Support up to 3 alternative INI files (Back+DPAD in OSD). Some refactoring in cfg/ini parsing.
This commit is contained in:
67
user_io.cpp
67
user_io.cpp
@@ -35,7 +35,8 @@
|
||||
|
||||
#include "support.h"
|
||||
|
||||
static char core_path[1024];
|
||||
static char core_path[1024] = {};
|
||||
static char rbf_path[1024] = {};
|
||||
|
||||
static uint8_t vol_att = 0;
|
||||
unsigned long vol_set_timeout = 0;
|
||||
@@ -526,10 +527,10 @@ const char* get_rbf_path()
|
||||
|
||||
void MakeFile(const char * filename, const char * data)
|
||||
{
|
||||
FILE * file;
|
||||
file = fopen(filename, "w");
|
||||
fwrite(data, strlen(data), 1, file);
|
||||
fclose(file);
|
||||
FILE * file;
|
||||
file = fopen(filename, "w");
|
||||
fwrite(data, strlen(data), 1, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
int GetUARTMode()
|
||||
@@ -553,18 +554,18 @@ int GetMidiLinkMode()
|
||||
|
||||
void SetMidiLinkMode(int mode)
|
||||
{
|
||||
MakeFile("/tmp/CORENAME", user_io_get_core_name_ex());
|
||||
remove("/tmp/ML_FSYNTH");
|
||||
remove("/tmp/ML_MUNT");
|
||||
remove("/tmp/ML_UDP");
|
||||
remove("/tmp/ML_TCP");
|
||||
switch (mode)
|
||||
{
|
||||
case 0: MakeFile("/tmp/ML_FSYNTH", ""); break;
|
||||
case 1: MakeFile("/tmp/ML_MUNT", ""); break;
|
||||
case 2: MakeFile("/tmp/ML_TCP", ""); break;
|
||||
case 3: MakeFile("/tmp/ML_UDP", ""); break;
|
||||
}
|
||||
MakeFile("/tmp/CORENAME", user_io_get_core_name_ex());
|
||||
remove("/tmp/ML_FSYNTH");
|
||||
remove("/tmp/ML_MUNT");
|
||||
remove("/tmp/ML_UDP");
|
||||
remove("/tmp/ML_TCP");
|
||||
switch (mode)
|
||||
{
|
||||
case 0: MakeFile("/tmp/ML_FSYNTH", ""); break;
|
||||
case 1: MakeFile("/tmp/ML_MUNT", ""); break;
|
||||
case 2: MakeFile("/tmp/ML_TCP", ""); break;
|
||||
case 3: MakeFile("/tmp/ML_UDP", ""); break;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t sdram_sz(int sz)
|
||||
@@ -674,6 +675,8 @@ void user_io_init(const char *path, const char *xml)
|
||||
// not the RBF. The RBF will be in arcade, which the user shouldn't
|
||||
// browse
|
||||
strcpy(core_path, xml ? xml : path);
|
||||
strcpy(rbf_path, path);
|
||||
|
||||
if (xml) arcade_override_name(xml);
|
||||
|
||||
memset(sd_image, 0, sizeof(sd_image));
|
||||
@@ -715,7 +718,7 @@ void user_io_init(const char *path, const char *xml)
|
||||
user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET);
|
||||
}
|
||||
|
||||
MiSTer_ini_parse();
|
||||
cfg_parse();
|
||||
if (cfg.bootcore[0] != '\0')
|
||||
{
|
||||
bootcore_init(xml ? xml : path);
|
||||
@@ -2037,15 +2040,6 @@ void user_io_send_buttons(char force)
|
||||
|
||||
if ((map != key_map) || force)
|
||||
{
|
||||
if ((key_map & (BUTTON1 | BUTTON2)) == BUTTON2 && (map & (BUTTON1 | BUTTON2)) == (BUTTON1 | BUTTON2) && is_menu_core())
|
||||
{
|
||||
if (FileExists(ini_cfg.filename_alt))
|
||||
{
|
||||
altcfg(altcfg() ? 0 : 1);
|
||||
fpga_load_rbf("menu.rbf");
|
||||
}
|
||||
}
|
||||
|
||||
const char *name = get_rbf_path();
|
||||
if (name[0] && (get_key_mod() & (LGUI | LSHIFT)) == (LGUI | LSHIFT) && (key_map & BUTTON2) && !(map & BUTTON2))
|
||||
{
|
||||
@@ -2072,6 +2066,25 @@ void user_io_send_buttons(char force)
|
||||
}
|
||||
}
|
||||
|
||||
void user_io_set_ini(int ini_num)
|
||||
{
|
||||
const char *name = rbf_path;
|
||||
const char *xml = strcasecmp(rbf_path, core_path) ? core_path : NULL;
|
||||
|
||||
if (!name[0])
|
||||
{
|
||||
name = "menu.rbf";
|
||||
xml = NULL;
|
||||
}
|
||||
|
||||
if (FileExists(cfg_get_name(ini_num)))
|
||||
{
|
||||
altcfg(ini_num);
|
||||
fpga_load_rbf(name, NULL, xml);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static uint32_t diskled_timer = 0;
|
||||
static uint32_t diskled_is_on = 0;
|
||||
void diskled_on()
|
||||
|
||||
Reference in New Issue
Block a user