diff --git a/INSTALL.md b/INSTALL.md index 4d4370002..0f804bfaa 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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 diff --git a/es-app/src/emulationstation.6.gz b/es-app/src/emulationstation.6.gz index 46527c692..808912ffd 100644 Binary files a/es-app/src/emulationstation.6.gz and b/es-app/src/emulationstation.6.gz differ diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 6699a36f1..988391802 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -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) ); } diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 51797005d..a8b1a921f 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -51,6 +51,8 @@ #include #include +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. diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 1fdef57d1..e1d14a470 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -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" diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index adefabb41..4b8d24dbd 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -19,9 +19,11 @@ GuiDetectDevice::GuiDetectDevice( Window* window, bool firstRun, + bool forcedConfig, const std::function& 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. - mMsg1 = std::make_shared(mWindow, - "HOLD A BUTTON ON YOUR DEVICE OR KEYBOARD TO CONFIGURE IT.", - Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); + if (numDevices > 0) { + mMsg1 = std::make_shared(mWindow, + "HOLD A BUTTON ON YOUR GAMEPAD OR KEYBOARD TO CONFIGURE IT.", + Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); + } + else { + mMsg1 = std::make_shared(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(mWindow, msg2str, Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mMsg2, Vector2i(0, 3), false, true); @@ -91,9 +102,19 @@ 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; + } if (input.type == TYPE_BUTTON || input.type == TYPE_KEY ||input.type == TYPE_CEC_BUTTON) { if (input.value && mHoldingConfig == nullptr) { @@ -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(); diff --git a/es-core/src/guis/GuiDetectDevice.h b/es-core/src/guis/GuiDetectDevice.h index f0bc9651e..273339907 100644 --- a/es-core/src/guis/GuiDetectDevice.h +++ b/es-core/src/guis/GuiDetectDevice.h @@ -17,7 +17,8 @@ class TextComponent; class GuiDetectDevice : public GuiComponent { public: - GuiDetectDevice(Window* window, bool firstRun, const std::function& doneCallback); + GuiDetectDevice(Window* window, bool firstRun, bool forcedConfig, + const std::function& 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;