Added an 'Ignore keyboard input' option to the input device settings menu.

This commit is contained in:
Leon Styhre 2022-09-19 19:05:06 +02:00
parent db46180024
commit da343c49aa
3 changed files with 20 additions and 0 deletions

View file

@ -918,6 +918,19 @@ void GuiMenu::openInputDeviceOptions()
} }
}); });
// Whether to ignore keyboard input (except the quit shortcut).
auto inputIgnoreKeyboard = std::make_shared<SwitchComponent>();
inputIgnoreKeyboard->setState(Settings::getInstance()->getBool("InputIgnoreKeyboard"));
s->addWithLabel("IGNORE KEYBOARD INPUT", inputIgnoreKeyboard);
s->addSaveFunc([inputIgnoreKeyboard, s] {
if (Settings::getInstance()->getBool("InputIgnoreKeyboard") !=
inputIgnoreKeyboard->getState()) {
Settings::getInstance()->setBool("InputIgnoreKeyboard",
inputIgnoreKeyboard->getState());
s->setNeedsSaving();
}
});
// Configure keyboard and controllers. // Configure keyboard and controllers.
ComponentListRow configureInputRow; ComponentListRow configureInputRow;
configureInputRow.elements.clear(); configureInputRow.elements.clear();

View file

@ -450,11 +450,17 @@ bool InputManager::parseEvent(const SDL_Event& event)
} }
} }
if (Settings::getInstance()->getBool("InputIgnoreKeyboard"))
return true;
mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD), mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD),
Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 1, false)); Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 1, false));
return true; return true;
} }
case SDL_KEYUP: { case SDL_KEYUP: {
if (Settings::getInstance()->getBool("InputIgnoreKeyboard"))
return true;
mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD), mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD),
Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false)); Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false));
return true; return true;

View file

@ -202,6 +202,7 @@ void Settings::setDefaults()
// Input device settings. // Input device settings.
mStringMap["InputControllerType"] = {"xbox", "xbox"}; mStringMap["InputControllerType"] = {"xbox", "xbox"};
mBoolMap["InputOnlyFirstController"] = {false, false}; mBoolMap["InputOnlyFirstController"] = {false, false};
mBoolMap["InputIgnoreKeyboard"] = {false, false};
// Game collection settings. // Game collection settings.
mStringMap["CollectionSystemsAuto"] = {"", ""}; mStringMap["CollectionSystemsAuto"] = {"", ""};