Skip to content

FR: Caps Lock signal handling #5

@mayurankv

Description

@mayurankv

I would love a way for the caps lock led state to be modified in Kanata. I'm not familiar with rust or C++ so I wasn't able to fully understand the code but I was wondering if there was a way to send an event like:

  • event::type::caps_lock_state_changed (on) is sent via krbn::event_queue::utility::make_queue in karabiner_grabber

Thanks for any help!

P.S. This is from the following example in the Karabiner documents:

### The flow of handling caps lock as modifier

Example:

```json
{
    "from": {
        "key_code": "down_arrow",
        "modifiers": {
            "mandatory": ["caps_lock"],
            "optional": ["any"]
        }
    },
    "to": [
        {
            "key_code": "d"
        }
    ],
    "type": "basic"
}
```

-   Press the physical caps_lock key (`hid::usage::keyboard_or_keypad::keyboard_caps_lock`)
    -   `key_event_dispatcher` is updated.
        -   `pressed_keys_.insert(caps_lock)`
    -   macOS update the caps lock LED state (on).
    -   `event::type::caps_lock_state_changed (on)` is sent via `krbn::event_queue::utility::make_queue` in `karabiner_grabber`.
        -   `modifier_flag_manager increase_led_lock (caps_lock)`
        -   `key_event_dispatcher` is updated.
            -   `pressed_modifier_flags_.insert(caps_lock)`
-   Release the physical caps_lock key (`hid::usage::keyboard_or_keypad::keyboard_caps_lock`)
    -   `key_event_dispatcher` is updated.
        -   `pressed_keys_.erase(caps_lock)`
-   Press `down_arrow` key.j
    -   `sticky_modifier caps_lock false` is sent by `modifiers.mandatory`.
        -   `modifier_flag_manager decrease_sticky (caps_lock)`
    -   `hid::usage::keyboard_or_keypad::keyboard_caps_lock` is sent via virtual hid keyboard.
    -   `key_event_dispatcher` is updated.
        -   `pressed_modifier_flags_.erase(caps_lock)`
    -   `d` is sent via virtual hid keyboard.
    -   sticky_modifiers are erased.
    -   `sticky_modifier caps_lock true` is sent by `modifiers.mandatory`.
        -   `modifier_flag_manager increase_sticky (caps_lock)`
    -   macOS update the caps lock LED state (off).
    -   `event::type::caps_lock_state_changed (off)` is sent via `krbn::event_queue::utility::make_queue` in `karabiner_grabber`.
        -   `modifier_flag_manager decrease_led_lock (caps_lock)`
            -   Note: led_lock will be ignored while other counter is active in modifier_flag_manager.
-   Release `down_arrow` key.
    -   `d` is sent via virtual hid keyboard.
-   Press `tab` key.
    -   `hid::usage::keyboard_or_keypad::keyboard_caps_lock` is sent via virtual hid keyboard by sticky_modifier.
    -   sticky_modifiers are erased.
    -   `tab` is sent via virtual hid keyboard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions