Use motor sequence ID 0 in the HIDAPI GIP driver

Using a 0 sequence number is always allowed and avoids having to synchronize sequence numbers with the controller (and potentially confusing other things talking to the controller)

Also fixes occasional long running rumble at controller connection.
This commit is contained in:
Sam Lantinga 2025-05-02 10:19:57 -07:00
parent 33e5f4885a
commit f8c77908ad
1 changed files with 13 additions and 26 deletions

View File

@ -575,6 +575,7 @@ static bool GIP_SupportsVendorMessage(GIP_Device *device, Uint8 command, bool up
static Uint8 GIP_SequenceNext(GIP_Device *device, Uint8 command, bool system)
{
Uint8 seq;
if (system) {
switch (command) {
case GIP_CMD_SECURITY:
@ -603,6 +604,11 @@ static Uint8 GIP_SequenceNext(GIP_Device *device, Uint8 command, bool system)
break;
}
} else {
if (command == GIP_CMD_DIRECT_MOTOR) {
// The motor sequence number is optional and always works with 0
return 0;
}
seq = device->seq_vendor++;
if (!seq) {
seq = device->seq_vendor++;
@ -1147,8 +1153,6 @@ static bool GIP_EnsureMetadata(GIP_Device *device)
static bool GIP_SetMetadataDefaults(GIP_Device *device)
{
int seq;
/* Some decent default settings */
device->features |= GIP_FEATURE_MOTOR_CONTROL;
device->device_type = GIP_TYPE_GAMEPAD;
@ -1164,23 +1168,6 @@ static bool GIP_SetMetadataDefaults(GIP_Device *device)
GIP_SendQueryFirmware(device, 2);
}
if (device->features & GIP_FEATURE_MOTOR_CONTROL) {
for (seq = 1; seq < 0x100; seq++) {
Uint8 message[9] = {0};
/* Try all sequence numbers to reset it to 1 */
GIP_SendRawMessage(device,
GIP_CMD_DIRECT_MOTOR,
0,
(Uint8) seq,
message,
sizeof(message),
true,
NULL,
NULL);
}
}
device->got_metadata = GIP_METADATA_FAKED;
device->hello_deadline = 0;
return HIDAPI_JoystickConnected(device->device, NULL);