Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized keys in Debug on MacOS #761

Open
1 task done
moritzketzer opened this issue Feb 21, 2024 · 4 comments
Open
1 task done

Unrecognized keys in Debug on MacOS #761

moritzketzer opened this issue Feb 21, 2024 · 4 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed macos Issue pertains to macos; jtroo has no macOS devices and does not maintain the support for it.

Comments

@moritzketzer
Copy link
Contributor

moritzketzer commented Feb 21, 2024

Requirements

Describe the bug

The debug output shows unrecognized keys. To reduce error sources I tried the minimal confic and the problem still persists.

Might a problem be specific function media keys?

For example, I have spotlight, dictation and a do not disturb key (which I think is not even properly mapped in Karabiner Elements).

Furthermore, KMonad has keys for launchpad = lp and mission control = mctl, which is missing in Kanata.

Would be nice to have them added.

I can help to find the issue on MacOS, but would need some pointers or guidance.

Here are the available media control keys in Karabiner-Elements:
CleanShot 2024-02-21 at 11 34 31@2x

Relevant kanata config

#|
This minimal config changes Caps Lock to act as Caps Lock on quick tap, but
if held, it will act as Left Ctrl. It also changes the backtick/grave key to
act as backtick/grave on quick tap, but change ijkl keys to arrow keys on hold.

This text between the two pipe+octothorpe sequences is a multi-line comment.
|#

;; Text after double-semicolons are single-line comments.

#|
One defcfg entry may be added, which is used for configuration key-pairs. These
configurations change kanata's behaviour at a more global level than the other
configuration entries.
|#

(defcfg
  #|
  This configuration will process all keys pressed inside of kanata, even if
  they are not mapped in defsrc. This is so that certain actions can activate
  at the right time for certain input sequences. By default, unmapped keys are
  not processed through kanata due to a Windows issue related to AltGr. If you
  use AltGr in your keyboard, you will likely want to follow the simple.kbd
  file while unmapping lctl and ralt from defsrc.
  |#
  process-unmapped-keys yes
)

(defsrc
  caps grv         i
              j    k    l
  lsft rsft
)

(deflayer default
  @cap @grv        _
              _    _    _
  _    _
)

(deflayer arrows
  _    _           up
              left down rght
  _    _
)

(defalias
  cap (tap-hold-press 200 200 caps lctl)
  grv (tap-hold-press 200 200 grv (layer-toggle arrows))
)

To Reproduce

  1. Execute sudo kanata -c minimal.kbd -t
  2. Press space

Expected behavior

All keys are recognized and don't populate the debugging output.

Kanata version

kanata v1.6.0-prerelease-1

Debug logs

WARNING: could not set log TZ to local: ConfigBuilder(Config { time: Error, level: Error, level_padding: Off, thread: Debug, thread_log_mode: IDs, thread_padding: Off, target: Debug, target_padding: Off, location: Trace, time_format: Custom([Hour(Hour { padding: Zero, is_12_hour_clock: false }), :, Minute(Minute { padding: Zero }), :, Second(Second { padding: Zero })]), time_offset: +00:00:00, filter_allow: [], filter_ignore: [], level_color: [None, Some(Red), Some(Yellow), Some(Blue), Some(Cyan), Some(White)], write_log_enable_colors: false })
2024-02-21T09:45:29.721294Z [INFO] kanata v1.6.0-prerelease-1 starting
2024-02-21T09:45:29.722007Z [INFO] process unmapped keys: true
2024-02-21T09:45:29.722139Z [DEBUG] (1) kanata_parser::cfg::alloc: freeing allocations of length 0
2024-02-21T09:45:29.723642Z [INFO] config file is valid
2024-02-21T09:45:29.723659Z [INFO] Sleeping for 2s. Please release all keys and don't press additional ones.
2024-02-21T09:45:31.728393Z [INFO] entering the processing loop
2024-02-21T09:45:31.728578Z [INFO] entering the event loop
2024-02-21T09:45:31.72885Z [INFO] Init: catching only releases and sending immediately
connected
driver_activated 1
driver_connected 0
driver_version_mismatched 0
2024-02-21T09:45:32.43411Z [INFO] Starting kanata proper
2024-02-21T09:45:32.434277Z [INFO] You may forcefully exit kanata by pressing lctl+spc+esc at any time. These keys refer to defsrc input, meaning BEFORE kanata remaps keys.
2024-02-21T09:45:32.434299Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:1536] blocking on channel
driver_connected 1
2024-02-21T09:45:36.152148Z [DEBUG] (1) kanata::kanata::macos: InputEvent { value: 44, page: 7, code: 4294967295 } is unrecognized!
2024-02-21T09:45:36.152331Z [DEBUG] (1) kanata::oskbd::macos: Attempting to write InputEvent { value: 44, page: 7, code: 4294967295 } DKEvent { value: 44, page: 7, code: 4294967295 }
2024-02-21T09:45:36.152361Z [DEBUG] (1) kanata::kanata::macos: InputEvent { value: 0, page: 7, code: 1 } is unrecognized!
2024-02-21T09:45:36.152379Z [DEBUG] (1) kanata::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 1 } DKEvent { value: 0, page: 7, code: 1 }
2024-02-21T09:45:36.152487Z [DEBUG] (1) kanata::kanata::macos: sending KeyEvent { code: KEY_SPACE, value: Press } to processing loop
2024-02-21T09:45:36.1526Z [DEBUG] (1) kanata::kanata::macos: InputEvent { value: 44, page: 7, code: 4294967295 } is unrecognized!
2024-02-21T09:45:36.152617Z [DEBUG] (1) kanata::oskbd::macos: Attempting to write InputEvent { value: 44, page: 7, code: 4294967295 } DKEvent { value: 44, page: 7, code: 4294967295 }
2024-02-21T09:45:36.152729Z [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_SPACE, value: Press }
2024-02-21T09:45:36.152841Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:720] []
2024-02-21T09:45:36.152865Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:733] [Space]
2024-02-21T09:45:36.15289Z [DEBUG] (2) kanata::kanata: key press     Space
2024-02-21T09:45:36.152916Z [DEBUG] (2) kanata::oskbd::macos: Attempting to write InputEvent { value: 1, page: 7, code: 44 } DKEvent { value: 1, page: 7, code: 44 }
2024-02-21T09:45:36.154551Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:1536] blocking on channel
 2024-02-21T09:45:36.198548Z [DEBUG] (1) kanata::kanata::macos: InputEvent { value: 0, page: 7, code: 4294967295 } is unrecognized!
