Skip to content

Implement built-in gyroscope support for SDL2 platforms#2540

Merged
a1batross merged 1 commit intoFWGS:masterfrom
Vladislav4KZ:mobile-gyro
Apr 15, 2026
Merged

Implement built-in gyroscope support for SDL2 platforms#2540
a1batross merged 1 commit intoFWGS:masterfrom
Vladislav4KZ:mobile-gyro

Conversation

@Vladislav4KZ
Copy link
Copy Markdown
Member

@Vladislav4KZ Vladislav4KZ commented Apr 14, 2026

Introduce native support for mobile gyroscope sensors using the SDL2 Sensor API, enabling player view and aiming control with the built-in gyroscope on Android, iOS, and other SDL2-compatible platforms.

The implementation is split into platform-agnostic logic in engine/client/in_gyro.c and a platform-specific sensor layer in engine/platform/sdl2/sensor_sdl2.c.
Axis mapping is pre-configured for landscape orientation, typical for mobile gaming.

New CVars

gyro_enable: Master toggle for the built-in gyroscope.
gyro_available (Read-only): Hardware status indicator.
gyro_pitch, gyro_yaw, gyro_roll: Individual axis sensitivity.
gyro_pitch_deadzone, gyro_yaw_deadzone, gyro_roll_deadzone: Configurable thresholds to eliminate sensor jitter and noise.

Comment thread engine/client/in_gyro.c
Comment thread engine/platform/sdl2/sensor_sdl2.c
Copy link
Copy Markdown
Member

@a1batross a1batross left a comment

Choose a reason for hiding this comment

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

Seems mostly based on already existing gyro code but SDL2 handles system and joystick gyros separately, so maybe it's fine for now.

@Vladislav4KZ
Copy link
Copy Markdown
Member Author

Renamed the cl_gyro cvar to gyro_enable, and updated other cvars starting with cl_gyro_ to gyro_, following the naming convention of touch_ and joy_ cvars

@Vladislav4KZ
Copy link
Copy Markdown
Member Author

I think everything is ready to be merged now.

@a1batross a1batross merged commit dd1cb04 into FWGS:master Apr 15, 2026
18 checks passed
@Vladislav4KZ Vladislav4KZ deleted the mobile-gyro branch April 15, 2026 21:14
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