]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Support uae-configuration on the fly input config changes.
authorToni Wilen <twilen@winuae.net>
Sat, 21 Sep 2019 07:47:04 +0000 (10:47 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 21 Sep 2019 07:47:04 +0000 (10:47 +0300)
cfgfile.cpp
inputdevice.cpp

index 4de8214f620b5e7fd0a8e6037bce2ce9e16b0d70..36da7f0cd478b4c2bbbb2ae664ae1acc4122320b 100644 (file)
@@ -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);
index f5b51f32ded083b0f2c8f7a7f2fdec22017779af..d3911f4b7ef67aa85c3dcc224a39742011de0553 100644 (file)
@@ -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) {