MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / createEventDescriptor

Method createEventDescriptor

Engine/source/sim/actionMap.cpp:453–565  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

451
452//--------------------------------------------------------------------------
453bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor* pDescriptor)
454{
455 char copyBuffer[256];
456 dStrcpy(copyBuffer, pEventString, 256);
457
458 // Do we have modifiers?
459 char* pSpace = dStrchr(copyBuffer, ' ');
460 char* pObjectString;
461 if (pSpace != NULL) {
462 // Yes. Parse them out...
463 //
464 pDescriptor->flags = 0;
465 pObjectString = pSpace + 1;
466 pSpace[0] = '\0';
467
468 char* pModifier = dStrtok(copyBuffer, "-");
469 while (pModifier != NULL) {
470 if (dStricmp(pModifier, "shift") == 0) {
471 pDescriptor->flags |= SI_SHIFT;
472 } else if (dStricmp(pModifier, "ctrl") == 0) {
473 pDescriptor->flags |= SI_CTRL;
474 } else if (dStricmp(pModifier, "alt") == 0) {
475 pDescriptor->flags |= SI_ALT;
476 } else if (dStricmp(pModifier, "cmd") == 0) {
477 pDescriptor->flags |= SI_ALT;
478 } else if (dStricmp(pModifier, "opt") == 0) {
479 pDescriptor->flags |= SI_MAC_OPT;
480 }
481
482 pModifier = dStrtok(NULL, "-");
483 }
484 } else {
485 // No.
486 pDescriptor->flags = 0;
487 pObjectString = copyBuffer;
488 }
489
490 // Now we need to map the key string to the proper KEY code from event.h
491 //
492 AssertFatal(dStrlen(pObjectString) != 0, "Error, no key was specified!");
493
494 if (dStrlen(pObjectString) == 1)
495 {
496 if (dIsDecentChar(*pObjectString)) // includes foreign chars
497 {
498 U16 asciiCode = (*pObjectString);
499 // clear out the FF in upper 8bits for foreign keys??
500 asciiCode &= 0xFF;
501 U16 keyCode = Input::getKeyCode(asciiCode);
502 if ( keyCode >= KEY_0 )
503 {
504 pDescriptor->eventType = SI_KEY;
505 pDescriptor->eventCode = keyCode;
506 return true;
507 }
508 else if (dIsalpha(*pObjectString) == true)
509 {
510 pDescriptor->eventType = SI_KEY;

Callers

nothing calls this directly

Calls 10

dStrcpyFunction · 0.85
dStrtokFunction · 0.85
dStricmpFunction · 0.85
dIsDecentCharFunction · 0.85
dIsalphaFunction · 0.85
dTolowerFunction · 0.85
dIsdigitFunction · 0.85
findVirtualMapMethod · 0.80
dStrchrFunction · 0.50
dStrlenFunction · 0.50

Tested by

no test coverage detected