Update hid_app.c

This commit is contained in:
Liz 2025-04-08 15:40:15 -04:00
parent 547136cf39
commit a5a4294f9c

View file

@ -379,29 +379,29 @@ static void process_gamepad_report(const uint8_t *report) {
// Directional Controls // Directional Controls
// Left is when byte 2 is close to 0x00 // Left is when byte 2 is close to 0x00
if (report[2] < 0x40) { if (report[1] < 0x40) {
decoded_report |= MASK_JOY2_RIGHT; // Note: swapped due to gameboy mapping decoded_report |= MASK_JOY2_RIGHT; // Note: swapped due to gameboy mapping
} }
// Right is when byte 2 is close to 0xFF // Right is when byte 2 is close to 0xFF
if (report[2] > 0xB0) { if (report[1] > 0xB0) {
decoded_report |= MASK_JOY2_LEFT; // Note: swapped due to gameboy mapping decoded_report |= MASK_JOY2_LEFT; // Note: swapped due to gameboy mapping
} }
// Up is when byte 1 is close to 0x00 // Up is when byte 1 is close to 0x00
if (report[1] < 0x40) { if (report[2] < 0x40) {
decoded_report |= MASK_JOY2_UP; decoded_report |= MASK_JOY2_UP;
} }
// Down is when byte 1 is close to 0xFF // Down is when byte 1 is close to 0xFF
if (report[1] > 0xB0) { if (report[2] > 0xB0) {
decoded_report |= MASK_JOY2_DOWN; decoded_report |= MASK_JOY2_DOWN;
} }
// A Button (check for 0x2F or 0x1F in byte 6) // A Button (check for 0x2F or 0x1F in byte 6)
if ((report[6] & 0x20) || (report[6] & 0x10)) { if ((report[6] & 0x2F) || (report[6] & 0x1F)) {
decoded_report |= MASK_KEY_USER3; decoded_report |= MASK_KEY_USER3;
} }
// B Button (check for 0x4F or 0x8F in byte 6) // B Button (check for 0x4F or 0x8F in byte 6)
if ((report[6] & 0x40) || (report[6] & 0x80)) { if ((report[6] & 0x4F) || (report[6] & 0x8F)) {
decoded_report |= MASK_JOY2_BTN; decoded_report |= MASK_JOY2_BTN;
} }
@ -481,7 +481,7 @@ int proto = tuh_hid_interface_protocol (dev_addr, instance);
process_kbd_report ((hid_keyboard_report_t const*) report); process_kbd_report ((hid_keyboard_report_t const*) report);
break; break;
case HID_ITF_PROTOCOL_NONE: case HID_ITF_PROTOCOL_NONE:
if (len >= 8 && len <= 9) { if (len >= 8) {
process_gamepad_report(report); process_gamepad_report(report);
} }
break; break;