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

Modifiers (e.g. Alt) are sometimes ignored when using programmable keyboard #1358

Closed
quadruple-output opened this issue Jun 18, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@quadruple-output
Copy link

quadruple-output commented Jun 18, 2022

Describe the bug
I am using a programmable keyboard on a Mac. Sometimes when I enter, for example, the "{" character, neovide outputs "8" (Alt-8 is how you enter "{" on a mac). This only seems to occur when I have neovide maximized on my external 4K monitor. It happens at seemingly random times, but often enough to really drive me crazy.

Spoiler: I think I found a fix for the issue and plan to submit a PR.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a programmable keyboard, such that a single key press corresponds to pressing "Alt-8". In almost all apps, pressing this key should produce "{" in any kind of text input control.
  2. Startup neovide and maximize it on a high resolution monitor (it may be possible to achieve the same effect by putting the CPU under load, but I did not test this at all).
  3. Enter Insert Mode and keep hitting your programmed key. Use different time intervals, for example hit the key fast a few times, then wait 2 seconds, continue, wait longer or shorter, continue …
  4. When I follow these steps, I see something like this: 8{{88{{8{{8{{{{8{{{ (in a random order). This is an extreme but real example. Sometimes it just works as expected, especially when I keep hitting the key in short intervals.

Expected behavior
I would expect to see a series of "{" characters without any "8" in-between.

Screenshots

Desktop (please complete the following information):

  • macOS 12.4
  • Neovide Version 0.9.0
  • Neovim Version 0.7.0

Please run neovide --log and paste the contents of the .log file created in the current directory here:

I had to add a few log statements in KeyboardManager::handle_event() in order to see something. This is the condensed result. The first block reflects the "Ok" situation where hitting the key results in "{", while the second block reflects the error. Watch out for the ModifiersChanged event which is processed out-of-order with respect to the queued input events. (The time stamps show how quickly the events follow each other.

[2022-06-17 20:01:15.096005 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } }, is_synthetic: false } })
[2022-06-17 20:01:15.112254 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:79: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: ModifiersChanged(ALT) })
[2022-06-17 20:01:15.112324 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: Some("8"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } }, is_synthetic: false } })
[2022-06-17 20:01:15.112387 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } })
[2022-06-17 20:01:15.112418 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: Some("8"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } })
[2022-06-17 20:01:15.112647 +02:00] TRACE [neovide::bridge::ui_commands] src/bridge/ui_commands.rs:50: Keyboard Input Sent: {
[2022-06-17 20:01:15.112979 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: None, location: Standard, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } }, is_synthetic: false } })
[2022-06-17 20:01:15.124893 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } }, is_synthetic: false } })
[2022-06-17 20:01:15.125012 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:79: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: ModifiersChanged((empty)) })
[2022-06-17 20:01:15.125071 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: None, location: Standard, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } })
[2022-06-17 20:01:15.125102 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } })
[2022-06-17 20:01:15.612608 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } }, is_synthetic: false } })
[2022-06-17 20:01:15.613117 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:79: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: ModifiersChanged(ALT) })
[2022-06-17 20:01:15.613247 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } })
[2022-06-17 20:01:15.641187 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: Some("8"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } }, is_synthetic: false } })
[2022-06-17 20:01:15.653703 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: None, location: Standard, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } }, is_synthetic: false } })
[2022-06-17 20:01:15.653817 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:59: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: KeyboardInput { device_id: DeviceId(DeviceId), event: KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } }, is_synthetic: false } })
[2022-06-17 20:01:15.653860 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:79: handle_event(WindowEvent { window_id: WindowId(Id(5198875936)), event: ModifiersChanged((empty)) })
[2022-06-17 20:01:15.653905 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: Some("8"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } })
[2022-06-17 20:01:15.654029 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: Digit8, logical_key: Character("8"), text: None, location: Standard, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("{"), key_without_modifiers: Character("8") } })
[2022-06-17 20:01:15.654087 +02:00] DEBUG [neovide::window::keyboard_manager] src/window/keyboard_manager.rs:95: handle_event: handling queued input event KeyEvent(KeyEvent { physical_key: AltLeft, logical_key: Alt, text: None, location: Left, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Super } })
[2022-06-17 20:01:15.654135 +02:00] TRACE [neovide::bridge::ui_commands] src/bridge/ui_commands.rs:50: Keyboard Input Sent: 8

Additional context

@fredizzimo
Copy link
Member

I think that the new winit keyboard API merged in #1789, might fix the issue. Could you try again with the latest Neovide master?

@quadruple-output
Copy link
Author

I think that the new winit keyboard API merged in #1789, might fix the issue. Could you try again with the latest Neovide master?

@fredizzimo I just compiled and tested the current master. I can confirm that the issue I reported does not exist, any more, while it did exist with the previous commit.
Good job by everyone involved in the fix. Thank you very much. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants