Linux: Align scancode conversions with Firefox (#4021)
This commit is contained in:
parent
19e5bee3d1
commit
2e5db75101
2 changed files with 50 additions and 23 deletions
|
|
@ -75,6 +75,7 @@ changelog entry.
|
||||||
variables to test the respective modifiers of window creation.
|
variables to test the respective modifiers of window creation.
|
||||||
- Added `Window::surface_position`, which is the position of the surface inside the window.
|
- Added `Window::surface_position`, which is the position of the surface inside the window.
|
||||||
- Added `Window::safe_area`, which describes the area of the surface that is unobstructed.
|
- Added `Window::safe_area`, which describes the area of the surface that is unobstructed.
|
||||||
|
- On X11 and Wayland, improved scancode conversions for more obscure key codes.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ pub fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
|
||||||
// are defined by the Linux kernel. If Winit programs end up being run on other Unix-likes,
|
// are defined by the Linux kernel. If Winit programs end up being run on other Unix-likes,
|
||||||
// I can only hope they agree on what the keycodes mean.
|
// I can only hope they agree on what the keycodes mean.
|
||||||
//
|
//
|
||||||
|
// The mapping here is heavily influenced by Firefox' source:
|
||||||
|
// https://searchfox.org/mozilla-central/rev/c597e9c789ad36af84a0370d395be066b7dc94f4/widget/NativeKeyToDOMCodeName.h
|
||||||
|
//
|
||||||
// Some of the keycodes are likely superfluous for our purposes, and some are ones which are
|
// Some of the keycodes are likely superfluous for our purposes, and some are ones which are
|
||||||
// difficult to test the correctness of, or discover the purpose of. Because of this, they've
|
// difficult to test the correctness of, or discover the purpose of. Because of this, they've
|
||||||
// either been commented out here, or not included at all.
|
// either been commented out here, or not included at all.
|
||||||
|
|
@ -166,23 +169,23 @@ pub fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
|
||||||
125 => KeyCode::SuperLeft,
|
125 => KeyCode::SuperLeft,
|
||||||
126 => KeyCode::SuperRight,
|
126 => KeyCode::SuperRight,
|
||||||
127 => KeyCode::ContextMenu,
|
127 => KeyCode::ContextMenu,
|
||||||
// 128 => KeyCode::STOP,
|
128 => KeyCode::BrowserStop,
|
||||||
// 129 => KeyCode::AGAIN,
|
129 => KeyCode::Again,
|
||||||
// 130 => KeyCode::PROPS,
|
130 => KeyCode::Props,
|
||||||
// 131 => KeyCode::UNDO,
|
131 => KeyCode::Undo,
|
||||||
// 132 => KeyCode::FRONT,
|
132 => KeyCode::Select, // FRONT
|
||||||
// 133 => KeyCode::COPY,
|
133 => KeyCode::Copy,
|
||||||
// 134 => KeyCode::OPEN,
|
134 => KeyCode::Open,
|
||||||
// 135 => KeyCode::PASTE,
|
135 => KeyCode::Paste,
|
||||||
// 136 => KeyCode::FIND,
|
136 => KeyCode::Find,
|
||||||
// 137 => KeyCode::CUT,
|
137 => KeyCode::Cut,
|
||||||
// 138 => KeyCode::HELP,
|
138 => KeyCode::Help,
|
||||||
// 139 => KeyCode::MENU,
|
// 139 => KeyCode::MENU,
|
||||||
// 140 => KeyCode::CALC,
|
140 => KeyCode::LaunchApp2, // CALC
|
||||||
// 141 => KeyCode::SETUP,
|
// 141 => KeyCode::SETUP,
|
||||||
// 142 => KeyCode::SLEEP,
|
// 142 => KeyCode::SLEEP,
|
||||||
// 143 => KeyCode::WAKEUP,
|
143 => KeyCode::WakeUp,
|
||||||
// 144 => KeyCode::FILE,
|
144 => KeyCode::LaunchApp1, // FILE
|
||||||
// 145 => KeyCode::SENDFILE,
|
// 145 => KeyCode::SENDFILE,
|
||||||
// 146 => KeyCode::DELETEFILE,
|
// 146 => KeyCode::DELETEFILE,
|
||||||
// 147 => KeyCode::XFER,
|
// 147 => KeyCode::XFER,
|
||||||
|
|
@ -193,13 +196,13 @@ pub fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
|
||||||
// 152 => KeyCode::COFFEE,
|
// 152 => KeyCode::COFFEE,
|
||||||
// 153 => KeyCode::ROTATE_DISPLAY,
|
// 153 => KeyCode::ROTATE_DISPLAY,
|
||||||
// 154 => KeyCode::CYCLEWINDOWS,
|
// 154 => KeyCode::CYCLEWINDOWS,
|
||||||
// 155 => KeyCode::MAIL,
|
155 => KeyCode::LaunchMail,
|
||||||
// 156 => KeyCode::BOOKMARKS,
|
156 => KeyCode::BrowserFavorites, // BOOKMARKS
|
||||||
// 157 => KeyCode::COMPUTER,
|
// 157 => KeyCode::COMPUTER,
|
||||||
// 158 => KeyCode::BACK,
|
158 => KeyCode::BrowserBack,
|
||||||
// 159 => KeyCode::FORWARD,
|
159 => KeyCode::BrowserForward,
|
||||||
// 160 => KeyCode::CLOSECD,
|
// 160 => KeyCode::CLOSECD,
|
||||||
// 161 => KeyCode::EJECTCD,
|
161 => KeyCode::Eject, // EJECTCD
|
||||||
// 162 => KeyCode::EJECTCLOSECD,
|
// 162 => KeyCode::EJECTCLOSECD,
|
||||||
163 => KeyCode::MediaTrackNext,
|
163 => KeyCode::MediaTrackNext,
|
||||||
164 => KeyCode::MediaPlayPause,
|
164 => KeyCode::MediaPlayPause,
|
||||||
|
|
@ -209,9 +212,9 @@ pub fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
|
||||||
// 168 => KeyCode::REWIND,
|
// 168 => KeyCode::REWIND,
|
||||||
// 169 => KeyCode::PHONE,
|
// 169 => KeyCode::PHONE,
|
||||||
// 170 => KeyCode::ISO,
|
// 170 => KeyCode::ISO,
|
||||||
// 171 => KeyCode::CONFIG,
|
171 => KeyCode::MediaSelect, // CONFIG
|
||||||
// 172 => KeyCode::HOMEPAGE,
|
172 => KeyCode::BrowserHome,
|
||||||
// 173 => KeyCode::REFRESH,
|
173 => KeyCode::BrowserRefresh,
|
||||||
// 174 => KeyCode::EXIT,
|
// 174 => KeyCode::EXIT,
|
||||||
// 175 => KeyCode::MOVE,
|
// 175 => KeyCode::MOVE,
|
||||||
// 176 => KeyCode::EDIT,
|
// 176 => KeyCode::EDIT,
|
||||||
|
|
@ -250,7 +253,7 @@ pub fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
|
||||||
// 214 => KeyCode::QUESTION,
|
// 214 => KeyCode::QUESTION,
|
||||||
// 215 => KeyCode::EMAIL,
|
// 215 => KeyCode::EMAIL,
|
||||||
// 216 => KeyCode::CHAT,
|
// 216 => KeyCode::CHAT,
|
||||||
// 217 => KeyCode::SEARCH,
|
217 => KeyCode::BrowserSearch,
|
||||||
// 218 => KeyCode::CONNECT,
|
// 218 => KeyCode::CONNECT,
|
||||||
// 219 => KeyCode::FINANCE,
|
// 219 => KeyCode::FINANCE,
|
||||||
// 220 => KeyCode::SPORT,
|
// 220 => KeyCode::SPORT,
|
||||||
|
|
@ -419,10 +422,32 @@ pub fn physicalkey_to_scancode(key: PhysicalKey) -> Option<u32> {
|
||||||
KeyCode::SuperLeft => Some(125),
|
KeyCode::SuperLeft => Some(125),
|
||||||
KeyCode::SuperRight => Some(126),
|
KeyCode::SuperRight => Some(126),
|
||||||
KeyCode::ContextMenu => Some(127),
|
KeyCode::ContextMenu => Some(127),
|
||||||
|
KeyCode::BrowserStop => Some(128),
|
||||||
|
KeyCode::Again => Some(129),
|
||||||
|
KeyCode::Props => Some(130),
|
||||||
|
KeyCode::Undo => Some(131),
|
||||||
|
KeyCode::Select => Some(132),
|
||||||
|
KeyCode::Copy => Some(133),
|
||||||
|
KeyCode::Open => Some(134),
|
||||||
|
KeyCode::Paste => Some(135),
|
||||||
|
KeyCode::Find => Some(136),
|
||||||
|
KeyCode::Cut => Some(137),
|
||||||
|
KeyCode::Help => Some(138),
|
||||||
|
KeyCode::LaunchApp2 => Some(140),
|
||||||
|
KeyCode::WakeUp => Some(143),
|
||||||
|
KeyCode::LaunchApp1 => Some(144),
|
||||||
|
KeyCode::LaunchMail => Some(155),
|
||||||
|
KeyCode::BrowserFavorites => Some(156),
|
||||||
|
KeyCode::BrowserBack => Some(158),
|
||||||
|
KeyCode::BrowserForward => Some(159),
|
||||||
|
KeyCode::Eject => Some(161),
|
||||||
KeyCode::MediaTrackNext => Some(163),
|
KeyCode::MediaTrackNext => Some(163),
|
||||||
KeyCode::MediaPlayPause => Some(164),
|
KeyCode::MediaPlayPause => Some(164),
|
||||||
KeyCode::MediaTrackPrevious => Some(165),
|
KeyCode::MediaTrackPrevious => Some(165),
|
||||||
KeyCode::MediaStop => Some(166),
|
KeyCode::MediaStop => Some(166),
|
||||||
|
KeyCode::MediaSelect => Some(171),
|
||||||
|
KeyCode::BrowserHome => Some(172),
|
||||||
|
KeyCode::BrowserRefresh => Some(173),
|
||||||
KeyCode::F13 => Some(183),
|
KeyCode::F13 => Some(183),
|
||||||
KeyCode::F14 => Some(184),
|
KeyCode::F14 => Some(184),
|
||||||
KeyCode::F15 => Some(185),
|
KeyCode::F15 => Some(185),
|
||||||
|
|
@ -435,6 +460,7 @@ pub fn physicalkey_to_scancode(key: PhysicalKey) -> Option<u32> {
|
||||||
KeyCode::F22 => Some(192),
|
KeyCode::F22 => Some(192),
|
||||||
KeyCode::F23 => Some(193),
|
KeyCode::F23 => Some(193),
|
||||||
KeyCode::F24 => Some(194),
|
KeyCode::F24 => Some(194),
|
||||||
|
KeyCode::BrowserSearch => Some(217),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue