📄 sdl_epocevents.cpp
字号:
{ return 0; //TODO: Find out why events are get despite of cursor should be off }*/ const TPointerEvent* pointerEvent = aWsEvent.Pointer(); const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition); /*!! TODO Pointer do not yet work properly //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!! if (Private->EPOC_ShrinkedHeight) { mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height } if (Private->EPOC_ShrinkedWidth) { mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width } */ posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */ switch (pointerEvent->iType) { case TPointerEvent::EButton1Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton1Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton2Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton2Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton3Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); break; case TPointerEvent::EButton3Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); break; } // switch break; } case EEventKeyDown: /* Key events */ {#ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker down, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); if(mode != EPointerCursorNone) posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); }#endif (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym); #ifndef DISABLE_JOYSTICK /* Special handling */ switch((int)keysym.sym) { case SDLK_CAPSLOCK: if (!isCursorVisible) { /* Enable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); } else { /* Disable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); } isCursorVisible = !isCursorVisible; break; }#endif posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym); break; } case EEventKeyUp: /* Key events */ {#ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker up, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); }#endif posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym)); break; } case EEventFocusGained: /* SDL window got focus */ { Private->iIsWindowFocused = ETrue; posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); /* Draw window background and screen buffer */ DisableKeyBlocking(_this); //Markus: guess why:-) //RedrawWindowL(_this); break; } case EEventFocusLost: /* SDL window lost focus */ { Private->iIsWindowFocused = EFalse; posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); break; } case EEventModifiersChanged: { TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged(); TUint modstate = KMOD_NONE; if (modEvent->iModifiers == EModifierLeftShift) modstate |= KMOD_LSHIFT; if (modEvent->iModifiers == EModifierRightShift) modstate |= KMOD_RSHIFT; if (modEvent->iModifiers == EModifierLeftCtrl) modstate |= KMOD_LCTRL; if (modEvent->iModifiers == EModifierRightCtrl) modstate |= KMOD_RCTRL; if (modEvent->iModifiers == EModifierLeftAlt) modstate |= KMOD_LALT; if (modEvent->iModifiers == EModifierRightAlt) modstate |= KMOD_RALT; if (modEvent->iModifiers == EModifierLeftFunc) modstate |= KMOD_LMETA; if (modEvent->iModifiers == EModifierRightFunc) modstate |= KMOD_RMETA; if (modEvent->iModifiers == EModifierCapsLock) modstate |= KMOD_CAPS; SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT))); break; } case EEventScreenDeviceChanged: { EpocSdlEnv::WaitDeviceChange(); } break; default: break; } return posted;}extern "C" {void EPOC_PumpEvents(_THIS) { MEventQueue& events = EpocSdlEnv::EventQueue(); while(events.HasData()) { events.Lock(); //there have to be a copy, so we can release //lock immediately. HandleWsEvent may cause //deadlock otherwise. const TWsEvent event = events.Shift(); events.Unlock();// const TWsEvent& event = events.Top(); EPOC_HandleWsEvent(_this, event);// events.Shift(); } }void EPOC_InitOSKeymap(_THIS) { ResetKeyMap(); EpocSdlEnv::ObserverEvent(MSDLObserver::EEventKeyMapInit ,0); }static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym){// char debug[256]; //SDL_TRACE1("SDL: TranslateKey, scancode=%d", scancode); //!! /* Set the keysym information */ keysym->scancode = scancode; if ((scancode >= MAX_SCANCODE) && ((scancode - ENonCharacterKeyBase + 0x0081) >= MAX_SCANCODE)) { SDL_SetError("Too big scancode"); keysym->scancode = SDLK_UNKNOWN; keysym->mod = KMOD_NONE; return keysym; } keysym->mod = SDL_GetModState(); /* Handle function keys: F1, F2, F3 ... */ if (keysym->mod & KMOD_META) { if (scancode >= 'A' && scancode < ('A' + 24)) { /* first 32 alphabet keys */ switch(scancode) { case 'Q': scancode = EStdKeyF1; break; case 'W': scancode = EStdKeyF2; break; case 'E': scancode = EStdKeyF3; break; case 'R': scancode = EStdKeyF4; break; case 'T': scancode = EStdKeyF5; break; case 'Y': scancode = EStdKeyF6; break; case 'U': scancode = EStdKeyF7; break; case 'I': scancode = EStdKeyF8; break; case 'A': scancode = EStdKeyF9; break; case 'S': scancode = EStdKeyF10; break; case 'D': scancode = EStdKeyF11; break; case 'F': scancode = EStdKeyF12; break; } keysym->sym = keymap[scancode]; } } if (scancode >= ENonCharacterKeyBase) { // Non character keys keysym->sym = keymap[scancode - ENonCharacterKeyBase + 0x0081]; // !!hard coded } else { keysym->sym = keymap[scancode]; } /* Remap the arrow keys if the device is rotated *//* if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) { switch(keysym->sym) { case SDLK_UP: keysym->sym = SDLK_LEFT; break; case SDLK_DOWN: keysym->sym = SDLK_RIGHT; break; case SDLK_LEFT: keysym->sym = SDLK_DOWN; break; case SDLK_RIGHT:keysym->sym = SDLK_UP; break; } }*/ /* If UNICODE is on, get the UNICODE value for the key */ keysym->unicode = 0;#if 0 // !!TODO:unicode if ( SDL_TranslateUNICODE ) { /* Populate the unicode field with the ASCII value */ keysym->unicode = scancode; }#endif //!! //sprintf(debug, "SDL: TranslateKey: keysym->scancode=%d, keysym->sym=%d, keysym->mod=%d", // keysym->scancode, keysym->sym, keysym->mod); //SDL_TRACE(debug); //!! return(keysym);}} /* extern "C" */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -