diff --git a/Production/Firmware/chu_pico.uf2 b/Production/Firmware/chu_pico.uf2 index 8b9247c..304de68 100644 Binary files a/Production/Firmware/chu_pico.uf2 and b/Production/Firmware/chu_pico.uf2 differ diff --git a/firmware/src/board_defs.h b/firmware/src/board_defs.h index 9d7b853..256720f 100644 --- a/firmware/src/board_defs.h +++ b/firmware/src/board_defs.h @@ -20,6 +20,7 @@ #define RGB_PIN 2 #define RGB_ORDER GRB // or RGB +#define NKRO_KEYMAP "1aqz2swx3dec4frv5gtb6hyn7jum8ki90olp,." #else #endif diff --git a/firmware/src/main.c b/firmware/src/main.c index ce696c9..ee5683f 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -21,6 +21,7 @@ #include "tusb.h" #include "usb_descriptors.h" +#include "board_defs.h" #include "slider.h" #include "air.h" #include "rgb.h" @@ -117,12 +118,11 @@ static void gen_joy_report() } const uint8_t keycode_table[128][2] = { HID_ASCII_TO_KEYCODE }; - -const char keymap[33] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456"; +const char keymap[38 + 1] = NKRO_KEYMAP; // 32 keys, 6 air keys, 1 terminator static void gen_nkro_report() { for (int i = 0; i < 32; i++) { - uint8_t code = keycode_table[i + 'A'][1]; + uint8_t code = keycode_table[keymap[i]][1]; uint8_t byte = code / 8; uint8_t bit = code % 8; if (slider_touched(i)) { @@ -131,6 +131,16 @@ static void gen_nkro_report() hid_nkro.keymap[byte] &= ~(1 << bit); } } + for (int i = 0; i < 6; i++) { + uint8_t code = keycode_table[keymap[32 + i]][1]; + uint8_t byte = code / 8; + uint8_t bit = code % 8; + if (hid_joy.buttons & (1 << i)) { + hid_nkro.keymap[byte] |= (1 << bit); + } else { + hid_nkro.keymap[byte] &= ~(1 << bit); + } + } } static uint64_t last_hid_time = 0;