Skip to content

Commit

Permalink
Update SDLActivity.java (#2593)
Browse files Browse the repository at this point in the history
Possibly fix arrow keys error on android
  • Loading branch information
Pedrocasf authored May 22, 2024
1 parent 80657bd commit 1f23057
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions build/android/app/src/main/java/org/libsdl/app/SDLActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1327,19 +1327,6 @@ public static boolean handleKeyEvent(View v, int keyCode, KeyEvent event, InputC
// Furthermore, it's possible a game controller has SOURCE_KEYBOARD and
// SOURCE_JOYSTICK, while its key events arrive from the keyboard source
// So, retrieve the device itself and check all of its sources
if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) {
// Note that we process events with specific key codes here
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (SDLControllerManager.onNativePadDown(deviceId, keyCode) == 0) {
return true;
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (SDLControllerManager.onNativePadUp(deviceId, keyCode) == 0) {
return true;
}
}
}

if ((source & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (isTextInputEvent(event)) {
Expand All @@ -1356,7 +1343,18 @@ public static boolean handleKeyEvent(View v, int keyCode, KeyEvent event, InputC
return true;
}
}

if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) {
// Note that we process events with specific key codes here
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (SDLControllerManager.onNativePadDown(deviceId, keyCode) == 0) {
return true;
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (SDLControllerManager.onNativePadUp(deviceId, keyCode) == 0) {
return true;
}
}
}
if ((source & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
// on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
// they are ignored here because sending them as mouse input to SDL is messy
Expand Down

0 comments on commit 1f23057

Please sign in to comment.