WIP: feat(host): the Steam Deck's gyro reaches Motion controls when Steam starts the game #1181

Draft
zeldaootr wants to merge 2 commits from zeldaootr/Longshot:deck-gyro into main
Contributor

Type: feat · Risk: medium · Tested on: Steam Deck OLED (SteamOS 3.9.5), headless over ssh with Steam's variables set by hand: the Deck's gyroscope is found; Linux, game-free checks · Needs: Steam Deck, Game Mode, from the Steam shortcut, by hand (aiming, and the trackpads beside Steam Input)

Why

On a Steam Deck started from Steam, the Motion controls row says "no gyro on this pad" and motion aiming gets nothing, so players build a Steam Input "Gyro to Mouse" workaround. Steam hides the Deck's built-in controls from the game (its SDL_GAMECONTROLLER_IGNORE_DEVICES) and gives it a stand-in pad with no sensors. Valve's other pads were already taken out of that list for their gyro; the Deck's was kept in until it was tried beside Steam Input. Reported in the team's Discord thread "STEAM DECK GYRO SUPPORT".

The tracker was searched (gyro, motion, six-axis, sensor): no issue or pull request covers it. #699 (a "Custom" gyro aim style) and #1171 (the gyro at rest while the Insert menu is open) are other topics; 699 also edits host/pad_sdl.c.

What changed

The Deck's built-in controls now come out of Steam's ignore list too, so SDL's Steam Deck driver opens them and Motion controls reads their gyroscope and accelerometer. Their buttons and sticks keep coming through Steam Input as the player's layout maps them (motion only beside the stand-in pad). HOS_DECK_GYRO=0 keeps the old behaviour.

  • input: steam_pads_without_valve in host/steam_pads.h takes a keep_deck flag and drops 0x28de/0x1205 without it; pads_start in host/pad_sdl.c sets it from HOS_DECK_GYRO=0 and logs which.
  • docs: README (Motion controls), docs/development.md (HOS_DECK_GYRO).
  • tests: tests/test_steam_pads.py.

Measurements

Verdict: the gyroscope is found on a Steam Deck with this change and not without it; aiming in the game and the trackpads beside Steam Input are not yet checked by hand, so this stays work in progress. Nothing to time: an input change.

Steam Deck OLED, SteamOS 3.9.5, headless over ssh (not Game Mode), SDL_GAMECONTROLLER_IGNORE_DEVICES and Steam's virtual-gamepad variable set by hand as Steam sets them, HOS_MOTION_DEBUG=1, the Deck standing still in its dock. The change's host code on an older development base (main 9c9d69ed; host/pad_sdl.c, host/steam_pads.h and host/hos_sdl.* are the same there as on current main). All three runs loaded SDL3 and exited cleanly.

run pads opened motion
main Steam's virtual gamepad only none
this change the virtual gamepad, and Steam Deck Controller with a gyroscope ("taken out of Steam's ignore list", "motion controls from Steam Deck Controller") 106 motion lines: acceleration (0, -0.88, -0.36) G, the Deck tilted back in its dock; rotation 0.000, steady
this change, HOS_DECK_GYRO=0 Steam's virtual gamepad only none

Once in the run the gyroscope's reading stopped changing and the game turned the motion sensors off and on again (its frozen-gyro rule); a Deck that is perfectly still reads exactly 0.000, so this may be the rule meeting a still Deck. To be looked at in the by-hand run.

Before and after every run the kernel log, /dev/input/by-id and /proc/bus/input/devices were the same, and the Deck's own mouse and keyboard devices stayed listed. That does not show whether the trackpads' behaviour inside the controller changed.

Flags and settings

One new switch.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
HOS_DECK_GYRO Whether the Deck's built-in controls come out of Steam's ignore list (always kept in) on (=0: kept in) On: Motion controls gets the Deck's gyro under Steam Helps: the gyro is found on a Deck OLED. Untested: aiming, and Steam Input's trackpads beside it On, unless the by-hand Deck run shows Steam Input's trackpads affected

Testing

