Add sensor example and fix gravity/magnometric values on iOS by JonnyPtn · Pull Request #3773 · SFML/SFML · GitHub
Skip to content

Add sensor example and fix gravity/magnometric values on iOS - #3773

Open
JonnyPtn wants to merge 1 commit into
SFML:masterfrom
JonnyPtn:sensor_example
Open

JonnyPtn wants to merge 1 commit into
SFML:masterfrom
JonnyPtn:sensor_example

Conversation

@JonnyPtn

Copy link
Copy Markdown
Contributor

Currently there's no way to test or demonstrate SFML's sensor API so this adds an example for that - a simple ball rolling around based on the device rotation and movement, with a compass in the corner

ScreenRecording_10-15-2026.11-02-31_1.MP4

As I was primarily testing on iOS I also fixed two major issues there:

  • The gravity sensor was completely unimplemented
  • The magnometric sensor was the raw value which isn't remotely accurate, there's a calibrated alternative which it's been replaced with

There's still a few other things noticed during my testing but don't want too creep the scope too much so have left them out for the time being:

  • Android and iOS report opposite values (worked around in the example)
  • Android sensors seem to lag quite a bit
  • Values are reported relative to the device, so rotating the device gets confusing, especially without SFML exposing the device orientation outside of deducing it from the window size, for this example I have just locked it to portrait orientation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Planned

Development

Successfully merging this pull request may close these issues.

2 participants