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

Bug: F-row key get override on MacOS #975

Open
1 task done
OnFireByte opened this issue Apr 24, 2024 · 8 comments
Open
1 task done

Bug: F-row key get override on MacOS #975

OnFireByte opened this issue Apr 24, 2024 · 8 comments
Assignees
Labels
bug Something isn't working macos Issue pertains to macos; jtroo has no macOS devices and does not maintain the support for it.

Comments

@OnFireByte
Copy link

OnFireByte commented Apr 24, 2024

Requirements

Describe the bug

In my macbook, F-row get override to normal f1-f12 instead of normal feature (light control, sound control) when kanata is used.

This also happen when I try to turn on the "swap f-row to feature" setting (Image below), fn key + F-row key will still result in normal f1-f12
image

Relevant kanata config

No response

To Reproduce

  1. Running kanata
  2. waiting for driver_activated 1
  3. Done

Expected behavior

It shouldn't override anything.

Kanata version

kanata 1.6.0 (arm64, cmd allowed)

Debug logs

Happen when I press F12 (increase volume)

2024-04-24T19:32:48.957173+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: InputEvent { value: 69, page: 7, code: 4294967295 } is unrecognized!
2024-04-24T19:32:48.957267+07:00 [DEBUG] (1) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 69, page: 7, code: 4294967295 } DKEvent { value: 69, page: 7, code: 4294967295 }
2024-04-24T19:32:48.957286+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: InputEvent { value: 0, page: 7, code: 1 } is unrecognized!
2024-04-24T19:32:48.957298+07:00 [DEBUG] (1) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 1 } DKEvent { value: 0, page: 7, code: 1 }
2024-04-24T19:32:48.957337+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: sending KeyEvent { code: KEY_F12, value: Press } to processing loop
2024-04-24T19:32:48.957368+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: InputEvent { value: 69, page: 7, code: 4294967295 } is unrecognized!
2024-04-24T19:32:48.957383+07:00 [DEBUG] (1) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 69, page: 7, code: 4294967295 } DKEvent { value: 69, page: 7, code: 4294967295 }
2024-04-24T19:32:48.95741+07:00 [DEBUG] (2) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_F12, value: Press }
2024-04-24T19:32:48.957451+07:00 [DEBUG] (2) kanata_state_machine::kanata: key press     F12
2024-04-24T19:32:48.957466+07:00 [DEBUG] (2) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 1, page: 7, code: 69 } DKEvent { value: 1, page: 7, code: 69 }
^[[24~2024-04-24T19:32:49.049204+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: InputEvent { value: 0, page: 7, code: 4294967295 } is unrecognized!
2024-04-24T19:32:49.049335+07:00 [DEBUG] (1) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 4294967295 } DKEvent { value: 0, page: 7, code: 4294967295 }
2024-04-24T19:32:49.049375+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: InputEvent { value: 0, page: 7, code: 1 } is unrecognized!
2024-04-24T19:32:49.049383+07:00 [DEBUG] (1) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 1 } DKEvent { value: 0, page: 7, code: 1 }
2024-04-24T19:32:49.049396+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: sending KeyEvent { code: KEY_F12, value: Release } to processing loop
2024-04-24T19:32:49.049417+07:00 [DEBUG] (1) kanata_state_machine::kanata::macos: InputEvent { value: 0, page: 7, code: 4294967295 } is unrecognized!
2024-04-24T19:32:49.050545+07:00 [DEBUG] (2) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_F12, value: Release }
2024-04-24T19:32:49.050601+07:00 [DEBUG] (2) kanata_state_machine::kanata: key release   F12
2024-04-24T19:32:49.050611+07:00 [DEBUG] (2) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 69 } DKEvent { value: 0, page: 7, code: 69 }
2024-04-24T19:32:49.053527+07:00 [DEBUG] (1) kanata_state_machine::oskbd::macos: Attempting to write InputEvent { value: 0, page: 7, code: 4294967295 } DKEvent { value: 0, page: 7, code: 4294967295 }

Operating system

MacOS (arm64)

Additional context

No response

