X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;ds=sidebyside;f=keyboard%2Fgh60%2Fkeymap.c;h=1f5344d4c641fda0dd43f5018250663b764e20b3;hb=81d2753ab07890532ea8c4bd6a68de3e5e08ca33;hp=9438782f2e0d1cda8bc36d129bb7205fd65f4726;hpb=0c1d98bd3c0b0ea4f109d2515521f1fcbccf3d3f;p=max%2Ftmk_keyboard.git
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c
index 9438782f..1f5344d4 100644
--- a/keyboard/gh60/keymap.c
+++ b/keyboard/gh60/keymap.c
@@ -20,6 +20,7 @@ along with this program. If not, see .
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
+#include "layer_switch.h"
#include "report.h"
#include "host.h"
#include "print.h"
@@ -64,14 +65,16 @@ along with this program. If not, see .
#include "keymap_plain.h"
#elif defined(KEYMAP_POKER)
#include "keymap_poker.h"
-#elif defined(KEYMAP_POKER_STACK)
- #include "keymap_poker_stack.h"
+#elif defined(KEYMAP_POKER_SET)
+ #include "keymap_poker_set.h"
+#elif defined(KEYMAP_POKER_BIT)
+ #include "keymap_poker_bit.h"
#else
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* Funky
*/
- /* Layer 0: Default Layer
+ /* Keymap 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
* |-----------------------------------------------------------|
@@ -87,10 +90,32 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP_ANSI(
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
- LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT, ENT, \
- LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \
- LCTL,LGUI,LALT, SPC, RALT,FN4, FN4, FN1),
- /* Layer 1: HHKB mode
+ LCTL,A, S, D, F, G, H, J, K, L, FN2, QUOT, ENT, \
+ LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, RSFT, \
+ LCTL,LGUI,LALT, SPC, RALT,FN3, FN3, FN0),
+ /* Keymap 1: colemak */
+ KEYMAP_ANSI(
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
+ TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC,BSLS, \
+ BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, ENT, \
+ LSFT,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RSFT, \
+ LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0),
+ /* Keymap 2: dvorak */
+ KEYMAP_ANSI(
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,BSPC, \
+ TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, \
+ CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, \
+ LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, \
+ LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0),
+ /* Keymap 3: workman */
+ KEYMAP_ANSI(
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
+ TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC,BSLS, \
+ BSPC,A, S, H, T, G, Y, N, E, O, I, QUOT, ENT, \
+ LSFT,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RSFT, \
+ LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0),
+
+ /* Overlay 4: HHKB mode
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
* |-----------------------------------------------------------|
@@ -100,16 +125,16 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |-----------------------------------------------------------|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |
* |-----------------------------------------------------------|
- * |Ctrl|Gui |Alt | Space |Alt |Gui |App |Fn0 |
+ * |Ctrl|Gui |Alt | Space |Alt |Gui |App | |
* `-----------------------------------------------------------'
*/
KEYMAP_ANSI(
- PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
- CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, INS, \
- 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, \
- LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0),
- /* Layer 2: Vi mode (Slash)
+ GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
+ CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,INS, \
+ LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, \
+ LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, RSFT, \
+ LCTL,LGUI,LALT, SPC, RALT,RGUI,FN4, TRNS),
+ /* Overlay 5: Vi mode (Slash)
* ,-----------------------------------------------------------.
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
* |-----------------------------------------------------------|
@@ -117,79 +142,119 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |-----------------------------------------------------------|
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
* |-----------------------------------------------------------|
- * |Shift | | | | | |Hom|PgD|PgU|End|Fn0|Shift |
+ * |Shift | | | | | |Hom|PgD|PgU|End| |Shift |
* |-----------------------------------------------------------|
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
* `-----------------------------------------------------------'
*/
KEYMAP_ANSI(
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \
- TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \
- LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
- LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN0, RSFT, \
+ TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, TRNS,TRNS,TRNS,TRNS, \
+ LCTL,TRNS,LEFT,DOWN,RGHT,TRNS,LEFT,DOWN,UP, RGHT,TRNS,TRNS, ENT, \
+ LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGDN,PGUP,END, TRNS, RSFT, \
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL),
- /* Layer 3: Mouse mode (Semicolon/App)
+ /* Overlay 6: Mouse mode (Semicolon/App)
* ,-----------------------------------------------------------.
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
* |-----------------------------------------------------------|
* |Tab | | | | | |MwL|MwD|MwU|MwR| | | | |
* |-----------------------------------------------------------|
- * |Contro| |Ac0|Ac1|Ac1| |McL|McD|McU|McR|Fn0| |Return |
+ * |Contro| |Ac0|Ac1|Ac1| |McL|McD|McU|McR| | |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift |
* |-----------------------------------------------------------|
- * |Ctrl|Gui |Alt | Space | |Fn0 |Fn0 | |
+ * |Ctrl|Gui |Alt | Space | | | | |
* `-----------------------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
KEYMAP_ANSI(
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \
- TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \
- LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, ENT, \
- LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, \
- LCTL,LGUI,LALT, BTN1, NO, FN0, FN0, NO ),
+ TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,TRNS, \
+ LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,TRNS, ENT, \
+ LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,TRNS, RSFT, \
+ LCTL,LGUI,LALT, BTN1, TRNS,TRNS,TRNS,RCTL),
+ /* Overlay 7: Layout selector
+ * ,-----------------------------------------------------------.
+ * | Lq| Lc| Ld| Lw| | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | |Lq |Lw | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | | |Ld | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | | |Lc | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | |
+ * `-----------------------------------------------------------'
+ * Lq: set Qwerty layout
+ * Lc: set Colemak layout
+ * Ld: set Dvorak layout
+ * Lw: set Workman layout
+ */
+ KEYMAP_ANSI(
+ FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
+ TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
+ TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS),
};
+static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};
+
/*
* Fn action definition
*/
static const uint16_t PROGMEM fn_actions[] = {
- ACTION_LAYER_DEFAULT, // FN0
- ACTION_LAYER_SET(1), // FN1
- 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
+ [0] = ACTION_KEYMAP_MOMENTARY(4),
+ [1] = ACTION_KEYMAP_TAP_KEY(5, KC_SLASH),
+ [2] = ACTION_KEYMAP_TAP_KEY(6, KC_SCLN),
+ [3] = ACTION_KEYMAP_MOMENTARY(6),
+ [4] = ACTION_KEYMAP_MOMENTARY(7), // to Layout selector
+ [5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout
+ [6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout
+ [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
+ [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
};
#endif
+#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
+#define OVERLAYS_SIZE (sizeof(overlays) / sizeof(overlays[0]))
+#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
+
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{
- return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+ /* Overlay: 16-31(OVERLAY_BIT(0x10) | overlay_layer) */
+ if (layer & OVERLAY_BIT) {
+ layer &= OVERLAY_MASK;
+ if (layer < OVERLAYS_SIZE) {
+ return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]);
+ } else {
+ debug("key_to_keycode: overlay "); debug_dec(layer); debug(" is invalid.\n");
+ return KC_TRANSPARENT;
+ }
+ }
+ /* Keymap: 0-15 */
+ else {
+ if (layer < KEYMAPS_SIZE) {
+ return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+ } else {
+ // fall back to layer 0
+ debug("key_to_keycode: base "); debug_dec(layer); debug(" is invalid.\n");
+ return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
+ }
+ }
}
-/* translates Fn index to action */
+/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
action_t action;
- if (FN_INDEX(keycode) < sizeof(fn_actions) / sizeof(fn_actions[0])) {
+ if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
} else {
action.code = ACTION_NO;
}
return action;
}
-
-/* convert key to action */
-action_t action_for_key(uint8_t layer, key_t key)
-{
- uint8_t keycode = keymap_key_to_keycode(layer, key);
- switch (keycode) {
- case KC_FN0 ... KC_FN31:
- return keymap_fn_to_action(keycode);
- default:
- return keymap_keycode_to_action(keycode);
- }
-}