-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Keyboard input not captured on latest macOS 10.15.2 system #1470
Copy link
Copy link
Open
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedC - needs investigationIssue must be confirmed and researchedIssue must be confirmed and researchedDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backendH - help wantedSomeone please save usSomeone please save us
Description
Hello! I recently updated my macOS Catalina to 10.15.2. When I try to write winit code like this:
fn main() {
let event_loop = winit::event_loop::EventLoop::new();
winit::window::WindowBuilder::new()
.with_title("Hello world!")
.with_inner_size(winit::dpi::LogicalSize::new(1024.0, 768.0))
.build(&event_loop).unwrap();
event_loop.run(|ev, _target, flow| match ev {
winit::event::Event::WindowEvent { event, .. } => match event {
winit::event::WindowEvent::CloseRequested =>
*flow = winit::event_loop::ControlFlow::Exit,
winit::event::WindowEvent::KeyboardInput {
device_id, input: kin, is_synthetic: _
} => {
println!("WindowEvent Key: {:?} DeviceId: {:?}", kin, device_id);
},
_ => {},
},
winit::event::Event::DeviceEvent { event, device_id } => match event {
winit::event::DeviceEvent::Key(kin) => {
println!("DeviceEvent Key: {:?} DeviceId: {:?}", kin, device_id);
},
_ => {},
},
_ => {},
});
}When I run and press any keys, I expect to have an both WindowEvent and DeviceEvent in the output. However the output is like this:
WindowEvent Key: KeyboardInput { scancode: 23, state: Pressed, virtual_keycode: Some(Key5), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 23, state: Released, virtual_keycode: Some(Key5), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 22, state: Pressed, virtual_keycode: Some(Key6), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 22, state: Released, virtual_keycode: Some(Key6), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 28, state: Pressed, virtual_keycode: Some(Key8), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 28, state: Released, virtual_keycode: Some(Key8), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 25, state: Pressed, virtual_keycode: Some(Key9), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
WindowEvent Key: KeyboardInput { scancode: 25, state: Released, virtual_keycode: Some(Key9), modifiers: (empty) } DeviceId: DeviceId(DeviceId)
There is no DeviceEvent in the output. Is this expected behavior to have WindowEvent only? Or is there something wrong with my code or operating system (permission or something)? Thanks!
My winit version is winit = "0.21.0".
(I have raised issue at glium/glium#1822 , but that could be an issue on winit)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedC - needs investigationIssue must be confirmed and researchedIssue must be confirmed and researchedDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backendH - help wantedSomeone please save usSomeone please save us