void GameConfigKeys (unsigned int key, bool special, bool release, int x, int y) { if (release) return; switch (key) { case SDLK_q: Winsys.Quit (); break; case 27: Winsys.SetMode (g_game.prev_mode); break; case SDLK_TAB: if (curr_focus < 7) curr_focus++; else curr_focus = 0; break; case 13: switch (curr_focus) { case 6: Winsys.SetMode (g_game.prev_mode); break; case 7: SetConfig (); break; default: SetConfig (); break; } break; case 276: switch (curr_focus) { case 0: ToggleFullscreen (); break; case 1: ChangeRes (-1); break; case 2: ChangeMusVol (-1); break; case 3: ChangeSoundVol (-1); break; case 4: ChangeDetail (-1); break; case 5: ChangeLanguage (-1); break; } break; case 275: switch (curr_focus) { case 0: ToggleFullscreen (); break; case 1: ChangeRes (1); break; case 2: ChangeMusVol (1); break; case 3: ChangeSoundVol (1); break; case 4: ChangeDetail (1); break; case 5: ChangeLanguage (1); break; } break; case 273: if (curr_focus > 0) curr_focus--; break; case 274: if (curr_focus < 7) curr_focus++; break; } }
void CoreWin32Platform::SwitchScreenToMode(eScreenMode screenMode) { if (GetScreenMode() != screenMode) // check if we try to switch mode { if (screenMode == Core::MODE_FULLSCREEN) { ToggleFullscreen(); }else if (screenMode == Core::MODE_WINDOWED) { ToggleFullscreen(); } }else { } }
/** 程序更新函数 */ void SkyTerrain::Update(DWORD milliseconds) { if (m_Keys.IsPressed(VK_ESCAPE) == true) /**< 按ESC退出 */ { TerminateApplication(); } /** 用户自定义的更新过程 */ /** 更新摄像机 */ UpdateCamera(); /** 空格键切换绘制模式 */ if(m_Keys.IsPressed(VK_SPACE) && !sp) { sp = true; m_RenderMode = !m_RenderMode; if(m_RenderMode) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } if(!m_Keys.IsPressed(VK_SPACE)) sp = false; if (m_Keys.IsPressed(VK_F1) == true) /**< 按F1切换窗口/全屏模式 */ { ToggleFullscreen(); } }
void Engine::OnKeyDown(SDLKey key, SDLMod mod) { if(mod & KMOD_LALT) { if(key == SDLK_F4) SetQuit(true); else if(key == SDLK_RETURN) ToggleFullscreen(); } //if(mod & KMOD_CTRL) { if(key == SDLK_F1) ToggleDebugFlag(EDBG_COLLISION_MAP_OVERLAY); else if(key == SDLK_F2) ToggleDebugFlag(EDBG_HIDE_SPRITES); else if(key == SDLK_F3) ToggleDebugFlag(EDBG_HIDE_LAYERS); else if(key == SDLK_F4) ToggleDebugFlag(EDBG_SHOW_BBOXES); } if(key == SDLK_PAUSE) { TogglePause(); } }
void OnKeyDown(sht::PublicKey key, int mods) final { // Console blocks key input if (console_->IsActive()) { console_->ProcessKeyInput(key, mods); } else // process another input { if (key == sht::PublicKey::kF) { ToggleFullscreen(); } else if (key == sht::PublicKey::kEscape) { Application::Terminate(); } else if ((key == sht::PublicKey::kGraveAccent) && !(mods & sht::ModifierKey::kShift)) { console_->Move(); } else if (key == sht::PublicKey::kSpace) { // For debug purposes only ball_->body()->SetPosition(vec3(0.0f, 3.0f, 0.0f)); } } }
void OnKeyDown(sht::PublicKey key, int mods) final { if (key == sht::PublicKey::kF) { ToggleFullscreen(); } else if (key == sht::PublicKey::kEscape) { Application::Terminate(); } else if (key == sht::PublicKey::kF5) { renderer_->TakeScreenshot("screenshots"); } else if (key == sht::PublicKey::kLeft) { camera_manager_->RotateAroundTargetInY(0.1f); } else if (key == sht::PublicKey::kRight) { camera_manager_->RotateAroundTargetInY(-0.1f); } else if (key == sht::PublicKey::kUp) { camera_manager_->RotateAroundTargetInZ(0.1f); } else if (key == sht::PublicKey::kDown) { camera_manager_->RotateAroundTargetInZ(-0.1f); } else if (key == sht::PublicKey::kSpace) { show_shadow_texture_ = !show_shadow_texture_; } }
/*virtual*/ void EldritchFramework::HandleEvent(const WBEvent& Event) { XTRACE_FUNCTION; Framework3D::HandleEvent(Event); STATIC_HASHED_STRING(ToggleInvertY); STATIC_HASHED_STRING(ToggleFullscreen); STATIC_HASHED_STRING(OnSliderChanged); STATIC_HASHED_STRING(WritePrefsConfig); STATIC_HASHED_STRING(CheckForUpdates); const HashedString EventName = Event.GetEventName(); if (EventName == sToggleInvertY) { XTRACE_NAMED(ToggleInvertY); // TODO: Also invert controller? Or on a separate button? STATIC_HASHED_STRING(TurnY); const bool InvertY = !m_InputSystem->GetMouseInvert(sTurnY); m_InputSystem->SetMouseInvert(sTurnY, InvertY); m_InputSystem->SetControllerInvert(sTurnY, InvertY); // Publish config var so UI can reflect the change. // I could make input system publish config vars for each adjustment, but // that seems wasteful since most inputs currently have no adjustment. STATICHASH(InvertY); ConfigManager::SetBool(sInvertY, InvertY); } else if (EventName == sToggleFullscreen) { XTRACE_NAMED(ToggleFullscreen); ToggleFullscreen(); } else if (EventName == sOnSliderChanged) { XTRACE_NAMED(OnSliderChanged); STATIC_HASHED_STRING(SliderName); const HashedString SliderName = Event.GetHash(sSliderName); STATIC_HASHED_STRING(SliderValue); const float SliderValue = Event.GetFloat(sSliderValue); HandleUISliderEvent(SliderName, SliderValue); } else if (EventName == sWritePrefsConfig) { XTRACE_NAMED(WritePrefsConfig); WritePrefsConfig(); } else if (EventName == sCheckForUpdates) { #if BUILD_WINDOWS && !BUILD_STEAM XTRACE_NAMED(CheckForUpdates); // So I can compile updating out of certain builds. STATICHASH(Framework); STATICHASH(CheckForUpdates); const bool CheckForUpdates = ConfigManager::GetBool(sCheckForUpdates, true, sFramework); if (CheckForUpdates) { m_CheckForUpdates->Check(false, true); } #endif } }
BOOL Show(HINSTANCE hInstance) { hInst = hInstance; // Store instance handle in our global variable. RECT rc = DetermineWindowRectangle(); SavePosition(); u32 style = WS_OVERLAPPEDWINDOW; hwndMain = CreateWindowEx(0,szWindowClass, L"", style, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL); if (!hwndMain) return FALSE; SetWindowLong(hwndMain, GWL_EXSTYLE, WS_EX_APPWINDOW); RECT rcClient; GetClientRect(hwndMain, &rcClient); hwndDisplay = CreateWindowEx(0, szDisplayClass, L"", WS_CHILD | WS_VISIBLE, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hwndMain, 0, hInstance, 0); if (!hwndDisplay) return FALSE; menu = GetMenu(hwndMain); MENUINFO info; ZeroMemory(&info,sizeof(MENUINFO)); info.cbSize = sizeof(MENUINFO); info.cyMax = 0; info.dwStyle = MNS_CHECKORBMP; info.fMask = MIM_STYLE; for (int i = 0; i < GetMenuItemCount(menu); i++) { SetMenuInfo(GetSubMenu(menu,i), &info); } // Always translate first: translating resets the menu. TranslateMenus(hwndMain, menu); UpdateMenus(); // Accept dragged files. DragAcceptFiles(hwndMain, TRUE); hideCursor = true; SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0); ToggleFullscreen(hwndMain, g_Config.bFullScreen); W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); touchHandler.registerTouchWindow(hwndDisplay); WindowsRawInput::Init(); SetFocus(hwndMain); return TRUE; }
void Window::Update() { sf::Event evt; while (_window.pollEvent(evt)) { if (evt.type == sf::Event::Closed) { _isDone = true; } else if (evt.type == sf::Event::KeyPressed && evt.key.code == sf::Keyboard::F5) { ToggleFullscreen(); } } }
void VisualisationContainer::keyReleaseEvent(QKeyEvent* event) { if (event->matches(QKeySequence::Close) || event->key() == Qt::Key_Escape) { if (isFullScreen()) ToggleFullscreen(); else hide(); return; } QGraphicsView::keyReleaseEvent(event); }
void VisualisationContainer::Init() { setWindowTitle(tr("Clementine Visualization")); setWindowIcon(QIcon(":/icon.png")); // Set up the graphics view setScene(vis_); setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); setViewportUpdateMode(QGraphicsView::FullViewportUpdate); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFrameStyle(QFrame::NoFrame); // Add the overlay overlay_proxy_ = scene()->addWidget(overlay_); connect(overlay_, SIGNAL(OpacityChanged(qreal)), SLOT(ChangeOverlayOpacity(qreal))); connect(overlay_, SIGNAL(ShowPopupMenu(QPoint)), SLOT(ShowPopupMenu(QPoint))); ChangeOverlayOpacity(0.0); vis_->SetTextureSize(size_); SizeChanged(); // Selector selector_->SetVisualisation(vis_); // Settings menu menu_->addAction(IconLoader::Load("view-fullscreen"), tr("Toggle fullscreen"), this, SLOT(ToggleFullscreen())); QMenu* fps_menu = menu_->addMenu(tr("Framerate")); QSignalMapper* fps_mapper = new QSignalMapper(this); QActionGroup* fps_group = new QActionGroup(this); AddMenuItem(tr("Low (15 fps)"), 15, fps_, fps_group, fps_mapper); AddMenuItem(tr("Medium (25 fps)"), 25, fps_, fps_group, fps_mapper); AddMenuItem(tr("High (35 fps)"), 35, fps_, fps_group, fps_mapper); AddMenuItem(tr("Super high (60 fps)"), 60, fps_, fps_group, fps_mapper); fps_menu->addActions(fps_group->actions()); connect(fps_mapper, SIGNAL(mapped(int)), SLOT(SetFps(int))); QMenu* quality_menu = menu_->addMenu(tr("Quality")); QSignalMapper* quality_mapper = new QSignalMapper(this); QActionGroup* quality_group = new QActionGroup(this); AddMenuItem(tr("Low (256x256)"), 256, size_, quality_group, quality_mapper); AddMenuItem(tr("Medium (512x512)"), 512, size_, quality_group, quality_mapper); AddMenuItem(tr("High (1024x1024)"), 1024, size_, quality_group, quality_mapper); quality_menu->addActions(quality_group->actions()); connect(quality_mapper, SIGNAL(mapped(int)), SLOT(SetQuality(int))); menu_->addAction(tr("Select visualizations..."), selector_, SLOT(show())); menu_->addSeparator(); menu_->addAction(IconLoader::Load("application-exit"), tr("Close visualization"), this, SLOT(hide())); }
void Update (DWORD milliseconds) // Perform Motion Updates Here { g_flYRot += (float) ( milliseconds ) / 1000.0f * 25.0f; // Consistantly Rotate The Scenery if (g_keys->keyDown [VK_ESCAPE] == TRUE) // Is ESC Being Pressed? { TerminateApplication (g_window); // Terminate The Program } if (g_keys->keyDown [VK_F1] == TRUE) // Is F1 Being Pressed? { ToggleFullscreen (g_window); // Toggle Fullscreen Mode } }
void Update (DWORD milliseconds) // Perform Motion Updates Here { if (g_keys->keyDown [VK_ESCAPE] == TRUE) // Is ESC Being Pressed? { TerminateApplication (g_window); // Terminate The Program } if (g_keys->keyDown [VK_F1] == TRUE) // Is F1 Being Pressed? { ToggleFullscreen (g_window); // Toggle Fullscreen Mode } angle += (float)(milliseconds) / 5.0f; // Update angle Based On The Clock }
photon_window CreateSDLWindow(const photon_settings &settings){ PrintToLog("INFO: Initializing SDL."); photon_window window; SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == -1) { PrintToLog("ERROR: Unable to init SDL! \"%s\"", SDL_GetError()); // TODO - error handling. abort(); } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); if(settings.multisamples > 0){ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, settings.multisamples); } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, settings.doublebuffer); window.window_SDL = SDL_CreateWindow("Photon", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, PHOTON_WINDOW_FLAGS); if (!window.window_SDL){ PrintToLog("ERROR: Unable to create window!"); // TODO - error handling. abort(); } window.context_SDL = SDL_GL_CreateContext(window.window_SDL); SDL_GL_SetSwapInterval(settings.vsync); SDL_ShowCursor(SDL_ENABLE); if(settings.fullscreen){ ToggleFullscreen(window); } SetWindowIcon(window, "/textures/gui/window_icon.png"); return window; }
static void KeyCallback(unsigned char key, int x, int y) { if (key==27) { glutLeaveMainLoop(); /*EnableScreenSaver(); exit(0);*/ } else/* Closes Application on Escape Key*/ if (key=='j') { ToggleFullscreen(); /* Toggles Fullscreen "window" */ } /* The rest commands are handled in controls.cpp / controls.h */ unsigned int nokey = Controls_Handle_Keyboard(key,x,y); if ( nokey == 0 ) { key=0; if (PrintDevMsg()) fprintf(stderr,"X:%f Y:%f Z:%f \n",frame.vx,frame.vy,frame.vz); usleep(100); glutPostRedisplay(); } }
/** 程序更新函数 */ void CThreeCube::Update(DWORD milliseconds) { if (m_Keys.IsPressed(VK_ESCAPE) == true) /**< 按ESC退出 */ { TerminateApplication(); } if (m_Keys.IsPressed(VK_F1) == true) /**< 按F1切换窗口/全屏模式 */ { ToggleFullscreen(); } /** 用户自定义的更新过程 */ m_Angle += (float)(milliseconds) / 15.0f; /**< 更新旋转的角度 */ }
bool StereoDisplay::Update(void) { if (keys_->keyDown [VK_ESCAPE] == TRUE) // Is ESC Being Pressed? { TerminateApplication (window_); // Terminate The Program } if (keys_->keyDown [VK_F1] == TRUE) // Is F1 Being Pressed? { ToggleFullscreen (window_); // Toggle Fullscreen Mode } return TRUE; }
void GameConfigMouseFunc (int button, int state, int x, int y) { int focus, dr; if (state == 1) { GetFocus (x, y, &focus, &dr); switch (focus) { case 0: ToggleFullscreen (); break; case 1: ChangeConfigSelection (focus, dr); break; case 2: ChangeConfigSelection (focus, dr); break; case 3: ChangeConfigSelection (focus, dr); break; case 4: ChangeConfigSelection (focus, dr); break; case 5: ChangeConfigSelection (focus, dr); break; case 6: Winsys.SetMode (g_game.prev_mode); break; case 7: SetConfig (); break; } } }
/////////////////////////////////////////////////////////// /// Initialize /////////////////////////////////////////////////////////// void Player::Update() { Event evnt; bool result; do { result = main_window->GetEvent(evnt); if (evnt.type == Event::Quit) { ARuby::Exit(); Player::Exit(); exit(0); return; } else if (evnt.type == Event::KeyDown) { if (evnt.param1 == Input::Keys::ALT) { alt_pressing = true; } else if (evnt.param1 == Input::Keys::RETURN && alt_pressing) { ToggleFullscreen(); alt_pressing = false; } } else if (evnt.type == Event::KeyUp) { if (evnt.param1 == Input::Keys::ALT) { alt_pressing = false; } } #if (PAUSE_GAME_WHEN_FOCUS_LOST == YES) else { if (evnt.type == Event::GainFocus && !focus) { focus = true; Graphics::TimerContinue(); #if (PAUSE_AUDIO_WHEN_FOCUS_LOST) Audio::Continue(); #endif } else if (evnt.type == Event::LostFocus && focus) { focus = false; Input::ClearKeys(); Graphics::TimerWait(); #if (PAUSE_AUDIO_WHEN_FOCUS_LOST) Audio::Pause(); #endif } } #endif #if PAUSE_GAME_WHEN_FOCUS_LOST == YES } while(result || !focus); #else } while(result);
void Update (DWORD milliseconds) // Perform Motion Updates Here { if (g_keys->keyDown [VK_ESCAPE] == TRUE) // Is ESC Being Pressed? TerminateApplication (g_window); // Terminate The Program if (g_keys->keyDown [VK_F1] == TRUE) // Is F1 Being Pressed? ToggleFullscreen (g_window); // Toggle Fullscreen Mode Vector3D ropeConnectionVel; // Create A Temporary Vector3D // Keys Are Used To Move The Rope if (g_keys->keyDown [VK_RIGHT] == TRUE) // Is The Right Arrow Being Pressed? ropeConnectionVel.x += 3.0f; // Add Velocity In +X Direction if (g_keys->keyDown [VK_LEFT] == TRUE) // Is The Left Arrow Being Pressed? ropeConnectionVel.x -= 3.0f; // Add Velocity In -X Direction if (g_keys->keyDown [VK_UP] == TRUE) // Is The Up Arrow Being Pressed? ropeConnectionVel.z -= 3.0f; // Add Velocity In +Z Direction if (g_keys->keyDown [VK_DOWN] == TRUE) // Is The Down Arrow Being Pressed? ropeConnectionVel.z += 3.0f; // Add Velocity In -Z Direction if (g_keys->keyDown [VK_HOME] == TRUE) // Is The Home Key Pressed? ropeConnectionVel.y += 3.0f; // Add Velocity In +Y Direction if (g_keys->keyDown [VK_END] == TRUE) // Is The End Key Pressed? ropeConnectionVel.y -= 3.0f; // Add Velocity In -Y Direction ropeSimulation->setRopeConnectionVel(ropeConnectionVel); // Set The Obtained ropeConnectionVel In The Simulation float dt = milliseconds / 1000.0f; // Let's Convert Milliseconds To Seconds float maxPossible_dt = 0.002f; // Maximum Possible dt Is 0.002 Seconds // This Is Needed To Prevent Pass Over Of A Non-Precise dt Value int numOfIterations = (int)(dt / maxPossible_dt) + 1; // Calculate Number Of Iterations To Be Made At This Update Depending On maxPossible_dt And dt if (numOfIterations != 0) // Avoid Division By Zero dt = dt / numOfIterations; // dt Should Be Updated According To numOfIterations for (int a = 0; a < numOfIterations; ++a) // We Need To Iterate Simulations "numOfIterations" Times ropeSimulation->operate(dt); }
int WindowFrame::MsgLoop(GL_Window* window) { MSG msg; BOOL isMessagePumpActive = TRUE; while (isMessagePumpActive == TRUE) { if (PeekMessage (&msg, window->hWnd, 0, 0, PM_REMOVE) != 0) { if (msg.message != WM_QUIT) { DispatchMessage (&msg); // 如果不是退出消息,把消息发送到处理函数 } else { isMessagePumpActive = FALSE; // 否则结束退出 } } else // 如果没有消息 { if (window->isVisible == FALSE) // 窗口不可见 { WaitMessage (); // 等待下一条消息 } else // 窗口可见 { if (window->keys->keyDown[VK_ESCAPE]) // 按下 ESC? { TerminateApplication(window); // 推出程序 } if (window->keys->keyDown[VK_F1]) // 按下f1? { ToggleFullscreen(window); // 换到全屏模式 } //Draw(); // 绘制场景 SwapBuffers(window->hDC); // 交换帧缓存 } } } return (msg.wParam); }
void Update (DWORD milliseconds) // Perform Motion Updates Here { // ROACH if(g_keys->keyDown [VK_SPACE] == TRUE) domulti=!domulti; if(g_keys->keyDown ['M'] == TRUE) doangle=!doangle; // ENDROACH if (g_keys->keyDown [VK_ESCAPE] == TRUE) // Is ESC Being Pressed? { TerminateApplication (g_window); // Terminate The Program } if (g_keys->keyDown [VK_F1] == TRUE) // Is F1 Being Pressed? { ToggleFullscreen (g_window); // Toggle Fullscreen Mode } }
//handles keyboard processing void ProcessKeys(void) { // debug keys ////////////////////////////////////////////////////////////////////////// if (g_keys->keyDown[VK_F4]) { ToggleFullscreen (g_window); } if (g_keys->keyDown[VK_F11]) { g_camera->ToggleMouseControl(); g_keys->keyDown[VK_F11] = FALSE; } if (g_keys->keyDown[VK_F12]) { g_camera->DEBUG_WritePositionToFile(); g_keys->keyDown[VK_F12] = FALSE; } // pass all pressed keys into the for(int index = 0; index <= 256; index++) { if(g_keys->keyDown[index]) { Sokoban.KeyPressed((char) index); g_keys->keyDown[index] = false; } } }
BOOL CtpView::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if (message == WM_CONTEXTMENU) { int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); int nCmd = TrackPopupMenu(*m_ContextMenu.GetSubMenu(0), TPM_LEFTALIGN | TPM_RETURNCMD, xPos, yPos, 0, m_hWnd, NULL); if (nCmd == ID_CTXMENU_FULLSCREEN) { ToggleFullscreen(); } } else { return CScrollView::OnWndMsg(message, wParam, lParam, pResult); } }
void OnKeyDown(sht::PublicKey key, int mods) final { // Console blocks key input if (console_->IsActive()) { console_->ProcessKeyInput(key, mods); } else // process another input { if (key == sht::PublicKey::kF) { ToggleFullscreen(); } else if (key == sht::PublicKey::kEscape) { Application::Terminate(); } else if ((key == sht::PublicKey::kGraveAccent) && !(mods & sht::ModifierKey::kShift)) { console_->Move(); } } }
void JoystickExec(void) { // uint8 * keystate = SDL_GetKeyState(NULL); // memset(joypad_0_buttons, 0, 21); // memset(joypad_1_buttons, 0, 21); gpu_start_log = 0; // Only log while key down! effect_start = 0; effect_start2 = effect_start3 = effect_start4 = effect_start5 = effect_start6 = 0; blit_start_log = 0; iLeft = iRight = false; #if 0 if ((keystate[SDLK_LALT] || keystate[SDLK_RALT]) & keystate[SDLK_RETURN]) ToggleFullscreen(); // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, * // vjs.p1KeyBindings[0] = sdlemu_getval_int("p1k_up", SDLK_UP); #if 0 if (keystate[vjs.p1KeyBindings[0]]) joypad_0_buttons[BUTTON_U] = 0x01; if (keystate[vjs.p1KeyBindings[1]]) joypad_0_buttons[BUTTON_D] = 0x01; if (keystate[vjs.p1KeyBindings[2]]) joypad_0_buttons[BUTTON_L] = 0x01; if (keystate[vjs.p1KeyBindings[3]]) joypad_0_buttons[BUTTON_R] = 0x01; // The buttons are labelled C,B,A on the controller (going from left to right) if (keystate[vjs.p1KeyBindings[4]]) joypad_0_buttons[BUTTON_C] = 0x01; if (keystate[vjs.p1KeyBindings[5]]) joypad_0_buttons[BUTTON_B] = 0x01; if (keystate[vjs.p1KeyBindings[6]]) joypad_0_buttons[BUTTON_A] = 0x01; //I may yet move these to O and P... if (keystate[vjs.p1KeyBindings[7]]) joypad_0_buttons[BUTTON_OPTION] = 0x01; if (keystate[vjs.p1KeyBindings[8]]) joypad_0_buttons[BUTTON_PAUSE] = 0x01; if (keystate[vjs.p1KeyBindings[9]]) joypad_0_buttons[BUTTON_0] = 0x01; if (keystate[vjs.p1KeyBindings[10]]) joypad_0_buttons[BUTTON_1] = 0x01; if (keystate[vjs.p1KeyBindings[11]]) joypad_0_buttons[BUTTON_2] = 0x01; if (keystate[vjs.p1KeyBindings[12]]) joypad_0_buttons[BUTTON_3] = 0x01; if (keystate[vjs.p1KeyBindings[13]]) joypad_0_buttons[BUTTON_4] = 0x01; if (keystate[vjs.p1KeyBindings[14]]) joypad_0_buttons[BUTTON_5] = 0x01; if (keystate[vjs.p1KeyBindings[15]]) joypad_0_buttons[BUTTON_6] = 0x01; if (keystate[vjs.p1KeyBindings[16]]) joypad_0_buttons[BUTTON_7] = 0x01; if (keystate[vjs.p1KeyBindings[17]]) joypad_0_buttons[BUTTON_8] = 0x01; if (keystate[vjs.p1KeyBindings[18]]) joypad_0_buttons[BUTTON_9] = 0x01; if (keystate[vjs.p1KeyBindings[19]]) joypad_0_buttons[BUTTON_s] = 0x01; if (keystate[vjs.p1KeyBindings[20]]) joypad_0_buttons[BUTTON_d] = 0x01; #else if (keyBuffer[0]) joypad_0_buttons[BUTTON_U] = 0x01; if (keyBuffer[1]) joypad_0_buttons[BUTTON_D] = 0x01; if (keyBuffer[2]) joypad_0_buttons[BUTTON_L] = 0x01; if (keyBuffer[3]) joypad_0_buttons[BUTTON_R] = 0x01; // The buttons are labelled C,B,A on the controller (going from left to right) if (keyBuffer[4]) joypad_0_buttons[BUTTON_C] = 0x01; if (keyBuffer[5]) joypad_0_buttons[BUTTON_B] = 0x01; if (keyBuffer[6]) joypad_0_buttons[BUTTON_A] = 0x01; //I may yet move these to O and P... if (keyBuffer[7]) joypad_0_buttons[BUTTON_OPTION] = 0x01; if (keyBuffer[8]) joypad_0_buttons[BUTTON_PAUSE] = 0x01; if (keyBuffer[9]) joypad_0_buttons[BUTTON_0] = 0x01; if (keyBuffer[10]) joypad_0_buttons[BUTTON_1] = 0x01; if (keyBuffer[11]) joypad_0_buttons[BUTTON_2] = 0x01; if (keyBuffer[12]) joypad_0_buttons[BUTTON_3] = 0x01; if (keyBuffer[13]) joypad_0_buttons[BUTTON_4] = 0x01; if (keyBuffer[14]) joypad_0_buttons[BUTTON_5] = 0x01; if (keyBuffer[15]) joypad_0_buttons[BUTTON_6] = 0x01; if (keyBuffer[16]) joypad_0_buttons[BUTTON_7] = 0x01; if (keyBuffer[17]) joypad_0_buttons[BUTTON_8] = 0x01; if (keyBuffer[18]) joypad_0_buttons[BUTTON_9] = 0x01; if (keyBuffer[19]) joypad_0_buttons[BUTTON_s] = 0x01; if (keyBuffer[20]) joypad_0_buttons[BUTTON_d] = 0x01; #endif #warning "!!! FIX !!! (debounceRunKey)" // extern bool debounceRunKey; bool debounceRunKey; if (keystate[SDLK_ESCAPE]) { if (!debounceRunKey) #warning "!!! FIX !!! (finished = true)" ;// finished = true; } else debounceRunKey = false; if (keystate[SDLK_TAB]) { if (!GUIKeyHeld) #warning "!!! FIX !!! (showGUI = !showGUI, ...)" ;// showGUI = !showGUI, GUIKeyHeld = true; } else GUIKeyHeld = false; if (keystate[SDLK_q]) start_logging = 1; if (keystate[SDLK_w]) GPUResetStats(); // if (keystate[SDLK_u]) jaguar_long_write(0xf1c384,jaguar_long_read(0xf1c384)+1); if (keystate[SDLK_d]) DumpMainMemory(); if (keystate[SDLK_l]) gpu_start_log = 1; if (keystate[SDLK_o]) op_start_log = 1; if (keystate[SDLK_b]) blit_start_log = 1; if (keystate[SDLK_1]) effect_start = 1; if (keystate[SDLK_2]) effect_start2 = 1; if (keystate[SDLK_3]) effect_start3 = 1; if (keystate[SDLK_4]) effect_start4 = 1; if (keystate[SDLK_5]) effect_start5 = 1; if (keystate[SDLK_6]) effect_start6 = 1; if (keystate[SDLK_i]) interactiveMode = true; if (keystate[SDLK_8] && interactiveMode) { if (!keyHeld1) objectPtr--, keyHeld1 = true; } else keyHeld1 = false; if (keystate[SDLK_0] && interactiveMode) { if (!keyHeld2) objectPtr++, keyHeld2 = true; } else keyHeld2 = false; if (keystate[SDLK_9] && interactiveMode) { if (!keyHeld3) iToggle = !iToggle, keyHeld3 = true; } else keyHeld3 = false; if (keystate[SDLK_e]) startMemLog = true; if (keystate[SDLK_r]) WriteLog("\n--------> MARK!\n\n"); if (keystate[SDLK_t]) doDSPDis = true; if (keystate[SDLK_y]) doGPUDis = true; // BLITTER single step if (keystate[SDLK_F5]) blitterSingleStep = true; if (keystate[SDLK_F6]) { if (!bssHeld) { bssHeld = true; bssGo = true; } } else bssHeld = false; #endif // We need to ensure that illegal combinations are not possible. // So, we do a simple minded way here... // It would be better to check to see which one was pressed last // and discard that one, but for now... //This didn't work... Was still able to do bad combination. //It's because the GUI is changing this *after* we fix it here. #if 0 if (joypad_0_buttons[BUTTON_R] && joypad_0_buttons[BUTTON_L]) joypad_0_buttons[BUTTON_L] = 0; if (joypad_0_buttons[BUTTON_U] && joypad_0_buttons[BUTTON_D]) joypad_0_buttons[BUTTON_D] = 0; #endif // Joystick support [nwagenaar] /*if (vjs.useJoystick) { extern SDL_Joystick * joystick1; int16 x = SDL_JoystickGetAxis(joystick1, 0), y = SDL_JoystickGetAxis(joystick1, 1); if (x > 16384) joypad_0_buttons[BUTTON_R] = 0x01; if (x < -16384) joypad_0_buttons[BUTTON_L] = 0x01; if (y > 16384) joypad_0_buttons[BUTTON_D] = 0x01; if (y < -16384) joypad_0_buttons[BUTTON_U] = 0x01; if (SDL_JoystickGetButton(joystick1, 0) == SDL_PRESSED) joypad_0_buttons[BUTTON_A] = 0x01; if (SDL_JoystickGetButton(joystick1, 1) == SDL_PRESSED) joypad_0_buttons[BUTTON_B] = 0x01; if (SDL_JoystickGetButton(joystick1, 2) == SDL_PRESSED) joypad_0_buttons[BUTTON_C] = 0x01; } // Needed to ensure that the events queue is empty [nwagenaar] SDL_PumpEvents();*/ }
bool XWindow::ProcessEvents() { XEvent event; bool ret = false; XLockDisplay (_display); while (XCheckWindowEvent (_display, _XWindow, StructureNotifyMask | SubstructureRedirectMask | ExposureMask | KeyPressMask | ButtonPressMask, &event) == True) { switch (event.type) { case ClientMessage: // If "closeWindow" is clicked do nothing right now // (window is closed from the GUI) break; case ConfigureNotify: { // the window size has changed XConfigureEvent *xce = &(event.xconfigure); // if a slave window exists it has to be resized as well if (_slave) _slave->SetWindow (xce->width - (int) (xce->width / ( _state.fullscreen ? PIP_RATIO_FS : PIP_RATIO_WIN)), xce->height - (int) (_slave->GetYUVHeight () * xce->width / ( _state.fullscreen ? PIP_RATIO_FS : PIP_RATIO_WIN) / _slave->GetYUVWidth ()), (int) (xce->width / ( _state.fullscreen ? PIP_RATIO_FS : PIP_RATIO_WIN)), (int) (_slave->GetYUVHeight () * xce->width / ( _state.fullscreen ? PIP_RATIO_FS : PIP_RATIO_WIN) / _slave->GetYUVWidth ())); CalculateSize (xce->width, xce->height, true); if( _paintColorKey ) { XSetForeground( _display, _gc, _colorKey ); XFillRectangle( _display, _XWindow, _gc, _state.curX, _state.curY, _state.curWidth, _state.curHeight); } } break; case Expose: if (_paintColorKey) { XSetForeground( _display, _gc, _colorKey ); XFillRectangle( _display, _XWindow, _gc, _state.curX, _state.curY, _state.curWidth, _state.curHeight); } ret = true; break; case KeyPress: // a key is pressed { XKeyEvent *xke = &(event.xkey); switch (xke->keycode) { case 41: if (_master) _master->ToggleFullscreen (); else ToggleFullscreen (); // "f" break; case 40: if (_master) _master->ToggleDecoration (); else ToggleDecoration (); // "d" break; case 32: if (_master) _master->ToggleOntop (); else ToggleOntop (); // "o" break; case 9: if (_master) { if (_master->IsFullScreen ()) _master->ToggleFullscreen(); } // esc else { if (IsFullScreen ()) ToggleFullscreen(); } break; default: break; } } break; case ButtonPress: // a mouse button is clicked if (_master) if (!_master->HasDecoration()) _master->ToggleDecoration(); else _master->ToggleFullscreen(); else if (!_state.decoration) ToggleDecoration(); else ToggleFullscreen(); break; case DestroyNotify: PTRACE(4, "X11\tWindow is being destroyed"); break; default: PTRACE(1, "X11\tUnknown X Event " << event.type << " received"); } } XUnlockDisplay (_display); return ret; }
/*virtual*/ bool Framework3D::TickSim( float DeltaTime ) { XTRACE_FUNCTION; const bool WasPaused = m_UIManager->GetUIStack()->PausesGame(); m_Clock->GameTick( WasPaused, DeltaTime ); #if BUILD_SDL if( !TickSDLEvents() ) { return false; } #endif TickDevices(); #if !BUILD_STEAM // Bit of a hack... And would conflict with Steam's F12 key function. if( m_Keyboard->OnRise( Keyboard::EB_F12 ) ) { TakeScreenshot(); } #endif // Man I'm really ruining the notion of "TickInput" huh. if( ( m_Keyboard->IsHigh( Keyboard::EB_LeftAlt ) || m_Keyboard->IsHigh( Keyboard::EB_RightAlt ) ) && m_Keyboard->OnRise( Keyboard::EB_Enter ) ) { ToggleFullscreen(); } #if !BUILD_MAC // This causes problems on Mac, but is essential on Linux and maybe Windows. if( m_Mouse->IsActive() && m_Window->HasFocus() ) { // Fix invisible cursor from affecting other windows m_Mouse->SetPosition( m_Display->m_Width / 2, m_Display->m_Height / 2, m_Window ); } #endif XTRACE_BEGIN( TickUI ); m_UIManager->ProcessEvents(); m_UIManager->GetUIStack()->Tick( DeltaTime, DeltaTime, false ); XTRACE_END; const bool Unpaused = WasPaused && !m_UIManager->GetUIStack()->PausesGame(); if( Unpaused ) { OnUnpaused(); m_Clock->GameTick( false, DeltaTime ); } if( m_HasFocus ) { if( WasPaused ) { TickPausedInput(); } else { if( !TickInput( DeltaTime ) ) { return false; } } } if( !WasPaused ) { TickGame( DeltaTime ); } XTRACE_BEGIN( TickAudio ); m_AudioSystem->Tick( DeltaTime, WasPaused ); XTRACE_END; return true; }
void Update(gl_window_t *window) { int dir; // Will Hold Current Direction keys_t *keys = &(window->keys); if (keys->keyDown [VK_ESCAPE]) // Is ESC Being Pressed? WindowTerminate(window); // Terminate The Program if (keys->keyDown [VK_F1]) // Is F1 Being Pressed? ToggleFullscreen(window); // Toggle Fullscreen Mode if (keys->keyDown [' '] && !sp) // Check To See If Spacebar Is Pressed { sp=TRUE; // If So, Set sp To TRUE (Spacebar Pressed) Reset(); // If So, Call Reset And Start A New Maze } if (!keys->keyDown [' ']) // Check To See If Spacebar Has Been Released sp=FALSE; // If So, Set sp To FALSE (Spacebar Released) float milliseconds = window->deltaTime; printf("win=%.8p fps=%8.2f deltaTime=%8.2f\n", window, 1000.0f/window->deltaTime, window->deltaTime); xrot+=(float)(milliseconds)*0.02f; // Increase Rotation On The X-Axis yrot+=(float)(milliseconds)*0.03f; // Increase Rotation On The Y-Axis zrot+=(float)(milliseconds)*0.015f; // Increase Rotation On The Z-Axis done=TRUE; // Set done To True for (int x=0; x<width; x+=2) // Loop Through All The Rooms { for (int y=0; y<height; y+=2) // On X And Y Axis { if (tex_data[((x+(width*y))*3)]==0) // If Current Texture Pixel (Room) Is Blank done=FALSE; // We Have To Set done To False (Not Finished Yet) } } if (done) // If done Is True Then There Were No Unvisited Rooms { // Display A Message At The Top Of The Window, Pause For A Bit And Then Start Building A New Maze! SetWindowText(window->hWnd,"Lesson 42: Multiple Viewports... 2003 NeHe Productions... Maze Complete!"); Sleep(5000); SetWindowText(window->hWnd,"Lesson 42: Multiple Viewports... 2003 NeHe Productions... Building Maze!"); Reset(); } // Check To Make Sure We Are Not Trapped (Nowhere Else To Move) if (((mx>(width-4) || tex_data[(((mx+2)+(width*my))*3)]==255)) && ((mx<2 || tex_data[(((mx-2)+(width*my))*3)]==255)) && ((my>(height-4) || tex_data[((mx+(width*(my+2)))*3)]==255)) && ((my<2 || tex_data[((mx+(width*(my-2)))*3)]==255))) { do // If We Are Trapped { mx=int(rand()%(width/2))*2; // Pick A New Random X Position my=int(rand()%(height/2))*2; // Pick A New Random Y Position } while (tex_data[((mx+(width*my))*3)]==0); // Keep Picking A Random Position Until We Find } // One That Has Already Been Tagged (Safe Starting Point) dir=int(rand()%4); // Pick A Random Direction if ((dir==0) && (mx<=(width-4))) // If The Direction Is 0 (Right) And We Are Not At The Far Right { if (tex_data[(((mx+2)+(width*my))*3)]==0) // And If The Room To The Right Has Not Already Been Visited { UpdateTex(mx+1,my); // Update The Texture To Show Path Cut Out Between Rooms mx+=2; // Move To The Right (Room To The Right) } } if ((dir==1) && (my<=(height-4))) // If The Direction Is 1 (Down) And We Are Not At The Bottom { if (tex_data[((mx+(width*(my+2)))*3)]==0) // And If The Room Below Has Not Already Been Visited { UpdateTex(mx,my+1); // Update The Texture To Show Path Cut Out Between Rooms my+=2; // Move Down (Room Below) } } if ((dir==2) && (mx>=2)) // If The Direction Is 2 (Left) And We Are Not At The Far Left { if (tex_data[(((mx-2)+(width*my))*3)]==0) // And If The Room To The Left Has Not Already Been Visited { UpdateTex(mx-1,my); // Update The Texture To Show Path Cut Out Between Rooms mx-=2; // Move To The Left (Room To The Left) } } if ((dir==3) && (my>=2)) // If The Direction Is 3 (Up) And We Are Not At The Top { if (tex_data[((mx+(width*(my-2)))*3)]==0) // And If The Room Above Has Not Already Been Visited { UpdateTex(mx,my-1); // Update The Texture To Show Path Cut Out Between Rooms my-=2; // Move Up (Room Above) } } UpdateTex(mx,my); // Update Current Room }
// // Command line. // UBOOL UXViewport::Exec( const TCHAR* Cmd, FOutputDevice& Ar ) { guard(UXViewport::Exec); if( UViewport::Exec( Cmd, Ar ) ) { return 1; } else if( ParseCommand(&Cmd,TEXT("EndFullscreen")) ) { EndFullscreen(); return 1; } else if( ParseCommand(&Cmd,TEXT("ToggleFullscreen")) ) { ToggleFullscreen(); return 1; } else if( ParseCommand(&Cmd,TEXT("Iconify")) ) { Iconify(); return 1; } else if( ParseCommand(&Cmd,TEXT("GetCurrentRes")) ) { Ar.Logf( TEXT("%ix%i"), SizeX, SizeY, (ColorBytes?ColorBytes:2)*8 ); return 1; } else if( ParseCommand(&Cmd,TEXT("GetCurrentColorDepth")) ) { Ar.Logf( TEXT("%i"), (ColorBytes?ColorBytes:2)*8 ); return 1; } else if( ParseCommand(&Cmd,TEXT("GetColorDepths")) ) { Ar.Log( TEXT("16 32") ); return 1; } else if( ParseCommand(&Cmd,TEXT("GetCurrentRenderDevice")) ) { Ar.Log( RenDev->GetClass()->GetPathName() ); return 1; } else if( ParseCommand(&Cmd,TEXT("SetRenderDevice")) ) { FString Saved = RenDev->GetClass()->GetPathName(); INT SavedSizeX=SizeX, SavedSizeY=SizeY, SavedColorBytes=ColorBytes, SavedFullscreen=((BlitFlags & BLIT_Fullscreen)!=0); TryRenderDevice( Cmd, SizeX, SizeY, ColorBytes, SavedFullscreen ); if( !RenDev ) { TryRenderDevice( *Saved, SavedSizeX, SavedSizeY, SavedColorBytes, SavedFullscreen ); check(RenDev); Ar.Log(TEXT("0")); } else Ar.Log(TEXT("1")); return 1; } else if( ParseCommand(&Cmd,TEXT("GetRes")) ) { return 1; } else if( ParseCommand(&Cmd,TEXT("SetRes")) ) { INT X=appAtoi(Cmd); TCHAR* CmdTemp = (TCHAR*) (appStrchr(Cmd,'x') ? appStrchr(Cmd,'x')+1 : appStrchr(Cmd,'X') ? appStrchr(Cmd,'X')+1 : TEXT("")); INT Y=appAtoi(CmdTemp); Cmd = CmdTemp; CmdTemp = (TCHAR*) (appStrchr(Cmd,'x') ? appStrchr(Cmd,'x')+1 : appStrchr(Cmd,'X') ? appStrchr(Cmd,'X')+1 : TEXT("")); INT C=appAtoi(CmdTemp); INT NewColorBytes = C ? C/8 : ColorBytes; if( X && Y ) { HoldCount++; UBOOL Result = RenDev->SetRes( X, Y, NewColorBytes, IsFullscreen() ); HoldCount--; if( !Result ) EndFullscreen(); } return 1; } else if( ParseCommand(&Cmd,TEXT("Preferences")) ) { // No preferences window. return 1; } else return 0; unguard; }