-
Notifications
You must be signed in to change notification settings - Fork 877
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
Releasing the Shift key does not set virtual_keycode #361
Comments
I'm personally not able to reproduce this on X11, but is it resolved if you try this branch? It changes all the relevant code on X11, though Wayland is outside of my purview. |
Thanks for looking into this! I had to install
After that, running If I only pressed and released the Shift key after running it, it would report |
I've updated the branch to update state much more correctly. I'm hoping that fixes things, but if not, I have some thoughts. You're getting the correct scancode, so that means the problem must be in the keysym you're getting. Keysyms are based on both the scancode and your keyboard mapping, and they come from external functions (which are both official and beyond our control). I've added a line to log which keysym you're getting, since if we're lucky that will shed some light on things. So here's some info that could help:
|
Good catch on the So this is something on my end. If you want to close the issue, be my guest. I'm a bit confused because this did use to work before, so it might be something we want to track down nonetheless. In case it helps, here's the info you asked for:
And here's the log. I run the example, then press & release left shift, press & release right shift and then close it with Alt+F4.
|
65509 is the keysym for caps lock. In regards to it working in the past... my research shows that I've made a GLFW program to test if GLFW gives you the expected events. If it does, then you can give me a copy of your layout and I can try to get to the bottom of why things are working differently here. |
Hey, same issue here. Namely, pressing and releasing LShift in
I've run your GLFW program, which ignores my layout and gives me
My layout is set using the Xfce utility, and the issue remains w/e I change it to. If there's anything I can do to help. |
@JadeSnail I may have taken for granted that GLFW actually has good layout support. Anyway, the fact that the keycode is correct on the (Also, the branch I linked to earlier here is no longer relevant, so be sure to run against master.) |
I was running the latest version of winit. What kind of information are you looking for ? The issue occurs on both my desktop and laptop, which are running arch linux, X, and Xfce. It seems to occur regardless of the layout chosen in Xfce (I pick any layout, remove other layouts, even reboot). Oh here's
|
The grp:shifts_toggle option seems to be the culprit, if I remove it, the issue goes away. |
Ah, then I should be able to look into how to fix this. What are some examples of programs it works correctly in? |
I don't use shift for anything other than capitilizing letters, so I really can't say. I'd be happy to test things if you've got candidates with an easy way to know if it works or not. The way Xfce deals with keyboard shortuts may «work correctly»: if I set a shortcut for Shift+A, and keep both pressed, the shortcut is repeatedly called, and when I release the Shift key, it isn't anymore. |
Sorry for not answering earlier. On my setup, it's also related to having a behaviour for pressing both Shift keys at once. In my case this acts as a caps lock, not a layout toggle. SDL2 handles this fine for me. I've adapted the keyboard-state example: https://github.com/Rust-SDL2/rust-sdl2/blob/master/examples/keyboard-state.rs extern crate sdl2;
use sdl2::event::Event;
use std::time::Duration;
pub fn main() {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let _window = video_subsystem.window("Keyboard", 800, 600)
.position_centered()
.build()
.unwrap();
let mut events = sdl_context.event_pump().unwrap();
'running: loop {
for event in events.poll_iter() {
println!("{:?}", event);
if let Event::Quit {..} = event {
break 'running;
};
}
std::thread::sleep(Duration::from_millis(100));
}
} And running it, pressing and releasing left shift and then right shift, I get the following output:
|
I can confirm this bug on Kubuntu 18.04, X11 with KDE Plasma 5.12.9. The bug only occurs when I set special behaviour of the shift key in my systems settings, changing it back even while the demo program is running eliminates the bug immediately. The bug is present whenever @tomassedovic's test using SDL2 shows the correct behaviour in both cases |
Overhaul the keyboard API in winit to mimic the W3C specification to achieve better crossplatform parity. The `KeyboardInput` event is now uses `KeyEvent` which consists of: - `physical_key` - a cross platform way to refer to scancodes; - `logical_key` - keysym value, which shows your key respecting the layout; - `text` - the text produced by this keypress; - `location` - the location of the key on the keyboard; - `repeat` - whether the key was produced by the repeat. And also a `platform_specific` field which encapsulates extra information on desktop platforms, like key without modifiers and text with all modifiers. The `Modifiers` were also slightly reworked as in, the information whether the left or right modifier is pressed is now also exposed on platforms where it could be queried reliably. The support was also added for the web and orbital platforms finishing the API change. This change made the `OptionAsAlt` API on macOS redundant thus it was removed all together. Co-Authored-By: Artúr Kovács <kovacs.artur.barnabas@gmail.com> Co-Authored-By: Kirill Chibisov <contact@kchibisov.com> Co-Authored-By: daxpedda <daxpedda@gmail.com> Fixes: #2631. Fixes: #2055. Fixes: #2032. Fixes: #1904. Fixes: #1810. Fixes: #1700. Fixes: #1443. Fixes: #1343. Fixes: #1208. Fixes: #1151. Fixes: #812. Fixes: #600. Fixes: #361. Fixes: #343.
When I press and release the Shift key, the
WindowEvent
for the release has virtual_keycodeNone
rather thanSome(RShift)
(and the same is true for the left shift).The
DeviceEvent
is fine, so is the key press.To reproduce:
cargo run --example window
Expected:
The final line should read:
WindowEvent { window_id: WindowId(X(WindowId(127926274))), event: KeyboardInput { device_id: DeviceId(X(DeviceId(3))), input: KeyboardInput { scancode: 54, state: Released, virtual_keycode: Some(RShift), modifiers: ModifiersState { shift: true, ctrl: false, alt: false, logo: false } } } }
Actual:
(look at the
virtual_keycode
)I ran
git bisect
and it ended up with commit 52a78d6Here's the output that illustrate this on my computer (running Fedora 26 with Wayland I believe as well as on another computer with Fedora 24 + X11).
The text was updated successfully, but these errors were encountered: