Repository navigation
Conversation
Add -led CLI option accepting scroll, num, caps values (comma-separated). Multiple LEDs can be active simultaneously. Default remains scroll lock to preserve backward compatibility. Changes: - layout_indicator: replace set_scroll_lock_state with generic set_indicator_leds that iterates an ACTIVE_LEDS bitmask - cli: extract_led_option parses -led from args, background_command_line preserves the setting when re-launching - main: apply LED mask before starting indicator - console_log, interactive_menu: generalize LED label text Closes holgertkey#2
Change ACTIVE_LEDS default from LED_SCROLL to 0, so no indicator is used unless the user explicitly passes -led. This allows a 'no LEDs' configuration that was not possible before.
Without the marker, set_key_toggle(VK_CAPITAL) sends a CapsLock press that the keyboard hook sees as an external injection, blocks it, and triggers an unwanted layout switch — causing -led caps to immediately revert after every switch.
Replace SendInput-based LED toggling with IOCTL_KEYBOARD_SET_INDICATORS which talks directly to the keyboard class driver. This decouples the physical LED from the OS toggle state, fixing the CapsLock LED indicator issue where toggling the LED also changed the CapsLock typing state. The IOCTL approach: - Opens \\Device\\KeyboardClass0 via DefineDosDevice + CreateFile - Uses DeviceIoControl to set LED flags directly on the hardware - Does NOT require admin privileges (FILE_ANY_ACCESS) - Works on USB keyboards (kbdclass -> kbdhid -> HID output report) - Handle is opened lazily and cached for the process lifetime - Cleaned up on shutdown (CloseHandle + DefineDosDevice remove) This applies to ALL LED types (scroll, num, caps), not just CapsLock. Scroll Lock and Num Lock indicators also no longer affect their respective toggle states.
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.
This closes #2.
-ledoption allows to choose LEDs for indication:scroll,num,capsNo indication by default, multiple LEDs are possible.
Had to change approach of LED toggling to avoid unwanted keyboard behavior.
Please squash on merge.