Release game controller device correctly. #568

A followup on 02520fb6.

In wxSDLJoy::Remove(n), which is the only API that needs to release a
game controller device from the application, actually call
SDL_GameControllerClose(dev) when a device is released.

This is used when the input config dialog is launched. First all sticks
are closed, and then all available sticks are added for the duration of
the dialog. Then they are closed again, and only the configured sticks
are open for the game, which is what happens generally.

The device ordering is determined by the OS.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-11-29 03:50:24 +00:00
parent 85abf97a21
commit e04efa76b3
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 9 additions and 0 deletions

View File

@ -147,10 +147,19 @@ void wxSDLJoy::Remove(int8_t joy_n)
add_all = false;
if (joy_n < 0) {
for (auto joy : joystate) {
if (auto dev = std::get<1>(joy).dev)
SDL_GameControllerClose(dev);
}
joystate.clear();
return;
}
if (auto dev = joystate[joy_n].dev)
SDL_GameControllerClose(dev);
joystate.erase(joy_n);
}