[PATCH 03/13] Clear KeysDown[] key mapping state on reset

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


IKBD clears corresponding Keyboard.KeyStates[] array on reset, so
KeyDown[] needs to be cleared on reset too.
---
 src/includes/keymap.h | 1 +
 src/keymap.c          | 9 +++++++++
 src/reset.c           | 2 ++
 3 files changed, 12 insertions(+)

diff --git a/src/includes/keymap.h b/src/includes/keymap.h
index abf7586e..0ba2ac9e 100644
--- a/src/includes/keymap.h
+++ b/src/includes/keymap.h
@@ -11,6 +11,7 @@
 #include <SDL_keyboard.h>
 
 extern void Keymap_Init(void);
+extern void Keymap_Reset(void);
 extern void Keymap_LoadRemapFile(const char *pszFileName);
 extern void Keymap_DebounceAllKeys(void);
 extern void Keymap_KeyDown(const SDL_Keysym *sdlkey);
diff --git a/src/keymap.c b/src/keymap.c
index d39bccef..9f3df866 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -73,6 +73,15 @@ void Keymap_Init(void)
 	Keymap_LoadRemapFile(ConfigureParams.Keyboard.szMappingFileName);
 }
 
+/**
+ * Clear key states on reset, like IKBD does
+ */
+void Keymap_Reset(void)
+{
+	memset(KeysDown, 0, sizeof(KeysDown));
+}
+
+
 /**
  * Map SDL symbolic key to ST scan code.
  * This assumes a QWERTY ST keyboard.
diff --git a/src/reset.c b/src/reset.c
index 0a244c50..10946540 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -22,6 +22,7 @@ const char Reset_fileid[] = "Hatari reset.c";
 #include "ioMem.h"
 #include "cycles.h"
 #include "cycInt.h"
+#include "keymap.h"
 #include "m68000.h"
 #include "mfp.h"
 #include "midi.h"
@@ -103,6 +104,7 @@ static int Reset_ST(bool bCold)
 	Sound_Reset();                /* Reset Sound */
 	ACIA_Reset( ACIA_Array );     /* ACIA */
 	IKBD_Reset(bCold);            /* Keyboard (after ACIA) */
+	Keymap_Reset();               /* Key mapping state */
 	SCC_Reset();
 	if (Config_IsMachineFalcon() && !bUseVDIRes)
 		VIDEL_reset();
-- 
2.30.2


--------------6125158E9D8E923B9ED57408
Content-Type: text/x-patch; charset=UTF-8;
 name="0002-Switch-to-using-KeyMapping-struct-and-KeysDown-array.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0002-Switch-to-using-KeyMapping-struct-and-KeysDown-array.pa";
 filename*1="tch"



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/