aboutsummaryrefslogtreecommitdiff
path: root/keyboards/hub16/keymaps/macro/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/hub16/keymaps/macro/keymap.c')
-rwxr-xr-xkeyboards/hub16/keymaps/macro/keymap.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/keyboards/hub16/keymaps/macro/keymap.c b/keyboards/hub16/keymaps/macro/keymap.c
new file mode 100755
index 000000000..3bf8fa31f
--- /dev/null
+++ b/keyboards/hub16/keymaps/macro/keymap.c
@@ -0,0 +1,115 @@
1/* Copyright 2019 Josh Johnson
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18// Function key we are 'wrapping' usual key presses in
19#define KC_WRAP KC_F24
20
21// Keyboard Layers
22enum keyboard_layers{
23 _BASE = 0,
24 _CTRL
25};
26
27// Tap Dance Declarations
28void td_ctrl (qk_tap_dance_state_t *state, void *user_data);
29
30enum tap_dance { CTRL = 0, BASE = 1 };
31
32qk_tap_dance_action_t tap_dance_actions[] = {
33 // Tap once for standard key on base layer, twice to toggle to control layer
34 [CTRL] = ACTION_TAP_DANCE_FN(td_ctrl),
35 [BASE] = ACTION_TAP_DANCE_LAYER_MOVE(_______, _BASE)};
36
37const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
38 [_BASE] = LAYOUT( /* Base */
39 KC_S, KC_V,
40 KC_A, KC_B, KC_C, KC_D,
41 KC_E, KC_F, KC_G, KC_H,
42 KC_I, KC_J, KC_K, KC_L,
43 KC_M, KC_N, KC_O, TD(CTRL)
44 ),
45
46 [_CTRL] = LAYOUT( /* Control */
47 KC_NO, KC_NO,
48 _______, RGB_MOD, RGB_RMOD, RGB_TOG,
49 RGB_VAD, RGB_VAI, RGB_HUD, RGB_HUI,
50 RGB_SAD, RGB_SAI, _______, _______,
51 _______, _______, RESET, TD(BASE)
52 ),
53};
54
55// Keyboard is setup to 'wrap' the pressed key with an unused Fxx key,
56// allowing for easy differentiation from a real keyboard.
57void encoder_update_user(uint8_t index, bool clockwise) {
58 if (index == 0) { /* Left Encoder */
59 if (clockwise) {
60 register_code(KC_WRAP);
61 tap_code(KC_R);
62 unregister_code(KC_WRAP);
63 } else {
64 register_code(KC_WRAP);
65 tap_code(KC_Q);
66 unregister_code(KC_WRAP);
67 }
68 } else if (index == 1) { /* Right Encoder */
69 if (clockwise) {
70 register_code(KC_WRAP);
71 tap_code(KC_U);
72 unregister_code(KC_WRAP);
73 } else {
74 register_code(KC_WRAP);
75 tap_code(KC_T);
76 unregister_code(KC_WRAP);
77 }
78 }
79}
80
81// Below stolen from TaranVH (https://github.com/TaranVH/2nd-keyboard/blob/master/HASU_USB/F24/keymap.c)
82// Shoutout to drashna on the QMK discord for basically writing this for me.... :P
83bool process_record_user(uint16_t keycode, keyrecord_t *record) {
84 static uint8_t f24_tracker;
85 switch (keycode) {
86 case KC_A ... KC_F23:
87 case KC_EXECUTE ... KC_EXSEL:
88 if (record->event.pressed) {
89 register_code(KC_WRAP);
90 f24_tracker++;
91 register_code(keycode);
92 } else {
93 unregister_code(keycode);
94 f24_tracker--;
95 if (!f24_tracker) {
96 unregister_code(KC_WRAP);
97 }
98 }
99 return false;
100 break;
101 }
102 return true;
103}
104
105// Below works around TD() not running key press through process_record_user.
106// Fixes bug of CTRL layer move key not being wrapped in by modifier on single tap
107void td_ctrl (qk_tap_dance_state_t *state, void *user_data) {
108 if (state->count == 1) {
109 register_code(KC_WRAP);
110 tap_code(KC_P);
111 unregister_code(KC_WRAP);
112 } else if (state->count == 2) {
113 layer_move(_CTRL);
114 }
115}