Fix volume scroll wheel
This commit is contained in:
Binary file not shown.
+25
-8
@@ -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,12 +184,13 @@ void startADC() {
|
||||
// process media key presses and prepare HID Consumer Control byte
|
||||
void send_media(uint8_t const* report, uint16_t len) {
|
||||
(void) len;
|
||||
if ( report[0]==0x05 ) {
|
||||
switch(report[2]) {
|
||||
case 0xB0: // set next button to vol up
|
||||
mediabit = 4;
|
||||
case 0xB0: // next
|
||||
mediabit = 0;
|
||||
break;
|
||||
case 0xB1: // set prev button to vol down
|
||||
mediabit = 5;
|
||||
case 0xB1: // prev
|
||||
mediabit = 1;
|
||||
break;
|
||||
case 0xB3: // play/pause
|
||||
mediabit = 2;
|
||||
@@ -211,6 +211,23 @@ void send_media(uint8_t const* report, uint16_t len) {
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// process new HID reports from the keyboard and set them up to forward to host
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ enum
|
||||
{
|
||||
HYPERX_KEYBOARD_VID = 0x0951,
|
||||
HYPERX_ELITE2_PID = 0x1711,
|
||||
NUM_KEYS = 128,
|
||||
NUM_KEYS = 129,
|
||||
BUF_SIZE = 64,
|
||||
NUM_PACKETS = 10,
|
||||
NKRO_BUF_SIZE = 15,
|
||||
|
||||
@@ -89,6 +89,5 @@ uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_t
|
||||
(void) buffer;
|
||||
(void) reqlen;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ void core1_main() {
|
||||
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
|
||||
pio_cfg.alarm_pool = (void*) alarm_pool_create(2,1);
|
||||
tuh_configure(1, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
|
||||
tuh_hid_set_default_protocol(HID_PROTOCOL_REPORT);
|
||||
tuh_init(1);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user