Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

Gamepad.notifyOnConnect listeners are not called on connection or disconnection of gamepads #1289

Closed ghost closed 3 years ago

ghost commented 3 years ago

Describe the bug After calling Gamepad.notifyOnConnect(), listeners specified are never called, even though Gamepad.get() with hardcoded indices returns working Gamepad instances.

To Reproduce Steps to reproduce the behavior:

  1. Call Gamepad.notifyOnConnect() with valid listeners
  2. Connect or disconnect gamepad
  3. Listeners are not called

Expected behavior calling Gamepad.notifyOnConnect() causes specified listeners to be called when gamepad is connected or disconnected

Execution Environment:

ghost commented 3 years ago

is the total silence for a month because of an obscure target? maybe someone could point me to relevant files? is fixing this at all possible? are there workarounds for this?

i am sorry for pestering with this comment, but i really need this functionality.

RobDangerous commented 3 years ago

This is a hobby project, maintained by only a single person. One month is nothing. The code is here: https://github.com/Kode/Kinc/blob/master/Backends/System/Linux/Sources/kinc/backend/input/gamepad.cpp

ghost commented 3 years ago

Well i got something working, but i'm not sure if solution is at all acceptable.

  1. It requires linking against udev from systemd client libraries
  2. select() call, used for checking read readiness (i guess in case udev fires off faster than libinput or something), blocks until there is something to read, BUT it works without a select() call, not sure if that's stable though
  3. i didn't find where to put udev_unref() call, don't know if that is a problem

should i make a PR or is it better to just continue investigating?

RobDangerous commented 3 years ago

Sounds more complicated than I expected but please always feel free to send pull-requests even if something isn't necessarily ready to be merged yet - that way I can help figuring things out.

ghost commented 3 years ago

Fixed by b4e753f