Tested: the three headless Deck runs above. python -I -B tests/run_all.py on Linux: 628 passed, 23 failed, 26 skipped; all 23 fail on main 71b1edd8 too (test_fsr_uniform_ownership, test_parallel_init_order, test_linux_update, test_make_game_cache, test_audio_output_devices, test_bug_report, test_bug_report_defaults, test_crt_options, test_failed_compile_keeps_objects, test_dlss_feature_size, test_hardware_report, test_guest_imported, test_lift_lookups, test_import_reach, test_linux_preflight, test_missing_nup, test_mods_size_table, test_pending_guest_import, test_replay_write_order, test_run_all_changed, test_nonuniform_image_arrays, test_walk_key, test_vk_occlusion_queries); none reads the changed files. tests/test_steam_pads.py fails on main and passes here. host/pad_sdl.c compiles without warnings for Linux and for Windows (llvm-mingw).

Not tested: a start from the Steam shortcut in Game Mode; aiming with the gyro in the game; Steam Input's trackpads, back grips and Steam buttons beside SDL's Steam Deck driver, during play and after quitting; a Steam Deck LCD; this head in a full build of current main.

Must be tested:

  • Steam Deck, SteamOS, Game Mode, from the Steam shortcut with Steam Input on and no gyro workaround: the Motion controls row reads "On (gyro found)"; slingshot and first-person aim follow the Deck and are not inverted; buttons act once; the trackpads move and click, and the back grips and the Steam and Quick Access buttons work during play, after quitting and in Desktop Mode (by hand: zeldaootr).

Risks

What could break: SDL's Steam Deck driver may change the Deck's trackpad settings when it opens the controls; beside Steam Input that could change trackpad clicks during play or after the game exits. Only runs started by Steam on a Deck are affected; other pads and platforms behave as before.

Turning it off: HOS_DECK_GYRO=0 (in longshot_env.txt or the launch options), or revert the commit.

Compatibility: Nothing changes for saves, options, caches or the renderer's interface.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing's Tested names headless ssh runs with Steam variables set by hand, not a game played; Game Mode and aiming were not run.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks. Not ticked yet: Risks says Steam's trackpad settings could change during play or after quitting, and that was not measured.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main. On main 71b1edd8.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md). To be added with the by-hand Game Mode run.
  • A game-free test added for the fix, failing on main and passing here.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
