void InputComponent::onEvent(Event* e) { EventType type = e->getType(); if(type == EVENT_RUMBLE) { handleRumbleEvent(static_cast<Event_Rumble*>(e)); } if(type == EVENT_MOUSE_MOVE) { handleMouseMoveEvent(static_cast<Event_MouseMove*>(e)); } if(type == EVENT_KEY_PRESS) { Event_KeyPress* ekp = static_cast<Event_KeyPress*>(e); int keyEnum = ekp->keyEnum; bool isPressed = ekp->isPressed; bool shiftPressed = ekp->shiftPressed; bool tabPressed = ekp->tabPressed; handleKeyEvent(keyEnum, isPressed, shiftPressed, tabPressed); } if(type == EVENT_MOUSE_PRESS) { Event_MousePress* emp = static_cast<Event_MousePress*>(e); int keyEnum = emp->keyEnum; bool isPressed = emp->isPressed; handleMousePressedEvent(keyEnum, isPressed); } if(type == EVENT_INPUT_DEVICE_SEARCH) { inputManager_->UpdateNumberOfGamepads(windowHandle_); } if(type == EVENT_START_DEATHMATCH) { setupPlayerControllerConnection(); } if(type == EVENT_MOUSE_WHEEL) { Event_MouseWheel* emw = static_cast<Event_MouseWheel*>(e); QTInputDevices* device = inputManager_->GetMouseAndKeyboard(); if(device != nullptr) { if(emw->value >= 0) { //device->setScrollButton(true); handleKeyEvent('â', true); } else { //device->setScrollButton(false); handleKeyEvent('ô', true); } } } }
void eventMaster::handleEvents() { while (!event_queue.empty()) { event * evt = event_queue.front(); if (evt->type == COLLISION) { handleCollisionEvent(*((collisionEvent *) evt)); } else if (evt->type == TURN) { handleTurnEvent(*((turnEvent *) evt)); } else if (evt->type == KEY) { handleKeyEvent(*((keyEvent *) evt)); } else if (evt->type == MOUSE) { handleMouseEvent(*((mouseEvent*) evt)); } else if (evt->type == CUSTOM) { handleCustomEvent(*((customEvent*) evt)); } event_queue.pop(); if (Parent != NULL) { Parent->take_event(evt); } else { delete evt; } } }
void Application::handleEvent() { switch (m_event.type) { case sf::Event::Closed: m_window->close(); break; case sf::Event::KeyPressed: handleKeyEvent(); break; case sf::Event::MouseButtonPressed: m_clicked = true; handleMouseEvent(); break; case sf::Event::MouseButtonReleased: m_clicked = false; break; case sf::Event::MouseMoved: if (m_clicked && m_state == SET_COLLIDER) { handleMouseEvent(); } break; default: return; } }
static gboolean repeatRateTimeout(void* data) { auto& seatData = *static_cast<WaylandDisplay::SeatData*>(data); handleKeyEvent(seatData, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); return G_SOURCE_CONTINUE; }
void handleGraphicEvent(SDL_Event event, GraphicModule * module){ //Giant Case to handle all events switch (event.type){ case SDL_QUIT: //Halt the execution of the graphics module->stopFlag = 1; break; case SDL_KEYDOWN: handleKeyEvent(event,module); break; case SDL_MOUSEBUTTONDOWN: mouseDown = 1; handleMouseEvent(event,module); break; case SDL_MOUSEBUTTONUP: mouseDown = 0; handleMouseEvent(event,module); break; case SDL_MOUSEMOTION: handleMouseEvent(event,module); break; default: break; } }
void InputService::onEvent(const Event &event) { if (event.type == EVENT_RAW_INPUT_CLICK) handleMouseEvent(event); else handleKeyEvent(event); }
static gboolean repeatDelayTimeout(void* data) { auto& seatData = *static_cast<WaylandDisplay::SeatData*>(data); handleKeyEvent(seatData, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); seatData.repeatData.eventSource = g_timeout_add(seatData.repeatInfo.rate, static_cast<GSourceFunc>(repeatRateTimeout), data); return G_SOURCE_REMOVE; }
void EmulatorWindow::keyReleaseEvent(QKeyEvent *event) { handleKeyEvent(kEventKeyUp, event); if (event->text().length() > 0) { SkinEvent *skin_event = createSkinEvent(kEventTextInput); skin_event->u.text.down = false; strncpy((char*)skin_event->u.text.text, (const char*)event->text().constData(), 32); queueEvent(skin_event); } }
void Runtime::processEvent(MAEvent &event) { switch (event.type) { case EVENT_TYPE_KEY_PRESSED: handleKeyEvent(event); break; default: handleEvent(event); break; } }
void QGraphicsViewAdapter::customEvent( QEvent* event ) { if ( event->type()==MYQKEYEVENT ) { MyQKeyEvent* keyEvent = ( MyQKeyEvent* )event; handleKeyEvent( keyEvent->_key, keyEvent->_down ); } else if ( event->type()==MYQPOINTEREVENT ) { MyQPointerEvent* pointerEvent = ( MyQPointerEvent* )event; handlePointerEvent( pointerEvent->_x, pointerEvent->_y, pointerEvent->_buttonMask ); } }
// Listens to events during the whole time of the application // and distributes corresponding tasks void Application::handleEvent(const SDL_Event& event) { switch (event.type) { // User events case SDL_USEREVENT: handleUserEvent(event); break; // Key presses case SDL_KEYDOWN: handleKeyEvent(event.key.keysym, true); break; // Key releases case SDL_KEYUP: handleKeyEvent(event.key.keysym, false); break; // Quit event (for example sent when the window is closed) case SDL_QUIT: m_bRunning = false; break; default: break; } }
static void handleInput(MirEvent const* event, _GLFWwindow* window) { switch (event->type) { case mir_event_type_key: handleKeyEvent(event->key, window); break; case mir_event_type_motion: handleMotionEvent(event->motion, window); break; default: break; } }
void eventMaster::handle_event(event * evt) { if (evt->type == COLLISION) { handleCollisionEvent(*((collisionEvent *) evt)); } else if (evt->type == TURN) { handleTurnEvent(*((turnEvent *) evt)); } else if (evt->type == KEY) { handleKeyEvent(*((keyEvent *) evt)); } else if (evt->type == MOUSE) { handleMouseEvent(*((mouseEvent*) evt)); } else if (evt->type == CUSTOM) { handleCustomEvent(*((customEvent*) evt)); } }
static void handleInput(const MirInputEvent* input_event, _GLFWwindow* window) { int type = mir_input_event_get_type(input_event); switch (type) { case mir_input_event_type_key: handleKeyEvent(mir_input_event_get_keyboard_event(input_event), window); break; case mir_input_event_type_pointer: handlePointerEvent(mir_input_event_get_pointer_event(input_event), window); break; default: break; } }
static pascal OSStatus eventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) { ::UInt32 eventClass = GetEventClass(event); switch (eventClass) { // Mouse events case kEventClassMouse: return handleMouseEvent(nextHandler, event, userData); // Key press events case kEventClassTextInput: return handleKeyEvent(nextHandler, event, userData); default: return eventNotHandledErr; } }
bool Config::handleEvent(const eq::ConfigEvent* event) { switch (event->data.type) { case eq::Event::KEY_PRESS: if (handleKeyEvent(event->data.keyPress)) return true; break; case eq::Event::POINTER_MOTION: if (event->data.pointerMotion.buttons == eq::PTR_BUTTON1) { _cameraFrame.rotateHorizontally(-0.005f * event->data.pointerMotion.dx); _cameraFrame.rotateVertically(-0.005f * event->data.pointerMotion.dy); return true; } break; } return eq::Config::handleEvent(event); }
EM_BOOL Context::keyCb(int eventType, const EmscriptenKeyboardEvent *event, void *userData) { BX_UNUSED(userData); if (event) { uint8_t modifiers = 0; uint8_t pressedChar[4]; Key::Enum key = handleKeyEvent(event, &modifiers, &pressedChar[0]); // Returning true means that we take care of the key (instead of the default behavior) if (key != Key::None) { switch (eventType) { case EMSCRIPTEN_EVENT_KEYPRESS: case EMSCRIPTEN_EVENT_KEYDOWN: { if (key == Key::KeyQ && (modifiers & Modifier::RightMeta) ) { s_ctx.m_eventQueue.postExitEvent(); } else { enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift }; s_ctx.m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar); s_ctx.m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true); return true; } break; } case EMSCRIPTEN_EVENT_KEYUP: { s_ctx.m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, false); return true; } } } } return false; }
////////////////////////////////////////////////////////////////////////// // handleEvent void OsClientHTML5::handleEvent( const SDL_Event& SDLEvent ) { switch( SDLEvent.type ) { case SDL_KEYDOWN: case SDL_KEYUP: handleKeyEvent( SDLEvent ); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_MOUSEMOTION: handleMouseEvent( SDLEvent ); break; case SDL_WINDOWEVENT: handleWindowEvent( SDLEvent ); break; } }
bool WebPagePopupImpl::handleCharEvent(const WebKeyboardEvent& event) { return handleKeyEvent(PlatformKeyboardEventBuilder(event)); }
void EmulatorWindow::keyPressEvent(QKeyEvent *event) { handleKeyEvent(kEventKeyDown, event); }
bool QWidgetWindow::event(QEvent *event) { if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) { // \a event is uninteresting for QWidgetWindow, the event was probably // generated before WA_DontShowOnScreen was set return m_widget->event(event); } switch (event->type()) { case QEvent::Close: handleCloseEvent(static_cast<QCloseEvent *>(event)); return true; case QEvent::Enter: case QEvent::Leave: handleEnterLeaveEvent(event); return true; // these should not be sent to QWidget, the corresponding events // are sent by QApplicationPrivate::notifyActiveWindowChange() case QEvent::FocusIn: handleFocusInEvent(static_cast<QFocusEvent *>(event)); // Fallthrough case QEvent::FocusOut: { #ifndef QT_NO_ACCESSIBILITY QAccessible::State state; state.active = true; QAccessibleStateChangeEvent ev(widget(), state); QAccessible::updateAccessibility(&ev); #endif return false; } case QEvent::FocusAboutToChange: if (QApplicationPrivate::focus_widget) { if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) qApp->inputMethod()->commit(); QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event); } return true; case QEvent::KeyPress: case QEvent::KeyRelease: case QEvent::ShortcutOverride: handleKeyEvent(static_cast<QKeyEvent *>(event)); return true; case QEvent::MouseMove: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: handleMouseEvent(static_cast<QMouseEvent *>(event)); return true; case QEvent::NonClientAreaMouseMove: case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonRelease: case QEvent::NonClientAreaMouseButtonDblClick: handleNonClientAreaMouseEvent(static_cast<QMouseEvent *>(event)); return true; case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: case QEvent::TouchCancel: handleTouchEvent(static_cast<QTouchEvent *>(event)); return true; case QEvent::Move: handleMoveEvent(static_cast<QMoveEvent *>(event)); return true; case QEvent::Resize: handleResizeEvent(static_cast<QResizeEvent *>(event)); return true; #ifndef QT_NO_WHEELEVENT case QEvent::Wheel: handleWheelEvent(static_cast<QWheelEvent *>(event)); return true; #endif #ifndef QT_NO_DRAGANDDROP case QEvent::DragEnter: case QEvent::DragMove: handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); return true; case QEvent::DragLeave: handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event)); return true; case QEvent::Drop: handleDropEvent(static_cast<QDropEvent *>(event)); return true; #endif case QEvent::Expose: handleExposeEvent(static_cast<QExposeEvent *>(event)); return true; case QEvent::WindowStateChange: handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event)); return true; case QEvent::ThemeChange: { QEvent widgetEvent(QEvent::ThemeChange); QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); } return true; #ifndef QT_NO_TABLETEVENT case QEvent::TabletPress: case QEvent::TabletMove: case QEvent::TabletRelease: handleTabletEvent(static_cast<QTabletEvent *>(event)); return true; #endif #ifndef QT_NO_GESTURES case QEvent::NativeGesture: handleGestureEvent(static_cast<QNativeGestureEvent *>(event)); return true; #endif #ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: handleContextMenuEvent(static_cast<QContextMenuEvent *>(event)); return true; #endif // Handing show events to widgets (see below) here would cause them to be triggered twice case QEvent::Show: case QEvent::Hide: return QWindow::event(event); case QEvent::WindowBlocked: qt_button_down = 0; break; default: break; } return m_widget->event(event) || QWindow::event(event); }
bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent) { if (!m_widget) return false; // FIXME: WebKit seems to always return false on mouse events methods. For // now we'll assume it has processed them (as we are only interested in // whether keyboard events are processed). switch (inputEvent.type) { case WebInputEvent::MouseMove: handleMouseMove(static_cast<const WebMouseEvent&>(inputEvent)); return true; case WebInputEvent::MouseLeave: handleMouseLeave(static_cast<const WebMouseEvent&>(inputEvent)); return true; case WebInputEvent::MouseWheel: handleMouseWheel(static_cast<const WebMouseWheelEvent&>(inputEvent)); return true; case WebInputEvent::MouseDown: handleMouseDown(static_cast<const WebMouseEvent&>(inputEvent)); return true; case WebInputEvent::MouseUp: handleMouseUp(static_cast<const WebMouseEvent&>(inputEvent)); return true; // In Windows, RawKeyDown only has information about the physical key, but // for "selection", we need the information about the character the key // translated into. For English, the physical key value and the character // value are the same, hence, "selection" works for English. But for other // languages, such as Hebrew, the character value is different from the // physical key value. Thus, without accepting Char event type which // contains the key's character value, the "selection" won't work for // non-English languages, such as Hebrew. case WebInputEvent::RawKeyDown: case WebInputEvent::KeyDown: case WebInputEvent::KeyUp: case WebInputEvent::Char: return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent)); case WebInputEvent::TouchStart: case WebInputEvent::TouchMove: case WebInputEvent::TouchEnd: case WebInputEvent::TouchCancel: return handleTouchEvent(static_cast<const WebTouchEvent&>(inputEvent)); case WebInputEvent::GestureScrollBegin: case WebInputEvent::GestureScrollEnd: case WebInputEvent::GestureScrollUpdate: case WebInputEvent::GestureFlingStart: case WebInputEvent::GestureFlingCancel: case WebInputEvent::GestureTap: case WebInputEvent::GestureTapUnconfirmed: case WebInputEvent::GestureTapDown: case WebInputEvent::GestureShowPress: case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: case WebInputEvent::GestureLongTap: case WebInputEvent::GesturePinchBegin: case WebInputEvent::GesturePinchEnd: case WebInputEvent::GesturePinchUpdate: return handleGestureEvent(static_cast<const WebGestureEvent&>(inputEvent)); case WebInputEvent::Undefined: case WebInputEvent::MouseEnter: case WebInputEvent::ContextMenu: return false; } return false; }
void QtKeySequenceEdit::keyPressEvent(QKeyEvent *e) { handleKeyEvent(e); e->accept(); }
void KeySequenceDialog::keyPressEvent(QKeyEvent *e) { handleKeyEvent(e); e->accept(); }
int main( int argc, char* args[] ) { positionVector.push_back(Position(0, 0, "bateau/0001" )); positionVector.push_back(Position(0, 0, "bateau/picking_a")); // positionVector.push_back(Position(0, 0, "bateau/0001", boost::assign::list_of(44)(45)(46)(47) )); // positionVector.push_back(Position(0, 0, "bateau/0002", boost::assign::list_of(42)(43)(48)(49) )); // positionVector.push_back(Position(0, 0, "bateau/0003", boost::assign::list_of(40)(41)(50)(51) )); // positionVector.push_back(Position(0, 0, "bateau/0004", boost::assign::list_of(38)(39)(52)(53) )); // positionVector.push_back(Position(0, 0, "bateau/0005", boost::assign::list_of(36)(37)(54)(55) )); // positionVector.push_back(Position(0, 0, "bateau/0006", boost::assign::list_of(34)(35)(56)(57) )); // positionVector.push_back(Position(0, 0, "bateau/0007", boost::assign::list_of(32)(33)(58)(59) )); // positionVector.push_back(Position(0, 0, "bateau/0008", boost::assign::list_of(0)(1)(30)(31) )); // positionVector.push_back(Position(0, 0, "bateau/0009", boost::assign::list_of(2)(3)(28)(29) )); // positionVector.push_back(Position(0, 0, "bateau/0010", boost::assign::list_of(4)(5)(26)(27) )); // positionVector.push_back(Position(0, 0, "bateau/0011", boost::assign::list_of(6)(7)(24)(25) )); // positionVector.push_back(Position(0, 0, "bateau/0012", boost::assign::list_of(8)(9)(22)(23) )); // positionVector.push_back(Position(0, 0, "bateau/0013", boost::assign::list_of(10)(11)(20)(21) )); // positionVector.push_back(Position(0, 0, "bateau/0014", boost::assign::list_of(12)(13)(18)(19) )); // positionVector.push_back(Position(0, 0, "bateau/0015", boost::assign::list_of(14)(15)(16)(17) )); positionVector.push_back(Position(0, 0, "bateau/petitpoteau")); positionVector.push_back(Position(0, 0, "bateau/nuage/nuage")); scalefactor = 325; // /* // * Initialise libSDL // */ // if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) == -1) { // printf("cannot initialize SDL\n"); // return EXIT_FAILURE; // } // empty = SDL_CreateRGBSurface(SDL_SWSURFACE, WIDTH, HEIGHT, // 32, 0, 0, 0, 0); mutex = SDL_CreateMutex(); Uint32 flags = SDL_WINDOW_HIDDEN; if(SDL_CreateWindowAndRenderer(WIDTH, HEIGHT, flags, &screen, &sdlRenderer)) { printf("cannot set video mode\n"); return EXIT_FAILURE; } SDL_SetWindowTitle(screen, "Titre fenêtre"); SDL_SetWindowSize(screen, WIDTH, HEIGHT); SDL_ShowWindow(screen); // Création du thread pour charger les images if ( (threadChargementImage = SDL_CreateThread(fonctionChargementImage, NULL, NULL)) == NULL ) { printf("Impossible de créer le thread --> Chargement image\n"); return EXIT_FAILURE; } //Quit flag quit = false; //The frame rate regulator Timer fps; while( quit == false ) { //Start the frame timer fps.start(); quit = handleKeyEvent(); if(quit == true) { printf("FIN ...\n"); } if(imageChargee == true && quit == false) { scalefactor += delta; permanentShiftX += shiftX; permanentShiftY += shiftY; yConst += shiftConstY; if(mouseClicked == true) { xPosClicked = xPos; yPosClicked = yPos; mouseClicked = false; } applySurfaces(); flipSurfaces(); freeSurfaces(); SDL_Delay(100); if ( SDL_mutexP(mutex) < 0 ) { fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); exit(1); } imageChargee = false; if ( SDL_mutexV(mutex) < 0 ) { fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); exit(1); } //currentFrame = (currentFrame + 1) % 30; currentFrame = (currentFrame + 1) % 60; currentFrame240 = (currentFrame240 + 1) % 240; currentFrame480 = (currentFrame480 + 1) % 480; currentFrame960 = (currentFrame960 + 1) % 960; if( fps.get_ticks() < (1000 / FRAMES_PER_SECOND) ) { //Sleep the remaining frame time SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() ); } } } return 0; }
template<class KeyEvent> bool Context::handleKeyPressEvent(KeyEvent& event) { return handleKeyEvent(event, true); }
template<class KeyEvent> bool Context::handleKeyReleaseEvent(KeyEvent& event) { return handleKeyEvent(event, false); }
void menu( void ) { static bool firstrun = true; SDL_Rect SrcR, DstR; SDL_Event event; SDL_Surface *modeSelector, *speedSelector, *sizeSelector; if ( firstrun ) { initMenu(); firstrun = false; } // clear screen SDL_FillRect( screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); // draw bg SrcR.x = 0; SrcR.y = 0; SrcR.w = 800; SrcR.h = 480; DstR.x = 0; DstR.y = 0; DstR.w = 800; DstR.h = 480; SDL_BlitSurface( menuBG, &SrcR, screen, &DstR ); switch ( difficulty ) { case EASY_DIFFICULTY: modeSelector = easyMode; break; case STANDARD_DIFFICULTY: modeSelector = standardMode; break; case HARD_DIFFICULTY: modeSelector = hardMode; break; default: break; } switch ( speed ) { case FAST_SPEED: speedSelector = fast; break; case SLOW_SPEED: speedSelector = slow; break; case AVERAGE_SPEED: speedSelector = average; break; case INSANE_SPEED: speedSelector = insane; break; default: break; } switch ( size ) { case SMALL_SIZE: sizeSelector = small; break; case MEDIUM_SIZE: sizeSelector = medium; break; case BIG_SIZE: sizeSelector = big; break; default: break; } // draw menu if ( selection == START_GAME_SELECT ) DstR.x = 3*sin(SDL_GetTicks()); else DstR.x = 0; DstR.y = 250; SDL_BlitSurface( startButton, &SrcR, screen, &DstR ); if ( selection == DIFFICULTY_SELECT ) DstR.x = 3*sin(SDL_GetTicks()); else DstR.x = 0; DstR.y = 300; SDL_BlitSurface( modeSelector, &SrcR, screen, &DstR ); if ( selection == SPEED_SELECT ) DstR.x = 3*sin(SDL_GetTicks()); else DstR.x = 0; DstR.y = 350; SDL_BlitSurface( speedSelector, &SrcR, screen, &DstR ); if ( selection == SIZE_SELECT ) DstR.x = 3*sin(SDL_GetTicks()); else DstR.x = 0; DstR.y = 400; SDL_BlitSurface( sizeSelector, &SrcR, screen, &DstR ); while(SDL_PollEvent(&event)) { /* Loop until there are no events left on the queue */ switch(event.type) { /* Process the appropriate event type */ case SDL_KEYDOWN: /* Handle a KEYDOWN event */ handleKeyEvent( &event ); break; //case SDL_MOUSEMOTION: // maybe i will use the mouse in future ... atm it seems not like a good idea thogh default: break; // nothing to do } } }
void GLWidget::keyReleaseEvent(QKeyEvent *event) { if (!handleKeyEvent(event->key(), false)) { QGLWidget::keyReleaseEvent(event); } }
void GLWidget::keyPressEvent(QKeyEvent *event) { if (!handleKeyEvent(event->key(), true)) { QGLWidget::keyPressEvent(event); } }