1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-29 13:02:09 +00:00

bdk: usb: add Sio support to hid gadget

This commit is contained in:
CTCaer 2022-05-09 06:10:49 +03:00
parent f31170bb51
commit 54b054c940

View file

@ -159,14 +159,22 @@ static bool _jc_poll(gamepad_report_t *rpt)
u16 y_raw = (jc_pad->lstick_y - jc_cal_ctx.cly_max) / 7; u16 y_raw = (jc_pad->lstick_y - jc_cal_ctx.cly_max) / 7;
if (y_raw > 0x7F) if (y_raw > 0x7F)
y_raw = 0x7F; y_raw = 0x7F;
rpt->y = 0x7F - y_raw; // Hoag has inverted Y axis.
if (!jc_pad->sio_mode)
rpt->y = 0x7F - y_raw;
else
rpt->y = 0x7F + y_raw;
} }
else else
{ {
u16 y_raw = (jc_cal_ctx.cly_min - jc_pad->lstick_y) / 7; u16 y_raw = (jc_cal_ctx.cly_min - jc_pad->lstick_y) / 7;
if (y_raw > 0x7F) if (y_raw > 0x7F)
y_raw = 0x7F; y_raw = 0x7F;
rpt->y = 0x7F + y_raw; // Hoag has inverted Y axis.
if (!jc_pad->sio_mode)
rpt->y = 0x7F + y_raw;
else
rpt->y = 0x7F - y_raw;
} }
// Calculate right analog stick. // Calculate right analog stick.
@ -194,14 +202,22 @@ static bool _jc_poll(gamepad_report_t *rpt)
u16 y_raw = (jc_pad->rstick_y - jc_cal_ctx.cry_max) / 7; u16 y_raw = (jc_pad->rstick_y - jc_cal_ctx.cry_max) / 7;
if (y_raw > 0x7F) if (y_raw > 0x7F)
y_raw = 0x7F; y_raw = 0x7F;
rpt->rz = 0x7F - y_raw; // Hoag has inverted Y axis.
if (!jc_pad->sio_mode)
rpt->rz = 0x7F - y_raw;
else
rpt->rz = 0x7F + y_raw;
} }
else else
{ {
u16 y_raw = (jc_cal_ctx.cry_min - jc_pad->rstick_y) / 7; u16 y_raw = (jc_cal_ctx.cry_min - jc_pad->rstick_y) / 7;
if (y_raw > 0x7F) if (y_raw > 0x7F)
y_raw = 0x7F; y_raw = 0x7F;
rpt->rz = 0x7F + y_raw; // Hoag has inverted Y axis.
if (!jc_pad->sio_mode)
rpt->rz = 0x7F + y_raw;
else
rpt->rz = 0x7F - y_raw;
} }
// Set D-pad. // Set D-pad.
@ -361,7 +377,7 @@ int usb_device_gadget_hid(usb_ctxt_t *usbs)
if (usbs->type == USB_HID_GAMEPAD) if (usbs->type == USB_HID_GAMEPAD)
{ {
polling_time = 8000; polling_time = 15000;
gadget_type = USB_GADGET_HID_GAMEPAD; gadget_type = USB_GADGET_HID_GAMEPAD;
} }
else else