From 214b5a52044ea2ccc212d35fd4e48e6cb0f97cdb Mon Sep 17 00:00:00 2001 From: alexytomi <60690056+alexytomi@users.noreply.github.com> Date: Sun, 14 Sep 2025 01:47:34 +0800 Subject: [PATCH] SDL: Add back proper checks for GLFW/SDL switch --- .../src/main/java/net/kdt/pojavlaunch/MainActivity.java | 2 +- .../java/net/kdt/pojavlaunch/MinecraftGLSurface.java | 9 +++++---- app_pojavlauncher/src/main/res/xml/pref_control.xml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MainActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MainActivity.java index d71f879a2..88c1395cd 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MainActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MainActivity.java @@ -112,7 +112,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (true) { + if (LauncherPreferences.PREF_GAMEPAD_SDL_PASSTHRU) { // TODO: Use lower level HID capture that needs a dialogue box from the user for the // app to fully take focus of the input devices. Might cause issues with older android // versions so we don't use that right now. Needs testing. diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java index 5afd165e5..067e5d893 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java @@ -220,11 +220,11 @@ public class MinecraftGLSurface extends View implements GrabListener, DirectGame } private void createGamepad(View contextView, InputDevice inputDevice) { - if(CallbackBridge.sGamepadDirectInput) { + if(CallbackBridge.sGamepadDirectInput && !LauncherPreferences.PREF_GAMEPAD_SDL_PASSTHRU) { mGamepadHandler = new DirectGamepad(); - }else { + }else if(!LauncherPreferences.PREF_GAMEPAD_SDL_PASSTHRU) { mGamepadHandler = new Gamepad(contextView, inputDevice, DefaultDataProvider.INSTANCE, true); - } + }else mGamepadHandler = (code, value) -> {}; // Ensure it isn't null while also not processing the events. } /** @@ -310,7 +310,8 @@ public class MinecraftGLSurface extends View implements GrabListener, DirectGame } // Android bundles in garbage KeyEvents for compatibility with old apps // that don't have controller code so we are, checking for em. - if (eventKeycode >= KeyEvent.KEYCODE_BUTTON_A && + if (LauncherPreferences.PREF_GAMEPAD_SDL_PASSTHRU && + eventKeycode >= KeyEvent.KEYCODE_BUTTON_A && eventKeycode <= KeyEvent.KEYCODE_BUTTON_MODE) { try { SDLActivity.handleKeyEvent(this, eventKeycode, event, null); diff --git a/app_pojavlauncher/src/main/res/xml/pref_control.xml b/app_pojavlauncher/src/main/res/xml/pref_control.xml index aa11475e7..bba8377fb 100644 --- a/app_pojavlauncher/src/main/res/xml/pref_control.xml +++ b/app_pojavlauncher/src/main/res/xml/pref_control.xml @@ -14,7 +14,7 @@