Fix gamepad removal not working properly

This commit is contained in:
2024-05-09 22:00:38 +10:00
parent 06046cd163
commit b62cd056b5
3 changed files with 31 additions and 15 deletions

View File

@ -84,7 +84,7 @@ public class Application
for idx in 0...SDL_NumJoysticks()
{
if SDL_IsGameController(idx) != SDL_TRUE { continue }
Input.instance.padConnectedEvent(index: idx)
Input.instance.padConnectedEvent(deviceIndex: idx)
}
do
@ -129,9 +129,9 @@ public class Application
Input.instance.releaseEvent(scan: event.key.keysym.scancode)
case SDL_CONTROLLERDEVICEADDED:
if SDL_IsGameController(event.cdevice.which) != SDL_TRUE { break }
Input.instance.padConnectedEvent(index: event.cdevice.which)
Input.instance.padConnectedEvent(deviceIndex: event.cdevice.which)
case SDL_CONTROLLERDEVICEREMOVED:
Input.instance.padRemovedEvent(index: event.cdevice.which)
Input.instance.padRemovedEvent(id: event.cdevice.which)
case SDL_CONTROLLERBUTTONDOWN:
Input.instance.padButtonPressEvent(id: event.cbutton.which, btn: event.cbutton.button)
case SDL_CONTROLLERBUTTONUP: