Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key input issue on mac #32

Closed
toyboot4e opened this issue Sep 29, 2020 · 5 comments · Fixed by #33
Closed

Key input issue on mac #32

toyboot4e opened this issue Sep 29, 2020 · 5 comments · Fixed by #33

Comments

@toyboot4e
Copy link
Member

toyboot4e commented Sep 29, 2020

winit has key input issue on macOS: rust-windowing/winit#1470

It says that macOS Accesibility prevents key inputs from going as DeviceEvents. So, on macOS, keyboard input events can only be captured as WindowEvent, unless somehow configuring Accesibility.

I made a commit to enable key input on macOS in the 3rd_person example: toyboot4e@2f2dafe. I can make such changes and make a PR, but I'm not sure if it's good to get key input as WindowEvent.

@mrDIMAS
Copy link
Member

mrDIMAS commented Sep 29, 2020

This is sad, WindowEvent is bad because it requires mouse to be inside window bounds to get any events from it, so it is suitable only for full screen mode. However it seems that there is no other solutions, so yeah PR would be nice, but I'd add #[cfg(target_os="macos")] to WindowEvent branch and #[cfg(not(target_os="macos"))] to DeviceEvent branch, so to use DeviceEvent where possible and WindowEvent otherwise.

@toyboot4e
Copy link
Member Author

WindowEvent is bad because it requires mouse to be inside window bounds to get any events from it

Does it? My creature walks with WASD when my mouse is not on the window (if the window has focus). So I'm not seeing any particular problem on macOS. Hope this is a good news (or not on Windows?).

@mrDIMAS
Copy link
Member

mrDIMAS commented Sep 29, 2020

Keyboard input is working, right, mouse events won't come if cursor is outside window.

@toyboot4e
Copy link
Member Author

Mouse events are still available as DeviceEvents on macOS. How about handling mouse events via DeviceEvent while handling keyboard events via WindowEvent? Then we don't need #[cfg] branch.

If that's OK, I would make a PR and prepare for review.

@mrDIMAS
Copy link
Member

mrDIMAS commented Sep 30, 2020

Yeah, that sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants