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: device detection works poorly #999

Closed
1 task done
prescientmoon opened this issue May 1, 2024 · 3 comments
Closed
1 task done

Bug: device detection works poorly #999

prescientmoon opened this issue May 1, 2024 · 3 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@prescientmoon
Copy link

Requirements

Describe the bug

When I disconnect my external keyboard and reconnect it immediately (as in, less than one second later), the kanata service seems to stop working.

While this might seem contrived, I have a bad cable which keeps disconnecting and reconnecting when it moves. Having to restart the kanata systemd service to fix the issue is a bit annoying.

Relevant kanata config

I don't think this is very relevant, but:

    keyboards.keychronK6 = {
      devices = [ "/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd" ];
    };
(defcfg
  linux-dev /dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd
  linux-continue-if-no-devs-found yes)

To Reproduce

  1. Connect external keyboard
  2. Pull the cable out and push it in super quickly

Expected behavior

Kanata should detect the device is still there.

Kanata version

1.4.0

Debug logs

2024-05-01T20:48:24.331828786+02:00 [INFO] kanata v1.4.0 starting
2024-05-01T20:48:24.33241852+02:00 [INFO] process unmapped keys: false
2024-05-01T20:48:24.332511135+02:00 [INFO] NOTE: kanata was compiled to never allow cmd
2024-05-01T20:48:24.332520932+02:00 [DEBUG] (1) kanata_parser::cfg::alloc: freeing allocations of length 0
2024-05-01T20:48:24.334953638+02:00 [INFO] config parsed
2024-05-01T20:48:24.335666745+02:00 [INFO] Created device "/dev/input/event10"
2024-05-01T20:48:24.335695751+02:00 [INFO] Created symlink "/run/keychronK6" -> "/dev/input/event10"
2024-05-01T20:48:24.335792071+02:00 [INFO] Sleeping for 2s. Please release all keys and don't press additional ones.
2024-05-01T20:48:26.33611098+02:00 [INFO] entering the processing loop
2024-05-01T20:48:26.336245193+02:00 [INFO] entering the event loop
2024-05-01T20:48:26.336335927+02:00 [INFO] registering /dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd: "Keychron Keychron K6"
2024-05-01T20:48:26.336354301+02:00 [INFO] Init: catching only releases and sending immediately
2024-05-01T20:48:26.921589974+02:00 [INFO] Starting kanata proper
2024-05-01T20:48:27.57772853+02:00 [WARN] removing kbd device: /dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd
2024-05-01T20:48:27.958465833+02:00 [INFO] watch found file changes, looking for new devices
2024-05-01T20:48:27.95847888+02:00 [INFO] checking for ["/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd"]
2024-05-01T20:48:28.060177572+02:00 [INFO] watch found file changes, looking for new devices
2024-05-01T20:48:28.060191286+02:00 [INFO] checking for ["/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd"]

Operating system

Nixos 23.11

Additional context

No response

@prescientmoon prescientmoon added the bug Something isn't working label May 1, 2024
@maueroats
Copy link

As a first step you should upgrade to the most recent version of Kanata.
This area improved a lot in 1.5 iirc.
Come back and confirm.
Including the log from kanata --debug would make a lot of sense.

@jtroo
Copy link
Owner

jtroo commented May 3, 2024

Maybe you need to adjust this value:

    /// Milliseconds to wait before attempting to register a newly connected
    /// device. The default is 200.
    ///
    /// You may wish to increase this if you have a device that is failing
    /// to register - the device may be taking too long to become ready.
    #[cfg(target_os = "linux")]
    #[arg(short, long, verbatim_doc_comment)]
    wait_device_ms: Option<u64>,

Could try making it larger, or making it smaller.

@jtroo jtroo added the question Further information is requested label May 4, 2024
@jtroo
Copy link
Owner

jtroo commented Jun 8, 2024

Closing as stale

@jtroo jtroo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants