--------------------------------------------------------------------------
| 451 | |
| 452 | //-------------------------------------------------------------------------- |
| 453 | bool 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; |
nothing calls this directly
no test coverage detected