aboutsummaryrefslogtreecommitdiff
path: root/keyboards/massdrop
diff options
context:
space:
mode:
authorPaul Ewers <ewersp@gmail.com>2020-06-21 23:11:10 -0700
committerGitHub <noreply@github.com>2020-06-22 16:11:10 +1000
commit0b09189087c580bc8d3aa2bd529a08c7633d3e2b (patch)
tree76fddbfada785200382527f46e9e9f34a0c1a040 /keyboards/massdrop
parent3d6d89966614be1e80d9957fb83743934c5eb162 (diff)
downloadqmk_firmware-0b09189087c580bc8d3aa2bd529a08c7633d3e2b.tar.gz
qmk_firmware-0b09189087c580bc8d3aa2bd529a08c7633d3e2b.zip
[Keymap] New custom 'super alt' keymap for the Drop ALT (#9385)
* New custom 'super alt' keymap for the Drop ALT * Improvements to 'super alt' keymap based on PR feedback * Fix flickering LED caps lock bug * Code cleanup from PR feedback * Minor keymap layout cleanup
Diffstat (limited to 'keyboards/massdrop')
-rw-r--r--keyboards/massdrop/alt/keymaps/ewersp/README.md30
-rw-r--r--keyboards/massdrop/alt/keymaps/ewersp/config.h3
-rw-r--r--keyboards/massdrop/alt/keymaps/ewersp/keymap.c196
3 files changed, 229 insertions, 0 deletions
diff --git a/keyboards/massdrop/alt/keymaps/ewersp/README.md b/keyboards/massdrop/alt/keymaps/ewersp/README.md
new file mode 100644
index 000000000..d2e691a9e
--- /dev/null
+++ b/keyboards/massdrop/alt/keymaps/ewersp/README.md
@@ -0,0 +1,30 @@
1## Greetings, Traveler!
2
3This layout is for the [Massdrop ALT Keyboard](https://drop.com/buy/massdrop-alt-mechanical-keyboard) and targets Windows machines.
4
5This keymap is very similar to the default keymap for the Drop ALT, but it overloads the left alt key to behave like an additional 'Fn' key while keeping the functionality of the alt key intact.
6
7### For example:
8```
9LeftAlt + 1...N -> F1...FN
10LeftAlt + L/R Arrows -> Home/End
11LeftAlt + Home -> End
12LeftAlt + Backspace -> Delete
13LeftAlt + Esc -> Backtick (`)
14```
15
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.
17
18Everything also works with other modifier keys, so ```'alt + L/R' and 'alt + shift + L/R'``` work great for text manipulation to select lines.
19
20This **'super alt'** keymap will feel very familiar for anyone **coming from macOS** since the Windows alt key is in the same position as CMD on macOS keyboards.
21
22And finally, the original alt key functionality can be toggled at any time by pressing **```'Fn + period'```** so even if you don't like it, you can turn it off.
23
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.
25
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.
29
30Enjoy! **<3**
diff --git a/keyboards/massdrop/alt/keymaps/ewersp/config.h b/keyboards/massdrop/alt/keymaps/ewersp/config.h
new file mode 100644
index 000000000..1c801d7e3
--- /dev/null
+++ b/keyboards/massdrop/alt/keymaps/ewersp/config.h
@@ -0,0 +1,3 @@
1#pragma once
2
3#define FORCE_NKRO
diff --git a/keyboards/massdrop/alt/keymaps/ewersp/keymap.c b/keyboards/massdrop/alt/keymaps/ewersp/keymap.c
new file mode 100644
index 000000000..483ea3cfb
--- /dev/null
+++ b/keyboards/massdrop/alt/keymaps/ewersp/keymap.c
@@ -0,0 +1,196 @@
1#include QMK_KEYBOARD_H
2
3enum alt_keycodes {
4 U_T_AUTO = SAFE_RANGE, //USB Extra Port Toggle Auto Detect / Always Active
5 U_T_AGCR, //USB Toggle Automatic GCR control
6 DBG_TOG, //DEBUG Toggle On / Off
7 DBG_MTRX, //DEBUG Toggle Matrix Prints
8 DBG_KBD, //DEBUG Toggle Keyboard Prints
9 DBG_MOU, //DEBUG Toggle Mouse Prints
10 MD_BOOT, //Restart into bootloader after hold timeout
11 ALT_DEL, //Added to map left alt + backspace to delete
12};
13
14// Friendly layer names
15enum alt_layers {
16 DEF = 0,
17 ALT,
18 FUNC,
19 SUPR
20};
21
22const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
23 [DEF] = LAYOUT_65_ansi_blocker(
24 KC_ESC, 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,
25 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_HOME,
26 KC_CAPS, 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,
27 KC_LSFT, 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,
28 KC_LCTL, KC_LGUI, MO(SUPR), KC_SPC, KC_RALT, MO(FUNC),KC_LEFT, KC_DOWN, KC_RGHT
29 ),
30 [ALT] = LAYOUT_65_ansi_blocker(
31 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
32 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
33 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
34 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
35 _______, _______, KC_LALT, _______, _______, _______, _______, _______, _______
36 ),
37 [FUNC] = LAYOUT_65_ansi_blocker(
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,
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,
42 _______, _______, KC_LALT, _______, _______, _______, KC_HOME, KC_PGDN, KC_END
43 ),
44 [SUPR] = LAYOUT_65_ansi_blocker(
45 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, ALT_DEL, _______,
46 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_END,
47 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
48 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
49 _______, _______, _______, _______, _______, _______, KC_HOME, _______, KC_END
50 )
51};
52
53// If the super alt layer is the active layer
54bool super_alt_layer_active = false;
55
56// If we need to unregister alt when leaving the super alt layer
57bool need_to_unregister_alt = false;
58
59#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))
61#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
62
63// Taken from 'g_led_config' in config_led.c
64#define CAPS_LOCK_LED_ID 30
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
73 // This fixes a bug where the caps lock LED flickers when toggled in either keylight or underglow modes
74 if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) {
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
82// This runs code every time that the layers get changed
83layer_state_t layer_state_set_user(layer_state_t state) {
84 switch (get_highest_layer(state)) {
85 case DEF:
86 // When returning to the default layer, check if we need to unregister the left alt key
87 if (super_alt_layer_active && need_to_unregister_alt) {
88 unregister_code(KC_LALT);
89 }
90
91 super_alt_layer_active = false;
92 need_to_unregister_alt = false;
93 break;
94 case SUPR:
95 super_alt_layer_active = true;
96 break;
97 }
98 return state;
99}
100
101bool process_record_user(uint16_t keycode, keyrecord_t *record) {
102 static uint32_t key_timer;
103
104 switch (keycode) {
105 // These are the keys we want to 'fall though' and behave as usual when pressed with the alt modifier
106 case KC_A ... KC_Z:
107 case KC_TAB:
108 case KC_DEL:
109 case KC_UP:
110 case KC_DOWN:
111 case MO(FUNC):
112 if (super_alt_layer_active && record->event.pressed) {
113 // Only activate the alt modifier for the first key press
114 if ((get_mods() & MOD_BIT(KC_LALT)) == false) {
115 register_code(KC_LALT);
116 need_to_unregister_alt = true;
117 }
118 }
119 // We still want to process the keycode normally
120 return true;
121 case ALT_DEL:
122 if (record->event.pressed) {
123 register_code(KC_DEL);
124 } else {
125 unregister_code(KC_DEL);
126 }
127 return false;
128 case U_T_AUTO:
129 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
130 TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
131 }
132 return false;
133 case U_T_AGCR:
134 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
135 TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
136 }
137 return false;
138 case DBG_TOG:
139 if (record->event.pressed) {
140 TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
141 }
142 return false;
143 case DBG_MTRX:
144 if (record->event.pressed) {
145 TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
146 }
147 return false;
148 case DBG_KBD:
149 if (record->event.pressed) {
150 TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
151 }
152 return false;
153 case DBG_MOU:
154 if (record->event.pressed) {
155 TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
156 }
157 return false;
158 case MD_BOOT:
159 if (record->event.pressed) {
160 key_timer = timer_read32();
161 } else {
162 if (timer_elapsed32(key_timer) >= 500) {
163 reset_keyboard();
164 }
165 }
166 return false;
167 case RGB_TOG:
168 if (record->event.pressed) {
169 switch (rgb_matrix_get_flags()) {
170 case LED_FLAG_ALL: {
171 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT);
172 rgb_matrix_set_color_all(0, 0, 0);
173 }
174 break;
175 case LED_FLAG_KEYLIGHT: {
176 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
177 rgb_matrix_set_color_all(0, 0, 0);
178 }
179 break;
180 case LED_FLAG_UNDERGLOW: {
181 rgb_matrix_set_flags(LED_FLAG_NONE);
182 rgb_matrix_disable_noeeprom();
183 }
184 break;
185 default: {
186 rgb_matrix_set_flags(LED_FLAG_ALL);
187 rgb_matrix_enable_noeeprom();
188 }
189 break;
190 }
191 }
192 return false;
193 default:
194 return true; // Process all other keycodes normally
195 }
196}