Commit Graph

19 Commits

Author SHA1 Message Date
8599c9e64c Merge pull request #2567 from marquezini
# Conflicts:
#	docs/gameinput.md
2026-11-22 13:16:16 -05:00
c1543e3449 Merge pull request #2552 from Leonida local test 2026-11-22 13:16:07 -05:00
af330fcce3 gameinput: keep only the haptic calls the shim makes in the test seam (RT-160)
HapticApi carried SDL_GetNumHapticAxes and SDL_HapticEffectSupported, which
nothing calls: the motor's axes are the shim's choice and the effect kinds are
gated on SDL_GetHapticFeatures. They are gone from the table, its SDL
implementation and the test's fake, so the seam is exactly the calls a pad's
force feedback makes.

AI-assisted.
2026-11-22 18:37:28 +01:00
2aed56c6e5 RT-176: IGameInputDispatcher::Dispatch honours its quota
Dispatch ran the whole queue whatever quota it was given. It now runs
queued events oldest first, at least one per call (a quota of 0 runs
exactly one, as the GDK documents), takes no further event once the
quota has passed, and returns whether events remain. While events
remain the wait handle is signalled again, so a title that waits on it
before each call comes back for the rest.

The automatic path (no dispatcher, poll thread) still delivers the
whole queue. gameinput_test checks Dispatch(0), a 1 ms quota against a
5 ms callback, a large quota draining the queue, and an empty queue.
2026-11-22 14:31:09 -03:00
a3b1719c61 gameinput: report and drive force-feedback and haptic motors through SDL3 haptics (RT-160)
IGameInputDevice answered the force-feedback and haptic half of the API with
nothing: no motors in GameInputDeviceInfo, E_INVALIDARG from
CreateForceFeedbackEffect, false from IsForceFeedbackMotorPoweredOn, a no-op
SetForceFeedbackMotorGain and E_INVALIDARG from SetHapticMotorState. A pad SDL
opens as a haptic device now reports one force-feedback motor with the effect
kinds SDL lists, and a pad with trigger motors reports two haptic motors.

Force feedback goes to SDL_CreateHapticEffect/RunHapticEffect on the poll
thread, so title calls still never touch SDL; the eleven GameInput effect kinds
are SDL's eleven force-feedback effects. The trigger haptic motors play their
one waveform as an intensity on the existing trigger output. A pad with neither
keeps the old answers, and LEONIDA_RUMBLE=0 silences both. gameinput_test drives
all of it through a fake haptic backend, because SDL's virtual joysticks report
no haptics.

AI-assisted.
2026-11-22 18:26:28 +01:00
873a952a37 Merge pull request #2239 from itsRevela 2026-11-22 11:43:15 -05:00
d159969a1b Merge pull request #2162 from Cozma 2026-11-22 11:42:23 -05:00
b9a3cbcfc0 gameinput: GetTemporalReading stays E_NOTIMPL, as in GameInput v0 (RT-147)
Microsoft's reference page says IGameInput::GetTemporalReading "was never
implemented in v0" and returns E_NOTIMPL, and v1 removed it, so the shim's
E_NOTIMPL already matches the API the title was built against. A history
lookup would answer what no GameInput runtime does. The v0 header (NuGet
Microsoft.GameInput 0.2303.22621.3038) declares (timestamp, device,
reading), the shim's layout; the page's five-parameter form doesn't match it.

Pin the behaviour in gameinput_test (E_NOTIMPL with the reading cleared, for
past, present and current timestamps, with and without a device filter;
E_POINTER for a null output) and say so in docs/gameinput.md instead of
listing the method as a gap.
2026-11-22 10:26:34 -06:00
3ff74e8d58 gameinput: the keyboard pad's right stick reads raw mouse input and keeps the cursor in the window
GetCursorPos deltas stop at the screen edge and include pointer
acceleration. A message-only window on its own thread now registers for
raw mouse input (RIDEV_INPUTSINK) and sums the relative counts; the poll
takes the difference of that total. Absolute reports are ignored, and
GetCursorPos stays as the fallback if registration fails.

With raw input on and a window of this process in the foreground, the
cursor is clipped to that window's client area (re-applied every 100 ms),
and released on focus loss or when the pad is turned off.

LEONIDA_MOUSE_SENSITIVITY (0.1..10, default 1) scales the axis units per
count.
2026-11-22 18:09:44 +02:00
3b8e442055 gameinput: refine aggregate device reading kind filter and callback guards 2026-11-22 21:09:21 +05:30
3ba5205180 gameinput: implement IGameInput::CreateAggregateDevice and reading delegation 2026-11-22 20:37:22 +05:30
c608a65679 GameInput: motion support via SDL sensors (#660 follow-up)
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).
2026-11-22 14:26:06 +01:00
851eb563b6 gameinput: keyboard pad moves and aims: WASD left stick, mouse right stick, mouse buttons LT/RT
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.
2026-11-22 12:49:29 +05:30
9eaf37e96f Distinguish identical connected gamepads in device-ID lookup 2026-11-21 22:59:21 -07:00
5190d597c8 Merge keyboard-pad coverage with controller reading history 2026-11-21 21:58:55 -07:00
b72fc5a4fe Keep gamepad readings in order between title polls 2026-11-21 21:46:14 -07:00
5097ea041a GameInput shim: keyboard pad (LEONIDA_KEYBOARD_PAD)
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>
2026-11-22 06:05:38 +02:00
71812aac05 GameInput shim: download SDL3 only when asked (LEONIDA_SDL3_FETCH)
The shim is built with an installed SDL3 (find_package) or with
-DLEONIDA_SDL3_FETCH=ON / FETCHCONTENT_SOURCE_DIR_SDL3; otherwise configure
prints a message, gta6rt builds without it, and CTest lists gameinput as
disabled. build_runtime.ps1 gains -FetchSdl3 and warns that its cl.exe
fallback never builds the shim. Review nits: delivering_thread is atomic,
and SDL's own GameInput joystick driver is pinned off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:58:46 +00:00
0e59c75b7b Runtime: GameInput shim on SDL3 (any controller; DualSense trigger effects, lightbar)
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>
2026-11-22 02:54:55 +00:00