From 8d6c967c68f1af2af48cbacc99f3891e7bbcfc05 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 9 Dec 2017 21:29:59 +0200 Subject: [PATCH] Do not refresh input/gui if nothing changed. --- include/inputdevice.h | 2 +- inputdevice.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/inputdevice.h b/include/inputdevice.h index 69829308..f5407252 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -248,7 +248,7 @@ void setmousestate (int mouse, int axis, int data, int isabs); extern int getmousestate (int mouse); extern void inputdevice_updateconfig (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs); extern void inputdevice_updateconfig_internal (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs); -extern void inputdevice_devicechange (struct uae_prefs *prefs); +extern bool inputdevice_devicechange (struct uae_prefs *prefs); #define INTERNALEVENT_CPURESET 0 #define INTERNALEVENT_KBRESET 1 diff --git a/inputdevice.cpp b/inputdevice.cpp index 562f889e..290d848e 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -3284,7 +3284,7 @@ uae_u8 handle_parport_joystick (int port, uae_u8 pra, uae_u8 dra) } } -/* p5 is 1 or floating = cd32 2-button mode */ +/* p5 (3rd button) is 1 or floating = cd32 2-button mode */ static bool cd32padmode (uae_u16 p5dir, uae_u16 p5dat) { if (!(potgo_value & p5dir) || ((potgo_value & p5dat) && (potgo_value & p5dir))) @@ -7253,7 +7253,7 @@ void inputdevice_updateconfig (struct uae_prefs *srcprefs, struct uae_prefs *dst * store old devices temporarily, enumerate all devices * restore old devices back (order may have changed) */ -void inputdevice_devicechange (struct uae_prefs *prefs) +bool inputdevice_devicechange (struct uae_prefs *prefs) { int acc = input_acquired; int i, idx; @@ -7262,6 +7262,7 @@ void inputdevice_devicechange (struct uae_prefs *prefs) int jportskb[MAX_JPORTS], jportscustom[MAX_JPORTS]; int jportsmode[MAX_JPORTS]; int jportid[MAX_JPORTS], jportaf[MAX_JPORTS]; + bool changed = false; for (i = 0; i < MAX_JPORTS; i++) { jportskb[i] = -1; @@ -7343,12 +7344,14 @@ void inputdevice_devicechange (struct uae_prefs *prefs) if (devcfg[i][j].name[0]) { write_log(_T("REMOVED: %s (%s)\n"), devcfg[i][j].name, devcfg[i][j].configname); inputdevice_store_unplugged_port(prefs, &devcfg[i][j]); + changed = true; } if (i < num && df[i] == false) { struct inputdevconfig idc; _tcscpy(idc.configname, inf->get_uniquename(i)); _tcscpy(idc.name, inf->get_friendlyname(i)); write_log(_T("INSERTED: %s (%s)\n"), idc.name, idc.configname); + changed = true; int portnum = inputdevice_get_unplugged_device(&idc); if (portnum >= 0) { write_log(_T("Inserting to port %d\n"), portnum); @@ -7395,6 +7398,9 @@ void inputdevice_devicechange (struct uae_prefs *prefs) inputdevice_validate_jports(prefs, i, fixedports); } + if (!changed) + return false; + if (prefs == &changed_prefs) inputdevice_copyconfig (&changed_prefs, &currprefs); if (acc) @@ -7403,6 +7409,7 @@ void inputdevice_devicechange (struct uae_prefs *prefs) rp_enumdevices (); #endif set_config_changed (); + return true; } -- 2.47.3