mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +02:00
Add proper adding and removal of subdeviceNames in SDL2Manager after startup
This commit is contained in:
parent
413199459b
commit
687605ad38
2 changed files with 7 additions and 1 deletions
|
@ -31,6 +31,8 @@ public:
|
||||||
|
|
||||||
const QString& getName() const { return _name; }
|
const QString& getName() const { return _name; }
|
||||||
|
|
||||||
|
SDL_GameController* getGameController() { return _sdlGameController; }
|
||||||
|
|
||||||
// Device functions
|
// Device functions
|
||||||
virtual controller::Input::NamedVector getAvailableInputs() const override;
|
virtual controller::Input::NamedVector getAvailableInputs() const override;
|
||||||
virtual QString getDefaultMappingConfig() const override;
|
virtual QString getDefaultMappingConfig() const override;
|
||||||
|
|
|
@ -163,15 +163,19 @@ void SDL2Manager::pluginUpdate(float deltaTime, const controller::InputCalibrati
|
||||||
Joystick::Pointer joystick = std::make_shared<Joystick>(id, controller);
|
Joystick::Pointer joystick = std::make_shared<Joystick>(id, controller);
|
||||||
_openJoysticks[id] = joystick;
|
_openJoysticks[id] = joystick;
|
||||||
userInputMapper->registerDevice(joystick);
|
userInputMapper->registerDevice(joystick);
|
||||||
|
QString name = SDL_GameControllerName(controller);
|
||||||
emit joystickAdded(joystick.get());
|
emit joystickAdded(joystick.get());
|
||||||
emit subdeviceConnected(getName(), SDL_GameControllerName(controller));
|
emit subdeviceConnected(getName(), name);
|
||||||
|
_subdeviceNames << name;
|
||||||
}
|
}
|
||||||
} else if (event.type == SDL_CONTROLLERDEVICEREMOVED) {
|
} else if (event.type == SDL_CONTROLLERDEVICEREMOVED) {
|
||||||
if (_openJoysticks.contains(event.cdevice.which)) {
|
if (_openJoysticks.contains(event.cdevice.which)) {
|
||||||
Joystick::Pointer joystick = _openJoysticks[event.cdevice.which];
|
Joystick::Pointer joystick = _openJoysticks[event.cdevice.which];
|
||||||
_openJoysticks.remove(event.cdevice.which);
|
_openJoysticks.remove(event.cdevice.which);
|
||||||
userInputMapper->removeDevice(joystick->getDeviceID());
|
userInputMapper->removeDevice(joystick->getDeviceID());
|
||||||
|
QString name = SDL_GameControllerName(joystick->getGameController());
|
||||||
emit joystickRemoved(joystick.get());
|
emit joystickRemoved(joystick.get());
|
||||||
|
_subdeviceNames.removeOne(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue