mirror of https://github.com/encounter/SDL.git
Scale the values correctly based on the sensor type (thanks @meyraud705)
This commit is contained in:
parent
65ff00ec1b
commit
b3a0174b26
|
@ -1341,9 +1341,15 @@ static void SendSensorUpdate(SDL_Joystick *joystick, SDL_DriverSwitch_Context *c
|
||||||
* since that's our de facto standard from already supporting those controllers, and
|
* since that's our de facto standard from already supporting those controllers, and
|
||||||
* users will want consistent axis mappings across devices.
|
* users will want consistent axis mappings across devices.
|
||||||
*/
|
*/
|
||||||
|
if (type == SDL_SENSOR_GYRO) {
|
||||||
data[0] = -HIDAPI_DriverSwitch_ScaleGyro(values[1]);
|
data[0] = -HIDAPI_DriverSwitch_ScaleGyro(values[1]);
|
||||||
data[1] = HIDAPI_DriverSwitch_ScaleGyro(values[2]);
|
data[1] = HIDAPI_DriverSwitch_ScaleGyro(values[2]);
|
||||||
data[2] = -HIDAPI_DriverSwitch_ScaleGyro(values[0]);
|
data[2] = -HIDAPI_DriverSwitch_ScaleGyro(values[0]);
|
||||||
|
} else {
|
||||||
|
data[0] = -HIDAPI_DriverSwitch_ScaleAccel(values[1]);
|
||||||
|
data[1] = HIDAPI_DriverSwitch_ScaleAccel(values[2]);
|
||||||
|
data[2] = -HIDAPI_DriverSwitch_ScaleAccel(values[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Right Joy-Con flips some axes, so let's flip them back for consistency */
|
/* Right Joy-Con flips some axes, so let's flip them back for consistency */
|
||||||
if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
||||||
|
|
Loading…
Reference in New Issue