@OnFireByte OnFireByte added the bug Something isn't working label Apr 24, 2024
@jtroo jtroo added the macos Issue pertains to macos; jtroo has no macOS devices and does not maintain the support for it. label Apr 24, 2024
@jtroo
Copy link
Owner

jtroo commented Apr 24, 2024

Hi @OnFireByte,

To help a future reader, what is the minimal configuration that reproduces the behaviour?

  • Are you mapping f1-f12 in defsrc?
  • Are you using process-unmapped-keys yes?

@jtroo
Copy link
Owner

jtroo commented Apr 24, 2024

Also, does karabiner elements reproduce the same or does karabiner work as intended?

@OnFireByte
Copy link
Author

OnFireByte commented Apr 24, 2024

Hi @OnFireByte,

To help a future reader, what is the minimal configuration that reproduces the behaviour?

  • Are you mapping f1-f12 in defsrc?
  • Are you using process-unmapped-keys yes?

Also, does karabiner elements reproduce the same or does karabiner work as intended?

  1. I didn't map anything to f1-f12, I only do the home row mod
  2. For process-unmapped-keys yes, I already try removing it, but the problem still occurred
  3. Karabiner work fine for me

@yzhuang
Copy link

yzhuang commented Apr 26, 2024

I also ran into this issue, and it happens with or without process-unmapped-keys yes.
It can be reproduced using simple configs like: https://github.com/jtroo/kanata/blob/main/cfg_samples/minimal.kbd

A related question is: what is the defsrc key code for the fn key?
The below is what Karabiner EventViewer reports when the fn key is pressed.

[
  {
    "type": "down",
    "name": {"apple_vendor_top_case_key_code":"keyboard_fn"},
    "usagePage": "255 (0x00ff)",
    "usage": "3 (0x0003)",
    "misc": "flags fn"
  },
  {
    "type": "up",
    "name": {"apple_vendor_top_case_key_code":"keyboard_fn"},
    "usagePage": "255 (0x00ff)",
    "usage": "3 (0x0003)",
    "misc": ""
  },
]

@jtroo
Copy link
Owner

jtroo commented Apr 26, 2024

The fn key is fn.

"fn" | "🌐" | "ƒ" | "ⓕ" | "Ⓕ" | "🄵" | "🅕" | "🅵" => OsCode::KEY_FN,

@yzhuang
Copy link

yzhuang commented Apr 26, 2024

The fn key is fn.

"fn" | "🌐" | "ƒ" | "ⓕ" | "Ⓕ" | "🄵" | "🅕" | "🅵" => OsCode::KEY_FN,

Thank you very much! Would be nice to update https://github.com/jtroo/kanata/blob/main/cfg_samples/all_keys_in_defsrc.kbd to include fn as well!

@yzhuang
Copy link

yzhuang commented Apr 26, 2024

@jtroo Thanks for the pointer to the file https://github.com/jtroo/kanata/blob/b1e828b4cda220eda3bc4e0aef2f9afba5fc9b4f/parser/src/keys/mod.rs and it was super helpful for me to find many keycodes I needed.

I was able to resolve the issue by explicit handling the F-key row and the fn key. CC @OnFireByte

I.e.

;; add this row to your defsrc. Need to add the fn key as well.
(defsrc
  esc  f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12
  ...
  ...
  fn
)

;; then you can create a fn layer. E.g. mine is:
(deflayer fn
  _    brdn brup _    _    _    _    _    _    _    mute vold volu
  ...
)

;; then map your fn key to `fnl` as shown below.
(defalias
  fnl (layer-while-held fn)
)

The reason why I believe this is needed is because Karabiner also handles the F-keys explicitly. See attached screenshot:
image

Update:
In case you tap the fn key to switch layout like me, this is even better:

(defalias
  fnl (tap-hold 200 200 fn (layer-toggle fn))
)

@yzhuang
Copy link

yzhuang commented May 5, 2024

It would still be nice to fix the bug--looks like the fn key code is not available on Windows, so having fn in defsrc breaks my configs compatibility in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 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

3 participants