How to get axis resting value

Hello,

Is there a way to get an axis resting value?
I’m currently trying to support Logitech racing wheel G29 and the pedal axis goes from 32767 to -32768 and the resting position is 32767. This is different from most other axis (as far as i can tell) which have a resting value of 0.
SDL_JoystickGetAxisInitialState only returns the initial value and not the resting value so if the pedal is pressed when calling SDL_JoystickGetAxisInitialState it doesn’t return 32767.
Every code/tutorial I’ve seen just assume axis are centered at 0 which isn’t the case here.
Is there a generic way to support such axis?

Thanks!

Or put another way is it possible to check if the pedals are in combine mode or not?
Does any1 have experience supporting racing wheel with SDL or know of a game using SDL that also supports racing wheels with pedals I could check the source code of?

No, all this isn’t possible, because that kind of information just does not exist.

Joystick-like devices (with the sole exception of gamepad-like XInput controllers) just don’t provide any useful information about their buttons and axes - nothing about their position, nothing about their resting value and the “names” they provide for buttons or axes (via HID identifiers) are also completely useless and random.

The only way to “properly” support racing wheels (or also Joysticks) is to

  1. Provide calibration and configuration support in your game/application, where you tell people to move the axes to their extreme points and resting points and let them specify what kind of axis it is (a slider that stays in position, a “normal” axis that has a resting position it gets back to when not touched, and maybe as a special case a wheel axis - while it’s technically like the second case usually, you may want to handle it differently for steering, with joystick-like axes moving steering more slowly towards the current axis value, while the steering wheel is translated directly, i.e. the steering wheel being turned X% directly translates to the wheels of the car being turned X% in the same direction)
  2. Let people freely configure (“bind”) which axis or button belongs to which action in the game (“axis_1 = accelerate”, “axis_2 = steer”, etc)
  3. Provide default configuration for commonly used hardware (identifying it by name or something), so people only have to do 1. and 2. if they have a more “exotic” device.

See also Joost's Dev Blog: The craziness that is joysticks on PC - 10 years later this rant is still mostly correct, except for the complaints about SDL (which have indeed been fixed with SDL 2.0.0 which was released about a year after that blogpost was written).

1 Like