HeapsIO / heaps

Heaps : Haxe Game Framework
http://heaps.io
MIT License
3.19k stars 337 forks source link

Fix SDL pad reconnect after disconnect event error #1177

Closed yuxiaomao closed 10 months ago

yuxiaomao commented 10 months ago

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.

ncannasse commented 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

yuxiaomao commented 10 months ago

https://github.com/HaxeFoundation/hashlink/commit/a502906ce5d701987f3b83a709ebd35251077114 Will return joystick index as event->controller value, but