mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-11-30 16:48:41 +01:00
hidapi: strip the report ID from Flydigi rumble packets
Verified on a Vader 5 Pro over the 2.4 GHz dongle. Fixes #16187
This commit is contained in:
committed by
Sam Lantinga
parent
145f1f825a
commit
cdee4e09e6
@@ -313,13 +313,16 @@ static void HIDAPI_DriverFlydigi_SetAvailable(SDL_HIDAPI_Device *device, bool av
|
||||
}
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverFlydigi_WritePacket(SDL_HIDAPI_Device *device, const Uint8 *data, size_t size)
|
||||
static bool HIDAPI_DriverFlydigi_UsesUnnumberedReports(SDL_HIDAPI_Device *device)
|
||||
{
|
||||
// We know that at the very least the Vader 5 now uses unnumbered reports for commands instead of FLYDIGI_V2_CMD_REPORT_ID.
|
||||
// If other Flydigi things prove to do the same, we can tweak this check to be more general.
|
||||
bool bUsesUnnumberedReports = (device->vendor_id == USB_VENDOR_FLYDIGI_V2 && (device->product_id == USB_PRODUCT_FLYDIGI_V2_VADER || device->product_id == USB_PRODUCT_FLYDIGI_V2_APEX6));
|
||||
return (device->vendor_id == USB_VENDOR_FLYDIGI_V2 && (device->product_id == USB_PRODUCT_FLYDIGI_V2_VADER || device->product_id == USB_PRODUCT_FLYDIGI_V2_APEX6));
|
||||
}
|
||||
|
||||
if (bUsesUnnumberedReports && data[0] == FLYDIGI_V2_CMD_REPORT_ID) {
|
||||
static int HIDAPI_DriverFlydigi_WritePacket(SDL_HIDAPI_Device *device, const Uint8 *data, size_t size)
|
||||
{
|
||||
if (HIDAPI_DriverFlydigi_UsesUnnumberedReports(device) && data[0] == FLYDIGI_V2_CMD_REPORT_ID) {
|
||||
// Zero out the report byte.
|
||||
Uint8 output[USB_PACKET_LENGTH];
|
||||
SDL_memcpy(output, data, SDL_min(size, USB_PACKET_LENGTH));
|
||||
@@ -706,6 +709,9 @@ static bool HIDAPI_DriverFlydigi_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J
|
||||
Uint8 rumble_packet[] = { FLYDIGI_V2_CMD_REPORT_ID, FLYDIGI_V2_MAGIC1, FLYDIGI_V2_MAGIC2, FLYDIGI_V2_HAPTIC_COMMAND, 6, 0, 0, 0, 0, 0 };
|
||||
rumble_packet[5] = low_frequency_rumble >> 8;
|
||||
rumble_packet[6] = high_frequency_rumble >> 8;
|
||||
if (HIDAPI_DriverFlydigi_UsesUnnumberedReports(device)) {
|
||||
rumble_packet[0] = 0;
|
||||
}
|
||||
|
||||
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
|
||||
return SDL_SetError("Couldn't send rumble packet");
|
||||
|
||||
Reference in New Issue
Block a user