bool InputEventController::OnKeyPressed(const SDL_KeyboardEvent& arg) { SDL_Keycode kc = arg.keysym.sym; auto textInputActive = SDL_IsTextInputActive(); if (textInputActive) { SDL_Keycode nkc = kc; // Map numpad enter to the "normal" enter so action subscribers don't need to // check for both. if (nkc == SDLK_KP_ENTER) nkc = SDLK_RETURN; switch (nkc) { case SDLK_BACKSPACE: case SDLK_RETURN: // For now, key_t values are mapped directly to SDL keycodes for // convenience. (*actions.ui.control)(static_cast<TextControl::key_t>(nkc)); break; } } // make left and right modifiers equal if (kc == SDLK_RSHIFT) kc = SDLK_LSHIFT; else if (kc == SDLK_RCTRL) kc = SDLK_LCTRL; else if (kc == SDLK_RGUI) kc = SDLK_LGUI; // Hotkeys are fired in addition to the normal bound action, but we don't // want to interfere with text input. if (!textInputActive) { auto iter = hotkeys.find(kc); if (iter != hotkeys.end()) { (*(iter->second))(1); } } auto hash = HashKeyboardEvent(kc); // Flip the meaning of menuNext if shift is held down. if (IsMapActive(ActionMapId::MENU) && hash == actions.ui.menuNext->GetPrimaryTrigger() && (SDL_GetModState() & KMOD_SHIFT)) { hash = actions.ui.menuPrev->GetPrimaryTrigger(); } HandleEvent(hash, 1); return true; }
GlueMapWindow * MainWindow::GetMapIfActive() { return IsMapActive() ? map : NULL; }
GlueMapWindow * MainWindow::GetMapIfActive() { return IsMapActive() ? map : nullptr; }