mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improved key names and platform support
This commit is contained in:
parent
593e47418c
commit
a7f7ea6327
@ -445,11 +445,8 @@ impl KeyMouse {
|
|||||||
Key(Grave) => "`",
|
Key(Grave) => "`",
|
||||||
Key(Kana) => "Kana",
|
Key(Kana) => "Kana",
|
||||||
Key(Kanji) => "Kanji",
|
Key(Kanji) => "Kanji",
|
||||||
Key(LAlt) => "LAlt",
|
|
||||||
Key(LBracket) => "[",
|
Key(LBracket) => "[",
|
||||||
Key(LControl) => "LControl",
|
Key(RBracket) => "]",
|
||||||
Key(LShift) => "LShift",
|
|
||||||
Key(LWin) => "LWin",
|
|
||||||
Key(Mail) => "Mail",
|
Key(Mail) => "Mail",
|
||||||
Key(MediaSelect) => "MediaSelect",
|
Key(MediaSelect) => "MediaSelect",
|
||||||
Key(MediaStop) => "MediaStop",
|
Key(MediaStop) => "MediaStop",
|
||||||
@ -457,23 +454,76 @@ impl KeyMouse {
|
|||||||
Key(NumpadMultiply) => "Numpad *",
|
Key(NumpadMultiply) => "Numpad *",
|
||||||
Key(Mute) => "Mute",
|
Key(Mute) => "Mute",
|
||||||
Key(MyComputer) => "My Computer",
|
Key(MyComputer) => "My Computer",
|
||||||
Key(NavigateForward) => "Navigate Forward",
|
|
||||||
Key(NavigateBackward) => "Navigate Backward",
|
Key(NavigateBackward) => "Navigate Backward",
|
||||||
Key(NextTrack) => "Next Track",
|
Key(NavigateForward) => "Navigate Forward",
|
||||||
Key(NoConvert) => "Non Convert",
|
Key(NoConvert) => "Non Convert",
|
||||||
Key(NumpadComma) => "Num ,",
|
Key(NumpadComma) => "Num ,",
|
||||||
Key(NumpadEnter) => "Num Enter",
|
Key(NumpadEnter) => "Num Enter",
|
||||||
Key(NumpadEquals) => "Num =",
|
Key(NumpadEquals) => "Num =",
|
||||||
Key(OEM102) => "<",
|
Key(OEM102) => "<",
|
||||||
Key(Period) => ".",
|
Key(Period) => ".",
|
||||||
Key(PlayPause) => "Play / Pause",
|
|
||||||
Key(Power) => "Power",
|
Key(Power) => "Power",
|
||||||
|
Key(PlayPause) => "Play / Pause",
|
||||||
Key(PrevTrack) => "Prev Track",
|
Key(PrevTrack) => "Prev Track",
|
||||||
Key(RAlt) => "RAlt",
|
Key(NextTrack) => "Next Track",
|
||||||
Key(RBracket) => "]",
|
Key(LAlt) => {
|
||||||
Key(RControl) => "RControl",
|
if cfg!(macos) {
|
||||||
Key(RShift) => "RShift",
|
"Left Option ⌥"
|
||||||
Key(RWin) => "RWin",
|
} 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(Semicolon) => ";",
|
||||||
Key(Slash) => "/",
|
Key(Slash) => "/",
|
||||||
Key(Sleep) => "Sleep",
|
Key(Sleep) => "Sleep",
|
||||||
@ -499,18 +549,18 @@ impl KeyMouse {
|
|||||||
Key(Cut) => "Cut",
|
Key(Cut) => "Cut",
|
||||||
Key(Asterisk) => "*",
|
Key(Asterisk) => "*",
|
||||||
Key(Plus) => "+",
|
Key(Plus) => "+",
|
||||||
Mouse(MouseButton::Left) => "M1",
|
Mouse(MouseButton::Left) => "Left Click",
|
||||||
Mouse(MouseButton::Right) => "M2",
|
Mouse(MouseButton::Right) => "Right Click",
|
||||||
Mouse(MouseButton::Middle) => "M3",
|
Mouse(MouseButton::Middle) => "Middle Click",
|
||||||
Mouse(MouseButton::Other(button)) => {
|
Mouse(MouseButton::Other(button)) => {
|
||||||
// Additional mouse buttons after middle click start at 1
|
// Additional mouse buttons after middle click start at 1
|
||||||
return format!("M{}", button + 3);
|
return format!("Mouse {}", button + 3);
|
||||||
},
|
},
|
||||||
ScanKey(scancode) => {
|
ScanKey(scancode) => {
|
||||||
if let Some(layout) = key_layout {
|
if let Some(layout) = key_layout {
|
||||||
return layout.get_key_as_string(*scancode);
|
return layout.get_key_as_string(*scancode);
|
||||||
} else {
|
} else {
|
||||||
return format!("Unknown({})", scancode);
|
return format!("Unknown (0x{:X})", scancode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user