Skip to content
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

Rename keys like LAlt to AltLeft #8792

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions crates/bevy_input/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +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 `LWin` / `Left Windows` key. Maps to `Left Command` on Mac.
LWin,
/// The `Left Alt` key. Maps to `Left Option` on Mac.
AltLeft,
Comment on lines +321 to +322
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor thing: The doc string is now the reverse of the actual name.
Not sure if this matters though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm not a fan of winit's naming here but it makes sense to be consistent with them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this is fine.

/// 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"))]
SuperLeft,

/// The `Mail` key.
Mail,
Expand Down Expand Up @@ -368,16 +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 `RWin` / `Right Windows` key. Maps to `Right Command` on Mac.
RWin,
/// 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"))]
SuperRight,

/// The `Semicolon` / `;` key.
Semicolon,
Expand Down
20 changes: 10 additions & 10 deletions crates/bevy_winit/src/converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::LWin,
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,
Expand All @@ -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::RWin,
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,
Expand Down
4 changes: 2 additions & 2 deletions examples/3d/fog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/shadow_biases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/skybox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions examples/input/keyboard_modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn main() {

/// This system prints when `Ctrl + Shift + A` is pressed
fn keyboard_input_system(input: Res<Input<KeyCode>>) {
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!");
Expand Down
2 changes: 1 addition & 1 deletion examples/tools/scene_viewer/camera_controller_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down