mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-24 04:35:03 +00:00
Android: handleMotionEvent() is checking for SOURCE_JOYSTICK. So don't handle DPAD GAMEPAD (see #5322, #2718)
This commit is contained in:
parent
1fc5dba3d5
commit
2df2da11f6
|
@ -255,23 +255,21 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMotionEvent(MotionEvent event) {
|
public boolean handleMotionEvent(MotionEvent event) {
|
||||||
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
|
int actionPointerIndex = event.getActionIndex();
|
||||||
int actionPointerIndex = event.getActionIndex();
|
int action = event.getActionMasked();
|
||||||
int action = event.getActionMasked();
|
if (action == MotionEvent.ACTION_MOVE) {
|
||||||
if (action == MotionEvent.ACTION_MOVE) {
|
SDLJoystick joystick = getJoystick(event.getDeviceId());
|
||||||
SDLJoystick joystick = getJoystick(event.getDeviceId());
|
if (joystick != null) {
|
||||||
if (joystick != null) {
|
for (int i = 0; i < joystick.axes.size(); i++) {
|
||||||
for (int i = 0; i < joystick.axes.size(); i++) {
|
InputDevice.MotionRange range = joystick.axes.get(i);
|
||||||
InputDevice.MotionRange range = joystick.axes.get(i);
|
/* Normalize the value to -1...1 */
|
||||||
/* Normalize the value to -1...1 */
|
float value = (event.getAxisValue(range.getAxis(), actionPointerIndex) - range.getMin()) / range.getRange() * 2.0f - 1.0f;
|
||||||
float value = (event.getAxisValue(range.getAxis(), actionPointerIndex) - range.getMin()) / range.getRange() * 2.0f - 1.0f;
|
SDLControllerManager.onNativeJoy(joystick.device_id, i, value);
|
||||||
SDLControllerManager.onNativeJoy(joystick.device_id, i, value);
|
}
|
||||||
}
|
for (int i = 0; i < joystick.hats.size() / 2; i++) {
|
||||||
for (int i = 0; i < joystick.hats.size() / 2; i++) {
|
int hatX = Math.round(event.getAxisValue(joystick.hats.get(2 * i).getAxis(), actionPointerIndex));
|
||||||
int hatX = Math.round(event.getAxisValue(joystick.hats.get(2 * i).getAxis(), actionPointerIndex));
|
int hatY = Math.round(event.getAxisValue(joystick.hats.get(2 * i + 1).getAxis(), actionPointerIndex));
|
||||||
int hatY = Math.round(event.getAxisValue(joystick.hats.get(2 * i + 1).getAxis(), actionPointerIndex));
|
SDLControllerManager.onNativeHat(joystick.device_id, i, hatX, hatY);
|
||||||
SDLControllerManager.onNativeHat(joystick.device_id, i, hatX, hatY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,8 +560,6 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||||
|
|
||||||
switch ( event.getSource() ) {
|
switch ( event.getSource() ) {
|
||||||
case InputDevice.SOURCE_JOYSTICK:
|
case InputDevice.SOURCE_JOYSTICK:
|
||||||
case InputDevice.SOURCE_GAMEPAD:
|
|
||||||
case InputDevice.SOURCE_DPAD:
|
|
||||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||||
|
|
||||||
case InputDevice.SOURCE_MOUSE:
|
case InputDevice.SOURCE_MOUSE:
|
||||||
|
@ -693,8 +689,6 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
|
||||||
|
|
||||||
switch ( event.getSource() ) {
|
switch ( event.getSource() ) {
|
||||||
case InputDevice.SOURCE_JOYSTICK:
|
case InputDevice.SOURCE_JOYSTICK:
|
||||||
case InputDevice.SOURCE_GAMEPAD:
|
|
||||||
case InputDevice.SOURCE_DPAD:
|
|
||||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||||
|
|
||||||
case InputDevice.SOURCE_MOUSE:
|
case InputDevice.SOURCE_MOUSE:
|
||||||
|
|
Loading…
Reference in a new issue