diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio/song_list.h | 3 | ||||
| -rw-r--r-- | quantum/process_keycode/process_terminal.c | 252 | ||||
| -rw-r--r-- | quantum/process_keycode/process_terminal.h | 27 | ||||
| -rw-r--r-- | quantum/process_keycode/process_terminal_nop.h | 25 | ||||
| -rw-r--r-- | quantum/quantum.c | 73 | ||||
| -rw-r--r-- | quantum/quantum.h | 25 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 5 | ||||
| -rw-r--r-- | quantum/send_string_keycodes.h | 168 |
8 files changed, 565 insertions, 13 deletions
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index 5ad543ca7..25e66e67c 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h | |||
| @@ -248,4 +248,7 @@ | |||
| 248 | Q__NOTE(_GS5), \ | 248 | Q__NOTE(_GS5), \ |
| 249 | HD_NOTE(_C6), | 249 | HD_NOTE(_C6), |
| 250 | 250 | ||
| 251 | #define TERMINAL_SOUND \ | ||
| 252 | E__NOTE(_C5 ) | ||
| 253 | |||
| 251 | #endif | 254 | #endif |
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c new file mode 100644 index 000000000..deb1543e3 --- /dev/null +++ b/quantum/process_keycode/process_terminal.c | |||
| @@ -0,0 +1,252 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_terminal.h" | ||
| 18 | #include <string.h> | ||
| 19 | #include "version.h" | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <math.h> | ||
| 22 | |||
| 23 | bool terminal_enabled = false; | ||
| 24 | char buffer[80] = ""; | ||
| 25 | char newline[2] = "\n"; | ||
| 26 | char arguments[6][20]; | ||
| 27 | |||
| 28 | __attribute__ ((weak)) | ||
| 29 | const char terminal_prompt[8] = "> "; | ||
| 30 | |||
| 31 | #ifdef AUDIO_ENABLE | ||
| 32 | #ifndef TERMINAL_SONG | ||
| 33 | #define TERMINAL_SONG SONG(TERMINAL_SOUND) | ||
| 34 | #endif | ||
| 35 | float terminal_song[][2] = TERMINAL_SONG; | ||
| 36 | #define TERMINAL_BELL() PLAY_SONG(terminal_song) | ||
| 37 | #else | ||
| 38 | #define TERMINAL_BELL() | ||
| 39 | #endif | ||
| 40 | |||
| 41 | __attribute__ ((weak)) | ||
| 42 | const char keycode_to_ascii_lut[58] = { | ||
| 43 | 0, 0, 0, 0, | ||
| 44 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', | ||
| 45 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', | ||
| 46 | '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t', | ||
| 47 | ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/' | ||
| 48 | }; | ||
| 49 | |||
| 50 | __attribute__ ((weak)) | ||
| 51 | const char shifted_keycode_to_ascii_lut[58] = { | ||
| 52 | 0, 0, 0, 0, | ||
| 53 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', | ||
| 54 | 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', | ||
| 55 | '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t', | ||
| 56 | ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?' | ||
| 57 | }; | ||
| 58 | |||
| 59 | struct stringcase { | ||
| 60 | char* string; | ||
| 61 | void (*func)(void); | ||
| 62 | } typedef stringcase; | ||
| 63 | |||
| 64 | void enable_terminal(void) { | ||
| 65 | terminal_enabled = true; | ||
| 66 | strcpy(buffer, ""); | ||
| 67 | for (int i = 0; i < 6; i++) | ||
| 68 | strcpy(arguments[i], ""); | ||
| 69 | // select all text to start over | ||
| 70 | // SEND_STRING(SS_LCTRL("a")); | ||
| 71 | send_string(terminal_prompt); | ||
| 72 | } | ||
| 73 | |||
| 74 | void disable_terminal(void) { | ||
| 75 | terminal_enabled = false; | ||
| 76 | } | ||
| 77 | |||
| 78 | void terminal_about(void) { | ||
| 79 | SEND_STRING("QMK Firmware\n"); | ||
| 80 | SEND_STRING(" v"); | ||
| 81 | SEND_STRING(QMK_VERSION); | ||
| 82 | SEND_STRING("\n"SS_TAP(X_HOME)" Built: "); | ||
| 83 | SEND_STRING(QMK_BUILDDATE); | ||
| 84 | send_string(newline); | ||
| 85 | #ifdef TERMINAL_HELP | ||
| 86 | if (strlen(arguments[1]) != 0) { | ||
| 87 | SEND_STRING("You entered: "); | ||
| 88 | send_string(arguments[1]); | ||
| 89 | send_string(newline); | ||
| 90 | } | ||
| 91 | #endif | ||
| 92 | } | ||
| 93 | |||
| 94 | void terminal_help(void); | ||
| 95 | |||
| 96 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||
| 97 | |||
| 98 | void terminal_keycode(void) { | ||
| 99 | if (strlen(arguments[1]) != 0 && strlen(arguments[2]) != 0 && strlen(arguments[3]) != 0) { | ||
| 100 | char keycode_dec[5]; | ||
| 101 | char keycode_hex[5]; | ||
| 102 | uint16_t layer = strtol(arguments[1], (char **)NULL, 10); | ||
| 103 | uint16_t row = strtol(arguments[2], (char **)NULL, 10); | ||
| 104 | uint16_t col = strtol(arguments[3], (char **)NULL, 10); | ||
| 105 | uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]); | ||
| 106 | itoa(keycode, keycode_dec, 10); | ||
| 107 | itoa(keycode, keycode_hex, 16); | ||
| 108 | SEND_STRING("0x"); | ||
| 109 | send_string(keycode_hex); | ||
| 110 | SEND_STRING(" ("); | ||
| 111 | send_string(keycode_dec); | ||
| 112 | SEND_STRING(")\n"); | ||
| 113 | } else { | ||
| 114 | #ifdef TERMINAL_HELP | ||
| 115 | SEND_STRING("usage: keycode <layer> <row> <col>\n"); | ||
| 116 | #endif | ||
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 120 | void terminal_keymap(void) { | ||
| 121 | if (strlen(arguments[1]) != 0) { | ||
| 122 | uint16_t layer = strtol(arguments[1], (char **)NULL, 10); | ||
| 123 | for (int r = 0; r < MATRIX_ROWS; r++) { | ||
| 124 | for (int c = 0; c < MATRIX_COLS; c++) { | ||
| 125 | uint16_t keycode = pgm_read_word(&keymaps[layer][r][c]); | ||
| 126 | char keycode_s[8]; | ||
| 127 | sprintf(keycode_s, "0x%04x, ", keycode); | ||
| 128 | send_string(keycode_s); | ||
| 129 | } | ||
| 130 | send_string(newline); | ||
| 131 | } | ||
| 132 | } else { | ||
| 133 | #ifdef TERMINAL_HELP | ||
| 134 | SEND_STRING("usage: keymap <layer>\n"); | ||
| 135 | #endif | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | stringcase terminal_cases[] = { | ||
| 140 | { "about", terminal_about }, | ||
| 141 | { "help", terminal_help }, | ||
| 142 | { "keycode", terminal_keycode }, | ||
| 143 | { "keymap", terminal_keymap }, | ||
| 144 | { "exit", disable_terminal } | ||
| 145 | }; | ||
| 146 | |||
| 147 | void terminal_help(void) { | ||
| 148 | SEND_STRING("commands available:\n "); | ||
| 149 | for( stringcase* case_p = terminal_cases; case_p != terminal_cases + sizeof( terminal_cases ) / sizeof( terminal_cases[0] ); case_p++ ) { | ||
| 150 | send_string(case_p->string); | ||
| 151 | SEND_STRING(" "); | ||
| 152 | } | ||
| 153 | send_string(newline); | ||
| 154 | } | ||
| 155 | |||
| 156 | void command_not_found(void) { | ||
| 157 | SEND_STRING("command \""); | ||
| 158 | send_string(buffer); | ||
| 159 | SEND_STRING("\" not found\n"); | ||
| 160 | } | ||
| 161 | |||
| 162 | void process_terminal_command(void) { | ||
| 163 | // we capture return bc of the order of events, so we need to manually send a newline | ||
| 164 | send_string(newline); | ||
| 165 | |||
| 166 | char * pch; | ||
| 167 | uint8_t i = 0; | ||
| 168 | pch = strtok(buffer, " "); | ||
| 169 | while (pch != NULL) { | ||
| 170 | strcpy(arguments[i], pch); | ||
| 171 | pch = strtok(NULL, " "); | ||
| 172 | i++; | ||
| 173 | } | ||
| 174 | |||
| 175 | bool command_found = false; | ||
| 176 | for( stringcase* case_p = terminal_cases; case_p != terminal_cases + sizeof( terminal_cases ) / sizeof( terminal_cases[0] ); case_p++ ) { | ||
| 177 | if( 0 == strcmp( case_p->string, buffer ) ) { | ||
| 178 | command_found = true; | ||
| 179 | (*case_p->func)(); | ||
| 180 | break; | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | if (!command_found) | ||
| 185 | command_not_found(); | ||
| 186 | |||
| 187 | if (terminal_enabled) { | ||
| 188 | strcpy(buffer, ""); | ||
| 189 | for (int i = 0; i < 6; i++) | ||
| 190 | strcpy(arguments[i], ""); | ||
| 191 | SEND_STRING(SS_TAP(X_HOME)); | ||
| 192 | send_string(terminal_prompt); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | bool process_terminal(uint16_t keycode, keyrecord_t *record) { | ||
| 197 | |||
| 198 | if (keycode == TERM_ON && record->event.pressed) { | ||
| 199 | enable_terminal(); | ||
| 200 | return false; | ||
| 201 | } | ||
| 202 | |||
| 203 | if (terminal_enabled && record->event.pressed) { | ||
| 204 | if (keycode == TERM_OFF && record->event.pressed) { | ||
| 205 | disable_terminal(); | ||
| 206 | return false; | ||
| 207 | } | ||
| 208 | if (keycode < 256) { | ||
| 209 | uint8_t str_len; | ||
| 210 | char char_to_add; | ||
| 211 | switch (keycode) { | ||
| 212 | case KC_ENTER: | ||
| 213 | process_terminal_command(); | ||
| 214 | return false; break; | ||
| 215 | case KC_ESC: | ||
| 216 | SEND_STRING("\n"); | ||
| 217 | enable_terminal(); | ||
| 218 | return false; break; | ||
| 219 | case KC_BSPC: | ||
| 220 | str_len = strlen(buffer); | ||
| 221 | if (str_len > 0) { | ||
| 222 | buffer[str_len-1] = 0; | ||
| 223 | return true; | ||
| 224 | } else { | ||
| 225 | TERMINAL_BELL(); | ||
| 226 | return false; | ||
| 227 | } break; | ||
| 228 | case KC_LEFT: | ||
| 229 | case KC_RIGHT: | ||
| 230 | case KC_UP: | ||
| 231 | case KC_DOWN: | ||
| 232 | return false; break; | ||
| 233 | default: | ||
| 234 | if (keycode <= 58) { | ||
| 235 | char_to_add = 0; | ||
| 236 | if (get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) { | ||
| 237 | char_to_add = shifted_keycode_to_ascii_lut[keycode]; | ||
| 238 | } else if (get_mods() == 0) { | ||
| 239 | char_to_add = keycode_to_ascii_lut[keycode]; | ||
| 240 | } | ||
| 241 | if (char_to_add != 0) { | ||
| 242 | strncat(buffer, &char_to_add, 1); | ||
| 243 | } | ||
| 244 | } break; | ||
| 245 | } | ||
| 246 | |||
| 247 | |||
| 248 | |||
| 249 | } | ||
| 250 | } | ||
| 251 | return true; | ||
| 252 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_terminal.h b/quantum/process_keycode/process_terminal.h new file mode 100644 index 000000000..d945949a4 --- /dev/null +++ b/quantum/process_keycode/process_terminal.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef PROCESS_TERMINAL_H | ||
| 18 | #define PROCESS_TERMINAL_H | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | |||
| 22 | extern const char keycode_to_ascii_lut[58]; | ||
| 23 | extern const char shifted_keycode_to_ascii_lut[58]; | ||
| 24 | extern const char terminal_prompt[8]; | ||
| 25 | bool process_terminal(uint16_t keycode, keyrecord_t *record); | ||
| 26 | |||
| 27 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_terminal_nop.h b/quantum/process_keycode/process_terminal_nop.h new file mode 100644 index 000000000..56895b33c --- /dev/null +++ b/quantum/process_keycode/process_terminal_nop.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef PROCESS_TERMINAL_H | ||
| 18 | #define PROCESS_TERMINAL_H | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | |||
| 22 | #define TERM_ON KC_NO | ||
| 23 | #define TERM_OFF KC_NO | ||
| 24 | |||
| 25 | #endif \ No newline at end of file | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 285e1e81e..1fccaa7d5 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -238,6 +238,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 238 | #ifdef UNICODEMAP_ENABLE | 238 | #ifdef UNICODEMAP_ENABLE |
| 239 | process_unicode_map(keycode, record) && | 239 | process_unicode_map(keycode, record) && |
| 240 | #endif | 240 | #endif |
| 241 | #ifdef TERMINAL_ENABLE | ||
| 242 | process_terminal(keycode, record) && | ||
| 243 | #endif | ||
| 241 | true)) { | 244 | true)) { |
| 242 | return false; | 245 | return false; |
| 243 | } | 246 | } |
| @@ -600,21 +603,55 @@ void send_string(const char *str) { | |||
| 600 | send_string_with_delay(str, 0); | 603 | send_string_with_delay(str, 0); |
| 601 | } | 604 | } |
| 602 | 605 | ||
| 606 | void send_string_P(const char *str) { | ||
| 607 | send_string_with_delay_P(str, 0); | ||
| 608 | } | ||
| 609 | |||
| 603 | void send_string_with_delay(const char *str, uint8_t interval) { | 610 | void send_string_with_delay(const char *str, uint8_t interval) { |
| 604 | while (1) { | 611 | while (1) { |
| 605 | uint8_t keycode; | 612 | char ascii_code = *str; |
| 606 | uint8_t ascii_code = pgm_read_byte(str); | ||
| 607 | if (!ascii_code) break; | 613 | if (!ascii_code) break; |
| 608 | keycode = pgm_read_byte(&ascii_to_keycode_lut[ascii_code]); | 614 | if (ascii_code == 1) { |
| 609 | if (pgm_read_byte(&ascii_to_shift_lut[ascii_code])) { | 615 | // tap |
| 610 | register_code(KC_LSFT); | 616 | uint8_t keycode = *(++str); |
| 611 | register_code(keycode); | 617 | register_code(keycode); |
| 612 | unregister_code(keycode); | 618 | unregister_code(keycode); |
| 613 | unregister_code(KC_LSFT); | 619 | } else if (ascii_code == 2) { |
| 620 | // down | ||
| 621 | uint8_t keycode = *(++str); | ||
| 622 | register_code(keycode); | ||
| 623 | } else if (ascii_code == 3) { | ||
| 624 | // up | ||
| 625 | uint8_t keycode = *(++str); | ||
| 626 | unregister_code(keycode); | ||
| 627 | } else { | ||
| 628 | send_char(ascii_code); | ||
| 614 | } | 629 | } |
| 615 | else { | 630 | ++str; |
| 616 | register_code(keycode); | 631 | // interval |
| 617 | unregister_code(keycode); | 632 | { uint8_t ms = interval; while (ms--) wait_ms(1); } |
| 633 | } | ||
| 634 | } | ||
| 635 | |||
| 636 | void send_string_with_delay_P(const char *str, uint8_t interval) { | ||
| 637 | while (1) { | ||
| 638 | char ascii_code = pgm_read_byte(str); | ||
| 639 | if (!ascii_code) break; | ||
| 640 | if (ascii_code == 1) { | ||
| 641 | // tap | ||
| 642 | uint8_t keycode = pgm_read_byte(++str); | ||
| 643 | register_code(keycode); | ||
| 644 | unregister_code(keycode); | ||
| 645 | } else if (ascii_code == 2) { | ||
| 646 | // down | ||
| 647 | uint8_t keycode = pgm_read_byte(++str); | ||
| 648 | register_code(keycode); | ||
| 649 | } else if (ascii_code == 3) { | ||
| 650 | // up | ||
| 651 | uint8_t keycode = pgm_read_byte(++str); | ||
| 652 | unregister_code(keycode); | ||
| 653 | } else { | ||
| 654 | send_char(ascii_code); | ||
| 618 | } | 655 | } |
| 619 | ++str; | 656 | ++str; |
| 620 | // interval | 657 | // interval |
| @@ -622,6 +659,20 @@ void send_string_with_delay(const char *str, uint8_t interval) { | |||
| 622 | } | 659 | } |
| 623 | } | 660 | } |
| 624 | 661 | ||
| 662 | void send_char(char ascii_code) { | ||
| 663 | uint8_t keycode; | ||
| 664 | keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); | ||
| 665 | if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) { | ||
| 666 | register_code(KC_LSFT); | ||
| 667 | register_code(keycode); | ||
| 668 | unregister_code(keycode); | ||
| 669 | unregister_code(KC_LSFT); | ||
| 670 | } else { | ||
| 671 | register_code(keycode); | ||
| 672 | unregister_code(keycode); | ||
| 673 | } | ||
| 674 | } | ||
| 675 | |||
| 625 | void set_single_persistent_default_layer(uint8_t default_layer) { | 676 | void set_single_persistent_default_layer(uint8_t default_layer) { |
| 626 | #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) | 677 | #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) |
| 627 | PLAY_SONG(default_layer_songs[default_layer]); | 678 | PLAY_SONG(default_layer_songs[default_layer]); |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 9a6d691a1..f3333a002 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | #include "action_util.h" | 40 | #include "action_util.h" |
| 41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
| 42 | #include "print.h" | 42 | #include "print.h" |
| 43 | 43 | #include "send_string_keycodes.h" | |
| 44 | 44 | ||
| 45 | extern uint32_t default_layer_state; | 45 | extern uint32_t default_layer_state; |
| 46 | 46 | ||
| @@ -103,11 +103,32 @@ extern uint32_t default_layer_state; | |||
| 103 | #include "process_key_lock.h" | 103 | #include "process_key_lock.h" |
| 104 | #endif | 104 | #endif |
| 105 | 105 | ||
| 106 | #define SEND_STRING(str) send_string(PSTR(str)) | 106 | #ifdef TERMINAL_ENABLE |
| 107 | #include "process_terminal.h" | ||
| 108 | #else | ||
| 109 | #include "process_terminal_nop.h" | ||
| 110 | #endif | ||
| 111 | |||
| 112 | #define STRINGIZE(z) #z | ||
| 113 | #define ADD_SLASH_X(y) STRINGIZE(\x ## y) | ||
| 114 | #define SYMBOL_STR(x) ADD_SLASH_X(x) | ||
| 115 | |||
| 116 | #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode) | ||
| 117 | #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode) | ||
| 118 | #define SS_UP(keycode) "\3" SYMBOL_STR(keycode) | ||
| 119 | |||
| 120 | #define SS_LCTRL(string) SS_DOWN(X_LCTRL) string SS_UP(X_LCTRL) | ||
| 121 | #define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI) | ||
| 122 | #define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT) | ||
| 123 | |||
| 124 | #define SEND_STRING(str) send_string_P(PSTR(str)) | ||
| 107 | extern const bool ascii_to_shift_lut[0x80]; | 125 | extern const bool ascii_to_shift_lut[0x80]; |
| 108 | extern const uint8_t ascii_to_keycode_lut[0x80]; | 126 | extern const uint8_t ascii_to_keycode_lut[0x80]; |
| 109 | void send_string(const char *str); | 127 | void send_string(const char *str); |
| 110 | void send_string_with_delay(const char *str, uint8_t interval); | 128 | void send_string_with_delay(const char *str, uint8_t interval); |
| 129 | void send_string_P(const char *str); | ||
| 130 | void send_string_with_delay_P(const char *str, uint8_t interval); | ||
| 131 | void send_char(char ascii_code); | ||
| 111 | 132 | ||
| 112 | // For tri-layer | 133 | // For tri-layer |
| 113 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); | 134 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index ccd4565f5..26c3c41a7 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -431,6 +431,11 @@ enum quantum_keycodes { | |||
| 431 | KC_LOCK, | 431 | KC_LOCK, |
| 432 | #endif | 432 | #endif |
| 433 | 433 | ||
| 434 | #ifdef TERMINAL_ENABLE | ||
| 435 | TERM_ON, | ||
| 436 | TERM_OFF, | ||
| 437 | #endif | ||
| 438 | |||
| 434 | // always leave at the end | 439 | // always leave at the end |
| 435 | SAFE_RANGE | 440 | SAFE_RANGE |
| 436 | }; | 441 | }; |
diff --git a/quantum/send_string_keycodes.h b/quantum/send_string_keycodes.h new file mode 100644 index 000000000..0e308be50 --- /dev/null +++ b/quantum/send_string_keycodes.h | |||
| @@ -0,0 +1,168 @@ | |||
| 1 | #ifndef SEND_STRING_KEYCODES | ||
| 2 | #define SEND_STRING_KEYCODES | ||
| 3 | |||
| 4 | #define X_NO 00 | ||
| 5 | #define X_ROLL_OVER 01 | ||
| 6 | #define X_POST_FAIL 02 | ||
| 7 | #define X_UNDEFINED 03 | ||
| 8 | #define X_A 04 | ||
| 9 | #define X_B 05 | ||
| 10 | #define X_C 06 | ||
| 11 | #define X_D 07 | ||
| 12 | #define X_E 08 | ||
| 13 | #define X_F 09 | ||
| 14 | #define X_G 0A | ||
| 15 | #define X_H 0B | ||
| 16 | #define X_I 0C | ||
| 17 | #define X_J 0D | ||
| 18 | #define X_K 0E | ||
| 19 | #define X_L 0F | ||
| 20 | #define X_M 10 | ||
| 21 | #define X_N 11 | ||
| 22 | #define X_O 12 | ||
| 23 | #define X_P 13 | ||
| 24 | #define X_Q 14 | ||
| 25 | #define X_R 15 | ||
| 26 | #define X_S 16 | ||
| 27 | #define X_T 17 | ||
| 28 | #define X_U 18 | ||
| 29 | #define X_V 19 | ||
| 30 | #define X_W 1A | ||
| 31 | #define X_X 1B | ||
| 32 | #define X_Y 1C | ||
| 33 | #define X_Z 1D | ||
| 34 | #define X_1 1E | ||
| 35 | #define X_2 1F | ||
| 36 | #define X_3 20 | ||
| 37 | #define X_4 21 | ||
| 38 | #define X_5 22 | ||
| 39 | #define X_6 23 | ||
| 40 | #define X_7 24 | ||
| 41 | #define X_8 25 | ||
| 42 | #define X_9 26 | ||
| 43 | #define X_0 27 | ||
| 44 | #define X_ENTER 28 | ||
| 45 | #define X_ESCAPE 29 | ||
| 46 | #define X_BSPACE 2A | ||
| 47 | #define X_TAB 2B | ||
| 48 | #define X_SPACE 2C | ||
| 49 | #define X_MINUS 2D | ||
| 50 | #define X_EQUAL 2E | ||
| 51 | #define X_LBRACKET 2F | ||
| 52 | #define X_RBRACKET 30 | ||
| 53 | #define X_BSLASH 31 | ||
| 54 | #define X_NONUS_HASH 32 | ||
| 55 | #define X_SCOLON 33 | ||
| 56 | #define X_QUOTE 34 | ||
| 57 | #define X_GRAVE 35 | ||
| 58 | #define X_COMMA 36 | ||
| 59 | #define X_DOT 37 | ||
| 60 | #define X_SLASH 38 | ||
| 61 | #define X_CAPSLOCK 39 | ||
| 62 | #define X_F1 3A | ||
| 63 | #define X_F2 3B | ||
| 64 | #define X_F3 3C | ||
| 65 | #define X_F4 3D | ||
| 66 | #define X_F5 3E | ||
| 67 | #define X_F6 3F | ||
| 68 | #define X_F7 40 | ||
| 69 | #define X_F8 41 | ||
| 70 | #define X_F9 42 | ||
| 71 | #define X_F10 43 | ||
| 72 | #define X_F11 44 | ||
| 73 | #define X_F12 45 | ||
| 74 | #define X_PSCREEN 46 | ||
| 75 | #define X_SCROLLLOCK 47 | ||
| 76 | #define X_PAUSE 48 | ||
| 77 | #define X_INSERT 49 | ||
| 78 | #define X_HOME 4A | ||
| 79 | #define X_PGUP 4B | ||
| 80 | #define X_DELETE 4C | ||
| 81 | #define X_END 4D | ||
| 82 | #define X_PGDOWN 4E | ||
| 83 | #define X_RIGHT 4F | ||
| 84 | #define X_LEFT 50 | ||
| 85 | #define X_DOWN 51 | ||
| 86 | #define X_UP 52 | ||
| 87 | #define X_NUMLOCK 53 | ||
| 88 | #define X_KP_SLASH 54 | ||
| 89 | #define X_KP_ASTERISK 55 | ||
| 90 | #define X_KP_MINUS 56 | ||
| 91 | #define X_KP_PLUS 57 | ||
| 92 | #define X_KP_ENTER 58 | ||
| 93 | #define X_KP_1 59 | ||
| 94 | #define X_KP_2 5A | ||
| 95 | #define X_KP_3 5B | ||
| 96 | #define X_KP_4 5C | ||
| 97 | #define X_KP_5 5D | ||
| 98 | #define X_KP_6 5E | ||
| 99 | #define X_KP_7 5F | ||
| 100 | #define X_KP_8 60 | ||
| 101 | #define X_KP_9 61 | ||
| 102 | #define X_KP_0 62 | ||
| 103 | #define X_KP_DOT 63 | ||
| 104 | #define X_NONUS_BSLASH 64 | ||
| 105 | #define X_APPLICATION 65 | ||
| 106 | #define X_POWER 66 | ||
| 107 | #define X_KP_EQUAL 67 | ||
| 108 | #define X_F13 68 | ||
| 109 | #define X_F14 69 | ||
| 110 | #define X_F15 6A | ||
| 111 | #define X_F16 6B | ||
| 112 | #define X_F17 6C | ||
| 113 | #define X_F18 6D | ||
| 114 | #define X_F19 6E | ||
| 115 | #define X_F20 6F | ||
| 116 | #define X_F21 70 | ||
| 117 | #define X_F22 71 | ||
| 118 | #define X_F23 72 | ||
| 119 | #define X_F24 73 | ||
| 120 | #define X_EXECUTE 74 | ||
| 121 | #define X_HELP 75 | ||
| 122 | #define X_MENU 76 | ||
| 123 | #define X_SELECT 77 | ||
| 124 | #define X_STOP 78 | ||
| 125 | #define X_AGAIN 79 | ||
| 126 | #define X_UNDO 7A | ||
| 127 | #define X_CUT 7B | ||
| 128 | #define X_COPY 7C | ||
| 129 | #define X_PASTE 7D | ||
| 130 | #define X_FIND 7E | ||
| 131 | #define X__MUTE 7F | ||
| 132 | #define X__VOLUP 80 | ||
| 133 | #define X__VOLDOWN 81 | ||
| 134 | #define X_LOCKING_CAPS 82 | ||
| 135 | #define X_LOCKING_NUM 83 | ||
| 136 | #define X_LOCKING_SCROLL 84 | ||
| 137 | #define X_KP_COMMA 85 | ||
| 138 | #define X_KP_EQUAL_AS400 86 | ||
| 139 | #define X_INT1 87 | ||
| 140 | #define X_INT2 88 | ||
| 141 | #define X_INT3 89 | ||
| 142 | #define X_INT4 8A | ||
| 143 | #define X_INT5 8B | ||
| 144 | #define X_INT6 8C | ||
| 145 | #define X_INT7 8D | ||
| 146 | #define X_INT8 8E | ||
| 147 | #define X_INT9 8F | ||
| 148 | #define X_LANG1 90 | ||
| 149 | #define X_LANG2 91 | ||
| 150 | #define X_LANG3 92 | ||
| 151 | #define X_LANG4 93 | ||
| 152 | #define X_LANG5 94 | ||
| 153 | #define X_LANG6 95 | ||
| 154 | #define X_LANG7 96 | ||
| 155 | #define X_LANG8 97 | ||
| 156 | #define X_LANG9 98 | ||
| 157 | |||
| 158 | /* Modifiers */ | ||
| 159 | #define X_LCTRL e0 | ||
| 160 | #define X_LSHIFT e1 | ||
| 161 | #define X_LALT e2 | ||
| 162 | #define X_LGUI e3 | ||
| 163 | #define X_RCTRL e4 | ||
| 164 | #define X_RSHIFT e5 | ||
| 165 | #define X_RALT e6 | ||
| 166 | #define X_RGUI e7 | ||
| 167 | |||
| 168 | #endif \ No newline at end of file | ||
