MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / keyEvent

Method keyEvent

engine/source/platformEmscripten/EmscriptenInputManager.cpp:917–970  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

915
916//------------------------------------------------------------------------------
917void UInputManager::keyEvent(const SDL_Event& event)
918{
919 S32 action = (event.type == SDL_KEYDOWN) ? SI_MAKE : SI_BREAK;
920 InputEvent ievent;
921
922// Con::printf("keyEvent: %u", event.key.keysym.sym);
923
924 ievent.deviceInst = 0;
925 ievent.deviceType = KeyboardDeviceType;
926 ievent.objType = SI_KEY;
927 ievent.objInst = TranslateSDLKeytoTKey(event.key.keysym.sym);
928// Con::printf("keyEvent: objInst %u", ievent.objInst);
929 // if the action is a make but this key is already pressed,
930 // count it as a repeat
931 if (action == SI_MAKE && mKeyboardState[ievent.objInst])
932 action = SI_REPEAT;
933 ievent.action = action;
934 ievent.fValues[0] = (action == SI_MAKE || action == SI_REPEAT) ? 1.0 : 0.0;
935
936 processKeyEvent(ievent);
937 Game->postEvent(ievent);
938
939#if 0
940 if (ievent.action == SI_MAKE)
941 dPrintf("key event: : %s key pressed. MODS:%c%c%c\n",
942 getKeyName(ievent.objInst),
943 ( mModifierKeys & SI_SHIFT ? 'S' : '.' ),
944 ( mModifierKeys & SI_CTRL ? 'C' : '.' ),
945 ( mModifierKeys & SI_ALT ? 'A' : '.' ));
946 else if (ievent.action == SI_REPEAT)
947 dPrintf("key event: : %s key repeated. MODS:%c%c%c\n",
948 getKeyName(ievent.objInst),
949 ( mModifierKeys & SI_SHIFT ? 'S' : '.' ),
950 ( mModifierKeys & SI_CTRL ? 'C' : '.' ),
951 ( mModifierKeys & SI_ALT ? 'A' : '.' ));
952 else if (ievent.action == SI_BREAK)
953 dPrintf("key event: : %s key released. MODS:%c%c%c\n",
954 getKeyName(ievent.objInst),
955 ( mModifierKeys & SI_SHIFT ? 'S' : '.' ),
956 ( mModifierKeys & SI_CTRL ? 'C' : '.' ),
957 ( mModifierKeys & SI_ALT ? 'A' : '.' ));
958 else
959 dPrintf("unknown key event!\n");
960#endif
961
962#ifdef LOG_INPUT
963 Input::log( "EVENT (Input): %s key %s. MODS:%c%c%c\n",
964 getKeyName(ievent.objInst),
965 action == SI_MAKE ? "pressed" : "released",
966 ( mModifierKeys & SI_SHIFT ? 'S' : '.' ),
967 ( mModifierKeys & SI_CTRL ? 'C' : '.' ),
968 ( mModifierKeys & SI_ALT ? 'A' : '.' ));
969#endif
970}
971
972//------------------------------------------------------------------------------
973// This function was ripped from DInputDevice almost entirely intact.

Callers

nothing calls this directly

Calls 5

logFunction · 0.85
TranslateSDLKeytoTKeyFunction · 0.70
dPrintfFunction · 0.70
getKeyNameFunction · 0.70
postEventMethod · 0.45

Tested by

no test coverage detected