From: Toni Wilen Date: Tue, 2 Jun 2015 17:07:25 +0000 (+0300) Subject: Input device autoswitch on/off option. X-Git-Tag: 3100~8 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=753b94cb0fdfcc8ea904d916dac65ceb5f8b8eb3;p=francis%2Fwinuae.git Input device autoswitch on/off option. --- diff --git a/include/inputdevice.h b/include/inputdevice.h index 3b4cf481..d7486d9a 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -335,3 +335,4 @@ extern int inputdevice_istest (void); extern void inputdevice_settest (int); extern int inputdevice_testread_count (void); +extern bool target_can_autoswitchdevice(void); diff --git a/include/options.h b/include/options.h index 43063f98..80ea6597 100644 --- a/include/options.h +++ b/include/options.h @@ -676,6 +676,7 @@ struct uae_prefs { bool input_magic_mouse; int input_magic_mouse_cursor; int input_keyboard_type; + int input_autoswitch; struct uae_input_device joystick_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; struct uae_input_device mouse_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; struct uae_input_device keyboard_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; diff --git a/inputdevice.cpp b/inputdevice.cpp index ca49f7ef..19ad3678 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -564,6 +564,7 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f) cfgfile_write (f, _T("input.analog_joystick_offset"), _T("%d"), p->input_analog_joystick_offset); cfgfile_write (f, _T("input.mouse_speed"), _T("%d"), p->input_mouse_speed); cfgfile_write (f, _T("input.autofire_speed"), _T("%d"), p->input_autofire_linecnt); + cfgfile_write (f, _T("input.autoswitch"), _T("%d"), p->input_autoswitch); cfgfile_dwrite_str (f, _T("input.keyboard_type"), kbtypes[p->input_keyboard_type]); cfgfile_dwrite (f, _T("input.contact_bounce"), _T("%d"), p->input_contact_bounce); for (id = 0; id < MAX_INPUT_SETTINGS; id++) { @@ -878,6 +879,8 @@ void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR * pr->input_analog_joystick_mult = _tstol (value); if (!strcasecmp (p, _T("analog_joystick_offset"))) pr->input_analog_joystick_offset = _tstol (value); + if (!strcasecmp (p, _T("autoswitch"))) + pr->input_autoswitch = _tstol (value); if (!strcasecmp (p, _T("keyboard_type"))) { cfgfile_strval (option, value, NULL, &pr->input_analog_joystick_offset, kbtypes, 0); keyboard_default = keyboard_default_table[pr->input_keyboard_type]; @@ -3481,6 +3484,7 @@ static void inputdevice_checkconfig (void) currprefs.input_joystick_deadzone != changed_prefs.input_joystick_deadzone || currprefs.input_joymouse_speed != changed_prefs.input_joymouse_speed || currprefs.input_autofire_linecnt != changed_prefs.input_autofire_linecnt || + currprefs.input_autoswitch != changed_prefs.input_autoswitch || currprefs.input_mouse_speed != changed_prefs.input_mouse_speed) { currprefs.input_selected_setting = changed_prefs.input_selected_setting; @@ -3490,6 +3494,7 @@ static void inputdevice_checkconfig (void) currprefs.input_joymouse_speed = changed_prefs.input_joymouse_speed; currprefs.input_autofire_linecnt = changed_prefs.input_autofire_linecnt; currprefs.input_mouse_speed = changed_prefs.input_mouse_speed; + currprefs.input_autoswitch = changed_prefs.input_autoswitch; inputdevice_updateconfig (&changed_prefs, &currprefs); } @@ -3605,12 +3610,11 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode) if (num >= 4) return 0; -#ifdef RETROPLATFORM - if (rp_isactive ()) - return 0; -#endif - if (!ismouseactive()) + if (!currprefs.input_autoswitch) + return false; + if (!target_can_autoswitchdevice()) return 0; + for (i = 0; i < MAX_INPUT_DEVICES; i++) { if (id == &joysticks[i]) { name = idev[IDTYPE_JOYSTICK].get_uniquename (i); @@ -5745,6 +5749,7 @@ void inputdevice_default_prefs (struct uae_prefs *p) p->input_mouse_speed = 100; p->input_autofire_linecnt = 600; p->input_keyboard_type = 0; + p->input_autoswitch = true; keyboard_default = keyboard_default_table[p->input_keyboard_type]; inputdevice_default_kb_all (p); }