[PATCH] Accept any kind of symbolic SDL key names

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


Besides adding some [1] support for special characters, this is needed
also for non-ASCII alphabetic characters. Hatari could be run in a
locale where those are not recognized as alphabetic characters, or it
could be built with a C-library missing proper locale support.

[1] Following still need to be specified using SDL scancodes:

* Numbers and other characters ("#;, ") used in keymap syntax

* Keys for which SDL does not have scancode with *host* keyboard
  mapping, such as dead keys and virtual ones:
  https://wiki.libsdl.org/SDL_Keycode
---
 src/keymap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/keymap.c b/src/keymap.c
index 7ce7bc7d..3daff690 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -794,8 +794,8 @@ static bool HostSpecToKeymap(const char *spec, KeyMapping* mapping)
 	     token = strtok_r(NULL, "|", &saveptr))
 	{
 		token = Str_Trim(token);
-		/* text description? */
-		if (isalpha(token[0]))
+		/* not a number? */
+		if (!isdigit(token[0]))
 		{
 			SDL_Scancode code;
 			SDL_Keymod mod;
@@ -902,7 +902,8 @@ static bool GuestSpecToKeymap(const char *spec, KeyMapping* mapping)
 	     token = strtok_r(NULL, "|", &saveptr))
 	{
 		token = Str_Trim(token);
-		if (isalpha(token[0]))
+		/* not a number? */
+		if (!isdigit(token[0]))
 		{
 			mods = AddSTModifier(mods, token);
 			if (!mods)
-- 
2.30.2


--------------6D59CF2683B8E6D297AA7665
Content-Type: text/plain; charset=UTF-8;
 name="keymap.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="keymap.txt"

IyBzcGVjaWFsIHNjYW5jb2RlIG5hbWUgZXhhbXBsZToKIyAgICdmMScgLT4gJ2InCkYxLDQ4
CgojIHNwZWNpYWwga2V5cyBtYXBwZWQgZGlmZmVyZW50bHkgb24gVVMgJiBGSSBrZXlib2Fy
ZHMKIyAoYW5kIHVzaW5nIGhleCBkZWNpbWFscykKIyAgICcgLT4gJ2EnCiMgICDDtiAtPiAn
YicKJ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