]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Automatically enable inactive port if external input event uses it. Support mouse...
authorToni Wilen <twilen@winuae.net>
Sun, 20 Dec 2015 11:05:28 +0000 (13:05 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 20 Dec 2015 11:05:28 +0000 (13:05 +0200)
inputdevice.cpp

index 7c2a5760c7ef4295931d14224642298c3d919156..516f2511f4053bc76ccda0830a7a527d2f9ae2c7 100644 (file)
@@ -156,6 +156,8 @@ static int isdevice (struct uae_input_device *id)
        return 0;
 }
 
+static void check_enable(int ei);
+
 int inputdevice_uaelib (const TCHAR *s, const TCHAR *parm)
 {
        int i;
@@ -185,6 +187,7 @@ int inputdevice_uaelib (const TCHAR *s, const TCHAR *parm)
 
        for (i = 1; events[i].name; i++) {
                if (!_tcscmp (s, events[i].confname)) {
+                       check_enable(i);
                        handle_input_event (i, parm ? _tstol (parm) : 0, 1, 0, false, false);
                        return 1;
                }
@@ -196,6 +199,7 @@ int inputdevice_uaelib(const TCHAR *s, int parm, int max, bool autofire)
 {
        for (int i = 1; events[i].name; i++) {
                if (!_tcscmp(s, events[i].confname)) {
+                       check_enable(i);
                        handle_input_event(i, parm, max, autofire, false, false);
                        return 1;
                }
@@ -3369,7 +3373,7 @@ static int handle_input_event (int nr, int state, int max, int autofire, bool ca
 
                        /* real mouse / analog stick mouse emulation */
                        int delta;
-                       int deadzone = currprefs.input_joymouse_deadzone * max / 100;
+                       int deadzone = max < 0 ? 0 : currprefs.input_joymouse_deadzone * max / 100;
                        int unit = ie->data & 0x7f;
 
                        if (max) {
@@ -3383,8 +3387,12 @@ static int handle_input_event (int nr, int state, int max, int autofire, bool ca
                                        state -= deadzone;
                                        mouse_deltanoreset[joy][unit] = 1;
                                }
-                               max -= deadzone;
-                               delta = state * currprefs.input_joymouse_multiplier / max;
+                               if (max > 0) {
+                                       max -= deadzone;
+                                       delta = state * currprefs.input_joymouse_multiplier / max;
+                               } else {
+                                       delta = state;
+                               }
                        } else {
                                delta = state;
                                mouse_deltanoreset[joy][unit] = 0;
@@ -4403,6 +4411,16 @@ static void isqualifier (int ei)
 {
 }
 
+static void check_enable(int ei)
+{
+       iscd32(ei);
+       isparport(ei);
+       ismouse(ei);
+       isdigitalbutton(ei);
+       isqualifier(ei);
+       islightpen(ei);
+}
+
 static void scanevents (struct uae_prefs *p)
 {
        int i, j, k, ei;