Can we take another shot at TTS support for Mudlet 3 [Yeah we can!]

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Can we take another shot at TTS support for Mudlet 3 [Yeah we can!]

Post by SlySven »

Yeah that mis-naming is entirely down to the absence of platform specific code, I have the following lined up for the reporting of the key-grab which should solve some of that:

Code: Select all

 QString KeyUnit::getKeyName(int keyCode, int modifierCode)
 {
     QString name;
     /*
      Qt::NoModifier      0x00000000 No modifier key is pressed.
      Qt::ShiftModifier   0x02000000 A Shift key on the keyboard is pressed.
      Qt::ControlModifier 0x04000000 A Ctrl key on the keyboard is pressed.
      Qt::AltModifier     0x08000000 An Alt key on the keyboard is pressed.
      Qt::MetaModifier    0x10000000 A Meta key on the keyboard is pressed.
      Qt::KeypadModifier  0x20000000 A keypad button is pressed.
      Qt::GroupSwitchModifier 0x40000000 X11 only. A Mode_switch key on the keyboard is pressed.
     */
-    if (modifierCode == 0x00000000) {
-        name += "no modifiers + ";
-    }
-    if (modifierCode & 0x02000000) {
-        name += "shift + ";
-    }
-    if (modifierCode & 0x04000000) {
-        name += "control + ";
-    }
-    if (modifierCode & 0x08000000) {
-        name += "alt + ";
-    }
-    if (modifierCode & 0x10000000) {
-        name += "meta + ";
-    }
-    if (modifierCode & 0x20000000) {
-        name += "keypad + ";
+    if (!modifierCode) {
+        name += tr("no modifiers + ");
+    } else {
+        if (modifierCode & Qt::ShiftModifier) {
+#if defined(Q_OS_MAC)
+            name += tr("⇧ shift + ");
+#else
+            name += tr("shift + ");
+#endif
+        }
+        if (modifierCode & Qt::ControlModifier) {
+            // Control is the:
+            // "⌘ Command" on macOs (symbol is U+2318 PLACE OF INTEREST
+            //             a.k.a. "Cloverleaf"
+            // "Ctrl" on other platforms
+#if defined(Q_OS_MAC)
+            name += tr("⌘ command + ");
+#else
+            name += tr("ctrl + ");
+#endif
+        }
+        if (modifierCode & Qt::AltModifier) {
+            // Alt is the:
+            // "Option" on macOs
+            // "Alt" on other platform
+#if defined(Q_OS_MAC)
+            name += tr("⌥ option + ");
+#else
+            name += tr("alt + ");
+#endif
+        }
+        if (modifierCode & Qt::MetaModifier) {
+            // Meta is the:
+            // "Windows" keys on Wintel machines and
+            // "Control" on macOs
+            // "Meta" on other platforms
+#if defined(Q_OS_MAC)
+            name += tr("control + ");
+#elif defined(Q_OS_WIN)
+            name += tr("win + ");
+#else
+            name += tr("meta + ");
+#endif
+        }
+        if (modifierCode & Qt::KeypadModifier) {
+            name += tr("keypad + ");
+        }
+        if (modifierCode & Qt::GroupSwitchModifier) {
+            name += tr("groupswitch + ");
         }
-    if (modifierCode & 0x40000000) {
-        name += "groupswitch + ";
     }
+
     if (mKeys.contains(keyCode)) {
         name += mKeys[keyCode];
         return name;
     } else {
-        return QString("undefined key");
+        return tr("%1undefined key {code: 0x%2}").arg(name).arg(keyCode, 8, 16, QLatin1Char('0'));
     }
 }
Does that look as though it is on the right track?

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Can we take another shot at TTS support for Mudlet 3 [Yeah we can!]

Post by Jor'Mox »

That certainly looks like it would be adjusting the names for MacOS properly, for sure. Though, I will say that I am currently unable to use the option key (i.e. the alt key) with keybindings at all, no doubt because it has been reserved for the shortcuts that Mudlet itself uses. Were I to have my own way, I would enable the option key for keybindings, disable the command key for keybindings, switch all Mudlet shortcuts to use command instead of option, AND have some automated process such that a keybindings from other OSs are switched around to use the appropriate keys in MacOS.

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Can we take another shot at TTS support for Mudlet 3 [Yeah we can!]

Post by SlySven »

Humm, not sure if that can be handled script wise with use of the getOs() function - although setting up key-bindings for a different OS is not possible with the current Editor code as there is no way to fake/tweak the modifiers for the grab-key process. I cannot recall how much it is possible to set up with the lua function to create a permanent key-binding with a script running in the lua subsystem.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Can we take another shot at TTS support for Mudlet 3 [Yeah we can!]

Post by Jor'Mox »

Well, even if you can't automate switching from OS to OS, surely you guys can switch the built in keybindings based on OS. Using option instead of command on my Mac for basic functions is just weird.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Can we take another shot at TTS support for Mudlet 3 [Yeah we can!]

Post by Vadi »

On the subject of TTS - check out viewtopic.php?f=6&t=23015

Post Reply