diff options
Diffstat (limited to 'keyboards/dichotomy/keymaps')
-rw-r--r-- | keyboards/dichotomy/keymaps/alairock/keymap.c | 196 | ||||
-rw-r--r-- | keyboards/dichotomy/keymaps/beat/config.h | 19 | ||||
-rw-r--r-- | keyboards/dichotomy/keymaps/beat/keymap.c | 126 | ||||
-rwxr-xr-x | keyboards/dichotomy/keymaps/default/keymap.c | 497 |
4 files changed, 838 insertions, 0 deletions
diff --git a/keyboards/dichotomy/keymaps/alairock/keymap.c b/keyboards/dichotomy/keymaps/alairock/keymap.c new file mode 100644 index 000000000..a7f9189a4 --- /dev/null +++ b/keyboards/dichotomy/keymaps/alairock/keymap.c | |||
@@ -0,0 +1,196 @@ | |||
1 | // this is the style you want to emulate. | ||
2 | // This is the canonical layout file for the Quantum project. If you want to add another keyboard, | ||
3 | |||
4 | #include QMK_KEYBOARD_H | ||
5 | |||
6 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
7 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
8 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
9 | // entirely and just use numbers. | ||
10 | #define _QWERTY 0 | ||
11 | #define _LOWER 1 | ||
12 | #define _RAISE 2 | ||
13 | #define _MOUSE 8 | ||
14 | #define _ADJUST 16 | ||
15 | |||
16 | |||
17 | enum dichotomy_keycodes | ||
18 | { | ||
19 | QWERTY = SAFE_RANGE, | ||
20 | LOWER, | ||
21 | RAISE, | ||
22 | ADJUST, | ||
23 | MOUKEY, | ||
24 | MS_BTN1, | ||
25 | MS_BTN2, | ||
26 | MS_BTN3 | ||
27 | }; | ||
28 | |||
29 | #define RED_BRIGHTNESS 3 | ||
30 | #define GREEN_BRIGHTNESS 2 | ||
31 | #define BLUE_BRIGHTNESS 2 | ||
32 | |||
33 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
34 | |||
35 | |||
36 | [_QWERTY] = LAYOUT( /* Base layout, nearly qwerty but with modifications because it's not a full keyboard. Obviously. */ | ||
37 | KC_ESCAPE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, | ||
38 | KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, | ||
39 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, MOUKEY, | ||
40 | KC_LCTL, KC_LALT, MOUKEY, KC_RGUI, KC_RALT, KC_RCTL, | ||
41 | MS_BTN3, SFT_T(KC_ESCAPE), KC_LGUI, KC_BSPC, KC_SPC, RAISE, LOWER, MS_BTN3 | ||
42 | ), | ||
43 | |||
44 | [_RAISE] = LAYOUT( /* Shifted layout, small changes (because angle brackets have been moved to thumb cluster buttons) */ | ||
45 | _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, | ||
46 | _______, _______, KC_VOLD, KC_VOLU, KC_MPLY, KC_MFFD, KC_MUTE, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______, | ||
47 | _______, _______, KC_GRV, _______, _______, KC_MRWD, _______, _______, _______, KC_BSLS, KC_QUOT, _______, | ||
48 | _______, _______, _______, _______, _______, _______, | ||
49 | _______, _______, KC_LABK, _______, _______, KC_RABK, _______, _______ | ||
50 | ), | ||
51 | |||
52 | [_LOWER] = LAYOUT( /* Number layout, basically the main function layer */ | ||
53 | _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, | ||
54 | _______, _______, KC_VOLD, KC_VOLU, KC_MPLY, KC_MFFD, KC_MUTE, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______, | ||
55 | _______, _______, KC_TILD, _______, _______, KC_MRWD, _______, _______, _______, KC_PIPE, KC_DQT, _______, | ||
56 | _______, _______, _______, _______, _______, _______, | ||
57 | _______, RAISE, _______, _______, _______, _______, _______, _______ | ||
58 | ), | ||
59 | |||
60 | [_ADJUST] = LAYOUT( /* Shifted number/function layout, for per-key control. Only active when shift is held, and number is toggled or held */ | ||
61 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, KC_PGUP, KC_UP, KC_PGDN, _______, _______, | ||
62 | KC_LGUI, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, | ||
63 | KC_LSFT, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, _______, _______, _______, _______, _______, _______, | ||
64 | _______, _______, _______, _______, _______, _______, | ||
65 | _______, _______, _______, _______, _______, _______, _______, _______ | ||
66 | ), | ||
67 | |||
68 | [_MOUSE] = LAYOUT( /* Mouse layer, including buttons for clicking. */ | ||
69 | _______, _______, _______, _______, _______, _______, KC_VOLU, KC_HOME, KC_PGUP, _______, _______, _______, | ||
70 | _______, _______, _______, _______, _______, _______, _______, MS_BTN1, MS_BTN2, _______, _______, _______, | ||
71 | _______, _______, _______, _______, _______, _______, KC_VOLD, KC_END, KC_PGDN, _______, _______, _______, | ||
72 | _______, _______, _______, _______, KC_UP, _______, | ||
73 | _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______ | ||
74 | ) | ||
75 | |||
76 | }; // end keymaps block | ||
77 | |||
78 | static bool shift_held = false; | ||
79 | static bool shift_suspended = false; | ||
80 | report_mouse_t currentReport = {}; | ||
81 | |||
82 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
83 | switch (keycode) { | ||
84 | case QWERTY: | ||
85 | if (record->event.pressed) { | ||
86 | set_single_persistent_default_layer(_QWERTY); | ||
87 | } | ||
88 | return false; | ||
89 | break; | ||
90 | case LOWER: | ||
91 | if (record->event.pressed) { | ||
92 | layer_on(_LOWER); | ||
93 | grn_led_on(); | ||
94 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
95 | } else { | ||
96 | layer_off(_LOWER); | ||
97 | grn_led_off(); | ||
98 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
99 | } | ||
100 | return false; | ||
101 | break; | ||
102 | //SHIFT is handled as LSHIFT in the general case - 'toggle' shoudl activate caps, while the layer is only active when shift is held. | ||
103 | case RAISE: | ||
104 | if (record->event.pressed) { | ||
105 | layer_on(_RAISE); | ||
106 | red_led_on(); | ||
107 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
108 | } else { | ||
109 | layer_off(_RAISE); | ||
110 | red_led_off(); | ||
111 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
112 | } | ||
113 | return false; | ||
114 | break; | ||
115 | case ADJUST: | ||
116 | if (record->event.pressed) { | ||
117 | layer_on(_ADJUST); | ||
118 | } else { | ||
119 | layer_off(_ADJUST); | ||
120 | } | ||
121 | return false; | ||
122 | break; | ||
123 | //MOUSE layer needs to be handled the same way as NUMKEY, but differently from shift | ||
124 | case MOUKEY: | ||
125 | if (record->event.pressed) { | ||
126 | layer_on(_MOUSE); | ||
127 | blu_led_on(); | ||
128 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
129 | } else { | ||
130 | layer_off(_MOUSE); | ||
131 | blu_led_off(); | ||
132 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
133 | } | ||
134 | return false; | ||
135 | break; | ||
136 | |||
137 | //mouse buttons, for 1-3, to update the mouse report: | ||
138 | case MS_BTN1: | ||
139 | currentReport = pointing_device_get_report(); | ||
140 | if (record->event.pressed) { | ||
141 | if (shift_held && shift_suspended){ | ||
142 | register_code(KC_LSFT); | ||
143 | shift_suspended = false; | ||
144 | } | ||
145 | //update mouse report here | ||
146 | currentReport.buttons |= MOUSE_BTN1; //MOUSE_BTN1 is a const defined in report.h | ||
147 | } else { | ||
148 | //update mouse report here | ||
149 | currentReport.buttons &= ~MOUSE_BTN1; | ||
150 | } | ||
151 | pointing_device_set_report(currentReport); | ||
152 | return false; | ||
153 | break; | ||
154 | case MS_BTN2: | ||
155 | currentReport = pointing_device_get_report(); | ||
156 | if (record->event.pressed) { | ||
157 | if (shift_held && shift_suspended){ | ||
158 | register_code(KC_LSFT); | ||
159 | shift_suspended = false; | ||
160 | } | ||
161 | //update mouse report here | ||
162 | currentReport.buttons |= MOUSE_BTN2; //MOUSE_BTN2 is a const defined in report.h | ||
163 | } else { | ||
164 | //update mouse report here | ||
165 | currentReport.buttons &= ~MOUSE_BTN2; | ||
166 | } | ||
167 | pointing_device_set_report(currentReport); | ||
168 | return false; | ||
169 | break; | ||
170 | case MS_BTN3: | ||
171 | currentReport = pointing_device_get_report(); | ||
172 | if (record->event.pressed) { | ||
173 | if (shift_held && shift_suspended){ | ||
174 | register_code(KC_LSFT); | ||
175 | shift_suspended = false; | ||
176 | } | ||
177 | //update mouse report here | ||
178 | currentReport.buttons |= MOUSE_BTN3; //MOUSE_BTN3 is a const defined in report.h | ||
179 | } else { | ||
180 | //update mouse report here | ||
181 | currentReport.buttons &= ~MOUSE_BTN3; | ||
182 | } | ||
183 | pointing_device_set_report(currentReport); | ||
184 | return false; | ||
185 | break; | ||
186 | //Additionally, if NS_ keys are in use, then shift may be held (but is | ||
187 | //disabled for the unshifted keycodes to be send. Check the bool and | ||
188 | //register shift as necessary. | ||
189 | // default: | ||
190 | // if (shift_held){ | ||
191 | // register_code(KC_LSFT); | ||
192 | // } | ||
193 | // break; | ||
194 | } | ||
195 | return true; | ||
196 | }; | ||
diff --git a/keyboards/dichotomy/keymaps/beat/config.h b/keyboards/dichotomy/keymaps/beat/config.h new file mode 100644 index 000000000..f31e7469f --- /dev/null +++ b/keyboards/dichotomy/keymaps/beat/config.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * This program is free software: you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation, either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
14 | */ | ||
15 | |||
16 | #pragma once | ||
17 | |||
18 | #define TAPPING_TERM 200 | ||
19 | #define TAPPING_TOGGLE 2 | ||
diff --git a/keyboards/dichotomy/keymaps/beat/keymap.c b/keyboards/dichotomy/keymaps/beat/keymap.c new file mode 100644 index 000000000..c686d77d6 --- /dev/null +++ b/keyboards/dichotomy/keymaps/beat/keymap.c | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | * This program is free software: you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation, either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
14 | */ | ||
15 | |||
16 | #include QMK_KEYBOARD_H | ||
17 | |||
18 | enum layer_names { | ||
19 | _QWERTY, | ||
20 | _LOWER, | ||
21 | _RAISE, | ||
22 | _MOUSE, | ||
23 | _ADJUST | ||
24 | }; | ||
25 | |||
26 | enum dichotomy_keycodes { | ||
27 | MS_BTN1 = SAFE_RANGE, | ||
28 | MS_BTN2, | ||
29 | MS_BTN3 | ||
30 | }; | ||
31 | |||
32 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
33 | |||
34 | [_QWERTY] = LAYOUT( /* Base layout, nearly qwerty but with modifications because it's not a full keyboard. Obviously. */ | ||
35 | KC_ESCAPE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, | ||
36 | KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, | ||
37 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, TT(_MOUSE), | ||
38 | KC_LGUI, KC_LALT, KC_DEL, KC_RCTL, KC_RALT, KC_RGUI, | ||
39 | MS_BTN3, SFT_T(KC_ESCAPE), KC_LCTL, KC_SPC, KC_SPC, TT(_RAISE), TT(_LOWER), MS_BTN3 | ||
40 | ), | ||
41 | |||
42 | [_RAISE] = LAYOUT( /* Shifted layout, small changes (because angle brackets have been moved to thumb cluster buttons) */ | ||
43 | _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, | ||
44 | _______, _______, KC_VOLD, KC_VOLU, KC_MPLY, KC_MNXT, KC_MUTE, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______, | ||
45 | _______, _______, KC_GRV, _______, _______, KC_MPRV, _______, KC_LABK, KC_RABK, KC_BSLS, KC_QUOT, _______, | ||
46 | _______, _______, _______, _______, _______, _______, | ||
47 | _______, _______, _______, _______, _______, _______, _______, _______ | ||
48 | ), | ||
49 | |||
50 | [_LOWER] = LAYOUT( /* Number layout, basically the main function layer */ | ||
51 | _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, | ||
52 | _______, _______, KC_VOLD, KC_VOLU, KC_MPLY, KC_MNXT, KC_MUTE, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______, | ||
53 | _______, _______, KC_TILD, _______, _______, KC_MPRV, _______, _______, _______, KC_PIPE, KC_DQT, _______, | ||
54 | _______, _______, _______, _______, _______, _______, | ||
55 | _______, _______, _______, _______, _______, _______, _______, _______ | ||
56 | ), | ||
57 | |||
58 | [_ADJUST] = LAYOUT( /* Shifted number/function layout, for per-key control. Only active when shift is held, and number is toggled or held */ | ||
59 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_PSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, _______, | ||
60 | KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PAST, KC_P4, KC_P5, KC_P6, KC_PPLS, _______, | ||
61 | _______, _______, _______, LGUI(KC_L), KC_PSCR, KC_APP, KC_PCMM, KC_P1, KC_P2, KC_P3, KC_PEQL, _______, | ||
62 | _______, _______, _______, _______, KC_P0, KC_PDOT, | ||
63 | _______, _______, _______, _______, _______, _______, _______, _______ | ||
64 | ), | ||
65 | |||
66 | [_MOUSE] = LAYOUT( /* Mouse layer, including buttons for clicking. */ | ||
67 | _______, _______, _______, _______, _______, _______, KC_VOLU, KC_HOME, KC_WH_U, KC_PGUP, _______, _______, | ||
68 | _______, _______, MS_BTN2, MS_BTN3, MS_BTN1, _______, KC_VOLD, MS_BTN1, MS_BTN3, MS_BTN2, _______, _______, | ||
69 | _______, _______, _______, _______, _______, _______, KC_HOME, KC_END, KC_WH_D, KC_PGDN, _______, _______, | ||
70 | _______, KC_UP, _______, _______, KC_UP, _______, | ||
71 | _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_LEFT, KC_DOWN, KC_RGHT, _______ | ||
72 | ) | ||
73 | }; | ||
74 | |||
75 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
76 | red_led(layer_state_cmp(state, _LOWER)); | ||
77 | grn_led(layer_state_cmp(state, _RAISE)); | ||
78 | blu_led(layer_state_cmp(state, _MOUSE)); | ||
79 | return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); | ||
80 | } | ||
81 | |||
82 | #define SetBitMask(variable, mask, on) if (on) variable |= mask; else variable &= ~mask | ||
83 | |||
84 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
85 | report_mouse_t currentReport; | ||
86 | switch (keycode) { | ||
87 | //mouse buttons, for 1-3, to update the mouse report: | ||
88 | //MOUSE_BTN1-3 are consts defined in report.h | ||
89 | case MS_BTN1: | ||
90 | currentReport = pointing_device_get_report(); | ||
91 | SetBitMask(currentReport.buttons, MOUSE_BTN1, record->event.pressed); | ||
92 | pointing_device_set_report(currentReport); | ||
93 | return false; | ||
94 | case MS_BTN2: | ||
95 | currentReport = pointing_device_get_report(); | ||
96 | SetBitMask(currentReport.buttons, MOUSE_BTN2, record->event.pressed); | ||
97 | pointing_device_set_report(currentReport); | ||
98 | return false; | ||
99 | case MS_BTN3: | ||
100 | currentReport = pointing_device_get_report(); | ||
101 | SetBitMask(currentReport.buttons, MOUSE_BTN3, record->event.pressed); | ||
102 | pointing_device_set_report(currentReport); | ||
103 | return false; | ||
104 | case KC_WH_U: | ||
105 | currentReport = pointing_device_get_report(); | ||
106 | if(record->event.pressed) { | ||
107 | currentReport.v += 1; | ||
108 | } | ||
109 | else { | ||
110 | currentReport.v = 0; | ||
111 | } | ||
112 | pointing_device_set_report(currentReport); | ||
113 | return false; | ||
114 | case KC_WH_D: | ||
115 | currentReport = pointing_device_get_report(); | ||
116 | if(record->event.pressed) { | ||
117 | currentReport.v -= 1; | ||
118 | } | ||
119 | else { | ||
120 | currentReport.v = 0; | ||
121 | } | ||
122 | pointing_device_set_report(currentReport); | ||
123 | return false; | ||
124 | } | ||
125 | return true; | ||
126 | } | ||
diff --git a/keyboards/dichotomy/keymaps/default/keymap.c b/keyboards/dichotomy/keymaps/default/keymap.c new file mode 100755 index 000000000..b8c7ef427 --- /dev/null +++ b/keyboards/dichotomy/keymaps/default/keymap.c | |||
@@ -0,0 +1,497 @@ | |||
1 | // this is the style you want to emulate. | ||
2 | // This is the canonical layout file for the Quantum project. If you want to add another keyboard, | ||
3 | |||
4 | #include QMK_KEYBOARD_H | ||
5 | |||
6 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
7 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
8 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
9 | // entirely and just use numbers. | ||
10 | enum dichotomy_layers { | ||
11 | _BS, | ||
12 | _SF, | ||
13 | _NM, | ||
14 | _NS, | ||
15 | _MS | ||
16 | }; | ||
17 | |||
18 | #define LONGPRESS_COUNT 4 | ||
19 | |||
20 | enum dichotomy_keycodes | ||
21 | { | ||
22 | CK_1G = SAFE_RANGE, | ||
23 | CK_BSPE, | ||
24 | CK_QE, | ||
25 | CK_TE, //these 4 CK_XXXX keys are special "alternate long-press" keys controlled with unique timers. Make sure you understand them before you mess with them. | ||
26 | NS_HYPH, | ||
27 | NS_EQU, | ||
28 | NUMKEY, | ||
29 | SFTKEY, | ||
30 | MOUKEY, | ||
31 | MS_BTN1, | ||
32 | MS_BTN2, | ||
33 | MS_BTN3 | ||
34 | }; | ||
35 | |||
36 | #define CUSTOM_LONGPRESS 150 | ||
37 | #define CUSTOM_TOGGLE_TIME 300 | ||
38 | |||
39 | #define RED_BRIGHTNESS 3 | ||
40 | #define GREEN_BRIGHTNESS 2 | ||
41 | #define BLUE_BRIGHTNESS 2 | ||
42 | |||
43 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
44 | [_BS] = LAYOUT( /* Base layout, nearly qwerty but with modifications because it's not a full keyboard. Obviously. */ | ||
45 | CK_TE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, | ||
46 | NUMKEY, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, CK_QE, | ||
47 | SFTKEY, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, MOUKEY, | ||
48 | KC_LCTL, KC_LALT, KC_LGUI, KC_RGUI, KC_RALT, KC_RCTL, | ||
49 | MS_BTN3, KC_LBRC, KC_LPRN, KC_SPC, KC_SPC, KC_RPRN, KC_RBRC, MS_BTN3 | ||
50 | ), | ||
51 | |||
52 | [_SF] = LAYOUT( /* Shifted layout, small changes (because angle brackets have been moved to thumb cluster buttons) */ | ||
53 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
54 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
55 | _______, _______, _______, _______, _______, _______, _______, _______, NS_HYPH, KC_UNDS, _______, _______, | ||
56 | _______, _______, _______, _______, _______, _______, | ||
57 | _______, _______, KC_LABK, _______, _______, KC_RABK, _______, _______ | ||
58 | ), | ||
59 | |||
60 | [_NM] = LAYOUT( /* Number layout, basically the main function layer */ | ||
61 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, | ||
62 | _______, CK_1G, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, CK_BSPE, | ||
63 | _______, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, _______, | ||
64 | _______, _______, _______, _______, _______, _______, | ||
65 | _______, _______, _______, _______, _______, _______, _______, _______ | ||
66 | ), | ||
67 | |||
68 | [_NS] = LAYOUT( /* Shifted number/function layout, for per-key control. Only active when shift is held, and number is toggled or held */ | ||
69 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
70 | _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PLUS, NS_EQU, _______, | ||
71 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
72 | _______, _______, _______, _______, _______, _______, | ||
73 | _______, _______, _______, _______, _______, _______, _______, _______ | ||
74 | ), | ||
75 | |||
76 | [_MS] = LAYOUT( /* Mouse layer, including buttons for clicking. */ | ||
77 | _______, _______, _______, _______, _______, _______, KC_VOLU, KC_HOME, KC_PGUP, _______, _______, _______, | ||
78 | _______, _______, _______, _______, _______, _______, _______, MS_BTN1, MS_BTN2, _______, _______, _______, | ||
79 | _______, _______, _______, _______, _______, _______, KC_VOLD, KC_END, KC_PGDN, _______, _______, _______, | ||
80 | _______, _______, _______, _______, KC_UP, _______, | ||
81 | _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______ | ||
82 | ) | ||
83 | |||
84 | }; | ||
85 | |||
86 | static uint16_t special_timers[LONGPRESS_COUNT] = {0xFFFF,0xFFFF,0xFFFF,0xFFFF}; | ||
87 | static bool special_key_states[LONGPRESS_COUNT] = {0,0,0,0}; | ||
88 | static bool special_key_pressed[LONGPRESS_COUNT] = {0,0,0,0}; | ||
89 | |||
90 | static uint16_t shift_timer; | ||
91 | static uint16_t num_timer; | ||
92 | static uint16_t mouse_timer; | ||
93 | |||
94 | static uint8_t red_timer; | ||
95 | static uint8_t green_timer; | ||
96 | static uint8_t blue_timer; | ||
97 | |||
98 | static bool shift_singular_key = false; | ||
99 | static bool number_singular_key = false; | ||
100 | static bool mouse_singular_key = false; | ||
101 | static bool capsLED = false; | ||
102 | static bool shiftLED = false; | ||
103 | static bool numLED = false; | ||
104 | static bool mouseLED = false; | ||
105 | |||
106 | static bool shift_held = false; | ||
107 | static bool shift_suspended = false; | ||
108 | report_mouse_t currentReport = {}; | ||
109 | |||
110 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
111 | //uint8_t layer; | ||
112 | //layer = biton32(layer_state); // get the current layer //Or don't, I didn't use it. | ||
113 | bool returnVal = true; //this is to determine if more key processing is needed. | ||
114 | |||
115 | //custom layer handling for tri_layer, | ||
116 | switch (keycode) { | ||
117 | case NUMKEY: | ||
118 | if (record->event.pressed) { | ||
119 | num_timer = timer_read(); | ||
120 | number_singular_key = true; | ||
121 | layer_invert(_NM); | ||
122 | numLED = !numLED; | ||
123 | } else { | ||
124 | if (timer_elapsed(num_timer) < CUSTOM_TOGGLE_TIME && number_singular_key) { | ||
125 | //do nothing, the layer has already been inverted | ||
126 | } else { | ||
127 | layer_invert(_NM); | ||
128 | numLED = !numLED; | ||
129 | } | ||
130 | } | ||
131 | update_tri_layer(_NM, _SF, _NS); | ||
132 | returnVal = false; | ||
133 | break; | ||
134 | //SHIFT is handled as LSHIFT in the general case - 'toggle' shoudl activate caps, while the layer is only active when shift is held. | ||
135 | case SFTKEY: | ||
136 | if (record->event.pressed) { | ||
137 | shift_held = true; | ||
138 | shiftLED = true; | ||
139 | shift_suspended = false; | ||
140 | shift_timer = timer_read(); | ||
141 | shift_singular_key = true; | ||
142 | layer_on(_SF); | ||
143 | register_code(KC_LSFT); | ||
144 | } else { | ||
145 | shift_held = false; | ||
146 | shiftLED = false; | ||
147 | if (timer_elapsed(shift_timer) < CUSTOM_TOGGLE_TIME && shift_singular_key) { | ||
148 | //this was basically a toggle, so activate/deactivate caps lock. | ||
149 | SEND_STRING(SS_TAP(X_CAPSLOCK)); | ||
150 | capsLED = !capsLED; | ||
151 | } | ||
152 | layer_off(_SF); | ||
153 | unregister_code(KC_LSFT); | ||
154 | } | ||
155 | update_tri_layer(_NM, _SF, _NS); | ||
156 | returnVal = false; | ||
157 | break; | ||
158 | //MOUSE layer needs to be handled the same way as NUMKEY, but differently from shift | ||
159 | case MOUKEY: | ||
160 | if (record->event.pressed) { | ||
161 | mouse_timer = timer_read(); | ||
162 | mouse_singular_key = true; | ||
163 | layer_invert(_MS); | ||
164 | mouseLED = !mouseLED; | ||
165 | } else { | ||
166 | if (timer_elapsed(mouse_timer) < CUSTOM_TOGGLE_TIME && mouse_singular_key){ | ||
167 | //do nothing, it was a toggle (and it's already been toggled) | ||
168 | } else { | ||
169 | layer_invert(_MS); | ||
170 | mouseLED = !mouseLED; | ||
171 | } | ||
172 | } | ||
173 | returnVal = false; | ||
174 | break; | ||
175 | //Custom macros for strange keys with different long-tap behavior | ||
176 | case CK_1G: | ||
177 | if (shift_held && shift_suspended){ | ||
178 | register_code(KC_LSFT); | ||
179 | shift_suspended = false; | ||
180 | } | ||
181 | if (record->event.pressed) { | ||
182 | special_timers[CK_1G-SAFE_RANGE] = timer_read(); | ||
183 | special_key_pressed[CK_1G-SAFE_RANGE] = 1; | ||
184 | } else { | ||
185 | if (special_key_states[CK_1G-SAFE_RANGE]){ | ||
186 | //key was activated after custom_longpress, need to close those keycodes | ||
187 | special_key_states[CK_1G-SAFE_RANGE] = 0; | ||
188 | unregister_code(KC_GRAVE); | ||
189 | } else { | ||
190 | if (special_key_pressed[CK_1G-SAFE_RANGE]){ | ||
191 | //key was not activated, return macro activating proper, pre-long-tap key | ||
192 | SEND_STRING(SS_TAP(X_1)); | ||
193 | special_key_pressed[CK_1G-SAFE_RANGE] = 0; | ||
194 | } else { | ||
195 | //the short key was already sent, because another key was pressed. | ||
196 | //Do nothing. | ||
197 | } | ||
198 | |||
199 | } | ||
200 | } | ||
201 | returnVal = false; | ||
202 | break; | ||
203 | case CK_BSPE: | ||
204 | if (shift_held && shift_suspended){ | ||
205 | register_code(KC_LSFT); | ||
206 | shift_suspended = false; | ||
207 | } | ||
208 | if (record->event.pressed) { | ||
209 | special_timers[CK_BSPE-SAFE_RANGE] = timer_read(); | ||
210 | special_key_pressed[CK_BSPE-SAFE_RANGE] = 1; | ||
211 | } else { | ||
212 | if (special_key_states[CK_BSPE-SAFE_RANGE]){ | ||
213 | //key was activated after custom_longpress, need to close those keycodes | ||
214 | special_key_states[CK_BSPE-SAFE_RANGE] = 0; | ||
215 | unregister_code(KC_ENTER); | ||
216 | } else { | ||
217 | if (special_key_pressed[CK_BSPE-SAFE_RANGE]){ | ||
218 | //key was not activated, return macro activating proper, pre-long-tap key | ||
219 | SEND_STRING(SS_TAP(X_BSLASH)); | ||
220 | special_key_pressed[CK_BSPE-SAFE_RANGE] = 0; | ||
221 | } else { | ||
222 | //the short key was already sent, because another key was pressed. | ||
223 | //Do nothing. | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | returnVal = false; | ||
228 | break; | ||
229 | case CK_QE: | ||
230 | if (shift_held && shift_suspended){ | ||
231 | register_code(KC_LSFT); | ||
232 | shift_suspended = false; | ||
233 | } | ||
234 | if (record->event.pressed) { | ||
235 | special_timers[CK_QE-SAFE_RANGE] = timer_read(); | ||
236 | special_key_pressed[CK_QE-SAFE_RANGE] = 1; | ||
237 | } else { | ||
238 | if (special_key_states[CK_QE-SAFE_RANGE]){ | ||
239 | //key was activated after custom_longpress, need to close those keycodes | ||
240 | special_key_states[CK_QE-SAFE_RANGE] = 0; | ||
241 | unregister_code(KC_ENTER); | ||
242 | } else { | ||
243 | if (special_key_pressed[CK_QE-SAFE_RANGE]){ | ||
244 | //the long-press key was not activated, return macro activating proper, pre-long-tap key | ||
245 | SEND_STRING(SS_TAP(X_QUOTE)); | ||
246 | special_key_pressed[CK_QE-SAFE_RANGE] = 0; | ||
247 | } else { | ||
248 | //the short key was already sent, because another key was pressed. | ||
249 | //Do nothing. | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | returnVal = false; | ||
254 | break; | ||
255 | case CK_TE: | ||
256 | if (shift_held && shift_suspended){ | ||
257 | register_code(KC_LSFT); | ||
258 | shift_suspended = false; | ||
259 | } | ||
260 | if (record->event.pressed) { | ||
261 | special_timers[CK_TE-SAFE_RANGE] = timer_read(); | ||
262 | special_key_pressed[CK_TE-SAFE_RANGE] = 1; | ||
263 | } else { | ||
264 | if (special_key_states[CK_TE-SAFE_RANGE]){ | ||
265 | //key was activated after custom_longpress, need to close those keycodes | ||
266 | special_key_states[CK_TE-SAFE_RANGE] = 0; | ||
267 | unregister_code(KC_ESCAPE); | ||
268 | } else { | ||
269 | if (special_key_pressed[CK_TE-SAFE_RANGE]){ | ||
270 | //the long-press key was not activated, return macro activating proper, pre-long-tap key | ||
271 | SEND_STRING(SS_TAP(X_TAB)); | ||
272 | special_key_pressed[CK_TE-SAFE_RANGE] = 0; | ||
273 | } else { | ||
274 | //the short key was already sent, because another key was pressed. | ||
275 | //Do nothing. | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | returnVal = false; | ||
280 | break; | ||
281 | //No-shift keys, they unregister the KC_LSFT code so they can send | ||
282 | //unshifted values - but they don't change the bool. if any other | ||
283 | //key is pressed and the bool is set, KC_LSFT is registered again. | ||
284 | case NS_HYPH: | ||
285 | if (record->event.pressed) { | ||
286 | shift_suspended = true; | ||
287 | unregister_code(KC_LSFT); | ||
288 | register_code(KC_MINS); | ||
289 | } else { | ||
290 | unregister_code(KC_MINS); | ||
291 | if (shift_held && shift_suspended){ | ||
292 | register_code(KC_LSFT); | ||
293 | shift_suspended = false; | ||
294 | } | ||
295 | } | ||
296 | returnVal = false; | ||
297 | break; | ||
298 | case NS_EQU: | ||
299 | if (record->event.pressed) { | ||
300 | shift_suspended = true; | ||
301 | unregister_code(KC_LSFT); | ||
302 | register_code(KC_EQUAL); | ||
303 | } else { | ||
304 | unregister_code(KC_EQUAL); | ||
305 | if (shift_held && shift_suspended){ | ||
306 | register_code(KC_LSFT); | ||
307 | shift_suspended = false; | ||
308 | } | ||
309 | } | ||
310 | returnVal = false; | ||
311 | break; | ||
312 | |||
313 | //mouse buttons, for 1-3, to update the mouse report: | ||
314 | case MS_BTN1: | ||
315 | currentReport = pointing_device_get_report(); | ||
316 | if (record->event.pressed) { | ||
317 | if (shift_held && shift_suspended){ | ||
318 | register_code(KC_LSFT); | ||
319 | shift_suspended = false; | ||
320 | } | ||
321 | //update mouse report here | ||
322 | currentReport.buttons |= MOUSE_BTN1; //MOUSE_BTN1 is a const defined in report.h | ||
323 | } else { | ||
324 | //update mouse report here | ||
325 | currentReport.buttons &= ~MOUSE_BTN1; | ||
326 | } | ||
327 | pointing_device_set_report(currentReport); | ||
328 | returnVal = false; | ||
329 | break; | ||
330 | case MS_BTN2: | ||
331 | currentReport = pointing_device_get_report(); | ||
332 | if (record->event.pressed) { | ||
333 | if (shift_held && shift_suspended){ | ||
334 | register_code(KC_LSFT); | ||
335 | shift_suspended = false; | ||
336 | } | ||
337 | //update mouse report here | ||
338 | currentReport.buttons |= MOUSE_BTN2; //MOUSE_BTN2 is a const defined in report.h | ||
339 | } else { | ||
340 | //update mouse report here | ||
341 | currentReport.buttons &= ~MOUSE_BTN2; | ||
342 | } | ||
343 | pointing_device_set_report(currentReport); | ||
344 | returnVal = false; | ||
345 | break; | ||
346 | case MS_BTN3: | ||
347 | currentReport = pointing_device_get_report(); | ||
348 | if (record->event.pressed) { | ||
349 | if (shift_held && shift_suspended){ | ||
350 | register_code(KC_LSFT); | ||
351 | shift_suspended = false; | ||
352 | } | ||
353 | //update mouse report here | ||
354 | currentReport.buttons |= MOUSE_BTN3; //MOUSE_BTN3 is a const defined in report.h | ||
355 | } else { | ||
356 | //update mouse report here | ||
357 | currentReport.buttons &= ~MOUSE_BTN3; | ||
358 | } | ||
359 | pointing_device_set_report(currentReport); | ||
360 | returnVal = false; | ||
361 | break; | ||
362 | //Additionally, if NS_ keys are in use, then shift may be held (but is | ||
363 | //disabled for the unshifted keycodes to be send. Check the bool and | ||
364 | //register shift as necessary. | ||
365 | default: | ||
366 | if (shift_held){ | ||
367 | register_code(KC_LSFT); | ||
368 | } | ||
369 | break; | ||
370 | } | ||
371 | switch (keycode){ | ||
372 | case KC_BSPC: | ||
373 | case KC_NO: | ||
374 | case NUMKEY: | ||
375 | case SFTKEY: | ||
376 | case MOUKEY: | ||
377 | //don't want to reset single key variables | ||
378 | break; | ||
379 | default: | ||
380 | //If any other key was pressed during the layer mod hold period, | ||
381 | //then the layer mod was used momentarily, and should block latching | ||
382 | shift_singular_key = false; | ||
383 | number_singular_key = false; | ||
384 | mouse_singular_key = false; | ||
385 | break; | ||
386 | } | ||
387 | switch (keycode){ | ||
388 | case KC_BSPC: | ||
389 | case KC_NO: | ||
390 | case NUMKEY: | ||
391 | case SFTKEY: | ||
392 | case MOUKEY: | ||
393 | case MOUSE_BTN1: | ||
394 | case MOUSE_BTN2: | ||
395 | case MOUSE_BTN3: | ||
396 | case KC_LCTL: | ||
397 | case KC_LALT: | ||
398 | case KC_LGUI: | ||
399 | case KC_RCTL: | ||
400 | case KC_RALT: | ||
401 | case KC_RGUI: | ||
402 | case CK_1G: | ||
403 | case CK_BSPE: | ||
404 | case CK_QE: | ||
405 | case CK_TE: | ||
406 | //Do nothing, don't want to trigger the timer key rollover | ||
407 | break; | ||
408 | default: | ||
409 | //Now we're checking to see if any of the special timer keys are pressed | ||
410 | //if so, we need to activate their short-press features | ||
411 | if (record->event.pressed) { | ||
412 | for (uint8_t i = 0; i<LONGPRESS_COUNT; i++){ | ||
413 | if ((!special_key_states[i]) && special_key_pressed[i]){ | ||
414 | switch (i + SAFE_RANGE){ | ||
415 | case CK_1G: | ||
416 | SEND_STRING(SS_TAP(X_1)); | ||
417 | break; | ||
418 | case CK_BSPE: | ||
419 | SEND_STRING(SS_TAP(X_BSLASH)); | ||
420 | break; | ||
421 | case CK_QE: | ||
422 | SEND_STRING(SS_TAP(X_QUOTE)); | ||
423 | break; | ||
424 | case CK_TE: | ||
425 | SEND_STRING(SS_TAP(X_TAB)); | ||
426 | break; | ||
427 | } | ||
428 | special_key_pressed[i] = 0; | ||
429 | } | ||
430 | } | ||
431 | } else { | ||
432 | //do nothing, we don't want to trigger short presses on key releases. | ||
433 | } | ||
434 | break; | ||
435 | } | ||
436 | return returnVal; | ||
437 | }; | ||
438 | |||
439 | void matrix_scan_user(void) { | ||
440 | //uint8_t layer = biton32(layer_state); | ||
441 | for (uint8_t i = 0; i<LONGPRESS_COUNT; i++){ | ||
442 | if ((timer_elapsed(special_timers[i]) >= CUSTOM_LONGPRESS) && (!special_key_states[i]) && special_key_pressed[i]){ | ||
443 | switch (i + SAFE_RANGE){ | ||
444 | case CK_1G: | ||
445 | register_code(KC_GRAVE); | ||
446 | break; | ||
447 | case CK_BSPE: | ||
448 | register_code(KC_ENTER); | ||
449 | break; | ||
450 | case CK_QE: | ||
451 | register_code(KC_ENTER); | ||
452 | break; | ||
453 | case CK_TE: | ||
454 | register_code(KC_ESCAPE); | ||
455 | break; | ||
456 | } | ||
457 | special_key_pressed[i] = 0; | ||
458 | special_key_states[i] = 1; | ||
459 | } | ||
460 | } | ||
461 | if (shiftLED || capsLED){ | ||
462 | red_timer++; | ||
463 | if (red_timer < RED_BRIGHTNESS){ | ||
464 | red_led_on(); | ||
465 | } else { | ||
466 | red_timer = 0; | ||
467 | red_led_off(); | ||
468 | } | ||
469 | } else { | ||
470 | red_timer = 0; | ||
471 | red_led_off(); | ||
472 | } | ||
473 | if (numLED){ | ||
474 | green_timer++; | ||
475 | if (green_timer < GREEN_BRIGHTNESS){ | ||
476 | grn_led_on(); | ||
477 | } else { | ||
478 | green_timer = 0; | ||
479 | grn_led_off(); | ||
480 | } | ||
481 | } else { | ||
482 | green_timer = 0; | ||
483 | grn_led_off(); | ||
484 | } | ||
485 | if (mouseLED){ | ||
486 | blue_timer++; | ||
487 | if (blue_timer < BLUE_BRIGHTNESS){ | ||
488 | blu_led_on(); | ||
489 | } else { | ||
490 | blue_timer = 0; | ||
491 | blu_led_off(); | ||
492 | } | ||
493 | } else { | ||
494 | blue_timer = 0; | ||
495 | blu_led_off(); | ||
496 | } | ||
497 | }; | ||