summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2015-03-23 00:33:54 -0400
committerJack Humbert <jack.humb@gmail.com>2015-03-23 00:33:54 -0400
commit4454ded0af219362604cda0e3f5eb6001b90dc6d (patch)
treed69716bd55f3bd9035c9d5baf8d43247f337dba0
parent9514ee8df71350076b668fddee32c1c143c65372 (diff)
macros
-rw-r--r--keyboard/planck/extended_keymap_common.c11
-rw-r--r--keyboard/planck/extended_keymap_common.h37
-rw-r--r--keyboard/planck/extended_keymap_jack.c15
3 files changed, 57 insertions, 6 deletions
diff --git a/keyboard/planck/extended_keymap_common.c b/keyboard/planck/extended_keymap_common.c
index d9f79ac041..f8fc3209fb 100644
--- a/keyboard/planck/extended_keymap_common.c
+++ b/keyboard/planck/extended_keymap_common.c
@@ -33,15 +33,19 @@ action_t action_for_key(uint8_t layer, keypos_t key)
// 16bit keycodes - important
uint16_t keycode = keymap_key_to_keycode(layer, key);
- if (keycode > 0x00FF && keycode < 0x2000) {
+ if (keycode >= 0x0100 && keycode < 0x2000) {
// Has a modifier
action_t action;
// Split it up
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF);
return action;
- } else if (keycode > 0x1FFF && keycode < 0x3000) {
+ } else if (keycode >= 0x2000 && keycode < 0x3000) {
// Is a shortcut for function layer, pull last 12bits
return keymap_func_to_action(keycode & 0xFFF);
+ } else if (keycode >= 0x3000 && keycode < 0x4000) {
+ action_t action;
+ action.code = ACTION_MACRO(keycode & 0xFF);
+ return action;
}
switch (keycode) {
@@ -173,9 +177,8 @@ action_t keymap_fn_to_action(uint16_t keycode)
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
}
-/* translates Fn keycode to action */
action_t keymap_func_to_action(uint16_t keycode)
{
// For FUNC without 8bit limit
return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
-} \ No newline at end of file
+}
diff --git a/keyboard/planck/extended_keymap_common.h b/keyboard/planck/extended_keymap_common.h
index 24c2cb848e..66712459c6 100644
--- a/keyboard/planck/extended_keymap_common.h
+++ b/keyboard/planck/extended_keymap_common.h
@@ -111,5 +111,42 @@ extern const uint16_t fn_actions[];
#define CM_DOT KC_DOT
#define CM_SLSH KC_SLSH
+// Make it easy to support these in macros
+#define KC_CM_Q CM_Q
+#define KC_CM_W CM_W
+#define KC_CM_F CM_F
+#define KC_CM_P CM_P
+#define KC_CM_G CM_G
+#define KC_CM_J CM_J
+#define KC_CM_L CM_L
+#define KC_CM_U CM_U
+#define KC_CM_Y CM_Y
+#define KC_CM_SCLN CM_SCLN
+
+#define KC_CM_A CM_A
+#define KC_CM_R CM_R
+#define KC_CM_S CM_S
+#define KC_CM_T CM_T
+#define KC_CM_D CM_D
+#define KC_CM_H CM_H
+#define KC_CM_N CM_N
+#define KC_CM_E CM_E
+#define KC_CM_I CM_I
+#define KC_CM_O CM_O
+
+#define KC_CM_Z CM_Z
+#define KC_CM_X CM_X
+#define KC_CM_C CM_C
+#define KC_CM_V CM_V
+#define KC_CM_B CM_B
+#define KC_CM_K CM_K
+#define KC_CM_M CM_M
+#define KC_CM_COMM CM_COMM
+#define KC_CM_DOT CM_DOT
+#define KC_CM_SLSH CM_SLSH
+
+#define M(kc) kc | 0x3000
+
+#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
#endif
diff --git a/keyboard/planck/extended_keymap_jack.c b/keyboard/planck/extended_keymap_jack.c
index ef1eae49f7..416ae83450 100644
--- a/keyboard/planck/extended_keymap_jack.c
+++ b/keyboard/planck/extended_keymap_jack.c
@@ -5,7 +5,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, CM_Q, CM_W, CM_F, CM_P, CM_G, CM_J, CM_L, CM_U, CM_Y, CM_SCLN, KC_BSPC},
{KC_ESC, CM_A, CM_R, CM_S, CM_T, CM_D, CM_H, CM_N, CM_E, CM_I, CM_O, KC_QUOT},
{KC_LSFT, CM_Z, CM_X, CM_C, CM_V, CM_B, CM_K, CM_M, CM_COMM, CM_DOT, CM_SLSH, KC_ENT},
- {KC_RSFT, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_NO, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+ {M(0), KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_NO, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
},
[1] = { /* Jack hard-coded colemak */
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
@@ -35,4 +35,15 @@ const uint16_t PROGMEM fn_actions[] = {
[3] = ACTION_DEFAULT_LAYER_SET(0),
[4] = ACTION_DEFAULT_LAYER_SET(1),
-}; \ No newline at end of file
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ // MACRODOWN only works in this function
+ switch(id) {
+ case 0:
+ return MACRODOWN(T(CM_T), END);
+ break;
+ }
+ return MACRO_NONE;
+};