48
48
#define SDL_8BITDO_BT_REPORTID_SDL_REPORTID 0x01
49
49
50
50
#define ABITDO_ACCEL_SCALE 4096.f
51
- #define SENSOR_INTERVAL_NS 8000000ULL
51
+ #define ABITDO_SENSOR_POLLING_RATE 125.f
52
+ #define SENSOR_INTERVAL_NS 8000000ULL
53
+ #define ABITDO_GYRO_MAX_DEGREES_PER_SECOND 2000.f
52
54
53
55
typedef struct
54
56
{
@@ -67,7 +69,7 @@ typedef struct
67
69
float accelScale ;
68
70
float gyroScale ;
69
71
Uint8 last_state [USB_PACKET_LENGTH ];
70
- Uint64 sensor_timestamp ; // Microseconds. Simulate onboard clock. Advance by known rate: SENSOR_INTERVAL_NS == 8ms = 125 Hz
72
+ Uint64 sensor_timestamp ; // Nanoseconds. Simulate onboard clock. Advance by known rate: SENSOR_INTERVAL_NS == 8ms = 125 Hz
71
73
} SDL_Driver8BitDo_Context ;
72
74
73
75
#pragma pack(push,1)
@@ -240,12 +242,13 @@ static bool HIDAPI_Driver8BitDo_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys
240
242
joystick -> nhats = 1 ;
241
243
242
244
if (ctx -> sensors_supported ) {
243
- SDL_PrivateJoystickAddSensor (joystick , SDL_SENSOR_GYRO , 125.0f );
244
- SDL_PrivateJoystickAddSensor (joystick , SDL_SENSOR_ACCEL , 125.0f );
245
+ SDL_PrivateJoystickAddSensor (joystick , SDL_SENSOR_GYRO , ABITDO_SENSOR_POLLING_RATE );
246
+ SDL_PrivateJoystickAddSensor (joystick , SDL_SENSOR_ACCEL , ABITDO_SENSOR_POLLING_RATE );
245
247
246
248
247
249
ctx -> accelScale = SDL_STANDARD_GRAVITY / ABITDO_ACCEL_SCALE ;
248
- ctx -> gyroScale = DEG2RAD (2048 ) / INT16_MAX ; // Hardware senses +/- 2048 Degrees per second mapped to +/- INT16_MAX
250
+ // Hardware senses +/- N Degrees per second mapped to +/- INT16_MAX
251
+ ctx -> gyroScale = DEG2RAD (ABITDO_GYRO_MAX_DEGREES_PER_SECOND ) / INT16_MAX ;
249
252
}
250
253
251
254
return true;
0 commit comments