virtual key codes
This commit is contained in:
@@ -4,6 +4,7 @@ mod tests {
|
||||
use winit::{dpi::PhysicalPosition, event::{DeviceId, ElementState, Event, Force, KeyboardInput, ModifiersState, Touch, TouchPhase, WindowEvent}, window::WindowId};
|
||||
|
||||
use crate::{config::LogConfig, game::player::{intersect_triangle}, input::InputState};
|
||||
use crate::input::vk_to_scan_code;
|
||||
|
||||
fn epsilon_eq(f1: f32, f2: f32) {
|
||||
assert!(f32::abs(f1 - f2) < f32::EPSILON, "{} == {}", f1, f2);
|
||||
@@ -71,6 +72,16 @@ mod tests {
|
||||
}
|
||||
state.frame_start();
|
||||
assert_eq!(state.button_down("quit"), false);
|
||||
state.frame_end();
|
||||
unsafe {
|
||||
state.on_window_event(&Event::WindowEvent{ window_id: WindowId::dummy(), event: WindowEvent::KeyboardInput {
|
||||
device_id: DeviceId::dummy(),
|
||||
input: KeyboardInput { scancode: 32, state: ElementState::Pressed, virtual_keycode: None, modifiers: ModifiersState::empty() },
|
||||
is_synthetic: true,
|
||||
}});
|
||||
}
|
||||
state.frame_start();
|
||||
assert_eq!(state.button_down("button_right"), true);
|
||||
}
|
||||
|
||||
fn touch_event(state: &mut InputState, phase: TouchPhase, id: u64) {
|
||||
@@ -136,4 +147,10 @@ mod tests {
|
||||
// assert_eq!(state.button_just_released("doubletouchclick"), false);
|
||||
assert_eq!(state.button_down("doubletouchclick"), false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vk_input_name_test() {
|
||||
let vk = "VK_ESCAPE";
|
||||
assert_eq!(vk_to_scan_code(vk), Some(1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user