diff options
author | tmk <nobody@nowhere> | 2013-02-13 01:23:52 +0100 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-02-13 01:26:22 +0100 |
commit | 48e6d0848cdeac26ffab101ea2ef48e5ac60acd3 (patch) | |
tree | 7f6d82af6752a9ca0d7ae2e3b72cf1ad3b602a3a /common | |
parent | f02431e9da2158ff8a8508629b86329fef0ba24a (diff) | |
download | qmk_firmware-48e6d0848cdeac26ffab101ea2ef48e5ac60acd3.tar.gz qmk_firmware-48e6d0848cdeac26ffab101ea2ef48e5ac60acd3.tar.xz |
Make Transparent feature available to new keymaps.
Diffstat (limited to 'common')
-rw-r--r-- | common/action.c | 19 | ||||
-rw-r--r-- | common/action.h | 5 | ||||
-rw-r--r-- | common/keycode.h | 12 |
3 files changed, 28 insertions, 8 deletions
diff --git a/common/action.c b/common/action.c index aadf5e16e..710300eb3 100644 --- a/common/action.c +++ b/common/action.c @@ -201,6 +201,19 @@ void action_exec(keyevent_t event) } } +static action_t get_action(key_t key) +{ + action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col); + + /* Transparently use default layer */ + if (action.code == ACTION_TRANSPARENT) { + // TODO: layer stacking + action = keymap_get_action(default_layer, key.pos.row, key.pos.col); + debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n"); + } + return action; +} + static void process_action(keyrecord_t *record) { keyevent_t event = record->event; @@ -208,8 +221,7 @@ static void process_action(keyrecord_t *record) if (IS_NOEVENT(event)) { return; } - action_t action = keymap_get_action(current_layer, event.key.pos.row, event.key.pos.col); - //debug("action: "); debug_hex16(action.code); if (event.pressed) debug("d\n"); else debug("u\n"); + action_t action = get_action(event.key); debug("ACTION: "); debug_action(action); debug("\n"); switch (action.kind.id) { @@ -809,7 +821,8 @@ void layer_switch(uint8_t new_layer) bool is_tap_key(key_t key) { - action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col); + action_t action = get_action(key); + switch (action.kind.id) { case ACT_LMODS_TAP: case ACT_RMODS_TAP: diff --git a/common/action.h b/common/action.h index ac44b1a79..bb44049ad 100644 --- a/common/action.h +++ b/common/action.h @@ -106,12 +106,14 @@ Keyboard Keys ------------- ACT_LMODS(0000): 0000|0000|000000|00 No action +0000|0000|000000|01 Transparent 0000|0000| keycode Key 0000|mods|000000|00 Left mods 0000|mods| keycode Key & Left mods ACT_RMODS(0001): -0001|0000|000000|00 No action +0001|0000|000000|00 No action(not used) +0001|0000|000000|01 Transparent(not used) 0001|0000| keycode Key(no used) 0001|mods|000000|00 Right mods 0001|mods| keycode Key & Right mods @@ -207,6 +209,7 @@ enum action_kind_id { /* action utility */ #define ACTION_NO 0 +#define ACTION_TRANSPARENT 1 #define ACTION(kind, param) ((kind)<<12 | (param)) #define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F) diff --git a/common/keycode.h b/common/keycode.h index 4f57a5887..364679994 100644 --- a/common/keycode.h +++ b/common/keycode.h @@ -28,6 +28,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL) #define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI) + +#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) +#define IS_SYSTEM(code) (KC_POWER <= (code) && (code) <= KC_WAKE) +#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) #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) @@ -35,10 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #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 IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) -#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) -#define IS_SYSTEM(code) (KC_POWER <= (code) && (code) <= KC_WAKE) - #define MOD_BIT(code) (1<<MOD_INDEX(code)) #define MOD_INDEX(code) ((code) & 0x07) #define FN_BIT(code) (1<<FN_INDEX(code)) @@ -149,6 +149,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define KC_WSTP KC_WWW_STOP #define KC_WREF KC_WWW_REFRESH #define KC_WFAV KC_WWW_FAVORITES +/* Transparent */ +#define KC_TRANSPARENT 1 +#define KC_TRNS KC_TRANSPARENT + /* USB HID Keyboard/Keypad Usage(0x07) */ |