diff options
Diffstat (limited to 'keyboards/mitosis/keymaps/default/keymap.c')
-rw-r--r-- | keyboards/mitosis/keymaps/default/keymap.c | 105 |
1 files changed, 44 insertions, 61 deletions
diff --git a/keyboards/mitosis/keymaps/default/keymap.c b/keyboards/mitosis/keymaps/default/keymap.c index ec440ed75..6132ad6f7 100644 --- a/keyboards/mitosis/keymaps/default/keymap.c +++ b/keyboards/mitosis/keymaps/default/keymap.c | |||
@@ -18,16 +18,10 @@ enum mitosis_layers | |||
18 | enum mitosis_keycodes | 18 | enum mitosis_keycodes |
19 | { | 19 | { |
20 | FNKEY = SAFE_RANGE, | 20 | FNKEY = SAFE_RANGE, |
21 | SHIFT | 21 | SHIFT, |
22 | }; | 22 | M_VOLU, |
23 | 23 | M_VOLD, | |
24 | 24 | M_ESCM | |
25 | // Macro definitions for readability | ||
26 | enum mitosis_macros | ||
27 | { | ||
28 | VOLU, | ||
29 | VOLD, | ||
30 | ESCM | ||
31 | }; | 25 | }; |
32 | 26 | ||
33 | #define LONGPRESS_DELAY 150 | 27 | #define LONGPRESS_DELAY 150 |
@@ -39,8 +33,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
39 | KC_Q, KC_P, KC_Y, KC_C, KC_B, KC_V, KC_M, KC_U, KC_Z, KC_L, | 33 | KC_Q, KC_P, KC_Y, KC_C, KC_B, KC_V, KC_M, KC_U, KC_Z, KC_L, |
40 | KC_A, KC_N, KC_I, KC_S, KC_F, KC_D, KC_T, KC_H, KC_O, KC_R, | 34 | KC_A, KC_N, KC_I, KC_S, KC_F, KC_D, KC_T, KC_H, KC_O, KC_R, |
41 | KC_COMM, KC_DOT, KC_J, KC_G, KC_SLSH, KC_SCLN, KC_W, KC_K, KC_QUOT, KC_X, | 35 | KC_COMM, KC_DOT, KC_J, KC_G, KC_SLSH, KC_SCLN, KC_W, KC_K, KC_QUOT, KC_X, |
42 | M(VOLU), M(ESCM), KC_TAB, KC_LCTL, KC_LALT, KC_ENT, KC_DEL, KC_PGUP, | 36 | M_VOLU, M_ESCM, KC_TAB, KC_LCTL, KC_LALT, KC_ENT, KC_DEL, KC_PGUP, |
43 | M(VOLD), KC_LGUI, KC_E, FNKEY, SHIFT, KC_SPC, KC_BSPC, KC_PGDN | 37 | M_VOLD, KC_LGUI, KC_E, FNKEY, SHIFT, KC_SPC, KC_BSPC, KC_PGDN |
44 | ), | 38 | ), |
45 | 39 | ||
46 | 40 | ||
@@ -78,55 +72,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
78 | 72 | ||
79 | static uint16_t key_timer; | 73 | static uint16_t key_timer; |
80 | 74 | ||
81 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
82 | { | ||
83 | // MACRODOWN only works in this function | ||
84 | switch(id) { | ||
85 | |||
86 | //switch multiplexing for media, short tap for volume up, long press for play/pause | ||
87 | case VOLU: | ||
88 | if (record->event.pressed) { | ||
89 | key_timer = timer_read(); // if the key is being pressed, we start the timer. | ||
90 | } else { // this means the key was just released, so we can figure out how long it was pressed for (tap or "held down"). | ||
91 | if (timer_elapsed(key_timer) > LONGPRESS_DELAY) { // LONGPRESS_DELAY being 150ms, the threshhold we pick for counting something as a tap. | ||
92 | return MACRO(T(MPLY), END); | ||
93 | } else { | ||
94 | return MACRO(T(VOLU), END); | ||
95 | } | ||
96 | } | ||
97 | break; | ||
98 | |||
99 | //switch multiplexing for media, short tap for volume down, long press for next track | ||
100 | case VOLD: | ||
101 | if (record->event.pressed) { | ||
102 | key_timer = timer_read(); | ||
103 | } else { | ||
104 | if (timer_elapsed(key_timer) > LONGPRESS_DELAY) { | ||
105 | return MACRO(T(MNXT), END); | ||
106 | } else { | ||
107 | return MACRO(T(VOLD), END); | ||
108 | } | ||
109 | } | ||
110 | break; | ||
111 | |||
112 | //switch multiplexing for escape, short tap for escape, long press for context menu | ||
113 | case ESCM: | ||
114 | if (record->event.pressed) { | ||
115 | key_timer = timer_read(); | ||
116 | } else { | ||
117 | if (timer_elapsed(key_timer) > LONGPRESS_DELAY) { | ||
118 | return MACRO(T(APP), END); | ||
119 | } else { | ||
120 | return MACRO(T(ESC), END); | ||
121 | } | ||
122 | } | ||
123 | break; | ||
124 | |||
125 | break; | ||
126 | } | ||
127 | return MACRO_NONE; | ||
128 | }; | ||
129 | |||
130 | static bool singular_key = false; | 75 | static bool singular_key = false; |
131 | 76 | ||
132 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 77 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
@@ -165,6 +110,44 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
165 | update_tri_layer(_FUNCTION, _SHIFTED, _FUNCSHIFT); | 110 | update_tri_layer(_FUNCTION, _SHIFTED, _FUNCSHIFT); |
166 | return false; | 111 | return false; |
167 | break; | 112 | break; |
113 | //switch multiplexing for media, short tap for volume up, long press for play/pause | ||
114 | case M_VOLU: | ||
115 | if (record->event.pressed) { | ||
116 | key_timer = timer_read(); // if the key is being pressed, we start the timer. | ||
117 | } else { // this means the key was just released, so we can figure out how long it was pressed for (tap or "held down"). | ||
118 | if (timer_elapsed(key_timer) > LONGPRESS_DELAY) { // LONGPRESS_DELAY being 150ms, the threshhold we pick for counting something as a tap. | ||
119 | tap_code(KC_MPLY); | ||
120 | } else { | ||
121 | tap_code(KC_VOLU); | ||
122 | } | ||
123 | } | ||
124 | return false; | ||
125 | |||
126 | //switch multiplexing for media, short tap for volume down, long press for next track | ||
127 | case M_VOLD: | ||
128 | if (record->event.pressed) { | ||
129 | key_timer = timer_read(); | ||
130 | } else { | ||
131 | if (timer_elapsed(key_timer) > LONGPRESS_DELAY) { | ||
132 | tap_code(KC_MNXT); | ||
133 | } else { | ||
134 | tap_code(KC_VOLD); | ||
135 | } | ||
136 | } | ||
137 | return false; | ||
138 | |||
139 | //switch multiplexing for escape, short tap for escape, long press for context menu | ||
140 | case M_ESCM: | ||
141 | if (record->event.pressed) { | ||
142 | key_timer = timer_read(); | ||
143 | } else { | ||
144 | if (timer_elapsed(key_timer) > LONGPRESS_DELAY) { | ||
145 | tap_code(KC_APP); | ||
146 | } else { | ||
147 | tap_code(KC_ESC); | ||
148 | } | ||
149 | } | ||
150 | return false; | ||
168 | 151 | ||
169 | //If any other key was pressed during the layer mod hold period, | 152 | //If any other key was pressed during the layer mod hold period, |
170 | //then the layer mod was used momentarily, and should block latching | 153 | //then the layer mod was used momentarily, and should block latching |