diff --git a/build/hyperx_kb_rgb.uf2 b/build/hyperx_kb_rgb.uf2 index 22a23fb..eb60347 100644 Binary files a/build/hyperx_kb_rgb.uf2 and b/build/hyperx_kb_rgb.uf2 differ diff --git a/hyperx_elite2.c b/hyperx_elite2.c index fe7b316..790c6b1 100644 --- a/hyperx_elite2.c +++ b/hyperx_elite2.c @@ -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 diff --git a/hyperx_elite2.h b/hyperx_elite2.h index d125425..da8ba67 100644 --- a/hyperx_elite2.h +++ b/hyperx_elite2.h @@ -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, diff --git a/main_device.c b/main_device.c index cb9981f..06a7170 100644 --- a/main_device.c +++ b/main_device.c @@ -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 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 - (void) instance; - (void) report_id; - (void) report_type; - (void) buffer; - (void) reqlen; + // TODO not Implemented + (void) instance; + (void) report_id; + (void) report_type; + (void) buffer; + (void) reqlen; - - return 0; + return 0; } diff --git a/main_host.c b/main_host.c index 20c64f9..03ab954 100644 --- a/main_host.c +++ b/main_host.c @@ -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);