aboutsummaryrefslogtreecommitdiff
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
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 <=>
-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
-rw-r--r--keyboards/keebio/quefrency/keymaps/jonavin/keymap.c81
-rw-r--r--keyboards/keebio/quefrency/keymaps/jonavin/readme.md7
-rw-r--r--keyboards/keebio/quefrency/keymaps/jonavin/rules.mk3
-rwxr-xr-xkeyboards/mechwild/mercutio/keymaps/jonavin/keymap.c47
-rw-r--r--keyboards/mechwild/mercutio/keymaps/jonavin/readme.md7
-rw-r--r--keyboards/mechwild/mercutio/keymaps/jonavin/rules.mk3
-rw-r--r--users/jonavin/config.h30
-rw-r--r--users/jonavin/jonavin.c231
-rw-r--r--users/jonavin/jonavin.h82
-rw-r--r--users/jonavin/readme.md76
-rw-r--r--users/jonavin/rules.mk13
14 files changed, 500 insertions, 285 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
diff --git a/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c b/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c
index 7243c59b6..721148f4d 100644
--- a/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c
+++ b/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c
@@ -1,4 +1,4 @@
1/* Copyright 2021 Jonavin Eng 1/* Copyright 2021 Jonavin Eng @Jonavin
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 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 4 * it under the terms of the GNU General Public License as published by
@@ -16,36 +16,7 @@
16 16
17 17
18#include QMK_KEYBOARD_H 18#include QMK_KEYBOARD_H
19 19#include "jonavin.h"
20// Each layer gets a name for readability, which is then used in the keymap matrix below.
21// The underscores don't mean anything - you can have a layer called STUFF or any other name.
22// Layer names don't all need to be of the same length, obviously, and you can also skip them
23// entirely and just use numbers.
24enum custom_layers {
25 _BASE,
26 _FN1,
27 _MO2,
28 _MO3,
29};
30
31enum custom_keycodes {
32 DOUBLEZERO = SAFE_RANGE,
33 KC_WINLCK, //Toggles Win key on and off
34};
35
36// Tap Dance Definitions
37enum custom_tapdance {
38 TD_LSFT_CAPSLOCK,
39};
40
41qk_tap_dance_action_t tap_dance_actions[] = {
42 // Tap once for shift, twice for Caps Lock
43 [TD_LSFT_CAPSLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
44};
45
46#define KC_LSFTCAPS TD(TD_LSFT_CAPSLOCK)
47
48bool _isWinKeyDisabled = false;
49 20
50#ifdef RGBLIGHT_ENABLE 21#ifdef RGBLIGHT_ENABLE
51 // Custom RGB Colours 22 // Custom RGB Colours
@@ -56,7 +27,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
56 [_BASE] = LAYOUT_65( 27 [_BASE] = LAYOUT_65(
57 KC_GESC, 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_BSLS, KC_INS, 28 KC_GESC, 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_BSLS, KC_INS,
58 KC_PSCR, 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_BSPC, KC_DEL, 29 KC_PSCR, 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_BSPC, KC_DEL,
59 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_PGUP, 30 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_PGUP,
60 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_PGDN, 31 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_PGDN,
61 KC_LCTL, KC_LGUI, KC_LALT, LT(_FN1, KC_SPC), KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(_FN1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), 32 KC_LCTL, KC_LGUI, KC_LALT, LT(_FN1, KC_SPC), KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(_FN1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
62 [_FN1] = LAYOUT_65( 33 [_FN1] = LAYOUT_65(
@@ -65,13 +36,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
65 KC_CAPS, KC_NO, RGB_VAD, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_HOME, 36 KC_CAPS, KC_NO, RGB_VAD, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_HOME,
66 KC_TRNS, KC_NO, RGB_HUI, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, RGB_MOD, KC_END, 37 KC_TRNS, KC_NO, RGB_HUI, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, RGB_MOD, KC_END,
67 KC_TRNS, KC_WINLCK, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_APP, RGB_SPD, RGB_RMOD, RGB_SPI), 38 KC_TRNS, KC_WINLCK, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_APP, RGB_SPD, RGB_RMOD, RGB_SPI),
68 [_MO2] = LAYOUT_65( 39 [_LOWER] = LAYOUT_65(
69 KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_P7, KC_P8, KC_P9, KC_P0, KC_PMNS, KC_PPLS, KC_PSLS, KC_PEQL, KC_TRNS, 40 KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_P7, KC_P8, KC_P9, KC_P0, KC_PMNS, KC_PPLS, KC_PSLS, KC_PEQL, KC_TRNS,
70 KC_TAB, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_NO, KC_NO, KC_P4, KC_P5, KC_P6, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, 41 KC_TAB, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_NO, KC_NO, KC_P4, KC_P5, KC_P6, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS,
71 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_NO, KC_TAB, KC_P1, KC_P2, KC_P3, KC_NO, KC_PAST, KC_PENT, KC_HOME, 42 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_NO, KC_TAB, KC_P1, KC_P2, KC_P3, KC_NO, KC_PAST, KC_PENT, KC_HOME,
72 KC_TRNS, KC_NO, KC_DEL, KC_INS, KC_NO, KC_NO, KC_NLCK, KC_P0, DOUBLEZERO, KC_PDOT, KC_PSLS, KC_TRNS, RCTL(KC_PGUP), KC_END, 43 KC_TRNS, KC_NO, KC_DEL, KC_INS, KC_NO, KC_NO, KC_NLCK, KC_P0, KC_00, KC_PDOT, KC_PSLS, KC_TRNS, RCTL(KC_PGUP), KC_END,
73 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSPC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RCTL(KC_LEFT), RCTL(KC_PGDN), RCTL(KC_RIGHT)), 44 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSPC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RCTL(KC_LEFT), RCTL(KC_PGDN), RCTL(KC_RIGHT)),
74 [_MO3] = LAYOUT_65( 45 [_RAISE] = LAYOUT_65(
75 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 46 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
76 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 47 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
77 KC_TRNS, KC_TRNS, KC_DOWN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 48 KC_TRNS, KC_TRNS, KC_DOWN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@@ -80,27 +51,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
80}; 51};
81 52
82 53
83bool process_record_user(uint16_t keycode, keyrecord_t *record) { 54bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
84 switch (keycode) { 55 // process_record_user() moved to userspace
85 case DOUBLEZERO:
86 if (record->event.pressed) {
87 // when keycode DOUBLEZERO is pressed
88 SEND_STRING("00");
89 } else {
90 // when keycode DOUBLEZERO is released
91 }
92 break;
93 case KC_WINLCK:
94 if (record->event.pressed) {
95 _isWinKeyDisabled = !_isWinKeyDisabled; //toggle status
96 if(_isWinKeyDisabled) {
97 process_magic(GUI_OFF, record);
98 } else {
99 process_magic(GUI_ON, record);
100 }
101 } else unregister_code16(keycode);
102 break;
103 }
104 return true; 56 return true;
105}; 57};
106 58
@@ -183,22 +135,19 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
183 135
184 bool led_update_user(led_t led_state) { 136 bool led_update_user(led_t led_state) {
185 rgblight_set_layer_state(_rgbCAPS, led_state.caps_lock); 137 rgblight_set_layer_state(_rgbCAPS, led_state.caps_lock);
186 rgblight_set_layer_state(_rgbWINLOCK, _isWinKeyDisabled); 138 rgblight_set_layer_state(_rgbWINLOCK, keymap_config.no_gui);
187 return true; 139 return true;
188 } 140 }
189 141
190 layer_state_t layer_state_set_user(layer_state_t state) { 142 layer_state_t layer_state_set_user(layer_state_t state) {
191 rgblight_set_layer_state(_rgbFN, layer_state_cmp(state, _FN1)); 143 rgblight_set_layer_state(_rgbFN, layer_state_cmp(state, _FN1));
192 rgblight_set_layer_state(_rgbNUMPAD, layer_state_cmp(state, _MO2)); 144 rgblight_set_layer_state(_rgbNUMPAD, layer_state_cmp(state, _LOWER));
193 return state; 145 return state;
194 } 146 }
195#endif // RGBLIGHT_ENABLE 147#endif // RGBLIGHT_ENABLE
196 148
197void keyboard_post_init_user(void) { 149void keyboard_post_init_keymap(void) {
198 150 // keyboard_post_init_user() moved to userspace
199 if (IS_HOST_LED_ON(USB_LED_NUM_LOCK)) { // turn on Num lock by defautl so that the numpad layer always has predictable results
200 tap_code(KC_NUMLOCK);
201 }
202 #ifdef RGBLIGHT_ENABLE 151 #ifdef RGBLIGHT_ENABLE
203 rgblight_mode(1); // single colour mode 152 rgblight_mode(1); // single colour mode
204 rgblight_setrgb(RGB_GODSPEED); // Default startup colour 153 rgblight_setrgb(RGB_GODSPEED); // Default startup colour
diff --git a/keyboards/keebio/quefrency/keymaps/jonavin/readme.md b/keyboards/keebio/quefrency/keymaps/jonavin/readme.md
index c782d26c0..4833c5b62 100644
--- a/keyboards/keebio/quefrency/keymaps/jonavin/readme.md
+++ b/keyboards/keebio/quefrency/keymaps/jonavin/readme.md
@@ -18,6 +18,13 @@
18 - Add capslock indicator, win key lock indicator 18 - Add capslock indicator, win key lock indicator
19 - Fn and layer 2 indicators using RGB underglow 19 - Fn and layer 2 indicators using RGB underglow
20 20
21rules.mk OPTIONS - Active features from userspace
22STARTUP_NUMLOCK_ON = yes
23 - turns on NUMLOCK by default
24
25TD_LSFT_CAPSLOCK_ENABLE = yes
26 - This will enable double tap on Left Shift to toggle CAPSLOCK when using KC_LSFTCAPS
27
21## All layers diagram 28## All layers diagram
22 29
23Default Layer 30Default Layer
diff --git a/keyboards/keebio/quefrency/keymaps/jonavin/rules.mk b/keyboards/keebio/quefrency/keymaps/jonavin/rules.mk
index eff3d692e..f27873bb8 100644
--- a/keyboards/keebio/quefrency/keymaps/jonavin/rules.mk
+++ b/keyboards/keebio/quefrency/keymaps/jonavin/rules.mk
@@ -4,3 +4,6 @@ LTO_ENABLE = yes
4 4
5MOUSEKEY_ENABLE = no 5MOUSEKEY_ENABLE = no
6TAP_DANCE_ENABLE = yes 6TAP_DANCE_ENABLE = yes
7
8TD_LSFT_CAPSLOCK_ENABLE = yes
9STARTUP_NUMLOCK_ON = yes
diff --git a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
index ed321e79b..ddde6d652 100755
--- a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
+++ b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
@@ -18,35 +18,7 @@
18 18
19#include QMK_KEYBOARD_H 19#include QMK_KEYBOARD_H
20#include <stdio.h> 20#include <stdio.h>
21 21#include "jonavin.h"
22enum custom_layers {
23 _BASE,
24 _FN1,
25 _LOWER,
26 _RAISE,
27};
28
29enum custom_keycodes {
30 ENCFUNC = SAFE_RANGE, // encoder function keys
31 KC_WINLCK, //Toggles Win key on and off
32};
33
34// Tap Dance Definitions
35enum custom_tapdance {
36 TD_LSFT_CAPSLOCK,
37};
38
39qk_tap_dance_action_t tap_dance_actions[] = {
40 // Tap once for shift, twice for Caps Lock
41 [TD_LSFT_CAPSLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
42};
43
44bool _isWinKeyDisabled = false;
45
46#define KC_LSFTCAPS TD(TD_LSFT_CAPSLOCK)
47#define KC_CAD LALT(LCTL(KC_DEL))
48#define KC_AF4 LALT(KC_F4)
49#define KC_TASK LCTL(LSFT(KC_ESC))
50 22
51const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 23const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
52[_BASE] = LAYOUT_all( 24[_BASE] = LAYOUT_all(
@@ -113,13 +85,12 @@ static void set_selectedkey(uint8_t idx) {
113 85
114} 86}
115 87
116void keyboard_post_init_user(void) { 88void keyboard_post_init_keymap(void) {
117 // Call the keyboard post init code. 89 // Call the keyboard post init code.
118 //selectedkey_rec = keyselection[selectedkey_idx];
119 set_selectedkey(selectedkey_idx); 90 set_selectedkey(selectedkey_idx);
120} 91}
121 92
122bool process_record_user(uint16_t keycode, keyrecord_t *record) { 93bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
123 switch (keycode) { 94 switch (keycode) {
124 case ENCFUNC: 95 case ENCFUNC:
125 if (record->event.pressed) { 96 if (record->event.pressed) {
@@ -128,16 +99,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
128 // when keycode is released 99 // when keycode is released
129 } 100 }
130 break; 101 break;
131 case KC_WINLCK:
132 if (record->event.pressed) {
133 _isWinKeyDisabled = !_isWinKeyDisabled; //toggle status
134 if(_isWinKeyDisabled) {
135 process_magic(GUI_OFF, record);
136 } else {
137 process_magic(GUI_ON, record);
138 }
139 } else unregister_code16(keycode);
140 break;
141 } 102 }
142 return true; 103 return true;
143}; 104};
@@ -274,7 +235,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
274 default: 235 default:
275 oled_write_P(PSTR("Layer ?"), false); // Should never display, here as a catchall 236 oled_write_P(PSTR("Layer ?"), false); // Should never display, here as a catchall
276 } 237 }
277 oled_write_P(_isWinKeyDisabled ? PSTR(" WL") : PSTR(" "), false); 238 oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false);
278 oled_set_cursor(8,3); 239 oled_set_cursor(8,3);
279 if (get_highest_layer(layer_state) == selected_layer) { 240 if (get_highest_layer(layer_state) == selected_layer) {
280 oled_write_P(PSTR(" "), false); 241 oled_write_P(PSTR(" "), false);
diff --git a/keyboards/mechwild/mercutio/keymaps/jonavin/readme.md b/keyboards/mechwild/mercutio/keymaps/jonavin/readme.md
index 730bee889..6255dadd0 100644
--- a/keyboards/mechwild/mercutio/keymaps/jonavin/readme.md
+++ b/keyboards/mechwild/mercutio/keymaps/jonavin/readme.md
@@ -38,6 +38,13 @@ Features
38 While holding Left Alt, media next track or previous track 38 While holding Left Alt, media next track or previous track
39 39
40 40
41rules.mk OPTIONS - Active features from userspace
42STARTUP_NUMLOCK_ON = yes
43 - turns on NUMLOCK by default
44
45TD_LSFT_CAPSLOCK_ENABLE = yes
46 - This will enable double tap on Left Shift to toggle CAPSLOCK when using KC_LSFTCAPS
47
41Default Layers 48Default Layers
42![image](https://user-images.githubusercontent.com/71780717/127014682-3aa05136-6dc7-4a40-9be1-89a5b584848a.png) 49![image](https://user-images.githubusercontent.com/71780717/127014682-3aa05136-6dc7-4a40-9be1-89a5b584848a.png)
43 50
diff --git a/keyboards/mechwild/mercutio/keymaps/jonavin/rules.mk b/keyboards/mechwild/mercutio/keymaps/jonavin/rules.mk
index 550e84c80..0b76c6e57 100644
--- a/keyboards/mechwild/mercutio/keymaps/jonavin/rules.mk
+++ b/keyboards/mechwild/mercutio/keymaps/jonavin/rules.mk
@@ -3,3 +3,6 @@ VIA_ENABLE = yes
3MOUSEKEY_ENABLE = yes 3MOUSEKEY_ENABLE = yes
4WPM_ENABLE = yes 4WPM_ENABLE = yes
5TAP_DANCE_ENABLE = yes 5TAP_DANCE_ENABLE = yes
6
7TD_LSFT_CAPSLOCK_ENABLE = yes
8STARTUP_NUMLOCK_ON = yes
diff --git a/users/jonavin/config.h b/users/jonavin/config.h
new file mode 100644
index 000000000..4f4568f70
--- /dev/null
+++ b/users/jonavin/config.h
@@ -0,0 +1,30 @@
1/* Copyright 2021 Jonavin Eng
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
17#pragma once
18
19#define TAPPING_TOGGLE 2 // TT () set to two taps
20
21/* Handle GRAVESC combo keys */
22#define GRAVE_ESC_ALT_OVERRIDE // Always send Escape if Alt is pressed
23#define GRAVE_ESC_CTRL_OVERRIDE // Always send Escape if Control is pressed
24
25#define TAPPING_TERM 180
26
27#ifdef RGB_MATRIX_ENABLE
28 #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR
29 #define RGB_DISABLE_WHEN_USB_SUSPENDED true
30#endif
diff --git a/users/jonavin/jonavin.c b/users/jonavin/jonavin.c
new file mode 100644
index 000000000..d5fdb2a1e
--- /dev/null
+++ b/users/jonavin/jonavin.c
@@ -0,0 +1,231 @@
1
2/* Copyright 2021 Jonavin Eng @Jonavin
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18
19#include QMK_KEYBOARD_H
20#include "jonavin.h"
21
22
23#ifdef TD_LSFT_CAPSLOCK_ENABLE
24 // Tap once for shift, twice for Caps Lock but only if Win Key in not disabled
25 void dance_LSFT_finished(qk_tap_dance_state_t *state, void *user_data) {
26 if (state->count == 1 || keymap_config.no_gui) {
27 register_code16(KC_LSFT);
28 } else {
29 register_code(KC_CAPS);
30 }
31 }
32
33 void dance_LSFT_reset(qk_tap_dance_state_t *state, void *user_data) {
34 if (state->count == 1 || keymap_config.no_gui) {
35 unregister_code16(KC_LSFT);
36 } else {
37 unregister_code(KC_CAPS);
38 }
39 }
40
41 qk_tap_dance_action_t tap_dance_actions[] = {
42 // Tap once for shift, twice for Caps Lock
43 [TD_LSFT_CAPSLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
44 [TD_LSFT_CAPS_WIN] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_LSFT_finished, dance_LSFT_reset),
45 };
46#endif // TD_LSFT_CAPSLOCK_ENABLE
47
48// TIMEOUTS
49#ifdef IDLE_TIMEOUT_ENABLE
50 static uint16_t timeout_timer = 0;
51 static uint16_t timeout_counter = 0; //in minute intervals
52 static uint16_t timeout_threshold = TIMEOUT_THRESHOLD_DEFAULT;
53
54 uint16_t get_timeout_threshold(void) {
55 return timeout_threshold;
56 }
57
58 void timeout_reset_timer(void) {
59 timeout_timer = timer_read();
60 timeout_counter = 0;
61 };
62
63 void timeout_update_threshold(bool increase) {
64 if (increase && timeout_threshold < TIMEOUT_THRESHOLD_MAX) timeout_threshold++;
65 if (!increase && timeout_threshold > 0) timeout_threshold--;
66 };
67
68 void timeout_tick_timer(void) {
69 if (timeout_threshold > 0) {
70 if (timer_elapsed(timeout_timer) >= 60000) { // 1 minute tick
71 timeout_counter++;
72 timeout_timer = timer_read();
73 }
74 #ifdef RGB_MATRIX_ENABLE
75 if (timeout_threshold > 0 && timeout_counter >= timeout_threshold) {
76 rgb_matrix_disable_noeeprom();
77 }
78 #endif
79 } // timeout_threshold = 0 will disable timeout
80 }
81
82 __attribute__((weak)) void matrix_scan_keymap(void) {}
83
84 void matrix_scan_user(void) {
85 timeout_tick_timer();
86 matrix_scan_keymap();
87 }
88#endif // IDLE_TIMEOUT_ENABLE
89
90
91#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality
92 #ifndef DYNAMIC_KEYMAP_LAYER_COUNT
93 #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere
94 #endif
95 #ifndef ENCODER_DEFAULTACTIONS_INDEX
96 #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders
97 #endif
98
99uint8_t selected_layer = 0;
100
101__attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; }
102
103bool encoder_update_user(uint8_t index, bool clockwise) {
104 if (!encoder_update_keymap(index, clockwise)) { return false; }
105 if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match
106 if ( clockwise ) {
107 if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers
108 if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) {
109 selected_layer ++;
110 layer_move(selected_layer);
111 }
112 } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up
113 unregister_mods(MOD_BIT(KC_RSFT));
114 register_code(KC_PGDN);
115 register_mods(MOD_BIT(KC_RSFT));
116 } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word
117 tap_code16(LCTL(KC_RGHT));
118 } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track
119 tap_code(KC_MEDIA_NEXT_TRACK);
120 } else {
121 switch (selected_layer) {
122 case _FN1:
123 #ifdef IDLE_TIMEOUT_ENABLE
124 timeout_update_threshold(true);
125 #endif
126 break;
127 default:
128 tap_code(KC_VOLU); // Otherwise it just changes volume
129 break;
130 }
131 }
132 } else {
133 if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) {
134 if (selected_layer > 0) {
135 selected_layer --;
136 layer_move(selected_layer);
137 }
138 } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) {
139 unregister_mods(MOD_BIT(KC_RSFT));
140 register_code(KC_PGUP);
141 register_mods(MOD_BIT(KC_RSFT));
142 } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word
143 tap_code16(LCTL(KC_LEFT));
144 } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track
145 tap_code(KC_MEDIA_PREV_TRACK);
146 } else {
147 switch (selected_layer) {
148 case _FN1:
149 #ifdef IDLE_TIMEOUT_ENABLE
150 timeout_update_threshold(false);
151 #endif
152 break;
153 default:
154 tap_code(KC_VOLD);
155 break;
156 }
157 }
158 }
159
160 return true;
161 }
162#endif // ENCODER_ENABLE
163
164
165// PROCESS KEY CODES
166__attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
167
168bool process_record_user(uint16_t keycode, keyrecord_t *record) {
169 if (!process_record_keymap(keycode, record)) { return false; }
170 switch (keycode) {
171 case KC_00:
172 if (record->event.pressed) {
173 // when keycode KC_00 is pressed
174 SEND_STRING("00");
175 } else unregister_code16(keycode);
176 break;
177 case KC_WINLCK:
178 if (record->event.pressed) {
179 keymap_config.no_gui = !keymap_config.no_gui; //toggle status
180 } else unregister_code16(keycode);
181 break;
182
183#ifdef IDLE_TIMEOUT_ENABLE
184 case RGB_TOI:
185 if(record->event.pressed) {
186 timeout_update_threshold(true);
187 } else unregister_code16(keycode);
188 break;
189 case RGB_TOD:
190 if(record->event.pressed) {
191 timeout_update_threshold(false); //decrease timeout
192 } else unregister_code16(keycode);
193 break;
194#endif // IDLE_TIMEOUT_ENABLE
195
196 default:
197 if (record->event.pressed) {
198 #ifdef RGB_MATRIX_ENABLE
199 rgb_matrix_enable();
200 #endif
201 #ifdef IDLE_TIMEOUT_ENABLE
202 timeout_reset_timer(); //reset activity timer
203 #endif
204 }
205 break;
206 }
207 return true;
208};
209
210
211// Turn on/off NUM LOCK if current state is different
212void activate_numlock(bool turn_on) {
213 if (IS_HOST_LED_ON(USB_LED_NUM_LOCK) != turn_on) {
214 tap_code(KC_NUMLOCK);
215 }
216}
217
218
219// INITIAL STARTUP
220
221__attribute__ ((weak)) void keyboard_post_init_keymap(void) {}
222
223void keyboard_post_init_user(void) {
224 keyboard_post_init_keymap();
225 #ifdef STARTUP_NUMLOCK_ON
226 activate_numlock(true); // turn on Num lock by default so that the numpad layer always has predictable results
227 #endif // STARTUP_NUMLOC_ON
228 #ifdef IDLE_TIMEOUT_ENABLE
229 timeout_timer = timer_read(); // set inital time for ide timeout
230 #endif
231}
diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h
new file mode 100644
index 000000000..894feddfd
--- /dev/null
+++ b/users/jonavin/jonavin.h
@@ -0,0 +1,82 @@
1
2/* Copyright 2021 Jonavin Eng @Jonavin
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20// DEFINE MACROS
21#define ARRAYSIZE(arr) sizeof(arr)/sizeof(arr[0])
22
23
24// LAYERS
25enum custom_user_layers {
26 _BASE,
27 _FN1,
28 _LOWER,
29 _RAISE,
30};
31
32// KEYCODES
33enum custom_user_keycodes {
34 KC_00 = SAFE_RANGE,
35 ENCFUNC,
36 KC_WINLCK, //Toggles Win key on and off
37 RGB_TOI, // Timeout idle time up
38 RGB_TOD, // Timeout idle time down
39};
40
41#define KC_CAD LALT(LCTL(KC_DEL))
42#define KC_AF4 LALT(KC_F4)
43#define KC_TASK LCTL(LSFT(KC_ESC))
44
45
46#ifdef TD_LSFT_CAPSLOCK_ENABLE
47 // Tap Dance Definitions
48 enum custom_tapdance {
49 TD_LSFT_CAPSLOCK,
50 TD_LSFT_CAPS_WIN
51 };
52
53 #define KC_LSFTCAPS TD(TD_LSFT_CAPSLOCK)
54 #define KC_LSFTCAPSWIN TD(TD_LSFT_CAPS_WIN)
55#else // regular Shift
56 #define KC_LSFTCAPS KC_LSFT
57#endif // TD_LSFT_CAPSLOCK_ENABLE
58
59
60
61#ifdef RGB_MATRIX_ENABLE
62//RGB custom colours
63 #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps
64 #define RGB_NAUTILUS 0x00, 0xA4, 0xA9 // Nautilus Font colours
65#endif
66
67
68// IDLE TIMEOUTS
69#ifdef IDLE_TIMEOUT_ENABLE
70 #define TIMEOUT_THRESHOLD_DEFAULT 5 // default timeout minutes
71 #define TIMEOUT_THRESHOLD_MAX 140 // upper limits (2 hours and 10 minutes -- no rgb indicators above this value)
72
73 //prototype functions
74 uint16_t get_timeout_threshold(void);
75 void timeout_reset_timer(void);
76 void timeout_update_threshold(bool increase);
77 void timeout_tick_timer(void);
78#endif //IDLE_TIMEOUT_ENABLE
79
80
81// OTHER FUNCTION PROTOTYPE
82void activate_numlock(bool turn_on);
diff --git a/users/jonavin/readme.md b/users/jonavin/readme.md
new file mode 100644
index 000000000..97fff6520
--- /dev/null
+++ b/users/jonavin/readme.md
@@ -0,0 +1,76 @@
1Copyright 2021 Jonavin Eng @Jonavin
2
3This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or
6(at your option) any later version.
7
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16LAYERS:
17 0 = _BASE
18 1 = _FN1
19 2 = _LOWER
20 3 = _RAISE
21
22KEYCODES:
23 KC_CAD Ctrl-Alt-Del
24 KC_AF4 Alt-F4
25 KC_TASK Windows Task Manager (Ctrl-Shift-Esc)
26 LSFT_CAPSLOCK When LSFT_CAPSLOCK_ENABLE is defined, hold for Shift double tap for CAPSLOCK; otherwise, just Shift
27 KC_00 double zero "00"
28 KC_WINLCK toggles LGui/Win key lock
29 RGB_TOI Increase Timeout idle time threshold
30 RGB_TOD Decrease Timeout idle time threshold
31
32ENABLE FEATURES your keymap rules.mk
33
34STARTUP_NUMLOCK_ON = yes
35 turns on NUMLOCK by default
36
37ENCODER_DEFAULTACTIONS_ENABLE = yes
38 Enabled default encoder funtions
39 When enabled, use this in the keymap for an additional encoder processing
40 bool encoder_update_keymap(uint8_t index, bool clockwise)
41
42 OPTION: set ENCODER_DEFAULTACTIONS_INDEX to the encoder number if the encoder is not index 0
43
44TD_LSFT_CAPSLOCK_ENABLE = yes
45 This will enable double tap on Left Shift to toggle CAPSLOCK
46 KC_LSFTCAPS to bind to left Shift to enable feature
47 KC_LSFTCAPSWIN does the same thing but will not turn on CAPS when Win Lkey is disabled
48
49IDLE_TIMEOUT_ENABLE = yes
50 Enables Timer functionality; for RGB idle timeouts that can be changed dynamically
51 When enabled, use this in the keymap for an additional matrix processing
52 void matrix_scan_keymap(void)
53
54 Functions:
55 u16int_t get_timeout_threshold(void) // returns the current timeout threshold
56 void timeout_update_threshold(bool increase) // change threshold: true = increase, false = decrease
57 void timeout_reset_timer(void) // resets timer (put in process_record_user if you override it)
58 void timeout_tick_timer(void) // registers time ticks (put in maxtrix_scan_user if you override it)
59
60Other Functions:
61 - activate_numlock(bool turn_on) // true = turn on NUM LOCK, false = off
62
63KEYMAP LEVEL ADDITIONAL PROCESSING FUNCTIONS
64 bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
65 void keyboard_post_init_keymap(void)
66
67LIST OF COMPATIBLE KEYMAPS
68 - gmmk/pro
69 - gmmk/pro/ansi
70 - keebio/quefrency/rev3
71 - mechwild/mercutio
72 - mechwild/murphpad (*)
73 - mechwild/OBE (*)
74 - nopunin10did/kastenwagen (*)
75
76 (*) coming soon
diff --git a/users/jonavin/rules.mk b/users/jonavin/rules.mk
new file mode 100644
index 000000000..4e9ee08ff
--- /dev/null
+++ b/users/jonavin/rules.mk
@@ -0,0 +1,13 @@
1SRC += jonavin.c
2ifeq ($(strip $(ENCODER_DEFAULTACTIONS_ENABLE)), yes)
3 OPT_DEFS += -DENCODER_DEFAULTACTIONS_ENABLE
4endif
5ifeq ($(strip $(TD_LSFT_CAPSLOCK_ENABLE)), yes)
6 OPT_DEFS += -DTD_LSFT_CAPSLOCK_ENABLE
7endif
8ifeq ($(strip $(IDLE_TIMEOUT_ENABLE)), yes)
9 OPT_DEFS += -DIDLE_TIMEOUT_ENABLE
10endif
11ifeq ($(strip $(STARTUP_NUMLOCK_ON)), yes)
12 OPT_DEFS += -DSTARTUP_NUMLOCK_ON
13endif