MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / isKeycodeDown

Method isKeycodeDown

Source/UserInput/keyboard.cpp:265–289  ·  view source on GitHub ↗

Check if a key is pressed

Source from the content-addressed store, hash-verified

263
264// Check if a key is pressed
265bool Keyboard::isKeycodeDown(SDL_Keycode which_key, const uint32_t kimf) const {
266 SDL_Scancode sc = SDL_GetScancodeFromKey(which_key);
267 if (kimf & input_mode) {
268 switch (which_key) {
269 case SDLK_CTRL:
270 return isKeycodeDown(SDLK_LCTRL, kimf) || isKeycodeDown(SDLK_RCTRL, kimf);
271 case SDLK_ALT:
272 return isKeycodeDown(SDLK_LALT, kimf) || isKeycodeDown(SDLK_RALT, kimf);
273 case SDLK_GUI:
274 return isKeycodeDown(SDLK_LGUI, kimf) || isKeycodeDown(SDLK_RGUI, kimf);
275 case SDLK_SHIFT:
276 return isKeycodeDown(SDLK_LSHIFT, kimf) || isKeycodeDown(SDLK_RSHIFT, kimf);
277 default: {
278 KeyStatusMap::const_iterator iter = keys.find(sc);
279 if (iter != keys.end()) {
280 const KeyStatus &key = iter->second;
281 return key.down;
282 } else {
283 return false;
284 }
285 }
286 }
287 }
288 return false;
289}
290
291bool Keyboard::isScancodeDown(SDL_Scancode which_key, const uint32_t kimf) const {
292 KeyStatusMap::const_iterator iter = keys.find(which_key);

Callers 4

UpdateMethod · 0.80
BoxSelectEntitiesFunction · 0.80
HandleShortcutsMethod · 0.80
DrawImGuiFunction · 0.80

Calls 2

findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected