- }
- else if IS_CONSUMER(code) {
- uint16_t usage = 0;
- switch (code) {
- case KC_AUDIO_MUTE:
- usage = AUDIO_MUTE;
- break;
- case KC_AUDIO_VOL_UP:
- usage = AUDIO_VOL_UP;
- break;
- case KC_AUDIO_VOL_DOWN:
- usage = AUDIO_VOL_DOWN;
- break;
- case KC_MEDIA_NEXT_TRACK:
- usage = TRANSPORT_NEXT_TRACK;
- break;
- case KC_MEDIA_PREV_TRACK:
- usage = TRANSPORT_PREV_TRACK;
- break;
- case KC_MEDIA_STOP:
- usage = TRANSPORT_STOP;
- break;
- case KC_MEDIA_PLAY_PAUSE:
- usage = TRANSPORT_PLAY_PAUSE;
- break;
- case KC_MEDIA_SELECT:
- usage = AL_CC_CONFIG;
- break;
- case KC_MAIL:
- usage = AL_EMAIL;
- break;
- case KC_CALCULATOR:
- usage = AL_CALCULATOR;
- break;
- case KC_MY_COMPUTER:
- usage = AL_LOCAL_BROWSER;
- break;
- case KC_WWW_SEARCH:
- usage = AC_SEARCH;
- break;
- case KC_WWW_HOME:
- usage = AC_HOME;
- break;
- case KC_WWW_BACK:
- usage = AC_BACK;
- break;
- case KC_WWW_FORWARD:
- usage = AC_FORWARD;
- break;
- case KC_WWW_STOP:
- usage = AC_STOP;
- break;
- case KC_WWW_REFRESH:
- usage = AC_REFRESH;
- break;
- case KC_WWW_FAVORITES:
- usage = AC_BOOKMARKS;
- break;
- }
- host_consumer_send(usage);
- }
- else if IS_SYSTEM(code) {
- uint16_t usage = 0;
- switch (code) {
- case KC_SYSTEM_POWER:
- usage = SYSTEM_POWER_DOWN;
- break;
- case KC_SYSTEM_SLEEP:
- usage = SYSTEM_SLEEP;
- break;
- case KC_SYSTEM_WAKE:
- usage = SYSTEM_WAKE_UP;
- break;
- }
- host_system_send(usage);
- }
-
-}
-
-static void unregister_code(uint8_t code)
-{
- if IS_KEY(code) {
- host_del_key(code);
- host_send_keyboard_report();
- }
- else if IS_MOD(code) {
- host_del_mod_bit(MOD_BIT(code));
- host_send_keyboard_report();
- }
- else if IS_FN(code) {
- host_del_key(keymap_fn_keycode(FN_INDEX(code)));
- host_send_keyboard_report();
- }
- else if IS_MOUSEKEY(code) {
-#ifdef MOUSEKEY_ENABLE
- mousekey_off(code);
- mousekey_send();
-#endif
- }
- else if IS_CONSUMER(code) {
- host_consumer_send(0x0000);
- }
- else if IS_SYSTEM(code) {
- host_system_send(0x0000);
- }
-}
-
-/*
- *
- * 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)
- */
-#define NEXT(state) do { \
- Kdebug("NEXT: "); Kdebug_P(state_str(kbdstate)); \
- kbdstate = state; \
- Kdebug(" -> "); Kdebug_P(state_str(kbdstate)); Kdebug("\n"); \
-} while (0)