Skip to content

Native games: rsos-gamepad, the built-in controls as one SDL gamepad - #15

Open
KurdtNervanna wants to merge 3 commits into
PaddleStroke:mainfrom
KurdtNervanna:rsos-gamepad
Open

KurdtNervanna wants to merge 3 commits into
PaddleStroke:mainfrom
KurdtNervanna:rsos-gamepad

Conversation

@KurdtNervanna

Copy link
Copy Markdown
Contributor

The next feature after #14, as one PR (#11): rsos-gamepad, the RetroStone2's built-in controls as one SDL game controller for native games.

Depends on #14. This branch sits on top of #14's branch, so until #14 is merged the diff also shows its two commits. The change for review is the last commit, 4bd2608.

Why

The built-in controls are three input devices: the buttons, the shoulder buttons and the optional analog stick. Many SDL games read only one game controller, so they see only part of the controls. SDL doesn't take the stick for a joystick at all.

What it adds

rsos-gamepad (board/retrostone2/tools/rsos-gamepad.c, built in post-build.sh with -Wall -Wextra -Werror) reads the three devices and writes one standard virtual gamepad through uinput, named "RetroStoneOS Gamepad":

  • The face buttons go by position (bottom = SDL "a", left = "x"). L1/R1 are the shoulders, L2/R2 the triggers, and the optional C/Z the stick clicks.
  • The D-pad is hat 0.
  • The stick is the left stick, centred while it isn't fitted, as in the menu.

It doesn't grab the devices, so the menu still sees Select+Start.

A launch script starts it in the game's process group, so the menu stops it with the game. The script gives SDL the mapping and tells SDL to ignore the raw button device:

SDL_GAMECONTROLLERCONFIG="$(/usr/bin/rsos-gamepad --print-mapping)"
export SDL_GAMECONTROLLERCONFIG
export SDL_GAMECONTROLLER_IGNORE_DEVICES=0x0001/0x0001
/usr/bin/rsos-gamepad &

Kernel: CONFIG_INPUT_UINPUT=y in the RetroStone2 kernel fragment.

Docs: docs/native-games.md gets a section on the built-in controls.

Tests

  • It builds for the console with Buildroot's compiler and for the host with -Wall -Wextra -Werror. --print-mapping prints the SDL mapping line.
  • check-defconfigs and check-modes pass. shellcheck isn't installed here.

On hardware

Tested on a RetroStone2 Pro with fork builds 0.1.4.18 to 0.1.5.19, which ship this tool. Two SDL2 games built on a PC from the user's own ROMs use it for all their controls:

  • a Star Fox 64 port (Starship);
  • an Ocarina of Time port (Ship of Harkinian), both on libultraship with GLES2.

Buttons, triggers, D-pad and stick all reach the game. The menu stops the tool together with the game. No game or game data is part of this PR.

🤖 Generated with Claude Code

KurdtNervanna and others added 3 commits October 28, 2026 01:34
…ator

The system "native" (Native games, roms/native): one launch script per
game (.sh), run by /bin/sh in its own folder and its own process group
(host_launch_native), with the display, sound and pads handed over as for
a libretro game. HOME on /data (the root is read-only), SDL_VIDEODRIVER
kmsdrm, SDL_AUDIODRIVER alsa, RSOS_GAME_DIR, RSOS_LANG; output to
game.log. Select+Start held 1 s quits it (SIGTERM to the group, SIGKILL
after HANG_KILL_MS); sleep stops the group and turns the backlight off;
a power-off sends SIGTERM; the idle power-off waits while it runs (no
save state); an error exit is shown.

SDL2 (KMS/DRM, GLES2, ALSA) in the RetroStone2 configs.
docs/native-games.md; check-frontend 2a-2c (the launch and environment,
an error exit, the menu stopping: the group goes too).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check-transfer: sysmap.c lists every system of systems.c. Its alias is
"nativegames", not "ports": RetroPie's port scripts start RetroPie's own
emulators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RetroStone2's buttons, shoulder buttons and optional analog stick are
three input devices, and many SDL games read one game controller only (SDL
does not take the stick for a joystick at all). rsos-gamepad merges them into
one standard uinput gamepad, "RetroStoneOS Gamepad": positional buttons, the
D-pad as hat 0, the stick as the left stick (centred while not fitted). A
game's launch script starts it in the game's process group and gives SDL its
mapping (--print-mapping). The kernel gets CONFIG_INPUT_UINPUT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant