@@ -466,23 +466,41 @@ bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor*
466466 pObjectString = pSpace + 1 ;
467467 pSpace[0 ] = ' \0 ' ;
468468
469- char * pModifier = dStrtok (copyBuffer, " -" );
470- while (pModifier != NULL ) {
471- if (dStricmp (pModifier, " shift" ) == 0 ) {
472- pDescriptor->flags |= SI_SHIFT;
473- } else if (dStricmp (pModifier, " ctrl" ) == 0 ) {
474- pDescriptor->flags |= SI_CTRL;
475- } else if (dStricmp (pModifier, " alt" ) == 0 ) {
476- pDescriptor->flags |= SI_ALT;
477- } else if (dStricmp (pModifier, " cmd" ) == 0 ) {
478- pDescriptor->flags |= SI_ALT;
479- } else if (dStricmp (pModifier, " opt" ) == 0 ) {
480- pDescriptor->flags |= SI_MAC_OPT;
481- }
482-
483- pModifier = dStrtok (NULL , " -" );
484- }
485- } else {
469+ char * pModifier = dStrtok (copyBuffer, " -" );
470+ while (pModifier != NULL )
471+ {
472+ #if defined(TORQUE_OS_MAC)
473+ if (dStricmp (pModifier, " ctrl" ) == 0 || dStricmp (pModifier, " cmd" ) == 0 )
474+ {
475+ pDescriptor->flags |= SI_CTRL; // On Mac, map Ctrl/Cmd to the standard Mac command key
476+ }
477+ else if (dStricmp (pModifier, " shift" ) == 0 )
478+ {
479+ pDescriptor->flags |= SI_SHIFT;
480+ }
481+ else if (dStricmp (pModifier, " alt" ) == 0 || dStricmp (pModifier, " opt" ) == 0 )
482+ {
483+ pDescriptor->flags |= SI_MAC_OPT;
484+ }
485+ #else
486+ if (dStricmp (pModifier, " ctrl" ) == 0 || (dStricmp (pModifier, " cmd" ) == 0 )
487+ {
488+ pDescriptor->flags |= SI_CTRL;
489+ }
490+ else if (dStricmp (pModifier, " shift" ) == 0 )
491+ {
492+ pDescriptor->flags |= SI_SHIFT;
493+ }
494+ else if (dStricmp (pModifier, " alt" ) == 0 || dStricmp (pModifier, " opt" ) == 0 )
495+ {
496+ pDescriptor->flags |= SI_ALT;
497+ }
498+ #endif
499+ pModifier = dStrtok (NULL , " -" );
500+ }
501+ }
502+ else
503+ {
486504 // No.
487505 pDescriptor->flags = 0 ;
488506 pObjectString = copyBuffer;
@@ -492,6 +510,47 @@ bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor*
492510 //
493511 AssertFatal (dStrlen (pObjectString) != 0 , " Error, no key was specified!" );
494512
513+ // rebuild normalized modifier string from parsed flags
514+ String newString;
515+
516+ #if defined(TORQUE_OS_MAC)
517+
518+ if (pDescriptor->flags & SI_ALT || pDescriptor->flags & SI_CTRL)
519+ newString += " Cmd" ;
520+
521+ if (pDescriptor->flags & SI_MAC_OPT)
522+ {
523+ if (newString.length ()) newString += " -" ;
524+ newString += " Opt" ;
525+ }
526+
527+ #else
528+
529+ if (pDescriptor->flags & SI_CTRL)
530+ newString += " Ctrl" ;
531+
532+ if (pDescriptor->flags & SI_ALT)
533+ {
534+ if (newString.length ()) newString += " -" ;
535+ newString += " Alt" ;
536+ }
537+
538+ #endif
539+
540+ if (pDescriptor->flags & SI_SHIFT)
541+ {
542+ if (newString.length ()) newString += " -" ;
543+ newString += " Shift" ;
544+ }
545+
546+ // rebuild full event string
547+ if (newString.length ())
548+ newString = String::ToString (" %s %s" , newString.c_str (), pObjectString).c_str ();
549+ else
550+ newString = String::ToString (" %s" , pObjectString).c_str ();
551+
552+ dStrcpy (const_cast <char *>(pEventString), newString.c_str (), newString.length ()+1 );
553+
495554 if (dStrlen (pObjectString) == 1 )
496555 {
497556 if (dIsDecentChar (*pObjectString)) // includes foreign chars
@@ -544,16 +603,7 @@ bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor*
544603 }
545604 }
546605 }
547- // Didn't find an ascii match. Check the virtual map table
548- // for (U32 j = 0; gVirtualMap[j].code != 0xFFFFFFFF; j++)
549- // {
550- // if (dStricmp(pObjectString, gVirtualMap[j].pDescription) == 0)
551- // {
552- // pDescriptor->eventType = gVirtualMap[j].type;
553- // pDescriptor->eventCode = gVirtualMap[j].code;
554- // return true;
555- // }
556- // }
606+
557607 InputEventManager::VirtualMapData* data = INPUTMGR->findVirtualMap (pObjectString);
558608 if (data)
559609 {
0 commit comments