[Android] Fix a bunch of input bugs.

Looking at the old code for the ButtonManager was a brainfsck. This fixes a ton of bugs I kept uncovering as I was moving along.

Fixes the gamepad configuration file being incorrect.
No longer treats touchscreen in a special way. Ends up as a regular device with a "Touchscreen" device name.
Was incorrectly converting a index from integer to ButtonType. Wouldn't work due to the addition of some unused(in JNI) enumerators in ButtonType.
Fixes an issue where a map had a key as an axis which was causing its binding to be overwritten for every axis that was used twice (eg main stick left and right);
Fixes Triggers not working at all.
Fixes DPad not working at all.
Fixes C-Stick only half working.
Removes touch screen specific nativelibrary types onTouchAxisEvent and onTouchEvent.

Adds a configuration version configuration option. Allows easy configuration overwriting if the options need to be changed during updating.

Supersedes github PR #291.
This commit is contained in:
Ryan Houdek 2014-04-23 03:49:25 -05:00
parent 9f12d02328
commit e1bbda1e18
9 changed files with 138 additions and 132 deletions

View File

@ -12,14 +12,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14` Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000 Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15` C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 16` C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 17` C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 18` C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000 C-Stick/Modifier/Range = 50.000000
Triggers/L = `Button 18` Triggers/L = `Axis 20`
Triggers/R = `Button 19` Triggers/R = `Axis 21`
D-Pad/Up = `Button 6` D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7` D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8` D-Pad/Left = `Button 8`
@ -38,14 +38,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14` Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000 Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15` C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 16` C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 17` C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 18` C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000 C-Stick/Modifier/Range = 50.000000
Triggers/L = `Axis 18` Triggers/L = `Axis 20`
Triggers/R = `Axis 19` Triggers/R = `Axis 21`
D-Pad/Up = `Button 6` D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7` D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8` D-Pad/Left = `Button 8`
@ -64,14 +64,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14` Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000 Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15` C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 16` C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 17` C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 18` C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000 C-Stick/Modifier/Range = 50.000000
Triggers/L = `Axis 18` Triggers/L = `Axis 20`
Triggers/R = `Axis 19` Triggers/R = `Axis 21`
D-Pad/Up = `Button 6` D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7` D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8` D-Pad/Left = `Button 8`
@ -90,14 +90,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14` Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000 Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15` C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 16` C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 17` C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 18` C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000 C-Stick/Modifier/Range = 50.000000
Triggers/L = `Axis 18` Triggers/L = `Axis 20`
Triggers/R = `Axis 19` Triggers/R = `Axis 21`
D-Pad/Up = `Button 6` D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7` D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8` D-Pad/Left = `Button 8`

View File

@ -69,7 +69,6 @@ public final class DolphinEmulator extends Activity
if(!file.exists()) if(!file.exists())
{ {
NativeLibrary.CreateUserFolders(); NativeLibrary.CreateUserFolders();
CopyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini");
CopyAsset("Dolphin.ini", ConfigDir + File.separator + "Dolphin.ini"); CopyAsset("Dolphin.ini", ConfigDir + File.separator + "Dolphin.ini");
CopyAsset("dsp_coef.bin", GCDir + File.separator + "dsp_coef.bin"); CopyAsset("dsp_coef.bin", GCDir + File.separator + "dsp_coef.bin");
CopyAsset("dsp_rom.bin", GCDir + File.separator + "dsp_rom.bin"); CopyAsset("dsp_rom.bin", GCDir + File.separator + "dsp_rom.bin");
@ -77,6 +76,10 @@ public final class DolphinEmulator extends Activity
CopyAsset("font_sjis.bin", GCDir + File.separator + "font_sjis.bin"); CopyAsset("font_sjis.bin", GCDir + File.separator + "font_sjis.bin");
} }
// 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");
// Load the configuration keys set in the Dolphin ini and gfx ini files // Load the configuration keys set in the Dolphin ini and gfx ini files
// into the application's shared preferences. // into the application's shared preferences.
UserPreferences.LoadIniToPrefs(this); UserPreferences.LoadIniToPrefs(this);

View File

