[OS Detection] Improve MacOS detection (#24708)
This commit is contained in:
parent
ea3a968510
commit
8bf01dd796
2 changed files with 55 additions and 8 deletions
|
@ -133,7 +133,7 @@ void process_wlength(const uint16_t w_length) {
|
|||
} 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.
|
||||
|
|
|
@ -68,8 +68,12 @@ ChibiOS:
|
|||
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]
|
||||
macOS 15.1.x: [ 2, 4E, 2, 1C, 2, 1A, FF, FF]
|
||||
macOS 15.x (another host): [ 2, 0E, 2, 1E, 2, 42, FF]
|
||||
macOS 15.x (periodic weirdness): [ 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]
|
||||
Linux (another host): [FF, FF, FF, FF, FF, FF]
|
||||
PS5: [2, 4, 2, 28, 2, 24]
|
||||
Nintendo Switch: [82, FF, 40, 40, FF, 40, 40, FF, 40, 40, FF, 40, 40, FF, 40, 40]
|
||||
Quest 2: [FF, FF, FF, FE, FF, FE, FF, FE, FF, FE, FF]
|
||||
|
@ -79,6 +83,7 @@ Windows 10 (first connect): [12, FF, FF, 4, 10, FF, FF, FF, 4, 10, 20A, 20A, 20A
|
|||
Windows 10 (subsequent connect): [FF, FF, 4, 10, FF, 4, FF, 10, FF, 20A, 20A, 20A, 20A, 20A, 20A]
|
||||
Windows 10 (another host): [FF, FF, 4, 10, 4, 10]
|
||||
macOS: [2, 10, 2, E, FF]
|
||||
macOS 15.x: [ 2, 64, 2, 28, FF, FF]
|
||||
iOS/iPadOS: [2, 10, 2, E]
|
||||
Linux: [FF, FF, FF]
|
||||
PS5: [2, 4, 2, E, 2, 10]
|
||||
|
@ -109,18 +114,67 @@ TEST_F(OsDetectionTest, TestLinux) {
|
|||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestChibiosLinux) {
|
||||
EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}), OS_LINUX);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestChibiosMacos) {
|
||||
EXPECT_EQ(check_sequence({0x2, 0x24, 0x2, 0x28, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestChibiosMacos2) {
|
||||
EXPECT_EQ(check_sequence({0x2, 0x42, 0x2, 0x1C, 0x2, 0x1A, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
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();
|
||||
}
|
||||
|
||||
// Regression reported in https://github.com/qmk/qmk_firmware/pull/21777#issuecomment-1922815841
|
||||
TEST_F(OsDetectionTest, TestChibiosMacM1) {
|
||||
EXPECT_EQ(check_sequence({0x02, 0x32, 0x02, 0x24, 0x101, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestChibiosMacSequoia) {
|
||||
EXPECT_EQ(check_sequence({0x02, 0x4E, 0x02, 0x1C, 0x02, 0x1A, 0xFF, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestChibiosMacSequoia2) {
|
||||
EXPECT_EQ(check_sequence({0x02, 0x4E, 0x02, 0x1C, 0x02, 0x1A, 0xFF, 0x02, 0x42, 0x02, 0x1C, 0x02, 0x1A, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestChibiosMacSequoia3) {
|
||||
EXPECT_EQ(check_sequence({0x02, 0x0E, 0x02, 0x1E, 0x02, 0x42, 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();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestDetectLufaMacSequoia2) {
|
||||
EXPECT_EQ(check_sequence({0x02, 0x64, 0x02, 0x28, 0xFF, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestVusbMacos) {
|
||||
EXPECT_EQ(check_sequence({0x2, 0xE, 0x2, 0xE, 0xFF}), OS_MACOS);
|
||||
os_detection_task();
|
||||
|
@ -235,13 +289,6 @@ TEST_F(OsDetectionTest, TestVusbQuest2) {
|
|||
assert_not_reported();
|
||||
}
|
||||
|
||||
// Regression reported in https://github.com/qmk/qmk_firmware/pull/21777#issuecomment-1922815841
|
||||
TEST_F(OsDetectionTest, TestDetectMacM1AsIOS) {
|
||||
EXPECT_EQ(check_sequence({0x02, 0x32, 0x02, 0x24, 0x101, 0xFF}), OS_IOS);
|
||||
os_detection_task();
|
||||
assert_not_reported();
|
||||
}
|
||||
|
||||
TEST_F(OsDetectionTest, TestDoNotReportIfUsbUnstable) {
|
||||
EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE}), OS_LINUX);
|
||||
os_detection_task();
|
||||
|
|
Loading…
Add table
Reference in a new issue