commit 878eb23b8394109aeb32cd505f79b96c74ec97f6
parent d7c506450be613d6575649218fbcc90a4fabd150
Author: Louis Burda <quent.burda@gmail.com>
Date: Mon, 19 Dec 2022 19:29:41 +0100
Add special hid functionality, consumer control working
Diffstat:
19 files changed, 1225 insertions(+), 962 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -18,6 +18,8 @@ target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/util.c
${CMAKE_CURRENT_SOURCE_DIR}/src/hid.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/keysym/consumer.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/keysym/system.c
${CMAKE_CURRENT_SOURCE_DIR}/src/split.c
${CMAKE_CURRENT_SOURCE_DIR}/src/ws2812.c
${CMAKE_CURRENT_SOURCE_DIR}/src/led.c
diff --git a/src/hid.c b/src/hid.c
@@ -1,5 +1,11 @@
#include "hid.h"
-#include "keycode.h"
+
+#include "keysym/consumer.h"
+#include "keysym/system.h"
+#include "hid/keyboard.h"
+#include "hid/consumer.h"
+#include "hid/system.h"
+
#include "split.h"
#include "keymat.h"
#include "keysym.h"
@@ -9,6 +15,7 @@
#include "bsp/board.h"
#include "pico/types.h"
+#include <stdbool.h>
#include <string.h>
struct layerkey {
@@ -16,10 +23,31 @@ struct layerkey {
uint key;
};
-struct hid_report {
+struct hid_keyboard_report {
uint8_t mods;
uint8_t codes[6];
- uint8_t codecnt;
+ uint8_t cnt;
+};
+
+struct hid_mouse_report {
+ uint8_t btns;
+ int8_t x, y;
+ int8_t v, h;
+};
+
+struct hid_consumer_report {
+ uint16_t code;
+};
+
+struct hid_system_report {
+ uint16_t code;
+};
+
+struct hid_gamepad_report {
+ int8_t x, y, z;
+ int8_t rx, ry, rz;
+ uint8_t hat;
+ uint32_t btns;
};
static uint32_t keysyms[KEY_ROWS][KEY_COLS] = { 0 };
@@ -27,15 +55,27 @@ static uint32_t keysyms[KEY_ROWS][KEY_COLS] = { 0 };
static struct layerkey active_stack[16] = { 0 };
static uint active_top = 0;
-static struct hid_report hid_report_prev;
-static struct hid_report hid_report;
+static struct hid_keyboard_report keyboard_report_prev = { 0 };
+static struct hid_keyboard_report keyboard_report = { 0 };
+
+static struct hid_mouse_report mouse_report_prev = { 0 };
+static struct hid_mouse_report mouse_report = { 0 };
+
+static struct hid_consumer_report consumer_report_prev = { 0 };
+static struct hid_consumer_report consumer_report = { 0 };
-static uint8_t active_weak_mods;
-static uint8_t active_mods;
+static struct hid_system_report system_report_prev = { 0 };
+static struct hid_system_report system_report = { 0 };
+
+static struct hid_gamepad_report gamepad_report_prev = { 0 };
+static struct hid_gamepad_report gamepad_report = { 0 };
+
+static uint8_t active_weak_mods = 0;
+static uint8_t active_mods = 0;
static uint64_t bounce_mat[KEY_ROWS][KEY_COLS] = { 0 };
-static bool seen_mat[KEY_ROWS][KEY_COLS];
+static bool seen_mat[KEY_ROWS][KEY_COLS] = { 0 };
static void active_pop(uint layer);
static void active_push(uint layer, uint key);
@@ -75,13 +115,13 @@ active_push(uint layer, uint key)
void
add_keycode(uint8_t keycode)
{
- if (hid_report.codecnt >= 6) {
+ if (keyboard_report.cnt >= 6) {
WARN("HID report overflow");
return;
}
- hid_report.codes[hid_report.codecnt] = keycode;
- hid_report.codecnt++;
+ keyboard_report.codes[keyboard_report.cnt] = keycode;
+ keyboard_report.cnt++;
}
uint8_t
@@ -141,6 +181,9 @@ handle_keypress_new(uint x, uint y)
/* FIXME: two keys pressed at the exact same time with
* different weak modifiers will not be reported correctly */
active_weak_mods = parse_modifiers(keysyms[y][x]);
+ } else if (IS_CONSUMER(keysyms[y][x])) {
+ consumer_report.code = keysym_to_consumer(keysyms[y][x]);
+ INFO("CONSUMER KEY %i", consumer_report.code);
}
}
@@ -217,47 +260,110 @@ update_report(void)
bool
send_keyboard_report(void)
{
- hid_report.mods = active_weak_mods | active_mods;
- if (memcmp(&hid_report, &hid_report_prev, sizeof(hid_report))) {
+ bool sent;
+
+ sent = false;
+ keyboard_report.mods = active_weak_mods | active_mods;
+ if (memcmp(&keyboard_report, &keyboard_report_prev,
+ sizeof(keyboard_report))) {
tud_hid_keyboard_report(REPORT_ID_KEYBOARD,
- hid_report.mods, hid_report.codes);
- memcpy(&hid_report_prev, &hid_report, sizeof(hid_report));
- return true;
+ keyboard_report.mods, keyboard_report.codes);
+ memcpy(&keyboard_report_prev, &keyboard_report,
+ sizeof(keyboard_report));
+ sent = true;
}
- return false;
+ memset(&keyboard_report, 0, sizeof(keyboard_report));
+ active_mods = 0;
+ memset(seen_mat, 0, sizeof(seen_mat));
+
+ return sent;
}
bool
-send_mouse_report(bool state)
+send_consumer_report(void)
{
- if (state) {
- tud_hid_mouse_report(REPORT_ID_MOUSE, 0, 10, 10, 0, 0);
+ bool sent;
+
+ INFO("CONSUMER %u", consumer_report.code);
+
+ sent = false;
+ if (memcmp(&consumer_report, &consumer_report_prev,
+ sizeof(consumer_report))) {
+ tud_hid_report(REPORT_ID_CONSUMER,
+ &consumer_report.code, 2);
+ memcpy(&consumer_report_prev, &consumer_report,
+ sizeof(consumer_report));
return true;
}
- return false;
+ memset(&consumer_report, 0, sizeof(consumer_report));
+
+ return sent;
}
bool
-send_consumer_control_report(bool state)
+send_system_report(void)
{
- static bool cleared = true;
- uint16_t report;
+ bool sent;
+
+ sent = false;
+ if (memcmp(&system_report, &system_report_prev,
+ sizeof(system_report))) {
+ tud_hid_report(REPORT_ID_SYSTEM,
+ &system_report.code, 2);
+ memcpy(&system_report_prev, &system_report,
+ sizeof(system_report));
+ sent = true;
+ }
- if (state) {
- report = HID_USAGE_CONSUMER_VOLUME_DECREMENT;
- tud_hid_report(REPORT_ID_CONSUMER_CONTROL, &report, 2);
- cleared = false;
- return true;
- } else if (!cleared) {
- report = 0;
- tud_hid_report(REPORT_ID_CONSUMER_CONTROL, &report, 2);
- cleared = true;
- return true;
+ memset(&system_report, 0, sizeof(system_report));
+
+ return sent;
+}
+
+bool
+send_mouse_report(void)
+{
+ bool sent;
+
+ sent = false;
+ if (memcmp(&mouse_report, &mouse_report_prev,
+ sizeof(mouse_report))) {
+ tud_hid_mouse_report(REPORT_ID_KEYBOARD,
+ mouse_report.btns,
+ mouse_report.x, mouse_report.y,
+ mouse_report.h, mouse_report.v);
+ memcpy(&mouse_report_prev, &mouse_report,
+ sizeof(mouse_report));
+ sent = true;
}
- return false;
+ memset(&mouse_report, 0, sizeof(mouse_report));
+
+ return sent;
+}
+
+bool
+send_gamepad_report(void)
+{
+ bool sent;
+
+ sent = false;
+ if (memcmp(&gamepad_report, &gamepad_report_prev,
+ sizeof(gamepad_report))) {
+ tud_hid_gamepad_report(REPORT_ID_GAMEPAD,
+ gamepad_report.x, gamepad_report.y, gamepad_report.z,
+ gamepad_report.rz, gamepad_report.rx, gamepad_report.ry,
+ gamepad_report.hat, gamepad_report.btns);
+ memcpy(&gamepad_report_prev, &gamepad_report,
+ sizeof(gamepad_report));
+ sent = true;
+ }
+
+ memset(&gamepad_report, 0, sizeof(gamepad_report));
+
+ return sent;
}
bool
@@ -266,28 +372,38 @@ send_hid_report(int id)
switch (id) {
case REPORT_ID_KEYBOARD:
return send_keyboard_report();
+ case REPORT_ID_CONSUMER:
+ return send_consumer_report();
+ case REPORT_ID_SYSTEM:
+ return send_system_report();
case REPORT_ID_MOUSE:
- return send_mouse_report(false);
- case REPORT_ID_CONSUMER_CONTROL:
- return send_consumer_control_report(false);
+ return send_mouse_report();
+ case REPORT_ID_GAMEPAD:
+ return send_gamepad_report();
}
return false;
}
void
-tud_hid_report_complete_cb(uint8_t instance,
- uint8_t const *report, uint8_t len)
+send_next_hid_report(uint8_t min)
{
uint8_t id;
- for (id = report[0] + 1; id < REPORT_ID_MAX; id++) {
+ for (id = min; id < REPORT_ID_MAX; id++) {
if (send_hid_report(id))
break;
}
}
void
+tud_hid_report_complete_cb(uint8_t instance,
+ uint8_t const *report, uint8_t len)
+{
+ send_next_hid_report(report[0] + 1);
+}
+
+void
hid_init(void)
{
}
@@ -311,10 +427,6 @@ void
hid_task(void)
{
update_report();
- if (tud_hid_ready()) {
- send_hid_report(REPORT_ID_MIN);
- memset(&hid_report, 0, sizeof(hid_report));
- memset(seen_mat, 0, sizeof(seen_mat));
- active_mods = 0;
- }
+ if (tud_hid_ready())
+ send_next_hid_report(REPORT_ID_MIN);
}
diff --git a/src/hid.h b/src/hid.h
@@ -8,8 +8,10 @@
#define REPORT_ID_MIN REPORT_ID_KEYBOARD
enum {
REPORT_ID_KEYBOARD = 1,
+ REPORT_ID_CONSUMER,
+ REPORT_ID_SYSTEM,
REPORT_ID_MOUSE,
- REPORT_ID_CONSUMER_CONTROL,
+ REPORT_ID_GAMEPAD,
REPORT_ID_MAX
};
diff --git a/src/hid/consumer.h b/src/hid/consumer.h
@@ -0,0 +1,68 @@
+#pragma once
+
+#include <stdint.h>
+
+
+/* Consumer Page (0x0C)
+ *
+ * See https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf#page=75
+ */
+enum hid_consumer {
+ /* 15.5 Display Controls */
+ SNAPSHOT = 0x065,
+ /* https://www.usb.org/sites/default/files/hutrr41_0.pdf */
+ BRIGHTNESS_UP = 0x06F,
+ BRIGHTNESS_DOWN = 0x070,
+
+ /* 15.7 Transport Controls */
+ TRANSPORT_RECORD = 0x0B2,
+ TRANSPORT_FAST_FORWARD = 0x0B3,
+ TRANSPORT_REWIND = 0x0B4,
+ TRANSPORT_NEXT_TRACK = 0x0B5,
+ TRANSPORT_PREV_TRACK = 0x0B6,
+ TRANSPORT_STOP = 0x0B7,
+ TRANSPORT_EJECT = 0x0B8,
+ TRANSPORT_RANDOM_PLAY = 0x0B9,
+ TRANSPORT_STOP_EJECT = 0x0CC,
+ TRANSPORT_PLAY_PAUSE = 0x0CD,
+
+ /* 15.9.1 Audio Controls - Volume */
+ AUDIO_MUTE = 0x0E2,
+ AUDIO_VOL_UP = 0x0E9,
+ AUDIO_VOL_DOWN = 0x0EA,
+
+ /* 15.15 Application Launch Buttons */
+ AL_CC_CONFIG = 0x183,
+ AL_EMAIL = 0x18A,
+ AL_CALCULATOR = 0x192,
+ AL_LOCAL_BROWSER = 0x194,
+ AL_LOCK = 0x19E,
+ AL_CONTROL_PANEL = 0x19F,
+ AL_ASSISTANT = 0x1CB,
+ AL_KEYBOARD_LAYOUT = 0x1AE,
+
+ /* 15.16 Generic GUI Application Controls */
+ AC_NEW = 0x201,
+ AC_OPEN = 0x202,
+ AC_CLOSE = 0x203,
+ AC_EXIT = 0x204,
+ AC_MAXIMIZE = 0x205,
+ AC_MINIMIZE = 0x206,
+ AC_SAVE = 0x207,
+ AC_PRINT = 0x208,
+ AC_PROPERTIES = 0x209,
+ AC_UNDO = 0x21A,
+ AC_COPY = 0x21B,
+ AC_CUT = 0x21C,
+ AC_PASTE = 0x21D,
+ AC_SELECT_ALL = 0x21E,
+ AC_FIND = 0x21F,
+ AC_SEARCH = 0x221,
+ AC_HOME = 0x223,
+ AC_BACK = 0x224,
+ AC_FORWARD = 0x225,
+ AC_STOP = 0x226,
+ AC_REFRESH = 0x227,
+ AC_BOOKMARKS = 0x22A
+};
+
diff --git a/src/hid/keyboard.h b/src/hid/keyboard.h
@@ -0,0 +1,360 @@
+#pragma once
+
+/*
+ * Keycodes based on HID Keyboard/Keypad Usage Page (0x07) plus media keys
+ * from Generic Desktop Page (0x01) and Consumer Page (0x0C)
+ *
+ * See https://web.archive.org/web/20060218214400/http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
+ * or http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (older)
+ */
+
+#define IS_ANY_KC(code) (KC_A <= (code) && (code) <= 0xFF)
+#define IS_ERROR_KC(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
+#define IS_KEY_KC(code) (KC_A <= (code) && (code) <= KC_EXSEL)
+#define IS_MOD_KC(code) (KC_LEFT_CTRL <= (code) && (code) <= KC_RIGHT_GUI)
+
+#define MOD_INDEX(code) ((code) & 0b111)
+#define MOD_BIT(code) (1 << MOD_INDEX(code))
+
+/* Transparent */
+#define KC_TRANSPARENT 0x01
+#define KC_TRNS KC_TRANSPARENT
+
+/* Punctuation */
+#define KC_ENT KC_ENTER
+#define KC_ESC KC_ESCAPE
+#define KC_BSPC KC_BACKSPACE
+#define KC_SPC KC_SPACE
+#define KC_MINS KC_MINUS
+#define KC_EQL KC_EQUAL
+#define KC_LBRC KC_LEFT_BRACKET
+#define KC_RBRC KC_RIGHT_BRACKET
+#define KC_BSLS KC_BACKSLASH
+#define KC_NUHS KC_NONUS_HASH
+#define KC_SCLN KC_SEMICOLON
+#define KC_QUOT KC_QUOTE
+#define KC_GRV KC_GRAVE
+#define KC_COMM KC_COMMA
+#define KC_SLSH KC_SLASH
+#define KC_NUBS KC_NONUS_BACKSLASH
+
+/* Lock Keys */
+#define KC_CAPS KC_CAPS_LOCK
+#define KC_SCRL KC_SCROLL_LOCK
+#define KC_NUM KC_NUM_LOCK
+#define KC_LCAP KC_LOCKING_CAPS_LOCK
+#define KC_LNUM KC_LOCKING_NUM_LOCK
+#define KC_LSCR KC_LOCKING_SCROLL_LOCK
+
+/* Commands */
+#define KC_PSCR KC_PRINT_SCREEN
+#define KC_PAUS KC_PAUSE
+#define KC_BRK KC_PAUSE
+#define KC_INS KC_INSERT
+#define KC_PGUP KC_PAGE_UP
+#define KC_DEL KC_DELETE
+#define KC_PGDN KC_PAGE_DOWN
+#define KC_RGHT KC_RIGHT
+#define KC_APP KC_APPLICATION
+#define KC_EXEC KC_EXECUTE
+#define KC_SLCT KC_SELECT
+#define KC_AGIN KC_AGAIN
+#define KC_PSTE KC_PASTE
+#define KC_ERAS KC_ALTERNATE_ERASE
+#define KC_SYRQ KC_SYSTEM_REQUEST
+#define KC_CNCL KC_CANCEL
+#define KC_CLR KC_CLEAR
+#define KC_PRIR KC_PRIOR
+#define KC_RETN KC_RETURN
+#define KC_SEPR KC_SEPARATOR
+#define KC_CLAG KC_CLEAR_AGAIN
+#define KC_CRSL KC_CRSEL
+#define KC_EXSL KC_EXSEL
+
+/* Keypad */
+#define KC_PSLS KC_KP_SLASH
+#define KC_PAST KC_KP_ASTERISK
+#define KC_PMNS KC_KP_MINUS
+#define KC_PPLS KC_KP_PLUS
+#define KC_PENT KC_KP_ENTER
+#define KC_P1 KC_KP_1
+#define KC_P2 KC_KP_2
+#define KC_P3 KC_KP_3
+#define KC_P4 KC_KP_4
+#define KC_P5 KC_KP_5
+#define KC_P6 KC_KP_6
+#define KC_P7 KC_KP_7
+#define KC_P8 KC_KP_8
+#define KC_P9 KC_KP_9
+#define KC_P0 KC_KP_0
+#define KC_PDOT KC_KP_DOT
+#define KC_PEQL KC_KP_EQUAL
+#define KC_PCMM KC_KP_COMMA
+
+/* Language Specific */
+#define KC_INT1 KC_INTERNATIONAL_1
+#define KC_INT2 KC_INTERNATIONAL_2
+#define KC_INT3 KC_INTERNATIONAL_3
+#define KC_INT4 KC_INTERNATIONAL_4
+#define KC_INT5 KC_INTERNATIONAL_5
+#define KC_INT6 KC_INTERNATIONAL_6
+#define KC_INT7 KC_INTERNATIONAL_7
+#define KC_INT8 KC_INTERNATIONAL_8
+#define KC_INT9 KC_INTERNATIONAL_9
+#define KC_LNG1 KC_LANGUAGE_1
+#define KC_LNG2 KC_LANGUAGE_2
+#define KC_LNG3 KC_LANGUAGE_3
+#define KC_LNG4 KC_LANGUAGE_4
+#define KC_LNG5 KC_LANGUAGE_5
+#define KC_LNG6 KC_LANGUAGE_6
+#define KC_LNG7 KC_LANGUAGE_7
+#define KC_LNG8 KC_LANGUAGE_8
+#define KC_LNG9 KC_LANGUAGE_9
+
+/* Modifiers */
+#define KC_LCTL KC_LEFT_CTRL
+#define KC_LSFT KC_LEFT_SHIFT
+#define KC_LALT KC_LEFT_ALT
+#define KC_LOPT KC_LEFT_ALT
+#define KC_LGUI KC_LEFT_GUI
+#define KC_LCMD KC_LEFT_GUI
+#define KC_LWIN KC_LEFT_GUI
+#define KC_RCTL KC_RIGHT_CTRL
+#define KC_RSFT KC_RIGHT_SHIFT
+#define KC_RALT KC_RIGHT_ALT
+#define KC_ALGR KC_RIGHT_ALT
+#define KC_ROPT KC_RIGHT_ALT
+#define KC_RGUI KC_RIGHT_GUI
+#define KC_RCMD KC_RIGHT_GUI
+#define KC_RWIN KC_RIGHT_GUI
+
+/* Keyboard/Keypad Page (0x07) */
+enum hid_keyboard {
+ KC_NO = 0x00,
+ KC_ROLL_OVER,
+ KC_POST_FAIL,
+ KC_UNDEFINED,
+ KC_A,
+ KC_B,
+ KC_C,
+ KC_D,
+ KC_E,
+ KC_F,
+ KC_G,
+ KC_H,
+ KC_I,
+ KC_J,
+ KC_K,
+ KC_L,
+ KC_M, // 0x10
+ KC_N,
+ KC_O,
+ KC_P,
+ KC_Q,
+ KC_R,
+ KC_S,
+ KC_T,
+ KC_U,
+ KC_V,
+ KC_W,
+ KC_X,
+ KC_Y,
+ KC_Z,
+ KC_1,
+ KC_2,
+ KC_3, // 0x20
+ KC_4,
+ KC_5,
+ KC_6,
+ KC_7,
+ KC_8,
+ KC_9,
+ KC_0,
+ KC_ENTER,
+ KC_ESCAPE,
+ KC_BACKSPACE,
+ KC_TAB,
+ KC_SPACE,
+ KC_MINUS,
+ KC_EQUAL,
+ KC_LEFT_BRACKET,
+ KC_RIGHT_BRACKET, // 0x30
+ KC_BACKSLASH,
+ KC_NONUS_HASH,
+ KC_SEMICOLON,
+ KC_QUOTE,
+ KC_GRAVE,
+ KC_COMMA,
+ KC_DOT,
+ KC_SLASH,
+ KC_CAPS_LOCK,
+ KC_F1,
+ KC_F2,
+ KC_F3,
+ KC_F4,
+ KC_F5,
+ KC_F6,
+ KC_F7, // 0x40
+ KC_F8,
+ KC_F9,
+ KC_F10,
+ KC_F11,
+ KC_F12,
+ KC_PRINT_SCREEN,
+ KC_SCROLL_LOCK,
+ KC_PAUSE,
+ KC_INSERT,
+ KC_HOME,
+ KC_PAGE_UP,
+ KC_DELETE,
+ KC_END,
+ KC_PAGE_DOWN,
+ KC_RIGHT,
+ KC_LEFT, // 0x50
+ KC_DOWN,
+ KC_UP,
+ KC_NUM_LOCK,
+ KC_KP_SLASH,
+ KC_KP_ASTERISK,
+ KC_KP_MINUS,
+ KC_KP_PLUS,
+ KC_KP_ENTER,
+ KC_KP_1,
+ KC_KP_2,
+ KC_KP_3,
+ KC_KP_4,
+ KC_KP_5,
+ KC_KP_6,
+ KC_KP_7,
+ KC_KP_8, // 0x60
+ KC_KP_9,
+ KC_KP_0,
+ KC_KP_DOT,
+ KC_NONUS_BACKSLASH,
+ KC_APPLICATION,
+ KC_KB_POWER,
+ KC_KP_EQUAL,
+ KC_F13,
+ KC_F14,
+ KC_F15,
+ KC_F16,
+ KC_F17,
+ KC_F18,
+ KC_F19,
+ KC_F20,
+ KC_F21, // 0x70
+ KC_F22,
+ KC_F23,
+ KC_F24,
+ KC_EXECUTE,
+ KC_HELP,
+ KC_MENU,
+ KC_SELECT,
+ KC_STOP,
+ KC_AGAIN,
+ KC_UNDO,
+ KC_CUT,
+ KC_COPY,
+ KC_PASTE,
+ KC_FIND,
+ KC_KB_MUTE,
+ KC_KB_VOLUME_UP, // 0x80
+ KC_KB_VOLUME_DOWN,
+ KC_LOCKING_CAPS_LOCK,
+ KC_LOCKING_NUM_LOCK,
+ KC_LOCKING_SCROLL_LOCK,
+ KC_KP_COMMA,
+ KC_KP_EQUAL_AS400,
+ KC_INTERNATIONAL_1,
+ KC_INTERNATIONAL_2,
+ KC_INTERNATIONAL_3,
+ KC_INTERNATIONAL_4,
+ KC_INTERNATIONAL_5,
+ KC_INTERNATIONAL_6,
+ KC_INTERNATIONAL_7,
+ KC_INTERNATIONAL_8,
+ KC_INTERNATIONAL_9,
+ KC_LANGUAGE_1, // 0x90
+ KC_LANGUAGE_2,
+ KC_LANGUAGE_3,
+ KC_LANGUAGE_4,
+ KC_LANGUAGE_5,
+ KC_LANGUAGE_6,
+ KC_LANGUAGE_7,
+ KC_LANGUAGE_8,
+ KC_LANGUAGE_9,
+ KC_ALTERNATE_ERASE,
+ KC_SYSTEM_REQUEST,
+ KC_CANCEL,
+ KC_CLEAR,
+ KC_PRIOR,
+ KC_RETURN,
+ KC_SEPARATOR,
+ KC_OUT, // 0xA0
+ KC_OPER,
+ KC_CLEAR_AGAIN,
+ KC_CRSEL,
+ KC_EXSEL,
+
+#if 0
+ /* These keycodes are present in the HID spec, but are
+ * nonfunctional on modern OSes */
+
+ KC_KP_00 = 0xB0,
+ KC_KP_000,
+ KC_THOUSANDS_SEPARATOR,
+ KC_DECIMAL_SEPARATOR,
+ KC_CURRENCY_UNIT,
+ KC_CURRENCY_SUB_UNIT,
+ KC_KP_LEFT_PARENTHESIS,
+ KC_KP_RIGHT_PARENTHESIS,
+ KC_KP_LEFT_BRACE,
+ KC_KP_RIGHT_BRACE,
+ KC_KP_TAB,
+ KC_KP_BACKSPACE,
+ KC_KP_A,
+ KC_KP_B,
+ KC_KP_C,
+ KC_KP_D,
+ KC_KP_E, //0xC0
+ KC_KP_F,
+ KC_KP_XOR,
+ KC_KP_HAT,
+ KC_KP_PERCENT,
+ KC_KP_LESS_THAN,
+ KC_KP_GREATER_THAN,
+ KC_KP_AND,
+ KC_KP_LAZY_AND,
+ KC_KP_OR,
+ KC_KP_LAZY_OR,
+ KC_KP_COLON,
+ KC_KP_HASH,
+ KC_KP_SPACE,
+ KC_KP_AT,
+ KC_KP_EXCLAMATION,
+ KC_KP_MEM_STORE, //0xD0
+ KC_KP_MEM_RECALL,
+ KC_KP_MEM_CLEAR,
+ KC_KP_MEM_ADD,
+ KC_KP_MEM_SUB,
+ KC_KP_MEM_MUL,
+ KC_KP_MEM_DIV,
+ KC_KP_PLUS_MINUS,
+ KC_KP_CLEAR,
+ KC_KP_CLEAR_ENTRY,
+ KC_KP_BINARY,
+ KC_KP_OCTAL,
+ KC_KP_DECIMAL,
+ KC_KP_HEXADECIMAL,
+#endif
+
+ /* Modifiers */
+ KC_LEFT_CTRL = 0xE0,
+ KC_LEFT_SHIFT,
+ KC_LEFT_ALT,
+ KC_LEFT_GUI,
+ KC_RIGHT_CTRL,
+ KC_RIGHT_SHIFT,
+ KC_RIGHT_ALT,
+ KC_RIGHT_GUI
+};
diff --git a/src/hid/system.h b/src/hid/system.h
@@ -0,0 +1,17 @@
+#pragma once
+
+/* Generic Desktop Page (0x01)
+ *
+ * See https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf#page=26
+ */
+enum hid_system {
+ /* 4.5.1 System Controls - Power Controls */
+ SYSTEM_POWER_DOWN = 0x81,
+ SYSTEM_SLEEP = 0x82,
+ SYSTEM_WAKE_UP = 0x83,
+ SYSTEM_RESTART = 0x8F,
+
+ /* 4.10 System Display Controls */
+ SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5
+};
+
diff --git a/src/keycode.h b/src/keycode.h
@@ -1,515 +0,0 @@
-#pragma once
-
-/*
- * Keycodes based on HID Keyboard/Keypad Usage Page (0x07) plus media keys
- * from Generic Desktop Page (0x01) and Consumer Page (0x0C)
- *
- * See https://web.archive.org/web/20060218214400/http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
- * or http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (older)
- */
-
-#define IS_ANY_KC(code) (KC_A <= (code) && (code) <= 0xFF)
-#define IS_ERROR_KC(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
-#define IS_KEY_KC(code) (KC_A <= (code) && (code) <= KC_EXSEL)
-#define IS_MOD_KC(code) (KC_LEFT_CTRL <= (code) && (code) <= KC_RIGHT_GUI)
-
-#define IS_SPECIAL_KC(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
-#define IS_SYSTEM_KC(code) (KC_PWR <= (code) && (code) <= KC_WAKE)
-#define IS_CONSUMER_KC(code) (KC_MUTE <= (code) && (code) <= KC_BRID)
-
-#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
-#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
-#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN8)
-#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
-#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
-
-#define MOD_BIT(code) (1 << MOD_INDEX(code))
-#define MOD_INDEX(code) ((code) & 0b111)
-
-#define MOD_MASK_CTRL (MOD_BIT(KC_LEFT_CTRL) | MOD_BIT(KC_RIGHT_CTRL))
-#define MOD_MASK_SHIFT (MOD_BIT(KC_LEFT_SHIFT) | MOD_BIT(KC_RIGHT_SHIFT))
-#define MOD_MASK_ALT (MOD_BIT(KC_LEFT_ALT) | MOD_BIT(KC_RIGHT_ALT))
-#define MOD_MASK_GUI (MOD_BIT(KC_LEFT_GUI) | MOD_BIT(KC_RIGHT_GUI))
-#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT)
-#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT)
-#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI)
-#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT)
-#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI)
-#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI)
-#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT)
-#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI)
-#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI)
-#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
-#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
-
-/* Short names for ease of definition of keymap */
-
-/* Transparent */
-#define KC_TRANSPARENT 0x01
-#define KC_TRNS KC_TRANSPARENT
-
-/* Punctuation */
-#define KC_ENT KC_ENTER
-#define KC_ESC KC_ESCAPE
-#define KC_BSPC KC_BACKSPACE
-#define KC_SPC KC_SPACE
-#define KC_MINS KC_MINUS
-#define KC_EQL KC_EQUAL
-#define KC_LBRC KC_LEFT_BRACKET
-#define KC_RBRC KC_RIGHT_BRACKET
-#define KC_BSLS KC_BACKSLASH
-#define KC_NUHS KC_NONUS_HASH
-#define KC_SCLN KC_SEMICOLON
-#define KC_QUOT KC_QUOTE
-#define KC_GRV KC_GRAVE
-#define KC_COMM KC_COMMA
-#define KC_SLSH KC_SLASH
-#define KC_NUBS KC_NONUS_BACKSLASH
-
-/* Lock Keys */
-#define KC_CAPS KC_CAPS_LOCK
-#define KC_SCRL KC_SCROLL_LOCK
-#define KC_NUM KC_NUM_LOCK
-#define KC_LCAP KC_LOCKING_CAPS_LOCK
-#define KC_LNUM KC_LOCKING_NUM_LOCK
-#define KC_LSCR KC_LOCKING_SCROLL_LOCK
-
-/* Commands */
-#define KC_PSCR KC_PRINT_SCREEN
-#define KC_PAUS KC_PAUSE
-#define KC_BRK KC_PAUSE
-#define KC_INS KC_INSERT
-#define KC_PGUP KC_PAGE_UP
-#define KC_DEL KC_DELETE
-#define KC_PGDN KC_PAGE_DOWN
-#define KC_RGHT KC_RIGHT
-#define KC_APP KC_APPLICATION
-#define KC_EXEC KC_EXECUTE
-#define KC_SLCT KC_SELECT
-#define KC_AGIN KC_AGAIN
-#define KC_PSTE KC_PASTE
-#define KC_ERAS KC_ALTERNATE_ERASE
-#define KC_SYRQ KC_SYSTEM_REQUEST
-#define KC_CNCL KC_CANCEL
-#define KC_CLR KC_CLEAR
-#define KC_PRIR KC_PRIOR
-#define KC_RETN KC_RETURN
-#define KC_SEPR KC_SEPARATOR
-#define KC_CLAG KC_CLEAR_AGAIN
-#define KC_CRSL KC_CRSEL
-#define KC_EXSL KC_EXSEL
-
-/* Keypad */
-#define KC_PSLS KC_KP_SLASH
-#define KC_PAST KC_KP_ASTERISK
-#define KC_PMNS KC_KP_MINUS
-#define KC_PPLS KC_KP_PLUS
-#define KC_PENT KC_KP_ENTER
-#define KC_P1 KC_KP_1
-#define KC_P2 KC_KP_2
-#define KC_P3 KC_KP_3
-#define KC_P4 KC_KP_4
-#define KC_P5 KC_KP_5
-#define KC_P6 KC_KP_6
-#define KC_P7 KC_KP_7
-#define KC_P8 KC_KP_8
-#define KC_P9 KC_KP_9
-#define KC_P0 KC_KP_0
-#define KC_PDOT KC_KP_DOT
-#define KC_PEQL KC_KP_EQUAL
-#define KC_PCMM KC_KP_COMMA
-
-/* Language Specific */
-#define KC_INT1 KC_INTERNATIONAL_1
-#define KC_INT2 KC_INTERNATIONAL_2
-#define KC_INT3 KC_INTERNATIONAL_3
-#define KC_INT4 KC_INTERNATIONAL_4
-#define KC_INT5 KC_INTERNATIONAL_5
-#define KC_INT6 KC_INTERNATIONAL_6
-#define KC_INT7 KC_INTERNATIONAL_7
-#define KC_INT8 KC_INTERNATIONAL_8
-#define KC_INT9 KC_INTERNATIONAL_9
-#define KC_LNG1 KC_LANGUAGE_1
-#define KC_LNG2 KC_LANGUAGE_2
-#define KC_LNG3 KC_LANGUAGE_3
-#define KC_LNG4 KC_LANGUAGE_4
-#define KC_LNG5 KC_LANGUAGE_5
-#define KC_LNG6 KC_LANGUAGE_6
-#define KC_LNG7 KC_LANGUAGE_7
-#define KC_LNG8 KC_LANGUAGE_8
-#define KC_LNG9 KC_LANGUAGE_9
-
-/* Modifiers */
-#define KC_LCTL KC_LEFT_CTRL
-#define KC_LSFT KC_LEFT_SHIFT
-#define KC_LALT KC_LEFT_ALT
-#define KC_LOPT KC_LEFT_ALT
-#define KC_LGUI KC_LEFT_GUI
-#define KC_LCMD KC_LEFT_GUI
-#define KC_LWIN KC_LEFT_GUI
-#define KC_RCTL KC_RIGHT_CTRL
-#define KC_RSFT KC_RIGHT_SHIFT
-#define KC_RALT KC_RIGHT_ALT
-#define KC_ALGR KC_RIGHT_ALT
-#define KC_ROPT KC_RIGHT_ALT
-#define KC_RGUI KC_RIGHT_GUI
-#define KC_RCMD KC_RIGHT_GUI
-#define KC_RWIN KC_RIGHT_GUI
-
-/* Generic Desktop Page (0x01) */
-#define KC_PWR KC_SYSTEM_POWER
-#define KC_SLEP KC_SYSTEM_SLEEP
-#define KC_WAKE KC_SYSTEM_WAKE
-
-/* Consumer Page (0x0C) */
-#define KC_MUTE KC_AUDIO_MUTE
-#define KC_VOLU KC_AUDIO_VOL_UP
-#define KC_VOLD KC_AUDIO_VOL_DOWN
-#define KC_MNXT KC_MEDIA_NEXT_TRACK
-#define KC_MPRV KC_MEDIA_PREV_TRACK
-#define KC_MSTP KC_MEDIA_STOP
-#define KC_MPLY KC_MEDIA_PLAY_PAUSE
-#define KC_MSEL KC_MEDIA_SELECT
-#define KC_EJCT KC_MEDIA_EJECT
-#define KC_CALC KC_CALCULATOR
-#define KC_MYCM KC_MY_COMPUTER
-#define KC_WSCH KC_WWW_SEARCH
-#define KC_WHOM KC_WWW_HOME
-#define KC_WBAK KC_WWW_BACK
-#define KC_WFWD KC_WWW_FORWARD
-#define KC_WSTP KC_WWW_STOP
-#define KC_WREF KC_WWW_REFRESH
-#define KC_WFAV KC_WWW_FAVORITES
-#define KC_MFFD KC_MEDIA_FAST_FORWARD
-#define KC_MRWD KC_MEDIA_REWIND
-#define KC_BRIU KC_BRIGHTNESS_UP
-#define KC_BRID KC_BRIGHTNESS_DOWN
-
-/* System Specific */
-#define KC_BRMU KC_PAUSE
-#define KC_BRMD KC_SCROLL_LOCK
-
-/* Mouse Keys */
-#define KC_MS_U KC_MS_UP
-#define KC_MS_D KC_MS_DOWN
-#define KC_MS_L KC_MS_LEFT
-#define KC_MS_R KC_MS_RIGHT
-#define KC_BTN1 KC_MS_BTN1
-#define KC_BTN2 KC_MS_BTN2
-#define KC_BTN3 KC_MS_BTN3
-#define KC_BTN4 KC_MS_BTN4
-#define KC_BTN5 KC_MS_BTN5
-#define KC_BTN6 KC_MS_BTN6
-#define KC_BTN7 KC_MS_BTN7
-#define KC_BTN8 KC_MS_BTN8
-#define KC_WH_U KC_MS_WH_UP
-#define KC_WH_D KC_MS_WH_DOWN
-#define KC_WH_L KC_MS_WH_LEFT
-#define KC_WH_R KC_MS_WH_RIGHT
-#define KC_ACL0 KC_MS_ACCEL0
-#define KC_ACL1 KC_MS_ACCEL1
-#define KC_ACL2 KC_MS_ACCEL2
-
-/* Keyboard/Keypad Page (0x07) */
-enum hid_keyboard_keypad_usage {
- KC_NO = 0x00,
- KC_ROLL_OVER,
- KC_POST_FAIL,
- KC_UNDEFINED,
- KC_A,
- KC_B,
- KC_C,
- KC_D,
- KC_E,
- KC_F,
- KC_G,
- KC_H,
- KC_I,
- KC_J,
- KC_K,
- KC_L,
- KC_M, // 0x10
- KC_N,
- KC_O,
- KC_P,
- KC_Q,
- KC_R,
- KC_S,
- KC_T,
- KC_U,
- KC_V,
- KC_W,
- KC_X,
- KC_Y,
- KC_Z,
- KC_1,
- KC_2,
- KC_3, // 0x20
- KC_4,
- KC_5,
- KC_6,
- KC_7,
- KC_8,
- KC_9,
- KC_0,
- KC_ENTER,
- KC_ESCAPE,
- KC_BACKSPACE,
- KC_TAB,
- KC_SPACE,
- KC_MINUS,
- KC_EQUAL,
- KC_LEFT_BRACKET,
- KC_RIGHT_BRACKET, // 0x30
- KC_BACKSLASH,
- KC_NONUS_HASH,
- KC_SEMICOLON,
- KC_QUOTE,
- KC_GRAVE,
- KC_COMMA,
- KC_DOT,
- KC_SLASH,
- KC_CAPS_LOCK,
- KC_F1,
- KC_F2,
- KC_F3,
- KC_F4,
- KC_F5,
- KC_F6,
- KC_F7, // 0x40
- KC_F8,
- KC_F9,
- KC_F10,
- KC_F11,
- KC_F12,
- KC_PRINT_SCREEN,
- KC_SCROLL_LOCK,
- KC_PAUSE,
- KC_INSERT,
- KC_HOME,
- KC_PAGE_UP,
- KC_DELETE,
- KC_END,
- KC_PAGE_DOWN,
- KC_RIGHT,
- KC_LEFT, // 0x50
- KC_DOWN,
- KC_UP,
- KC_NUM_LOCK,
- KC_KP_SLASH,
- KC_KP_ASTERISK,
- KC_KP_MINUS,
- KC_KP_PLUS,
- KC_KP_ENTER,
- KC_KP_1,
- KC_KP_2,
- KC_KP_3,
- KC_KP_4,
- KC_KP_5,
- KC_KP_6,
- KC_KP_7,
- KC_KP_8, // 0x60
- KC_KP_9,
- KC_KP_0,
- KC_KP_DOT,
- KC_NONUS_BACKSLASH,
- KC_APPLICATION,
- KC_KB_POWER,
- KC_KP_EQUAL,
- KC_F13,
- KC_F14,
- KC_F15,
- KC_F16,
- KC_F17,
- KC_F18,
- KC_F19,
- KC_F20,
- KC_F21, // 0x70
- KC_F22,
- KC_F23,
- KC_F24,
- KC_EXECUTE,
- KC_HELP,
- KC_MENU,
- KC_SELECT,
- KC_STOP,
- KC_AGAIN,
- KC_UNDO,
- KC_CUT,
- KC_COPY,
- KC_PASTE,
- KC_FIND,
- KC_KB_MUTE,
- KC_KB_VOLUME_UP, // 0x80
- KC_KB_VOLUME_DOWN,
- KC_LOCKING_CAPS_LOCK,
- KC_LOCKING_NUM_LOCK,
- KC_LOCKING_SCROLL_LOCK,
- KC_KP_COMMA,
- KC_KP_EQUAL_AS400,
- KC_INTERNATIONAL_1,
- KC_INTERNATIONAL_2,
- KC_INTERNATIONAL_3,
- KC_INTERNATIONAL_4,
- KC_INTERNATIONAL_5,
- KC_INTERNATIONAL_6,
- KC_INTERNATIONAL_7,
- KC_INTERNATIONAL_8,
- KC_INTERNATIONAL_9,
- KC_LANGUAGE_1, // 0x90
- KC_LANGUAGE_2,
- KC_LANGUAGE_3,
- KC_LANGUAGE_4,
- KC_LANGUAGE_5,
- KC_LANGUAGE_6,
- KC_LANGUAGE_7,
- KC_LANGUAGE_8,
- KC_LANGUAGE_9,
- KC_ALTERNATE_ERASE,
- KC_SYSTEM_REQUEST,
- KC_CANCEL,
- KC_CLEAR,
- KC_PRIOR,
- KC_RETURN,
- KC_SEPARATOR,
- KC_OUT, // 0xA0
- KC_OPER,
- KC_CLEAR_AGAIN,
- KC_CRSEL,
- KC_EXSEL,
-
-#if 0
- /* These keycodes are present in the HID spec, but are
- * nonfunctional on modern OSes */
-
- KC_KP_00 = 0xB0,
- KC_KP_000,
- KC_THOUSANDS_SEPARATOR,
- KC_DECIMAL_SEPARATOR,
- KC_CURRENCY_UNIT,
- KC_CURRENCY_SUB_UNIT,
- KC_KP_LEFT_PARENTHESIS,
- KC_KP_RIGHT_PARENTHESIS,
- KC_KP_LEFT_BRACE,
- KC_KP_RIGHT_BRACE,
- KC_KP_TAB,
- KC_KP_BACKSPACE,
- KC_KP_A,
- KC_KP_B,
- KC_KP_C,
- KC_KP_D,
- KC_KP_E, //0xC0
- KC_KP_F,
- KC_KP_XOR,
- KC_KP_HAT,
- KC_KP_PERCENT,
- KC_KP_LESS_THAN,
- KC_KP_GREATER_THAN,
- KC_KP_AND,
- KC_KP_LAZY_AND,
- KC_KP_OR,
- KC_KP_LAZY_OR,
- KC_KP_COLON,
- KC_KP_HASH,
- KC_KP_SPACE,
- KC_KP_AT,
- KC_KP_EXCLAMATION,
- KC_KP_MEM_STORE, //0xD0
- KC_KP_MEM_RECALL,
- KC_KP_MEM_CLEAR,
- KC_KP_MEM_ADD,
- KC_KP_MEM_SUB,
- KC_KP_MEM_MUL,
- KC_KP_MEM_DIV,
- KC_KP_PLUS_MINUS,
- KC_KP_CLEAR,
- KC_KP_CLEAR_ENTRY,
- KC_KP_BINARY,
- KC_KP_OCTAL,
- KC_KP_DECIMAL,
- KC_KP_HEXADECIMAL,
-#endif
-
- /* Modifiers */
- KC_LEFT_CTRL = 0xE0,
- KC_LEFT_SHIFT,
- KC_LEFT_ALT,
- KC_LEFT_GUI,
- KC_RIGHT_CTRL,
- KC_RIGHT_SHIFT,
- KC_RIGHT_ALT,
- KC_RIGHT_GUI
-
- /* Range 0xF0-0xFF is unallocated in the HID spec */
-};
-
-/* Media and Function keys */
-enum internal_special_keycodes {
- /* Generic Desktop Page (0x01) */
- KC_SYSTEM_POWER = 0xA5,
- KC_SYSTEM_SLEEP,
- KC_SYSTEM_WAKE,
-
- /* Consumer Page (0x0C) */
- KC_AUDIO_MUTE,
- KC_AUDIO_VOL_UP,
- KC_AUDIO_VOL_DOWN,
- KC_MEDIA_NEXT_TRACK,
- KC_MEDIA_PREV_TRACK,
- KC_MEDIA_STOP,
- KC_MEDIA_PLAY_PAUSE,
- KC_MEDIA_SELECT,
- KC_MEDIA_EJECT, // 0xB0
- KC_MAIL,
- KC_CALCULATOR,
- KC_MY_COMPUTER,
- KC_WWW_SEARCH,
- KC_WWW_HOME,
- KC_WWW_BACK,
- KC_WWW_FORWARD,
- KC_WWW_STOP,
- KC_WWW_REFRESH,
- KC_WWW_FAVORITES,
- KC_MEDIA_FAST_FORWARD,
- KC_MEDIA_REWIND,
- KC_BRIGHTNESS_UP,
- KC_BRIGHTNESS_DOWN
-};
-
-/* Mouse Buttons */
-enum mouse_keys {
-#ifdef VIA_ENABLE
- KC_MS_UP = 0xF0,
-#else
- KC_MS_UP = 0xED,
-#endif
- KC_MS_DOWN,
- KC_MS_LEFT,
- KC_MS_RIGHT, // 0xF0
- KC_MS_BTN1,
- KC_MS_BTN2,
- KC_MS_BTN3,
- KC_MS_BTN4,
- KC_MS_BTN5,
-#ifdef VIA_ENABLE
- KC_MS_BTN6 = KC_MS_BTN5,
- KC_MS_BTN7 = KC_MS_BTN5,
- KC_MS_BTN8 = KC_MS_BTN5,
-#else
- KC_MS_BTN6,
- KC_MS_BTN7,
- KC_MS_BTN8,
-#endif
-
- /* Mouse Wheel */
- KC_MS_WH_UP,
- KC_MS_WH_DOWN,
- KC_MS_WH_LEFT,
- KC_MS_WH_RIGHT,
-
- /* Acceleration */
- KC_MS_ACCEL0,
- KC_MS_ACCEL1,
- KC_MS_ACCEL2 // 0xFF
-};
-
diff --git a/src/keymap.c b/src/keymap.c
@@ -1,7 +1,8 @@
#include "keymap.h"
-#include "keycode.h"
#include "keysym.h"
-#include "keysym_de.h"
+#include "keysym/consumer.h"
+#include "keysym/keyboard_de.h"
+#include "keysym/keyboard_us.h"
#include "hid.h"
#include "board.h"
#include "util.h"
@@ -81,8 +82,8 @@
_______ ,G(KC_TAB),G(DE_DOT), A(DE_B) , A(DE_F) ,A(KC_SPC), \
_______ , _______ , _______ , \
\
- _______ , G(KC_6) , G(KC_7) , G(KC_8) , G(KC_9) , G(KC_0) , \
- _______ , A(KC_6) , A(KC_7) , A(KC_8) , A(KC_9) , A(KC_0) , \
+ G(KC_6) , G(KC_7) , G(KC_8) , G(KC_9) , G(KC_0) , _______ , \
+ A(KC_6) , A(KC_7) , A(KC_8) , A(KC_9) , A(KC_0) , _______ , \
_______ , _______ , _______ , _______ , _______ , _______ , \
_______ , _______ , _______ \
)
@@ -117,8 +118,8 @@
KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , \
_______ , _______ , _______ , \
\
- _______ , KC_VOLD , KC_VOLU , KC_MUTE , _______ , _______ , \
- _______ , KC_MPRV , KC_MNXT , KC_MPLY , _______ , _______ , \
+ _______ , KS_VOLD , KS_VOLU , KS_MUTE , _______ , _______ , \
+ _______ , KS_MPRV , KS_MNXT , KS_MPLY , _______ , _______ , \
KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , \
_______ , _______ , _______ \
)
@@ -164,7 +165,6 @@ process_user_keypress_new(uint8_t sym, uint x, uint y)
case KVM2:
break;
case QUSW:
- INFO("Handling quick switch %i", keymat[7][3]);
if (keymat[7][3]) {
hid_force_release(3, 7);
hid_switch_layer_with_key(QUIX, x, y);
diff --git a/src/keysym.h b/src/keysym.h
@@ -1,21 +1,28 @@
#pragma once
-#include "keycode.h"
-
#define XXXXXXX KC_NO
#define _______ KC_TRNS
#define MASK(hi, lo) ((1U << (hi)) - (1U << (lo)))
#define IS_KC(x) (!((x) & ~MASK(B_TOGGLE, 0)))
-#define IS_CTRL(x) ((x) & (1 << B_CTRL))
-#define IS_SHIFT(x) ((x) & (1 << B_SHIFT))
-#define IS_ALT(x) ((x) & (1 << B_ALT))
-#define IS_GUI(x) ((x) & (1 << B_GUI))
-#define IS_RIGHT(x) ((x) & (1 << B_RIGHT))
-#define IS_TOGGLE(x) ((x) & (1 << B_TOGGLE))
-#define IS_SWITCH(x) ((x) & (1 << B_SWITCH))
-#define IS_USER(x) ((x) & (1 << B_USER))
+#define IS_CTRL(x) ((x) & (1U << B_CTRL))
+#define IS_SHIFT(x) ((x) & (1U << B_SHIFT))
+#define IS_ALT(x) ((x) & (1U << B_ALT))
+#define IS_GUI(x) ((x) & (1U << B_GUI))
+#define IS_RIGHT(x) ((x) & (1U << B_RIGHT))
+#define IS_TOGGLE(x) ((x) & (1U << B_TOGGLE))
+#define IS_SWITCH(x) ((x) & (1U << B_SWITCH))
+#define IS_SPECIAL(x) ((x) & (1U << B_SPECIAL))
+#define IS_USER(x) ((x) & (1U << B_USER))
+
+#define KEYSYM_MOUSE_MASK ((1U << B_SPECIAL) | (0b01 << B_SPECIAL_SEL))
+#define KEYSYM_SYSTEM_MASK ((1U << B_SPECIAL) | (0b10 << B_SPECIAL_SEL))
+#define KEYSYM_CONSUMER_MASK ((1U << B_SPECIAL) | (0b11 << B_SPECIAL_SEL))
+
+#define IS_MOUSE(x) ((x) & (KEYSYM_MOUSE_MASK))
+#define IS_SYSTEM(x) ((x) & (KEYSYM_SYSTEM_MASK))
+#define IS_CONSUMER(x) ((x) & (KEYSYM_CONSUMER_MASK))
#define IS_LEFT_CTRL(x) (IS_CTRL(x) && !IS_RIGHT(x))
#define IS_RIGHT_CTRL(x) (IS_CTRL(x) && IS_RIGHT(x))
@@ -26,7 +33,7 @@
#define IS_LEFT_GUI(x) (IS_GUI(x) && !IS_RIGHT(x))
#define IS_RIGHT_GUI(x) (IS_GUI(x) && IS_RIGHT(x))
-#define IS_MOD(x) ((x) & MASK(B_TOGGLE, 8))
+#define IS_MOD(x) ((x) & MASK(B_TOGGLE, B_CTRL))
#define TO_KC(x) ((x) & 0xFF)
#define TO_SYM(x) ((x) & 0xFF)
@@ -58,9 +65,11 @@
#define G(x) LGUI(x)
#define CS(x) C(SW(x))
+#define AS(x) A(SW(x))
#define GS(x) G(SW(x))
enum {
+ B_SPECIAL_SEL = 6,
B_CTRL = 8,
B_SHIFT,
B_ALT,
@@ -68,6 +77,7 @@ enum {
B_RIGHT,
B_TOGGLE,
B_SWITCH,
+ B_SPECIAL,
B_USER
};
diff --git a/src/keysym/consumer.c b/src/keysym/consumer.c
@@ -0,0 +1,60 @@
+#include "keysym/consumer.h"
+
+#include "hid/consumer.h"
+
+#include <stdint.h>
+
+uint16_t
+keysym_to_consumer(uint32_t key)
+{
+ switch (key) {
+ case KS_AUDIO_MUTE:
+ return AUDIO_MUTE;
+ case KS_AUDIO_VOL_UP:
+ return AUDIO_VOL_UP;
+ case KS_AUDIO_VOL_DOWN:
+ return AUDIO_VOL_DOWN;
+ case KS_MEDIA_NEXT_TRACK:
+ return TRANSPORT_NEXT_TRACK;
+ case KS_MEDIA_PREV_TRACK:
+ return TRANSPORT_PREV_TRACK;
+ case KS_MEDIA_FAST_FORWARD:
+ return TRANSPORT_FAST_FORWARD;
+ case KS_MEDIA_REWIND:
+ return TRANSPORT_REWIND;
+ case KS_MEDIA_STOP:
+ return TRANSPORT_STOP;
+ case KS_MEDIA_EJECT:
+ return TRANSPORT_STOP_EJECT;
+ case KS_MEDIA_PLAY_PAUSE:
+ return TRANSPORT_PLAY_PAUSE;
+ case KS_MEDIA_SELECT:
+ return AL_CC_CONFIG;
+ case KS_MAIL:
+ return AL_EMAIL;
+ case KS_CALCULATOR:
+ return AL_CALCULATOR;
+ case KS_MY_COMPUTER:
+ return AL_LOCAL_BROWSER;
+ case KS_WWW_SEARCH:
+ return AC_SEARCH;
+ case KS_WWW_HOME:
+ return AC_HOME;
+ case KS_WWW_BACK:
+ return AC_BACK;
+ case KS_WWW_FORWARD:
+ return AC_FORWARD;
+ case KS_WWW_STOP:
+ return AC_STOP;
+ case KS_WWW_REFRESH:
+ return AC_REFRESH;
+ case KS_BRIGHTNESS_UP:
+ return BRIGHTNESS_UP;
+ case KS_BRIGHTNESS_DOWN:
+ return BRIGHTNESS_DOWN;
+ case KS_WWW_FAVORITES:
+ return AC_BOOKMARKS;
+ default:
+ return 0;
+ }
+}
diff --git a/src/keysym/consumer.h b/src/keysym/consumer.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include "keysym.h"
+
+#include <stdint.h>
+
+/* Consumer Page (0x0C) */
+#define KS_MUTE KS_AUDIO_MUTE
+#define KS_VOLU KS_AUDIO_VOL_UP
+#define KS_VOLD KS_AUDIO_VOL_DOWN
+#define KS_MNXT KS_MEDIA_NEXT_TRACK
+#define KS_MPRV KS_MEDIA_PREV_TRACK
+#define KS_MSTP KS_MEDIA_STOP
+#define KS_MPLY KS_MEDIA_PLAY_PAUSE
+#define KS_MSEL KS_MEDIA_SELECT
+#define KS_EJCT KS_MEDIA_EJECT
+#define KS_CALC KS_CALCULATOR
+#define KS_MYCM KS_MY_COMPUTER
+#define KS_WSCH KS_WWW_SEARCH
+#define KS_WHOM KS_WWW_HOME
+#define KS_WBAK KS_WWW_BACK
+#define KS_WFWD KS_WWW_FORWARD
+#define KS_WSTP KS_WWW_STOP
+#define KS_WREF KS_WWW_REFRESH
+#define KS_WFAV KS_WWW_FAVORITES
+#define KS_MFFD KS_MEDIA_FAST_FORWARD
+#define KS_MRWD KS_MEDIA_REWIND
+#define KS_BRIU KS_BRIGHTNESS_UP
+#define KS_BRID KS_BRIGHTNESS_DOWN
+
+enum keysym_consumer {
+ KS_AUDIO_MUTE = KEYSYM_CONSUMER_MASK,
+ KS_AUDIO_VOL_UP,
+ KS_AUDIO_VOL_DOWN,
+ KS_MEDIA_NEXT_TRACK,
+ KS_MEDIA_PREV_TRACK,
+ KS_MEDIA_STOP,
+ KS_MEDIA_PLAY_PAUSE,
+ KS_MEDIA_SELECT,
+ KS_MEDIA_EJECT,
+ KS_MAIL,
+ KS_CALCULATOR,
+ KS_MY_COMPUTER,
+ KS_WWW_SEARCH,
+ KS_WWW_HOME,
+ KS_WWW_BACK,
+ KS_WWW_FORWARD,
+ KS_WWW_STOP,
+ KS_WWW_REFRESH,
+ KS_WWW_FAVORITES,
+ KS_MEDIA_FAST_FORWARD,
+ KS_MEDIA_REWIND,
+ KS_BRIGHTNESS_UP,
+ KS_BRIGHTNESS_DOWN
+};
+
+uint16_t keysym_to_consumer(uint32_t keysym);
diff --git a/src/keysym/keyboard_de.h b/src/keysym/keyboard_de.h
@@ -0,0 +1,152 @@
+#pragma once
+
+#include "keysym.h"
+#include "hid/keyboard.h"
+
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ^ │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ ß │ ´ │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ Q │ W │ E │ R │ T │ Z │ U │ I │ O │ P │ Ü │ + │ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
+ * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ Ö │ Ä │ # │ │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │ │ < │ Y │ X │ C │ V │ B │ N │ M │ , │ . │ - │ │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define DE_CIRC KC_GRV // ^ (dead)
+#define DE_1 KC_1 // 1
+#define DE_2 KC_2 // 2
+#define DE_3 KC_3 // 3
+#define DE_4 KC_4 // 4
+#define DE_5 KC_5 // 5
+#define DE_6 KC_6 // 6
+#define DE_7 KC_7 // 7
+#define DE_8 KC_8 // 8
+#define DE_9 KC_9 // 9
+#define DE_0 KC_0 // 0
+#define DE_SS KC_MINS // ß
+#define DE_ACUT KC_EQL // ´ (dead)
+
+/* Row 2 */
+#define DE_Q KC_Q // Q
+#define DE_W KC_W // W
+#define DE_E KC_E // E
+#define DE_R KC_R // R
+#define DE_T KC_T // T
+#define DE_Z KC_Y // Z
+#define DE_U KC_U // U
+#define DE_I KC_I // I
+#define DE_O KC_O // O
+#define DE_P KC_P // P
+#define DE_UDIA KC_LBRC // Ü
+#define DE_PLUS KC_RBRC // +
+
+/* Row 3 */
+#define DE_A KC_A // A
+#define DE_S KC_S // S
+#define DE_D KC_D // D
+#define DE_F KC_F // F
+#define DE_G KC_G // G
+#define DE_H KC_H // H
+#define DE_J KC_J // J
+#define DE_K KC_K // K
+#define DE_L KC_L // L
+#define DE_ODIA KC_SCLN // Ö
+#define DE_ADIA KC_QUOT // Ä
+#define DE_HASH KC_NUHS // #
+
+/* Row 4 */
+#define DE_LABK KC_NUBS // <
+#define DE_Y KC_Z // Y
+#define DE_X KC_X // X
+#define DE_C KC_C // C
+#define DE_V KC_V // V
+#define DE_B KC_B // B
+#define DE_N KC_N // N
+#define DE_M KC_M // M
+#define DE_COMM KC_COMM // ,
+#define DE_DOT KC_DOT // .
+#define DE_MINS KC_SLSH // -
+
+
+/* Shifted symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ° │ ! │ " │ § │ $ │ % │ & │ / │ ( │ ) │ = │ ? │ ` │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ │ * │ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
+ * │ │ │ │ │ │ │ │ │ │ │ │ │ ' │ │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │ │ > │ │ │ │ │ │ │ │ ; │ : │ _ │ │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define DE_DEG S(DE_CIRC) // °
+#define DE_EXLM S(DE_1) // !
+#define DE_DQUO S(DE_2) // "
+#define DE_SECT S(DE_3) // §
+#define DE_DLR S(DE_4) // $
+#define DE_PERC S(DE_5) // %
+#define DE_AMPR S(DE_6) // &
+#define DE_SLSH S(DE_7) // /
+#define DE_LPRN S(DE_8) // (
+#define DE_RPRN S(DE_9) // )
+#define DE_EQL S(DE_0) // =
+#define DE_QUES S(DE_SS) // ?
+#define DE_GRV S(DE_ACUT) // ` (dead)
+
+/* Row 2 */
+#define DE_ASTR S(DE_PLUS) // *
+
+/* Row 3 */
+#define DE_QUOT S(DE_HASH) // '
+
+/* Row 4 */
+#define DE_RABK S(DE_LABK) // >
+#define DE_SCLN S(DE_COMM) // ;
+#define DE_COLN S(DE_DOT) // :
+#define DE_UNDS S(DE_MINS) // _
+
+/* alternate names */
+#define DE_LESS DE_LABK
+#define DE_GRTR S(DE_LABK)
+
+/* AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ │ │ ² │ ³ │ │ │ │ { │ [ │ ] │ } │ \ │ │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ @ │ │ € │ │ │ │ │ │ │ │ │ ~ │ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
+ * │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │ │ | │ │ │ │ │ │ │ µ │ │ │ │ │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define DE_SUP2 ALGR(DE_2) // ²
+#define DE_SUP3 ALGR(DE_3) // ³
+#define DE_LCBR ALGR(DE_7) // {
+#define DE_LBRC ALGR(DE_8) // [
+#define DE_RBRC ALGR(DE_9) // ]
+#define DE_RCBR ALGR(DE_0) // }
+#define DE_BSLS ALGR(DE_SS) // (backslash)
+
+/* Row 2 */
+#define DE_AT ALGR(DE_Q) // @
+#define DE_EURO ALGR(DE_E) // €
+#define DE_TILD ALGR(DE_PLUS) // ~
+
+/* Row 4 */
+#define DE_PIPE ALGR(DE_LABK) // |
+#define DE_MICR ALGR(DE_M) // µ
diff --git a/src/keysym/keyboard_us.h b/src/keysym/keyboard_us.h
@@ -0,0 +1,228 @@
+#pragma once
+
+#include "keysym.h"
+#include "hid/keyboard.h"
+
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ \ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define US_GRV KC_GRV // `
+#define US_1 KC_1 // 1
+#define US_2 KC_2 // 2
+#define US_3 KC_3 // 3
+#define US_4 KC_4 // 4
+#define US_5 KC_5 // 5
+#define US_6 KC_6 // 6
+#define US_7 KC_7 // 7
+#define US_8 KC_8 // 8
+#define US_9 KC_9 // 9
+#define US_0 KC_0 // 0
+#define US_MINS KC_MINS // -
+#define US_EQL KC_EQL // =
+
+/* Row 2 */
+#define US_Q KC_Q // Q
+#define US_W KC_W // W
+#define US_E KC_E // E
+#define US_R KC_R // R
+#define US_T KC_T // T
+#define US_Y KC_Y // Y
+#define US_U KC_U // U
+#define US_I KC_I // I
+#define US_O KC_O // O
+#define US_P KC_P // P
+#define US_LBRC KC_LBRC // [
+#define US_RBRC KC_RBRC // ]
+#define US_BSLS KC_BSLS // (backslash)
+
+/* Row 3 */
+#define US_A KC_A // A
+#define US_S KC_S // S
+#define US_D KC_D // D
+#define US_F KC_F // F
+#define US_G KC_G // G
+#define US_H KC_H // H
+#define US_J KC_J // J
+#define US_K KC_K // K
+#define US_L KC_L // L
+#define US_SCLN KC_SCLN // ;
+#define US_QUOT KC_QUOT // '
+
+/* Row 4 */
+#define US_Z KC_Z // Z
+#define US_X KC_X // X
+#define US_C KC_C // C
+#define US_V KC_V // V
+#define US_B KC_B // B
+#define US_N KC_N // N
+#define US_M KC_M // M
+#define US_COMM KC_COMM // ,
+#define US_DOT KC_DOT // .
+#define US_SLSH KC_SLSH // /
+
+
+/* Shifted symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define US_TILD S(US_GRV) // ~
+#define US_EXLM S(US_1) // !
+#define US_AT S(US_2) // @
+#define US_HASH S(US_3) // #
+#define US_DLR S(US_4) // $
+#define US_PERC S(US_5) // %
+#define US_CIRC S(US_6) // ^
+#define US_AMPR S(US_7) // &
+#define US_ASTR S(US_8) // *
+#define US_LPRN S(US_9) // (
+#define US_RPRN S(US_0) // )
+#define US_UNDS S(US_MINS) // _
+#define US_PLUS S(US_EQL) // +
+
+/* Row 2 */
+#define US_LCBR S(US_LBRC) // {
+#define US_RCBR S(US_RBRC) // }
+#define US_PIPE S(US_BSLS) // |
+
+/* Row 3 */
+#define US_COLN S(US_SCLN) // :
+#define US_DQUO S(US_QUOT) // "
+
+/* Row 4 */
+#define US_LABK S(US_COMM) // <
+#define US_RABK S(US_DOT) // >
+#define US_QUES S(US_SLSH) // ?
+
+
+/* AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ` │ ¹ │ ² │ ³ │ ¤ │ € │ ^ │ ̛ │ ¾ │ ‘ │ ’ │ ¥ │ × │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ Ä │ Å │ É │ ® │ Þ │ Ü │ Ú │ Í │ Ó │ Ö │ « │ » │ ¬ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ Á │ ß │ Ð │ │ │ │ Ï │ Œ │ Ø │ ¶ │ ' │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ Æ │ │ © │ │ │ Ñ │ µ │ Ç │ ˙ │ ¿ │ │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define US_DGRV ALGR(US_GRV) // ` (dead)
+#define US_SUP1 ALGR(US_1) // ¹
+#define US_SUP2 ALGR(US_2) // ²
+#define US_SUP3 ALGR(US_3) // ³
+#define US_CURR ALGR(US_4) // ¤
+#define US_EURO ALGR(US_5) // €
+#define US_DCIR ALGR(US_6) // ^ (dead)
+#define US_HORN ALGR(US_7) // ̛ (dead)
+#define US_OGON ALGR(US_8) // ˛ (dead)
+#define US_LSQU ALGR(US_9) // ‘
+#define US_RSQU ALGR(US_0) // ’
+#define US_YEN ALGR(US_MINS) // ¥
+#define US_MUL ALGR(US_EQL) // ×
+
+/* Row 2 */
+#define US_ADIA ALGR(US_Q) // Ä
+#define US_ARNG ALGR(US_W) // Å
+#define US_EACU ALGR(US_E) // É
+#define US_EDIA ALGR(US_R) // Ë
+#define US_THRN ALGR(US_T) // Þ
+#define US_UDIA ALGR(US_Y) // Ü
+#define US_UACU ALGR(US_U) // Ú
+#define US_IACU ALGR(US_I) // Í
+#define US_OACU ALGR(US_O) // Ó
+#define US_ODIA ALGR(US_P) // Ö
+#define US_LDAQ ALGR(US_LBRC) // «
+#define US_RDAQ ALGR(US_RBRC) // »
+#define US_NOT ALGR(US_BSLS) // ¬
+
+/* Row 3 */
+#define US_AACU ALGR(US_A) // Á
+#define US_SS ALGR(US_S) // ß
+#define US_ETH ALGR(US_D) // Ð
+#define US_IDIA ALGR(US_J) // Ï
+#define US_OE ALGR(US_K) // Œ
+#define US_OSTR ALGR(US_L) // Ø
+#define US_PILC ALGR(US_SCLN) // ¶
+#define US_ACUT ALGR(US_QUOT) // ´ (dead)
+
+/* Row 4 */
+#define US_AE ALGR(US_Z) // Æ
+#define US_OE_2 ALGR(US_X) // Œ
+#define US_COPY ALGR(US_C) // ©
+#define US_REGD ALGR(US_V) // ®
+#define US_NTIL ALGR(US_N) // Ñ
+#define US_MICR ALGR(US_M) // µ
+#define US_CCED ALGR(US_COMM) // Ç
+#define US_DOTA ALGR(US_DOT) // ˙ (dead)
+#define US_IQUE ALGR(US_SLSH) // ¿
+
+
+/* Shift+AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ~ │ ¡ │ ˝ │ ¯ │ £ │ ¸ │ ¼ │ ½ │ ¾ │ ˘ │ ° │ ̣ │ ÷ │ │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │ │ │ │ │ │ │ │ │ │ │ │ “ │ ” │ ¦ │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │ │ │ § │ │ │ │ │ │ │ │ ° │ " │ │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │ │ │ │ ¢ │ │ │ │ │ │ ˇ │ ̉ │ │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │ │ │ │ │ │ │ │ │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+/* Row 1 */
+#define US_DTIL S(ALGR(US_GRV)) // ~ (dead)
+#define US_IEXL S(ALGR(US_1)) // ¡
+#define US_DACU S(ALGR(US_2)) // ˝ (dead)
+#define US_MACR S(ALGR(US_3)) // ¯ (dead)
+#define US_PND S(ALGR(US_4)) // £
+#define US_CEDL S(ALGR(US_5)) // ¸ (dead)
+#define US_QRTR S(ALGR(US_6)) // ¼
+#define US_HALF S(ALGR(US_7)) // ½
+#define US_TQTR S(ALGR(US_8)) // ¾
+#define US_BREV S(ALGR(US_9)) // ˘ (dead)
+#define US_RNGA S(ALGR(US_0)) // ° (dead)
+#define US_DOTB S(ALGR(US_MINS)) // ̣ (dead)
+#define US_DIV S(ALGR(US_EQL)) // ÷
+
+/* Row 2 */
+#define US_LDQU S(ALGR(US_LBRC)) // “
+#define US_RDQU S(ALGR(US_RBRC)) // ”
+#define US_BRKP S(ALGR(US_BSLS)) // ¦
+
+/* Row 3 */
+#define US_SECT S(ALGR(US_S)) // §
+#define US_DEG S(ALGR(US_SCLN)) // °
+#define US_DIAE S(ALGR(US_QUOT)) // ¨ (dead)
+
+/* Row 4 */
+#define US_CENT S(ALGR(US_C)) // ¢
+#define US_CARN S(ALGR(US_DOT)) // ˇ (dead)
+#define US_HOKA S(ALGR(US_SLSH)) // ̉ (dead)
diff --git a/src/keysym/mouse.h b/src/keysym/mouse.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "keysym.h"
+
+#define KS_MS_U KS_MS_UP
+#define KS_MS_D KS_MS_DOWN
+#define KS_MS_L KS_MS_LEFT
+#define KS_MS_R KS_MS_RIGHT
+#define KS_BTN1 KS_MS_BTN1
+#define KS_BTN2 KS_MS_BTN2
+#define KS_BTN3 KS_MS_BTN3
+#define KS_BTN4 KS_MS_BTN4
+#define KS_BTN5 KS_MS_BTN5
+#define KS_BTN6 KS_MS_BTN6
+#define KS_BTN7 KS_MS_BTN7
+#define KS_BTN8 KS_MS_BTN8
+#define KS_WH_U KS_MS_WH_UP
+#define KS_WH_D KS_MS_WH_DOWN
+#define KS_WH_L KS_MS_WH_LEFT
+#define KS_WH_R KS_MS_WH_RIGHT
+#define KS_ACL0 KS_MS_ACCEL0
+#define KS_ACL1 KS_MS_ACCEL1
+#define KS_ACL2 KS_MS_ACCEL2
+
+enum keysym_mouse {
+ /* Mouse Buttons */
+ KC_MS_UP = KEYSYM_MOUSE_MASK,
+ KC_MS_DOWN,
+ KC_MS_LEFT,
+ KC_MS_RIGHT,
+ KC_MS_BTN1,
+ KC_MS_BTN2,
+ KC_MS_BTN3,
+ KC_MS_BTN4,
+ KC_MS_BTN5,
+ KC_MS_BTN6,
+ KC_MS_BTN7,
+ KC_MS_BTN8,
+
+ /* Mouse Wheel */
+ KC_MS_WH_UP,
+ KC_MS_WH_DOWN,
+ KC_MS_WH_LEFT,
+ KC_MS_WH_RIGHT,
+
+ /* Acceleration */
+ KC_MS_ACCEL0,
+ KC_MS_ACCEL1,
+ KC_MS_ACCEL2
+};
diff --git a/src/keysym/system.c b/src/keysym/system.c
@@ -0,0 +1,20 @@
+#include "keysym/system.h"
+
+#include "hid/system.h"
+
+#include <stdint.h>
+
+uint16_t
+keysym_to_system(uint32_t keysym)
+{
+ switch (keysym) {
+ case KS_SYSTEM_POWER:
+ return SYSTEM_POWER_DOWN;
+ case KS_SYSTEM_SLEEP:
+ return SYSTEM_SLEEP;
+ case KS_SYSTEM_WAKE:
+ return SYSTEM_WAKE_UP;
+ default:
+ return 0;
+ }
+}
diff --git a/src/keysym/system.h b/src/keysym/system.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "keysym.h"
+
+#include <stdint.h>
+
+/* Generic Desktop Page (0x01) */
+#define KS_PWR KS_SYSTEM_POWER
+#define KS_SLEP KS_SYSTEM_SLEEP
+#define KS_WAKE KS_SYSTEM_WAKE
+
+enum keysym_system {
+ KS_SYSTEM_POWER = KEYSYM_SYSTEM_MASK,
+ KS_SYSTEM_SLEEP,
+ KS_SYSTEM_WAKE,
+};
+
+uint16_t keysym_to_system(uint32_t keysym);
diff --git a/src/keysym_de.h b/src/keysym_de.h
@@ -1,152 +0,0 @@
-#pragma once
-
-#include "keysym.h"
-#include "keycode.h"
-
-/*
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ^ │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ ß │ ´ │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ Q │ W │ E │ R │ T │ Z │ U │ I │ O │ P │ Ü │ + │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ Ö │ Ä │ # │ │
- * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ < │ Y │ X │ C │ V │ B │ N │ M │ , │ . │ - │ │
- * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define DE_CIRC KC_GRV // ^ (dead)
-#define DE_1 KC_1 // 1
-#define DE_2 KC_2 // 2
-#define DE_3 KC_3 // 3
-#define DE_4 KC_4 // 4
-#define DE_5 KC_5 // 5
-#define DE_6 KC_6 // 6
-#define DE_7 KC_7 // 7
-#define DE_8 KC_8 // 8
-#define DE_9 KC_9 // 9
-#define DE_0 KC_0 // 0
-#define DE_SS KC_MINS // ß
-#define DE_ACUT KC_EQL // ´ (dead)
-
-/* Row 2 */
-#define DE_Q KC_Q // Q
-#define DE_W KC_W // W
-#define DE_E KC_E // E
-#define DE_R KC_R // R
-#define DE_T KC_T // T
-#define DE_Z KC_Y // Z
-#define DE_U KC_U // U
-#define DE_I KC_I // I
-#define DE_O KC_O // O
-#define DE_P KC_P // P
-#define DE_UDIA KC_LBRC // Ü
-#define DE_PLUS KC_RBRC // +
-
-/* Row 3 */
-#define DE_A KC_A // A
-#define DE_S KC_S // S
-#define DE_D KC_D // D
-#define DE_F KC_F // F
-#define DE_G KC_G // G
-#define DE_H KC_H // H
-#define DE_J KC_J // J
-#define DE_K KC_K // K
-#define DE_L KC_L // L
-#define DE_ODIA KC_SCLN // Ö
-#define DE_ADIA KC_QUOT // Ä
-#define DE_HASH KC_NUHS // #
-
-/* Row 4 */
-#define DE_LABK KC_NUBS // <
-#define DE_Y KC_Z // Y
-#define DE_X KC_X // X
-#define DE_C KC_C // C
-#define DE_V KC_V // V
-#define DE_B KC_B // B
-#define DE_N KC_N // N
-#define DE_M KC_M // M
-#define DE_COMM KC_COMM // ,
-#define DE_DOT KC_DOT // .
-#define DE_MINS KC_SLSH // -
-
-
-/* Shifted symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ° │ ! │ " │ § │ $ │ % │ & │ / │ ( │ ) │ = │ ? │ ` │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ │ * │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ │ │ │ │ │ │ │ │ │ │ │ ' │ │
- * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ > │ │ │ │ │ │ │ │ ; │ : │ _ │ │
- * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define DE_DEG S(DE_CIRC) // °
-#define DE_EXLM S(DE_1) // !
-#define DE_DQUO S(DE_2) // "
-#define DE_SECT S(DE_3) // §
-#define DE_DLR S(DE_4) // $
-#define DE_PERC S(DE_5) // %
-#define DE_AMPR S(DE_6) // &
-#define DE_SLSH S(DE_7) // /
-#define DE_LPRN S(DE_8) // (
-#define DE_RPRN S(DE_9) // )
-#define DE_EQL S(DE_0) // =
-#define DE_QUES S(DE_SS) // ?
-#define DE_GRV S(DE_ACUT) // ` (dead)
-
-/* Row 2 */
-#define DE_ASTR S(DE_PLUS) // *
-
-/* Row 3 */
-#define DE_QUOT S(DE_HASH) // '
-
-/* Row 4 */
-#define DE_RABK S(DE_LABK) // >
-#define DE_SCLN S(DE_COMM) // ;
-#define DE_COLN S(DE_DOT) // :
-#define DE_UNDS S(DE_MINS) // _
-
-/* alternate names */
-#define DE_LESS DE_LABK
-#define DE_GRTR S(DE_LABK)
-
-/* AltGr symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ │ │ ² │ ³ │ │ │ │ { │ [ │ ] │ } │ \ │ │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ @ │ │ € │ │ │ │ │ │ │ │ │ ~ │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
- * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ | │ │ │ │ │ │ │ µ │ │ │ │ │
- * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define DE_SUP2 ALGR(DE_2) // ²
-#define DE_SUP3 ALGR(DE_3) // ³
-#define DE_LCBR ALGR(DE_7) // {
-#define DE_LBRC ALGR(DE_8) // [
-#define DE_RBRC ALGR(DE_9) // ]
-#define DE_RCBR ALGR(DE_0) // }
-#define DE_BSLS ALGR(DE_SS) // (backslash)
-
-/* Row 2 */
-#define DE_AT ALGR(DE_Q) // @
-#define DE_EURO ALGR(DE_E) // €
-#define DE_TILD ALGR(DE_PLUS) // ~
-
-/* Row 4 */
-#define DE_PIPE ALGR(DE_LABK) // |
-#define DE_MICR ALGR(DE_M) // µ
diff --git a/src/keysym_us.h b/src/keysym_us.h
@@ -1,228 +0,0 @@
-#pragma once
-
-#include "keysym.h"
-#include "keycode.h"
-
-/*
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ \ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
- * │ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ │
- * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define US_GRV KC_GRV // `
-#define US_1 KC_1 // 1
-#define US_2 KC_2 // 2
-#define US_3 KC_3 // 3
-#define US_4 KC_4 // 4
-#define US_5 KC_5 // 5
-#define US_6 KC_6 // 6
-#define US_7 KC_7 // 7
-#define US_8 KC_8 // 8
-#define US_9 KC_9 // 9
-#define US_0 KC_0 // 0
-#define US_MINS KC_MINS // -
-#define US_EQL KC_EQL // =
-
-/* Row 2 */
-#define US_Q KC_Q // Q
-#define US_W KC_W // W
-#define US_E KC_E // E
-#define US_R KC_R // R
-#define US_T KC_T // T
-#define US_Y KC_Y // Y
-#define US_U KC_U // U
-#define US_I KC_I // I
-#define US_O KC_O // O
-#define US_P KC_P // P
-#define US_LBRC KC_LBRC // [
-#define US_RBRC KC_RBRC // ]
-#define US_BSLS KC_BSLS // (backslash)
-
-/* Row 3 */
-#define US_A KC_A // A
-#define US_S KC_S // S
-#define US_D KC_D // D
-#define US_F KC_F // F
-#define US_G KC_G // G
-#define US_H KC_H // H
-#define US_J KC_J // J
-#define US_K KC_K // K
-#define US_L KC_L // L
-#define US_SCLN KC_SCLN // ;
-#define US_QUOT KC_QUOT // '
-
-/* Row 4 */
-#define US_Z KC_Z // Z
-#define US_X KC_X // X
-#define US_C KC_C // C
-#define US_V KC_V // V
-#define US_B KC_B // B
-#define US_N KC_N // N
-#define US_M KC_M // M
-#define US_COMM KC_COMM // ,
-#define US_DOT KC_DOT // .
-#define US_SLSH KC_SLSH // /
-
-
-/* Shifted symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
- * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │
- * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define US_TILD S(US_GRV) // ~
-#define US_EXLM S(US_1) // !
-#define US_AT S(US_2) // @
-#define US_HASH S(US_3) // #
-#define US_DLR S(US_4) // $
-#define US_PERC S(US_5) // %
-#define US_CIRC S(US_6) // ^
-#define US_AMPR S(US_7) // &
-#define US_ASTR S(US_8) // *
-#define US_LPRN S(US_9) // (
-#define US_RPRN S(US_0) // )
-#define US_UNDS S(US_MINS) // _
-#define US_PLUS S(US_EQL) // +
-
-/* Row 2 */
-#define US_LCBR S(US_LBRC) // {
-#define US_RCBR S(US_RBRC) // }
-#define US_PIPE S(US_BSLS) // |
-
-/* Row 3 */
-#define US_COLN S(US_SCLN) // :
-#define US_DQUO S(US_QUOT) // "
-
-/* Row 4 */
-#define US_LABK S(US_COMM) // <
-#define US_RABK S(US_DOT) // >
-#define US_QUES S(US_SLSH) // ?
-
-
-/* AltGr symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ` │ ¹ │ ² │ ³ │ ¤ │ € │ ^ │ ̛ │ ¾ │ ‘ │ ’ │ ¥ │ × │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ Ä │ Å │ É │ ® │ Þ │ Ü │ Ú │ Í │ Ó │ Ö │ « │ » │ ¬ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │ │ Á │ ß │ Ð │ │ │ │ Ï │ Œ │ Ø │ ¶ │ ' │ │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
- * │ │ Æ │ │ © │ │ │ Ñ │ µ │ Ç │ ˙ │ ¿ │ │
- * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define US_DGRV ALGR(US_GRV) // ` (dead)
-#define US_SUP1 ALGR(US_1) // ¹
-#define US_SUP2 ALGR(US_2) // ²
-#define US_SUP3 ALGR(US_3) // ³
-#define US_CURR ALGR(US_4) // ¤
-#define US_EURO ALGR(US_5) // €
-#define US_DCIR ALGR(US_6) // ^ (dead)
-#define US_HORN ALGR(US_7) // ̛ (dead)
-#define US_OGON ALGR(US_8) // ˛ (dead)
-#define US_LSQU ALGR(US_9) // ‘
-#define US_RSQU ALGR(US_0) // ’
-#define US_YEN ALGR(US_MINS) // ¥
-#define US_MUL ALGR(US_EQL) // ×
-
-/* Row 2 */
-#define US_ADIA ALGR(US_Q) // Ä
-#define US_ARNG ALGR(US_W) // Å
-#define US_EACU ALGR(US_E) // É
-#define US_EDIA ALGR(US_R) // Ë
-#define US_THRN ALGR(US_T) // Þ
-#define US_UDIA ALGR(US_Y) // Ü
-#define US_UACU ALGR(US_U) // Ú
-#define US_IACU ALGR(US_I) // Í
-#define US_OACU ALGR(US_O) // Ó
-#define US_ODIA ALGR(US_P) // Ö
-#define US_LDAQ ALGR(US_LBRC) // «
-#define US_RDAQ ALGR(US_RBRC) // »
-#define US_NOT ALGR(US_BSLS) // ¬
-
-/* Row 3 */
-#define US_AACU ALGR(US_A) // Á
-#define US_SS ALGR(US_S) // ß
-#define US_ETH ALGR(US_D) // Ð
-#define US_IDIA ALGR(US_J) // Ï
-#define US_OE ALGR(US_K) // Œ
-#define US_OSTR ALGR(US_L) // Ø
-#define US_PILC ALGR(US_SCLN) // ¶
-#define US_ACUT ALGR(US_QUOT) // ´ (dead)
-
-/* Row 4 */
-#define US_AE ALGR(US_Z) // Æ
-#define US_OE_2 ALGR(US_X) // Œ
-#define US_COPY ALGR(US_C) // ©
-#define US_REGD ALGR(US_V) // ®
-#define US_NTIL ALGR(US_N) // Ñ
-#define US_MICR ALGR(US_M) // µ
-#define US_CCED ALGR(US_COMM) // Ç
-#define US_DOTA ALGR(US_DOT) // ˙ (dead)
-#define US_IQUE ALGR(US_SLSH) // ¿
-
-
-/* Shift+AltGr symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ~ │ ¡ │ ˝ │ ¯ │ £ │ ¸ │ ¼ │ ½ │ ¾ │ ˘ │ ° │ ̣ │ ÷ │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ “ │ ” │ ¦ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │ │ │ § │ │ │ │ │ │ │ │ ° │ " │ │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
- * │ │ │ │ ¢ │ │ │ │ │ │ ˇ │ ̉ │ │
- * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-
-/* Row 1 */
-#define US_DTIL S(ALGR(US_GRV)) // ~ (dead)
-#define US_IEXL S(ALGR(US_1)) // ¡
-#define US_DACU S(ALGR(US_2)) // ˝ (dead)
-#define US_MACR S(ALGR(US_3)) // ¯ (dead)
-#define US_PND S(ALGR(US_4)) // £
-#define US_CEDL S(ALGR(US_5)) // ¸ (dead)
-#define US_QRTR S(ALGR(US_6)) // ¼
-#define US_HALF S(ALGR(US_7)) // ½
-#define US_TQTR S(ALGR(US_8)) // ¾
-#define US_BREV S(ALGR(US_9)) // ˘ (dead)
-#define US_RNGA S(ALGR(US_0)) // ° (dead)
-#define US_DOTB S(ALGR(US_MINS)) // ̣ (dead)
-#define US_DIV S(ALGR(US_EQL)) // ÷
-
-/* Row 2 */
-#define US_LDQU S(ALGR(US_LBRC)) // “
-#define US_RDQU S(ALGR(US_RBRC)) // ”
-#define US_BRKP S(ALGR(US_BSLS)) // ¦
-
-/* Row 3 */
-#define US_SECT S(ALGR(US_S)) // §
-#define US_DEG S(ALGR(US_SCLN)) // °
-#define US_DIAE S(ALGR(US_QUOT)) // ¨ (dead)
-
-/* Row 4 */
-#define US_CENT S(ALGR(US_C)) // ¢
-#define US_CARN S(ALGR(US_DOT)) // ˇ (dead)
-#define US_HOKA S(ALGR(US_SLSH)) // ̉ (dead)
diff --git a/src/usb_descriptors.c b/src/usb_descriptors.c
@@ -56,7 +56,9 @@ tusb_desc_device_t const desc_device = {
uint8_t const desc_hid_report[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(REPORT_ID_KEYBOARD)),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(REPORT_ID_MOUSE)),
- TUD_HID_REPORT_DESC_CONSUMER(HID_REPORT_ID(REPORT_ID_CONSUMER_CONTROL))
+ TUD_HID_REPORT_DESC_CONSUMER(HID_REPORT_ID(REPORT_ID_CONSUMER)),
+ TUD_HID_REPORT_DESC_SYSTEM_CONTROL(HID_REPORT_ID(REPORT_ID_SYSTEM)),
+ TUD_HID_REPORT_DESC_GAMEPAD(HID_REPORT_ID(REPORT_ID_GAMEPAD))
};
uint8_t const desc_fs_configuration[] = {