Full 11 bit USB HID gamepad resolution and fixed offsets for compatibility (#5825)

* Changed USB Gamepad resolution to full 11 bit and fixed offset issues for some games

* Changed USB Gamepad resolution to full 11 bit and fixed offset issues for some games

* Changed USB Gamepad resolution to full 11 bit and fixed offset issues for some games
This commit is contained in:
Yannick Richter
2018-06-29 08:07:30 +02:00
committed by Bertrand Songis
parent 71912cfdbd
commit 9cbd0b9813
3 changed files with 11 additions and 8 deletions
@@ -151,10 +151,13 @@ void usbJoystickUpdate()
//analog values
//uint8_t * p = HID_Buffer + 1;
for (int i = 0; i < 8; ++i) {
int16_t value = channelOutputs[i] / 8;
if ( value > 127 ) value = 127;
else if ( value < -127 ) value = -127;
HID_Buffer[i+3] = static_cast<int8_t>(value);
int16_t value = channelOutputs[i] + 1024;
if ( value > 2047 ) value = 2047;
else if ( value < 0 ) value = 0;
HID_Buffer[i*2 +3] = static_cast<uint8_t>(value & 0xFF);
HID_Buffer[i*2 +4] = static_cast<uint8_t>((value >> 8) & 0x07);
}
USBD_HID_SendReport(&USB_OTG_dev, HID_Buffer, HID_IN_PACKET);
}
@@ -47,7 +47,7 @@
#define HID_IN_EP 0x81
#define HID_OUT_EP 0x01
#define HID_IN_PACKET 11
#define HID_IN_PACKET 19
#define HID_OUT_PACKET 9
#define CDC_IN_EP 0x81 /* EP1 for data IN */
@@ -132,9 +132,9 @@ __ALIGN_BEGIN static const uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
0x09, 0x35, // USAGE (Rz)
0x09, 0x36, // USAGE (Slider)
0x09, 0x36, // USAGE (Slider)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x16, 0x00, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xFF, 0x07, // LOGICAL_MAXIMUM (2047)
0x75, 0x10, // REPORT_SIZE (16)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION