I tried to update this part of code and got the following result:
\n example.update(winit::event::WindowEvent::KeyboardInput {\n event: KeyEvent {\n physical_key: PhysicalKey::Code(KeyCode::Space),\n state: ElementState::Pressed,\n logical_key: Key::Named(NamedKey::Space),\n text: None,\n location: KeyLocation::Standard,\n repeat: false,\n platform_specific: false,\n },\n device_id: unsafe { winit::event::DeviceId::dummy() },\n is_synthetic: false,\n });
However, I've got a problem with platdform_specific: false
here, since it's a private attribute and I couldn't find a new
constructor or something like that for it. May I ask what's the proper way to fix this with the latest winit
update?
This is so cursed...
\nWhy 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...
\nI'd just suggest to not do what you're doing in this example, since there's clearly some abuse going on.
","upvoteCount":1,"url":"https://github.com/rust-windowing/winit/discussions/3176#discussioncomment-7363114"}}}-
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.
-
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.