From: tmk Date: Thu, 7 Feb 2013 15:50:51 +0000 (+0900) Subject: Clean layer actions. X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=b2aa142ee0a88ae6c38798f33cf5d833b0ae3864;p=max%2Ftmk_keyboard.git Clean layer actions. --- diff --git a/common/action.c b/common/action.c index 301a9b6a..f6e50032 100644 --- a/common/action.c +++ b/common/action.c @@ -319,14 +319,14 @@ static void process_action(keyrecord_t *record) case ACT_USAGE: #ifdef EXTRAKEY_ENABLE switch (action.usage.page) { - case ACTION_USAGE_PAGE_SYSTEM: + case PAGE_SYSTEM: if (event.pressed) { host_system_send(action.usage.code); } else { host_system_send(0); } break; - case ACTION_USAGE_PAGE_CONSUMER: + case PAGE_CONSUMER: if (event.pressed) { host_consumer_send(action.usage.code); } else { @@ -351,20 +351,44 @@ static void process_action(keyrecord_t *record) break; /* Layer key */ - case ACT_LAYER_PRESSED: - // layer action when pressed + case ACT_LAYER: switch (action.layer.code) { - case 0x00: + case LAYER_MOMENTARY: /* momentary */ if (event.pressed) { layer_switch(action.layer.val); } -//TODO: this is ok? else { layer_switch(default_layer); } break; - case 0xF0: - // tap toggle + case LAYER_ON_PRESS: + if (event.pressed) { + layer_switch(action.layer.val); + } + break; + case LAYER_ON_RELEASE: + if (!event.pressed) { + layer_switch(action.layer.val); + } + break; + case LAYER_DEFAULT: /* default layer */ + switch (action.layer.val) { + case DEFAULT_ON_BOTH: + layer_switch(default_layer); + break; + case DEFAULT_ON_PRESS: + if (event.pressed) { + layer_switch(default_layer); + } + break; + case DEFAULT_ON_RELEASE: + if (!event.pressed) { + layer_switch(default_layer); + } + break; + } + break; + case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */ if (event.pressed) { if (tap_count < TAPPING_TOGGLE) { layer_switch(action.layer.val); @@ -376,15 +400,13 @@ static void process_action(keyrecord_t *record) } } break; - case 0xFF: - // change default layer + case LAYER_CHANGE_DEFAULT: /* change default layer */ if (event.pressed) { default_layer = action.layer.val; layer_switch(default_layer); } break; - default: - // with tap key + default: /* switch layer on hold and key on tap*/ if (event.pressed) { if (tap_count > 0) { debug("LAYER_PRESSED: Tap: register_code\n"); @@ -407,65 +429,26 @@ static void process_action(keyrecord_t *record) break; } break; - case ACT_LAYER_RELEASED: + case ACT_LAYER_BIT: switch (action.layer.code) { - case 0x00: - if (!event.pressed) { - layer_switch(action.layer.val); - } - break; - case 0xF0: - // tap toggle + case LAYER_MOMENTARY: /* momentary */ if (event.pressed) { - if (tap_count >= TAPPING_TOGGLE) { - debug("LAYER_RELEASED: tap toggle.\n"); - layer_switch(action.layer.val); - } + layer_switch(current_layer ^ action.layer.val); } else { - if (tap_count < TAPPING_TOGGLE) { - layer_switch(action.layer.val); - } - } - break; - case 0xFF: - // change default layer - if (!event.pressed) { - default_layer = action.layer.val; - layer_switch(default_layer); + layer_switch(current_layer ^ action.layer.val); } break; - default: - // with tap key + case LAYER_ON_PRESS: if (event.pressed) { - if (tap_count > 0) { - debug("LAYER_RELEASED: Tap: register_code\n"); - register_code(action.layer.code); - } else { - debug("LAYER_RELEASED: No tap: NO ACTION\n"); - } - } else { - if (tap_count > 0) { - debug("LAYER_RELEASED: Tap: unregister_code\n"); - unregister_code(action.layer.code); - } else { - debug("LAYER_RELEASED: No tap: layer_switch\n"); - layer_switch(action.layer.val); - } + layer_switch(current_layer ^ action.layer.val); } break; - } - break; - case ACT_LAYER_BIT: - switch (action.layer.code) { - case 0x00: - if (event.pressed) { - layer_switch(current_layer ^ action.layer.val); - } else { + case LAYER_ON_RELEASE: + if (!event.pressed) { layer_switch(current_layer ^ action.layer.val); } break; - case 0xF0: - // tap toggle + case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */ if (event.pressed) { if (tap_count < TAPPING_TOGGLE) { debug("LAYER_BIT: tap toggle(press).\n"); @@ -510,108 +493,6 @@ static void process_action(keyrecord_t *record) break; } break; - case ACT_LAYER_EXT: - switch (action.layer.val) { - case 0x00: - // set default layer when pressed - switch (action.layer.code) { - case 0x00: - if (event.pressed) { - layer_switch(default_layer); - } - break; - case 0xF0: - // tap toggle - if (event.pressed) { - if (tap_count < TAPPING_TOGGLE) { - layer_switch(default_layer); - } - } else { - if (tap_count >= TAPPING_TOGGLE) { - debug("LAYER_EXT_PRESSED: tap toggle.\n"); - layer_switch(default_layer); - } - } - break; - case 0xFF: - // change default layer - if (event.pressed) { - default_layer = current_layer; - layer_switch(default_layer); - } - break; - default: - // with tap key - if (event.pressed) { - if (tap_count > 0) { - debug("LAYER_EXT_PRESSED: Tap: register_code\n"); - register_code(action.layer.code); - } else { - debug("LAYER_EXT_PRESSED: No tap: layer_switch\n"); - layer_switch(default_layer); - } - } else { - if (tap_count > 0) { - debug("LAYER_EXT_PRESSED: Tap: unregister_code\n"); - unregister_code(action.layer.code); - } else { - debug("LAYER_EXT_PRESSED: No tap: NO ACTION\n"); - } - } - break; - } - break; - case 0x01: - // set default layer when released - switch (action.layer.code) { - case 0x00: - if (!event.pressed) { - layer_switch(default_layer); - } - break; - case 0xF0: - // tap toggle - if (event.pressed) { - if (tap_count >= TAPPING_TOGGLE) { - debug("LAYER_EXT_RELEASED: tap toggle.\n"); - layer_switch(default_layer); - } - } else { - if (tap_count < TAPPING_TOGGLE) { - layer_switch(default_layer); - } - } - break; - case 0xFF: - // change default layer - if (!event.pressed) { - default_layer = current_layer; - layer_switch(default_layer); - } - break; - default: - // with tap key - if (event.pressed) { - if (tap_count > 0) { - debug("LAYER_EXT_RELEASED: Tap: register_code\n"); - register_code(action.layer.code); - } else { - debug("LAYER_EXT_RELEASED: No tap: NO ACTION\n"); - } - } else { - if (tap_count > 0) { - debug("LAYER_EXT_RELEASED: Tap: unregister_code\n"); - unregister_code(action.layer.code); - } else { - debug("LAYER_EXT_RELEASED: No tap: layer_switch\n"); - layer_switch(default_layer); - } - } - break; - } - break; - } - break; /* Extentions */ case ACT_MACRO: @@ -932,7 +813,7 @@ bool is_tap_key(key_t key) case ACT_LMODS_TAP: case ACT_RMODS_TAP: return true; - case ACT_LAYER_PRESSED: + case ACT_LAYER: case ACT_LAYER_BIT: switch (action.layer.code) { case 0x00: @@ -944,7 +825,7 @@ bool is_tap_key(key_t key) } return false; case ACT_FUNCTION: - if (action.func.opt & O_TAP) { + if (action.func.opt & FUNC_TAP) { return true; } return false; @@ -975,10 +856,8 @@ static void debug_action(action_t action) case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; case ACT_USAGE: debug("ACT_USAGE"); break; case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; - case ACT_LAYER_PRESSED: debug("ACT_LAYER_PRESSED"); break; - case ACT_LAYER_RELEASED: debug("ACT_LAYER_RELEASED"); break; + case ACT_LAYER: debug("ACT_LAYER"); break; case ACT_LAYER_BIT: debug("ACT_LAYER_BIT"); break; - case ACT_LAYER_EXT: debug("ACT_LAYER_EXT"); break; case ACT_MACRO: debug("ACT_MACRO"); break; case ACT_COMMAND: debug("ACT_COMMAND"); break; case ACT_FUNCTION: debug("ACT_FUNCTION"); break; diff --git a/common/action.h b/common/action.h index b1e958a2..800554eb 100644 --- a/common/action.h +++ b/common/action.h @@ -150,42 +150,26 @@ ACT_MOUSEKEY(0110): Layer Actions ------------- -TODO: reconsider layer methods. -1 momemtary + tap key up: L, down: default -1 bitwise + tap key up: xor B, down: xor B -3 momemtary go + tap key? up: X, down: -3 toggle(mementary back) + tap key? up: down: Y -3 no tap up: X, down: Y - -ACT_LAYER_PRESSED(1000): Set layer on key pressed -ACT_LAYER_RELEASED(1001): Set layer on key released -ACT_LAYER_BIT(1010): On/Off layer bit -ACT_LAYER_EXT(1011): Extentions - -1000|LLLL|0000 0000 set layer L when pressed -1001|LLLL|0000 0000 set layer L when released -1010|BBBB|0000 0000 on/off bit B when pressed/released -1011|0000|0000 0000 set default layer when pressed -1011|0001|0000 0000 set default layer when released - -1000|LLLL|1111 0000 set layer L when pressed + tap toggle -1001|LLLL|1111 0000 set layer L when released + tap toggle -1010|BBBB|1111 0000 on/off bit B when pressed/released + tap toggle -1011|0000|1111 0000 set default layer when pressed + tap toggle -1011|0001|1111 0000 set default layer when released + tap toggle - -1000|LLLL|1111 1111 set L to default layer when pressed -1001|LLLL|1111 1111 set L to default layer when released -1010|BBBB|1111 1111 on/off bit B of default layer when pressed/released -1011|0000|1111 1111 set current to default layer when pressed -1011|0001|1111 1111 set current to default layer when released - -1000|LLLL| keycode set layer L when pressed + tap key -1001|LLLL| keyocde set layer L when released + tap key -1010|BBBB| keyocde on/off bit B when pressed/released + tap key -1011|0000| keyocde set default layer when pressed + tap key -1011|0001| keyocde set default layer when released + tap key - +ACT_LAYER(1000): Set layer +ACT_LAYER_BIT(1001): Bit-op layer + +1000|LLLL|0000 0000 set L to layer on press and set default on release(momentary) +1000|LLLL|0000 0001 set L to layer on press +1000|LLLL|0000 0010 set L to layer on release +1000|----|0000 0011 set default to layer on both(return to default layer) +1000|LLLL|xxxx xxxx set L to layer while hold and send key on tap +1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps +1000|LLLL|1111 1111 set L to default and layer(on press) + +1001|BBBB|0000 0000 (not used) +1001|BBBB|0000 0001 bit-xor layer with B on press +1001|BBBB|0000 0010 bit-xor layer with B on release +1001|BBBB|0000 0011 bit-xor layer with B on both(momentary) +1001|BBBB|xxxx xxxx bit-xor layer with B while hold and send key on tap +1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps +1001|BBBB|1111 1111 bit-xor default with B and set layer(on press) + + Extensions(11XX) ---------------- @@ -212,24 +196,14 @@ enum action_kind_id { ACT_USAGE = 0b0100, ACT_MOUSEKEY = 0b0101, - ACT_LAYER_PRESSED = 0b1000, - ACT_LAYER_RELEASED = 0b1001, - ACT_LAYER_BIT = 0b1010, - ACT_LAYER_EXT = 0b1011, + ACT_LAYER = 0b1000, + ACT_LAYER_BIT = 0b1001, ACT_MACRO = 0b1100, ACT_COMMAND = 0b1110, ACT_FUNCTION = 0b1111 }; -enum params { - P_ONESHOT = 0x00, -}; - -enum options { - O_TAP = 0x8, -}; - /* action utility */ #define ACTION_NO 0 @@ -250,48 +224,93 @@ enum options { #define ACTION_RMOD_KEY(mod, key) ACTION(ACT_RMODS, MODS4(MOD_BIT(mod))<<8 | (key)) /* Mods + Tap key */ +enum mods_codes { + MODS_ONESHOT = 0x00, +}; #define ACTION_LMODS_TAP_KEY(mods, key) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | (key)) -#define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | P_ONESHOT) +#define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | MODS_ONESHOT) #define ACTION_RMODS_TAP_KEY(mods, key) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | (key)) -#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | P_ONESHOT) +#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | MODS_ONESHOT) /* Mod + Tap key */ #define ACTION_LMOD_TAP_KEY(mod, key) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) -#define ACTION_LMOD_ONESHOT(mod) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | P_ONESHOT) +#define ACTION_LMOD_ONESHOT(mod) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) -#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | P_ONESHOT) - -// TODO: contemplate about layer action -/* Switch current layer */ -#define ACTION_LAYER_SET(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0x00) -#define ACTION_LAYER_SET_ON_PRESSED(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0x00) -#define ACTION_LAYER_SET_ON_RELEASED(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0x00) -#define ACTION_LAYER_BIT(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | 0x00) -#define ACTION_LAYER_SET_DEFAULT ACTION(ACT_LAYER_EXT, 0x0<<8 | 0x00) -#define ACTION_LAYER_RETURN_DEFAULT ACTION(ACT_LAYER_EXT, 0x1<<8 | 0x00) -#define ACTION_LAYER_SET_DEFAULT_ON_PRESSED ACTION(ACT_LAYER_EXT, 0x0<<8 | 0x00) -#define ACTION_LAYER_SET_DEFAULT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0x00) -/* Switch default layer */ -#define ACTION_LAYER_DEFAULT_SET(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xFF) -#define ACTION_LAYER_DEFAULT_SET_ON_PRESSED(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xFF) -#define ACTION_LAYER_DEFAULT_SET_ON_RELEASED(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0xFF) -#define ACTION_LAYER_DEFAULT_BIT(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | 0xFF) -#define ACTION_LAYER_DEFAULT_SET_CURRENT_ON_PRESSED ACTION(ACT_LAYER_EXT, 0x0<<8 | 0xFF) -#define ACTION_LAYER_DEFAULT_SET_CURRENT_ON_RELEASED ACTION(ACT_LAYER_EXT, 0x1<<8 | 0xFF) -/* Layer switch with tap key */ -#define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | (key)) -#define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (bits)<<8 | (key)) -#define ACTION_LAYER_DEFAULT_SET_TAP_KEY(key) ACTION(ACT_LAYER_EXT, 0x0<<8 | (key)) -/* Layer switch with tap toggle */ -#define ACTION_LAYER_SET_ON_PRESSED_TAP_TOGGLE(layer) ACTION(ACT_LAYER_PRESSED, (layer)<<8 | 0xF0) -#define ACTION_LAYER_SET_ON_RELEASED_TAP_TOGGLE(layer) ACTION(ACT_LAYER_RELEASED, (layer)<<8 | 0xF0) -#define ACTION_LAYER_BIT_TAP_TOGGLE(layer) ACTION(ACT_LAYER_BIT, (layer)<<8 | 0xF0) -#define ACTION_LAYER_DEFAULT_TAP_TOGGLE ACTION(ACT_LAYER_EXT, 0x0<<8 | 0xF0) +#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) + + +/* + * Switch layer + */ +enum layer_codes { + LAYER_MOMENTARY = 0, + LAYER_ON_PRESS = 1, + LAYER_ON_RELEASE = 2, + LAYER_DEFAULT =3, + LAYER_TAP_TOGGLE = 0xF0, + LAYER_CHANGE_DEFAULT = 0xFF +}; +enum layer_vals_default { + DEFAULT_ON_PRESS = 1, + DEFAULT_ON_RELEASE = 2, + DEFAULT_ON_BOTH = 3, +}; + +/* + * return to default layer + */ +#define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R +/* set default layer on press */ +#define ACTION_LAYER_DEFAULT_P ACTION(ACT_LAYER, DEFAULT_ON_PRESS<<8 | LAYER_DEFAULT) +/* set default layer on release */ +#define ACTION_LAYER_DEFAULT_R ACTION(ACT_LAYER, DEFAULT_ON_RELEASE<<8 | LAYER_DEFAULT) +/* change default layer and set layer */ + +/* + * Set layer + */ +/* set layer on press and set default on release */ +#define ACTION_LAYER_SET(layer) ACTION_LAYER_SET_MOMENTARY(layer) +#define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_MOMENTARY) +/* set layer on press and none on release */ +#define ACTION_LAYER_SET_TOGGLE(layer) ACTION_LAYER_SET_R(layer) +/* set layer while hold and send key on tap */ +#define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER, (layer)<<8 | (key)) +/* set layer on press */ +#define ACTION_LAYER_SET_P(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_PRESS) +/* set layer on release */ +#define ACTION_LAYER_SET_R(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_RELEASE) +/* set layer on hold and toggle on several taps */ +#define ACTION_LAYER_SET_TAP_TOGGLE(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_TAP_TOGGLE) +/* set default layer on both press and release */ +#define ACTION_LAYER_SET_DEFAULT(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_CHANGE_DEFAULT) + +/* + * Bit-op layer + */ +/* bit-xor on both press and release */ +#define ACTION_LAYER_BIT(bits) ACTION_LAYER_BIT_MOMENTARY(bits) +#define ACTION_LAYER_BIT_MOMENTARY(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_MOMENTARY) +/* bit-xor on press */ +#define ACTION_LAYER_BIT_TOGGLE(bits) ACTION_LAYER_BIT_R(bits) +/* bit-xor while hold and send key on tap */ +#define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (bits)<<8 | (key)) +/* bit-xor on press */ +#define ACTION_LAYER_BIT_P(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_PRESS) +/* bit-xor on release */ +#define ACTION_LAYER_BIT_R(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_RELEASE) +/* bit-xor while hold and toggle on several taps */ +#define ACTION_LAYER_BIT_TAP_TOGGLE(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_TAP_TOGGLE) +/* bit-xor default layer and set layer */ +#define ACTION_LAYER_BIT_DEFAULT(bits) ACTION(ACT_LAYER, (bits)<<8 | LAYER_CHANGE_DEFAULT) + /* HID Usage */ -#define ACTION_USAGE_PAGE_SYSTEM 0 -#define ACTION_USAGE_PAGE_CONSUMER 1 -#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, ACTION_USAGE_PAGE_SYSTEM<<10 | (id)) -#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, ACTION_USAGE_PAGE_CONSUMER<<10 | (id)) +enum usage_pages { + PAGE_SYSTEM, + PAGE_CONSUMER +}; +#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) +#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) /* Mousekey */ #define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) @@ -303,7 +322,10 @@ enum options { #define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) /* Function */ +enum function_opts { + FUNC_TAP = 0x8, +}; #define ACTION_FUNCTION(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | id) -#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, O_TAP<<8 | id) +#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | id) #endif /* ACTION_H */ diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c index f2f21e8c..65ef89ad 100644 --- a/keyboard/hhkb/keymap.c +++ b/keyboard/hhkb/keymap.c @@ -29,8 +29,6 @@ along with this program. If not, see . #include "keymap.h" -// Convert physical keyboard layout to matrix array. -// This is a macro to define keymap easily in keyboard layout form. #define KEYMAP( \ K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \ K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \ @@ -50,6 +48,7 @@ along with this program. If not, see . } +// TODO: use [1] = KEYMAP(...) to prevent from changing index of element? static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Layer 0: Default Layer * ,-----------------------------------------------------------. @@ -57,17 +56,17 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| * |-----------------------------------------------------------| - * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | + * |Fn6 | A| S| D| F| G| H| J| K| L|Fn3| '|Return | * |-----------------------------------------------------------| - * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1| + * |Fn8 | Z| X| C| V| B| N| M| ,| .|Fn2|Fn12 |Fn1| * `-----------------------------------------------------------' - * |Gui|Alt |Fn5 |Alt |Fn4| + * |Gui|Alt | Fn5 |Alt |Fn4| * `-------------------------------------------' */ KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ FN6, A, S, D, F, G, H, J, K, L, FN3, QUOT,FN7, \ - FN8, Z, X, C, V, B, N, M, COMM,DOT, FN2, FN12,FN10, \ + FN8, Z, X, C, V, B, N, M, COMM,DOT, FN2, FN12,FN9, \ LGUI,LALT, FN5, FN13,FN4), /* Layer 1: HHKB mode (HHKB Fn) @@ -80,13 +79,13 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Shift | | | | | | +| -|End|PgD|Dow|Shift |Fn0| * `-----------------------------------------------------------' - * |Gui |Alt |Space |Alt |xxx| - * `--------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' */ KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, BSPC, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ - LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN10, \ + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN0, \ LGUI,LALT, SPC, RALT,RGUI), /* Layer 2: Vi mode (Slash) @@ -99,7 +98,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | | * `-----------------------------------------------------------' - * |Gui|Alt |Space |Alt |Gui| + * |Gui|Alt | Space |Alt |Gui| * `-------------------------------------------' */ KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ @@ -112,13 +111,13 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ,-----------------------------------------------------------. * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| * |-----------------------------------------------------------| - * |Tab |MwL|MwU|McU|MwD|MwR|MwL|MwD|MwU|MwR| | | |Backs| + * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs| * |-----------------------------------------------------------| - * |Contro| |McL|McD|McR| |McL|McD|McU|McR|Fn0| |Return | + * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return | * |-----------------------------------------------------------| - * |Shift |Mb4|Mb5|Mb1|Mb2|Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | * `-----------------------------------------------------------' - * |Gui |Alt |Mb1 |Alt |Fn0| + * |Gui |Alt | Mb1 |Alt |Fn0| * `--------------------------------------------' * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ @@ -147,10 +146,23 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \ LGUI,LALT, FN0, RALT,RGUI), - /* Layer5: another Mouse mode (Space) */ + /* Layer5: another Mouse mode (Space) + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Fn0 |Alt |Fn0| + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC, \ - LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, ENT, \ + LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,NO, NO, ENT, \ LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ LGUI,LALT, FN0, RALT,RGUI), }; @@ -164,27 +176,32 @@ enum function_id { MACRO = 0xff }; + /* * Fn action definition */ +// TODO: use [1] = KEYMAP(...) to prevent from changing index of element? static const uint16_t PROGMEM fn_actions[] = { - ACTION_LAYER_RETURN_DEFAULT, // FN0 + ACTION_LAYER_DEFAULT, // FN0 ACTION_LAYER_SET(1), // FN1 - ACTION_LAYER_SET_TAP_KEY(2, KC_SLASH), // FN2 - ACTION_LAYER_SET_TAP_KEY(3, KC_SCLN), // FN3 - //ACTION_LAYER_SET(3), // FN4 - ACTION_FUNCTION(MACRO, 0), // FN4 + ACTION_LAYER_SET_TAP_KEY(2, KC_SLASH), // FN2 Layer with Slash + ACTION_LAYER_SET_TAP_KEY(3, KC_SCLN), // FN3 Layer with Semicolon + + ACTION_LAYER_SET(3), // FN4 +// ACTION_LAYER_SET_TOGGLE(3), // FN4 +// ACTION_FUNCTION(MACRO, 0), // FN4 ACTION_LAYER_SET_TAP_KEY(5, KC_SPC), // FN5 - ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // FN6 - ACTION_RMOD_TAP_KEY(KC_RCTL, KC_ENT), // FN7 - ACTION_LMOD_ONESHOT(KC_LSFT), // FN8 Oneshot Shift - ACTION_LAYER_SET_ON_RELEASED_TAP_TOGGLE(1), // FN9 - ACTION_LAYER_BIT_TAP_KEY(1, KC_GRV), // FN10 +// ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // FN6 Control with tap Backspace + ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // FN6 Control with tap Backspace + ACTION_RMOD_TAP_KEY(KC_RCTL, KC_ENT), // FN7 Control with tap Enter + ACTION_LMOD_ONESHOT(KC_LSFT), // FN8 Oneshot Shift + ACTION_LAYER_SET_TAP_TOGGLE(1), // FN9 + ACTION_LAYER_BIT_TAP_KEY(1, KC_GRV), // FN10 Layer with Grave //ACTION_LAYER_BIT(1), // FN10 //ACTION_LAYER_BIT_TAP_TOGGLE(1), // FN10 - ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // FN11 - ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // FN12 - ACTION_FUNCTION(MACRO, 1), // FN13 + ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // FN11 Function: LShift with tap '(' + ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // FN12 Function: RShift with tap ')' + ACTION_FUNCTION(MACRO, 1), // FN13 Macro: };