1
0
mirror of https://github.com/whowechina/chu_pico.git synced 2024-11-24 19:10:11 +01:00
This commit is contained in:
whowechina 2023-09-14 22:33:26 +08:00
commit ed1af36ef6
3 changed files with 14 additions and 3 deletions

Binary file not shown.

View File

@ -20,6 +20,7 @@
#define RGB_PIN 2
#define RGB_ORDER GRB // or RGB
#define NKRO_KEYMAP "1aqz2swx3dec4frv5gtb6hyn7jum8ki90olp,."
#else
#endif

View File

@ -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;