mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
working towards #861 -
Use scancodes for (at minimum) key remapping added ScanCode fallback for when winit doesn't provide a VirtualKeyCode renamed SKey to ScanKey
This commit is contained in:
parent
55c49f88e6
commit
5f9984df12
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Reflective LoD water
|
- Reflective LoD water
|
||||||
- Map indicators for group members
|
- Map indicators for group members
|
||||||
- Hot-reloading for i18n, sounds, loot lotteries, and more
|
- Hot-reloading for i18n, sounds, loot lotteries, and more
|
||||||
|
- Initial support for alternate style keyboards
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -311,6 +311,7 @@ pub type EventLoop = winit::event_loop::EventLoop<()>;
|
|||||||
pub enum KeyMouse {
|
pub enum KeyMouse {
|
||||||
Key(winit::event::VirtualKeyCode),
|
Key(winit::event::VirtualKeyCode),
|
||||||
Mouse(winit::event::MouseButton),
|
Mouse(winit::event::MouseButton),
|
||||||
|
ScanKey(winit::event::ScanCode),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for KeyMouse {
|
impl fmt::Display for KeyMouse {
|
||||||
@ -487,6 +488,7 @@ impl fmt::Display for KeyMouse {
|
|||||||
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 write!(f, "M{}", button + 3),
|
return write!(f, "M{}", button + 3),
|
||||||
|
ScanKey(_) => "Unknown",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -992,47 +994,48 @@ impl Window {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(key) = input.virtual_keycode {
|
let input_key = match input.virtual_keycode {
|
||||||
if let Some(game_inputs) = Window::map_input(
|
Some(key) => KeyMouse::Key(key),
|
||||||
KeyMouse::Key(key),
|
None => KeyMouse::ScanKey(input.scancode),
|
||||||
controls,
|
};
|
||||||
&mut self.remapping_keybindings,
|
|
||||||
) {
|
if let Some(game_inputs) =
|
||||||
for game_input in game_inputs {
|
Window::map_input(input_key, controls, &mut self.remapping_keybindings)
|
||||||
match game_input {
|
{
|
||||||
GameInput::Fullscreen => {
|
for game_input in game_inputs {
|
||||||
if input.state == winit::event::ElementState::Pressed
|
match game_input {
|
||||||
&& !Self::is_pressed(
|
GameInput::Fullscreen => {
|
||||||
&mut self.keypress_map,
|
if input.state == winit::event::ElementState::Pressed
|
||||||
GameInput::Fullscreen,
|
&& !Self::is_pressed(
|
||||||
)
|
|
||||||
{
|
|
||||||
self.toggle_fullscreen = !self.toggle_fullscreen;
|
|
||||||
}
|
|
||||||
Self::set_pressed(
|
|
||||||
&mut self.keypress_map,
|
&mut self.keypress_map,
|
||||||
GameInput::Fullscreen,
|
GameInput::Fullscreen,
|
||||||
input.state,
|
)
|
||||||
);
|
{
|
||||||
},
|
self.toggle_fullscreen = !self.toggle_fullscreen;
|
||||||
GameInput::Screenshot => {
|
}
|
||||||
self.take_screenshot = input.state
|
Self::set_pressed(
|
||||||
== winit::event::ElementState::Pressed
|
&mut self.keypress_map,
|
||||||
&& !Self::is_pressed(
|
GameInput::Fullscreen,
|
||||||
&mut self.keypress_map,
|
input.state,
|
||||||
GameInput::Screenshot,
|
);
|
||||||
);
|
},
|
||||||
Self::set_pressed(
|
GameInput::Screenshot => {
|
||||||
|
self.take_screenshot = input.state
|
||||||
|
== winit::event::ElementState::Pressed
|
||||||
|
&& !Self::is_pressed(
|
||||||
&mut self.keypress_map,
|
&mut self.keypress_map,
|
||||||
GameInput::Screenshot,
|
GameInput::Screenshot,
|
||||||
input.state,
|
|
||||||
);
|
);
|
||||||
},
|
Self::set_pressed(
|
||||||
_ => self.events.push(Event::InputUpdate(
|
&mut self.keypress_map,
|
||||||
*game_input,
|
GameInput::Screenshot,
|
||||||
input.state == winit::event::ElementState::Pressed,
|
input.state,
|
||||||
)),
|
);
|
||||||
}
|
},
|
||||||
|
_ => self.events.push(Event::InputUpdate(
|
||||||
|
*game_input,
|
||||||
|
input.state == winit::event::ElementState::Pressed,
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user