]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add AltGr/RALT support to Send String
authorDrashna Jaelre <drashna@live.com>
Tue, 2 Oct 2018 18:08:41 +0000 (11:08 -0700)
committerskullydazed <skullydazed@users.noreply.github.com>
Fri, 12 Apr 2019 21:07:05 +0000 (14:07 -0700)
quantum/quantum.c

index a4ccccd00dd1735ac5b435c67fe114fa119e98c5..0fe918b36511250f17d88dacf32a444e78217a02 100644 (file)
@@ -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_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))
 const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
     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) {
   uint8_t keycode;
+  bool is_shifted;
+  bool is_alted;
+
   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);
-  }
+  if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) { is_shifted = true; } else { is_shifted = false; }
+ 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);
+  unregister_code(keycode);
+
+  if (is_alted) { unregister_code(KC_RALT); }
+  if (is_shifted) { unregister_code(KC_LSFT); }
 }
 
 void set_single_persistent_default_layer(uint8_t default_layer) {