Skip to content

Commit 4cd889c

Browse files
endriftslouken
authored andcommitted
joystick: Several minor GIP fixes
This mostly fixes stylistic issues, but also fixes an issue with some controllers where an erroneous check would clear the DLI flag, offsetting the share button index so it wouldn't work.
1 parent 0a75482 commit 4cd889c

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/joystick/hidapi/SDL_hidapi_gip.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ static void GIP_MetadataFree(GIP_Metadata *metadata)
809809
SDL_memset(metadata, 0, sizeof(*metadata));
810810
}
811811

812-
static bool GIP_ParseDeviceMetadata(GIP_Metadata *metadata, const Uint8 *bytes, int num_bytes, int* offset)
812+
static bool GIP_ParseDeviceMetadata(GIP_Metadata *metadata, const Uint8 *bytes, int num_bytes, int *offset)
813813
{
814814
GIP_DeviceMetadata *device = &metadata->device;
815815
int buffer_offset;
@@ -956,7 +956,7 @@ static bool GIP_ParseDeviceMetadata(GIP_Metadata *metadata, const Uint8 *bytes,
956956
return true;
957957
}
958958

959-
static bool GIP_ParseMessageMetadata(GIP_MessageMetadata *metadata, const Uint8 *bytes, int num_bytes, int* offset)
959+
static bool GIP_ParseMessageMetadata(GIP_MessageMetadata *metadata, const Uint8 *bytes, int num_bytes, int *offset)
960960
{
961961
Uint16 length;
962962

@@ -1095,7 +1095,8 @@ static bool GIP_Acknowledge(
10951095
NULL);
10961096
}
10971097

1098-
static bool GIP_FragmentFailed(GIP_Attachment *attachment, const GIP_Header *header) {
1098+
static bool GIP_FragmentFailed(GIP_Attachment *attachment, const GIP_Header *header)
1099+
{
10991100
attachment->fragment_retries++;
11001101
if (attachment->fragment_retries > 8) {
11011102
if (attachment->fragment_data) {
@@ -1120,14 +1121,11 @@ static bool GIP_EnableEliteButtons(GIP_Attachment *attachment) {
11201121
*/
11211122
static const Uint8 enable_raw_report[] = { 7, 0 };
11221123

1123-
if (!GIP_SendVendorMessage(attachment,
1124+
return GIP_SendVendorMessage(attachment,
11241125
GIP_SL_ELITE_CONFIG,
11251126
0,
11261127
enable_raw_report,
1127-
sizeof(enable_raw_report)))
1128-
{
1129-
return false;
1130-
}
1128+
sizeof(enable_raw_report));
11311129
}
11321130

11331131
return true;
@@ -1565,10 +1563,10 @@ static bool GIP_HandleCommandMetadataRespose(
15651563
"GIP: Controller was missing expected GUID. This controller probably won't work on an actual Xbox.");
15661564
}
15671565

1568-
if ((attachment->features & GIP_CMD_GUIDE_COLOR) &&
1566+
if ((attachment->features & GIP_FEATURE_GUIDE_COLOR) &&
15691567
!GIP_SupportsVendorMessage(attachment, GIP_CMD_GUIDE_COLOR, false))
15701568
{
1571-
attachment->features &= ~GIP_CMD_GUIDE_COLOR;
1569+
attachment->features &= ~GIP_FEATURE_GUIDE_COLOR;
15721570
}
15731571

15741572
GIP_HandleQuirks(attachment);
@@ -1661,9 +1659,9 @@ static bool GIP_HandleCommandFirmware(
16611659
} else {
16621660
attachment->paddle_format = GIP_PADDLES_XBE2;
16631661
}
1662+
return GIP_EnableEliteButtons(attachment);
16641663
}
1665-
1666-
return GIP_EnableEliteButtons(attachment);
1664+
return true;
16671665
} else {
16681666
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "GIP: Unimplemented Firmware message");
16691667

@@ -1715,7 +1713,6 @@ static bool GIP_HandleCommandRawReport(
17151713
return true;
17161714
}
17171715

1718-
17191716
static bool GIP_HandleCommandHidReport(
17201717
GIP_Attachment *attachment,
17211718
const GIP_Header *header,
@@ -1886,8 +1883,6 @@ static void GIP_HandleNavigationReport(
18861883
} else {
18871884
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, ((bytes[1] & 0x10) != 0));
18881885
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, ((bytes[1] & 0x20) != 0));
1889-
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, ((bytes[1] & 0x40) != 0));
1890-
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, ((bytes[1] & 0x80) != 0));
18911886
}
18921887
}
18931888
}
@@ -1900,6 +1895,10 @@ static void GIP_HandleGamepadReport(
19001895
int num_bytes)
19011896
{
19021897
Sint16 axis;
1898+
1899+
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_STICK, ((bytes[1] & 0x40) != 0));
1900+
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, ((bytes[1] & 0x80) != 0));
1901+
19031902
axis = bytes[2];
19041903
axis |= bytes[3] << 8;
19051904
axis = SDL_clamp(axis, 0, 1023);
@@ -2241,7 +2240,7 @@ static bool GIP_HandleSystemMessage(
22412240
}
22422241
}
22432242

2244-
static GIP_Attachment * GIP_EnsureAttachment(GIP_Device *device, Uint8 attachment_index)
2243+
static GIP_Attachment *GIP_EnsureAttachment(GIP_Device *device, Uint8 attachment_index)
22452244
{
22462245
GIP_Attachment *attachment = device->attachments[attachment_index];
22472246
if (!attachment) {
@@ -2280,7 +2279,7 @@ static bool GIP_HandleMessage(
22802279
case GIP_LL_BUTTON_INFO_REPORT:
22812280
return GIP_HandleLLButtonInfoReport(attachment, header, bytes, num_bytes);
22822281
case GIP_LL_OVERFLOW_INPUT_REPORT:
2283-
return GIP_HandleLLOverflowInputReport(attachment, header, bytes, num_bytes);
2282+
return GIP_HandleLLOverflowInputReport(attachment, header, bytes, num_bytes);
22842283
}
22852284
}
22862285
SDL_LogWarn(SDL_LOG_CATEGORY_INPUT,

0 commit comments

Comments
 (0)