From 92849895c3872c62d8e477c36d4b967f7c1b32fe Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 21 Sep 2019 10:47:04 +0300 Subject: [PATCH] Support uae-configuration on the fly input config changes. --- cfgfile.cpp | 25 +++++++++++++++++-------- inputdevice.cpp | 19 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 4de8214f..36da7f0c 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -3102,7 +3102,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) TCHAR *tmpp; TCHAR tmpbuf[CONFIG_BLEN]; - if (_tcsncmp (option, _T("input."), 6) == 0) { + if (_tcsncmp (option, _T("input."), 6) == 0 || _tcsncmp(option, _T("input_"), 6) == 0) { read_inputdevice_config (p, option, value); return 1; } @@ -7093,11 +7093,16 @@ void cfgfile_addcfgparam (TCHAR *line) } if (!cfgfile_separate_line (line, line1b, line2b)) return; + if (!_tcsnicmp(line1b, _T("input."), 6)) { + line1b[5] = '_'; + } u = xcalloc (struct strlist, 1); - u->option = my_strdup (line1b); - u->value = my_strdup (line2b); - u->next = temp_lines; - temp_lines = u; + if (u) { + u->option = my_strdup(line1b); + u->value = my_strdup(line2b); + u->next = temp_lines; + temp_lines = u; + } } #if 0 @@ -9207,9 +9212,13 @@ void error_log (const TCHAR *format, ...) va_end (parms); strlist *u = xcalloc (struct strlist, 1); - u->option = my_strdup (bufp); - u->next = error_lines; - error_lines = u; + if (u) { + u->option = my_strdup(bufp); + if (u->option) { + u->next = error_lines; + error_lines = u; + } + } if (bufp != buffer) xfree (bufp); diff --git a/inputdevice.cpp b/inputdevice.cpp index f5b51f32..d3911f4b 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -1467,6 +1467,7 @@ void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR * TCHAR *p2, *custom; struct temp_uids *tid = &temp_uid; struct inputdevice_functions *idf = NULL; + bool directmode = option[5] == '_'; option += 6; /* "input." */ p = getstring (&option); @@ -1512,7 +1513,7 @@ void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR * return; idnum--; - if (idnum != tid->idnum) { + if (idnum != tid->idnum || directmode) { reset_inputdevice_config_temp(); tid->idnum = idnum; } @@ -1575,33 +1576,37 @@ void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR * } #endif } + if (directmode) { + tid->joystick = joystick; + tid->devtype = devtype; + } if (!_tcscmp (p2, _T("name"))) { xfree(tid->configname); tid->configname = my_strdup (value); - tid->joystick = joystick; - tid->devtype = devtype; tid->custom = false; tid->empty = false; tid->disabled = false; + tid->joystick = joystick; + tid->devtype = devtype; return; } if (!_tcscmp (p2, _T("friendlyname"))) { xfree (tid->name); tid->name = my_strdup (value); - tid->joystick = joystick; - tid->devtype = devtype; tid->custom = false; tid->empty = false; tid->disabled = false; + tid->joystick = joystick; + tid->devtype = devtype; return; } if (!_tcscmp (p2, _T("custom"))) { p = value; tid->custom = getnum(&p); + tid->empty = false; tid->joystick = joystick; tid->devtype = devtype; - tid->empty = false; return; } if (!_tcscmp(p2, _T("empty"))) { @@ -1691,7 +1696,7 @@ void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR * return; } - if (newdev) { + if (newdev && !directmode) { if (!tid->initialized) clear_id(id); if (!tid->empty && tid->devtype == IDTYPE_KEYBOARD && !tid->initialized) { -- 2.47.3