Merge pull request #2773 from sigmabeta/android_wiimote_main

Android: Add Wiimote support, including configuration UI.
This commit is contained in:
Ryan Houdek 2015-07-26 16:54:45 -05:00
commit e805e05ff5
7 changed files with 505 additions and 27 deletions

View File

@ -0,0 +1,84 @@
[Wiimote1]
Device = Android/4/Touchscreen
Buttons/A = `Button 22`
Buttons/B = `Button 23`
Buttons/1 = `Button 27`
Buttons/2 = `Button 28`
Buttons/- = `Button 24`
Buttons/+ = `Button 25`
Buttons/Home = `Button 26`
IR/Up =
IR/Down =
IR/Left =
IR/Right =
Shake/X =
Shake/Y =
Shake/Z =
D-Pad/Up = `Button 29`
D-Pad/Down = `Button 30`
D-Pad/Left = `Button 31`
D-Pad/Right = `Button 32`
Source = 1
[Wiimote2]
Device = Android/5/Touchscreen
Buttons/A = `Button 22`
Buttons/B = `Button 23`
Buttons/1 = `Button 27`
Buttons/2 = `Button 28`
Buttons/- = `Button 24`
Buttons/+ = `Button 25`
Buttons/Home = `Button 26`
IR/Up =
IR/Down =
IR/Left =
IR/Right =
Shake/X =
Shake/Y =
Shake/Z =
D-Pad/Up = `Button 29`
D-Pad/Down = `Button 30`
D-Pad/Left = `Button 31`
D-Pad/Right = `Button 32`
Source = 1
[Wiimote3]
Device = Android/6/Touchscreen
Buttons/A = `Button 22`
Buttons/B = `Button 23`
Buttons/1 = `Button 27`
Buttons/2 = `Button 28`
Buttons/- = `Button 24`
Buttons/+ = `Button 25`
Buttons/Home = `Button 26`
IR/Up =
IR/Down =
IR/Left =
IR/Right =
Shake/X =
Shake/Y =
Shake/Z =
D-Pad/Up = `Button 29`
D-Pad/Down = `Button 30`
D-Pad/Left = `Button 31`
D-Pad/Right = `Button 32`
Source = 1
[Wiimote4]
Device = Android/7/Touchscreen
Buttons/A = `Button 22`
Buttons/B = `Button 23`
Buttons/1 = `Button 27`
Buttons/2 = `Button 28`
Buttons/- = `Button 24`
Buttons/+ = `Button 25`
Buttons/Home = `Button 26`
IR/Up =
IR/Down =
IR/Left =
IR/Right =
Shake/X =
Shake/Y =
Shake/Z =
D-Pad/Up = `Button 29`
D-Pad/Down = `Button 30`
D-Pad/Left = `Button 31`
D-Pad/Right = `Button 32`
Source = 1

View File

