Repository navigation
Conversation
A game played by tilting (LocoRoco tilts with L and R) can now be tilted with the motion sensors of a gamepad or of the phone itself. It is off by default and only for a game whose profile says how it tilts. - GameProfile::tilt names the buttons that tilt left and right, and whether the game eases its tilt towards the held side; then a small roll presses the button for part of the frames and tilts part way. - input/tilt: the roll from the accelerometer, fused with the gyroscope's rate; the dead zone with hysteresis, re-centring, inversion; three modes: Angle, Angle + level horizon, and Rate, where turning the device tilts and the tilt stays when the turning stops. Unit tested with synthetic readings (portablekit_tilt_tests). - input/motion: the sensors through SDL, a gamepad's first, else the device's own turned with the screen. The log says which were found, and why none were: Steam Input's virtual pad hides a Steam Deck's. - A tilt button the player presses takes over from the sensors, so a tilt never becomes both buttons at once. R3 alone re-centres, and so do the start and closing the menu. - Angle + level horizon turns the finished game picture against the device's roll and zooms it just enough to cover its rectangle at that angle (1:1 when level), capped at 10 degrees by default. The overlay and the interface are drawn after it and stay upright. - Controls > Tilt controls in the menu, settings.ini keys input.tilt*, and <prefix>_TILT, _TILT_MODE, _TILT_FULL, _TILT_DEAD_ZONE. - The input script's virtual pad gets a gyroscope and an accelerometer when a script uses the new tilt and gyro steps, so all of it can be driven without hardware. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A game played by tilting (LocoRoco tilts its world with L and R) can now be tilted with the motion sensors of a gamepad or of the phone itself. It is opt-in per game (
GameProfile::tilt) and off by default for the player. First user: TeamGDB/Purun (LocoRoco 2).What changed
GameProfile::tilt(TiltControls): the buttons that tilt left and right, whether the game eases its tilt towards the held side (proportional), and a note for the menu. Without it, nothing opens a sensor and the menu has no Tilt controls section.host/input/tilt.{hpp,cpp}: plain arithmetic, no SDL.asin(-up.x)from the accelerometer, so it does not depend on the device's pitch: a flat gamepad and an upright phone or Deck read the same. It is fused with the gyroscope's rate through a complementary filter.proportional, a roll between the dead zone and full tilt presses the button for that share of the frames.host/input/motion.{hpp,cpp}: sensors through SDL3.SDL_SetGamepadSensorEnabled, gyro and accel, enabled only while tilt is on). Otherwise the device's (SDL_OpenSensor), turned from the natural orientation into the screen's.[tilt] DualSense…: gyroscope and accelerometer (… Hz),[tilt] device sensors: …), or why there is nothing. Under Steam Input it points at Steam Input hiding the Deck's gyroscope.max(cos a + (H/W) sin a, cos a + (W/H) sin a), 1:1 when level, capped atinput.tilt_level_limit(default 10°). The overlay and ImGui draw after it and stay upright. Android pre-rotation targets are handled.input.tilt,input.tilt_mode(angle|level|rate),input.tilt_full(12°),input.tilt_dead_zone(4°),input.tilt_invert,input.tilt_level_limit(10°).<prefix>_TILT,_TILT_MODE,_TILT_FULL,_TILT_DEAD_ZONE, and<prefix>_TRACE_TILT(also underTRACE_PAD).tilt ROLL [PITCH]andgyro X Y Zsteps. The virtual pad gets a gyroscope and accelerometer only when a script uses them, or withINPUT_LIVE.tests/tilt_tests.cpp(portablekit_tilt_tests) anddocs/PROFILE_GUIDE.md.This branch is the cherry-pick onto main. Purun uses the same commit on
purun/tilt-controls(on e73a866, which merges cleanly withpurun/confirm-cross). The only conflict with main was the test block inCMakeLists.txt.How it was verified
feature/gyro-tiltwith this commit on e73a866:portablekit_tilt_testsandportablekit_settings_testspass.INPUT_LIVEwith synthetictiltandgyrosteps, in LocoRoco 2's Franzea 1.[tilt]/[pad]traces and window captures showed:[tilt] this device has no accelerometer or gyroscope of its own.-fsyntax-onlycompile of every changed translation unit with the Purun build's flags. Not a full build or run of main.Not verified
🤖 Generated with Claude Code