Skip to content

Commit

Permalink
Merge pull request #7 from ErgoDox-EZ/alt_gr_send_string
Browse files Browse the repository at this point in the history
Alt gr send string
  • Loading branch information
fdidron committed Apr 16, 2019
2 parents 7a5cbca + 72537dd commit 7b19fcc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
04-12-2019 - Port DIRECT_PINS from split_common/matrix.c to matrix.c (qmk#5091)
04-12-2019 - Add AltGr/RALT support to Send String #4046
04-12-2019 - Port DIRECT_PINS from split_common/matrix.c to matrix.c (qmk#5091)
46 changes: 36 additions & 10 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,26 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = {
0, 0, 0, 1, 1, 1, 1, 0
};

__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,
Expand Down Expand Up @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7b19fcc

Please sign in to comment.