@ -25,28 +25,39 @@ public final class NativeLibrary
*/
public static final class ButtonType
{
public static final int BUTTON_A = 0;
public static final int BUTTON_B = 1;
public static final int BUTTON_START = 2;
public static final int BUTTON_X = 3;
public static final int BUTTON_Y = 4;
public static final int BUTTON_Z = 5;
public static final int BUTTON_UP = 6;
public static final int BUTTON_DOWN = 7;
public static final int BUTTON_LEFT = 8;
public static final int BUTTON_RIGHT = 9;
public static final int STICK_MAIN = 10;
public static final int STICK_MAIN_UP = 11;
public static final int STICK_MAIN_DOWN = 12;
public static final int STICK_MAIN_LEFT = 13;
public static final int STICK_MAIN_RIGHT = 14;
public static final int STICK_C = 15;
public static final int STICK_C_UP = 16;
public static final int STICK_C_DOWN = 17;
public static final int STICK_C_LEFT = 18;
public static final int STICK_C_RIGHT = 19;
public static final int TRIGGER_L = 20;
public static final int TRIGGER_R = 21;
public static final int BUTTON_A = 0;
public static final int BUTTON_B = 1;
public static final int BUTTON_START = 2;
public static final int BUTTON_X = 3;
public static final int BUTTON_Y = 4;
public static final int BUTTON_Z = 5;
public static final int BUTTON_UP = 6;
public static final int BUTTON_DOWN = 7;
public static final int BUTTON_LEFT = 8;
public static final int BUTTON_RIGHT = 9;
public static final int STICK_MAIN = 10;
public static final int STICK_MAIN_UP = 11;
public static final int STICK_MAIN_DOWN = 12;
public static final int STICK_MAIN_LEFT = 13;
public static final int STICK_MAIN_RIGHT = 14;
public static final int STICK_C = 15;
public static final int STICK_C_UP = 16;
public static final int STICK_C_DOWN = 17;
public static final int STICK_C_LEFT = 18;
public static final int STICK_C_RIGHT = 19;
public static final int TRIGGER_L = 20;
public static final int TRIGGER_R = 21;
public static final int WIIMOTE_BUTTON_A = 22;
public static final int WIIMOTE_BUTTON_B = 23;
public static final int WIIMOTE_BUTTON_MINUS = 24;
public static final int WIIMOTE_BUTTON_PLUS = 25;
public static final int WIIMOTE_BUTTON_HOME = 26;
public static final int WIIMOTE_BUTTON_1 = 27;
public static final int WIIMOTE_BUTTON_2 = 28;
public static final int WIIMOTE_UP = 29;
public static final int WIIMOTE_DOWN = 30;
public static final int WIIMOTE_LEFT = 31;
public static final int WIIMOTE_RIGHT = 32;
}
/**

View File

@ -61,6 +61,7 @@ public final class AssetCopyService extends IntentService
// Always copy over the GCPad config in case of change or corruption.
// Not a user configurable file.
copyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini");
copyAsset("WiimoteNew.ini", ConfigDir + File.separator + "WiimoteNew.ini");
// Load the configuration keys set in the Dolphin ini and gfx ini files
// into the application's shared preferences.

View File

@ -569,6 +569,317 @@
</PreferenceScreen>
</PreferenceScreen>
<!-- Wiimote Bindings -->
<PreferenceScreen
android:key="wiimote_bindings"
android:title="@string/wiimote_bindings">
<PreferenceScreen
android:key="wiimote_bindings_4"
android:title="@string/controller_0">
<CheckBoxPreference
android:key="enableWiimote1"
android:title="@string/enable_wiimote"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteA_4"
android:summary="%s"
android:title="@string/button_a"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteB_4"
android:summary="%s"
android:title="@string/button_b"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteMinus_4"
android:summary="%s"
android:title="@string/button_minus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimotePlus_4"
android:summary="%s"
android:title="@string/button_plus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteHome_4"
android:summary="%s"
android:title="@string/button_home"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="Wiimote1_4"
android:summary="%s"
android:title="@string/button_one"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="Wiimote2_4"
android:summary="%s"
android:title="@string/button_two"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteUp_4"
android:summary="%s"
android:title="@string/dpad_up"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteDown_4"
android:summary="%s"
android:title="@string/dpad_down"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteLeft_4"
android:summary="%s"
android:title="@string/dpad_left"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote1"
android:key="WiimoteRight_4"
android:summary="%s"
android:title="@string/dpad_right"/>
</PreferenceScreen>
<PreferenceScreen
android:key="wiimote_bindings_5"
android:title="@string/controller_1">
<CheckBoxPreference
android:key="enableWiimote2"
android:title="@string/enable_wiimote"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteA_5"
android:summary="%s"
android:title="@string/button_a"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteB_5"
android:summary="%s"
android:title="@string/button_b"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteMinus_5"
android:summary="%s"
android:title="@string/button_minus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimotePlus_5"
android:summary="%s"
android:title="@string/button_plus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteHome_5"
android:summary="%s"
android:title="@string/button_home"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="Wiimote2_5"
android:summary="%s"
android:title="@string/button_one"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="Wiimote2_5"
android:summary="%s"
android:title="@string/button_two"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteUp_5"
android:summary="%s"
android:title="@string/dpad_up"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteDown_5"
android:summary="%s"
android:title="@string/dpad_down"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteLeft_5"
android:summary="%s"
android:title="@string/dpad_left"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote2"
android:key="WiimoteRight_5"
android:summary="%s"
android:title="@string/dpad_right"/>
</PreferenceScreen>
<PreferenceScreen
android:key="wiimote_bindings_6"
android:title="@string/controller_2">
<CheckBoxPreference
android:key="enableWiimote3"
android:title="@string/enable_wiimote"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteA_6"
android:summary="%s"
android:title="@string/button_a"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteB_6"
android:summary="%s"
android:title="@string/button_b"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteMinus_6"
android:summary="%s"
android:title="@string/button_minus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimotePlus_6"
android:summary="%s"
android:title="@string/button_plus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteHome_6"
android:summary="%s"
android:title="@string/button_home"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="Wiimote3_6"
android:summary="%s"
android:title="@string/button_one"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="Wiimote2_6"
android:summary="%s"
android:title="@string/button_two"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteUp_6"
android:summary="%s"
android:title="@string/dpad_up"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteDown_6"
android:summary="%s"
android:title="@string/dpad_down"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteLeft_6"
android:summary="%s"
android:title="@string/dpad_left"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote3"
android:key="WiimoteRight_6"
android:summary="%s"
android:title="@string/dpad_right"/>
</PreferenceScreen>
<PreferenceScreen
android:key="wiimote_bindings_7"
android:title="@string/controller_3">
<CheckBoxPreference
android:key="enableWiimote4"
android:title="@string/enable_wiimote"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteA_7"
android:summary="%s"
android:title="@string/button_a"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteB_7"
android:summary="%s"
android:title="@string/button_b"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteMinus_7"
android:summary="%s"
android:title="@string/button_minus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimotePlus_7"
android:summary="%s"
android:title="@string/button_plus"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteHome_7"
android:summary="%s"
android:title="@string/button_home"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="Wiimote4_7"
android:summary="%s"
android:title="@string/button_one"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="Wiimote2_7"
android:summary="%s"
android:title="@string/button_two"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteUp_7"
android:summary="%s"
android:title="@string/dpad_up"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteDown_7"
android:summary="%s"
android:title="@string/dpad_down"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteLeft_7"
android:summary="%s"
android:title="@string/dpad_left"/>
<org.dolphinemu.dolphinemu.utils.InputBindingPreference
android:dependency="enableWiimote4"
android:key="WiimoteRight_7"
android:summary="%s"
android:title="@string/dpad_right"/>
</PreferenceScreen>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory

View File

@ -14,6 +14,7 @@ namespace ButtonManager
const std::string touchScreenKey = "Touchscreen";
std::unordered_map<std::string, InputDevice*> m_controllers;
std::vector<std::string> configStrings = {
// GC
"InputA",
"InputB",
"InputStart",
@ -33,9 +34,22 @@ namespace ButtonManager
"CStickLeft",
"CStickRight",
"InputL",
"InputR"
"InputR",
// Wiimote
"WiimoteA",
"WiimoteB",
"WiimoteMinus",
"WiimotePlus",
"WiimoteHome",
"Wiimote1",
"Wiimote2",
"WiimoteUp",
"WiimoteDown",
"WiimoteLeft",
"WiimoteRight",
};
std::vector<ButtonType> configTypes = {
// GC
BUTTON_A,
BUTTON_B,
BUTTON_START,
@ -55,7 +69,19 @@ namespace ButtonManager
STICK_C_LEFT,
STICK_C_RIGHT,
TRIGGER_L,
TRIGGER_R
TRIGGER_R,
// Wiimote
WIIMOTE_BUTTON_A,
WIIMOTE_BUTTON_B,
WIIMOTE_BUTTON_MINUS,
WIIMOTE_BUTTON_PLUS,
WIIMOTE_BUTTON_HOME,
WIIMOTE_BUTTON_1,
WIIMOTE_BUTTON_2,
WIIMOTE_UP,
WIIMOTE_DOWN,
WIIMOTE_LEFT,
WIIMOTE_RIGHT,
};
static void AddBind(const std::string& dev, sBind *bind)
@ -73,8 +99,9 @@ namespace ButtonManager
void Init()
{
// Initialize our touchScreenKey buttons
for (int a = 0; a < 4; ++a)
for (int a = 0; a < 8; ++a)
{
// GC
AddBind(touchScreenKey, new sBind(a, BUTTON_A, BIND_BUTTON, BUTTON_A, 1.0f));
AddBind(touchScreenKey, new sBind(a, BUTTON_B, BIND_BUTTON, BUTTON_B, 1.0f));
AddBind(touchScreenKey, new sBind(a, BUTTON_START, BIND_BUTTON, BUTTON_START, 1.0f));
@ -96,13 +123,26 @@ namespace ButtonManager
AddBind(touchScreenKey, new sBind(a, STICK_C_RIGHT, BIND_AXIS, STICK_C_RIGHT, 1.0f));
AddBind(touchScreenKey, new sBind(a, TRIGGER_L, BIND_AXIS, TRIGGER_L, 1.0f));
AddBind(touchScreenKey, new sBind(a, TRIGGER_R, BIND_AXIS, TRIGGER_R, 1.0f));
// Wiimote
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_A, BIND_BUTTON, WIIMOTE_BUTTON_A, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_B, BIND_BUTTON, WIIMOTE_BUTTON_B, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_MINUS, BIND_BUTTON, WIIMOTE_BUTTON_MINUS, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_PLUS, BIND_BUTTON, WIIMOTE_BUTTON_PLUS, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_HOME, BIND_BUTTON, WIIMOTE_BUTTON_HOME, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_1, BIND_BUTTON, WIIMOTE_BUTTON_1, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_BUTTON_2, BIND_BUTTON, WIIMOTE_BUTTON_2, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_UP, BIND_BUTTON, WIIMOTE_UP, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_DOWN, BIND_BUTTON, WIIMOTE_DOWN, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_LEFT, BIND_BUTTON, WIIMOTE_LEFT, 1.0f));
AddBind(touchScreenKey, new sBind(a, WIIMOTE_RIGHT, BIND_BUTTON, WIIMOTE_RIGHT, 1.0f));
}
// Init our controller bindings
IniFile ini;
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini"));
for (u32 a = 0; a < configStrings.size(); ++a)
{
for (int padID = 0; padID < 4; ++padID)
for (int padID = 0; padID < 8; ++padID)
{
std::ostringstream config;
config << configStrings[a] << "_" << padID;

View File

@ -11,6 +11,7 @@ namespace ButtonManager
{
enum ButtonType
{
// GC
BUTTON_A = 0,
BUTTON_B = 1,
BUTTON_START = 2,
@ -33,6 +34,18 @@ namespace ButtonManager
STICK_C_RIGHT = 19,
TRIGGER_L = 20,
TRIGGER_R = 21,
// Wiimote
WIIMOTE_BUTTON_A = 22,
WIIMOTE_BUTTON_B = 23,
WIIMOTE_BUTTON_MINUS = 24,
WIIMOTE_BUTTON_PLUS = 25,
WIIMOTE_BUTTON_HOME = 26,
WIIMOTE_BUTTON_1 = 27,
WIIMOTE_BUTTON_2 = 28,
WIIMOTE_UP = 29,
WIIMOTE_DOWN = 30,
WIIMOTE_LEFT = 31,
WIIMOTE_RIGHT = 32,
};
enum ButtonState
{

View File

@ -17,6 +17,10 @@ void Init( std::vector<Core::Device*>& devices )
devices.push_back(new Touchscreen(1));
devices.push_back(new Touchscreen(2));
devices.push_back(new Touchscreen(3));
devices.push_back(new Touchscreen(4));
devices.push_back(new Touchscreen(5));
devices.push_back(new Touchscreen(6));
devices.push_back(new Touchscreen(7));
}
// Touchscreens and stuff
@ -32,11 +36,12 @@ std::string Touchscreen::GetSource() const
int Touchscreen::GetId() const
{
return 0;
return _padID;
}
Touchscreen::Touchscreen(int padID)
: _padID(padID)
{
// GC
AddInput(new Button(_padID, ButtonManager::BUTTON_A));
AddInput(new Button(_padID, ButtonManager::BUTTON_B));
AddInput(new Button(_padID, ButtonManager::BUTTON_START));
@ -53,6 +58,19 @@ Touchscreen::Touchscreen(int padID)
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_UP), new Axis(_padID, ButtonManager::STICK_C_DOWN));
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_L), new Axis(_padID, ButtonManager::TRIGGER_L));
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), new Axis(_padID, ButtonManager::TRIGGER_R));
// Wiimote
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_A));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_B));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_MINUS));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_PLUS));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_HOME));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_1));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_2));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_UP));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_DOWN));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_LEFT));
AddInput(new Button(_padID, ButtonManager::WIIMOTE_RIGHT));
}
// Buttons and stuff