Added
Link Here
|
1 |
https://github.com/rust-windowing/winit/pull/1534 |
2 |
|
3 |
--- cargo-crates/winit-0.22.2/src/platform_impl/linux/wayland/keyboard.rs.orig 2020-05-16 16:27:31 UTC |
4 |
+++ cargo-crates/winit-0.22.2/src/platform_impl/linux/wayland/keyboard.rs |
5 |
@@ -65,7 +65,7 @@ pub fn init_keyboard( |
6 |
wl_keyboard::KeyState::Released => ElementState::Released, |
7 |
_ => unreachable!(), |
8 |
}; |
9 |
- let vkcode = key_to_vkey(rawkey, keysym); |
10 |
+ let vkcode = keysym_to_vkey(keysym); |
11 |
my_sink.send_window_event( |
12 |
#[allow(deprecated)] |
13 |
WindowEvent::KeyboardInput { |
14 |
@@ -110,7 +110,7 @@ pub fn init_keyboard( |
15 |
move |repeat_event: KeyRepeatEvent, _| { |
16 |
if let Some(wid) = *repeat_target.lock().unwrap() { |
17 |
let state = ElementState::Pressed; |
18 |
- let vkcode = key_to_vkey(repeat_event.rawkey, repeat_event.keysym); |
19 |
+ let vkcode = keysym_to_vkey(repeat_event.keysym); |
20 |
repeat_sink.send_window_event( |
21 |
#[allow(deprecated)] |
22 |
WindowEvent::KeyboardInput { |
23 |
@@ -199,26 +199,20 @@ pub fn init_keyboard( |
24 |
} |
25 |
} |
26 |
|
27 |
-fn key_to_vkey(rawkey: u32, keysym: u32) -> Option<VirtualKeyCode> { |
28 |
- match rawkey { |
29 |
- 1 => Some(VirtualKeyCode::Escape), |
30 |
- 2 => Some(VirtualKeyCode::Key1), |
31 |
- 3 => Some(VirtualKeyCode::Key2), |
32 |
- 4 => Some(VirtualKeyCode::Key3), |
33 |
- 5 => Some(VirtualKeyCode::Key4), |
34 |
- 6 => Some(VirtualKeyCode::Key5), |
35 |
- 7 => Some(VirtualKeyCode::Key6), |
36 |
- 8 => Some(VirtualKeyCode::Key7), |
37 |
- 9 => Some(VirtualKeyCode::Key8), |
38 |
- 10 => Some(VirtualKeyCode::Key9), |
39 |
- 11 => Some(VirtualKeyCode::Key0), |
40 |
- _ => keysym_to_vkey(keysym), |
41 |
- } |
42 |
-} |
43 |
- |
44 |
fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCode> { |
45 |
use smithay_client_toolkit::keyboard::keysyms; |
46 |
match keysym { |
47 |
+ // numbers |
48 |
+ keysyms::XKB_KEY_1 => Some(VirtualKeyCode::Key1), |
49 |
+ keysyms::XKB_KEY_2 => Some(VirtualKeyCode::Key2), |
50 |
+ keysyms::XKB_KEY_3 => Some(VirtualKeyCode::Key3), |
51 |
+ keysyms::XKB_KEY_4 => Some(VirtualKeyCode::Key4), |
52 |
+ keysyms::XKB_KEY_5 => Some(VirtualKeyCode::Key4), |
53 |
+ keysyms::XKB_KEY_6 => Some(VirtualKeyCode::Key5), |
54 |
+ keysyms::XKB_KEY_7 => Some(VirtualKeyCode::Key6), |
55 |
+ keysyms::XKB_KEY_8 => Some(VirtualKeyCode::Key7), |
56 |
+ keysyms::XKB_KEY_9 => Some(VirtualKeyCode::Key8), |
57 |
+ keysyms::XKB_KEY_0 => Some(VirtualKeyCode::Key9), |
58 |
// letters |
59 |
keysyms::XKB_KEY_A | keysyms::XKB_KEY_a => Some(VirtualKeyCode::A), |
60 |
keysyms::XKB_KEY_B | keysyms::XKB_KEY_b => Some(VirtualKeyCode::B), |
61 |
@@ -246,6 +240,8 @@ fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCod |
62 |
keysyms::XKB_KEY_X | keysyms::XKB_KEY_x => Some(VirtualKeyCode::X), |
63 |
keysyms::XKB_KEY_Y | keysyms::XKB_KEY_y => Some(VirtualKeyCode::Y), |
64 |
keysyms::XKB_KEY_Z | keysyms::XKB_KEY_z => Some(VirtualKeyCode::Z), |
65 |
+ // Escape |
66 |
+ keysyms::XKB_KEY_Escape => Some(VirtualKeyCode::Escape), |
67 |
// F-- |
68 |
keysyms::XKB_KEY_F1 => Some(VirtualKeyCode::F1), |
69 |
keysyms::XKB_KEY_F2 => Some(VirtualKeyCode::F2), |
70 |
@@ -286,10 +282,14 @@ fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCod |
71 |
keysyms::XKB_KEY_Up => Some(VirtualKeyCode::Up), |
72 |
keysyms::XKB_KEY_Right => Some(VirtualKeyCode::Right), |
73 |
keysyms::XKB_KEY_Down => Some(VirtualKeyCode::Down), |
74 |
- // |
75 |
+ |
76 |
keysyms::XKB_KEY_BackSpace => Some(VirtualKeyCode::Back), |
77 |
keysyms::XKB_KEY_Return => Some(VirtualKeyCode::Return), |
78 |
keysyms::XKB_KEY_space => Some(VirtualKeyCode::Space), |
79 |
+ |
80 |
+ keysyms::XKB_KEY_Multi_key => Some(VirtualKeyCode::Compose), |
81 |
+ keysyms::XKB_KEY_caret => Some(VirtualKeyCode::Caret), |
82 |
+ |
83 |
// keypad |
84 |
keysyms::XKB_KEY_Num_Lock => Some(VirtualKeyCode::Numlock), |
85 |
keysyms::XKB_KEY_KP_0 => Some(VirtualKeyCode::Numpad0), |
86 |
@@ -308,33 +308,32 @@ fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCod |
87 |
keysyms::XKB_KEY_plus => Some(VirtualKeyCode::Add), |
88 |
keysyms::XKB_KEY_apostrophe => Some(VirtualKeyCode::Apostrophe), |
89 |
// => Some(VirtualKeyCode::Apps), |
90 |
- // => Some(VirtualKeyCode::At), |
91 |
+ keysyms::XKB_KEY_at => Some(VirtualKeyCode::At), |
92 |
// => Some(VirtualKeyCode::Ax), |
93 |
keysyms::XKB_KEY_backslash => Some(VirtualKeyCode::Backslash), |
94 |
- // => Some(VirtualKeyCode::Calculator), |
95 |
+ keysyms::XKB_KEY_XF86Calculator => Some(VirtualKeyCode::Calculator), |
96 |
// => Some(VirtualKeyCode::Capital), |
97 |
keysyms::XKB_KEY_colon => Some(VirtualKeyCode::Colon), |
98 |
keysyms::XKB_KEY_comma => Some(VirtualKeyCode::Comma), |
99 |
// => Some(VirtualKeyCode::Convert), |
100 |
- // => Some(VirtualKeyCode::Decimal), |
101 |
- // => Some(VirtualKeyCode::Divide), |
102 |
+ keysyms::XKB_KEY_KP_Decimal => Some(VirtualKeyCode::Decimal), |
103 |
keysyms::XKB_KEY_equal => Some(VirtualKeyCode::Equals), |
104 |
- // => Some(VirtualKeyCode::Grave), |
105 |
+ keysyms::XKB_KEY_grave => Some(VirtualKeyCode::Grave), |
106 |
// => Some(VirtualKeyCode::Kana), |
107 |
- // => Some(VirtualKeyCode::Kanji), |
108 |
+ keysyms::XKB_KEY_Kanji => Some(VirtualKeyCode::Kanji), |
109 |
keysyms::XKB_KEY_Alt_L => Some(VirtualKeyCode::LAlt), |
110 |
- // => Some(VirtualKeyCode::LBracket), |
111 |
+ keysyms::XKB_KEY_bracketleft => Some(VirtualKeyCode::LBracket), |
112 |
keysyms::XKB_KEY_Control_L => Some(VirtualKeyCode::LControl), |
113 |
keysyms::XKB_KEY_Shift_L => Some(VirtualKeyCode::LShift), |
114 |
- // => Some(VirtualKeyCode::LWin), |
115 |
- // => Some(VirtualKeyCode::Mail), |
116 |
+ keysyms::XKB_KEY_Super_L => Some(VirtualKeyCode::LWin), |
117 |
+ keysyms::XKB_KEY_XF86Mail => Some(VirtualKeyCode::Mail), |
118 |
// => Some(VirtualKeyCode::MediaSelect), |
119 |
// => Some(VirtualKeyCode::MediaStop), |
120 |
keysyms::XKB_KEY_minus => Some(VirtualKeyCode::Minus), |
121 |
keysyms::XKB_KEY_asterisk => Some(VirtualKeyCode::Multiply), |
122 |
- // => Some(VirtualKeyCode::Mute), |
123 |
+ keysyms::XKB_KEY_XF86AudioMute => Some(VirtualKeyCode::Mute), |
124 |
// => Some(VirtualKeyCode::MyComputer), |
125 |
- // => Some(VirtualKeyCode::NextTrack), |
126 |
+ keysyms::XKB_KEY_XF86AudioNext => Some(VirtualKeyCode::NextTrack), |
127 |
// => Some(VirtualKeyCode::NoConvert), |
128 |
keysyms::XKB_KEY_KP_Separator => Some(VirtualKeyCode::NumpadComma), |
129 |
keysyms::XKB_KEY_KP_Enter => Some(VirtualKeyCode::NumpadEnter), |
130 |
@@ -347,24 +346,23 @@ fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCod |
131 |
keysyms::XKB_KEY_KP_Home => Some(VirtualKeyCode::Home), |
132 |
keysyms::XKB_KEY_KP_End => Some(VirtualKeyCode::End), |
133 |
// => Some(VirtualKeyCode::OEM102), |
134 |
- // => Some(VirtualKeyCode::Period), |
135 |
+ keysyms::XKB_KEY_period => Some(VirtualKeyCode::Period), |
136 |
// => Some(VirtualKeyCode::Playpause), |
137 |
- // => Some(VirtualKeyCode::Power), |
138 |
- // => Some(VirtualKeyCode::Prevtrack), |
139 |
+ keysyms::XKB_KEY_XF86PowerOff => Some(VirtualKeyCode::Power), |
140 |
+ keysyms::XKB_KEY_XF86AudioPrev => Some(VirtualKeyCode::PrevTrack), |
141 |
keysyms::XKB_KEY_Alt_R => Some(VirtualKeyCode::RAlt), |
142 |
- // => Some(VirtualKeyCode::RBracket), |
143 |
+ keysyms::XKB_KEY_bracketright => Some(VirtualKeyCode::RBracket), |
144 |
keysyms::XKB_KEY_Control_R => Some(VirtualKeyCode::RControl), |
145 |
keysyms::XKB_KEY_Shift_R => Some(VirtualKeyCode::RShift), |
146 |
- // => Some(VirtualKeyCode::RWin), |
147 |
+ keysyms::XKB_KEY_Super_R => Some(VirtualKeyCode::RWin), |
148 |
keysyms::XKB_KEY_semicolon => Some(VirtualKeyCode::Semicolon), |
149 |
keysyms::XKB_KEY_slash => Some(VirtualKeyCode::Slash), |
150 |
- // => Some(VirtualKeyCode::Sleep), |
151 |
+ keysyms::XKB_KEY_XF86Sleep => Some(VirtualKeyCode::Sleep), |
152 |
// => Some(VirtualKeyCode::Stop), |
153 |
- // => Some(VirtualKeyCode::Subtract), |
154 |
// => Some(VirtualKeyCode::Sysrq), |
155 |
keysyms::XKB_KEY_Tab => Some(VirtualKeyCode::Tab), |
156 |
keysyms::XKB_KEY_ISO_Left_Tab => Some(VirtualKeyCode::Tab), |
157 |
- // => Some(VirtualKeyCode::Underline), |
158 |
+ keysyms::XKB_KEY_underscore => Some(VirtualKeyCode::Underline), |
159 |
// => Some(VirtualKeyCode::Unlabeled), |
160 |
keysyms::XKB_KEY_XF86AudioLowerVolume => Some(VirtualKeyCode::VolumeDown), |
161 |
keysyms::XKB_KEY_XF86AudioRaiseVolume => Some(VirtualKeyCode::VolumeUp), |
162 |
@@ -376,7 +374,7 @@ fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCod |
163 |
// => Some(VirtualKeyCode::WebRefresh), |
164 |
// => Some(VirtualKeyCode::WebSearch), |
165 |
// => Some(VirtualKeyCode::WebStop), |
166 |
- // => Some(VirtualKeyCode::Yen), |
167 |
+ keysyms::XKB_KEY_yen => Some(VirtualKeyCode::Yen), |
168 |
keysyms::XKB_KEY_XF86Copy => Some(VirtualKeyCode::Copy), |
169 |
keysyms::XKB_KEY_XF86Paste => Some(VirtualKeyCode::Paste), |
170 |
keysyms::XKB_KEY_XF86Cut => Some(VirtualKeyCode::Cut), |