hmans / controlfreak

Composable Game Input.
MIT License
59 stars 2 forks source link

Multiple input devices cause issues with Keyboard input #44

Open whoisryosuke opened 2 years ago

whoisryosuke commented 2 years ago

Great library! been stress testing it recently and noticed some issues. might be my setup since I'm in React-land, but thought it'd be good to point out since it's reproducible.

I have an issue where the device keeps competing with gamepad, and when I use a key on keyboard, it doesn’t get picked up until the device is recognized — then I press key again to see input. I also see the gamepad as a “new device” right after my keyboard each time I press a key.

This only happens after using a gamepad. If start with keyboard, I have no issues. But once there’s 2 input, the keyboard input becomes “lagged” (aka requiring 1 key press to activate again). Every single time though — so I press, it finds device, press again, key works, press again, it has to find device again… Hard refreshing page fixes this until gamepad is used again.

You can see an example of the logs here in this screenshot: Screenshot of keyboard and gamepad device found logs in Chrome's devtools - sorry if picbun loses this

Or try running the example here - I'm using a PlayStation DualShock 4 and a standard keyboard: https://codesandbox.io/s/github/whoisryosuke/r3f-experiments/tree/f391624b2a9e1f24e7a78b6751c6e95efb63b5a4

The code is here on Github for reference (so you don't have to CSB everytime): https://github.com/whoisryosuke/r3f-experiments/tree/f391624b2a9e1f24e7a78b6751c6e95efb63b5a4

Input stuff happens here: Controller init + input mapping React component for input (aka update()) Using the input for moving the "player"

hmans commented 2 years ago

Hi, thanks for your issue! The README should have a warning about this, but this library is still extremely WIP and should not be used in production projects. One of the next steps for the library is a complete rewrite that will provide a significantly more solid foundation for many things (including multi-device handling, which is currently very basic, and admittedly quite a bit wonky). It still be quite some time before I get to this, though, because I'm currently focusing on my work around three-vfx.

I recommed that you watch this repo for new releases so you get notified when things are picking up again. Thanks for your patience!