Skip to content

Commit 15c6acf

Browse files

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/joystick/hidapi/SDL_hidapi_lg4ff.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static int HIDAPI_DriverLg4ff_GetNumberOfButtons(Uint32 device_id)
7575
case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
7676
return 25;
7777
case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
78-
return 22;
78+
return 23;
7979
case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
8080
return 19;
8181
case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
@@ -647,6 +647,19 @@ static bool HIDAPI_DriverLg4ff_HandleState(SDL_HIDAPI_Device *device,
647647
SDL_assert(0);
648648
}
649649

650+
if (device->product_id == USB_DEVICE_ID_LOGITECH_G27_WHEEL) {
651+
// ref https://github.com/sonik-br/lgff_wheel_adapter/blob/d97f7823154818e1b3edff6d51498a122c302728/pico_lgff_wheel_adapter/reports.h#L265-L310
652+
// shifter_r is outside of the main button bit field for this particular wheel
653+
num_buttons--;
654+
655+
bool button_on = HIDAPI_DriverLg4ff_GetBit(report_buf, 80, report_size);
656+
bool button_was_on = HIDAPI_DriverLg4ff_GetBit(ctx->last_report_buf, 80, report_size);
657+
if (button_on != button_was_on) {
658+
state_changed = true;
659+
SDL_SendJoystickButton(timestamp, joystick, (Uint8)(SDL_GAMEPAD_BUTTON_SOUTH + num_buttons), button_on);
660+
}
661+
}
662+
650663
for (int i = 0;i < num_buttons;i++) {
651664
int bit_num = bit_offset + i;
652665
bool button_on = HIDAPI_DriverLg4ff_GetBit(report_buf, bit_num, report_size);

0 commit comments

Comments
 (0)