Expose SDL3's gyroscope and accelerometer through the GameInput shim:
- gameinput_abi.h: GameInputMotionAccuracy, GameInputMotionInfo and
GameInputMotionState with the v0 layouts (Microsoft's public docs),
size asserts included.
- The shim enables both sensors when a pad with them is opened, reads
the latest sample each poll, and reports GameInputKindMotion plus a
GameInputMotionInfo on such pads. GetMotionState returns the state as
signed fractions of the motionInfo maxima (2 g accel, 2000 deg/s
gyro, the shim's choice since SDL exposes no sensor range; VERIFY).
All-zero accel means no sample yet, so readings before the device's
first sample carry no motion. Magnetic field and orientation stay
zero and Unknown: SDL has no compass and nothing synthesises a
quaternion. Pads with sensors stream a reading every ~8 ms so motion
is not stuck at the last button event; other pads keep the old
change-driven behaviour.
- GetCurrentReading and GetNextReading with a device filter now reject
kinds the device does not support (READING_NOT_FOUND), matching the
v0 docs and the device-less path, so a motion query on a plain pad
fails instead of returning a reading without motion.
- gameinput_test: a virtual pad with SDL sensors covers kind/motionInfo
presence, no-motion-before-first-sample, normalisation, accuracy
values, the +-1 clamp, the cadence, and the plain-pad rejection.
gameinput_probe prints the live accel and gyro fractions.
- docs/gameinput.md: a Motion section, the API table, and VERIFY notes
for the chosen maxima and the unprovided members.
Tested: gameinput_test 185/185 and ctest 90/90 (RelWithDebInfo) on
Windows 11 Pro 10.0.26200; SDL3 3.4.20 via -DLEONIDA_SDL3_FETCH=ON.
Follows: #660. AI-assisted (ZCode agent).
The keyboard pad only pressed buttons, enough for menus. WASD now drives
the left stick (opposite keys cancel, diagonals on the round gate), cursor
movement the right stick (decaying back to center), and the right/left
mouse buttons the left/right triggers. Everything is released on focus
loss. A set_cursor_source seam sits beside set_keyboard_source for tests.
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.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GameInputCreate and the v0 IGameInput/IGameInputDevice/IGameInputReading/IGameInputDispatcher surface a title uses
for gamepads, served from SDL3 gamepads so DualSense, DualShock 4, Switch Pro and Xbox pads all work. Rumble goes to
SDL_RumbleGamepad, impulse-trigger rumble to SDL_RumbleGamepadTriggers, and on a DualSense to adaptive-trigger effects
through SDL_SendGamepadEffect (LEONIDA_DS_TRIGGERS=off|rumble|resistance). Lightbar via LEONIDA_DS_LIGHTBAR.
SDL3 (zlib) comes from an installed package or a pinned, hash-checked release tarball via FetchContent;
-DLEONIDA_SDL3=OFF skips the shim. gameinput_test covers the shim on SDL virtual joysticks; gameinput_probe is the
manual check on a real pad. docs/gameinput.md has the mapping, settings and VERIFY list.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>