-
Notifications
You must be signed in to change notification settings - Fork 53
Num Lock, Caps Lock and Scroll Lock
HASUMI Hitoshi edited this page May 17, 2022
·
1 revision
0.9.14+
You can get a callback when the status of "Num Lock", "Caps Lock" and "Scroll Lock" in the host device is changed.
led_pin = 25 # It's the on-board LED of Raspi Pico
gpio_init led_pin
gpio_set_dir led_pin, Keyboard::GPIO_OUT
gpio_put led_pin, 0
kbd.output_report_changed do |output|
gpio_put led_pin, (output & Keyboard::LED_CAPSLOCK > 0 ? 1 : 0)
end
rgb.effect = :breath
rgb.hue = 0
rgb.speed = 25
kbd.append rgb
kbd.output_report_changed do |output|
if output & Keyboard::LED_CAPSLOCK > 0
rgb.hue = 100
else
rgb.hue = 0
end
end
See RGBLED for details.
The block variable output
in the above examples has the status that you can extract by bit operation:
output: 0b11111
^ Num Lock
^ Caps Lock
^ Scroll Lock
^ Compose
^ Kana
If a bit is 1
, the corresponding function is locked in the host PC.
Keycode | Alias | Mask constant | Value |
---|---|---|---|
:KC_NUMLOCK | :KC_NLCK | Keyboard::LED_NUMLOCK | 0b00001 |
:KC_CAPSLOCK | :KC_CAPS | Keyboard::LED_CAPSLOCK | 0b00010 |
:KC_SCROLLLOCK | :KC_SLCK | Keyboard::LED_SCROLLLOCK | 0b00100 |
N/A | N/A | Keyboard::LED_COMPOSE | 0b01000 |
N/A | N/A | Keyboard::LED_KANA | 0b10000 |
LED_COMPOSE and LED_KANA are implemented according to the HID descriptor though, dev team hasn't check the actual function.
- Getting started
- Keyboard features
- Keycodes (ja)
- Mouse (ja)
- Layers and mode key (ja)
- Debounce
- Composite key
- Split-type keyboard
- Keyscan matrix
- Num Lock, Caps Lock and Scroll Lock
- Useful methods that make you free
- BIOS mode
- Other features
- Examples
- Development
- Contribute to the Wiki
- FAQ