Fix volume scroll wheel

This commit is contained in:
2025-08-08 07:53:36 -04:00
parent 41d2eae1be
commit bab8f9678c
5 changed files with 55 additions and 38 deletions
Binary file not shown.
+46 -29
View File
@@ -11,8 +11,7 @@ static bool sending = false;
static absolute_time_t lastTime; static absolute_time_t lastTime;
static bool backlight = false; static bool backlight = false;
static const unsigned int SKIP_INDICES[] = { 23, 29, 41, 47, 70, 71, 76, 87, 88, 93, 99, 100, 102, 108, 113, 123 }; static const unsigned int SKIP_INDICES[] = { 23, 29, 41, 47, 70, 71, 76, 87, 88, 93, 99, 100, 102, 108, 113 };
// added play/pause (123)
static unsigned char buf[BUF_SIZE]; static unsigned char buf[BUF_SIZE];
static uint8_t buf_idx=0; static uint8_t buf_idx=0;
@@ -100,8 +99,8 @@ void send_color(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t r
} else { } else {
// start by sending color init byte for the current key // start by sending color init byte for the current key
buf[buf_idx] = 0x81; buf[buf_idx] = 0x81;
// turn rewind and fast forward keys to white // turn rewind, play, and fast forward keys to white
if(color_idx==105 || color_idx== 108) { if(color_idx==105 || color_idx==108 || color_idx==109) {
buf[buf_idx + 1] = 0x20; buf[buf_idx + 1] = 0x20;
buf[buf_idx + 2] = 0x20; buf[buf_idx + 2] = 0x20;
buf[buf_idx + 3] = 0x20; buf[buf_idx + 3] = 0x20;
@@ -185,32 +184,50 @@ void startADC() {
// process media key presses and prepare HID Consumer Control byte // process media key presses and prepare HID Consumer Control byte
void send_media(uint8_t const* report, uint16_t len) { void send_media(uint8_t const* report, uint16_t len) {
(void) len; (void) len;
switch(report[2]) { if ( report[0]==0x05 ) {
case 0xB0: // set next button to vol up switch(report[2]) {
mediabit = 4; case 0xB0: // next
break; mediabit = 0;
case 0xB1: // set prev button to vol down break;
mediabit = 5; case 0xB1: // prev
break; mediabit = 1;
case 0xB3: // play/pause break;
mediabit = 2; case 0xB3: // play/pause
break; mediabit = 2;
case 0xB5: // mute break;
mediabit = 3; case 0xB5: // mute
if (report[3]) { mediabit = 3;
mute = !mute; if (report[3]) {
} mute = !mute;
break; }
default: break;
return; default:
return;
}
if (report[3]) {
SET_KEYBIT(mediakeys, mediabit);
} else {
CLEAR_KEYBIT(mediakeys, mediabit);
}
// set flag to send media keys during the next sending round
sendmedia = true;
} else if ( report[0]==0x03 ) {
switch(report[1]) {
case 0xE9: // vol up
SET_KEYBIT(mediakeys, 4);
break;
case 0xEA: // vol down
SET_KEYBIT(mediakeys, 5);
break;
case 0x00: // none
CLEAR_KEYBIT(mediakeys, 4);
CLEAR_KEYBIT(mediakeys, 5);
break;
default:
return;
}
sendmedia = true;
} }
if (report[3]) {
SET_KEYBIT(mediakeys, mediabit);
} else {
CLEAR_KEYBIT(mediakeys, mediabit);
}
// set flag to send media keys during the next sending round
sendmedia = true;
} }
// process new HID reports from the keyboard and set them up to forward to host // process new HID reports from the keyboard and set them up to forward to host
+1 -1
View File
@@ -5,7 +5,7 @@ enum
{ {
HYPERX_KEYBOARD_VID = 0x0951, HYPERX_KEYBOARD_VID = 0x0951,
HYPERX_ELITE2_PID = 0x1711, HYPERX_ELITE2_PID = 0x1711,
NUM_KEYS = 128, NUM_KEYS = 129,
BUF_SIZE = 64, BUF_SIZE = 64,
NUM_PACKETS = 10, NUM_PACKETS = 10,
NKRO_BUF_SIZE = 15, NKRO_BUF_SIZE = 15,
+7 -8
View File
@@ -82,13 +82,12 @@ void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_
// Return zero will cause the stack to STALL request // Return zero will cause the stack to STALL request
uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{ {
// TODO not Implemented // TODO not Implemented
(void) instance; (void) instance;
(void) report_id; (void) report_id;
(void) report_type; (void) report_type;
(void) buffer; (void) buffer;
(void) reqlen; (void) reqlen;
return 0;
return 0;
} }
+1
View File
@@ -24,6 +24,7 @@ void core1_main() {
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG; pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
pio_cfg.alarm_pool = (void*) alarm_pool_create(2,1); pio_cfg.alarm_pool = (void*) alarm_pool_create(2,1);
tuh_configure(1, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg); tuh_configure(1, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
tuh_hid_set_default_protocol(HID_PROTOCOL_REPORT);
tuh_init(1); tuh_init(1);