mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Improved the input configuration logic.
Also added a command line option to force the input configuration even if a es_input.cfg file exists.
This commit is contained in:
parent
d4907f69a7
commit
1550c48187
|
@ -575,6 +575,7 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
|
|||
--force-kid Force the UI mode to Kid
|
||||
--force-kiosk Force the UI mode to Kiosk
|
||||
--force-disable-filters Force the UI to ignore applied filters in gamelist
|
||||
--force-input-config Force configuration of input device
|
||||
--home [path] Directory to use as home path
|
||||
--version, -v Displays version information
|
||||
--help, -h Summon a sentient, angry tuba
|
||||
|
@ -599,6 +600,7 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
|
|||
--force-kid Force the UI mode to Kid
|
||||
--force-kiosk Force the UI mode to Kiosk
|
||||
--force-disable-filters Force the UI to ignore applied filters in gamelist
|
||||
--force-input-config Force configuration of input device
|
||||
--home [path] Directory to use as home path
|
||||
--version, -v Displays version information
|
||||
--help, -h Summon a sentient, angry tuba
|
||||
|
|
Binary file not shown.
|
@ -705,7 +705,7 @@ void GuiMenu::openConfigInput()
|
|||
Window* window = mWindow;
|
||||
window->pushGui(new GuiMsgBox(window, getHelpStyle(),
|
||||
"ARE YOU SURE YOU WANT TO CONFIGURE INPUT?", "YES", [window] {
|
||||
window->pushGui(new GuiDetectDevice(window, false, nullptr));
|
||||
window->pushGui(new GuiDetectDevice(window, false, false, nullptr));
|
||||
}, "NO", nullptr)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#include <iostream>
|
||||
#include <time.h>
|
||||
|
||||
bool forceInputConfig = false;
|
||||
|
||||
#ifdef _WIN64
|
||||
enum eConsoleType {
|
||||
NO_CONSOLE,
|
||||
|
@ -283,6 +285,9 @@ bool parseArgs(int argc, char* argv[])
|
|||
else if (strcmp(argv[i], "--force-disable-filters") == 0) {
|
||||
Settings::getInstance()->setBool("ForceDisableFilters", true);
|
||||
}
|
||||
else if (strcmp(argv[i], "--force-input-config") == 0) {
|
||||
forceInputConfig = true;
|
||||
}
|
||||
else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-v") == 0) {
|
||||
std::cout <<
|
||||
"EmulationStation Desktop Edition v" << PROGRAM_VERSION_STRING << "\n";
|
||||
|
@ -314,6 +319,7 @@ bool parseArgs(int argc, char* argv[])
|
|||
" --force-kid Force the UI mode to Kid\n"
|
||||
" --force-kiosk Force the UI mode to Kiosk\n"
|
||||
" --force-disable-filters Force the UI to ignore applied filters in gamelist\n"
|
||||
" --force-input-config Force configuration of input device\n"
|
||||
" --home [path] Directory to use as home path\n"
|
||||
" --version, -v Display version information\n"
|
||||
" --help, -h Summon a sentient, angry tuba\n";
|
||||
|
@ -519,21 +525,24 @@ int main(int argc, char* argv[])
|
|||
if (splashScreen && splashScreenProgress)
|
||||
window.renderLoadingScreen("Done.");
|
||||
|
||||
// Choose which GUI to open depending on if an input configuration already exists.
|
||||
// Choose which GUI to open depending on if an input configuration already exists and
|
||||
// whether the flag to force the input configuration was passed from the command line.
|
||||
if (errorMsg == "") {
|
||||
if (Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
||||
if (!forceInputConfig && Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
||||
InputManager::getInstance()->getNumConfiguredDevices() > 0) {
|
||||
ViewController::get()->goToStart();
|
||||
}
|
||||
else {
|
||||
// Always reset ShowDefaultKeyboardWarning to true if the es_input.cfg
|
||||
// file is missing.
|
||||
Settings::getInstance()->setBool("ShowDefaultKeyboardWarning", true);
|
||||
Settings::getInstance()->saveFile();
|
||||
|
||||
window.pushGui(new GuiDetectDevice(&window, true, [] {
|
||||
else if (forceInputConfig) {
|
||||
window.pushGui(new GuiDetectDevice(&window, true, true, [] {
|
||||
ViewController::get()->goToStart(); }));
|
||||
}
|
||||
else {
|
||||
if (InputManager::getInstance()->getNumJoysticks() > 0)
|
||||
window.pushGui(new GuiDetectDevice(&window, true, false, [] {
|
||||
ViewController::get()->goToStart(); }));
|
||||
else
|
||||
ViewController::get()->goToStart();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the media directory exists, and if not, log a warning.
|
||||
|
|
|
@ -66,6 +66,9 @@ void ViewController::goToStart()
|
|||
// configuration has been performed.
|
||||
if (InputManager::getInstance()->
|
||||
getInputConfigByDevice(DEVICE_KEYBOARD)->getDefaultConfigFlag()) {
|
||||
|
||||
LOG(LogInfo) << "Applying default keyboard mappings.";
|
||||
|
||||
if (Settings::getInstance()->getBool("ShowDefaultKeyboardWarning")) {
|
||||
std::string message = "NO KEYBOARD CONFIGURATION COULD BE\n"
|
||||
"FOUND IN ES_INPUT.CFG, SO APPLYING THE\n"
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
GuiDetectDevice::GuiDetectDevice(
|
||||
Window* window,
|
||||
bool firstRun,
|
||||
bool forcedConfig,
|
||||
const std::function<void()>& doneCallback)
|
||||
: GuiComponent(window),
|
||||
mFirstRun(firstRun),
|
||||
mForcedConfig(forcedConfig),
|
||||
mBackground(window, ":/graphics/frame.png"),
|
||||
mGrid(window, Vector2i(1, 5))
|
||||
{
|
||||
|
@ -50,12 +52,21 @@ GuiDetectDevice::GuiDetectDevice(
|
|||
mGrid.setEntry(mDeviceInfo, Vector2i(0, 1), false, true);
|
||||
|
||||
// Message.
|
||||
if (numDevices > 0) {
|
||||
mMsg1 = std::make_shared<TextComponent>(mWindow,
|
||||
"HOLD A BUTTON ON YOUR DEVICE OR KEYBOARD TO CONFIGURE IT.",
|
||||
"HOLD A BUTTON ON YOUR GAMEPAD OR KEYBOARD TO CONFIGURE IT.",
|
||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
||||
}
|
||||
else {
|
||||
mMsg1 = std::make_shared<TextComponent>(mWindow,
|
||||
"HOLD A BUTTON ON YOUR KEYBOARD TO CONFIGURE IT.",
|
||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true);
|
||||
|
||||
const char* msg2str = firstRun ? "PRESS F4 TO QUIT AT ANY TIME." : "PRESS ESC TO CANCEL.";
|
||||
const char* msg2str = firstRun ?
|
||||
"PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)." : "PRESS ESC TO CANCEL.";
|
||||
mMsg2 = std::make_shared<TextComponent>(mWindow, msg2str,
|
||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mMsg2, Vector2i(0, 3), false, true);
|
||||
|
@ -91,7 +102,17 @@ bool GuiDetectDevice::input(InputConfig* config, Input input)
|
|||
input.value && input.id == SDLK_ESCAPE) {
|
||||
// Cancel the configuration.
|
||||
PowerSaver::resume();
|
||||
delete this;
|
||||
delete this; // Delete GUI element.
|
||||
return true;
|
||||
}
|
||||
// First run, but the user chooses to skip the configuration. This will default to the
|
||||
// built-in keyboard mappings.
|
||||
else if (mFirstRun && input.device == DEVICE_KEYBOARD && input.type == TYPE_KEY &&
|
||||
input.value && input.id == SDLK_ESCAPE) {
|
||||
if (mDoneCallback)
|
||||
mDoneCallback();
|
||||
PowerSaver::resume();
|
||||
delete this; // Delete GUI element.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -114,9 +135,11 @@ bool GuiDetectDevice::input(InputConfig* config, Input input)
|
|||
void GuiDetectDevice::update(int deltaTime)
|
||||
{
|
||||
if (mHoldingConfig) {
|
||||
// If ES starts and if a known device is connected after startup
|
||||
// skip controller configuration.
|
||||
if (mFirstRun && Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
||||
// If ES starts and if a known device is connected after startup skip controller
|
||||
// configuration unless the flag to force the configuration was passed on the
|
||||
// command line.
|
||||
if (!mForcedConfig && mFirstRun &&
|
||||
Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
||||
InputManager::getInstance()->getNumConfiguredDevices() > 0) {
|
||||
if (mDoneCallback)
|
||||
mDoneCallback();
|
||||
|
|
|
@ -17,7 +17,8 @@ class TextComponent;
|
|||
class GuiDetectDevice : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiDetectDevice(Window* window, bool firstRun, const std::function<void()>& doneCallback);
|
||||
GuiDetectDevice(Window* window, bool firstRun, bool forcedConfig,
|
||||
const std::function<void()>& doneCallback);
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
void update(int deltaTime) override;
|
||||
|
@ -25,6 +26,7 @@ public:
|
|||
|
||||
private:
|
||||
bool mFirstRun;
|
||||
bool mForcedConfig;
|
||||
InputConfig* mHoldingConfig;
|
||||
int mHoldTime;
|
||||
|
||||
|
|
Loading…
Reference in a new issue