sxkbd

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

keysym.h (3039B)


      1#pragma once
      2
      3#define XXXXXXX KC_NO
      4#define _______ KC_TRNS
      5
      6#define MASK(hi, lo) ((1U << (hi)) - (1U << (lo)))
      7
      8#define IS_KC(x)    (!((x) & ~MASK(B_TOGGLE, 0)))
      9#define IS_CTRL(x)    ((x) & (1U << B_CTRL))
     10#define IS_SHIFT(x)   ((x) & (1U << B_SHIFT))
     11#define IS_ALT(x)     ((x) & (1U << B_ALT))
     12#define IS_GUI(x)     ((x) & (1U << B_GUI))
     13#define IS_RIGHT(x)   ((x) & (1U << B_RIGHT))
     14#define IS_TOGGLE(x)  ((x) & (1U << B_TOGGLE))
     15#define IS_REBASE(x)  ((x) & (1U << B_REBASE))
     16#define IS_SWITCH(x)  ((x) & (1U << B_SWITCH))
     17#define IS_SPECIAL(x) ((x) & (1U << B_SPECIAL))
     18#define IS_USER(x)    ((x) & (1U << B_USER))
     19
     20#define IS_MOUSE(x)    (IS_SPECIAL(x) && (TO_SPECIAL(x) == S_MOUSE))
     21#define IS_SYSTEM(x)   (IS_SPECIAL(x) && (TO_SPECIAL(x) == S_SYSTEM))
     22#define IS_CONSUMER(x) (IS_SPECIAL(x) && (TO_SPECIAL(x) == S_CONSUMER))
     23
     24#define IS_MACRO_HOLD(x)    ((x) & (1U << B_MACRO_HOLD))
     25#define IS_MACRO_RELEASE(x) ((x) & (1U << B_MACRO_RELEASE))
     26#define IS_MACRO_DELAY(x)   ((x) & (1U << B_MACRO_DELAY))
     27#define IS_MACRO_PRESS(x)   (!IS_MACRO_HOLD(x) && !IS_MACRO_RELEASE(x) \
     28		&& !IS_MACRO_DELAY(x))
     29
     30#define IS_LEFT_CTRL(x)   (IS_CTRL(x) && !IS_RIGHT(x))
     31#define IS_RIGHT_CTRL(x)  (IS_CTRL(x) && IS_RIGHT(x))
     32#define IS_LEFT_SHIFT(x)  (IS_SHIFT(x) && !IS_RIGHT(x))
     33#define IS_RIGHT_SHIFT(x) (IS_SHIFT(x) && IS_RIGHT(x))
     34#define IS_LEFT_ALT(x)    (IS_ALT(x) && !IS_RIGHT(x))
     35#define IS_RIGHT_ALT(x)   (IS_ALT(x) && IS_RIGHT(x))
     36#define IS_LEFT_GUI(x)    (IS_GUI(x) && !IS_RIGHT(x))
     37#define IS_RIGHT_GUI(x)   (IS_GUI(x) && IS_RIGHT(x))
     38
     39#define IS_MOD(x) ((x) & MASK(B_TOGGLE, B_CTRL))
     40
     41#define TO_SPECIAL(x) (((x) >> B_SPECIAL_SEL) & 0b11)
     42#define TO_KC(x)    ((x) & 0xFF)
     43#define TO_USER(x)  ((x) & 0xFF)
     44#define TO_LAYER(x) ((x) & 0xFF)
     45#define TO_SYM(x)   ((x) & 0xFFFF)
     46#define TO_DELAY(x) ((x) & 0xFFFF)
     47
     48#define SPECIAL(x, g) ((x) | (1U << B_SPECIAL) | ((g) << B_SPECIAL_SEL))
     49
     50#define LCTL(x) ((x) | (1 << B_CTRL))
     51#define LSFT(x) ((x) | (1 << B_SHIFT))
     52#define LALT(x) ((x) | (1 << B_ALT))
     53#define LGUI(x) ((x) | (1 << B_GUI))
     54#define RIGH(x) ((x) | (1 << B_RIGHT))
     55
     56#define HOLD(x)    ((x) | (1 << B_MACRO_HOLD))
     57#define RELEASE(x) ((x) | (1 << B_MACRO_RELEASE))
     58#define DELAY(x)   ((x) | (1 << B_MACRO_DELAY))
     59
     60#define SW(x) ((x) | (1 << B_SWITCH))
     61#define TO(x) ((x) | (1 << B_TOGGLE))
     62#define RB(x) ((x) | (1 << B_REBASE))
     63#define SX(x) ((x) | (1 << B_USER))
     64
     65#define RCTL(x) RIGH(LCTL(x))
     66#define RSFT(x) RIGH(LSFT(x))
     67#define RALT(x) RIGH(LALT(x))
     68#define RGUI(x) RIGH(LGUI(x))
     69
     70#define LOPT(x) LALT(x)
     71#define LCMD(x) LGUI(x)
     72#define LWIN(x) LGUI(x)
     73#define ALGR(x) RALT(x)
     74#define ROPT(x) RALT(x)
     75#define RCMD(x) RGUI(x)
     76
     77#define CS(x) C(SW(x))
     78#define AS(x) A(SW(x))
     79#define GS(x) G(SW(x))
     80
     81#define C(x) LCTL(x)
     82#define S(x) LSFT(x)
     83#define A(x) LALT(x)
     84#define G(x) LGUI(x)
     85
     86enum {
     87	S_CONSUMER,
     88	S_MOUSE,
     89	S_SYSTEM
     90};
     91
     92enum {
     93	B_SPECIAL_SEL = 6,
     94	B_CTRL = 8,
     95	B_SHIFT,
     96	B_ALT,
     97	B_GUI,
     98	B_RIGHT,
     99	B_TOGGLE,
    100	B_REBASE,
    101	B_SWITCH,
    102	B_SPECIAL,
    103	B_USER,
    104	B_MACRO_HOLD,
    105	B_MACRO_RELEASE,
    106	B_MACRO_DELAY /* >= 16 */
    107};
    108