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
+46 -29
View File
@@ -11,8 +11,7 @@ static bool sending = false;
static absolute_time_t lastTime;
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 };
// added play/pause (123)
static const unsigned int SKIP_INDICES[] = { 23, 29, 41, 47, 70, 71, 76, 87, 88, 93, 99, 100, 102, 108, 113 };
static unsigned char buf[BUF_SIZE];
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 {
// start by sending color init byte for the current key
buf[buf_idx] = 0x81;
// turn rewind and fast forward keys to white
if(color_idx==105 || color_idx== 108) {
// turn rewind, play, and fast forward keys to white
if(color_idx==105 || color_idx==108 || color_idx==109) {
buf[buf_idx + 1] = 0x20;
buf[buf_idx + 2] = 0x20;
buf[buf_idx + 3] = 0x20;
@@ -185,32 +184,50 @@ void startADC() {
// process media key presses and prepare HID Consumer Control byte
void send_media(uint8_t const* report, uint16_t len) {
(void) len;
switch(report[2]) {
case 0xB0: // set next button to vol up
mediabit = 4;
break;
case 0xB1: // set prev button to vol down
mediabit = 5;
break;
case 0xB3: // play/pause
mediabit = 2;
break;
case 0xB5: // mute
mediabit = 3;
if (report[3]) {
mute = !mute;
}
break;
default:
return;
if ( report[0]==0x05 ) {
switch(report[2]) {
case 0xB0: // next
mediabit = 0;
break;
case 0xB1: // prev
mediabit = 1;
break;
case 0xB3: // play/pause
mediabit = 2;
break;
case 0xB5: // mute
mediabit = 3;
if (report[3]) {
mute = !mute;
}
break;
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