-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Substract virtual keycode not sent in WindowEvent #979
Comments
It is actually a change in winit that broke this. If I revert the following changeset it works again: rust-windowing/winit@52a78d6#diff-c3f6b02da9e467b737e84b8236fa5ba2 |
The following changes to winit and alacritty fixes my issues. I don't know what the proper solution is though. Seems like a lot of fields will have to be added to these structs to support all keys. diff --git a/src/events.rs b/src/events.rs
index 2947db1..3ed5b02 100644
--- a/src/events.rs
+++ b/src/events.rs
@@ -379,6 +379,7 @@ pub enum VirtualKeyCode {
LBracket,
LControl,
LMenu,
+ LParen,
LShift,
LWin,
Mail,
@@ -404,6 +405,7 @@ pub enum VirtualKeyCode {
RBracket,
RControl,
RMenu,
+ RParen,
RShift,
RWin,
Semicolon,
@@ -414,6 +416,7 @@ pub enum VirtualKeyCode {
Sysrq,
Tab,
Underline,
+ Underscore,
Unlabeled,
VolumeDown,
VolumeUp,
diff --git a/src/platform/linux/x11/events.rs b/src/platform/linux/x11/events.rs
index c17cfe7..76e3209 100644
--- a/src/platform/linux/x11/events.rs
+++ b/src/platform/linux/x11/events.rs
@@ -181,8 +181,8 @@ pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> {
//ffi::XK_ampersand => events::VirtualKeyCode::Ampersand,
ffi::XK_apostrophe => events::VirtualKeyCode::Apostrophe,
//ffi::XK_quoteright => events::VirtualKeyCode::Quoteright,
- //ffi::XK_parenleft => events::VirtualKeyCode::Parenleft,
- //ffi::XK_parenright => events::VirtualKeyCode::Parenright,
+ ffi::XK_parenleft => events::VirtualKeyCode::LParen,
+ ffi::XK_parenright => events::VirtualKeyCode::RParen,
//ffi::XK_asterisk => events::VirtualKeyCode::Asterisk,
ffi::XK_plus => events::VirtualKeyCode::Add,
ffi::XK_comma => events::VirtualKeyCode::Comma,
@@ -236,7 +236,7 @@ pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> {
ffi::XK_backslash => events::VirtualKeyCode::Backslash,
ffi::XK_bracketright => events::VirtualKeyCode::RBracket,
//ffi::XK_asciicircum => events::VirtualKeyCode::Asciicircum,
- //ffi::XK_underscore => events::VirtualKeyCode::Underscore,
+ ffi::XK_underscore => events::VirtualKeyCode::Underscore,
ffi::XK_grave => events::VirtualKeyCode::Grave,
//ffi::XK_quoteleft => events::VirtualKeyCode::Quoteleft,
ffi::XK_a => events::VirtualKeyCode::A, diff --git a/src/config.rs b/src/config.rs
index be96715..56c4a30 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1841,6 +1841,7 @@ enum Key {
LBracket,
LControl,
LMenu,
+ LParen,
LShift,
LWin,
Mail,
@@ -1866,6 +1867,7 @@ enum Key {
RBracket,
RControl,
RMenu,
+ RParen,
RShift,
RWin,
Semicolon,
@@ -1876,6 +1878,7 @@ enum Key {
Sysrq,
Tab,
Underline,
+ Underscore,
Unlabeled,
VolumeDown,
VolumeUp,
@@ -1998,6 +2001,7 @@ impl Key {
Key::LBracket => LBracket,
Key::LControl => LControl,
Key::LMenu => LMenu,
+ Key::LParen => LParen,
Key::LShift => LShift,
Key::LWin => LWin,
Key::Mail => Mail,
@@ -2023,6 +2027,7 @@ impl Key {
Key::RBracket => RBracket,
Key::RControl => RControl,
Key::RMenu => RMenu,
+ Key::RParen => RParen,
Key::RShift => RShift,
Key::RWin => RWin,
Key::Semicolon => Semicolon,
@@ -2033,6 +2038,7 @@ impl Key {
Key::Sysrq => Sysrq,
Key::Tab => Tab,
Key::Underline => Underline,
+ Key::Underscore => Underscore,
Key::Unlabeled => Unlabeled,
Key::VolumeDown => VolumeDown,
Key::VolumeUp => VolumeUp, |
Was this ever fixed? (This also belongs on winit, obviously.) |
No, I never submitted a PR because my patch doesn't solve the general problem that there are a lot of commented out keys in |
That problem will honestly never be fixed unless someone decides to push for more rigorous keyboard API design (rust-windowing/winit#71) which I don't see as likely to happen in the foreseeable future. |
This issue has been filed with winit as rust-windowing/winit#600. |
This issue was originally reported by @NickeZ in alacritty/alacritty#1010.
I've tested this with a slightly modified version of the
window.rs
example:https://gist.github.com/chrisduerr/5dead96a0279592d2e320e088b611a87
The general issue is that when the
Shift
key and theSubstract
key are pressed at the same time, theWindowEvent
'sKeyboardInput
will haveNone
asvirtual_keycode
.However reading the
DeviceEvent
'sKeyboardInput
, it will reportSome(Substract)
as thevirtual_keycode
.To compare the two outputs directly, here's the
WindowEvent
output:And here's the
DeviceEvent
output:To be it seems like the
WindowEvent
should also reportSome(Substract)
as thevirtual_keycode
, or reportSome(Underline)
at least. However not reporting anyvirtual_keycode
seems a bit strange to me.Simililar problems have been reported for the
Key0
virtual_keycode
.The text was updated successfully, but these errors were encountered: