aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Ewers <ewersp@gmail.com>2021-07-20 10:46:52 -0700
committerGitHub <noreply@github.com>2021-07-20 10:46:52 -0700
commit3591312fa3d41cf18bc873a974698af3a59afcca (patch)
tree45a9c857d54f810b5c0c2fb63e6e462af0c3d100
parent42ac7c0541b2a9c2f38f6c2aac6d05163dec4a37 (diff)
downloadqmk_firmware-3591312fa3d41cf18bc873a974698af3a59afcca.tar.gz
qmk_firmware-3591312fa3d41cf18bc873a974698af3a59afcca.zip
[Keymap] Updates to personal Drop ALT keymap (#13058)
-rw-r--r--keyboards/massdrop/alt/keymaps/ewersp/README.md14
-rw-r--r--keyboards/massdrop/alt/keymaps/ewersp/keymap.c134
2 files changed, 97 insertions, 51 deletions
diff --git a/keyboards/massdrop/alt/keymaps/ewersp/README.md b/keyboards/massdrop/alt/keymaps/ewersp/README.md
index d2e691a9e..8a19bb6c1 100644
--- a/keyboards/massdrop/alt/keymaps/ewersp/README.md
+++ b/keyboards/massdrop/alt/keymaps/ewersp/README.md
@@ -6,11 +6,13 @@ This keymap is very similar to the default keymap for the Drop ALT, but it overl
6 6
7### For example: 7### For example:
8``` 8```
9LeftAlt + 1...N -> F1...FN 9LeftAlt + 1...N -> F1...FN
10LeftAlt + L/R Arrows -> Home/End 10LeftAlt + L/R Arrows -> Home/End
11LeftAlt + Home -> End 11LeftAlt + Home -> End
12LeftAlt + Backspace -> Delete 12LeftAlt + Backspace -> Delete
13LeftAlt + Esc -> Backtick (`) 13LeftAlt + Esc -> Backtick (`)
14LeftAlt + Shift + Esc -> Tilde (~)
15LeftAlt + LeftShift + 4 -> Alt+F4
14``` 16```
15 17
16The novel part of this keymap is that it **preserves the default functionality** of the left alt key, so ```'alt + tab', 'ctrl + alt + del', 'alt + f4'```, etc. all work as expected without using any janky timers. 18The novel part of this keymap is that it **preserves the default functionality** of the left alt key, so ```'alt + tab', 'ctrl + alt + del', 'alt + f4'```, etc. all work as expected without using any janky timers.
@@ -23,8 +25,6 @@ And finally, the original alt key functionality can be toggled at any time by pr
23 25
24This keymap was based on the 'default' Drop ALT keymap (and _not_ 'default_md') which means it supports all the fancy QMK RGB patterns, and isn't limited to the stock options that come with the board. 26This keymap was based on the 'default' Drop ALT keymap (and _not_ 'default_md') which means it supports all the fancy QMK RGB patterns, and isn't limited to the stock options that come with the board.
25 27
26It's also worth noting that this keymap fixes an outstanding issue where the caps lock LED flickers when the RGB mode is keylight or underglow. I could not find a general purpose fix, but the one included here works quite well.
27
28If you have any questions, feel free to reach out to me at: ewersp [at] gmail [dot] com. 28If you have any questions, feel free to reach out to me at: ewersp [at] gmail [dot] com.
29 29
30Enjoy! **<3** 30Enjoy! **<3**
diff --git a/keyboards/massdrop/alt/keymaps/ewersp/keymap.c b/keyboards/massdrop/alt/keymaps/ewersp/keymap.c
index 483ea3cfb..d4f05b9f3 100644
--- a/keyboards/massdrop/alt/keymaps/ewersp/keymap.c
+++ b/keyboards/massdrop/alt/keymaps/ewersp/keymap.c
@@ -38,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
38 KC_GRV, 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_MUTE, 38 KC_GRV, 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_MUTE,
39 _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_END, 39 _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______, U_T_AUTO,U_T_AGCR,_______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_END,
40 _______, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, 40 _______, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, KC_VOLU,
41 _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, DBG_TOG, _______, TG(ALT), _______, _______, KC_PGUP, KC_VOLD, 41 _______, RGB_TOG, _______, _______, EEP_RST, MD_BOOT, NK_TOGG, DBG_TOG, _______, TG(ALT), _______, _______, KC_PGUP, KC_VOLD,
42 _______, _______, KC_LALT, _______, _______, _______, KC_HOME, KC_PGDN, KC_END 42 _______, _______, KC_LALT, _______, _______, _______, KC_HOME, KC_PGDN, KC_END
43 ), 43 ),
44 [SUPR] = LAYOUT_65_ansi_blocker( 44 [SUPR] = LAYOUT_65_ansi_blocker(
@@ -50,34 +50,56 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
50 ) 50 )
51}; 51};
52 52
53// If the super alt layer is the active layer 53// EEPROM storage mode
54bool super_alt_layer_active = false; 54enum alt_rgb_mode {
55 RGB_MODE_ALL,
56 RGB_MODE_KEYLIGHT,
57 RGB_MODE_UNDERGLOW,
58 RGB_MODE_NONE,
59};
55 60
56// If we need to unregister alt when leaving the super alt layer 61// EEPROM storage type
57bool need_to_unregister_alt = false; 62typedef union {
63 uint32_t raw;
64 struct {
65 uint8_t rgb_mode :8;
66 };
67} alt_config_t;
68
69alt_config_t alt_config;
70
71// Read from EEPROM on init to load the last saved mode
72void keyboard_post_init_kb(void) {
73 alt_config.raw = eeconfig_read_user();
74 switch (alt_config.rgb_mode) {
75 case RGB_MODE_ALL:
76 rgb_matrix_set_flags(LED_FLAG_ALL);
77 rgb_matrix_enable_noeeprom();
78 break;
79 case RGB_MODE_KEYLIGHT:
80 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT);
81 rgb_matrix_set_color_all(0, 0, 0);
82 break;
83 case RGB_MODE_UNDERGLOW:
84 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
85 rgb_matrix_set_color_all(0, 0, 0);
86 break;
87 case RGB_MODE_NONE:
88 rgb_matrix_set_flags(LED_FLAG_NONE);
89 rgb_matrix_disable_noeeprom();
90 break;
91 }
92}
58 93
59#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT)) 94#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
60#define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL)) 95#define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL))
61#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT)) 96#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
62 97
63// Taken from 'g_led_config' in config_led.c 98// If the super alt layer is the active layer
64#define CAPS_LOCK_LED_ID 30 99bool super_alt_layer_active = false;
65
66// This runs every matrix scan (every 'frame')
67void rgb_matrix_indicators_user(void) {
68 led_flags_t flags = rgb_matrix_get_flags();
69
70 // If we're in either keylight or underglow modes (but not both simultaneously)
71 if (HAS_FLAGS(flags, LED_FLAG_KEYLIGHT) != HAS_FLAGS(flags, LED_FLAG_UNDERGLOW)) {
72 100
73 // This fixes a bug where the caps lock LED flickers when toggled in either keylight or underglow modes 101// If we need to unregister alt when leaving the super alt layer
74 if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) { 102bool need_to_unregister_alt = false;
75 rgb_matrix_set_color(CAPS_LOCK_LED_ID, RGB_WHITE);
76 } else {
77 rgb_matrix_set_color(CAPS_LOCK_LED_ID, 0, 0, 0);
78 }
79 }
80}
81 103
82// This runs code every time that the layers get changed 104// This runs code every time that the layers get changed
83layer_state_t layer_state_set_user(layer_state_t state) { 105layer_state_t layer_state_set_user(layer_state_t state) {
@@ -118,6 +140,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
118 } 140 }
119 // We still want to process the keycode normally 141 // We still want to process the keycode normally
120 return true; 142 return true;
143 case KC_F4:
144 // Map alt+shift+4 to alt+f4
145 if (super_alt_layer_active && (get_mods() & MOD_BIT(KC_LSHIFT))) {
146 if (record->event.pressed) {
147 register_code(KC_LALT);
148 } else {
149 unregister_code(KC_LALT);
150 }
151 }
152 return true;
121 case ALT_DEL: 153 case ALT_DEL:
122 if (record->event.pressed) { 154 if (record->event.pressed) {
123 register_code(KC_DEL); 155 register_code(KC_DEL);
@@ -164,30 +196,44 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
164 } 196 }
165 } 197 }
166 return false; 198 return false;
199 case EEP_RST:
200 if (record->event.pressed) {
201 key_timer = timer_read32();
202 } else {
203 if (timer_elapsed32(key_timer) >= 500) {
204 eeconfig_init();
205 }
206 }
207 return false;
167 case RGB_TOG: 208 case RGB_TOG:
168 if (record->event.pressed) { 209 if (record->event.pressed) {
169 switch (rgb_matrix_get_flags()) { 210 switch (rgb_matrix_get_flags()) {
170 case LED_FLAG_ALL: { 211 case LED_FLAG_ALL: {
171 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); 212 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
172 rgb_matrix_set_color_all(0, 0, 0); 213 rgb_matrix_set_color_all(0, 0, 0);
173 } 214 alt_config.rgb_mode = RGB_MODE_KEYLIGHT;
174 break; 215 break;
175 case LED_FLAG_KEYLIGHT: { 216 }
176 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); 217 case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): {
177 rgb_matrix_set_color_all(0, 0, 0); 218 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
178 } 219 rgb_matrix_set_color_all(0, 0, 0);
179 break; 220 alt_config.rgb_mode = RGB_MODE_UNDERGLOW;
180 case LED_FLAG_UNDERGLOW: { 221 break;
181 rgb_matrix_set_flags(LED_FLAG_NONE); 222 }
182 rgb_matrix_disable_noeeprom(); 223 case LED_FLAG_UNDERGLOW: {
183 } 224 rgb_matrix_set_flags(LED_FLAG_NONE);
184 break; 225 rgb_matrix_disable_noeeprom();
185 default: { 226 alt_config.rgb_mode = RGB_MODE_NONE;
186 rgb_matrix_set_flags(LED_FLAG_ALL); 227 break;
187 rgb_matrix_enable_noeeprom(); 228 }
188 } 229 default: {
189 break; 230 rgb_matrix_set_flags(LED_FLAG_ALL);
190 } 231 rgb_matrix_enable_noeeprom();
232 alt_config.rgb_mode = RGB_MODE_ALL;
233 break;
234 }
235 }
236 eeconfig_update_user(alt_config.raw);
191 } 237 }
192 return false; 238 return false;
193 default: 239 default: