-
Hello! I'm currently trying to bump up the As you can see here, we are emulating a WindowEvent: example.update(winit::event::WindowEvent::KeyboardInput {
input: winit::event::KeyboardInput {
scancode: 0,
state: winit::event::ElementState::Pressed,
virtual_keycode: Some(winit::event::VirtualKeyCode::Space),
modifiers: winit::event::ModifiersState::empty(),
},
device_id: unsafe { winit::event::DeviceId::dummy() },
is_synthetic: false,
}); I tried to update this part of code and got the following result: example.update(winit::event::WindowEvent::KeyboardInput {
event: KeyEvent {
physical_key: PhysicalKey::Code(KeyCode::Space),
state: ElementState::Pressed,
logical_key: Key::Named(NamedKey::Space),
text: None,
location: KeyLocation::Standard,
repeat: false,
platform_specific: false,
},
device_id: unsafe { winit::event::DeviceId::dummy() },
is_synthetic: false,
}); However, I've got a problem with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is so cursed... Why not just use a I could think of creating such events for testing purposes, and hide the platform_specific field for tests, but not sure what to do with general code, since platform specific fields sometimes are required... I'd just suggest to not do what you're doing in this example, since there's clearly some abuse going on. |
Beta Was this translation helpful? Give feedback.
This is so cursed...
Why not just use a
logical_key
? Maybe some other state you actually need instead of doing synthetic event like that.I could think of creating such events for testing purposes, and hide the platform_specific field for tests, but not sure what to do with general code, since platform specific fields sometimes are required...
I'd just suggest to not do what you're doing in this example, since there's clearly some abuse going on.