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

Method createEventDescriptor

Engine/source/sim/actionMap.cpp:423–535  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

421
422//--------------------------------------------------------------------------
423bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor* pDescriptor)
424{
425 char copyBuffer[256];
426 dStrcpy(copyBuffer, pEventString);
427
428 // Do we have modifiers?
429 char* pSpace = dStrchr(copyBuffer, ' ');
430 char* pObjectString;
431 if (pSpace != NULL) {
432 // Yes. Parse them out...
433 //
434 pDescriptor->flags = 0;
435 pObjectString = pSpace + 1;
436 pSpace[0] = '\0';
437
438 char* pModifier = dStrtok(copyBuffer, "-");
439 while (pModifier != NULL) {
440 if (dStricmp(pModifier, "shift") == 0) {
441 pDescriptor->flags |= SI_SHIFT;
442 } else if (dStricmp(pModifier, "ctrl") == 0) {
443 pDescriptor->flags |= SI_CTRL;
444 } else if (dStricmp(pModifier, "alt") == 0) {
445 pDescriptor->flags |= SI_ALT;
446 } else if (dStricmp(pModifier, "cmd") == 0) {
447 pDescriptor->flags |= SI_ALT;
448 } else if (dStricmp(pModifier, "opt") == 0) {
449 pDescriptor->flags |= SI_MAC_OPT;
450 }
451
452 pModifier = dStrtok(NULL, "-");
453 }
454 } else {
455 // No.
456 pDescriptor->flags = 0;
457 pObjectString = copyBuffer;
458 }
459
460 // Now we need to map the key string to the proper KEY code from event.h
461 //
462 AssertFatal(dStrlen(pObjectString) != 0, "Error, no key was specified!");
463
464 if (dStrlen(pObjectString) == 1)
465 {
466 if (dIsDecentChar(*pObjectString)) // includes foreign chars
467 {
468 U16 asciiCode = (*pObjectString);
469 // clear out the FF in upper 8bits for foreign keys??
470 asciiCode &= 0xFF;
471 U16 keyCode = Input::getKeyCode(asciiCode);
472 if ( keyCode >= KEY_0 )
473 {
474 pDescriptor->eventType = SI_KEY;
475 pDescriptor->eventCode = keyCode;
476 return true;
477 }
478 else if (dIsalpha(*pObjectString) == true)
479 {
480 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