Last active
October 5, 2023 07:53
-
-
Save tml1024/958cbb3b9f3aab14e3bf17a7a89e3543 to your computer and use it in GitHub Desktop.
Initial Blender hack to enable binding of some non-English Latin keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From f808afe28bb0aafec5ce7f5ed28d6b5424f93667 Mon Sep 17 00:00:00 2001 | |
From: Tor Lillqvist <tml@iki.fi> | |
Date: Thu, 5 Oct 2023 01:03:28 +0300 | |
Subject: [PATCH] Enable binding of common non-English but still Latin letter | |
keys | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset=UTF-8 | |
Content-Transfer-Encoding: 8bit | |
Add keys Å, Ö, Ä, Ü, Æ, and Ø. (As found on Finnish, Swedish, German, | |
Danish, and Norwegian keyboards.) | |
Input handling added only for macOS for now. | |
--- | |
intern/ghost/GHOST_Types.h | 18 ++++++++++++++++++ | |
intern/ghost/intern/GHOST_SystemCocoa.mm | 12 +++++++++++- | |
source/blender/makesrna/intern/rna_wm.cc | 6 ++++++ | |
.../windowmanager/intern/wm_event_system.cc | 4 ++++ | |
source/blender/windowmanager/wm_event_types.hh | 6 ++++++ | |
5 files changed, 45 insertions(+), 1 deletion(-) | |
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h | |
index a2f4738a3be..7701c86ff9d 100644 | |
--- a/intern/ghost/GHOST_Types.h | |
+++ b/intern/ghost/GHOST_Types.h | |
@@ -426,6 +426,10 @@ typedef enum { | |
#define _GHOST_KEY_MODIFIER_MIN GHOST_kKeyLeftShift | |
/* Modifiers: See #GHOST_KEY_MODIFIER_CHECK. */ | |
GHOST_kKeyLeftShift = 0x100, | |
+ | |
+ /* After this the enumerators below should not have defined values, | |
+ but instead atutomatically just follow each other numerically. */ | |
+ | |
GHOST_kKeyRightShift, | |
GHOST_kKeyLeftControl, | |
GHOST_kKeyRightControl, | |
@@ -475,6 +479,20 @@ typedef enum { | |
GHOST_kKeyNumpadAsterisk, | |
GHOST_kKeyNumpadSlash, | |
+ /* Character keys found on common non-English but still Latin | |
+ keyboards. Names based on the XML and HTML character entity | |
+ reference names. Their order must be the same as that of the | |
+ corresponding values EVT_ARINGKEY etc in wm_event_types.hh. See | |
+ also the initial if statement in convert_key() in | |
+ wm_event_system.cc. */ | |
+ | |
+ GHOST_kKeyAring, | |
+ GHOST_kKeyOuml, | |
+ GHOST_kKeyAuml, | |
+ GHOST_kKeyUuml, | |
+ GHOST_kKeyAElig, | |
+ GHOST_kKeyOslash, | |
+ | |
/* Function keys. */ | |
GHOST_kKeyF1, | |
GHOST_kKeyF2, | |
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm | |
index 6f70f278dd7..32b1d4f8643 100644 | |
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm | |
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm | |
@@ -325,7 +325,17 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar) | |
case '`': | |
case '<': /* The position of '`' is equivalent to this symbol in the French layout. */ | |
return GHOST_kKeyAccentGrave; | |
- default: | |
+ case '\xE4': | |
+ return GHOST_kKeyAuml; | |
+ case '\xE5': | |
+ return GHOST_kKeyAring; | |
+ case '\xE6': | |
+ return GHOST_kKeyAElig; | |
+ case '\xF6': | |
+ return GHOST_kKeyOuml; | |
+ case '\xF8': | |
+ return GHOST_kKeyOslash; | |
+ default: | |
return GHOST_kKeyUnknown; | |
} | |
} | |
diff --git a/source/blender/makesrna/intern/rna_wm.cc b/source/blender/makesrna/intern/rna_wm.cc | |
index 14aa836107a..33323ccf5d7 100644 | |
--- a/source/blender/makesrna/intern/rna_wm.cc | |
+++ b/source/blender/makesrna/intern/rna_wm.cc | |
@@ -208,6 +208,12 @@ const EnumPropertyItem rna_enum_event_type_items[] = { | |
{EVT_XKEY, "X", 0, "X", ""}, | |
{EVT_YKEY, "Y", 0, "Y", ""}, | |
{EVT_ZKEY, "Z", 0, "Z", ""}, | |
+ {EVT_ARINGKEY, "Å", 0, "Å", ""}, | |
+ {EVT_OUMLKEY, "Ö", 0, "Ö", ""}, | |
+ {EVT_AUMLKEY, "Ä", 0, "Ä", ""}, | |
+ {EVT_UUMLKEY, "Ü", 0, "Ü", ""}, | |
+ {EVT_AELIGKEY, "Æ", 0, "Æ", ""}, | |
+ {EVT_OSLASHKEY, "Ø", 0, "Ø", ""}, | |
RNA_ENUM_ITEM_SEPR, | |
{EVT_ZEROKEY, "ZERO", 0, "0", ""}, | |
{EVT_ONEKEY, "ONE", 0, "1", ""}, | |
diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc | |
index b5a82c0143f..a1dbd9d492c 100644 | |
--- a/source/blender/windowmanager/intern/wm_event_system.cc | |
+++ b/source/blender/windowmanager/intern/wm_event_system.cc | |
@@ -4886,6 +4886,9 @@ static int convert_key(GHOST_TKey key) | |
if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) { | |
return (EVT_AKEY + (int(key) - GHOST_kKeyA)); | |
} | |
+ if (key >= GHOST_kKeyAring && key <= GHOST_kKeyOslash) { | |
+ return (EVT_ARINGKEY + (int(key) - GHOST_kKeyAring)); | |
+ } | |
if (key >= GHOST_kKey0 && key <= GHOST_kKey9) { | |
return (EVT_ZEROKEY + (int(key) - GHOST_kKey0)); | |
} | |
@@ -5024,6 +5027,7 @@ static int convert_key(GHOST_TKey key) | |
* Note that these members have been handled, these ranges are to satisfy the compiler. */ | |
case GHOST_kKeyF1 ... GHOST_kKeyF24: | |
case GHOST_kKeyA ... GHOST_kKeyZ: | |
+ case GHOST_kKeyAring ... GHOST_kKeyOslash: | |
case GHOST_kKeyNumpad0 ... GHOST_kKeyNumpad9: | |
case GHOST_kKey0 ... GHOST_kKey9: { | |
BLI_assert_unreachable(); | |
diff --git a/source/blender/windowmanager/wm_event_types.hh b/source/blender/windowmanager/wm_event_types.hh | |
index 995d5980f83..fa7aa6f8177 100644 | |
--- a/source/blender/windowmanager/wm_event_types.hh | |
+++ b/source/blender/windowmanager/wm_event_types.hh | |
@@ -135,6 +135,12 @@ enum { | |
EVT_XKEY = 0x0078, /* 'x' (120). */ | |
EVT_YKEY = 0x0079, /* 'y' (121). */ | |
EVT_ZKEY = 0x007a, /* 'z' (122). */ | |
+ EVT_ARINGKEY = 0x007b, /* 'å' (123). */ | |
+ EVT_OUMLKEY = 0x007c, /* 'ö' (124). */ | |
+ EVT_AUMLKEY = 0x007d, /* 'ä' (125). */ | |
+ EVT_UUMLKEY = 0x007e, /* 'ü' (126). */ | |
+ EVT_AELIGKEY = 0x007f, /* 'æ' (127). */ | |
+ EVT_OSLASHKEY = 0x0080, /* 'ø' (128). */ | |
EVT_LEFTARROWKEY = 0x0089, /* 137 */ | |
EVT_DOWNARROWKEY = 0x008a, /* 138 */ | |
-- | |
2.39.3 (Apple Git-145) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment