diff --git a/src/lindbergh/config.c b/src/lindbergh/config.c index c1e0023..dffa1ef 100644 --- a/src/lindbergh/config.c +++ b/src/lindbergh/config.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "config.h" #include "gpuvendor.h" @@ -1348,22 +1349,20 @@ int initConfig(const char* configPath) } config.inputMode = 0; // Default to all inputs + char* configFilePath = CONFIG_PATH; + if (configPath != NULL) + strcpy(configFilePath, configPath); - // first we try to read the external config path - configFile = fopen(configPath, "r"); - if (configFile != NULL) { - printf("Found lindbergh loader config at %s in system environment\n",configPath); - } else { - // then we try to read through default config path - configFile = fopen(CONFIG_PATH, "r"); - if (configFile == NULL) - { - printf("Warning: Cannot open %s, using default values.\n", CONFIG_PATH); - return 1; - } + configFile = fopen(configFilePath, "r"); + + if (configFile == NULL) + { + printf("Warning: Cannot open %s, using default config values.\n", configFilePath); + return 1; } + readConfig(configFile, &config); fclose(configFile); diff --git a/src/lindbergh/lindbergh.c b/src/lindbergh/lindbergh.c index 985a05c..bc7dce3 100644 --- a/src/lindbergh/lindbergh.c +++ b/src/lindbergh/lindbergh.c @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include #include "evdevinput.h" #include "version.h" @@ -249,7 +251,7 @@ int main(int argc, char *argv[]) int forceGame = 0; int segaboot = 0; int extConfig = 0; - char envConfigPath[256] = {0}; + char envConfigPath[PATH_MAX] = {0}; char forceGamePath[128] = {0}; for (int i = 1; i < argc; i++) @@ -279,8 +281,10 @@ int main(int argc, char *argv[]) printf("Unable to read config file because it's the end of argument list\n"); break; } + extConfig = 1; strcpy(envConfigPath, argv[i+1]); + // skip the next argument i += 1; continue;