aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCallum Oakley <hello@callumoakley.net>2020-07-10 02:31:18 +0100
committerGitHub <noreply@github.com>2020-07-10 11:31:18 +1000
commitc50009d5d4909d55f5511378ba5bf0b4623a0a1c (patch)
tree38e1f2daf16299577e9a51271768eae596260734
parent823165b9b784feda7546daa83ded9afe0e35ee6f (diff)
downloadqmk_firmware-c50009d5d4909d55f5511378ba5bf0b4623a0a1c.tar.gz
qmk_firmware-c50009d5d4909d55f5511378ba5bf0b4623a0a1c.zip
[keymap] curly quotes (#9662)
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
-rw-r--r--keyboards/planck/keymaps/callum/config.h0
-rw-r--r--keyboards/planck/keymaps/callum/keymap.c127
-rw-r--r--keyboards/planck/keymaps/callum/readme.md8
-rw-r--r--keyboards/planck/keymaps/callum/rules.mk26
4 files changed, 94 insertions, 67 deletions
diff --git a/keyboards/planck/keymaps/callum/config.h b/keyboards/planck/keymaps/callum/config.h
deleted file mode 100644
index e69de29bb..000000000
--- a/keyboards/planck/keymaps/callum/config.h
+++ /dev/null
diff --git a/keyboards/planck/keymaps/callum/keymap.c b/keyboards/planck/keymaps/callum/keymap.c
index 4db54577b..d9fe43f00 100644
--- a/keyboards/planck/keymaps/callum/keymap.c
+++ b/keyboards/planck/keymaps/callum/keymap.c
@@ -49,7 +49,7 @@
49#define bspc KC_BSPC 49#define bspc KC_BSPC
50#define caps KC_CAPS 50#define caps KC_CAPS
51#define comm KC_COMM 51#define comm KC_COMM
52#define dash A(KC_MINS) 52#define dash A(KC_MINS) // en-dash (–); or with shift: em-dash (—)
53#define scln KC_SCLN 53#define scln KC_SCLN
54#define slsh KC_SLSH 54#define slsh KC_SLSH
55#define spc KC_SPC 55#define spc KC_SPC
@@ -60,7 +60,6 @@
60#define mins KC_MINS 60#define mins KC_MINS
61#define quot KC_QUOT 61#define quot KC_QUOT
62#define esc KC_ESC 62#define esc KC_ESC
63#define gbp A(KC_3)
64 63
65#define down KC_DOWN 64#define down KC_DOWN
66#define home G(KC_LEFT) 65#define home G(KC_LEFT)
@@ -75,8 +74,8 @@
75#define tabr G(S(KC_RBRC)) 74#define tabr G(S(KC_RBRC))
76#define fwd G(KC_RBRC) 75#define fwd G(KC_RBRC)
77#define back G(KC_LBRC) 76#define back G(KC_LBRC)
78#define slup S(A(KC_UP)) 77#define slup S(A(KC_UP)) // Previous unread in Slack
79#define sldn S(A(KC_DOWN)) 78#define sldn S(A(KC_DOWN)) // Next unread in Slack
80 79
81#define ctl1 C(KC_1) 80#define ctl1 C(KC_1)
82#define ctl2 C(KC_2) 81#define ctl2 C(KC_2)
@@ -137,6 +136,7 @@ enum planck_layers {
137}; 136};
138 137
139enum planck_keycodes { 138enum planck_keycodes {
139 // ASCII
140 ampr = SAFE_RANGE, 140 ampr = SAFE_RANGE,
141 astr, 141 astr,
142 at, 142 at,
@@ -158,6 +158,11 @@ enum planck_keycodes {
158 rprn, 158 rprn,
159 tild, 159 tild,
160 160
161 // Curly quotes
162 lcqt,
163 rcqt,
164
165 // "Smart" mods
161 cmd, 166 cmd,
162}; 167};
163 168
@@ -171,7 +176,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
171 176
172 [SYMB] = LAYOUT_planck_grid( 177 [SYMB] = LAYOUT_planck_grid(
173 esc, n7, n5, n3, n1, n9, n8, n0, n2, n4, n6, dash, 178 esc, n7, n5, n3, n1, n9, n8, n0, n2, n4, n6, dash,
174 del, at, dlr, eql, lprn, lbrc, rbrc, rprn, astr, hash, plus, gbp, 179 lcqt, at, dlr, eql, lprn, lbrc, rbrc, rprn, astr, hash, plus, rcqt,
175 ____, grv, pipe, bsls, lcbr, tild, circ, rcbr, ampr, exlm, perc, ____, 180 ____, grv, pipe, bsls, lcbr, tild, circ, rcbr, ampr, exlm, perc, ____,
176 ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____ 181 ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____
177 ), 182 ),
@@ -191,78 +196,112 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
191 ), 196 ),
192}; 197};
193 198
194bool send_string_if_keydown(keyrecord_t *record, const char *s) { 199bool send_string_if_keydown(
200 keyrecord_t *record,
201 const char *unshifted,
202 const char *shifted) {
195 if (record->event.pressed) { 203 if (record->event.pressed) {
196 send_string(s); 204 if (shifted) {
205 uint8_t shifts = get_mods() & MOD_MASK_SHIFT;
206 if (shifts) {
207 del_mods(shifts);
208 SEND_STRING(shifted);
209 add_mods(shifts);
210 } else {
211 SEND_STRING(unshifted);
212 }
213 } else {
214 SEND_STRING(unshifted);
215 }
197 } 216 }
198 return true; 217 return true;
199} 218}
200 219
201int cmd_keys_down = 0; 220// Holding both cmd keys will instead register as cmd + ctl
221bool smart_cmd(keyrecord_t *record) {
222 static int cmd_keys_down = 0;
223
224 if (record->event.pressed) {
225 if (cmd_keys_down == 0) {
226 register_code(KC_LCMD);
227 } else {
228 register_code(KC_LCTL);
229 }
230 cmd_keys_down++;
231 } else {
232 if (cmd_keys_down == 1) {
233 unregister_code(KC_LCMD);
234 } else {
235 unregister_code(KC_LCTL);
236 }
237 cmd_keys_down--;
238 }
239 return true;
240}
202 241
203bool process_record_user(uint16_t keycode, keyrecord_t *record) { 242bool process_record_user(uint16_t keycode, keyrecord_t *record) {
204 switch (keycode) { 243 switch (keycode) {
205 // Override the defualt auto shifted symbols to use SEND_STRING See 244 // Override the defualt auto shifted symbols to use SEND_STRING See
206 // https://github.com/qmk/qmk_firmware/issues/4072 245 // https://github.com/qmk/qmk_firmware/issues/4072
207 case ampr: 246 case ampr:
208 return send_string_if_keydown(record, "&"); 247 return send_string_if_keydown(record, "&", NULL);
209 case astr: 248 case astr:
210 return send_string_if_keydown(record, "*"); 249 return send_string_if_keydown(record, "*", NULL);
211 case at: 250 case at:
212 return send_string_if_keydown(record, "@"); 251 return send_string_if_keydown(record, "@", NULL);
213 case bsls: 252 case bsls:
214 return send_string_if_keydown(record, "\\"); 253 return send_string_if_keydown(record, "\\", NULL);
215 case circ: 254 case circ:
216 return send_string_if_keydown(record, "^"); 255 return send_string_if_keydown(record, "^", NULL);
217 case dlr: 256 case dlr:
218 return send_string_if_keydown(record, "$"); 257 return send_string_if_keydown(record, "$", NULL);
219 case eql: 258 case eql:
220 return send_string_if_keydown(record, "="); 259 return send_string_if_keydown(record, "=", NULL);
221 case exlm: 260 case exlm:
222 return send_string_if_keydown(record, "!"); 261 return send_string_if_keydown(record, "!", NULL);
223 case grv: 262 case grv:
224 return send_string_if_keydown(record, "`"); 263 return send_string_if_keydown(record, "`", NULL);
225 case hash: 264 case hash:
226 return send_string_if_keydown(record, "#"); 265 return send_string_if_keydown(record, "#", NULL);
227 case lbrc: 266 case lbrc:
228 return send_string_if_keydown(record, "["); 267 return send_string_if_keydown(record, "[", NULL);
229 case lcbr: 268 case lcbr:
230 return send_string_if_keydown(record, "{"); 269 return send_string_if_keydown(record, "{", NULL);
231 case lprn: 270 case lprn:
232 return send_string_if_keydown(record, "("); 271 return send_string_if_keydown(record, "(", NULL);
233 case perc: 272 case perc:
234 return send_string_if_keydown(record, "%"); 273 return send_string_if_keydown(record, "%", NULL);
235 case pipe: 274 case pipe:
236 return send_string_if_keydown(record, "|"); 275 return send_string_if_keydown(record, "|", NULL);
237 case plus: 276 case plus:
238 return send_string_if_keydown(record, "+"); 277 return send_string_if_keydown(record, "+", NULL);
239 case rbrc: 278 case rbrc:
240 return send_string_if_keydown(record, "]"); 279 return send_string_if_keydown(record, "]", NULL);
241 case rcbr: 280 case rcbr:
242 return send_string_if_keydown(record, "}"); 281 return send_string_if_keydown(record, "}", NULL);
243 case rprn: 282 case rprn:
244 return send_string_if_keydown(record, ")"); 283 return send_string_if_keydown(record, ")", NULL);
245 case tild: 284 case tild:
246 return send_string_if_keydown(record, "~"); 285 return send_string_if_keydown(record, "~", NULL);
286
287 // The macOS shortcuts for curly quotes are horrible, so this rebinds
288 // them so that shift toggles single–double instead of left–right, and
289 // then both varieties of left quote can share one key, and both
290 // varieties of right quote share another.
291 case lcqt:
292 return send_string_if_keydown(
293 record,
294 SS_LALT("]"), // left single quote (‘)
295 SS_LALT("[")); // left double quote (“)
296 case rcqt:
297 return send_string_if_keydown(
298 record,
299 SS_LALT(SS_LSFT("]")), // right single quote (’)
300 SS_LALT(SS_LSFT("["))); // right double quote (”)
247 301
248 // cmd + cmd -> cmd + ctl 302 // cmd + cmd -> cmd + ctl
249 case cmd: 303 case cmd:
250 if (record->event.pressed) { 304 return smart_cmd(record);
251 if (cmd_keys_down == 0) {
252 register_code(KC_LCMD);
253 } else {
254 register_code(KC_LCTL);
255 }
256 cmd_keys_down++;
257 } else {
258 if (cmd_keys_down == 1) {
259 unregister_code(KC_LCMD);
260 } else {
261 unregister_code(KC_LCTL);
262 }
263 cmd_keys_down--;
264 }
265 return true;
266 } 305 }
267 return true; 306 return true;
268} 307}
diff --git a/keyboards/planck/keymaps/callum/readme.md b/keyboards/planck/keymaps/callum/readme.md
index 561901b48..471de2b74 100644
--- a/keyboards/planck/keymaps/callum/readme.md
+++ b/keyboards/planck/keymaps/callum/readme.md
@@ -1,4 +1,4 @@
1# callum's planck layout 1# callums planck layout
2 2
3This is a layout for the grid planck, built with a few ideals in mind: 3This is a layout for the grid planck, built with a few ideals in mind:
4 4
@@ -23,8 +23,8 @@ This is a layout for the grid planck, built with a few ideals in mind:
23 23
24- Symbols should be arranged so that the most frequently used are easiest to 24- Symbols should be arranged so that the most frequently used are easiest to
25 reach. This includes numbers, and lower numbers are more commonly used than 25 reach. This includes numbers, and lower numbers are more commonly used than
26 higher ones. (number arrangement borrowed from [dustypomeleau's minidox 26 higher ones. (number arrangement borrowed from [dustypomeleaus minidox
27 layout][]. 27 layout][]).
28 28
29[dustypomeleau's minidox layout]: https://github.com/qmk/qmk_firmware/tree/master/keyboards/minidox/keymaps/dustypomerleau 29[dustypomeleaus minidox layout]: https://github.com/qmk/qmk_firmware/tree/master/keyboards/minidox/keymaps/dustypomerleau
30[keymap.c]: keymap.c 30[keymap.c]: keymap.c
diff --git a/keyboards/planck/keymaps/callum/rules.mk b/keyboards/planck/keymaps/callum/rules.mk
index db87d5ece..9615222d1 100644
--- a/keyboards/planck/keymaps/callum/rules.mk
+++ b/keyboards/planck/keymaps/callum/rules.mk
@@ -1,19 +1,7 @@
1# Build Options 1BOOTMAGIC_ENABLE = no
2# change to "no" to disable the options, or define them in the Makefile in 2MOUSEKEY_ENABLE = no
3# the appropriate keymap folder that will get included automatically 3CONSOLE_ENABLE = no
4# 4COMMAND_ENABLE = yes
5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) 5MIDI_ENABLE = no
6MOUSEKEY_ENABLE = no # Mouse keys(+4700) 6AUDIO_ENABLE = yes
7EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 7RGBLIGHT_ENABLE = no
8CONSOLE_ENABLE = no # Console for debug(+400)
9COMMAND_ENABLE = yes # Commands for debug and configuration
10NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
12MIDI_ENABLE = no # MIDI controls
13AUDIO_ENABLE = yes # Audio output on port C6
14UNICODE_ENABLE = no # Unicode
15BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
16RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
17
18# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
19SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend