mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Added a setting to only accept input from the first controller.
This commit is contained in:
parent
9125ab78e5
commit
ecf8e50500
|
@ -759,6 +759,20 @@ void GuiMenu::openInputDeviceOptions()
|
||||||
{
|
{
|
||||||
auto s = new GuiSettings(mWindow, "INPUT DEVICE SETTINGS");
|
auto s = new GuiSettings(mWindow, "INPUT DEVICE SETTINGS");
|
||||||
|
|
||||||
|
// Whether to only accept input from the first controller.
|
||||||
|
auto input_only_first_controller = std::make_shared<SwitchComponent>(mWindow);
|
||||||
|
input_only_first_controller->setState(Settings::getInstance()->
|
||||||
|
getBool("InputOnlyFirstController"));
|
||||||
|
s->addWithLabel("ONLY ACCEPT INPUT FROM FIRST CONTROLLER", input_only_first_controller);
|
||||||
|
s->addSaveFunc([input_only_first_controller, s] {
|
||||||
|
if (Settings::getInstance()->getBool("InputOnlyFirstController") !=
|
||||||
|
input_only_first_controller->getState()) {
|
||||||
|
Settings::getInstance()->setBool("InputOnlyFirstController",
|
||||||
|
input_only_first_controller->getState());
|
||||||
|
s->setNeedsSaving();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Configure keyboard and controllers.
|
// Configure keyboard and controllers.
|
||||||
ComponentListRow configure_input_row;
|
ComponentListRow configure_input_row;
|
||||||
configure_input_row.elements.clear();
|
configure_input_row.elements.clear();
|
||||||
|
|
|
@ -357,6 +357,11 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_CONTROLLERAXISMOTION: {
|
case SDL_CONTROLLERAXISMOTION: {
|
||||||
|
// Whether to only accept input from the first controller.
|
||||||
|
if (Settings::getInstance()->getBool("InputOnlyFirstController"))
|
||||||
|
if (mInputConfigs.begin()->first != event.cdevice.which)
|
||||||
|
return false;
|
||||||
|
|
||||||
// This is needed for a situation which sometimes occur when a game is launched,
|
// This is needed for a situation which sometimes occur when a game is launched,
|
||||||
// some axis input is generated and then the controller is disconnected before
|
// some axis input is generated and then the controller is disconnected before
|
||||||
// leaving the game. In this case, events for the old device index could be received
|
// leaving the game. In this case, events for the old device index could be received
|
||||||
|
@ -395,6 +400,11 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
|
||||||
case SDL_CONTROLLERBUTTONDOWN: {
|
case SDL_CONTROLLERBUTTONDOWN: {
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERBUTTONUP: {
|
case SDL_CONTROLLERBUTTONUP: {
|
||||||
|
// Whether to only accept input from the first controller.
|
||||||
|
if (Settings::getInstance()->getBool("InputOnlyFirstController"))
|
||||||
|
if (mInputConfigs.begin()->first != event.cdevice.which)
|
||||||
|
return false;
|
||||||
|
|
||||||
// The event filtering below is required as some controllers send button presses
|
// The event filtering below is required as some controllers send button presses
|
||||||
// starting with the state 0 when using the D-pad. I consider this invalid behaviour
|
// starting with the state 0 when using the D-pad. I consider this invalid behaviour
|
||||||
// and the more popular controllers such as those from Microsoft and Sony do not show
|
// and the more popular controllers such as those from Microsoft and Sony do not show
|
||||||
|
|
|
@ -196,6 +196,9 @@ void Settings::setDefaults()
|
||||||
mBoolMap["ScreensaverVideoAudio"] = { false, false };
|
mBoolMap["ScreensaverVideoAudio"] = { false, false };
|
||||||
mBoolMap["NavigationSounds"] = { true, true };
|
mBoolMap["NavigationSounds"] = { true, true };
|
||||||
|
|
||||||
|
// Input device settings.
|
||||||
|
mBoolMap["InputOnlyFirstController"] = { false, false };
|
||||||
|
|
||||||
// Game collection settings.
|
// Game collection settings.
|
||||||
mStringMap["CollectionSystemsAuto"] = { "", "" };
|
mStringMap["CollectionSystemsAuto"] = { "", "" };
|
||||||
mStringMap["CollectionSystemsCustom"] = { "", "" };
|
mStringMap["CollectionSystemsCustom"] = { "", "" };
|
||||||
|
|
Loading…
Reference in a new issue