aboutsummaryrefslogtreecommitdiff
path: root/users/konstantin/konstantin.c
diff options
context:
space:
mode:
authorKonstantin Đorđević <vomindoraan@gmail.com>2019-05-06 17:41:45 +0200
committerDrashna Jaelre <drashna@live.com>2019-05-06 08:41:45 -0700
commitcb1935aaff0fed118954996fc7afb722b6ed21be (patch)
tree753712b2dff56ca41675a99af8f3ffcaf58b85b9 /users/konstantin/konstantin.c
parent8a9c90ad78305a1d76663fcb973a1a2ae7177297 (diff)
downloadqmk_firmware-cb1935aaff0fed118954996fc7afb722b6ed21be.tar.gz
qmk_firmware-cb1935aaff0fed118954996fc7afb722b6ed21be.zip
[Keymap] Update personal userspace and keymaps (now with 4 spaces!) (#5774)
* Add FnLk to Melody96 bottom row * Update conditional in userspace makefile Thanks @drashna * Add F keys to Melody96 Fn layer * Add FN_ESC alias to userspace * Update KBD6X keymap * Fix RGB_MATRIX_ENABLE constant name in #if * Remove trailing \ from LAYOUT macro calls * Set RGB mode on EEPROM reset in KBD6X * Swap right and middle mouse buttons in KBD6X * Rearrange RGB controls in KBD6X * Update keycode aliases, replace CLEAR with DEL_NXT in KBD6X Add Clear to KBD6X as RCtrl+` * Convert code to 4 space indents * Tweak RCTRL layer functionality * Replace NUMPAD custom keycode with layer state logic * Update RGB_MATRIX_ENABLE check Co-Authored-By: vomindoraan <vomindoraan@gmail.com>
Diffstat (limited to 'users/konstantin/konstantin.c')
-rw-r--r--users/konstantin/konstantin.c120
1 files changed, 56 insertions, 64 deletions
diff --git a/users/konstantin/konstantin.c b/users/konstantin/konstantin.c
index 753742fa7..9e3caca41 100644
--- a/users/konstantin/konstantin.c
+++ b/users/konstantin/konstantin.c
@@ -4,107 +4,99 @@ __attribute__((weak))
4void keyboard_pre_init_keymap(void) {} 4void keyboard_pre_init_keymap(void) {}
5 5
6void keyboard_pre_init_user(void) { 6void keyboard_pre_init_user(void) {
7 keyboard_pre_init_keymap(); 7 keyboard_pre_init_keymap();
8} 8}
9 9
10__attribute__((weak)) 10__attribute__((weak))
11void eeconfig_init_keymap(void) {} 11void eeconfig_init_keymap(void) {}
12 12
13void eeconfig_init_user(void) { 13void eeconfig_init_user(void) {
14 eeconfig_init_keymap(); 14 eeconfig_init_keymap();
15} 15}
16 16
17__attribute__((weak)) 17__attribute__((weak))
18void keyboard_post_init_keymap(void) {} 18void keyboard_post_init_keymap(void) {}
19 19
20void keyboard_post_init_user(void) { 20void keyboard_post_init_user(void) {
21 keyboard_post_init_keymap(); 21 keyboard_post_init_keymap();
22} 22}
23 23
24__attribute__((weak)) 24__attribute__((weak))
25bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { 25bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
26 return true; 26 return true;
27} 27}
28 28
29bool process_record_user(uint16_t keycode, keyrecord_t *record) { 29bool process_record_user(uint16_t keycode, keyrecord_t *record) {
30 if (!process_record_keymap(keycode, record)) { 30 if (!process_record_keymap(keycode, record)) {
31 return false; 31 return false;
32 }
33
34#ifdef LAYER_NUMPAD
35 void toggle_numpad(void) {
36 layer_invert(L_NUMPAD);
37 bool numpad = IS_LAYER_ON(L_NUMPAD), num_lock = IS_HOST_LED_ON(USB_LED_NUM_LOCK);
38 if (num_lock != numpad) {
39 tap_code(KC_NLCK); // Toggle Num Lock to match layer state
40 } 32 }
41 }
42#endif
43 33
44 switch (keycode) { 34 switch (keycode) {
45 case CLEAR: 35 case CLEAR:
46 if (record->event.pressed) { 36 if (record->event.pressed) {
47 SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); 37 SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE));
48 } 38 }
49 return false; 39 return false;
50 40
51 case DST_P_R: 41 case DST_P_R:
52 (record->event.pressed ? register_code16 : unregister_code16)( 42 (record->event.pressed ? register_code16 : unregister_code16)(
53 (get_mods() & DST_MOD_MASK) ? DST_REM : DST_PRV 43 (get_mods() & DST_MOD_MASK) ? DST_REM : DST_PRV
54 ); 44 );
55 return false; 45 return false;
56 46
57 case DST_N_A: 47 case DST_N_A:
58 (record->event.pressed ? register_code16 : unregister_code16)( 48 (record->event.pressed ? register_code16 : unregister_code16)(
59 (get_mods() & DST_MOD_MASK) ? DST_ADD : DST_NXT 49 (get_mods() & DST_MOD_MASK) ? DST_ADD : DST_NXT
60 ); 50 );
61 return false; 51 return false;
62 52
63#ifdef LAYER_FN 53#ifdef LAYER_FN
64 static bool fn_lock; 54 static bool fn_lock;
65
66 case FN_FNLK:
67 if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
68 fn_lock = !IS_LAYER_ON(L_FN); // Fn layer will be toggled after this
69 }
70 return true;
71#endif
72 55
73#ifdef LAYER_NUMPAD 56 case FN_FNLK:
74 case NUMPAD: 57 if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
75 if (record->event.pressed) { 58 fn_lock = !IS_LAYER_ON(L_FN); // Fn layer will be toggled after this
76 toggle_numpad(); 59 }
77 } 60 return true;
78 return false;
79#endif 61#endif
80 62
81 case KC_ESC: 63 case KC_ESC:
82 if (record->event.pressed) { 64 if (record->event.pressed) {
83#ifdef LAYER_NUMPAD 65#ifdef LAYER_NUMPAD // Disable Numpad layer before Fn layer
84 if (IS_LAYER_ON(L_NUMPAD)) { 66 if (IS_LAYER_ON(L_NUMPAD)) {
85 toggle_numpad(); 67 layer_off(L_NUMPAD);
86 return false; 68 return false;
87 } 69 }
88#endif 70#endif
89#ifdef LAYER_FN 71#ifdef LAYER_FN
90 if (IS_LAYER_ON(L_FN) && fn_lock) { 72 if (IS_LAYER_ON(L_FN) && fn_lock) {
91 layer_off(L_FN); 73 layer_off(L_FN);
92 return fn_lock = false; 74 return fn_lock = false;
93 } 75 }
94#endif 76#endif
95 } 77 }
96 return true; 78 return true;
97 79
98 default: 80 default:
99 return true; 81 return true;
100 } 82 }
101} 83}
102 84
103__attribute__((weak)) 85__attribute__((weak))
104uint32_t layer_state_set_keymap(uint32_t state) { 86uint32_t layer_state_set_keymap(uint32_t state) {
105 return state; 87 return state;
106} 88}
107 89
108uint32_t layer_state_set_user(uint32_t state) { 90uint32_t layer_state_set_user(uint32_t state) {
109 return layer_state_set_keymap(state); 91 state = layer_state_set_keymap(state);
92
93#ifdef LAYER_NUMPAD
94 bool numpad = state & 1UL<<L_NUMPAD;
95 bool num_lock = IS_HOST_LED_ON(USB_LED_NUM_LOCK);
96 if (numpad != num_lock) {
97 tap_code(KC_NLCK); // Toggle Num Lock to match Numpad layer state
98 }
99#endif
100
101 return state;
110} 102}