Skip to content

GameInput shim: keyboard pad for menus (LEONIDA_KEYBOARD_PAD) - #875

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Cozmaaa:keyboard-pad
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Cozmaaa:keyboard-pad

Conversation

@Cozmaaa

@Cozmaaa Cozmaaa commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claimed in #634: #634 (comment) (new item, no ID yet)

Builds on #680 (merged).

What and why

The title reads gamepads only, so a player without a controller has no way to drive even the menus. With LEONIDA_KEYBOARD_PAD set, the GameInput shim attaches one SDL virtual gamepad, Keyboard pad (Leonida), and presses its buttons from the keyboard on every poll. It then goes through open_pad / read_pad like a real controller, so it gets a device object, the next free player slot, readings, reading and device callbacks, and UI navigation, with no new paths in the API code. It reports no rumble motors.

key button
arrow keys d-pad
Enter A
Backspace B
X / Y X / Y
Q / E left / right shoulder
Esc Menu
Tab View
  • Off by default. Without the variable nothing changes.
  • LEONIDA_KEYBOARD_PAD=1: keys count only while a window of this process is in the foreground, and every button is released when focus moves away, so typing in another app presses nothing.
  • LEONIDA_KEYBOARD_PAD=always: ignores focus (needed by console tools such as gameinput_probe, whose console window belongs to the terminal).
  • Keys are read with GetAsyncKeyState: no window or message loop needed (SDL's keyboard lives in its video subsystem, which this build leaves out), and it works under Wine.
  • Sticks and triggers stay at rest. WASD → left stick and mouse → right stick are for a follow-up PR.

docs/gameinput.md has a new "Keyboard pad" section, the env var row, the test coverage, and a VERIFY item: with a controller plugged in the title sees two pads, and whether the game listens to both is unknown until the executable is available.

Test seam

rt::gameinput::set_keyboard_source(key_down, has_focus) replaces GetAsyncKeyState and the foreground check (nullptr restores the defaults). rt::gameinput::keyboard_bindings() exposes the fixed key map.

Tested

  • gameinput_test (CTest gameinput): 106/106 checks, 31 of them new. They cover off by default, attach and device callbacks, every binding, two keys at once, UI navigation, sticks and triggers at rest, no input out of focus, release on focus loss, the always mode, and turning it off and on again (the same device object comes back).
  • gta6rt builds with the shim.
  • Windows 11, VS 2026 MSVC, Ninja, RelWithDebInfo, SDL3 3.4.20 through -DLEONIDA_SDL3_FETCH=ON. CPU only; no GPU is involved in this change.
  • Not tested by hand with real key presses yet. $env:LEONIDA_KEYBOARD_PAD='always'; gameinput_probe --seconds 20 shows it live.
  • No game data used.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

The title reads gamepads only, so keys reach it as one more pad: an SDL
virtual gamepad whose buttons are pressed from GetAsyncKeyState on each
poll. It goes through open_pad/read_pad like a real controller (device
object, player slot, readings, callbacks, UI navigation) and reports no
motors.

Arrows d-pad, Enter A, Backspace B, X X, Y Y, Q/E shoulders, Esc Menu,
Tab View. Off by default; =1 reads keys only while a window of this
process is in the foreground and releases everything on focus loss,
=always ignores focus (console tools). Sticks and triggers stay at rest.

gameinput_test drives it through set_keyboard_source with fake keys and
focus: 31 new checks.

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 5b0fddd on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • 32 test programs in the build pass with 0 validation errors
  • d3d12_clear_test fails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as on main 4a36bb1 here, so not from this PR; #521 addresses it

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

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.

3 participants