From a8227ad9b1430d8891f1c6221374dadd94a3a534 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 21 Jul 2015 21:28:32 -0500 Subject: [PATCH 1/4] Add Wiimote support to the Android backend. Not actually wired up to the Android UI for configuration. --- .../app/src/main/assets/WiimoteNew.ini | 84 +++++++++++++++++++ .../dolphinemu/dolphinemu/NativeLibrary.java | 55 +++++++----- .../dolphinemu/services/AssetCopyService.java | 1 + .../Core/DolphinWX/Android/ButtonManager.cpp | 48 ++++++++++- Source/Core/DolphinWX/Android/ButtonManager.h | 13 +++ .../ControllerInterface/Android/Android.cpp | 18 ++++ 6 files changed, 193 insertions(+), 26 deletions(-) create mode 100644 Source/Android/app/src/main/assets/WiimoteNew.ini diff --git a/Source/Android/app/src/main/assets/WiimoteNew.ini b/Source/Android/app/src/main/assets/WiimoteNew.ini new file mode 100644 index 0000000000..41082fd8de --- /dev/null +++ b/Source/Android/app/src/main/assets/WiimoteNew.ini @@ -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 diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index 9fcdbe8cd1..db387344bd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -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; } /** diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java index 1f6f94bc8a..558a34be37 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java @@ -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. diff --git a/Source/Core/DolphinWX/Android/ButtonManager.cpp b/Source/Core/DolphinWX/Android/ButtonManager.cpp index c48ecc11a1..5b5d8242fa 100644 --- a/Source/Core/DolphinWX/Android/ButtonManager.cpp +++ b/Source/Core/DolphinWX/Android/ButtonManager.cpp @@ -14,6 +14,7 @@ namespace ButtonManager const std::string touchScreenKey = "Touchscreen"; std::unordered_map m_controllers; std::vector 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 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; diff --git a/Source/Core/DolphinWX/Android/ButtonManager.h b/Source/Core/DolphinWX/Android/ButtonManager.h index 12151fab03..672699cb49 100644 --- a/Source/Core/DolphinWX/Android/ButtonManager.h +++ b/Source/Core/DolphinWX/Android/ButtonManager.h @@ -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 { diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index b0539b520f..24c6efebe9 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -17,6 +17,10 @@ void Init( std::vector& 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 @@ -37,6 +41,7 @@ int Touchscreen::GetId() const 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 From 008ac0eeb09ffb3528b1df875cee9076648b5a5a Mon Sep 17 00:00:00 2001 From: sigmabeta Date: Thu, 23 Jul 2015 21:58:32 -0400 Subject: [PATCH 2/4] Android: Add UI for Wiimote configuration. --- .../app/src/main/res/xml/preferences.xml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Source/Android/app/src/main/res/xml/preferences.xml b/Source/Android/app/src/main/res/xml/preferences.xml index c91f77ab96..70352a7acf 100644 --- a/Source/Android/app/src/main/res/xml/preferences.xml +++ b/Source/Android/app/src/main/res/xml/preferences.xml @@ -569,6 +569,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Date: Thu, 23 Jul 2015 23:17:16 -0400 Subject: [PATCH 3/4] Android: Wiimote UI Fixup --- .../app/src/main/res/xml/preferences.xml | 24 +++++++++---------- .../ControllerInterface/Android/Android.cpp | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Android/app/src/main/res/xml/preferences.xml b/Source/Android/app/src/main/res/xml/preferences.xml index 70352a7acf..97dacb147e 100644 --- a/Source/Android/app/src/main/res/xml/preferences.xml +++ b/Source/Android/app/src/main/res/xml/preferences.xml @@ -575,7 +575,7 @@ android:title="@string/wiimote_bindings"> diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index 24c6efebe9..7cf0f628bd 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -36,7 +36,7 @@ std::string Touchscreen::GetSource() const int Touchscreen::GetId() const { - return 0; + return _padID; } Touchscreen::Touchscreen(int padID) : _padID(padID) From a8aa19f1fa146fbe6682dd70ab549fd1e5597a56 Mon Sep 17 00:00:00 2001 From: sigmabeta Date: Sat, 25 Jul 2015 11:10:46 -0400 Subject: [PATCH 4/4] Android: Implement UI for configuration of all 4 Wiimotes. --- .../app/src/main/res/xml/preferences.xml | 228 ++++++++++++++++++ 1 file changed, 228 insertions(+) diff --git a/Source/Android/app/src/main/res/xml/preferences.xml b/Source/Android/app/src/main/res/xml/preferences.xml index 97dacb147e..b4b5efd365 100644 --- a/Source/Android/app/src/main/res/xml/preferences.xml +++ b/Source/Android/app/src/main/res/xml/preferences.xml @@ -650,6 +650,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +