not-fl3 / macroquad

Cross-platform game engine in Rust.
Apache License 2.0
3.28k stars 318 forks source link

`is_key_down` function is not working properly on Linux. #357

Open baehyunsol opened 2 years ago

baehyunsol commented 2 years ago

is_key_down function is not working properly on Linux.

I'm using Ubuntu with LeftWM. The window manager uses Mod + Shift + (1 - 9) to move a window to another desktop. When I use the keys to move my game to another desktop, is_key_down(KeyCode::LeftShift) || is_key_down(KeyCode::RightShift) keeps returning true even after I released the shift key. It goes back to normal after I press Shift key again.

I tested the same thing on other keys, but it only makes problem with Shift keys. When using Mod + Shift + 4 to move my game to 4th desktop, is_key_down(KeyCode::Key4) does not make any problem.

Edersteiner commented 2 years ago

Same thing happens on MacOS when CMD key is down at the same time as (in my case) the arrow keys.

eboatwright commented 2 years ago

Do you have sticky keys on?

baehyunsol commented 2 years ago

@eboatwright It's not on.

eboatwright commented 2 years ago

hm

buxx commented 2 years ago

I have a similar issue but with an other rust game lib (Coffee). Maybe third party related ?

baehyunsol commented 2 years ago

@buxx are you using Windows?

I'm using Ubuntu 21.10 with LeftWM

buxx commented 2 years ago

@baehyunsol Using Ubuntu 20.04 and Kubuntu 21.10 (same on both).

This behavior happen to me when I switch workspaces with CTRL+ALT+arrow

eboatwright commented 2 years ago

I think it's just keyboard related / switching workspaces or pressing weird keys messes with keyboard inputs

Bibi210 commented 2 years ago

Hello I'm a student in IT. I would like to make my first contribution to an open projet.

I was able to reproduce the bug on MacOS Monterey 12.1. The main issue (on macOS) in my opinion is that using SuperKey and any others keys shortly after, doesn't trigger the key_up_event for the others.

On the Library SOKOL used by this projet we can see some workaround with the SuperKey maybe it's the source of the problem

sokol_app.h

Bibi210 commented 2 years ago

I just saw that the miniquad project used to manage inputs doesn't have the last version with the workaround. A simple update might solve the issue. Old sokol_app.h currently used New sokol_app.h with the fix

IohannRabeson commented 1 year ago

I think this is an issue for Miniquad and not for Macroquad (I created one https://github.com/not-fl3/miniquad/issues/353). I looked quickly and, when pressing Shift on MacOS, the callback registered by miniquad is not called when Shift is pressed (it is for other key). @not-fl3 Any plan to update to the latest version of miniquad? That would help to investigate and eventually merge an eventual fix.

profan commented 3 days ago

this seems like a dupe of #547, also interestingly the issue doesn't reproduce with just miniquad for me? however with a bare macroquad project it very much does very quickly reproduce which is very strange given macroquad is basically just a thin layer over miniquad :eyes: