Check if a key is pressed
| 263 | |
| 264 | // Check if a key is pressed |
| 265 | bool 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 | |
| 291 | bool Keyboard::isScancodeDown(SDL_Scancode which_key, const uint32_t kimf) const { |
| 292 | KeyStatusMap::const_iterator iter = keys.find(which_key); |
no test coverage detected