libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.33k stars 1.84k forks source link

Sensor API clarifications. #16202

Open oshaboy opened 9 months ago

oshaboy commented 9 months ago

I have been trying to implement udev and sdl drivers for accelerometer and gyroscope but there seems to be a bit of miscommunication between the retropad, gamepad designers, and the libretro core developers.

So Retropad gives the following bindings for sensors.

RETRO_SENSOR_ACCELEROMETER_X
RETRO_SENSOR_ACCELEROMETER_Y
RETRO_SENSOR_ACCELEROMETER_Z
RETRO_SENSOR_GYROSCOPE_X
RETRO_SENSOR_GYROSCOPE_Y
RETRO_SENSOR_GYROSCOPE_Z

These are ambiguous. udev uses a similar thing calling the accelerometer ABS_X, ABS_Y and ABS_Z and the gyroscope ABS_RX, ABS_RY and ABS_RZ. SDL has a similar thing where you poll either the accelerometer or the gyroscope once and then get 3 floats with no context. The gamepads I have access to disagree on which is which. This causes things like the dualsense requiring you to hold it with the shoulder buttons facing up and tilting backwards for kirby to move forwards. I would like to make retropad bindings for gamepads but the ambiguity still exists in retropad itself. You could say there is a similar ambiguity with the analog stick, but we're basically in de-facto agreement that X is left->right and Y is up->down like how Latin (English) text is written. Not so with the six axes of the sensors, especially because those axes depend on how you hold the gamepad or mobile device.

I would propose renaming the gyroscope axes to pitch yaw and roll (I think calling the accelerometer X Y and Z is fine as long as it's fomalized), but these are public API values. So a better solution would be to modify the retropad documentation here to show the gyroscope and accelerometer axes including which direction is negative and which is positive.

Thank you.

zoltanvb commented 9 months ago

The referenced page belongs to another project, but the actual libretro RetroPad docs could also do with an update: https://docs.libretro.com/guides/input-and-controls/#what-is-a-retropad

oshaboy commented 9 months ago

Whoops I didn't notice. I just googled "Retropad Diagram" on Duckduckgo and picked one of the first results.