**Type:** feat · **Risk:** medium · **Tested on:** Steam Deck OLED (SteamOS 3.9.5), headless over ssh with Steam's variables set by hand: the Deck's gyroscope is found; Linux, game-free checks · **Needs:** Steam Deck, Game Mode, from the Steam shortcut, by hand (aiming, and the trackpads beside Steam Input) ## Why On a Steam Deck started from Steam, the Motion controls row says "no gyro on this pad" and motion aiming gets nothing, so players build a Steam Input "Gyro to Mouse" workaround. Steam hides the Deck's built-in controls from the game (its `SDL_GAMECONTROLLER_IGNORE_DEVICES`) and gives it a stand-in pad with no sensors. Valve's other pads were already taken out of that list for their gyro; the Deck's was kept in until it was tried beside Steam Input. Reported in the team's Discord thread "STEAM DECK GYRO SUPPORT". The tracker was searched (gyro, motion, six-axis, sensor): no issue or pull request covers it. https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/699 (a "Custom" gyro aim style) and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1171 (the gyro at rest while the Insert menu is open) are other topics; 699 also edits `host/pad_sdl.c`. ## What changed The Deck's built-in controls now come out of Steam's ignore list too, so SDL's Steam Deck driver opens them and Motion controls reads their gyroscope and accelerometer. Their buttons and sticks keep coming through Steam Input as the player's layout maps them (motion only beside the stand-in pad). `HOS_DECK_GYRO=0` keeps the old behaviour. - input: `steam_pads_without_valve` in `host/steam_pads.h` takes a `keep_deck` flag and drops `0x28de/0x1205` without it; `pads_start` in `host/pad_sdl.c` sets it from `HOS_DECK_GYRO=0` and logs which. - docs: README (Motion controls), `docs/development.md` (`HOS_DECK_GYRO`). - tests: `tests/test_steam_pads.py`. ## Measurements **Verdict:** the gyroscope is found on a Steam Deck with this change and not without it; aiming in the game and the trackpads beside Steam Input are not yet checked by hand, so this stays work in progress. Nothing to time: an input change. Steam Deck OLED, SteamOS 3.9.5, headless over ssh (not Game Mode), `SDL_GAMECONTROLLER_IGNORE_DEVICES` and Steam's virtual-gamepad variable set by hand as Steam sets them, `HOS_MOTION_DEBUG=1`, the Deck standing still in its dock. The change's host code on an older development base (main 9c9d69ed; `host/pad_sdl.c`, `host/steam_pads.h` and `host/hos_sdl.*` are the same there as on current main). All three runs loaded SDL3 and exited cleanly. | run | pads opened | motion | |---|---|---| | main | Steam's virtual gamepad only | none | | this change | the virtual gamepad, and `Steam Deck Controller` with a gyroscope ("taken out of Steam's ignore list", "motion controls from Steam Deck Controller") | 106 motion lines: acceleration (0, -0.88, -0.36) G, the Deck tilted back in its dock; rotation 0.000, steady | | this change, `HOS_DECK_GYRO=0` | Steam's virtual gamepad only | none | Once in the run the gyroscope's reading stopped changing and the game turned the motion sensors off and on again (its frozen-gyro rule); a Deck that is perfectly still reads exactly 0.000, so this may be the rule meeting a still Deck. To be looked at in the by-hand run. Before and after every run the kernel log, `/dev/input/by-id` and `/proc/bus/input/devices` were the same, and the Deck's own mouse and keyboard devices stayed listed. That does not show whether the trackpads' behaviour inside the controller changed. ### Flags and settings One new switch. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `HOS_DECK_GYRO` | Whether the Deck's built-in controls come out of Steam's ignore list | (always kept in) | on (`=0`: kept in) | On: Motion controls gets the Deck's gyro under Steam | Helps: the gyro is found on a Deck OLED. Untested: aiming, and Steam Input's trackpads beside it | On, unless the by-hand Deck run shows Steam Input's trackpads affected | ## Testing **Tested:** the three headless Deck runs above. `python -I -B tests/run_all.py` on Linux: 628 passed, 23 failed, 26 skipped; all 23 fail on main 71b1edd8 too (`test_fsr_uniform_ownership`, `test_parallel_init_order`, `test_linux_update`, `test_make_game_cache`, `test_audio_output_devices`, `test_bug_report`, `test_bug_report_defaults`, `test_crt_options`, `test_failed_compile_keeps_objects`, `test_dlss_feature_size`, `test_hardware_report`, `test_guest_imported`, `test_lift_lookups`, `test_import_reach`, `test_linux_preflight`, `test_missing_nup`, `test_mods_size_table`, `test_pending_guest_import`, `test_replay_write_order`, `test_run_all_changed`, `test_nonuniform_image_arrays`, `test_walk_key`, `test_vk_occlusion_queries`); none reads the changed files. `tests/test_steam_pads.py` fails on main and passes here. `host/pad_sdl.c` compiles without warnings for Linux and for Windows (llvm-mingw). **Not tested:** a start from the Steam shortcut in Game Mode; aiming with the gyro in the game; Steam Input's trackpads, back grips and Steam buttons beside SDL's Steam Deck driver, during play and after quitting; a Steam Deck LCD; this head in a full build of current main. **Must be tested:** - Steam Deck, SteamOS, Game Mode, from the Steam shortcut with Steam Input on and no gyro workaround: the Motion controls row reads "On (gyro found)"; slingshot and first-person aim follow the Deck and are not inverted; buttons act once; the trackpads move and click, and the back grips and the Steam and Quick Access buttons work during play, after quitting and in Desktop Mode (by hand: zeldaootr). ## Risks **What could break:** SDL's Steam Deck driver may change the Deck's trackpad settings when it opens the controls; beside Steam Input that could change trackpad clicks during play or after the game exits. Only runs started by Steam on a Deck are affected; other pads and platforms behave as before. **Turning it off:** `HOS_DECK_GYRO=0` (in `longshot_env.txt` or the launch options), or revert the commit. **Compatibility:** Nothing changes for saves, options, caches or the renderer's interface. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [ ] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing's Tested names headless ssh runs with Steam variables set by hand, not a game played; Game Mode and aiming were not run. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [ ] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. Not ticked yet: Risks says Steam's trackpad settings could change during play or after quitting, and that was not measured. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. On main 71b1edd8. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [ ] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). To be added with the by-hand Game Mode run. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated.
`tests/test_steam_pads.py` now expects `steam_pads_without_valve` to take
the Deck's `0x28de/0x1205` entry out of `SDL_GAMECONTROLLER_IGNORE_DEVICES`
too, unless asked to keep it (`keep_deck`, for `HOS_DECK_GYRO=0`), and
checks that the Deck's controls give their motion only beside Steam
Input's pad. Fails on main, which keeps the Deck's entry and has no
`keep_deck`.

