summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2019-11-26 18:16:58 +1100
committerDrashna Jaelre <drashna@live.com>2019-11-25 23:16:58 -0800
commit5a6737a778cfa828e4fdb5d382a84a41e5210d8e (patch)
tree0c746428a46df925b30675990aca209f59db2d9d
parenta2cedf4555ab417d849cbacf9562fd92407d5d71 (diff)
downloadqmk_firmware-5a6737a778cfa828e4fdb5d382a84a41e5210d8e.tar.gz
qmk_firmware-5a6737a778cfa828e4fdb5d382a84a41e5210d8e.zip
Send string keycode tweaks (#7471)
-rw-r--r--docs/feature_leader_key.md8
-rw-r--r--docs/feature_macros.md19
-rw-r--r--docs/feature_userspace.md10
-rw-r--r--keyboards/kmac/keymaps/default/keymap.c2
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi/keymap.c2
-rw-r--r--keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c2
-rw-r--r--quantum/process_keycode/process_terminal.c2
-rw-r--r--quantum/quantum.h24
-rw-r--r--quantum/send_string_keycodes.h32
-rw-r--r--quantum/template/base/keymaps/default/keymap.c2
10 files changed, 58 insertions, 45 deletions
diff --git a/docs/feature_leader_key.md b/docs/feature_leader_key.md
index 82cf789017..22370bf230 100644
--- a/docs/feature_leader_key.md
+++ b/docs/feature_leader_key.md
@@ -22,10 +22,10 @@ void matrix_scan_user(void) {
SEND_STRING("QMK is awesome.");
}
SEQ_TWO_KEYS(KC_D, KC_D) {
- SEND_STRING(SS_LCTRL("a")SS_LCTRL("c"));
+ SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
}
SEQ_THREE_KEYS(KC_D, KC_D, KC_S) {
- SEND_STRING("https://start.duckduckgo.com"SS_TAP(X_ENTER));
+ SEND_STRING("https://start.duckduckgo.com\n");
}
SEQ_TWO_KEYS(KC_A, KC_S) {
register_code(KC_LGUI);
@@ -115,11 +115,11 @@ void matrix_scan_user(void) {
SEQ_ONE_KEY(KC_E) {
// Anything you can do in a macro.
- SEND_STRING(SS_LCTRL(SS_LSFT("t")));
+ SEND_STRING(SS_LCTL(SS_LSFT("t")));
did_leader_succeed = true;
} else
SEQ_TWO_KEYS(KC_E, KC_D) {
- SEND_STRING(SS_LGUI("r")"cmd"SS_TAP(KC_ENTER)SS_LCTRL("c"));
+ SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c"));
did_leader_succeed = true;
}
leader_end();
diff --git a/docs/feature_macros.md b/docs/feature_macros.md
index d81c3c6559..c13ae82061 100644
--- a/docs/feature_macros.md
+++ b/docs/feature_macros.md
@@ -67,14 +67,14 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case QMKURL:
if (record->event.pressed) {
// when keycode QMKURL is pressed
- SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
+ SEND_STRING("https://qmk.fm/\n");
} else {
// when keycode QMKURL is released
}
break;
case MY_OTHER_MACRO:
if (record->event.pressed) {
- SEND_STRING(SS_LCTRL("ac")); // selects all and copies
+ SEND_STRING(SS_LCTL("ac")); // selects all and copies
}
break;
}
@@ -109,18 +109,21 @@ Which would send "VE" followed by a `KC_HOME` tap, and "LO" (spelling "LOVE" if
There's also a couple of mod shortcuts you can use:
-* `SS_LCTRL(string)`
-* `SS_LGUI(string)`
-* `SS_LALT(string)`
+* `SS_LCTL(string)`
* `SS_LSFT(string)`
-* `SS_RALT(string)`
+* `SS_LALT(string)`
+* `SS_LGUI(string)`, `SS_LCMD(string)` or `SS_LWIN(string)`
+* `SS_RCTL(string)`
+* `SS_RSFT(string)`
+* `SS_RALT(string)` or `SS_ALGR(string)`
+* `SS_RGUI(string)`, `SS_RCMD(string)` or `SS_RWIN(string)`
These press the respective modifier, send the supplied string and then release the modifier.
They can be used like this:
- SEND_STRING(SS_LCTRL("a"));
+ SEND_STRING(SS_LCTL("a"));
-Which would send LCTRL+a (LCTRL down, a, LCTRL up) - notice that they take strings (eg `"k"`), and not the `X_K` keycodes.
+Which would send Left Control+`a` (Left Control down, `a`, Left Control up) - notice that they take strings (eg `"k"`), and not the `X_K` keycodes.
### Alternative Keymaps
diff --git a/docs/feature_userspace.md b/docs/feature_userspace.md
index e162d423ce..a2657c1f60 100644
--- a/docs/feature_userspace.md
+++ b/docs/feature_userspace.md
@@ -208,15 +208,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
clear_mods(); clear_oneshot_mods();
SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP);
#ifndef FLASH_BOOTLOADER
- if ( (temp_mod | temp_osm) & MOD_MASK_SHIFT )
+ if ((temp_mod | temp_osm) & MOD_MASK_SHIFT)
#endif
- { //
+ {
SEND_STRING(":flash");
}
- if ( (temp_mod | temp_osm) & MOD_MASK_CTRL) {
- SEND_STRING(" -j8 --output-sync");
+ if ((temp_mod | temp_osm) & MOD_MASK_CTRL) {
+ SEND_STRING(" -j8 --output-sync");
}
- SEND_STRING(SS_TAP(X_ENTER));
+ tap_code(KC_ENT);
set_mods(temp_mod);
}
break;
diff --git a/keyboards/kmac/keymaps/default/keymap.c b/keyboards/kmac/keymaps/default/keymap.c
index 05ccd1bcb1..a67a4d10d3 100644
--- a/keyboards/kmac/keymaps/default/keymap.c
+++ b/keyboards/kmac/keymaps/default/keymap.c
@@ -73,7 +73,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
case MCR_04:
if (record->event.pressed) {
- SEND_STRING(SS_LCTRL("c") SS_TAP(X_RIGHT) SS_LCTRL("v"));
+ SEND_STRING(SS_LCTL("c") SS_TAP(X_RIGHT) SS_LCTL("v"));
}
break;
}
diff --git a/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c b/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c
index 05ccd1bcb1..a67a4d10d3 100644
--- a/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c
+++ b/keyboards/kmac/keymaps/default_tkl_ansi/keymap.c
@@ -73,7 +73,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
case MCR_04:
if (record->event.pressed) {
- SEND_STRING(SS_LCTRL("c") SS_TAP(X_RIGHT) SS_LCTRL("v"));
+ SEND_STRING(SS_LCTL("c") SS_TAP(X_RIGHT) SS_LCTL("v"));
}
break;
}
diff --git a/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c
index 42be547649..6b49585560 100644
--- a/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c
+++ b/keyboards/kmac/keymaps/default_tkl_ansi_wkl/keymap.c
@@ -73,7 +73,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
case MCR_04:
if (record->event.pressed) {
- SEND_STRING(SS_LCTRL("c") SS_TAP(X_RIGHT) SS_LCTRL("v"));
+ SEND_STRING(SS_LCTL("c") SS_TAP(X_RIGHT) SS_LCTL("v"));
}
break;
}
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c
index f48f3d702d..7d1eefa9ed 100644
--- a/quantum/process_keycode/process_terminal.c
+++ b/quantum/process_keycode/process_terminal.c
@@ -61,7 +61,7 @@ void enable_terminal(void) {
memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80);
for (int i = 0; i < 6; i++) strcpy(arguments[i], "");
// select all text to start over
- // SEND_STRING(SS_LCTRL("a"));
+ // SEND_STRING(SS_LCTL("a"));
send_string(terminal_prompt);
}
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 6beab65a32..91b9170b16 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -182,30 +182,8 @@ typedef ioline_t pin_t;
# define readPin(pin) palReadLine(pin)
#endif
-// Send string macros
-#define STRINGIZE(z) #z
-#define ADD_SLASH_X(y) STRINGIZE(\x##y)
-#define SYMBOL_STR(x) ADD_SLASH_X(x)
-
-#define SS_TAP_CODE 1
-#define SS_DOWN_CODE 2
-#define SS_UP_CODE 3
-
-#define SS_TAP(keycode) "\1" SYMBOL_STR(keycode)
-#define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode)
-#define SS_UP(keycode) "\3" SYMBOL_STR(keycode)
-
-// `string` arguments must not be parenthesized
-#define SS_LCTRL(string) SS_DOWN(X_LCTRL) string SS_UP(X_LCTRL)
-#define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
-#define SS_LCMD(string) SS_LGUI(string)
-#define SS_LWIN(string) SS_LGUI(string)
-#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
-#define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
-#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
-#define SS_ALGR(string) SS_RALT(string)
-
#define SEND_STRING(string) send_string_P(PSTR(string))
+#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
extern const bool ascii_to_shift_lut[128];
extern const bool ascii_to_altgr_lut[128];
diff --git a/quantum/send_string_keycodes.h b/quantum/send_string_keycodes.h
index e2deb980ae..fc6467a741 100644
--- a/quantum/send_string_keycodes.h
+++ b/quantum/send_string_keycodes.h
@@ -340,3 +340,35 @@
#define X_MEDIA_REWIND bc
#define X_BRIGHTNESS_UP bd
#define X_BRIGHTNESS_DOWN be
+
+// Send string macros
+#define STRINGIZE(z) #z
+#define ADD_SLASH_X(y) STRINGIZE(\x##y)
+#define SYMBOL_STR(x) ADD_SLASH_X(x)
+
+#define SS_TAP_CODE 1
+#define SS_DOWN_CODE 2
+#define SS_UP_CODE 3
+
+#define SS_TAP(keycode) "\1" SYMBOL_STR(keycode)
+#define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode)
+#define SS_UP(keycode) "\3" SYMBOL_STR(keycode)
+
+// `string` arguments must not be parenthesized
+#define SS_LCTL(string) SS_DOWN(X_LCTL) string SS_UP(X_LCTL)
+#define SS_LSFT(string) SS_DOWN(X_LSFT) string SS_UP(X_LSFT)
+#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
+#define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
+#define SS_LCMD(string) SS_LGUI(string)
+#define SS_LWIN(string) SS_LGUI(string)
+
+#define SS_RCTL(string) SS_DOWN(X_RCTL) string SS_UP(X_RCTL)
+#define SS_RSFT(string) SS_DOWN(X_RSFT) string SS_UP(X_RSFT)
+#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
+#define SS_RGUI(string) SS_DOWN(X_RGUI) string SS_UP(X_RGUI)
+#define SS_ALGR(string) SS_RALT(string)
+#define SS_RCMD(string) SS_RGUI(string)
+#define SS_RWIN(string) SS_RGUI(string)
+
+// DEPRECATED
+#define SS_LCTRL(string) SS_LCTL(string)
diff --git a/quantum/template/base/keymaps/default/keymap.c b/quantum/template/base/keymaps/default/keymap.c
index 3a68f5487c..af35ccec15 100644
--- a/quantum/template/base/keymaps/default/keymap.c
+++ b/quantum/template/base/keymaps/default/keymap.c
@@ -52,7 +52,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case QMKURL:
if (record->event.pressed) {
// when keycode QMKURL is pressed
- SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
+ SEND_STRING("https://qmk.fm/\n");
} else {
// when keycode QMKURL is released
}