Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

input/input_ext.h: pad capabilities, mouse capture and the SDL hooks (the M1 contract)

Rafael Abud Ferreira8b9d2dc75110
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 30a5218..13f7f4a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,6 +115,11 @@ if(NOT MSVC)
target_compile_options(xcloud_appcore PRIVATE -Wall -Wextra -Wno-unused-parameter)
endif()
+# TEMPORARY (branch m1-core only): input/input_ext.h's functions until every
+# input backend defines them (branch m1-io). The integrator deletes this block,
+# src/input/input_ext_stub.cpp and each ${XC_INPUT_EXT_STUB} below.
+set(XC_INPUT_EXT_STUB src/input/input_ext_stub.cpp)
+
if(XCLOUD_PS5)
target_sources(xcloud_core PRIVATE src/platform/ps5/platform_ps5.cpp src/platform/ps5/libc_compat.c src/platform/ps5/net_probe.cpp src/platform/ps5/keyboard_ps5.cpp)
@@ -129,6 +134,7 @@ if(XCLOUD_PS5)
src/media/hw_decoder_ps5.cpp
src/input/controller_ps5.cpp
src/input/kbm_ps5.cpp
+ ${XC_INPUT_EXT_STUB}
)
target_include_directories(xcloud_app PRIVATE "${PS5_RADV}/include")
# The USB keyboard / mouse backend kept the warnings it had in xcloud_core.
@@ -157,6 +163,7 @@ else()
$<TARGET_OBJECTS:xcloud_appcore>
src/app/headless_main.cpp
src/app/shell_null.cpp
+ ${XC_INPUT_EXT_STUB}
)
target_link_libraries(psbox-headless PRIVATE xcloud_backends_null xcloud_stream xcloud_media xcloud_ui xc_ffmpeg
datachannel-static)
diff --git a/src/input/input_ext.h b/src/input/input_ext.h
new file mode 100644
index 0000000..36df3de
--- /dev/null
+++ b/src/input/input_ext.h
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+// Input features beyond the common controller state: what each pad can do
+// (the UI hides what it can't), the mouse held by the window during a game,
+// and the desktop (SDL3) backends' hooks for the shell, which owns the
+// window and the event loop. The PS5 and null backends implement the first
+// two as well.
+#pragma once
+
+union SDL_Event;
+struct SDL_Window;
+
+namespace xc::input {
+
+enum class PadKind { None, DualSense, DualShock4, Xbox, Switch, Generic };
+
+struct PadCaps {
+ PadKind kind = PadKind::None; // None: nothing in the slot
+ bool rumble = false;
+ bool triggerRumble = false; // Xbox impulse triggers or the DualSense's trigger vibration
+ bool adaptiveTriggers = false; // DualSense resistance / pulses
+ bool lightBar = false;
+ bool gyro = false;
+ bool touchpad = false;
+};
+
+// The pad in slot `index` (0..kMaxPads-1).
+PadCaps padCaps(int index);
+// What the connected pads can do between them, for Settings and the game
+// menu. On the PS5 it is always a DualSense's (the console's pads), so the
+// PS5 shows every option as before.
+PadCaps anyPadCaps();
+
+// The mouse held by the window (relative motion, no cursor) while a game
+// has the keyboard and mouse; let go in menus and when the window loses
+// focus. A no-op where there is no pointer to hold (PS5, null).
+void kbmSetCaptured(bool captured);
+
+// Desktop (SDL3) only: the shell calls these around its event loop.
+void sdlInputInit(SDL_Window* window);
+void sdlInputEvent(const SDL_Event& event);
+void sdlInputShutdown();
+
+} // namespace xc::input
diff --git a/src/input/input_ext_stub.cpp b/src/input/input_ext_stub.cpp
new file mode 100644
index 0000000..0d48a98
--- /dev/null
+++ b/src/input/input_ext_stub.cpp
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+// TEMPORARY (branch m1-core only): input/input_ext.h until the input
+// backends define it themselves (branch m1-io). A DualSense with every
+// feature in every slot, as the PS5 reports, so every screen shows what it
+// did before; the rest does nothing. The integrator deletes this file and
+// its ${XC_INPUT_EXT_STUB} references in CMakeLists.txt.
+#include "input/input_ext.h"
+
+namespace xc::input {
+
+PadCaps padCaps(int) {
+ PadCaps c;
+ c.kind = PadKind::DualSense;
+ c.rumble = c.triggerRumble = c.adaptiveTriggers = c.lightBar = c.gyro = c.touchpad = true;
+ return c;
+}
+PadCaps anyPadCaps() { return padCaps(0); }
+void kbmSetCaptured(bool) {}
+void sdlInputInit(SDL_Window*) {}
+void sdlInputEvent(const SDL_Event&) {}
+void sdlInputShutdown() {}
+
+} // namespace xc::input