From ae5b5ec74f2e3f707e26f8bb3d294b586d5834ad Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 20 Dec 2015 13:05:28 +0200 Subject: [PATCH] Automatically enable inactive port if external input event uses it. Support mouse movement events without input_joymouse_multiplier. --- inputdevice.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/inputdevice.cpp b/inputdevice.cpp index 7c2a5760..516f2511 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -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; -- 2.47.3