2024-02-21T09:45:36.198625Z [DEBUG] (1) kanata::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 4294967295 } DKEvent { value: 0, page: 7, code: 4294967295 }
2024-02-21T09:45:36.198657Z [DEBUG] (1) kanata::kanata::macos: InputEvent { value: 0, page: 7, code: 1 } is unrecognized!
2024-02-21T09:45:36.198663Z [DEBUG] (1) kanata::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 1 } DKEvent { value: 0, page: 7, code: 1 }
2024-02-21T09:45:36.198771Z [DEBUG] (1) kanata::kanata::macos: sending KeyEvent { code: KEY_SPACE, value: Release } to processing loop
2024-02-21T09:45:36.198838Z [DEBUG] (1) kanata::kanata::macos: InputEvent { value: 0, page: 7, code: 4294967295 } is unrecognized!
2024-02-21T09:45:36.198853Z [DEBUG] (1) kanata::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 4294967295 } DKEvent { value: 0, page: 7, code: 4294967295 }
2024-02-21T09:45:36.19888Z [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_SPACE, value: Release }
2024-02-21T09:45:36.19892Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:720] [Space]
2024-02-21T09:45:36.198936Z [DEBUG] (2) kanata::kanata: key release   Space
2024-02-21T09:45:36.198967Z [DEBUG] (2) kanata::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 44 } DKEvent { value: 0, page: 7, code: 44 }
2024-02-21T09:45:36.198999Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:733] []
2024-02-21T09:45:36.199011Z [TRACE] (2) kanata::kanata: [src/kanata/mod.rs:1536] blocking on channel

Operating system

MacOS 14.2.1

Additional context

MacBook has a german keyboard. Issue persists when switching to US input source.

@moritzketzer moritzketzer added the bug Something isn't working label Feb 21, 2024
@jtroo
Copy link
Owner

jtroo commented Feb 21, 2024

To start, can see this change in the macOS PR:

2090665#diff-7332baefab560e9e683965f833b9e4c1150405f9bc437377d35b2292d447be69R270

Anywhere that OsCode::KEY_FN is used is where new code would need to be added to handle a new key.

@jtroo
Copy link
Owner

jtroo commented Feb 21, 2024

Also, I think the event inputs do have some other non-key events in there that would always be unrecognized, so need to differentiate those from the actual key presses that are presently unrecognized, but should be.

@jtroo jtroo added help wanted Extra attention is needed good first issue Good for newcomers macos Issue pertains to macos; jtroo has no macOS devices and does not maintain the support for it. labels Feb 21, 2024
@moritzketzer
Copy link
Contributor Author

Hi,

Thanks for the hints @jtroo.

I have another question. Say I want to add the following keys:

((0xFF01,0x1), KeySpotlight)
((0xFF01,0x4), KeyLaunchpad)
((0xFF01,0x10), KeyMissionCtrl)

What do I map them to? As I understand they dont exist in the kerberon or OsCode definions.

Can we add them or do I need to choose some unmapped key?
Any recommendation for what kind of unmapped key one should pick?

@jtroo
Copy link
Owner

jtroo commented Apr 23, 2024

I would just use some unnamed keys, or some key names that sound plausibly relevant but aren't mapped yet in the TryFrom...PageCode mappings. The higher numbered keys are primarily associated with Linux and are generally unused in Windows/macOS.

E.g. in parser\src\keys\mod.rs (untested):

    KEY_633 = 633, // macos: KeySpotlight, "spotlight"
    KEY_634 = 634, // macos: KeyLaunchpad, "launchpad"
    KEY_635 = 635, // macos: KeyMissionCtrl, "missionctrl"
        #[cfg(any(target_os = "macos", target_os = "unknown"))]
        "spotlight" => OsCode::KEY_633
        #[cfg(any(target_os = "macos", target_os = "unknown"))]
        "launchpad" => OsCode::KEY_634
        #[cfg(any(target_os = "macos", target_os = "unknown"))]
        "missionctrl" => OsCode::KEY_635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed macos Issue pertains to macos; jtroo has no macOS devices and does not maintain the support for it.
Projects
None yet
Development

No branches or pull requests

2 participants