-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
In SDL_joystick.h
there is the macro constant SDL_IPHONE_MAX_GFORCE
:
SDL/include/SDL3/SDL_joystick.h
Lines 164 to 167 in 0b64520
/* Set max recognized G-force from accelerometer | |
See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed | |
*/ | |
#define SDL_IPHONE_MAX_GFORCE 5.0 |
The mentioned file src/joystick/uikit/SDL_sysjoystick.m
doesn't exist.
SDL_IPHONE_MAX_GFORCE
is only referenced in docs/README-ios.md
:
Notes -- Accelerometer as Joystick
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_GetJoystickAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_GetJoystickAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
The mentioned demo file accelerometer.c
isn't in SD3 anymore.
In SDL2 it can be foud under SDL-2.30.7/Xcode-iOS/Demos/src/accelerometer.c