@ -54,23 +54,9 @@ public final class NativeLibrary
} }
/** /**
* Handles touch events. * Default touchscreen device
*
* @param padID Identifier for which GCpad 0-3,
* @param Button Key code identifying which button was pressed,
* @param Action Mask for the action being performed.
*/ */
public static native void onTouchEvent(int padID, int Button, int Action); public static final String TouchScreenDevice = "Touchscreen";
/**
* Handles axis-related touch events.
*
* @param padID Identifier for which GCpad 0-3,
* @param Axis Axis ID for the type of axis being altered. (Example: Main stick up, down, left, right, etc),
* @param force How 'far down' the joystick is pushed down. 0.0f indicates center (or no force),
* 1.0f indicates max force (or joystick pushed all the way down in any arbitrary direction).
*/
public static native void onTouchAxisEvent(int padID, int Axis, float force);
/** /**
* Handles button press events for a gamepad. * Handles button press events for a gamepad.

View File

@ -290,10 +290,10 @@ public final class EmulationActivity extends Activity
} }
// Normal key events. // Normal key events.
action = 0; action = NativeLibrary.ButtonState.PRESSED;
break; break;
case KeyEvent.ACTION_UP: case KeyEvent.ACTION_UP:
action = 1; action = NativeLibrary.ButtonState.RELEASED;
break; break;
default: default:
return false; return false;

View File

@ -123,14 +123,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
if (button.getBounds().contains((int)event.getX(), (int)event.getY())) if (button.getBounds().contains((int)event.getX(), (int)event.getY()))
{ {
NativeLibrary.onTouchEvent(0, button.getId(), buttonState); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), buttonState);
} }
else else
{ {
// Because the above code only changes the state for the button that is being touched, sliding off the // Because the above code only changes the state for the button that is being touched, sliding off the
// button does not allow for it to be released. Release the button as soon as the touch coordinates leave // button does not allow for it to be released. Release the button as soon as the touch coordinates leave
// the button bounds. // the button bounds.
NativeLibrary.onTouchEvent(0, button.getId(), ButtonState.RELEASED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED);
} }
} }
@ -142,7 +142,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
float[] axises = joystick.getAxisValues(); float[] axises = joystick.getAxisValues();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
NativeLibrary.onTouchAxisEvent(0, axisIDs[i], axises[i]); NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice, axisIDs[i], axises[i]);
} }
return true; return true;

View File

@ -9,11 +9,9 @@
namespace ButtonManager namespace ButtonManager
{ {
// Pair key is padID, BUTTONTYPE const std::string touchScreenKey = "Touchscreen";
std::map<std::pair<int, int>, Button*> m_buttons;
std::map<std::pair<int, int>, Axis*> m_axises;
std::unordered_map<std::string, InputDevice*> m_controllers; std::unordered_map<std::string, InputDevice*> m_controllers;
const char* configStrings[] = { std::vector<std::string> configStrings = {
"InputA", "InputA",
"InputB", "InputB",
"InputStart", "InputStart",
@ -35,7 +33,28 @@ namespace ButtonManager
"InputL", "InputL",
"InputR" "InputR"
}; };
const int configStringNum = 20; std::vector<ButtonType> configTypes = {
BUTTON_A,
BUTTON_B,
BUTTON_START,
BUTTON_X,
BUTTON_Y,
BUTTON_Z,
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
STICK_MAIN_UP,
STICK_MAIN_DOWN,
STICK_MAIN_LEFT,
STICK_MAIN_RIGHT,
STICK_C_UP,
STICK_C_DOWN,
STICK_C_LEFT,
STICK_C_RIGHT,
TRIGGER_L,
TRIGGER_R
};
void AddBind(std::string dev, sBind *bind) void AddBind(std::string dev, sBind *bind)
{ {
@ -51,35 +70,35 @@ namespace ButtonManager
void Init() void Init()
{ {
// Initialize our touchscreen buttons // Initialize our touchScreenKey buttons
for (int a = 0; a < 4; ++a) for (int a = 0; a < 4; ++a)
{ {
m_buttons[std::make_pair(a, BUTTON_A)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_A, BIND_BUTTON, BUTTON_A, 1.0f));
m_buttons[std::make_pair(a, BUTTON_B)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_B, BIND_BUTTON, BUTTON_B, 1.0f));
m_buttons[std::make_pair(a, BUTTON_START)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_START, BIND_BUTTON, BUTTON_START, 1.0f));
m_buttons[std::make_pair(a, BUTTON_X)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_X, BIND_BUTTON, BUTTON_X, 1.0f));
m_buttons[std::make_pair(a, BUTTON_Y)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_Y, BIND_BUTTON, BUTTON_Y, 1.0f));
m_buttons[std::make_pair(a, BUTTON_Z)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_Z, BIND_BUTTON, BUTTON_Z, 1.0f));
m_buttons[std::make_pair(a, BUTTON_UP)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_UP, BIND_BUTTON, BUTTON_UP, 1.0f));
m_buttons[std::make_pair(a, BUTTON_DOWN)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_DOWN, BIND_BUTTON, BUTTON_DOWN, 1.0f));
m_buttons[std::make_pair(a, BUTTON_LEFT)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_LEFT, BIND_BUTTON, BUTTON_LEFT, 1.0f));
m_buttons[std::make_pair(a, BUTTON_RIGHT)] = new Button(); AddBind(touchScreenKey, new sBind(a, BUTTON_RIGHT, BIND_BUTTON, BUTTON_RIGHT, 1.0f));
m_axises[std::make_pair(a, STICK_MAIN_UP)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_MAIN_UP, BIND_AXIS, STICK_MAIN_UP, -1.0f));
m_axises[std::make_pair(a, STICK_MAIN_DOWN)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_MAIN_DOWN, BIND_AXIS, STICK_MAIN_DOWN, 1.0f));
m_axises[std::make_pair(a, STICK_MAIN_LEFT)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_MAIN_LEFT, BIND_AXIS, STICK_MAIN_LEFT, -1.0f));
m_axises[std::make_pair(a, STICK_MAIN_RIGHT)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_MAIN_RIGHT, BIND_AXIS, STICK_MAIN_RIGHT, 1.0f));
m_axises[std::make_pair(a, STICK_C_UP)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_C_UP, BIND_AXIS, STICK_C_UP, -1.0f));
m_axises[std::make_pair(a, STICK_C_DOWN)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_C_DOWN, BIND_AXIS, STICK_C_DOWN, 1.0f));
m_axises[std::make_pair(a, STICK_C_LEFT)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_C_LEFT, BIND_AXIS, STICK_C_LEFT, -1.0f));
m_axises[std::make_pair(a, STICK_C_RIGHT)] = new Axis(); AddBind(touchScreenKey, new sBind(a, STICK_C_RIGHT, BIND_AXIS, STICK_C_RIGHT, 1.0f));
m_buttons[std::make_pair(a, TRIGGER_L)] = new Button(); AddBind(touchScreenKey, new sBind(a, TRIGGER_L, BIND_AXIS, TRIGGER_L, 1.0f));
m_buttons[std::make_pair(a, TRIGGER_R)] = new Button(); AddBind(touchScreenKey, new sBind(a, TRIGGER_R, BIND_AXIS, TRIGGER_R, 1.0f));
} }
// Init our controller bindings // Init our controller bindings
IniFile ini; IniFile ini;
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini")); ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini"));
for (int a = 0; a < configStringNum; ++a) for (u32 a = 0; a < configStrings.size(); ++a)
{ {
for (int padID = 0; padID < 4; ++padID) for (int padID = 0; padID < 4; ++padID)
{ {
@ -89,7 +108,7 @@ namespace ButtonManager
int bindnum; int bindnum;
char dev[128]; char dev[128];
bool hasbind = false; bool hasbind = false;
char modifier = 0; char modifier = '+';
std::string value; std::string value;
ini.Get("Android", config.str(), &value, "None"); ini.Get("Android", config.str(), &value, "None");
if (value == "None") if (value == "None")
@ -107,14 +126,14 @@ namespace ButtonManager
sscanf(value.c_str(), "Device '%[^\']'-Button %d", dev, &bindnum); sscanf(value.c_str(), "Device '%[^\']'-Button %d", dev, &bindnum);
} }
if (hasbind) if (hasbind)
AddBind(std::string(dev), new sBind(padID, (ButtonType)a, type, bindnum, modifier == '-' ? -1.0f : 1.0f)); AddBind(std::string(dev), new sBind(padID, configTypes[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f));
} }
} }
} }
bool GetButtonPressed(int padID, ButtonType button) bool GetButtonPressed(int padID, ButtonType button)
{ {
bool pressed = m_buttons[std::make_pair(padID, button)]->Pressed(); bool pressed = m_controllers[touchScreenKey]->ButtonValue(padID, button);
for (const auto& ctrl : m_controllers) for (const auto& ctrl : m_controllers)
pressed |= ctrl.second->ButtonValue(padID, button); pressed |= ctrl.second->ButtonValue(padID, button);
@ -123,19 +142,17 @@ namespace ButtonManager
} }
float GetAxisValue(int padID, ButtonType axis) float GetAxisValue(int padID, ButtonType axis)
{ {
float value = m_axises[std::make_pair(padID, axis)]->AxisValue(); float value = m_controllers[touchScreenKey]->AxisValue(padID, axis);
auto it = m_controllers.begin(); if (value == 0.0f)
if (it == m_controllers.end()) {
return value; for (const auto& ctrl : m_controllers)
return value != 0.0f ? value : it->second->AxisValue(padID, axis); {
} value = ctrl.second->AxisValue(padID, axis);
void TouchEvent(int padID, ButtonType button, int action) if (value != 0.0f)
{ return value;
m_buttons[std::make_pair(padID, button)]->SetState(action ? BUTTON_PRESSED : BUTTON_RELEASED); }
} }
void TouchAxisEvent(int padID, ButtonType axis, float value) return value;
{
m_axises[std::make_pair(padID, axis)]->SetValue(value);
} }
void GamepadEvent(std::string dev, int button, int action) void GamepadEvent(std::string dev, int button, int action)
{ {
@ -161,50 +178,58 @@ namespace ButtonManager
} }
void Shutdown() void Shutdown()
{ {
for (const auto& button : m_buttons)
delete button.second;
for (const auto& controller : m_controllers) for (const auto& controller : m_controllers)
delete controller.second; delete controller.second;
m_controllers.clear(); m_controllers.clear();
m_buttons.clear();
} }
// InputDevice // InputDevice
void InputDevice::PressEvent(int button, int action) void InputDevice::PressEvent(int button, int action)
{ {
if (_inputbinds.find(button) == _inputbinds.end()) for (const auto& binding : _inputbinds)
return; {
_buttons[_inputbinds[button]->_buttontype] = action == 0 ? true : false; if (binding.second->_bind == button)
{
if (binding.second->_bindtype == BIND_BUTTON)
_buttons[binding.second->_buttontype] = action == BUTTON_PRESSED ? true : false;
else
_axises[binding.second->_buttontype] = action == BUTTON_PRESSED ? 1.0f : 0.0f;
}
}
} }
void InputDevice::AxisEvent(int axis, float value) void InputDevice::AxisEvent(int axis, float value)
{ {
if (_inputbinds.find(axis) == _inputbinds.end()) for (const auto& binding : _inputbinds)
return; {
_axises[_inputbinds[axis]->_buttontype] = value; if (binding.second->_bind == axis)
{
if (binding.second->_bindtype == BIND_AXIS)
_axises[binding.second->_buttontype] = value;
else
_buttons[binding.second->_buttontype] = value > 0.5f ? true : false;
}
}
} }
bool InputDevice::ButtonValue(int padID, ButtonType button) bool InputDevice::ButtonValue(int padID, ButtonType button)
{ {
auto it = _binds.find(button); const auto& binding = _inputbinds.find(std::make_pair(padID, button));
if (it == _binds.end()) if (binding == _inputbinds.end())
return false; return false;
if (it->second->_padID != padID)
return false; if (binding->second->_bindtype == BIND_BUTTON)
if (it->second->_bindtype == BIND_BUTTON) return _buttons[binding->second->_buttontype];
return _buttons[it->second->_buttontype];
else else
return AxisValue(padID, button); return (_axises[binding->second->_buttontype] * binding->second->_neg) > 0.5f;
} }
float InputDevice::AxisValue(int padID, ButtonType axis) float InputDevice::AxisValue(int padID, ButtonType axis)
{ {
auto it = _binds.find(axis); const auto& binding = _inputbinds.find(std::make_pair(padID, axis));
if (it == _binds.end()) if (binding == _inputbinds.end())
return 0.0f; return 0.0f;
if (it->second->_padID != padID)
return 0.0f;
if (it->second->_bindtype == BIND_BUTTON)
return ButtonValue(padID, axis);
else
return _axises[it->second->_buttontype] * it->second->_neg;
}
if (binding->second->_bindtype == BIND_AXIS)
return _axises[binding->second->_buttontype] * binding->second->_neg;
else
return _buttons[binding->second->_buttontype] == BUTTON_PRESSED ? 1.0f : 0.0f;
}
} }

View File

@ -86,17 +86,19 @@ namespace ButtonManager
const std::string _dev; const std::string _dev;
std::map<ButtonType, bool> _buttons; std::map<ButtonType, bool> _buttons;
std::map<ButtonType, float> _axises; std::map<ButtonType, float> _axises;
std::map<ButtonType, sBind*> _binds;
std::map<int, sBind*> _inputbinds; // Key is padID and ButtonType
std::map<std::pair<int, ButtonType>, sBind*> _inputbinds;
public: public:
InputDevice(std::string dev) InputDevice(std::string dev)
: _dev(dev) {} : _dev(dev) {}
~InputDevice() ~InputDevice()
{ {
for (const auto& bind : _binds) for (const auto& bind : _inputbinds)
delete bind.second; delete bind.second;
_inputbinds.clear();
} }
void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; _inputbinds[bind->_bind] = bind; } void AddBind(sBind *bind) { _inputbinds[std::make_pair(bind->_padID, bind->_buttontype)] = bind; }
void PressEvent(int button, int action); void PressEvent(int button, int action);
void AxisEvent(int axis, float value); void AxisEvent(int axis, float value);
bool ButtonValue(int padID, ButtonType button); bool ButtonValue(int padID, ButtonType button);
@ -106,8 +108,6 @@ namespace ButtonManager
void Init(); void Init();
bool GetButtonPressed(int padID, ButtonType button); bool GetButtonPressed(int padID, ButtonType button);
float GetAxisValue(int padID, ButtonType axis); float GetAxisValue(int padID, ButtonType axis);
void TouchEvent(int padID, ButtonType button, int action);
void TouchAxisEvent(int padID, ButtonType axis, float value);
void GamepadEvent(std::string dev, int button, int action); void GamepadEvent(std::string dev, int button, int action);
void GamepadAxisEvent(std::string dev, int axis, float value); void GamepadAxisEvent(std::string dev, int axis, float value);
void Shutdown(); void Shutdown();

View File

@ -241,14 +241,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulatio
Core::Stop(); Core::Stop();
updateMainFrameEvent.Set(); // Kick the waiting event updateMainFrameEvent.Set(); // Kick the waiting event
} }
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onTouchEvent(JNIEnv *env, jobject obj, jint padID, jint Button, jint Action)
{
ButtonManager::TouchEvent(padID, (ButtonManager::ButtonType)Button, Action);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onTouchAxisEvent(JNIEnv *env, jobject obj, jint padID, jint Button, jfloat Action)
{
ButtonManager::TouchAxisEvent(padID, (ButtonManager::ButtonType)Button, Action);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Button, jint Action) JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Button, jint Action)
{ {
ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action); ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);

View File

@ -46,10 +46,10 @@ Touchscreen::Touchscreen(int padID)
AddInput(new Button(_padID, ButtonManager::BUTTON_DOWN)); AddInput(new Button(_padID, ButtonManager::BUTTON_DOWN));
AddInput(new Button(_padID, ButtonManager::BUTTON_LEFT)); AddInput(new Button(_padID, ButtonManager::BUTTON_LEFT));
AddInput(new Button(_padID, ButtonManager::BUTTON_RIGHT)); AddInput(new Button(_padID, ButtonManager::BUTTON_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_LEFT, -1.0f), new Axis(_padID, ButtonManager::STICK_MAIN_RIGHT)); AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_LEFT), new Axis(_padID, ButtonManager::STICK_MAIN_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_UP, -1.0f), new Axis(_padID, ButtonManager::STICK_MAIN_DOWN)); AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_UP), new Axis(_padID, ButtonManager::STICK_MAIN_DOWN));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_UP, -1.0f), new Axis(_padID, ButtonManager::STICK_C_DOWN)); AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_LEFT), new Axis(_padID, ButtonManager::STICK_C_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_LEFT, -1.0f), new Axis(_padID, ButtonManager::STICK_C_RIGHT)); 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_L), new Axis(_padID, ButtonManager::TRIGGER_L));
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), new Axis(_padID, ButtonManager::TRIGGER_R)); AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), new Axis(_padID, ButtonManager::TRIGGER_R));
} }