Skip to content

Commit

Permalink
Merge pull request #407 from shorepine/18bytes
Browse files Browse the repository at this point in the history
debugging 44 key from discord
  • Loading branch information
bwhitman authored Oct 19, 2024
2 parents 74e192f + e9004ee commit 1b1b703
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tulip/esp32s3/usb_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,7 @@ void decode_keyboard_report(uint8_t *p) {
// Second byte, reserved
// next 6 bytes, scan codes (for rollover)

#ifdef DEBUG_USB
//fprintf(stderr,"decode report %d %d %d %d %d %d\n", p[2],p[3],p[4],p[5],p[6],p[7]);
#endif

for(uint8_t i=2;i<8;i++) {
if(p[i]!=0) {
key_held_this_session = 1;
Expand Down Expand Up @@ -581,10 +579,16 @@ void keyboard_transfer_cb(usb_transfer_t *transfer)
} else if (transfer->actual_num_bytes == 10) {
uint8_t *const p = transfer->data_buffer;
decode_keyboard_report(p+1);
} else if (transfer->actual_num_bytes == 17 || transfer->actual_num_bytes == 32) {
// This is a weird keyboard (8bitdo retro, custom 40 key ortho) that uses USB FS HID and sends keys as a bitmask.
} else {
// This is a weird keyboard (8bitdo retro, custom 40 key ortho, custom 44 key) that uses USB FS HID and sends keys as a bitmask.
// I found people talking about this here but no code, so here i am https://stackoverflow.com/questions/57793525/unusual-usb-hid-reports
// I'm still not sure how to determine between "normal" scan code buffers or these types other than looking at actual_num_bytes
uint8_t *const p = transfer->data_buffer;
#ifdef DEBUG_USB
if(transfer->actual_num_bytes == 18) {
fprintf(stderr,"debugging weird kb: decode report %d %d %d %d %d %d %d %d %d %d\n", p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
}
#endif
// We treat each bit on position as a index into a scan code, and will add it to a new buffer for decode_report to deal with
uint8_t new_decode[8];
for(uint8_t i=0;i<8;i++) new_decode[i] = 0;
Expand All @@ -602,8 +606,6 @@ void keyboard_transfer_cb(usb_transfer_t *transfer)
}
}
decode_keyboard_report(new_decode);
} else {
fprintf(stderr, "Keyboard boot hid transfer (%d bytes) not supported\n", transfer->actual_num_bytes);
}
}
else {
Expand Down

0 comments on commit 1b1b703

Please sign in to comment.