diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 5a36bc60b..732773742 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -736,6 +736,20 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { return super.dispatchKeyEvent(event) } if (pcKeyboardOpen && event.device != null && PadBridge.isFromController(event.device)) return super.dispatchKeyEvent(event) + // Dolphin (PC) has no controller menu of its own: in a Dolphin game from the rail the guide + // button is its Toggle Fullscreen hotkey (Alt+Return, Dolphin's default) instead, which + // brings up Dolphin's window with its Config / Graphics / Stop buttons, and back again. + if (event.keyCode == KeyEvent.KEYCODE_BUTTON_MODE && guideIsDolphinFullscreen() && + event.device != null && PadBridge.isFromController(event.device) + ) { + if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0 && CompositorHost.isStarted) { + WaylandCompositor.nativeSendKey(KEY_LEFTALT, 1) + WaylandCompositor.nativeSendKey(KEY_ENTER, 1) + WaylandCompositor.nativeSendKey(KEY_ENTER, 0) + WaylandCompositor.nativeSendKey(KEY_LEFTALT, 0) + } + return true + } if (event.keyCode != KeyEvent.KEYCODE_BACK && padBridge?.onKeyEvent(event) == true) return true // A hardware keyboard, forwarded to the compositor's wl_keyboard. Back is left to the // activity, which opens the drawer. @@ -994,6 +1008,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { if (reset) secondScreenMode = SecondScreenMode.NONE } + private fun guideIsDolphinFullscreen(): Boolean = + SessionState.mode == SessionService.MODE_RUN && + SessionState.program?.substringAfterLast('/')?.startsWith("dolphin") == true + /** Touchpad on the desktop, direct in Steam, unless the drawer says otherwise. */ private fun usingTouchpad(): Boolean = when (SessionPrefs.touchMode(this)) { SessionPrefs.TOUCH_PAD -> true @@ -1191,6 +1209,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } companion object { + // evdev codes (linux/input-event-codes.h) for the Alt+Return sent to Dolphin. + private const val KEY_LEFTALT = 56 + private const val KEY_ENTER = 28 private const val TAG = "SessionActivity" private const val BACK_DOUBLE_PRESS_TIMEOUT_MS = 500L private const val DRAWER_HAT_THRESHOLD = 0.5f diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt index 0bc6655d9..fd5e78639 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -219,13 +219,16 @@ object Library { "armsx2" -> listOf("-batch", "-bigpicture", "-fullscreen", "--", guestPath) // DuckStation shares PCSX2's flags (src/duckstation-qt/qthost.cpp): the same launch and exit. "duckstation" -> listOf("-batch", "-bigpicture", "-fullscreen", "--", guestPath) - // Dolphin: full screen, and gone when the game stops (-b), without its "stop the emulation?" + // Dolphin: full screen, drawn inside its own main window, without its "stop the emulation?" // question; no warning boxes either, which wait for a click a controller cannot give - // (they still go to Dolphin's log). -C sets a Dolphin.ini value for this run only, so - // Dolphin started from the desktop keeps its window and its warnings. + // (they still go to Dolphin's log). The guide button toggles full screen (SessionActivity), + // which shows Dolphin's window and its settings - so no -b, which hides that window. + // Closing Dolphin ends the session. -C sets a Dolphin.ini value for this run only, so + // Dolphin started from the desktop keeps its own window and its warnings. "dolphin" -> listOf( - "-b", "-C", "Dolphin.Display.Fullscreen=True", "-C", "Dolphin.Interface.ConfirmStop=False", - "-C", "Dolphin.Interface.UsePanicHandlers=False", "-e", guestPath, + "-C", "Dolphin.Display.Fullscreen=True", "-C", "Dolphin.Display.RenderToMain=True", + "-C", "Dolphin.Interface.ConfirmStop=False", "-C", "Dolphin.Interface.UsePanicHandlers=False", + "-e", guestPath, ) "cemu" -> listOf("-g", guestPath) else -> listOf(guestPath)