Joystick hotplug support (#4141)

* use SDL_PollEvent instead of SDL_JoystickUpdate

Register hot plugged controller by GUID if they were configured in a previous session

* Move SDL_PollEvent into its own thread

* Don't store SDLJoystick pointer in Input Device; Get pointer on each GetStatus call

* Fix that joystick_list gets cleared after SDL_Quit

* Add VirtualJoystick for InputDevices thats never nullptr

* fixup! Add VirtualJoystick for InputDevices thats never nullptr

* fixup! fixup! Add VirtualJoystick for InputDevices thats never nullptr

* Remove SDL_GameController, make SDL_Joystick* unique_ptr

* fixup! Remove SDL_GameController, make SDL_Joystick* unique_ptr

* Adressed feedback; fixed handling of same guid reconnects

* fixup! Adressed feedback; fixed handling of same guid reconnects

* merge the two joystick_lists into one

* make SDLJoystick a member of VirtualJoystick

* fixup! make SDLJoystick a member of VirtualJoystick

* fixup! make SDLJoystick a member of VirtualJoystick

* fixup! fixup! make SDLJoystick a member of VirtualJoystick
This commit is contained in:
Ben 2018-09-08 19:01:30 +02:00 committed by GitHub
parent f86c993e11
commit 17978cf758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 343 additions and 102 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2016 Citra Emulator Project
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -53,19 +53,18 @@ static QString ButtonToText(const Common::ParamPackage& param) {
} else if (param.Get("engine", "") == "keyboard") {
return getKeyName(param.Get("code", 0));
} else if (param.Get("engine", "") == "sdl") {
QString text = QString(QObject::tr("Joystick %1")).arg(param.Get("joystick", "").c_str());
if (param.Has("hat")) {
text += QString(QObject::tr(" Hat %1 %2"))
.arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str());
return QString(QObject::tr("Hat %1 %2"))
.arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str());
}
if (param.Has("axis")) {
text += QString(QObject::tr(" Axis %1%2"))
.arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str());
return QString(QObject::tr("Axis %1%2"))
.arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str());
}
if (param.Has("button")) {
text += QString(QObject::tr(" Button %1")).arg(param.Get("button", "").c_str());
return QString(QObject::tr("Button %1")).arg(param.Get("button", "").c_str());
}
return text;
return QString();
} else {
return QObject::tr("[unknown]");
}
@ -81,13 +80,12 @@ static QString AnalogToText(const Common::ParamPackage& param, const std::string
return QString(QObject::tr("[unused]"));
}
QString text = QString(QObject::tr("Joystick %1")).arg(param.Get("joystick", "").c_str());
if (dir == "left" || dir == "right") {
text += QString(QObject::tr(" Axis %1")).arg(param.Get("axis_x", "").c_str());
return QString(QObject::tr("Axis %1")).arg(param.Get("axis_x", "").c_str());
} else if (dir == "up" || dir == "down") {
text += QString(QObject::tr(" Axis %1")).arg(param.Get("axis_y", "").c_str());
return QString(QObject::tr("Axis %1")).arg(param.Get("axis_y", "").c_str());
}
return text;
return QString();
} else {
return QObject::tr("[unknown]");
}