[PATCH 9/9] Use hex instead of decimals for keymap scancodes

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


Both in keymap config file and trace output used for debugging.

Based on Vincent Barilliot's patch.

This change will not be merged, because it breaks compatibility with
earlier keymap specification. It's provided for easier testing of
keymaps written for Vincent's patch (with this, one should need to
remove only mod masks from them).
---
 src/keymap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/keymap.c b/src/keymap.c
index 5276be1b..7fddc86c 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -595,7 +595,7 @@ static bool HostSpecToKeymap(const char *spec, KeyMapping* mapping)
 			Log_Printf(LOG_WARN, "extra '%s', PC/SDL scancode already set\n", token);
 			return false;
 		}
-		scancode = strtol(token, &endptr, 10);
+		scancode = strtol(token, &endptr, 16);
 		if (!scancode)
 		{
 			Log_Printf(LOG_ERROR, "invalid PC/SDL scancode '%s'\n", token);
@@ -697,7 +697,7 @@ static bool GuestSpecToKeymap(const char *spec, KeyMapping* mapping)
 			Log_Printf(LOG_WARN, "extra '%s', ST scancode already set\n", token);
 			return false;
 		}
-		scancode = strtol(token, &endptr, 10);
+		scancode = strtol(token, &endptr, 16);
 		if (!scancode)
 		{
 			Log_Printf(LOG_ERROR, "invalid ST scancode '%s'\n", token);
@@ -1000,7 +1000,7 @@ void Keymap_KeyDown(const SDL_Keysym *sdlkey)
 	int symkey = sdlkey->sym;
 	int modkey = sdlkey->mod;
 
-	LOG_TRACE(TRACE_KEYMAP, "key down: sym=%i scan=%i mod=0x%x name='%s'\n",
+	LOG_TRACE(TRACE_KEYMAP, "key down: sym=%i scan=0x%02x mod=0x%x name='%s'\n",
 	          symkey, sdlkey->scancode, modkey, Keymap_GetKeyName(symkey));
 
 	if (ShortCut_CheckKeys(modkey, symkey, true))
@@ -1049,7 +1049,7 @@ void Keymap_KeyUp(const SDL_Keysym *sdlkey)
 	int symkey = sdlkey->sym;
 	int modkey = sdlkey->mod;
 
-	LOG_TRACE(TRACE_KEYMAP, "key up: sym=%i scan=%i mod=0x%x name='%s'\n",
+	LOG_TRACE(TRACE_KEYMAP, "key up: sym=%i scan=0x%02x mod=0x%x name='%s'\n",
 	          symkey, sdlkey->scancode, modkey, Keymap_GetKeyName(symkey));
 
 	/* Ignore short-cut keys here */
-- 
2.30.2


--------------7873925CF10FCA11A2667F70
Content-Type: text/x-patch; charset=UTF-8;
 name="0008-Prevent-key-mapping-breaking-non-recoverably.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0008-Prevent-key-mapping-breaking-non-recoverably.patch"



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