static void processEvent(SDL_Event* e, InputContext* inputState, PlatformState* state) { ControllerInput* keyboardController = getContoller(inputState, 0); switch (e->type) { case SDL_QUIT: state->running = false; break; case SDL_WINDOWEVENT: processWindowEvent(&e->window); break; case SDL_KEYDOWN: case SDL_KEYUP: bool isDown = e->key.state == SDL_PRESSED; isDown &= e->key.state != SDL_RELEASED; if(e->key.repeat == 0) { switch(e->key.keysym.sym) { case SDLK_w: processKeyPress(&keyboardController->directionUp, isDown); break; case SDLK_s: processKeyPress(&keyboardController->directionDown, isDown); break; case SDLK_a: processKeyPress(&keyboardController->directionLeft, isDown); break; case SDLK_d: processKeyPress(&keyboardController->directionRight, isDown); break; case SDLK_l: //start/stop recording if(isDown && !state->isPlayingBack) { if(state->isRecording) { stopRecording(state); } else { beginRecording(state); } } break; case SDLK_p: //start/stop playback if(isDown && !state->isRecording) { if(state->isPlayingBack) { stopPlayback(state); *inputState = {}; } else { beginPlayback(state); } } break; } } break; } }
/** * Subclass procedure for any dialog control. Reports key press events to * ooDialog for those key presses connected to an ooDialog method by the user. * * All messages are passed on unchanged to the control. * * processKeyPress() is used to actually decipher the key press data and set * up the ooDialog method invocation. That function documents what is sent on * to the ooDialog method. */ LRESULT CALLBACK KeyPressSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR dwData) { SUBCLASSDATA *pSubclassData = (SUBCLASSDATA *)dwData; if ( ! pSubclassData ) { return DefSubclassProc(hwnd, msg, wParam, lParam); } KEYPRESSDATA *pKeyData = (KEYPRESSDATA *)pSubclassData->pData; switch ( msg ) { case WM_GETDLGCODE: /* Don't do anything for now. This message has some interesting * uses, perhaps a future enhancement. */ break; case WM_SYSKEYDOWN: /* Sent when the alt key is down. We need both WM_SYSKEYDOWN and * WM_KEYDOWN to catch everything that a keyboard hook catches. */ if ( pKeyData->key[wParam] && !(lParam & KEY_RELEASED) && !(lParam & KEY_WASDOWN) ) { processKeyPress(pSubclassData, wParam, lParam); } break; case WM_KEYDOWN: /* WM_KEYDOWN will never have KEY_RELEASED set. */ if ( pKeyData->key[wParam] && !(lParam & KEY_WASDOWN) ) { processKeyPress(pSubclassData, wParam, lParam); } break; case WM_NCDESTROY: /* The window is being destroyed, remove the subclass, clean up * memory. */ RemoveWindowSubclass(hwnd, KeyPressSubclassProc, id); freeKeyPressData(pSubclassData); break; } return DefSubclassProc(hwnd, msg, wParam, lParam); }
void WebkitPixelStreamer::processEvent(deflect::Event dcEvent) { QMutexLocker locker(&mutex_); switch(dcEvent.type) { case deflect::Event::EVT_CLICK: processClickEvent(dcEvent); break; case deflect::Event::EVT_PRESS: processPressEvent(dcEvent); break; case deflect::Event::EVT_MOVE: processMoveEvent(dcEvent); break; case deflect::Event::EVT_WHEEL: processWheelEvent(dcEvent); break; case deflect::Event::EVT_RELEASE: processReleaseEvent(dcEvent); break; case deflect::Event::EVT_SWIPE_LEFT: webView_.back(); break; case deflect::Event::EVT_SWIPE_RIGHT: webView_.forward(); break; case deflect::Event::EVT_KEY_PRESS: processKeyPress(dcEvent); break; case deflect::Event::EVT_KEY_RELEASE: processKeyRelease(dcEvent); break; case deflect::Event::EVT_VIEW_SIZE_CHANGED: processViewSizeChange(dcEvent); break; default: break; } }
MessageResult Editor::message(const T& msgAcc) { const Message & msg = msgAcc.message(); switch (msg.msgId) { case HASH::key_press: { messages::KeyPressR<T> msgR(msgAcc); processKeyPress(msgR.keys()); break; } case HASH::fin: { InputMgr::deregister_key_press_listener(HASH::editor__, mTask.id()); break; } default: PANIC("Unknown Editor message: %d", msg.msgId); } return MessageResult::Consumed; }
explicit Example( storm::Window::Pointer window ) : _window( std::move(window) ), _observer( std::make_shared<storm::WindowObserver>() ) { _window->setWindowedMode( outputWindowDimensions ); _window->addObserver( _observer ); _observer->onShutdownRequested = [] { outputString( "Shutdown requested" ); }; _observer->onFocusReceived = [] { outputString( "Focus received" ); }; _observer->onFocusLost = [] { outputString( "Focus lost" ); }; _observer->onResized = [this] { outputString( "The window size is changed. The new size is: " + std::to_string(_window->getDimensions().width) + ", " + std::to_string(_window->getDimensions().height) ); }; _observer->onMouseMotion = []( storm::IntVector2d value ) { outputString( "The mouse is moved. The delta is: " + std::to_string(value.x) + ", " + std::to_string(value.y) ); }; _observer->onMouseButtonPressed = []( storm::MouseButton value ) { outputString( "The mouse button is pressed. The value is: " + std::to_string(static_cast<int>(value)) ); }; _observer->onMouseButtonReleased = []( storm::MouseButton value ) { outputString( "The mouse button is released. The value is: " + std::to_string(static_cast<int>(value)) ); }; _observer->onMouseWheelRotated = []( float value ) { outputString( "The mouse wheel is rotated. The delta is: " + std::to_string(value) ); }; _observer->onPointerMotion = []( storm::IntVector2d value ) { outputString( "The mouse pointer is moved. The position is: " + std::to_string(value.x) + ", " + std::to_string(value.y) ); }; _observer->onKeyboardKeyPressed = [this]( storm::KeyboardKey value ) { outputString( "A keyboard key is pressed. The key is: " + std::string(getKeyboardKeyName(value)) ); processKeyPress( value ); }; _observer->onKeyboardKeyRepeated = []( storm::KeyboardKey value ) { outputString( "A keyboard key is repeated. The key is: " + std::string(getKeyboardKeyName(value)) ); }; _observer->onKeyboardKeyReleased = []( storm::KeyboardKey value ) { outputString( "A keyboard key is released. The key is: " + std::string(getKeyboardKeyName(value)) ); }; _observer->onCharacterInput = []( char32_t character ) { std::mbstate_t state = {}; std::string buffer( MB_CUR_MAX, 0 ); std::c32rtomb( buffer.data(), character, &state ); outputString( "Character input: " + buffer + " (" + std::to_string(character) + ")" ); }; }
void EuclideanMenuSlice::update(const sf::Time& elapsed, const std::vector<sf::Event::KeyEvent>& typed) { for (const auto& key : typed) { processKeyPress(key); } }