Assisted-by: Claude
feat(host): the Steam Deck's gyro reaches Motion controls when Steam starts the game
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
31dc503fd3
Started from Steam, the game gets Steam's `SDL_GAMECONTROLLER_IGNORE_DEVICES`,
which lists the Deck's built-in controls (`0x28de/0x1205`), so SDL opened
only Steam Input's stand-in pad, which has no sensors: the Motion controls
row said "no gyro on this pad" and players set up Steam Input's gyro to
mouse instead. Valve's other pads already came out of that list for the
same reason; the Deck's was kept because SDL's Steam Deck driver writes its
trackpad settings (lizard mode off) as it opens it.

- `host/steam_pads.h`: `steam_pads_without_valve` takes the Deck's entry
  out too, unless `keep_deck`.
- `host/pad_sdl.c`: `pads_start` passes `keep_deck` from `HOS_DECK_GYRO=0`
  and says which it did. Beside the stand-in pad the Deck's controls give
  their motion only (`steam_pads_motion_only`, unchanged): buttons and
  sticks keep coming through Steam Input as the player's layout maps them.
- README (Motion controls) and `docs/development.md` (`HOS_DECK_GYRO`).

Not yet run on a Deck: whether Steam Input's trackpads keep working beside
SDL's driver is the open question.

Assisted-by: Claude
Author
Contributor

Tested in game: Steam Deck OLED, SteamOS 3.9.5, headless over ssh with Steam's controller variables set by hand: with the change SDL3 opens Steam Deck Controller with a gyroscope and Motion controls reads it; main and HOS_DECK_GYRO=0 open only Steam's virtual gamepad. Not yet run from the Steam shortcut in Game Mode.

Tested in game: Steam Deck OLED, SteamOS 3.9.5, headless over ssh with Steam's controller variables set by hand: with the change SDL3 opens Steam Deck Controller with a gyroscope and Motion controls reads it; main and HOS_DECK_GYRO=0 open only Steam's virtual gamepad. Not yet run from the Steam shortcut in Game Mode.
Collaborator

Possibly related, for context:

  • PR #699 WIP: feat(input): custom gyro aiming with per-item aim detection — Overlapping input code: gyro aiming PR also edits host/pad_sdl.c.
Possibly related, for context: - PR #699 WIP: feat(input): custom gyro aiming with per-item aim detection — Overlapping input code: gyro aiming PR also edits host/pad_sdl.c.
Owner

Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).

  • Tested on my own PC: not ticked: Testing's Tested names headless ssh runs with Steam variables set by hand, not a game played; Game Mode and aiming were not run. Run it yourself on your PC (in the game, for a change the game runs) and say where and what you saw in Testing's Tested; or, when the fix's own case can't be run by hand, add a **Not testable by hand:** line saying why and what stands in for it. Then tick it.
  • Nothing gets worse that I know of: not ticked: Risks says Steam's trackpad settings could change during play or after quitting, and that was not measured. Measure that cost and state it in Risks, then tick it.
Brought up to the [ready-for-review standard](https://git.magicbean.dev/MagicBeanDev/Longshot/src/branch/main/CONTRIBUTING.md#ready-for-review-out-of-wip) (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know). - *Tested on my own PC*: not ticked: Testing's Tested names headless ssh runs with Steam variables set by hand, not a game played; Game Mode and aiming were not run. Run it yourself on your PC (in the game, for a change the game runs) and say where and what you saw in Testing's *Tested*; or, when the fix's own case can't be run by hand, add a `**Not testable by hand:**` line saying why and what stands in for it. Then tick it. - *Nothing gets worse that I know of*: not ticked: Risks says Steam's trackpad settings could change during play or after quitting, and that was not measured. Measure that cost and state it in Risks, then tick it.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'deck-gyro:zeldaootr-deck-gyro'
git switch 'zeldaootr-deck-gyro'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1181
No description provided.