[OS Detection] Don't classify MacOS sequences as Windows when cnt_02 >= 2#26303
Open
bin101 wants to merge 1 commit into
Open
[OS Detection] Don't classify MacOS sequences as Windows when cnt_02 >= 2#26303bin101 wants to merge 1 commit into
bin101 wants to merge 1 commit into
Conversation
macOS 26.x (ChibiOS) can send a late wLength=0x04 packet after the two 0xFF packets that already established OS_MACOS. The Windows check (cnt_ff >= 2 && cnt_04 >= 1) fired on this combination and overwrites the correct result. Real-world Windows sequences always start with 0xFF packets (cnt_02 = 0); macOS sequences always open with at least two 0x02 packets (cnt_02 >= 2). Adding && setups_data.cnt_02 < 2 to the Windows condition is sufficient to separate the two populations without affecting any existing detection. Adds a regression test for the affected sequence.
drashna
approved these changes
Jun 30, 2026
Author
|
@drashna How many reviews are required for a merge? |
Member
Usually 2 approvals before a merge. Also, this should probably target the develop branch, rather than master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes macOS 26.x being misidentified as Windows on ChibiOS keyboards
Description
On macOS 26.x with ChibiOS-based keyboards, the USB enumeration sends a late wLength=0x04 packet after the two 0xFF packets that already correctly established OS_MACOS. The existing Windows detection condition (cnt_ff >= 2 && cnt_04 >= 1) fires on this combination and permanently overwrites the correct result, causing the keyboard to report OS_WINDOWS on macOS for the remainder of the session.
Observed sequence (ChibiOS, macOS 15.x):
[0x02, 0x22, 0x02, 0x0E, 0x02, 0x42, 0xFF, 0xFF, 0x04, 0xFF]
After packet #6 (0xFF), detected_os is correctly set to OS_MACOS (cnt_02=3, cnt_ff=1). At packet #8 (0x04), cnt_ff=2 and cnt_04=1 satisfy the Windows condition, overwriting OS_MACOS with OS_WINDOWS. The final 0xFF at packet #9 re-evaluates to OS_WINDOWS again. The debounced callback delivers the incorrect result.
Fix: Add setups_data.cnt_02 < 2 as a conjunct to the Windows detection condition. This is sufficient because:
These populations do not overlap. All existing Windows sequences in the test suite pass the new condition unchanged (cnt_02 = 0 in all cases).
A test case for the affected sequence has been added to
quantum/os_detection/tests/os_detection.cppTypes of Changes
Issues Fixed or Closed by This PR
Checklist