/*! * The mainloop. * Fetches events, executes appropriate code */ static void mainLoop(void) { SDL_Event event; while (true) { frameUpdate(); // General housekeeping /* Deal with any windows messages */ while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYUP: case SDL_KEYDOWN: inputHandleKeyEvent(&event.key); break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: inputHandleMouseButtonEvent(&event.button); break; case SDL_MOUSEMOTION: inputHandleMouseMotionEvent(&event.motion); break; case SDL_ACTIVEEVENT: handleActiveEvent(&event.active); break; case SDL_QUIT: saveConfig(); return; default: break; } } // Screenshot key is now available globally if(keyPressed(KEY_F10)) { kf_ScreenDump(); inputLooseFocus(); // remove it from input stream } // only pause when not in multiplayer, no focus, and we actually want to pause if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) { if (loop_GetVideoStatus()) { videoLoop(); // Display the video if neccessary } else switch (GetGameMode()) { case GS_NORMAL: // Run the gameloop code runGameLoop(); break; case GS_TITLE_SCREEN: // Run the titleloop code runTitleLoop(); break; default: break; } realTimeUpdate(); // Update realTime. } } }
bool keyPressed(const char key) { std::string temp; temp.append(1, key); return keyPressed(temp); }
void eLircInputDriver::pumpEvent(const lircEvent &event) { keyPressed(event); }
void ofApp::onCharacterReceived(KeyListenerEventData& e) { keyPressed((int)e.character); }
/** * When you get pressed key, send it to video output */ void FullscreenControllerWidget::keyPressEvent( QKeyEvent *event ) { emit keyPressed( event ); }
int main() { GraphicsEngine ge("Indexed Star", 700, 700); long framecount = 0; long totalframecount = 0; // Display OpenGL version. Not needed in general, just a check. std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << std::endl; sf::Clock clock; sf::Clock totalclock; sf::Time time = clock.restart(); time = totalclock.restart(); // Start the Game/GUI loop while (ge.isOpen()) { // Process user events sf::Event event; while (ge.pollEvent(event)) { // Close Window or Escape Key Pressed: exit if (event.type == sf::Event::Closed || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)) ge.close(); // Key is pressed. if (event.type == sf::Event::KeyPressed) keyPressed(event.key.code, ge); // Window is resized. if (event.type == sf::Event::Resized) ge.resize(); } // Call the display function to do the OpenGL rendering. ge.display(); // Increment frame counts framecount++; totalframecount++; // Get Elapsed Time float timesec = clock.getElapsedTime().asSeconds(); float totaltimesec = totalclock.getElapsedTime().asSeconds(); char titlebar[128]; // If another second has elapsed, display the FPS and total FPS. if (timesec > 1.0) { float fps = framecount / timesec; float totalfps = totalframecount / totaltimesec; sprintf(titlebar, "Box & Circle FPS: %f Total FPS: %f", fps, totalfps); ge.setTitle(titlebar); time = clock.restart(); framecount = 0; } } return EXIT_SUCCESS; }
void OpenGLWindow::internalKeyPressed( unsigned char key, int x, int y ) { keyPressed(key, x, y); keyState[key] = 1; }
void VulkanExampleBase::handleEvent(const xcb_generic_event_t *event) { switch (event->response_type & 0x7f) { case XCB_CLIENT_MESSAGE: if ((*(xcb_client_message_event_t*)event).data.data32[0] == (*atom_wm_delete_window).atom) { quit = true; } break; case XCB_MOTION_NOTIFY: { xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *)event; if (mouseButtons.left) { rotation.x += (mousePos.y - (float)motion->event_y) * 1.25f; rotation.y -= (mousePos.x - (float)motion->event_x) * 1.25f; viewChanged(); } if (mouseButtons.right) { zoom += (mousePos.y - (float)motion->event_y) * .005f; viewChanged(); } if (mouseButtons.middle) { cameraPos.x -= (mousePos.x - (float)motion->event_x) * 0.01f; cameraPos.y -= (mousePos.y - (float)motion->event_y) * 0.01f; viewChanged(); mousePos.x = (float)motion->event_x; mousePos.y = (float)motion->event_y; } mousePos = glm::vec2((float)motion->event_x, (float)motion->event_y); } break; case XCB_BUTTON_PRESS: { xcb_button_press_event_t *press = (xcb_button_press_event_t *)event; if (press->detail == XCB_BUTTON_INDEX_1) mouseButtons.left = true; if (press->detail == XCB_BUTTON_INDEX_2) mouseButtons.middle = true; if (press->detail == XCB_BUTTON_INDEX_3) mouseButtons.right = true; } break; case XCB_BUTTON_RELEASE: { xcb_button_press_event_t *press = (xcb_button_press_event_t *)event; if (press->detail == XCB_BUTTON_INDEX_1) mouseButtons.left = false; if (press->detail == XCB_BUTTON_INDEX_2) mouseButtons.middle = false; if (press->detail == XCB_BUTTON_INDEX_3) mouseButtons.right = false; } break; case XCB_KEY_RELEASE: { const xcb_key_release_event_t *keyEvent = (const xcb_key_release_event_t *)event; if (keyEvent->detail == 0x9) quit = true; keyPressed(keyEvent->detail); } break; case XCB_DESTROY_NOTIFY: quit = true; break; default: break; } }
void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: prepared = false; DestroyWindow(hWnd); PostQuitMessage(0); break; case WM_PAINT: ValidateRect(window, NULL); break; case WM_KEYDOWN: switch (wParam) { case 0x50: paused = !paused; break; case VK_ESCAPE: exit(0); break; } keyPressed((uint32_t)wParam); break; case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: mousePos.x = (float)LOWORD(lParam); mousePos.y = (float)HIWORD(lParam); break; case WM_MOUSEWHEEL: { short wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam); zoom += (float)wheelDelta * 0.005f * zoomSpeed; viewChanged(); break; } case WM_MOUSEMOVE: if (wParam & MK_RBUTTON) { int32_t posx = LOWORD(lParam); int32_t posy = HIWORD(lParam); zoom += (mousePos.y - (float)posy) * .005f * zoomSpeed; mousePos = glm::vec2((float)posx, (float)posy); viewChanged(); } if (wParam & MK_LBUTTON) { int32_t posx = LOWORD(lParam); int32_t posy = HIWORD(lParam); rotation.x += (mousePos.y - (float)posy) * 1.25f * rotationSpeed; rotation.y -= (mousePos.x - (float)posx) * 1.25f * rotationSpeed; mousePos = glm::vec2((float)posx, (float)posy); viewChanged(); } if (wParam & MK_MBUTTON) { int32_t posx = LOWORD(lParam); int32_t posy = HIWORD(lParam); cameraPos.x -= (mousePos.x - (float)posx) * 0.01f; cameraPos.y -= (mousePos.y - (float)posy) * 0.01f; viewChanged(); mousePos.x = (float)posx; mousePos.y = (float)posy; } break; case WM_SIZE: if ((prepared) && (wParam != SIZE_MINIMIZED)) { destWidth = LOWORD(lParam); destHeight = HIWORD(lParam); if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED)) { windowResize(); } } break; case WM_EXITSIZEMOVE: if ((prepared) && ((destWidth != width) || (destHeight != height))) { windowResize(); } break; } }
// Returns true if escape key pressed. // bool CancelPressed(void) { return keyPressed(KEY_ESC); }
void GdvCanvas2D::keyPressEvent(QKeyEvent* e) { qDebug() << "Key pressed:" << e->text(); emit keyPressed(e->text()); }
void _int_33() //IRQ 1 (Keyboard controller) { keyPressed(); }
//////////////// emit keyboard signals void IrrWidget::keyPressEvent(QKeyEvent *event) { if(!event->isAutoRepeat()) emit keyPressed(event->key()); }
int main(int argc, char* argv[]) { sSdlWrapper* wrap = initializeSDLWrapper("Snake", 800, 600, 32, 1, 1); game* gameEngine = initGame(wrap, 32, 24); int Selection = 0; sTextGFX* startUnsel = createText(wrap, "Start Game", 0xFFFFFFFF); sTextGFX* startSel = createText(wrap, "Start Game", 0xFFFFF000); sTextGFX* exitUnsel = createText(wrap, "Exit Game" , 0xFFFFFFFF); sTextGFX* exitSel = createText(wrap, "Exit Game" , 0xFFFFF000); sLinkedList* titleList = 0; FILE* titleFile = fopen("snake.pic", "r"); listInitialize(&titleList, sizeofPoint(), NULL); for(int x = 0; x < 32; x++) for(int y = 0; y < 24; y++) if(x == 0 || x == (31) || y == 0 || y == (23)) { point* toAdd = createPoint(x,y); listPushFront(titleList, (void*)toAdd); free(toAdd); } while(isRunning(wrap)) { beginFrame(wrap); if(State == -1) { readTitleFile(titleList, titleFile); renderList(titleList, wrap); } else if(State == 1) tick(gameEngine); else { if(Selection == 0) { renderText(wrap, startSel, 400, 300); renderText(wrap, exitUnsel, 400, 325); } else { renderText(wrap, startUnsel, 400, 300); renderText(wrap, exitSel, 400, 325); } if(keyDown(wrap, SDLK_DOWN)) Selection = 1; if(keyDown(wrap,SDLK_UP)) Selection = 0; if(keyDown(wrap, SDLK_RETURN)) { if(Selection == 0) { State = 1; setupGame(gameEngine); } else toggleRunning(wrap); } renderList(titleList, wrap); } if(keyPressed(wrap, SDLK_ESCAPE)) toggleRunning(wrap); endFrame(wrap); } listClear(titleList); free(titleList); destroyText(startUnsel); destroyText(startSel); destroyText(exitUnsel); destroyText(exitSel); deinitializeWrapper(wrap); destroyGame(gameEngine); free(wrap); return 0; }
void DreamWebEngine::processEvents() { if (_eventMan->shouldQuit()) { quit(); return; } _sound->soundHandler(); Common::Event event; int softKey, hardKey; while (_eventMan->pollEvent(event)) { switch(event.type) { case Common::EVENT_RTL: quit(); break; case Common::EVENT_KEYDOWN: if (event.kbd.flags & Common::KBD_CTRL) { switch (event.kbd.keycode) { case Common::KEYCODE_d: _console->attach(); _console->onFrame(); break; case Common::KEYCODE_f: setSpeed(_speed != 20? 20: 1); break; case Common::KEYCODE_g: _turbo = !_turbo; break; case Common::KEYCODE_c: //skip statue puzzle _symbolBotNum = 3; _symbolTopNum = 5; break; default: break; } return; //do not pass ctrl + key to the engine } // Some parts of the ASM code uses the hardware key // code directly. We don't have that code, so we fake // it for the keys where it's needed and assume it's // 0 (which is actually an invalid value, as far as I // know) otherwise. hardKey = 0; switch (event.kbd.keycode) { case Common::KEYCODE_ESCAPE: hardKey = 1; break; case Common::KEYCODE_SPACE: hardKey = 57; break; default: hardKey = 0; break; } _lastHardKey = hardKey; // The rest of the keys are converted to ASCII. This // is fairly restrictive, and eventually we may want // to let through more keys. I think this is mostly to // keep weird glyphs out of savegame names. softKey = 0; if (event.kbd.keycode >= Common::KEYCODE_a && event.kbd.keycode <= Common::KEYCODE_z) { softKey = event.kbd.ascii & ~0x20; } else if (event.kbd.keycode == Common::KEYCODE_MINUS || event.kbd.keycode == Common::KEYCODE_SPACE || (event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9)) { softKey = event.kbd.ascii; } else if (event.kbd.keycode >= Common::KEYCODE_KP0 && event.kbd.keycode <= Common::KEYCODE_KP9) { softKey = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; } else if (event.kbd.keycode == Common::KEYCODE_KP_MINUS) { softKey = '-'; } else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE || event.kbd.keycode == Common::KEYCODE_DELETE) { softKey = 8; } else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_KP_ENTER) { softKey = 13; } if (softKey) keyPressed(softKey); break; default: break; } } }
void CEngine::handleEvents() { while ( SDL_PollEvent( &event ) ) { switch ( event.type ) { case SDL_KEYDOWN: keyPressed( event.key.keysym.sym ); break; case SDL_KEYUP: keyReleased( event.key.keysym.sym ); break; case SDL_QUIT: isRunning = true; break; case SDL_MOUSEMOTION: if(m_showCursor) mouseMoved( event.button.button, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); break; case SDL_MOUSEBUTTONUP: if(m_showCursor) mouseButtonUp( event.button.button, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); break; case SDL_MOUSEBUTTONDOWN: if(m_showCursor) mouseButtonDown( event.button.button, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); break; case SDL_ACTIVEEVENT: if ( event.active.state & SDL_APPACTIVE ) { if ( event.active.gain ) { /* Gain focus */ m_bMinimized = false; showNotify(); } else { /* Lost focus */ m_bMinimized = true; hideNotify(); } } break; } } }
void ofxSITextInput::keyPressedEvent(ofKeyEventArgs &a) { // if we're enabled if(*value) keyPressed(a.key); }
//-------------------------------------------------------------------------- void testApp::setup() { doScreenshots = false; screenshotCount = 0; ofxDaito::setup("oscSettings.xml"); ofxConnexion::start(); ofAddListener(ofxConnexion::connexionEvent, this, &testApp::connexionEvent); ofxConnexion::setLed(false); frameScaleFactor = .6; frameW = 320 * frameScaleFactor; frameH = 240 * frameScaleFactor; int numParticles = frameW * frameH; SP.setup(frameW, frameH); SP.loadDirectory("input/otherTest/"); notifier.setup("network.xml"); notifier.enable(); ofAddListener(notifier.theEvent,this,&testApp::eventsIn); state = VIZAPP_PARTICLES_FREE; setupControlPanel(); if( bDebugMode == false ){ ofSetFullscreen(true); panel.hide(); } bJustLoadedUser = false; pointBrightness = .5; aberration = .02; aperture = .01; dofShader.load("shaders/DOFCloud"); sphereShader.load("shaders/SphereShader"); timeLastLoaded = ofGetElapsedTimef(); bDoUnload = false; PS.setup(numParticles); isMousePressed = false; chroma.allocate(targetWidth, targetHeight); chroma.begin(); ofClear(0, 0, 0, 255); chroma.end(); bTogglePlayer = panel.getValueB("toggle_mode"); for(int k = 0; k < PS.particles.size(); k++){ PS.particles[k].queueState(PARTICLE_FLOCKING, 0.0); } connexionCamera.setup(PS); currentMsg = "app started"; isSlow = false; slowState = 0; ofEnableAlphaBlending(); keyPressed('f'); keyPressed('h'); ofSetSphereResolution(16); }
static bool driveControl(DROID *psDroid) { bool Input = false; SDWORD MaxSpeed = moveCalcDroidSpeed(psDroid); if (!DriveControlEnabled) { return false; } if (keyPressed(KEY_N)) { driveNextDriver(); } if (keyDown(KEY_LEFTARROW)) { driveDir += DRIVE_TURNSPEED; Input = true; } else if (keyDown(KEY_RIGHTARROW)) { driveDir -= DRIVE_TURNSPEED; if (driveDir < 0) { driveDir += 360; } Input = true; } driveDir = driveDir % 360; if (keyDown(KEY_UPARROW)) { if (driveSpeed >= 0) { driveSpeed += DRIVE_ACCELERATE; if (driveSpeed > MaxSpeed) { driveSpeed = MaxSpeed; } } else { driveSpeed += DRIVE_BRAKE; if (driveSpeed > 0) { driveSpeed = 0; } } Input = true; } else if (keyDown(KEY_DOWNARROW)) { if (driveSpeed <= 0) { driveSpeed -= DRIVE_ACCELERATE; if (driveSpeed < -MaxSpeed) { driveSpeed = -MaxSpeed; } } else { driveSpeed -= DRIVE_BRAKE; if (driveSpeed < 0) { driveSpeed = 0; } } Input = true; } else { if (driveSpeed > 0) { driveSpeed -= DRIVE_DECELERATE; if (driveSpeed < 0) { driveSpeed = 0; } } else { driveSpeed += DRIVE_DECELERATE; if (driveSpeed > 0) { driveSpeed = 0; } } } return Input; }
void ofxUICanvas::onKeyPressed(ofKeyEventArgs& data) { keyPressed(data.key); }
void BaseManager::run() { #ifndef EMSCRIPTEN while (!mExit) #endif { while (SDL_PollEvent(&mEvent) != 0) { switch (mEvent.type) { // keyboard events case SDL_KEYDOWN: mKeyCode = mEvent.key.keysym.sym; keyPressed(mKeyCode, nullptr); break; case SDL_TEXTINPUT: mKeyCode = SDLK_UNKNOWN; keyPressed(mKeyCode, &mEvent.text); break; case SDL_KEYUP: keyReleased(mEvent.key); break; // mouse events case SDL_MOUSEMOTION: mouseMoved(mEvent.motion); break; case SDL_MOUSEBUTTONDOWN: mousePressed(mEvent.button); break; case SDL_MOUSEBUTTONUP: mouseReleased(mEvent.button); break; case SDL_MOUSEWHEEL: mouseWheelMoved(mEvent.wheel); break; // drop file events case SDL_DROPFILE: break; // windows events case SDL_WINDOWEVENT: switch (mEvent.window.event) { case SDL_WINDOWEVENT_CLOSE: mExit = true; break; case SDL_WINDOWEVENT_RESIZED: _windowResized(mEvent.window.data1, mEvent.window.data2); break; case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_MAXIMIZED: mWindowOn = true; break; case SDL_WINDOWEVENT_MINIMIZED: case SDL_WINDOWEVENT_HIDDEN: mWindowOn = false; default: break; } break; default: break; } } glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); drawOneFrame(); if (!mWindowOn) SDL_Delay(50); } }
// For managing selection and cursor void CFileListView::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up || event->key() == Qt::Key_PageDown || event->key() == Qt::Key_PageUp || event->key() == Qt::Key_Home || event->key() == Qt::Key_End) { if ((event->modifiers() & (~Qt::KeypadModifier) & (~Qt::ShiftModifier)) == Qt::NoModifier) { const bool shiftPressed = (event->modifiers() & Qt::ShiftModifier) != 0; if (event->key() == Qt::Key_Down) moveCursorToNextItem(shiftPressed); else if (event->key() == Qt::Key_Up) moveCursorToPreviousItem(shiftPressed); else if (event->key() == Qt::Key_Home) moveCursorToItem(model()->index(0, 0), shiftPressed); else if (event->key() == Qt::Key_End) moveCursorToItem(model()->index(model()->rowCount()-1, 0), shiftPressed); else if (event->key() == Qt::Key_PageUp) pgUp(shiftPressed); else if (event->key() == Qt::Key_PageDown) pgDn(shiftPressed); event->accept(); return; } } else if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { if (event->modifiers() == Qt::NoModifier) { bool returnPressConsumed = false; for(FileListViewEventObserver* observer: _eventObservers) { returnPressConsumed = observer->fileListReturnPressed(); if (returnPressConsumed) break; } if (!returnPressConsumed) for (FileListViewEventObserver* observer: _eventObservers) { if (currentIndex().isValid()) { returnPressConsumed = observer->fileListReturnPressOrDoubleClickPerformed(currentIndex()); if (returnPressConsumed) break; } } } else if (event->modifiers() == Qt::ControlModifier) emit ctrlEnterPressed(); else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) emit ctrlShiftEnterPressed(); return; } else if (event->key() == Qt::Key_Shift) { _shiftPressedItemSelected = currentIndex().isValid() ? selectionModel()->isSelected(currentIndex()) : false; } else emit keyPressed(event->text(), event->key(), event->modifiers()); QTreeView::keyPressEvent(event); #ifdef __linux__ // FIXME: find out why this hack is necessary if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up || event->key() == Qt::Key_PageDown || event->key() == Qt::Key_PageUp || event->key() == Qt::Key_Home || event->key() == Qt::Key_End) if ((event->modifiers() & Qt::ShiftModifier) != 0) scrollTo(currentIndex()); #endif }
void TetrixBoard::keyPressEvent(QKeyEvent *event) { emit keyPressed(event->key()); }
void FboWarpOutput::keyPressed(ofKeyEventArgs& e){ keyPressed(e.key); }
// //////////////////////////////////////////////////////////////////////////// // Returns true if cancel pressed or a valid game slot was selected. // if when returning true strlen(sRequestResult) != 0 then a valid game slot was selected // otherwise cancel was selected.. BOOL runLoadSave(BOOL bResetMissionWidgets) { UDWORD id=0; static char sDelete[PATH_MAX]; UDWORD i, campaign; W_CONTEXT context; id = widgRunScreen(psRequestScreen); sstrcpy(sRequestResult, ""); // set returned filename to null; // cancel this operation... if(id == LOADSAVE_CANCEL || CancelPressed() ) { goto cleanup; } // clicked a load entry if( id >= LOADENTRY_START && id <= LOADENTRY_END ) { if (mode) // Loading, return that entry. { if( ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText ) { sprintf(sRequestResult,"%s%s.%s",sPath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText ,sExt); } else { return false; // clicked on an empty box } goto success; } else // SAVING!add edit box at that position. { if( ! widgGetFromID(psRequestScreen,SAVEENTRY_EDIT)) { // add blank box. W_EDBINIT sEdInit; sEdInit.formID= LOADSAVE_FORM; sEdInit.id = SAVEENTRY_EDIT; sEdInit.x = widgGetFromID(psRequestScreen,id)->x; sEdInit.y = widgGetFromID(psRequestScreen,id)->y; sEdInit.width = widgGetFromID(psRequestScreen,id)->width; sEdInit.height= widgGetFromID(psRequestScreen,id)->height; sEdInit.pText = ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText; sEdInit.pBoxDisplay = displayLoadSaveEdit; widgAddEditBox(psRequestScreen, &sEdInit); if (((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText != NULL) { snprintf(sDelete, sizeof(sDelete), "%s%s.%s", sPath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText , sExt); } else { sstrcpy(sDelete, ""); } widgHide(psRequestScreen,id); // hide the old button chosenSlotId = id; // auto click in the edit box we just made. context.psScreen = psRequestScreen; context.psForm = (W_FORM *)psRequestScreen->psForm; context.xOffset = 0; context.yOffset = 0; context.mx = mouseX(); context.my = mouseY(); widgGetFromID(psRequestScreen, SAVEENTRY_EDIT)->clicked(&context); } else { // clicked in a different box. shouldnt be possible!(since we autoclicked in editbox) } } } // finished entering a name. if( id == SAVEENTRY_EDIT) { char sTemp[MAX_STR_LENGTH]; if(!keyPressed(KEY_RETURN) && !keyPressed(KEY_KPENTER)) // enter was not pushed, so not a vaild entry. { widgDelete(psRequestScreen,SAVEENTRY_EDIT); //unselect this box, and go back .. widgReveal(psRequestScreen,chosenSlotId); return true; } // scan to see if that game exists in another slot, if so then fail. sstrcpy(sTemp, widgGetString(psRequestScreen, id)); for(i=LOADENTRY_START;i<LOADENTRY_END;i++) { if( i != chosenSlotId) { if( ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText && strcmp( sTemp, ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText ) ==0) { widgDelete(psRequestScreen,SAVEENTRY_EDIT); //unselect this box, and go back .. widgReveal(psRequestScreen,chosenSlotId); // move mouse to same box.. // SetMousePos(widgGetFromID(psRequestScreen,i)->pos.x ,widgGetFromID(psRequestScreen,i)->pos.y); audio_PlayTrack(ID_SOUND_BUILD_FAIL); return true; } } } // return with this name, as we've edited it. if (strlen(widgGetString(psRequestScreen, id))) { sstrcpy(sTemp, widgGetString(psRequestScreen, id)); removeWildcards(sTemp); snprintf(sRequestResult, sizeof(sRequestResult), "%s%s.%s", sPath, sTemp, sExt); if (strlen(sDelete) != 0) { deleteSaveGame(sDelete); //only delete game if a new game fills the slot } } goto cleanup; } return false; // failed and/or cancelled.. cleanup: closeLoadSave(); bRequestLoad = false; if (bResetMissionWidgets && widgGetFromID(psWScreen,IDMISSIONRES_FORM) == NULL) { resetMissionWidgets(); //reset the mission widgets here if necessary } return true; // success on load. success: campaign = getCampaign(sRequestResult); setCampaignNumber(campaign); debug(LOG_WZ, "Set campaign for %s to %u", sRequestResult, campaign); closeLoadSave(); bRequestLoad = true; return true; }
void KeyboardController::OnKeyDown(uint8_t _mod, uint8_t _oemKey) { modifiers = _mod; keyOem = _oemKey; keyascii = OemToAscii(_mod, _oemKey); keyPressed(); }
void MyDisplayItem::keyPressEvent(QKeyEvent* key) { //This shouldn't directly handle key events.. //QLineEdit::keyPressEvent(key); emit keyPressed(key); }
/* Main */ Tohkbd::Tohkbd(QObject *parent) : QObject(parent) { dbusRegistered = false; interruptsEnabled = false; vddEnabled = false; capsLockSeq = 0; vkbLayoutIsTohkbd = false; currentActiveLayout = QString(); currentOrientationLock = QString(); keypadIsPresent = false; gpio_fd = -1; displayIsOn = false; keyIsPressed = false; keyRepeat = false; slideEventEmitted = false; taskSwitcherVisible = false; ssNotifyReplacesId = 0; ssFilename = QString(); tohkbd2user = new QDBusInterface("com.kimmoli.tohkbd2user", "/", "com.kimmoli.tohkbd2user", QDBusConnection::sessionBus(), this); tohkbd2user->setTimeout(2000); thread = new QThread(); worker = new Worker(); worker->moveToThread(thread); connect(worker, SIGNAL(gpioInterruptCaptured()), this, SLOT(handleGpioInterrupt())); connect(worker, SIGNAL(workRequested()), thread, SLOT(start())); connect(thread, SIGNAL(started()), worker, SLOT(doWork())); connect(worker, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection); backlightTimer = new QTimer(this); backlightTimer->setSingleShot(true); connect(backlightTimer, SIGNAL(timeout()), this, SLOT(backlightTimerTimeout())); presenceTimer = new QTimer(this); presenceTimer->setInterval(2000); presenceTimer->setSingleShot(true); connect(presenceTimer, SIGNAL(timeout()), this, SLOT(presenceTimerTimeout())); repeatTimer = new QTimer(this); repeatTimer->setSingleShot(true); connect(repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerTimeout())); /* do this automatically at startup */ setVddState(true); setInterruptEnable(true); uinputif = new UinputIf(); uinputif->openUinputDevice(); tca8424 = new tca8424driver(0x3b); keymap = new keymapping(); FKEYS.clear(); FKEYS.append(KEY_F1); FKEYS.append(KEY_F2); FKEYS.append(KEY_F3); FKEYS.append(KEY_F4); FKEYS.append(KEY_F5); FKEYS.append(KEY_F6); FKEYS.append(KEY_F7); FKEYS.append(KEY_F8); FKEYS.append(KEY_F9); FKEYS.append(KEY_F10); FKEYS.append(KEY_F11); FKEYS.append(KEY_F12); reloadSettings(); if (currentActiveLayout.isEmpty()) changeActiveLayout(true); if (currentOrientationLock.isEmpty()) { changeOrientationLock(true); saveOrientation(); } checkKeypadPresence(); connect(keymap, SIGNAL(shiftChanged()), this, SLOT(handleShiftChanged())); connect(keymap, SIGNAL(ctrlChanged()), this, SLOT(handleCtrlChanged())); connect(keymap, SIGNAL(altChanged()), this, SLOT(handleAltChanged())); connect(keymap, SIGNAL(symChanged()), this, SLOT(handleSymChanged())); connect(keymap, SIGNAL(keyPressed(QList< QPair<int, int> >)), this, SLOT(handleKeyPressed(QList< QPair<int, int> >))); connect(keymap, SIGNAL(keyReleased()), this, SLOT(handleKeyReleased())); }
void ofxMSAInteractiveObject::_keyPressed(ofKeyEventArgs &e) { int key = e.key; if(verbose) printf("ofxMSAInteractiveObject::_keyPressed(key: %i)\n", key); if(!enabled) return; keyPressed(key); }
static void processLeaderSelection( void ) { DROID *psDroid; DROID *psPresent; DROID *psNew = NULL; UDWORD leaderClass; BOOL bSuccess; UDWORD dif; UDWORD bestSoFar; if (demoGetStatus()) { return; } if (getWarCamStatus()) { /* Only do if we're tracking a droid */ if (trackingCamera.target->type != OBJ_DROID) { return; } } else { return; } /* Don't do if we're driving?! */ if (getDrivingStatus()) { return; } psPresent = (DROID*)trackingCamera.target; if (keyPressed(KEY_LEFTARROW)) { leaderClass = LEADER_LEFT; } else if (keyPressed(KEY_RIGHTARROW)) { leaderClass = LEADER_RIGHT; } else if (keyPressed(KEY_UPARROW)) { leaderClass = LEADER_UP; } else if (keyPressed(KEY_DOWNARROW)) { leaderClass = LEADER_DOWN; } else { leaderClass = LEADER_STATIC; } bSuccess = false; bestSoFar = UDWORD_MAX; switch (leaderClass) { case LEADER_LEFT: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenX < psPresent->sDisplay.screenX) { dif = psPresent->sDisplay.screenX - psDroid->sDisplay.screenX; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_RIGHT: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenX > psPresent->sDisplay.screenX) { dif = psDroid->sDisplay.screenX - psPresent->sDisplay.screenX; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_UP: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenY < psPresent->sDisplay.screenY) { dif = psPresent->sDisplay.screenY - psDroid->sDisplay.screenY; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_DOWN: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenY > psPresent->sDisplay.screenY) { dif = psDroid->sDisplay.screenY - psPresent->sDisplay.screenY; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_STATIC: break; } if (bSuccess) { camAllignWithTarget((BASE_OBJECT*)psNew); } }