Closed yuxiaomao closed 10 months ago
Most likely #323 and #1154 were actually both fixes for the real issue which was fixed by https://github.com/HaxeFoundation/hashlink/commit/a502906ce5d701987f3b83a709ebd35251077114
https://github.com/HaxeFoundation/hashlink/commit/a502906ce5d701987f3b83a709ebd35251077114 Will return joystick index as event->controller value, but
initPad()
, new GameController (gctrl_open)
requires the device id, as a result initPad()
will fail if device id is not equal to joystick index (if we disconnect and reconnect a controller).event_loop
, and later new GameController (gctrl_open)
will just gather the created controller. Personally I do not like the idea of manage Open and Close in different objects
This commit revert #1154 #323 . It fix error of pad event id after disconnect and reconnect (new), and allow multiple pad to be connected to the system (what was fixed by #1154). However, it does not fix the double init in #323 (Fixed SDL double init), but I couldn't reproduce the error in a normal workflow.
The reason behind that is the e.controller is different in GControllerAdded (device id) and others events (joystick id). The joystick id is used to reference pad in pads (instead if device id), so pads.remove in GControllerAdded will remove the wrong pad.