Do changes as requested

This commit is contained in:
Synth_Magic
2025-01-05 11:51:47 +08:00
parent 4648cea7be
commit ea4745f758
2 changed files with 16 additions and 13 deletions
+11 -12
View File
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#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);
+5 -1
View File
@@ -1,8 +1,10 @@
#include <dirent.h>
#include <linux/limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <limits.h>
#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;