aboutsummaryrefslogtreecommitdiff
path: root/keyboards/gmmk/pro
diff options
context:
space:
mode:
authorjonavin <71780717+Jonavin@users.noreply.github.com>2021-08-19 13:45:49 -0400
committerGitHub <noreply@github.com>2021-08-19 10:45:49 -0700
commit98af5bc64e6148915cebcfdd607119b9feefe90d (patch)
tree3f7e4e4f3ce67c279a872d31ef62e89f3d0b5a73 /keyboards/gmmk/pro
parent425e1e665dc3c114fc42878f2b6a9d3225e5e6b5 (diff)
downloadqmk_firmware-98af5bc64e6148915cebcfdd607119b9feefe90d.tar.gz
qmk_firmware-98af5bc64e6148915cebcfdd607119b9feefe90d.zip
[Keymap] Add jonavin user space / common functions (#13876)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonavin <=>
Diffstat (limited to 'keyboards/gmmk/pro')
-rw-r--r--keyboards/gmmk/pro/keymaps/jonavin/keymap.c187
-rw-r--r--keyboards/gmmk/pro/keymaps/jonavin/readme.md13
-rw-r--r--keyboards/gmmk/pro/keymaps/jonavin/rules.mk5
3 files changed, 29 insertions, 176 deletions
diff --git a/keyboards/gmmk/pro/keymaps/jonavin/keymap.c b/keyboards/gmmk/pro/keymaps/jonavin/keymap.c
index 8b3744957..edca78cd1 100644
--- a/keyboards/gmmk/pro/keymaps/jonavin/keymap.c
+++ b/keyboards/gmmk/pro/keymaps/jonavin/keymap.c
@@ -17,36 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#include QMK_KEYBOARD_H 18#include QMK_KEYBOARD_H
19#include "rgb_matrix_map.h" 19#include "rgb_matrix_map.h"
20 20#include "jonavin.h"
21#define ARRAYSIZE(arr) sizeof(arr)/sizeof(arr[0])
22
23enum custom_layers {
24 _BASE,
25 _FN1,
26 _MO2,
27 _MO3,
28};
29
30enum custom_keycodes {
31 KC_00 = SAFE_RANGE,
32 KC_WINLCK, //Toggles Win key on and off
33 RGB_TOI, // Timeout idle time up
34 RGB_TOD, // Timeout idle time down
35};
36
37// Tap Dance Definitions
38enum custom_tapdance {
39 TD_LSFT_CAPSLOCK,
40};
41
42qk_tap_dance_action_t tap_dance_actions[] = {
43 // Tap once for shift, twice for Caps Lock
44 [TD_LSFT_CAPSLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
45};
46
47#define KC_LSFTCAPS TD(TD_LSFT_CAPSLOCK)
48
49bool _isWinKeyDisabled = false;
50 21
51 22
52const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 23const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@@ -63,8 +34,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
63 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_MUTE, 34 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_MUTE,
64 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, 35 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
65 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, 36 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
66 TT(_MO2), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN, 37 TT(_LOWER), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
67 KC_LSFTCAPS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, 38 KC_LSFTCAPSWIN, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
68 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1),KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT 39 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1),KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
69 ), 40 ),
70 41
@@ -77,7 +48,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
77 _______, KC_WINLCK, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI 48 _______, KC_WINLCK, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI
78 ), 49 ),
79 50
80 [_MO2] = LAYOUT( 51 [_LOWER] = LAYOUT(
81 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 52 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
82 _______, _______, _______, _______, _______, _______, _______, KC_P7, KC_P8, KC_P9, KC_P0, KC_PMNS, KC_PPLS, _______, _______, 53 _______, _______, _______, _______, _______, _______, _______, KC_P7, KC_P8, KC_P9, KC_P0, KC_PMNS, KC_PPLS, _______, _______,
83 _______, KC_HOME, KC_UP, KC_END, KC_PGUP, _______, KC_TAB, KC_P4, KC_P5, KC_P6, KC_PDOT, _______, _______, _______, KC_HOME, 54 _______, KC_HOME, KC_UP, KC_END, KC_PGUP, _______, KC_TAB, KC_P4, KC_P5, KC_P6, KC_PDOT, _______, _______, _______, KC_HOME,
@@ -86,7 +57,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
86 _______, _______, _______, KC_BSPC, _______, _______, _______, RCTL(KC_LEFT), RCTL(KC_PGDN), RCTL(KC_RIGHT) 57 _______, _______, _______, KC_BSPC, _______, _______, _______, RCTL(KC_LEFT), RCTL(KC_PGDN), RCTL(KC_RIGHT)
87 ), 58 ),
88 59
89 [_MO3] = LAYOUT( 60 [_RAISE] = LAYOUT(
90 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 61 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
91 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 62 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
92 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, 63 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
@@ -98,139 +69,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
98}; 69};
99 70
100 71
101// TIMEOUTS
102#define TIMEOUT_THRESHOLD_DEFAULT 5 // default timeout minutes
103#define TIMEOUT_THRESHOLD_MAX 140 // upper limits (2 hours and 10 minutes -- no rgb indicators above this value)
104static uint16_t timeout_timer = 0;
105static uint16_t timeout_counter = 0; //in minute intervals
106static uint16_t timeout_threshold = TIMEOUT_THRESHOLD_DEFAULT;
107
108void timeout_reset_timer(void) {
109 timeout_timer = timer_read();
110 timeout_counter = 0;
111};
112
113void timeout_update_threshold(bool increase) {
114 if (increase && timeout_threshold < TIMEOUT_THRESHOLD_MAX) timeout_threshold++;
115 if (!increase && timeout_threshold > 0) timeout_threshold--;
116};
117
118
119bool process_record_user(uint16_t keycode, keyrecord_t *record) {
120 switch (keycode) {
121 case KC_00:
122 if (record->event.pressed) {
123 // when keycode KC_00 is pressed
124 SEND_STRING("00");
125 } else {
126 // when keycode KC_00 is released
127 }
128 break;
129 case KC_WINLCK:
130 if (record->event.pressed) {
131 _isWinKeyDisabled = !_isWinKeyDisabled; //toggle status
132 if(_isWinKeyDisabled) {
133 process_magic(GUI_OFF, record);
134 } else {
135 process_magic(GUI_ON, record);
136 }
137 } else unregister_code16(keycode);
138 break;
139 case RGB_TOI:
140 if(record->event.pressed) {
141 timeout_update_threshold(true);
142 } else unregister_code16(keycode);
143 break;
144 case RGB_TOD:
145 if(record->event.pressed) {
146 timeout_update_threshold(false); //decrease timeout
147 } else unregister_code16(keycode);
148 break;
149 default:
150 if (record->event.pressed) { //reset activity timer
151 #ifdef RGB_MATRIX_ENABLE
152 rgb_matrix_enable();
153 #endif
154 timeout_reset_timer();
155 }
156 break;
157 }
158 return true;
159};
160
161void matrix_scan_user(void) {
162 if (timeout_threshold > 0) {
163 if (timer_elapsed(timeout_timer) >= 60000) { // 1 minute tick
164 timeout_counter++;
165 timeout_timer = timer_read();
166 }
167 #ifdef RGB_MATRIX_ENABLE
168 if (timeout_threshold > 0 && timeout_counter >= timeout_threshold) {
169 rgb_matrix_disable_noeeprom();
170 }
171 #endif
172 } // timeout_threshold = 0 will disable timeout
173};
174
175
176#ifdef ENCODER_ENABLE // Encoder Functionality
177 uint8_t selected_layer = 0;
178
179 bool encoder_update_user(uint8_t index, bool clockwise) {
180 if ( clockwise ) {
181 if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
182 if(selected_layer < 3) {
183 selected_layer ++;
184 layer_move(selected_layer);
185 }
186 } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up
187 unregister_mods(MOD_BIT(KC_LSFT));
188 register_code(KC_PGDN);
189 register_mods(MOD_BIT(KC_LSFT));
190 } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word
191 tap_code16(LCTL(KC_RGHT));
192 } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track
193 tap_code(KC_MEDIA_NEXT_TRACK);
194 } else {
195 switch (selected_layer) {
196 case _FN1:
197 timeout_update_threshold(true);
198 break;
199 default:
200 tap_code(KC_VOLU); // Otherwise it just changes volume
201 break;
202 }
203 }
204 } else {
205 if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) {
206 if (selected_layer > 0) {
207 selected_layer --;
208 layer_move(selected_layer);
209 }
210 } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) {
211 unregister_mods(MOD_BIT(KC_LSFT));
212 register_code(KC_PGUP);
213 register_mods(MOD_BIT(KC_LSFT));
214 } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word
215 tap_code16(LCTL(KC_LEFT));
216 } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
217 tap_code(KC_MEDIA_PREV_TRACK);
218 } else {
219 switch (selected_layer) {
220 case _FN1:
221 timeout_update_threshold(false);
222 break;
223 default:
224 tap_code(KC_VOLD);
225 break;
226 }
227 }
228 }
229
230 return true;
231 }
232#endif
233
234#ifdef RGB_MATRIX_ENABLE 72#ifdef RGB_MATRIX_ENABLE
235 // Capslock, Scroll lock and Numlock indicator on Left side lights. 73 // Capslock, Scroll lock and Numlock indicator on Left side lights.
236 void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { 74 void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
@@ -247,7 +85,7 @@ void matrix_scan_user(void) {
247 rgb_matrix_set_color(LED_L6, RGB_RED); 85 rgb_matrix_set_color(LED_L6, RGB_RED);
248 rgb_matrix_set_color(LED_L7, RGB_RED); 86 rgb_matrix_set_color(LED_L7, RGB_RED);
249 } 87 }
250 if (_isWinKeyDisabled) { 88 if (keymap_config.no_gui) {
251 rgb_matrix_set_color(LED_LWIN, RGB_RED); //light up Win key when disabled 89 rgb_matrix_set_color(LED_LWIN, RGB_RED); //light up Win key when disabled
252 } 90 }
253 switch(get_highest_layer(layer_state)){ // special handling per layer 91 switch(get_highest_layer(layer_state)){ // special handling per layer
@@ -258,6 +96,7 @@ void matrix_scan_user(void) {
258 rgb_matrix_set_color(LED_FN, RGB_RED); //FN key 96 rgb_matrix_set_color(LED_FN, RGB_RED); //FN key
259 97
260 // Add RGB Timeout Indicator -- shows 0 to 139 using F row and num row; larger numbers using 16bit code 98 // Add RGB Timeout Indicator -- shows 0 to 139 using F row and num row; larger numbers using 16bit code
99 uint16_t timeout_threshold = get_timeout_threshold();
261 if (timeout_threshold <= 10) rgb_matrix_set_color(LED_LIST_FUNCROW[timeout_threshold], RGB_RED); 100 if (timeout_threshold <= 10) rgb_matrix_set_color(LED_LIST_FUNCROW[timeout_threshold], RGB_RED);
262 else if (timeout_threshold < 140) { 101 else if (timeout_threshold < 140) {
263 rgb_matrix_set_color(LED_LIST_FUNCROW[(timeout_threshold / 10)], RGB_RED); 102 rgb_matrix_set_color(LED_LIST_FUNCROW[(timeout_threshold / 10)], RGB_RED);
@@ -268,7 +107,7 @@ void matrix_scan_user(void) {
268 rgb_matrix_set_color(LED_LIST_NUMROW[12], RGB_RED); 107 rgb_matrix_set_color(LED_LIST_NUMROW[12], RGB_RED);
269 } 108 }
270 break; 109 break;
271 case _MO2: 110 case _LOWER:
272 for (uint8_t i=0; i<ARRAYSIZE(LED_LIST_NUMPAD); i++) { 111 for (uint8_t i=0; i<ARRAYSIZE(LED_LIST_NUMPAD); i++) {
273 rgb_matrix_set_color(LED_LIST_NUMPAD[i], RGB_MAGENTA); 112 rgb_matrix_set_color(LED_LIST_NUMPAD[i], RGB_MAGENTA);
274 } 113 }
@@ -276,7 +115,7 @@ void matrix_scan_user(void) {
276 rgb_matrix_set_color(LED_R5, RGB_MAGENTA); 115 rgb_matrix_set_color(LED_R5, RGB_MAGENTA);
277 rgb_matrix_set_color(LED_R6, RGB_MAGENTA); 116 rgb_matrix_set_color(LED_R6, RGB_MAGENTA);
278 break; 117 break;
279 case _MO3: 118 case _RAISE:
280 rgb_matrix_set_color(LED_R6, RGB_GREEN); 119 rgb_matrix_set_color(LED_R6, RGB_GREEN);
281 rgb_matrix_set_color(LED_R7, RGB_GREEN); 120 rgb_matrix_set_color(LED_R7, RGB_GREEN);
282 rgb_matrix_set_color(LED_R8, RGB_GREEN); 121 rgb_matrix_set_color(LED_R8, RGB_GREEN);
@@ -296,12 +135,8 @@ void matrix_scan_user(void) {
296#endif 135#endif
297 136
298 137
299void keyboard_post_init_user(void) { 138void keyboard_post_init_keymap(void) {
300 139 // keyboard_post_init_user() moved to userspace
301 if (IS_HOST_LED_ON(USB_LED_NUM_LOCK)) { // turn on Num lock by defautl so that the numpad layer always has predictable results
302 tap_code(KC_NUMLOCK);
303 }
304 timeout_timer = timer_read(); // set inital time for ide timeout
305 #ifdef RGB_MATRIX_ENABLE 140 #ifdef RGB_MATRIX_ENABLE
306 rgb_matrix_set_color_all(RGB_NAUTILUS); // Default startup colour 141 rgb_matrix_set_color_all(RGB_NAUTILUS); // Default startup colour
307 #endif 142 #endif
diff --git a/keyboards/gmmk/pro/keymaps/jonavin/readme.md b/keyboards/gmmk/pro/keymaps/jonavin/readme.md
index f4f3401ab..dceaa1307 100644
--- a/keyboards/gmmk/pro/keymaps/jonavin/readme.md
+++ b/keyboards/gmmk/pro/keymaps/jonavin/readme.md
@@ -29,6 +29,19 @@
29 - Win Key light up red when Win Lock mode enabled 29 - Win Key light up red when Win Lock mode enabled
30 - Layer 2 activation lights up Numpad area 30 - Layer 2 activation lights up Numpad area
31 31
32rules.mk OPTIONS - Active features from userspace
33STARTUP_NUMLOCK_ON = yes
34 - turns on NUMLOCK by default
35
36ENCODER_DEFAULTACTIONS_ENABLE = yes
37 - Enabled default encoder funtions
38
39TD_LSFT_CAPSLOCK_ENABLE = yes
40 - This will enable double tap on Left Shift to toggle CAPSLOCK when using KC_LSFTCAPS
41
42IDLE_TIMEOUT_ENABLE = yes
43 - Enables Timer functionality; for RGB idle timeouts that can be changed dynamically
44
32## All layers diagram 45## All layers diagram
33Default layer 46Default layer
34![image](https://user-images.githubusercontent.com/71780717/124177658-82324880-da7e-11eb-9421-b69100131062.png) 47![image](https://user-images.githubusercontent.com/71780717/124177658-82324880-da7e-11eb-9421-b69100131062.png)
diff --git a/keyboards/gmmk/pro/keymaps/jonavin/rules.mk b/keyboards/gmmk/pro/keymaps/jonavin/rules.mk
index f4f3d4939..e17edf614 100644
--- a/keyboards/gmmk/pro/keymaps/jonavin/rules.mk
+++ b/keyboards/gmmk/pro/keymaps/jonavin/rules.mk
@@ -2,3 +2,8 @@ VIA_ENABLE = yes
2MOUSEKEY_ENABLE = no 2MOUSEKEY_ENABLE = no
3TAP_DANCE_ENABLE = yes 3TAP_DANCE_ENABLE = yes
4BOOTMAGIC_ENABLE = lite 4BOOTMAGIC_ENABLE = lite
5
6TD_LSFT_CAPSLOCK_ENABLE = yes
7IDLE_TIMEOUT_ENABLE = yes
8STARTUP_NUMLOCK_ON = yes
9ENCODER_DEFAULTACTIONS_ENABLE = yes