summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-04-12 14:54:40 -0700
committerDrashna Jaelre <drashna@live.com>2019-04-12 14:54:40 -0700
commit6e57437c42867d666e51dc6502efa59b7cf2c000 (patch)
treefe3c74f66832c350ea34ddc94daac24627d0a0fa /quantum
parentea4581cef15acc949aad2fffde8af61de81f10b6 (diff)
Add AltGr/RALT support to Send String qmk#4046)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.c46
-rw-r--r--quantum/quantum.h1
2 files changed, 37 insertions, 10 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index a62368ded2..4d8d2482d0 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -851,6 +851,26 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = {
};
__attribute__ ((weak))
+const bool ascii_to_altgr_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, 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, 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, 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
+};
+
+__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,
@@ -931,16 +951,22 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
}
void send_char(char ascii_code) {
- uint8_t keycode;
- keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
- if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) {
- register_code(KC_LSFT);
- register_code(keycode);
- unregister_code(keycode);
- unregister_code(KC_LSFT);
- } else {
- register_code(keycode);
- unregister_code(keycode);
+ uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
+ bool is_shifted = pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code]);
+ bool is_altgred = pgm_read_byte(&ascii_to_altgr_lut[(uint8_t)ascii_code]);
+
+ if (is_shifted) {
+ register_code(KC_LSFT);
+ }
+ if (is_altgred) {
+ register_code(KC_RALT);
+ }
+ tap_code(keycode);
+ if (is_altgred) {
+ unregister_code(KC_RALT);
+ }
+ if (is_shifted) {
+ unregister_code(KC_LSFT);
}
}
diff --git a/quantum/quantum.h b/quantum/quantum.h
index c7fce9a0f6..e2f467125e 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -206,6 +206,7 @@ extern uint32_t default_layer_state;
#define SEND_STRING(str) send_string_P(PSTR(str))
extern const bool ascii_to_shift_lut[0x80];
+extern const bool ascii_to_altgr_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);