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:
committed by
Bertrand Songis
parent
71912cfdbd
commit
9cbd0b9813
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user