Add AltGr/RALT support to Send String

master
Drashna Jaelre 2018-10-02 11:08:41 -07:00 committed by skullydazed
parent 6832a067ef
commit a2090d5e86
1 changed files with 34 additions and 9 deletions

View File

@ -850,6 +850,26 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = {
0, 0, 0, 1, 1, 1, 1, 0 0, 0, 0, 1, 1, 1, 1, 0
}; };
__attribute__ ((weak))
const bool ascii_to_alt_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)) __attribute__ ((weak))
const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -932,16 +952,21 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
void send_char(char ascii_code) { void send_char(char ascii_code) {
uint8_t keycode; uint8_t keycode;
bool is_shifted;
bool is_alted;
keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) { if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) { is_shifted = true; } else { is_shifted = false; }
register_code(KC_LSFT); if (pgm_read_byte(&ascii_to_alt_lut[(uint8_t)ascii_code])) { is_alted = true; } else { is_alted = false; }
if (is_shifted) { register_code(KC_LSFT); }
if (is_alted) { register_code(KC_RALT); }
register_code(keycode); register_code(keycode);
unregister_code(keycode); unregister_code(keycode);
unregister_code(KC_LSFT);
} else { if (is_alted) { unregister_code(KC_RALT); }
register_code(keycode); if (is_shifted) { unregister_code(KC_LSFT); }
unregister_code(keycode);
}
} }
void set_single_persistent_default_layer(uint8_t default_layer) { void set_single_persistent_default_layer(uint8_t default_layer) {