-#define Kdebug(s) do { if (debug_keyboard) debug(s); } while(0)
-#define Kdebug_P(s) do { if (debug_keyboard) debug_P(s); } while(0)
-#define Kdebug_hex(s) do { if (debug_keyboard) debug_hex(s); } while(0)
-
-
-/*
- *
- * Event/State|IDLE PRESSING DELAYING[f] WAITING[f,k]
- * -----------+------------------------------------------------------------------
- * Fn Down |(L+) -*1 WAITING(Sk) IDLE(Rf,Ps)*7
- * Up |(L-) IDLE(L-)*8 IDLE(L-)*8 IDLE(L-)*8
- * Fnk Down |DELAYING(Sf)* (Rf) WAITING(Sk) IDLE(Rf,Ps,Rf)
- * Up |(L-) IDLE(L-/Uf)*8 IDLE(Rf,Uf/L-)*3 IDLE(Rf,Ps,Uf/L-)*3
- * Key Down |PRESSING(Rk) (Rk) WAITING(Sk) IDLE(Rf,Ps,Rk)
- * Up |(Uk) IDLE(Uk)*4 (Uk) IDLE(L+,Ps,Pk)/(Uk)*a
- * |
- * Delay |- - IDLE(L+) IDLE(L+,Ps)
- * Magic Key |COMMAND*5
- *
- * *1: ignore Fn if other key is down.
- * *2: register Fnk if any key is pressing
- * *3: register/unregister delayed Fnk and move to IDLE if code == delayed Fnk, else *8
- * *4: if no keys registered to host
- * *5: unregister all keys
- * *6: only if no keys down
- * *7: ignore Fn because Fnk key and stored key are down.
- * *8: move to IDLE if layer switch(off) occurs, else stay at current state
- * *9: repeat key if pressing Fnk twice quickly(move to PRESSING)
- * *a: layer switch and process waiting key and code if code == wainting key, else unregister key
- *
- * States:
- * IDLE: No key is down except modifiers
- * DELAYING: delay layer switch after pressing Fn with alt keycode
- * WAITING: key is pressed during DELAYING
- *
- * Events:
- * Fn: Fn key without alternative keycode
- * Fnk: Fn key with alternative keycode
- * -: ignore
- * Delay: layer switch delay term is elapsed
- *
- * Actions:
- * Rk: register key
- * Uk: unregister key
- * Rf: register Fn(alt keycode)
- * Uf: unregister Fn(alt keycode)
- * Rs: register stored key
- * Us: unregister stored key
- * Sk: Store key(waiting Key)
- * Sf: Store Fn(delayed Fn)
- * Ps: Process stored key
- * Ps: Process key
- * Is: Interpret stored keys in current layer
- * L+: Switch to new layer(*unregister* all keys but modifiers)
- * L-: Switch back to last layer(*unregister* all keys but modifiers)
- * Ld: Switch back to default layer(*unregister* all keys but modifiers)
- */
-
-
-typedef enum { IDLE, DELAYING, WAITING, PRESSING } kbdstate_t;
-#define NEXT(state) do { \
- Kdebug("NEXT: "); Kdebug_P(state_str(kbdstate)); \
- kbdstate = state; \
- Kdebug(" -> "); Kdebug_P(state_str(kbdstate)); Kdebug("\n"); \
-} while (0)
-