sxkbd

Firmware for RP2040-based corne split keyboard
git clone https://git.sinitax.com/sinitax/sxkbd
Log | Files | Refs | Submodules | README | LICENSE | sfeed.txt

keyboard.h (6727B)


      1#pragma once
      2
      3/*
      4 * Keycodes based on HID Keyboard/Keypad Usage Page (0x07) plus media keys
      5 * from Generic Desktop Page (0x01) and Consumer Page (0x0C)
      6 *
      7 * See https://web.archive.org/web/20060218214400/http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
      8 * or http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (older)
      9 */
     10
     11#define IS_ANY_KC(code) (KC_A <= (code) && (code) <= 0xFF)
     12#define IS_ERROR_KC(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
     13#define IS_KEY_KC(code) (KC_A <= (code) && (code) <= KC_EXSEL)
     14#define IS_MOD_KC(code) (KC_LEFT_CTRL <= (code) && (code) <= KC_RIGHT_GUI)
     15
     16#define MOD_INDEX(code) ((code) & 0b111)
     17#define MOD_BIT(code) (1 << MOD_INDEX(code))
     18
     19/* Transparent */
     20#define KC_TRANSPARENT 0x01
     21#define KC_TRNS KC_TRANSPARENT
     22
     23/* Punctuation */
     24#define KC_ENT  KC_ENTER
     25#define KC_ESC  KC_ESCAPE
     26#define KC_BSPC KC_BACKSPACE
     27#define KC_SPC  KC_SPACE
     28#define KC_MINS KC_MINUS
     29#define KC_EQL  KC_EQUAL
     30#define KC_LBRC KC_LEFT_BRACKET
     31#define KC_RBRC KC_RIGHT_BRACKET
     32#define KC_BSLS KC_BACKSLASH
     33#define KC_NUHS KC_NONUS_HASH
     34#define KC_SCLN KC_SEMICOLON
     35#define KC_QUOT KC_QUOTE
     36#define KC_GRV  KC_GRAVE
     37#define KC_COMM KC_COMMA
     38#define KC_SLSH KC_SLASH
     39#define KC_NUBS KC_NONUS_BACKSLASH
     40
     41/* Lock Keys */
     42#define KC_CAPS KC_CAPS_LOCK
     43#define KC_SCRL KC_SCROLL_LOCK
     44#define KC_NUM  KC_NUM_LOCK
     45#define KC_LCAP KC_LOCKING_CAPS_LOCK
     46#define KC_LNUM KC_LOCKING_NUM_LOCK
     47#define KC_LSCR KC_LOCKING_SCROLL_LOCK
     48
     49/* Commands */
     50#define KC_PSCR KC_PRINT_SCREEN
     51#define KC_PAUS KC_PAUSE
     52#define KC_BRK  KC_PAUSE
     53#define KC_INS  KC_INSERT
     54#define KC_PGUP KC_PAGE_UP
     55#define KC_DEL  KC_DELETE
     56#define KC_PGDN KC_PAGE_DOWN
     57#define KC_RGHT KC_RIGHT
     58#define KC_APP  KC_APPLICATION
     59#define KC_EXEC KC_EXECUTE
     60#define KC_SLCT KC_SELECT
     61#define KC_AGIN KC_AGAIN
     62#define KC_PSTE KC_PASTE
     63#define KC_ERAS KC_ALTERNATE_ERASE
     64#define KC_SYRQ KC_SYSTEM_REQUEST
     65#define KC_CNCL KC_CANCEL
     66#define KC_CLR  KC_CLEAR
     67#define KC_PRIR KC_PRIOR
     68#define KC_RETN KC_RETURN
     69#define KC_SEPR KC_SEPARATOR
     70#define KC_CLAG KC_CLEAR_AGAIN
     71#define KC_CRSL KC_CRSEL
     72#define KC_EXSL KC_EXSEL
     73
     74/* Keypad */
     75#define KC_PSLS KC_KP_SLASH
     76#define KC_PAST KC_KP_ASTERISK
     77#define KC_PMNS KC_KP_MINUS
     78#define KC_PPLS KC_KP_PLUS
     79#define KC_PENT KC_KP_ENTER
     80#define KC_P1   KC_KP_1
     81#define KC_P2   KC_KP_2
     82#define KC_P3   KC_KP_3
     83#define KC_P4   KC_KP_4
     84#define KC_P5   KC_KP_5
     85#define KC_P6   KC_KP_6
     86#define KC_P7   KC_KP_7
     87#define KC_P8   KC_KP_8
     88#define KC_P9   KC_KP_9
     89#define KC_P0   KC_KP_0
     90#define KC_PDOT KC_KP_DOT
     91#define KC_PEQL KC_KP_EQUAL
     92#define KC_PCMM KC_KP_COMMA
     93
     94/* Language Specific */
     95#define KC_INT1 KC_INTERNATIONAL_1
     96#define KC_INT2 KC_INTERNATIONAL_2
     97#define KC_INT3 KC_INTERNATIONAL_3
     98#define KC_INT4 KC_INTERNATIONAL_4
     99#define KC_INT5 KC_INTERNATIONAL_5
    100#define KC_INT6 KC_INTERNATIONAL_6
    101#define KC_INT7 KC_INTERNATIONAL_7
    102#define KC_INT8 KC_INTERNATIONAL_8
    103#define KC_INT9 KC_INTERNATIONAL_9
    104#define KC_LNG1 KC_LANGUAGE_1
    105#define KC_LNG2 KC_LANGUAGE_2
    106#define KC_LNG3 KC_LANGUAGE_3
    107#define KC_LNG4 KC_LANGUAGE_4
    108#define KC_LNG5 KC_LANGUAGE_5
    109#define KC_LNG6 KC_LANGUAGE_6
    110#define KC_LNG7 KC_LANGUAGE_7
    111#define KC_LNG8 KC_LANGUAGE_8
    112#define KC_LNG9 KC_LANGUAGE_9
    113
    114/* Modifiers */
    115#define KC_LCTL KC_LEFT_CTRL
    116#define KC_LSFT KC_LEFT_SHIFT
    117#define KC_LALT KC_LEFT_ALT
    118#define KC_LOPT KC_LEFT_ALT
    119#define KC_LGUI KC_LEFT_GUI
    120#define KC_LCMD KC_LEFT_GUI
    121#define KC_LWIN KC_LEFT_GUI
    122#define KC_RCTL KC_RIGHT_CTRL
    123#define KC_RSFT KC_RIGHT_SHIFT
    124#define KC_RALT KC_RIGHT_ALT
    125#define KC_ALGR KC_RIGHT_ALT
    126#define KC_ROPT KC_RIGHT_ALT
    127#define KC_RGUI KC_RIGHT_GUI
    128#define KC_RCMD KC_RIGHT_GUI
    129#define KC_RWIN KC_RIGHT_GUI
    130
    131/* Keyboard/Keypad Page (0x07) */
    132enum hid_keyboard {
    133	KC_NO = 0x00,
    134	KC_ROLL_OVER,
    135	KC_POST_FAIL,
    136	KC_UNDEFINED,
    137	KC_A,
    138	KC_B,
    139	KC_C,
    140	KC_D,
    141	KC_E,
    142	KC_F,
    143	KC_G,
    144	KC_H,
    145	KC_I,
    146	KC_J,
    147	KC_K,
    148	KC_L,
    149	KC_M, // 0x10
    150	KC_N,
    151	KC_O,
    152	KC_P,
    153	KC_Q,
    154	KC_R,
    155	KC_S,
    156	KC_T,
    157	KC_U,
    158	KC_V,
    159	KC_W,
    160	KC_X,
    161	KC_Y,
    162	KC_Z,
    163	KC_1,
    164	KC_2,
    165	KC_3, // 0x20
    166	KC_4,
    167	KC_5,
    168	KC_6,
    169	KC_7,
    170	KC_8,
    171	KC_9,
    172	KC_0,
    173	KC_ENTER,
    174	KC_ESCAPE,
    175	KC_BACKSPACE,
    176	KC_TAB,
    177	KC_SPACE,
    178	KC_MINUS,
    179	KC_EQUAL,
    180	KC_LEFT_BRACKET,
    181	KC_RIGHT_BRACKET, // 0x30
    182	KC_BACKSLASH,
    183	KC_NONUS_HASH,
    184	KC_SEMICOLON,
    185	KC_QUOTE,
    186	KC_GRAVE,
    187	KC_COMMA,
    188	KC_DOT,
    189	KC_SLASH,
    190	KC_CAPS_LOCK,
    191	KC_F1,
    192	KC_F2,
    193	KC_F3,
    194	KC_F4,
    195	KC_F5,
    196	KC_F6,
    197	KC_F7, // 0x40
    198	KC_F8,
    199	KC_F9,
    200	KC_F10,
    201	KC_F11,
    202	KC_F12,
    203	KC_PRINT_SCREEN,
    204	KC_SCROLL_LOCK,
    205	KC_PAUSE,
    206	KC_INSERT,
    207	KC_HOME,
    208	KC_PAGE_UP,
    209	KC_DELETE,
    210	KC_END,
    211	KC_PAGE_DOWN,
    212	KC_RIGHT,
    213	KC_LEFT, // 0x50
    214	KC_DOWN,
    215	KC_UP,
    216	KC_NUM_LOCK,
    217	KC_KP_SLASH,
    218	KC_KP_ASTERISK,
    219	KC_KP_MINUS,
    220	KC_KP_PLUS,
    221	KC_KP_ENTER,
    222	KC_KP_1,
    223	KC_KP_2,
    224	KC_KP_3,
    225	KC_KP_4,
    226	KC_KP_5,
    227	KC_KP_6,
    228	KC_KP_7,
    229	KC_KP_8, // 0x60
    230	KC_KP_9,
    231	KC_KP_0,
    232	KC_KP_DOT,
    233	KC_NONUS_BACKSLASH,
    234	KC_APPLICATION,
    235	KC_KB_POWER,
    236	KC_KP_EQUAL,
    237	KC_F13,
    238	KC_F14,
    239	KC_F15,
    240	KC_F16,
    241	KC_F17,
    242	KC_F18,
    243	KC_F19,
    244	KC_F20,
    245	KC_F21, // 0x70
    246	KC_F22,
    247	KC_F23,
    248	KC_F24,
    249	KC_EXECUTE,
    250	KC_HELP,
    251	KC_MENU,
    252	KC_SELECT,
    253	KC_STOP,
    254	KC_AGAIN,
    255	KC_UNDO,
    256	KC_CUT,
    257	KC_COPY,
    258	KC_PASTE,
    259	KC_FIND,
    260	KC_KB_MUTE,
    261	KC_KB_VOLUME_UP, // 0x80
    262	KC_KB_VOLUME_DOWN,
    263	KC_LOCKING_CAPS_LOCK,
    264	KC_LOCKING_NUM_LOCK,
    265	KC_LOCKING_SCROLL_LOCK,
    266	KC_KP_COMMA,
    267	KC_KP_EQUAL_AS400,
    268	KC_INTERNATIONAL_1,
    269	KC_INTERNATIONAL_2,
    270	KC_INTERNATIONAL_3,
    271	KC_INTERNATIONAL_4,
    272	KC_INTERNATIONAL_5,
    273	KC_INTERNATIONAL_6,
    274	KC_INTERNATIONAL_7,
    275	KC_INTERNATIONAL_8,
    276	KC_INTERNATIONAL_9,
    277	KC_LANGUAGE_1, // 0x90
    278	KC_LANGUAGE_2,
    279	KC_LANGUAGE_3,
    280	KC_LANGUAGE_4,
    281	KC_LANGUAGE_5,
    282	KC_LANGUAGE_6,
    283	KC_LANGUAGE_7,
    284	KC_LANGUAGE_8,
    285	KC_LANGUAGE_9,
    286	KC_ALTERNATE_ERASE,
    287	KC_SYSTEM_REQUEST,
    288	KC_CANCEL,
    289	KC_CLEAR,
    290	KC_PRIOR,
    291	KC_RETURN,
    292	KC_SEPARATOR,
    293	KC_OUT, // 0xA0
    294	KC_OPER,
    295	KC_CLEAR_AGAIN,
    296	KC_CRSEL,
    297	KC_EXSEL,
    298
    299#if 0
    300	/* These keycodes are present in the HID spec, but are
    301	 * nonfunctional on modern OSes */
    302	
    303	KC_KP_00				= 0xB0,
    304	KC_KP_000,
    305	KC_THOUSANDS_SEPARATOR,
    306	KC_DECIMAL_SEPARATOR,
    307	KC_CURRENCY_UNIT,
    308	KC_CURRENCY_SUB_UNIT,
    309	KC_KP_LEFT_PARENTHESIS,
    310	KC_KP_RIGHT_PARENTHESIS,
    311	KC_KP_LEFT_BRACE,
    312	KC_KP_RIGHT_BRACE,
    313	KC_KP_TAB,
    314	KC_KP_BACKSPACE,
    315	KC_KP_A,
    316	KC_KP_B,
    317	KC_KP_C,
    318	KC_KP_D,
    319	KC_KP_E,				//0xC0
    320	KC_KP_F,
    321	KC_KP_XOR,
    322	KC_KP_HAT,
    323	KC_KP_PERCENT,
    324	KC_KP_LESS_THAN,
    325	KC_KP_GREATER_THAN,
    326	KC_KP_AND,
    327	KC_KP_LAZY_AND,
    328	KC_KP_OR,
    329	KC_KP_LAZY_OR,
    330	KC_KP_COLON,
    331	KC_KP_HASH,
    332	KC_KP_SPACE,
    333	KC_KP_AT,
    334	KC_KP_EXCLAMATION,
    335	KC_KP_MEM_STORE,		//0xD0
    336	KC_KP_MEM_RECALL,
    337	KC_KP_MEM_CLEAR,
    338	KC_KP_MEM_ADD,
    339	KC_KP_MEM_SUB,
    340	KC_KP_MEM_MUL,
    341	KC_KP_MEM_DIV,
    342	KC_KP_PLUS_MINUS,
    343	KC_KP_CLEAR,
    344	KC_KP_CLEAR_ENTRY,
    345	KC_KP_BINARY,
    346	KC_KP_OCTAL,
    347	KC_KP_DECIMAL,
    348	KC_KP_HEXADECIMAL,
    349#endif
    350
    351	/* Modifiers */
    352	KC_LEFT_CTRL = 0xE0,
    353	KC_LEFT_SHIFT,
    354	KC_LEFT_ALT,
    355	KC_LEFT_GUI,
    356	KC_RIGHT_CTRL,
    357	KC_RIGHT_SHIFT,
    358	KC_RIGHT_ALT,
    359	KC_RIGHT_GUI
    360};