@@ -393,7 +393,7 @@ typedef struct GIP_Metadata
393
393
Uint16 version_minor ;
394
394
395
395
GIP_DeviceMetadata device ;
396
-
396
+
397
397
Uint8 num_messages ;
398
398
GIP_MessageMetadata * message_metadata ;
399
399
} GIP_Metadata ;
@@ -575,6 +575,7 @@ static bool GIP_SupportsVendorMessage(GIP_Device *device, Uint8 command, bool up
575
575
static Uint8 GIP_SequenceNext (GIP_Device * device , Uint8 command , bool system )
576
576
{
577
577
Uint8 seq ;
578
+
578
579
if (system ) {
579
580
switch (command ) {
580
581
case GIP_CMD_SECURITY :
@@ -603,6 +604,11 @@ static Uint8 GIP_SequenceNext(GIP_Device *device, Uint8 command, bool system)
603
604
break ;
604
605
}
605
606
} else {
607
+ if (command == GIP_CMD_DIRECT_MOTOR ) {
608
+ // The motor sequence number is optional and always works with 0
609
+ return 0 ;
610
+ }
611
+
606
612
seq = device -> seq_vendor ++ ;
607
613
if (!seq ) {
608
614
seq = device -> seq_vendor ++ ;
@@ -792,7 +798,7 @@ static bool GIP_ParseDeviceMetadata(GIP_Metadata *metadata, const Uint8 *bytes,
792
798
793
799
for (i = 0 ; i < count ; i ++ ) {
794
800
Uint8 message = bytes [buffer_offset + 1 + i ];
795
- device -> in_system_messages [message >> 5 ] |= 1u << (message & 0x1F );
801
+ device -> in_system_messages [message >> 5 ] |= 1u << (message & 0x1F );
796
802
}
797
803
}
798
804
@@ -809,7 +815,7 @@ static bool GIP_ParseDeviceMetadata(GIP_Metadata *metadata, const Uint8 *bytes,
809
815
810
816
for (i = 0 ; i < count ; i ++ ) {
811
817
Uint8 message = bytes [buffer_offset + 1 + i ];
812
- device -> out_system_messages [message >> 5 ] |= 1u << (message & 0x1F );
818
+ device -> out_system_messages [message >> 5 ] |= 1u << (message & 0x1F );
813
819
}
814
820
}
815
821
@@ -1122,7 +1128,7 @@ static bool GIP_SendInitSequence(GIP_Device *device)
1122
1128
1123
1129
static bool GIP_EnsureMetadata (GIP_Device * device )
1124
1130
{
1125
-
1131
+
1126
1132
switch (device -> got_metadata ) {
1127
1133
case GIP_METADATA_GOT :
1128
1134
case GIP_METADATA_FAKED :
@@ -1147,8 +1153,6 @@ static bool GIP_EnsureMetadata(GIP_Device *device)
1147
1153
1148
1154
static bool GIP_SetMetadataDefaults (GIP_Device * device )
1149
1155
{
1150
- int seq ;
1151
-
1152
1156
/* Some decent default settings */
1153
1157
device -> features |= GIP_FEATURE_MOTOR_CONTROL ;
1154
1158
device -> device_type = GIP_TYPE_GAMEPAD ;
@@ -1164,23 +1168,6 @@ static bool GIP_SetMetadataDefaults(GIP_Device *device)
1164
1168
GIP_SendQueryFirmware (device , 2 );
1165
1169
}
1166
1170
1167
- if (device -> features & GIP_FEATURE_MOTOR_CONTROL ) {
1168
- for (seq = 1 ; seq < 0x100 ; seq ++ ) {
1169
- Uint8 message [9 ] = {0 };
1170
-
1171
- /* Try all sequence numbers to reset it to 1 */
1172
- GIP_SendRawMessage (device ,
1173
- GIP_CMD_DIRECT_MOTOR ,
1174
- 0 ,
1175
- (Uint8 ) seq ,
1176
- message ,
1177
- sizeof (message ),
1178
- true,
1179
- NULL ,
1180
- NULL );
1181
- }
1182
- }
1183
-
1184
1171
device -> got_metadata = GIP_METADATA_FAKED ;
1185
1172
device -> hello_deadline = 0 ;
1186
1173
return HIDAPI_JoystickConnected (device -> device , NULL );
@@ -1512,7 +1499,7 @@ static bool GIP_HandleCommandGuideButtonStatus(
1512
1499
if (!joystick ) {
1513
1500
return false;
1514
1501
}
1515
- if (bytes [1 ] == VK_LWIN ) {
1502
+ if (bytes [1 ] == VK_LWIN ) {
1516
1503
SDL_SendJoystickButton (timestamp , joystick , SDL_GAMEPAD_BUTTON_GUIDE , (bytes [0 ] & 0x01 ) != 0 );
1517
1504
}
1518
1505
@@ -1815,7 +1802,7 @@ static bool GIP_HandleLLInputReport(
1815
1802
(bytes [device -> paddle_offset ] & 0x08 ) != 0 );
1816
1803
}
1817
1804
}
1818
-
1805
+
1819
1806
if ((device -> features & GIP_FEATURE_CONSOLE_FUNCTION_MAP ) && num_bytes >= 32 ) {
1820
1807
int function_map_offset = -1 ;
1821
1808
if (device -> features & GIP_FEATURE_DYNAMIC_LATENCY_INPUT ) {
@@ -2057,7 +2044,7 @@ static int GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_byt
2057
2044
device -> fragment_data = NULL ;
2058
2045
}
2059
2046
device -> fragment_message = 0 ;
2060
- }
2047
+ }
2061
2048
fragment_offset += header .length ;
2062
2049
device -> fragment_offset = (Uint16 ) fragment_offset ;
2063
2050
}
0 commit comments