Skip to content

Add function to detect the gyro model in a 3ds#949

Open
rosaage wants to merge 5 commits intod0k3:masterfrom
rosaage:gyro_detect
Open

Add function to detect the gyro model in a 3ds#949
rosaage wants to merge 5 commits intod0k3:masterfrom
rosaage:gyro_detect

Conversation

@rosaage
Copy link

@rosaage rosaage commented Feb 23, 2026

This adds a function to get the gyro model as well as adding a string to sysinfo and a global int to the lua module.

The power registers and inspiration for the entire function comes from rehid:
https://github.com/hax0kartik/rehid/blob/5bfed26a1306be678fe3d6290c794e3bc529a086/source/Gyroscope.cpp#L97

Power registers were cross checked with problemkaputt.de for Gyro 0 and Gyro 1 along with adding who_am_i registers:
https://problemkaputt.de/gbatek-3ds-i2c-gyroscope-old-version.htm
https://problemkaputt.de/gbatek-3ds-i2c-gyroscope-new-version.htm

Simple lua test script: ui.echo("Your Gyro model is: "..GYROMODEL)

The code has been tested on:

  • Launch model o3DS, reporting gyro 0
  • n3DS (assembled 2 months after launch), reporting 1
  • n3DS ll (assembled in 2016), reporting 2

@ihaveamac
Copy link
Contributor

Make sure to add the constant to the lua doc.

@rosaage
Copy link
Author

rosaage commented Feb 24, 2026

I also added it to the original gm9 scripting now along with some documentation in the lua-doc file.
I updated the numbering to start from 1 instead of 0.

I was a bit unsure about the return value, but I ended up with a number instead of a string as I don't know the name of the 3rd model and I feel it's better for the API to not change if/when the model name is figured out.

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.

2 participants