aboutsummaryrefslogtreecommitdiffstats
path: root/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c
diff options
context:
space:
mode:
authorGravatar Erez Zukerman <ezuk@madmimi.com>2016-04-26 05:25:31 +0300
committerGravatar Erez Zukerman <ezuk@madmimi.com>2016-04-26 05:25:31 +0300
commit6274a216f87bad7d6fe9c9a1a4328dbf444fc364 (patch)
tree4269afe2dc40216ab49d0b9808aa9fa337e2f5a9 /keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c
parentaabcfd5b4ed32b3fa069629ac14c2561a59cce34 (diff)
downloadqmk_firmware-6274a216f87bad7d6fe9c9a1a4328dbf444fc364.tar.gz
[Erez & Jack] Examples for advanced macro stuff
Diffstat (limited to 'keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c')
-rw-r--r--keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c b/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c
index 24ff1c688..18bace4eb 100644
--- a/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c
+++ b/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c
@@ -7,6 +7,9 @@
#define SYMB 1 // symbols
#define MDIA 2 // media keys
+#define LSFTO M(0) // Left shift, open parens when tapped
+#define RSFTC M(1) // Right shift, close parens when tapped
+
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
@@ -17,7 +20,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | BkSp | A | S | D | F | G |------| |------| H | Alt/J| K | L |; / L2| LGui/' |
* |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
- * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
+ * |LShift/(|Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl|RShift/)|
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
* `----------------------------------' `----------------------------------'
@@ -36,7 +39,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
- KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
+ LSFTO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT,
ALT_T(KC_APP), KC_LGUI,
KC_HOME,
@@ -45,7 +48,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_RGHT, KC_6,KC_7, KC_8, KC_9, KC_0, KC_MINS,
TG(SYMB), KC_Y,KC_U, KC_I, KC_O, KC_P, KC_BSLS,
KC_H,ALT_T(KC_J),KC_K, KC_L, LT(MDIA,KC_SCLN),GUI_T(KC_QUOT),
- MEH_T(KC_NO),KC_N,KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
+ MEH_T(KC_NO),KC_N,KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), RSFTC,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1,
KC_LALT, CTL_T(KC_ESC),
KC_PGUP,
@@ -140,17 +143,37 @@ const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
};
+static uint16_t key_timer;
+
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:
- if (record->event.pressed) {
- register_code(KC_RSFT);
- } else {
- unregister_code(KC_RSFT);
+ case 0: {
+ if (record->event.pressed) {
+ key_timer = timer_read(); // if the key is being pressed, we start the timer.
+ register_code(KC_LSFT); // we're now holding down Shift.
+ } else { // this means the key was just released, so we can figure out how long it was pressed for (tap or "held down").
+ if (timer_elapsed(key_timer) < 150) { // 150 being 150ms, the threshhold we pick for counting something as a tap.
+ register_code(KC_9); // sending 9 while Shift is held down gives us an opening paren
+ unregister_code(KC_9); // now let's let go of that key
+ }
+ unregister_code(KC_LSFT); // let's release the Shift key now.
+ }
+ break;
+ }
+ case 1: {
+ if (record->event.pressed) {
+ key_timer = timer_read(); // Now we're doing the same thing, only for the right shift/close paren key
+ register_code(KC_RSFT);
+ } else {
+ if (timer_elapsed(key_timer) < 150) {
+ register_code(KC_0);
+ unregister_code(KC_0);
+ }
+ unregister_code(KC_RSFT);
+ }
+ break;
}
- break;
}
return MACRO_NONE;
};
@@ -183,3 +206,5 @@ void matrix_scan_user(void) {
}
};
+
+