Skip to content

Commit

Permalink
[OS Detection] Add hacky support for weirdness
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Jan 31, 2024
1 parent d198dbe commit effa43b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion quantum/os_detection.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void make_guess(void) {
} else if (setups_data.count == setups_data.cnt_ff) {
// Linux has 3 packets with 0xFF.
guessed = OS_LINUX;
} else if (setups_data.count >= 5 && setups_data.last_wlength == 0xFF && setups_data.cnt_ff == 1 && setups_data.cnt_02 >= 2) {
} else if (setups_data.count >= 5 && setups_data.last_wlength == 0xFF && setups_data.cnt_ff >= 1 && setups_data.cnt_02 >= 2) {
guessed = OS_MACOS;
} else if (setups_data.count == 4 && setups_data.cnt_ff == 0 && setups_data.cnt_02 == 2) {
// iOS and iPadOS don't have the last 0xFF packet.
Expand Down
8 changes: 8 additions & 0 deletions quantum/os_detection/tests/os_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void assert_reported(os_variant_t os) {
Windows 10: [FF, FF, 4, 24, 4, 24, 4, FF, 24, FF, 4, FF, 24, 4, 24, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A]
Windows 10 (another host): [FF, FF, 4, 24, 4, 24, 4, 24, 4, 24, 4, 24]
macOS 12.5: [2, 24, 2, 28, FF]
[ 2, 42, 2, 1C, 2, 1A, FF, 2, 42, 2, 1C, 2, 1A, FF]
iOS/iPadOS 15.6: [2, 24, 2, 28]
Linux (including Android, Raspberry Pi and WebOS TV): [FF, FF, FF]
PS5: [2, 4, 2, 28, 2, 24]
Expand Down Expand Up @@ -119,6 +120,13 @@ TEST_F(OsDetectionTest, TestChibiosMacos2) {
assert_not_reported();
}

TEST_F(OsDetectionTest, TestChibiosMacos3) {
EXPECT_EQ(check_sequence({ 0x2, 0x42, 0x2, 0x1C, 0x2, 0x1A, 0xFF, 0x2, 0x42, 0x2, 0x1C, 0x2, 0x1A, 0xFF}), OS_MACOS);
os_detection_task();
assert_not_reported();
}


TEST_F(OsDetectionTest, TestLufaMacos) {
EXPECT_EQ(check_sequence({0x2, 0x10, 0x2, 0xE, 0xFF}), OS_MACOS);
os_detection_task();
Expand Down

0 comments on commit effa43b

Please sign in to comment.