From 2bf5ec5ca4210b6478d50bdeb683b1c15a3eb8ab Mon Sep 17 00:00:00 2001 From: Jim Eckerlein Date: Thu, 8 Jun 2023 16:12:48 +0200 Subject: [PATCH 1/3] Rename `LWin` and `RWin` to `LSuper` and `RSuper` --- crates/bevy_input/src/keyboard.rs | 12 ++++++++---- crates/bevy_winit/src/converters.rs | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/bevy_input/src/keyboard.rs b/crates/bevy_input/src/keyboard.rs index cc14bac968689..eb568019a7874 100644 --- a/crates/bevy_input/src/keyboard.rs +++ b/crates/bevy_input/src/keyboard.rs @@ -326,8 +326,10 @@ pub enum KeyCode { LControl, /// The `LShift` / `Left Shift` key. LShift, - /// The `LWin` / `Left Windows` key. Maps to `Left Command` on Mac. - LWin, + /// The `LSuper` / `Left Super` key. + /// Generic keyboards usually display this key with the *Microsoft Windows* logo. + /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character. + LSuper, /// The `Mail` key. Mail, @@ -376,8 +378,10 @@ pub enum KeyCode { RControl, /// The `RShift` / `Right Shift` key. RShift, - /// The `RWin` / `Right Windows` key. Maps to `Right Command` on Mac. - RWin, + /// The `RSuper` / `Right Super` key. + /// Generic keyboards usually display this key with the *Microsoft Windows* logo. + /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character. + RSuper, /// The `Semicolon` / `;` key. Semicolon, diff --git a/crates/bevy_winit/src/converters.rs b/crates/bevy_winit/src/converters.rs index 65591f6b9910d..566c9640a94cf 100644 --- a/crates/bevy_winit/src/converters.rs +++ b/crates/bevy_winit/src/converters.rs @@ -176,7 +176,7 @@ pub fn convert_virtual_key_code(virtual_key_code: winit::event::VirtualKeyCode) winit::event::VirtualKeyCode::LBracket => KeyCode::LBracket, winit::event::VirtualKeyCode::LControl => KeyCode::LControl, winit::event::VirtualKeyCode::LShift => KeyCode::LShift, - winit::event::VirtualKeyCode::LWin => KeyCode::LWin, + winit::event::VirtualKeyCode::LWin => KeyCode::LSuper, winit::event::VirtualKeyCode::Mail => KeyCode::Mail, winit::event::VirtualKeyCode::MediaSelect => KeyCode::MediaSelect, winit::event::VirtualKeyCode::MediaStop => KeyCode::MediaStop, @@ -200,7 +200,7 @@ pub fn convert_virtual_key_code(virtual_key_code: winit::event::VirtualKeyCode) winit::event::VirtualKeyCode::RBracket => KeyCode::RBracket, winit::event::VirtualKeyCode::RControl => KeyCode::RControl, winit::event::VirtualKeyCode::RShift => KeyCode::RShift, - winit::event::VirtualKeyCode::RWin => KeyCode::RWin, + winit::event::VirtualKeyCode::RWin => KeyCode::RSuper, winit::event::VirtualKeyCode::Semicolon => KeyCode::Semicolon, winit::event::VirtualKeyCode::Slash => KeyCode::Slash, winit::event::VirtualKeyCode::Sleep => KeyCode::Sleep, From 8e7bd2b7461f7a7dab5ca64d2d40825685b23870 Mon Sep 17 00:00:00 2001 From: Jim Eckerlein Date: Thu, 8 Jun 2023 19:40:40 +0200 Subject: [PATCH 2/3] Add doc aliases `Win`, `Meta`, and `Logo` --- crates/bevy_input/src/keyboard.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bevy_input/src/keyboard.rs b/crates/bevy_input/src/keyboard.rs index eb568019a7874..e25e4af113cc3 100644 --- a/crates/bevy_input/src/keyboard.rs +++ b/crates/bevy_input/src/keyboard.rs @@ -329,6 +329,7 @@ pub enum KeyCode { /// The `LSuper` / `Left Super` key. /// Generic keyboards usually display this key with the *Microsoft Windows* logo. /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character. + #[doc(alias("LWin", "LMeta", "LLogo"))] LSuper, /// The `Mail` key. @@ -381,6 +382,7 @@ pub enum KeyCode { /// The `RSuper` / `Right Super` key. /// Generic keyboards usually display this key with the *Microsoft Windows* logo. /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character. + #[doc(alias("RWin", "RMeta", "RLogo"))] RSuper, /// The `Semicolon` / `;` key. From b5969ae7a1a0a20b51a2b41a7099079e500c2466 Mon Sep 17 00:00:00 2001 From: Jim Eckerlein Date: Fri, 9 Jun 2023 00:17:57 +0200 Subject: [PATCH 3/3] Rename to `AltLeft` ect. --- crates/bevy_input/src/keyboard.rs | 40 +++++++++---------- crates/bevy_winit/src/converters.rs | 20 +++++----- examples/3d/fog.rs | 4 +- examples/3d/shadow_biases.rs | 2 +- examples/3d/skybox.rs | 2 +- examples/input/keyboard_modifiers.rs | 4 +- .../scene_viewer/camera_controller_plugin.rs | 2 +- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/crates/bevy_input/src/keyboard.rs b/crates/bevy_input/src/keyboard.rs index e25e4af113cc3..8597476c1bcb3 100644 --- a/crates/bevy_input/src/keyboard.rs +++ b/crates/bevy_input/src/keyboard.rs @@ -318,19 +318,19 @@ pub enum KeyCode { /// The `Kanji` key. Kanji, - /// The `LAlt` / `Left Alt` key. Maps to `Left Option` on Mac. - LAlt, - /// The `LBracket` / `Left Bracket` key. - LBracket, - /// The `LControl` / `Left Control` key. - LControl, - /// The `LShift` / `Left Shift` key. - LShift, - /// The `LSuper` / `Left Super` key. + /// The `Left Alt` key. Maps to `Left Option` on Mac. + AltLeft, + /// The `Left Bracket` / `[` key. + BracketLeft, + /// The `Left Control` key. + ControlLeft, + /// The `Left Shift` key. + ShiftLeft, + /// The `Left Super` key. /// Generic keyboards usually display this key with the *Microsoft Windows* logo. /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character. #[doc(alias("LWin", "LMeta", "LLogo"))] - LSuper, + SuperLeft, /// The `Mail` key. Mail, @@ -371,19 +371,19 @@ pub enum KeyCode { /// The `PrevTrack` key. PrevTrack, - /// The `RAlt` / `Right Alt` key. Maps to `Right Option` on Mac. - RAlt, - /// The `RBracket` / `Right Bracket` key. - RBracket, - /// The `RControl` / `Right Control` key. - RControl, - /// The `RShift` / `Right Shift` key. - RShift, - /// The `RSuper` / `Right Super` key. + /// The `Right Alt` key. Maps to `Right Option` on Mac. + AltRight, + /// The `Right Bracket` / `]` key. + BracketRight, + /// The `Right Control` key. + ControlRight, + /// The `Right Shift` key. + ShiftRight, + /// The `Right Super` key. /// Generic keyboards usually display this key with the *Microsoft Windows* logo. /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character. #[doc(alias("RWin", "RMeta", "RLogo"))] - RSuper, + SuperRight, /// The `Semicolon` / `;` key. Semicolon, diff --git a/crates/bevy_winit/src/converters.rs b/crates/bevy_winit/src/converters.rs index 566c9640a94cf..550d6160dadba 100644 --- a/crates/bevy_winit/src/converters.rs +++ b/crates/bevy_winit/src/converters.rs @@ -172,11 +172,11 @@ pub fn convert_virtual_key_code(virtual_key_code: winit::event::VirtualKeyCode) winit::event::VirtualKeyCode::Grave => KeyCode::Grave, winit::event::VirtualKeyCode::Kana => KeyCode::Kana, winit::event::VirtualKeyCode::Kanji => KeyCode::Kanji, - winit::event::VirtualKeyCode::LAlt => KeyCode::LAlt, - winit::event::VirtualKeyCode::LBracket => KeyCode::LBracket, - winit::event::VirtualKeyCode::LControl => KeyCode::LControl, - winit::event::VirtualKeyCode::LShift => KeyCode::LShift, - winit::event::VirtualKeyCode::LWin => KeyCode::LSuper, + winit::event::VirtualKeyCode::LAlt => KeyCode::AltLeft, + winit::event::VirtualKeyCode::LBracket => KeyCode::BracketLeft, + winit::event::VirtualKeyCode::LControl => KeyCode::ControlLeft, + winit::event::VirtualKeyCode::LShift => KeyCode::ShiftLeft, + winit::event::VirtualKeyCode::LWin => KeyCode::SuperLeft, winit::event::VirtualKeyCode::Mail => KeyCode::Mail, winit::event::VirtualKeyCode::MediaSelect => KeyCode::MediaSelect, winit::event::VirtualKeyCode::MediaStop => KeyCode::MediaStop, @@ -196,11 +196,11 @@ pub fn convert_virtual_key_code(virtual_key_code: winit::event::VirtualKeyCode) winit::event::VirtualKeyCode::PlayPause => KeyCode::PlayPause, winit::event::VirtualKeyCode::Power => KeyCode::Power, winit::event::VirtualKeyCode::PrevTrack => KeyCode::PrevTrack, - winit::event::VirtualKeyCode::RAlt => KeyCode::RAlt, - winit::event::VirtualKeyCode::RBracket => KeyCode::RBracket, - winit::event::VirtualKeyCode::RControl => KeyCode::RControl, - winit::event::VirtualKeyCode::RShift => KeyCode::RShift, - winit::event::VirtualKeyCode::RWin => KeyCode::RSuper, + winit::event::VirtualKeyCode::RAlt => KeyCode::AltRight, + winit::event::VirtualKeyCode::RBracket => KeyCode::BracketRight, + winit::event::VirtualKeyCode::RControl => KeyCode::ControlRight, + winit::event::VirtualKeyCode::RShift => KeyCode::ShiftRight, + winit::event::VirtualKeyCode::RWin => KeyCode::SuperRight, winit::event::VirtualKeyCode::Semicolon => KeyCode::Semicolon, winit::event::VirtualKeyCode::Slash => KeyCode::Slash, winit::event::VirtualKeyCode::Sleep => KeyCode::Sleep, diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index bdd977df8ecb8..35d381ce0fced 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -284,12 +284,12 @@ fn update_system( fog.color.set_r(r); } - if keycode.pressed(KeyCode::LBracket) { + if keycode.pressed(KeyCode::BracketLeft) { let g = (fog.color.g() - 0.1 * delta).max(0.0); fog.color.set_g(g); } - if keycode.pressed(KeyCode::RBracket) { + if keycode.pressed(KeyCode::BracketRight) { let g = (fog.color.g() + 0.1 * delta).min(1.0); fog.color.set_g(g); } diff --git a/examples/3d/shadow_biases.rs b/examples/3d/shadow_biases.rs index a4fc96413681b..6ed89ce89f237 100644 --- a/examples/3d/shadow_biases.rs +++ b/examples/3d/shadow_biases.rs @@ -256,7 +256,7 @@ impl Default for CameraController { key_right: KeyCode::D, key_up: KeyCode::E, key_down: KeyCode::Q, - key_run: KeyCode::LShift, + key_run: KeyCode::ShiftLeft, walk_speed: 10.0, run_speed: 30.0, friction: 0.5, diff --git a/examples/3d/skybox.rs b/examples/3d/skybox.rs index 986114bfdba08..7cc6b91c4b5f6 100644 --- a/examples/3d/skybox.rs +++ b/examples/3d/skybox.rs @@ -209,7 +209,7 @@ impl Default for CameraController { key_right: KeyCode::D, key_up: KeyCode::E, key_down: KeyCode::Q, - key_run: KeyCode::LShift, + key_run: KeyCode::ShiftLeft, mouse_key_enable_mouse: MouseButton::Left, keyboard_key_enable_mouse: KeyCode::M, walk_speed: 2.0, diff --git a/examples/input/keyboard_modifiers.rs b/examples/input/keyboard_modifiers.rs index 271e133d7a063..1ec1232fbf1af 100644 --- a/examples/input/keyboard_modifiers.rs +++ b/examples/input/keyboard_modifiers.rs @@ -11,8 +11,8 @@ fn main() { /// This system prints when `Ctrl + Shift + A` is pressed fn keyboard_input_system(input: Res>) { - let shift = input.any_pressed([KeyCode::LShift, KeyCode::RShift]); - let ctrl = input.any_pressed([KeyCode::LControl, KeyCode::RControl]); + let shift = input.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight]); + let ctrl = input.any_pressed([KeyCode::ControlLeft, KeyCode::ControlRight]); if ctrl && shift && input.just_pressed(KeyCode::A) { info!("Just pressed Ctrl + Shift + A!"); diff --git a/examples/tools/scene_viewer/camera_controller_plugin.rs b/examples/tools/scene_viewer/camera_controller_plugin.rs index eac0d5baf7066..f786b2f04b80d 100644 --- a/examples/tools/scene_viewer/camera_controller_plugin.rs +++ b/examples/tools/scene_viewer/camera_controller_plugin.rs @@ -48,7 +48,7 @@ impl Default for CameraController { key_right: KeyCode::D, key_up: KeyCode::E, key_down: KeyCode::Q, - key_run: KeyCode::LShift, + key_run: KeyCode::ShiftLeft, mouse_key_enable_mouse: MouseButton::Left, keyboard_key_enable_mouse: KeyCode::M, walk_speed: 5.0,