diff --git a/docs/macros.md b/docs/macros.md index 1418d24a..bbf51434 100644 --- a/docs/macros.md +++ b/docs/macros.md @@ -41,7 +41,7 @@ A macro can include the following commands: ## Sending strings -Sometimes you just want a key to type out words or phrases. For the most common situations we've provided `SEND_STRING()`, which will type out your string for you instead of having to build a `MACRO()`. Right now it assumes a US keymap with a QWERTY layout, so if you are using something else it may not behave as you expect. +Sometimes you just want a key to type out words or phrases. For the most common situations we've provided `SEND_STRING()`, which will type out your string for you instead of having to build a `MACRO()`. For example: @@ -58,6 +58,12 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { }; ``` +By default, it assumes a US keymap with a QWERTY layout; if you want to change that (e.g. if your OS uses software Colemak), include this somewhere in your keymap: + +``` +#include +``` + ## Mapping a Macro to a key Use the `M()` function within your `KEYMAP()` to call a macro. For example, here is the keymap for a 2-key keyboard: diff --git a/keyboards/planck/keymaps/rai-suta/Makefile b/keyboards/planck/keymaps/rai-suta/Makefile index 5238d320..38efe374 100644 --- a/keyboards/planck/keymaps/rai-suta/Makefile +++ b/keyboards/planck/keymaps/rai-suta/Makefile @@ -20,9 +20,6 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend -# Option defines -OPT_DEFS += -DSENDSTRING_JIS_KEYCODE - ifndef QUANTUM_DIR include ../../../../Makefile endif \ No newline at end of file diff --git a/keyboards/planck/keymaps/rai-suta/keymap.c b/keyboards/planck/keymaps/rai-suta/keymap.c index 13fc3677..3206ffd3 100644 --- a/keyboards/planck/keymaps/rai-suta/keymap.c +++ b/keyboards/planck/keymaps/rai-suta/keymap.c @@ -3,6 +3,8 @@ #include "planck.h" #include "version.h" +#include "sendstring_jis.h" + // Keycode defines #define _______ KC_TRNS #define XXXXXXX KC_NO diff --git a/quantum/keymap_extras/sendstring_colemak.h b/quantum/keymap_extras/sendstring_colemak.h new file mode 100644 index 00000000..fa9ace92 --- /dev/null +++ b/quantum/keymap_extras/sendstring_colemak.h @@ -0,0 +1,41 @@ +/* Copyright 2016 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +/* Sendstring definitions for the Colemak layout */ +#ifndef SENDSTRING_COLEMAK +#define SENDSTRING_COLEMAK + +#include "keymap_colemak.h" + +const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, KC_ESC, 0, 0, 0, 0, + KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, + KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, + KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH, + KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, + CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, + CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, + CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS, + KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, + CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, + CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, + CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL +}; + +#endif diff --git a/quantum/keymap_extras/sendstring_dvorak.h b/quantum/keymap_extras/sendstring_dvorak.h new file mode 100644 index 00000000..f5c5c818 --- /dev/null +++ b/quantum/keymap_extras/sendstring_dvorak.h @@ -0,0 +1,41 @@ +/* Copyright 2016 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +/* Sendstring definitions for the Dvorak layout */ +#ifndef SENDSTRING_DVORAK +#define SENDSTRING_DVORAK + +#include "keymap_dvorak.h" + +const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, KC_ESC, 0, 0, 0, 0, + KC_SPC, DV_1, DV_QUOT, DV_3, DV_4, DV_5, DV_7, DV_QUOT, + DV_9, DV_0, DV_8, DV_EQL, DV_COMM, DV_MINS, DV_DOT, DV_SLSH, + DV_0, DV_1, DV_2, DV_3, DV_4, DV_5, DV_6, DV_7, + DV_8, DV_9, DV_SCLN, DV_SCLN, DV_COMM, DV_EQL, DV_DOT, DV_SLSH, + DV_2, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G, + DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O, + DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W, + DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_6, DV_MINS, + DV_GRV, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G, + DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O, + DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W, + DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_GRV, KC_DEL +}; + +#endif diff --git a/quantum/keymap_extras/sendstring_jis.h b/quantum/keymap_extras/sendstring_jis.h new file mode 100644 index 00000000..c5a38c6a --- /dev/null +++ b/quantum/keymap_extras/sendstring_jis.h @@ -0,0 +1,58 @@ +/* Copyright 2016 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +/* Sendstring definitions for the JIS keyboard layout */ +#ifndef SENDSTRING_JIS +#define SENDSTRING_JIS + +const bool ascii_to_shift_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 0 +}; + +const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, + KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, KC_ESC, 0, 0, 0, 0, + KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, + KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, + KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, + KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, + KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, + KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_RO, + KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, + KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, + KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, + KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_DEL, +}; + +#endif diff --git a/quantum/quantum.c b/quantum/quantum.c index b5acc75c..36e586d3 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -455,28 +455,7 @@ bool process_record_quantum(keyrecord_t *record) { return process_action_kb(record); } -#if defined SENDSTRING_JIS_KEYCODE -/* for users with JIS keyboards */ -const bool ascii_to_shift_lut[0x80] PROGMEM = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 0 -}; -#else -/* for standard keycodes */ +__attribute__ ((weak)) const bool ascii_to_shift_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -495,72 +474,8 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 }; -#endif -#if defined SENDSTRING_JIS_KEYCODE -/* for users with JIS keyboards */ -const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { - 0, 0, 0, 0, 0, 0, 0, 0, - KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, KC_ESC, 0, 0, 0, 0, - KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, - KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, - KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, - KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, - KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, - KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, - KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, - KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_RO, - KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, - KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, - KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, - KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_DEL, -}; -#elif defined SENDSTRING_COLEMAK_KEYCODE -/* for users whose OSes are set to Colemak */ -#include "keymap_colemak.h" -const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { - 0, 0, 0, 0, 0, 0, 0, 0, - KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, KC_ESC, 0, 0, 0, 0, - KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, - KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, - KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, - KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH, - KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, - CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, - CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, - CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS, - KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, - CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, - CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, - CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL -}; -#elif defined SENDSTRING_DVORAK_KEYCODE -/* for users whose OSes are set to Dvorak */ -#include "keymap_dvorak.h" -const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { - 0, 0, 0, 0, 0, 0, 0, 0, - KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, KC_ESC, 0, 0, 0, 0, - KC_SPC, DV_1, DV_QUOT, DV_3, DV_4, DV_5, DV_7, DV_QUOT, - DV_9, DV_0, DV_8, DV_EQL, DV_COMM, DV_MINS, DV_DOT, DV_SLSH, - DV_0, DV_1, DV_2, DV_3, DV_4, DV_5, DV_6, DV_7, - DV_8, DV_9, DV_SCLN, DV_SCLN, DV_COMM, DV_EQL, DV_DOT, DV_SLSH, - DV_2, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G, - DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O, - DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W, - DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_6, DV_MINS, - DV_GRV, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G, - DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O, - DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W, - DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_GRV, KC_DEL -}; -#else -/* For users with default keyboard layout in OS */ +__attribute__ ((weak)) const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, @@ -579,7 +494,6 @@ const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL }; -#endif void send_string(const char *str) { send_string_with_delay(str, 0); diff --git a/quantum/quantum.h b/quantum/quantum.h index 1dafbf3b..e00fe234 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -95,6 +95,8 @@ extern uint32_t default_layer_state; #endif #define SEND_STRING(str) send_string(PSTR(str)) +extern const bool ascii_to_shift_lut[0x80]; +extern const uint8_t ascii_to_keycode_lut[0x80]; void send_string(const char *str); void send_string_with_delay(const char *str, uint8_t interval);