BOOL CBaseScreen::OnWndProc(void* /*pi*/, AEEEvent eCode , uint16 wParam , uint32 dwParam) // 窗口主消息处理函数 { BOOL bRet = FALSE; switch (eCode) { case EVT_KEY_PRESS: { bRet = OnKeyPressed(wParam); } break; case EVT_KEY_RELEASE: { bRet = OnKeyReleased(wParam); } break; case EVT_KEY_HELD: { //注意这条消息没有处理 } break; case EVT_APP_SUSPEND: { bRet = OnSuspend(); } break; case EVT_APP_RESUME: { bRet = OnResume(); } break; case EVT_EXT_PEN_PRESS: { bRet = OnPointerPressed((int)wParam, (int)dwParam); } break; case EVT_EXT_PEN: { bRet = OnPointerDragged((int)wParam, (int)dwParam); } break; case EVT_EXT_PEN_RELEASE: { bRet = OnPointerReleased((int)wParam, (int)dwParam); } break; default: break; } return bRet; }
virtual void CallEvent(FKeyboardEvent& e) { switch (e.type()) { case fevents::kKeyPress: OnKeyPressed(e); break; case fevents::kKeyRelease: OnKeyReleased(e); break; default: break; } }
void InputEventController::ProcessInputEvent(const SDL_Event &evt) { switch (evt.type) { case SDL_KEYDOWN: OnKeyPressed(evt.key); break; case SDL_KEYUP: OnKeyReleased(evt.key); break; case SDL_TEXTINPUT: OnTextInput(evt.text); break; case SDL_MOUSEMOTION: OnMouseMoved(evt.motion); break; case SDL_MOUSEBUTTONDOWN: OnMousePressed(evt.button); break; case SDL_MOUSEBUTTONUP: OnMouseReleased(evt.button); break; case SDL_MOUSEWHEEL: OnMouseWheel(evt.wheel); break; default: HR_LOG(info) << "Unhandled input event type: " << evt.type; } }
void Input::OnAlt2CursorReleased() { OnKeyReleased(-2); }
void Input::OnAltCursorReleased() { OnKeyReleased(-1); }
void State::OnEvent(const sf::Event::Event &e) { switch (e.Type) { case sf::Event::KeyPressed: OnKeyPressed(e.Key.Code, e.Key.Alt, e.Key.Control, e.Key.Shift); break; case sf::Event::KeyReleased: OnKeyReleased(e.Key.Code, e.Key.Alt, e.Key.Control, e.Key.Shift); break; case sf::Event::MouseMoved: OnMouseMoved(e.MouseMove.X, e.MouseMove.Y); break; case sf::Event::MouseButtonPressed: { int x = e.MouseButton.X; int y = e.MouseButton.Y; switch (e.MouseButton.Button) { case sf::Mouse::Left: OnMouseLeftDown(x, y); buttons_[0] = true; break; case sf::Mouse::Right: OnMouseRightDown(x, y); buttons_[1] = true; break; case sf::Mouse::Middle: OnMouseMiddleDown(x, y); buttons_[2] = true; break; } break; } case sf::Event::MouseButtonReleased: { int x = e.MouseButton.X; int y = e.MouseButton.Y; switch (e.MouseButton.Button) { case sf::Mouse::Left: OnMouseLeftUp(x, y); if (buttons_[0]) { buttons_[0] = false; OnMouseLeftClick(x, y); } break; case sf::Mouse::Right: OnMouseRightUp(x, y); if (buttons_[1]) { buttons_[1] = false; OnMouseRightClick(x, y); } break; case sf::Mouse::Middle: OnMouseMiddleUp(x, y); if (buttons_[2]) { buttons_[2] = false; OnMouseMiddleClick(x, y); } break; } break; } case sf::Event::MouseEntered: OnMouseEntered(); break; case sf::Event::MouseLeft: OnMouseExited(); break; case sf::Event::GainedFocus: OnGainedFocus(); break; case sf::Event::LostFocus: OnLostFocus(); break; } }
void Application::Run() { // // keyboard // if (keyboard_needs_poll()) poll_keyboard(); for (int k = 0; k < 256; k++) { if (key[k]) { OnKeyPress(k); if (!prevKeyState[k]) OnKeyPressed(k); } else if (!key[k]) { if (prevKeyState[k]) OnKeyReleased(k); } } memcpy(prevKeyState,(char*)key,256); // // mouse // if (mouse_needs_poll()) poll_mouse(); for (int button = 0; button < (numMouseButtons); button++) { if ((mouse_b & (1 << button)) != 0) { mouseButtons[button] = true; } else { mouseButtons[button] = false; } if (mouseButtons[button] && (!prevMouseButtons[button])) { OnMousePressed(button, mouse_x, mouse_y); mousePressedLocs[button].x = mouse_x; mousePressedLocs[button].y = mouse_y; } else if ((!mouseButtons[button]) && prevMouseButtons[button]) { OnMouseReleased(button, mouse_x, mouse_y); if ((mousePressedLocs[button].x == mouse_x) && (mousePressedLocs[button].y == mouse_y)) { OnMouseClick(button,mouse_x,mouse_y); } } } memcpy(prevMouseButtons,mouseButtons,sizeof(bool)*(numMouseButtons+1)); if ((mouse_x != prevMouseX) || (mouse_y != prevMouseY)) { OnMouseMove(mouse_x,mouse_y); prevMouseX = mouse_x; prevMouseY = mouse_y; } // mouse wheel if (mouse_z > prevMouseZ) { OnMouseWheelUp( mouse_x, mouse_y ); prevMouseZ = mouse_z; } else if (mouse_z < prevMouseZ) { OnMouseWheelDown( mouse_x, mouse_y ); prevMouseZ = mouse_z; } // // run the game // show_mouse(NULL); RunGame(); show_mouse(canvas); // // render canvas to the screen // blit(canvas,screen,0,0,0,0,screen->w,screen->h); // // sound polling (to ensure sounds currently playing will keep playing) // SoundOGG::PollSounds(); // // handle timing // HandleTiming(); }
void EventHandler::OnEvent (sf::Event* event) { switch (event->type) { case sf::Event::Closed: //Window closed: OnClosed(); break; case sf::Event::Resized: //Window resized: OnWindowResized (event->size); case sf::Event::GainedFocus: //Window gained focus: OnGainedFocus(); break; case sf::Event::LostFocus: //Window lost focus: OnLostFocus(); break; break; case sf::Event::TextEntered: //Text entered: OnTextEntered (event->text); break; case sf::Event::KeyPressed: //Key pressed: OnKeyPressed (event->key); break; case sf::Event::KeyReleased: //Key released: OnKeyReleased (event->key); break; case sf::Event::MouseWheelMoved: //Mouse wheel moved: OnMouseWheelMoved (event->mouseWheel); break; case sf::Event::MouseButtonPressed: //Mouse button pressed: OnMouseButtonPressed (event->mouseButton); break; case sf::Event::MouseButtonReleased: //Mouse button released: OnMouseButtonReleased(event->mouseButton); break; case sf::Event::MouseMoved: //Mouse moved: OnMouseMoved (event->mouseMove); break; case sf::Event::MouseEntered: //Mouse entered Window bounds: OnMouseEntered(); break; case sf::Event::MouseLeft: //Mouse left Window bounds: OnMouseLeft(); break; case sf::Event::JoystickButtonPressed: //Joystick button pressed: OnJoystickButtonPressed (event->joystickButton); break; case sf::Event::JoystickButtonReleased: //Joystick button released: OnJoystickButtonReleased(event->joystickButton); break; case sf::Event::JoystickMoved: //Joystick moved: OnJoystickMoved(event->joystickMove); break; case sf::Event::JoystickConnected: //Joystick connected: OnJoystickConnected (event->joystickConnect); break; case sf::Event::JoystickDisconnected: //Joystick disconnected: OnJoystickDisconnected (event->joystickConnect); break; } }