SDL: Add back proper checks for GLFW/SDL switch

This commit is contained in:
alexytomi
2025-09-14 01:47:34 +08:00
parent d4fa037256
commit 214b5a5204
3 changed files with 7 additions and 6 deletions

View File

@@ -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.

View File

@@ -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);

View File

@@ -14,7 +14,7 @@
</Preference>
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:defaultValue="true"
android:icon="@drawable/ic_menu_custom_controls"
android:key="gamepadPassthru"
android:summary="@string/mcl_gamepad_SDL_subtitle"