Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion quantum/unicode/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ void send_unicode_string(const char *str) {
int32_t code_point = 0;
str = decode_utf8(str, &code_point);

if (code_point >= 0) {
if (code_point > 0 && code_point < 0x80 && pgm_read_byte(&ascii_to_keycode_lut[code_point]) != XXXXXXX) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the actual keycode.

Suggested change
if (code_point > 0 && code_point < 0x80 && pgm_read_byte(&ascii_to_keycode_lut[code_point]) != XXXXXXX) {
if (code_point > 0 && code_point < 0x80 && pgm_read_byte(&ascii_to_keycode_lut[code_point]) != KC_NO) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is also better encapsulated if its implemented within quantum/send_string/send_string.{h,c} as something like is_valid_send_char().

send_char(code_point);
} else if (code_point >= 0) {
register_unicode(code_point);
}
}
Expand Down
24 changes: 24 additions & 0 deletions tests/unicode/test_unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,27 @@ TEST_F(Unicode, sends_unicode_string) {

VERIFY_AND_CLEAR(driver);
}

TEST_F(Unicode, sends_unicode_string_ascii_with_keycodes) {
TestDriver driver;

set_unicode_input_mode(UNICODE_MODE_LINUX);

{
testing::InSequence s;

EXPECT_REPORT(driver, (KC_A));
EXPECT_EMPTY_REPORT(driver);
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_A, KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_EMPTY_REPORT(driver);
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_1, KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_EMPTY_REPORT(driver);
}
send_unicode_string("aA!");

VERIFY_AND_CLEAR(driver);
}