Browse Source

Send the normal sensor data for the right Joy-Con controller in combined mode

Sam Lantinga 3 weeks ago
parent
commit
74653b3cd5
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/joystick/hidapi/SDL_hidapi_switch2.c

+ 4 - 0
src/joystick/hidapi/SDL_hidapi_switch2.c

@@ -592,6 +592,8 @@ static bool HIDAPI_DriverSwitch2_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
         break;
         break;
     case USB_PRODUCT_NINTENDO_SWITCH2_JOYCON_RIGHT:
     case USB_PRODUCT_NINTENDO_SWITCH2_JOYCON_RIGHT:
         if (ctx->device->parent) {
         if (ctx->device->parent) {
+            SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 250.0f);
+            SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 250.0f);
             SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO_R, 250.0f);
             SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO_R, 250.0f);
             SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_R, 250.0f);
             SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_R, 250.0f);
         }
         }
@@ -1212,6 +1214,8 @@ static void HIDAPI_DriverSwitch2_HandleStatePacket(SDL_HIDAPI_Device *device, SD
             break;
             break;
         case USB_PRODUCT_NINTENDO_SWITCH2_JOYCON_RIGHT:
         case USB_PRODUCT_NINTENDO_SWITCH2_JOYCON_RIGHT:
             if (ctx->device->parent) {
             if (ctx->device->parent) {
+                SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, sensor_timestamp, gyro_data, 3);
+                SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, sensor_timestamp, accel_data, 3);
                 SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO_R, sensor_timestamp, gyro_data, 3);
                 SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO_R, sensor_timestamp, gyro_data, 3);
                 SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL_R, sensor_timestamp, accel_data, 3);
                 SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL_R, sensor_timestamp, accel_data, 3);
             } else {
             } else {