@@ -10,7 +10,6 @@ pub use winit;
1010use winit:: {
1111 dpi:: { LogicalPosition , LogicalSize } ,
1212 keyboard:: { Key as WinitKey , KeyLocation , NamedKey } ,
13- platform:: modifier_supplement:: KeyEventExtModifierSupplement ,
1413} ;
1514
1615use winit:: {
@@ -191,15 +190,14 @@ impl WinitPlatform {
191190 // We need to track modifiers separately because some system like macOS, will
192191 // not reliably send modifier states during certain events like ScreenCapture.
193192 // Gotta let the people show off their pretty imgui widgets!
194- io. add_key_event ( Key :: LeftShift , state. shift_key ( ) ) ;
195- io. add_key_event ( Key :: LeftCtrl , state. control_key ( ) ) ;
196- io. add_key_event ( Key :: LeftAlt , state. alt_key ( ) ) ;
197- io. add_key_event ( Key :: LeftSuper , state. super_key ( ) ) ;
193+ io. add_key_event ( Key :: ModShift , state. shift_key ( ) ) ;
194+ io. add_key_event ( Key :: ModCtrl , state. control_key ( ) ) ;
195+ io. add_key_event ( Key :: ModAlt , state. alt_key ( ) ) ;
196+ io. add_key_event ( Key :: ModSuper , state. super_key ( ) ) ;
198197 }
199198 WindowEvent :: KeyboardInput { ref event, .. } => {
200199 let is_pressed = event. state . is_pressed ( ) ;
201200 if is_pressed {
202- //println!("{:#?}", event);
203201 if let Some ( txt) = & event. text {
204202 for ch in txt. chars ( ) {
205203 if ch != '\u{7f}' {
@@ -209,14 +207,6 @@ impl WinitPlatform {
209207 }
210208 }
211209
212- // We map both left and right ctrl to `ModCtrl`, etc.
213- // imgui is told both "left control is pressed" and
214- // "consider the control key is pressed". Allows
215- // applications to use either general "ctrl" or a
216- // specific key. Same applies to other modifiers.
217- // https://github.com/ocornut/imgui/issues/5047
218- handle_key_modifier ( io, & event. key_without_modifiers ( ) , is_pressed) ;
219-
220210 // Add main key event
221211 if let Some ( key) = to_imgui_key ( & event. logical_key , event. location ) {
222212 io. add_key_event ( key, is_pressed) ;
@@ -502,13 +492,3 @@ fn to_imgui_key(key: &winit::keyboard::Key, location: KeyLocation) -> Option<Key
502492 _ => None ,
503493 }
504494}
505-
506- fn handle_key_modifier ( io : & mut Io , key : & WinitKey , down : bool ) {
507- match key {
508- WinitKey :: Named ( NamedKey :: Shift ) => io. add_key_event ( imgui:: Key :: LeftShift , down) ,
509- WinitKey :: Named ( NamedKey :: Control ) => io. add_key_event ( imgui:: Key :: LeftCtrl , down) ,
510- WinitKey :: Named ( NamedKey :: Alt ) => io. add_key_event ( imgui:: Key :: LeftAlt , down) ,
511- WinitKey :: Named ( NamedKey :: Super ) => io. add_key_event ( imgui:: Key :: LeftSuper , down) ,
512- _ => { }
513- }
514- }
0 commit comments