extract our ascii lookup table function. (saves 16 bytes)

pull/365/head
Jesse Vincent 7 years ago
parent d7a889f25e
commit cd847a7ead
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -115,12 +115,8 @@ static const Key ascii_to_key_map[] PROGMEM = {
LSHIFT(Key_Backtick), LSHIFT(Key_Backtick),
}; };
void Macros_::type(const char *string) {
while (true) {
uint8_t ascii_code = pgm_read_byte(string++);
if (!ascii_code)
break;
Key Macros_::lookupAsciiCode(uint8_t ascii_code) {
Key key = Key_NoKey; Key key = Key_NoKey;
switch (ascii_code) { switch (ascii_code) {
@ -159,6 +155,17 @@ void Macros_::type(const char *string) {
key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x7B + 29]); key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x7B + 29]);
break; break;
} }
return key;
}
void Macros_::type(const char *string) {
while (true) {
uint8_t ascii_code = pgm_read_byte(string++);
if (!ascii_code)
break;
Key key = lookupAsciiCode(ascii_code);
if (key.raw == Key_NoKey.raw) if (key.raw == Key_NoKey.raw)
continue; continue;

@ -17,6 +17,9 @@ class Macros_ : public KaleidoscopePlugin {
void type(const char *string); void type(const char *string);
static byte row, col; static byte row, col;
private:
Key lookupAsciiCode(uint8_t ascii_code);
}; };
extern Macros_ Macros; extern Macros_ Macros;

Loading…
Cancel
Save