Merge branch 'zesterer/keyboard' into 'master'

Improve default keybindings and Key names

See merge request veloren/veloren!2532
This commit is contained in:
Joshua Barretto 2021-06-30 17:33:17 +00:00
commit 61edae79ae
3 changed files with 78 additions and 27 deletions

View File

@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Food now has limited regeneration strength but longer duration.
- Harvester boss now has new abilities and AI
- Death particles and SFX
- Default keybindings were made more consistent
### Removed

View File

@ -52,7 +52,7 @@ impl From<ControlSettingsSerde> for ControlSettings {
/// (roll and wall jump) are both situations where you cannot glide (the other
/// default mapping for LShift).
#[cfg(target_os = "macos")]
const MIDDLE_CLICK_KEY: KeyMouse = KeyMouse::Key(VirtualKeyCode::LShift);
const MIDDLE_CLICK_KEY: KeyMouse = KeyMouse::Key(VirtualKeyCode::Grave);
#[cfg(not(target_os = "macos"))]
const MIDDLE_CLICK_KEY: KeyMouse = KeyMouse::Mouse(MouseButton::Middle);
@ -124,22 +124,22 @@ impl ControlSettings {
GameInput::Sit => KeyMouse::Key(VirtualKeyCode::K),
GameInput::Dance => KeyMouse::Key(VirtualKeyCode::J),
GameInput::Greet => KeyMouse::Key(VirtualKeyCode::H),
GameInput::Glide => KeyMouse::Key(VirtualKeyCode::LShift),
GameInput::Glide => KeyMouse::Key(VirtualKeyCode::LControl),
GameInput::Climb => KeyMouse::Key(VirtualKeyCode::Space),
GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl),
GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LShift),
GameInput::SwimUp => KeyMouse::Key(VirtualKeyCode::Space),
GameInput::SwimDown => KeyMouse::Key(VirtualKeyCode::LShift),
GameInput::Fly => KeyMouse::Key(VirtualKeyCode::H),
GameInput::Sneak => KeyMouse::Key(VirtualKeyCode::LControl),
GameInput::Sneak => KeyMouse::Key(VirtualKeyCode::LShift),
GameInput::ToggleLantern => KeyMouse::Key(VirtualKeyCode::G),
GameInput::Mount => KeyMouse::Key(VirtualKeyCode::F),
GameInput::Map => KeyMouse::Key(VirtualKeyCode::M),
GameInput::Bag => KeyMouse::Key(VirtualKeyCode::B),
GameInput::Trade => KeyMouse::Key(VirtualKeyCode::R),
GameInput::Trade => KeyMouse::Key(VirtualKeyCode::T),
GameInput::Social => KeyMouse::Key(VirtualKeyCode::O),
GameInput::Crafting => KeyMouse::Key(VirtualKeyCode::C),
GameInput::Spellbook => KeyMouse::Key(VirtualKeyCode::P),
GameInput::Settings => KeyMouse::Key(VirtualKeyCode::N),
GameInput::Settings => KeyMouse::Key(VirtualKeyCode::F10),
GameInput::Help => KeyMouse::Key(VirtualKeyCode::F1),
GameInput::ToggleInterface => KeyMouse::Key(VirtualKeyCode::F2),
GameInput::ToggleDebug => KeyMouse::Key(VirtualKeyCode::F3),
@ -149,7 +149,7 @@ impl ControlSettings {
GameInput::Roll => MIDDLE_CLICK_KEY,
GameInput::Respawn => KeyMouse::Key(VirtualKeyCode::Space),
GameInput::Interact => KeyMouse::Key(VirtualKeyCode::E),
GameInput::ToggleWield => KeyMouse::Key(VirtualKeyCode::T),
GameInput::ToggleWield => KeyMouse::Key(VirtualKeyCode::R),
GameInput::FreeLook => KeyMouse::Key(VirtualKeyCode::L),
GameInput::AutoWalk => KeyMouse::Key(VirtualKeyCode::Period),
GameInput::CameraClamp => KeyMouse::Key(VirtualKeyCode::Apostrophe),
@ -165,9 +165,9 @@ impl ControlSettings {
GameInput::Slot9 => KeyMouse::Key(VirtualKeyCode::Key9),
GameInput::Slot10 => KeyMouse::Key(VirtualKeyCode::Q),
GameInput::SwapLoadout => KeyMouse::Key(VirtualKeyCode::Tab),
GameInput::Select => KeyMouse::Key(VirtualKeyCode::Y),
GameInput::AcceptGroupInvite => KeyMouse::Key(VirtualKeyCode::U),
GameInput::DeclineGroupInvite => KeyMouse::Key(VirtualKeyCode::I),
GameInput::Select => KeyMouse::Key(VirtualKeyCode::X),
GameInput::AcceptGroupInvite => KeyMouse::Key(VirtualKeyCode::Y),
GameInput::DeclineGroupInvite => KeyMouse::Key(VirtualKeyCode::N),
GameInput::MapZoomIn => KeyMouse::Key(VirtualKeyCode::Plus),
GameInput::MapZoomOut => KeyMouse::Key(VirtualKeyCode::Minus),
}

View File

@ -445,11 +445,8 @@ impl KeyMouse {
Key(Grave) => "`",
Key(Kana) => "Kana",
Key(Kanji) => "Kanji",
Key(LAlt) => "LAlt",
Key(LBracket) => "[",
Key(LControl) => "LControl",
Key(LShift) => "LShift",
Key(LWin) => "LWin",
Key(RBracket) => "]",
Key(Mail) => "Mail",
Key(MediaSelect) => "MediaSelect",
Key(MediaStop) => "MediaStop",
@ -457,23 +454,76 @@ impl KeyMouse {
Key(NumpadMultiply) => "Numpad *",
Key(Mute) => "Mute",
Key(MyComputer) => "My Computer",
Key(NavigateForward) => "Navigate Forward",
Key(NavigateBackward) => "Navigate Backward",
Key(NextTrack) => "Next Track",
Key(NavigateForward) => "Navigate Forward",
Key(NoConvert) => "Non Convert",
Key(NumpadComma) => "Num ,",
Key(NumpadEnter) => "Num Enter",
Key(NumpadEquals) => "Num =",
Key(OEM102) => "<",
Key(Period) => ".",
Key(PlayPause) => "Play / Pause",
Key(Power) => "Power",
Key(PlayPause) => "Play / Pause",
Key(PrevTrack) => "Prev Track",
Key(RAlt) => "RAlt",
Key(RBracket) => "]",
Key(RControl) => "RControl",
Key(RShift) => "RShift",
Key(RWin) => "RWin",
Key(NextTrack) => "Next Track",
Key(LAlt) => {
if cfg!(macos) {
"Left Option ⌥"
} else {
// Assume Windows, Linux, BSD, etc.
"Left Alt"
}
},
Key(RAlt) => {
if cfg!(macos) {
"Right Option ⌥"
} else {
// Assume Windows, Linux, BSD, etc.
"Right Alt"
}
},
Key(LControl) => {
if cfg!(macos) {
"Left Cmd ⌘"
} else {
// Assume Windows, Linux, BSD, etc.
"Left Ctrl"
}
},
Key(RControl) => {
if cfg!(macos) {
"Right Cmd ⌘"
} else {
// Assume Windows, Linux, BSD, etc.
"Right Ctrl"
}
},
Key(LShift) => "Left Shift",
Key(RShift) => "Right Shift",
// Key doesn't usually have a right counterpart on modern keyboards, to omit the
// qualifier. The exception to this is Mac OS which doesn't usually have
// this key at all, so we keep the qualifier to minimise ambiguity.
Key(LWin) => {
if cfg!(windows) {
"Win ⊞"
} else if cfg!(macos) {
"Left Cmd ⌘ (Super)" // Extra qualifier because both Ctrl and Win map to Cmd on Mac
} else {
// Assume Linux, BSD, etc.
"Super"
}
},
// Most keyboards don't have this key, so throw in all the qualifiers
Key(RWin) => {
if cfg!(windows) {
"Right Win ⊞"
} else if cfg!(macos) {
"Right Cmd ⌘ (Super)" // Extra qualifier because both Ctrl and Win map to Cmd on Mac
} else {
// Assume Linux, BSD, etc.
"Right Super"
}
},
Key(Semicolon) => ";",
Key(Slash) => "/",
Key(Sleep) => "Sleep",
@ -499,18 +549,18 @@ impl KeyMouse {
Key(Cut) => "Cut",
Key(Asterisk) => "*",
Key(Plus) => "+",
Mouse(MouseButton::Left) => "M1",
Mouse(MouseButton::Right) => "M2",
Mouse(MouseButton::Middle) => "M3",
Mouse(MouseButton::Left) => "Left Click",
Mouse(MouseButton::Right) => "Right Click",
Mouse(MouseButton::Middle) => "Middle Click",
Mouse(MouseButton::Other(button)) => {
// Additional mouse buttons after middle click start at 1
return format!("M{}", button + 3);
return format!("Mouse {}", button + 3);
},
ScanKey(scancode) => {
if let Some(layout) = key_layout {
return layout.get_key_as_string(*scancode);
} else {
return format!("Unknown({})", scancode);
return format!("Unknown (0x{:X})", scancode);
}
},
};