/** * @brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetRelativeMouseMode * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetRelativeMouseMode */ int mouse_getSetRelativeMouseMode(void *arg) { int result; int i; SDL_bool initialState; SDL_bool currentState; /* Capture original state so we can revert back to it later */ initialState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); /* Repeat twice to check D->D transition */ for (i=0; i<2; i++) { /* Disable - should always be supported */ result = SDL_SetRelativeMouseMode(SDL_FALSE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); } /* Repeat twice to check D->E->E transition */ for (i=0; i<2; i++) { /* Enable - may not be supported */ result = SDL_SetRelativeMouseMode(SDL_TRUE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)"); if (result != -1) { SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState); } } /* Disable to check E->D transition */ result = SDL_SetRelativeMouseMode(SDL_FALSE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); /* Revert to original state - ignore result */ result = SDL_SetRelativeMouseMode(initialState); return TEST_COMPLETED; }
static void HandleEvents() { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: Sys_Quit(); break; case SDL_WINDOWEVENT: window_event(&event.window); break; case SDL_KEYDOWN: case SDL_KEYUP: keyb_event(&event.key); break; case SDL_MOUSEMOTION: if (mouse_active && !SDL_GetRelativeMouseMode()) { mx = old_x - event.motion.x; my = old_y - event.motion.y; old_x = event.motion.x; old_y = event.motion.y; SDL_WarpMouseInWindow(sdl_window, glConfig.vidWidth / 2, glConfig.vidHeight / 2); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: mouse_button_event(&event.button); break; case SDL_MOUSEWHEEL: mouse_wheel_event(&event.wheel); break; } } }
void GraphicsManager::toggleMouseGrab() { // Same as ScummVM's OSystem_SDL::toggleMouseGrab() if (SDL_GetRelativeMouseMode() == SDL_FALSE) SDL_SetRelativeMouseMode(SDL_TRUE); else SDL_SetRelativeMouseMode(SDL_FALSE); }
/* * (Un)grab Input */ void GLimp_GrabInput(qboolean grab) { #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE); SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE); in_relativemode = (SDL_GetRelativeMouseMode() == SDL_TRUE); #else SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); #endif }
bool input::set_mouse_hold(const bool set) { const SDL_bool set_mouse_hold = set ? SDL_TRUE : SDL_FALSE; if(SDL_GetRelativeMouseMode() == set_mouse_hold) { return false; } SDL_SetRelativeMouseMode(set_mouse_hold); return true; }
void SDLFrontend::setCursorPosition (int x, int y) { // special case to disable the mouse cursor if (x == -1 && y == -1) { UI::get().setCursorPosition(x, y); return; } x = clamp(x, 0, _width); y = clamp(y, 0, _height); UI::get().setCursorPosition(x, y); if (!SDL_GetRelativeMouseMode()) { SDL_WarpMouseInWindow(_window, x, y); } }
void IN_Frame(void) { if (!sdl_window) return; HandleEvents(); if (!ActiveApp || Minimized || (!r_fullscreen.integer && (key_dest != key_game || cls.state != ca_active))) { IN_DeactivateMouse(); return; } else { IN_ActivateMouse(); } if (mouse_active && SDL_GetRelativeMouseMode()) { SDL_GetRelativeMouseState(&mx, &my); } }
bool SDLSystem::relative_mouse_mode() const { return SDL_GetRelativeMouseMode() == SDL_TRUE ? true : false; }
void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) { int i; static SDL_MouseMotionEvent lastEvent; if (state->verbose & VERBOSE_EVENT) { SDLTest_PrintEvent(event); } switch (event->type) { case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_CLOSE: { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { SDL_DestroyWindow(window); } } break; } break; case SDL_KEYDOWN: switch (event->key.keysym.sym) { /* Add hotkeys here */ case SDLK_PRINTSCREEN: { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { for (i = 0; i < state->num_windows; ++i) { if (window == state->windows[i]) { SDLTest_ScreenShot(state->renderers[i]); } } } } break; case SDLK_EQUALS: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-+ double the size of the window */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { int w, h; SDL_GetWindowSize(window, &w, &h); SDL_SetWindowSize(window, w*2, h*2); } } break; case SDLK_MINUS: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-- half the size of the window */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { int w, h; SDL_GetWindowSize(window, &w, &h); SDL_SetWindowSize(window, w/2, h/2); } } break; case SDLK_c: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-C copy awesome text! */ SDL_SetClipboardText("SDL rocks!\nYou know it!"); printf("Copied text to clipboard\n"); } if (event->key.keysym.mod & KMOD_ALT) { /* Alt-C toggle a render clip rectangle */ for (i = 0; i < state->num_windows; ++i) { int w, h; if (state->renderers[i]) { SDL_Rect clip; SDL_GetWindowSize(state->windows[i], &w, &h); SDL_RenderGetClipRect(state->renderers[i], &clip); if (SDL_RectEmpty(&clip)) { clip.x = w/4; clip.y = h/4; clip.w = w/2; clip.h = h/2; SDL_RenderSetClipRect(state->renderers[i], &clip); } else { SDL_RenderSetClipRect(state->renderers[i], NULL); } } } } break; case SDLK_v: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-V paste awesome text! */ char *text = SDL_GetClipboardText(); if (*text) { printf("Clipboard: %s\n", text); } else { printf("Clipboard is empty\n"); } SDL_free(text); } break; case SDLK_g: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-G toggle grab */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window) ? SDL_TRUE : SDL_FALSE); } } break; case SDLK_m: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-M maximize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_MAXIMIZED) { SDL_RestoreWindow(window); } else { SDL_MaximizeWindow(window); } } } break; case SDLK_r: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-R toggle mouse relative mode */ SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode() ? SDL_TRUE : SDL_FALSE); } break; case SDLK_z: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Z minimize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_MinimizeWindow(window); } } break; case SDLK_RETURN: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Enter toggle fullscreen */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_FULLSCREEN) { SDL_SetWindowFullscreen(window, SDL_FALSE); } else { SDL_SetWindowFullscreen(window, SDL_TRUE); } } } else if (event->key.keysym.mod & KMOD_ALT) { /* Alt-Enter toggle fullscreen desktop */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_FULLSCREEN) { SDL_SetWindowFullscreen(window, SDL_FALSE); } else { SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } } } break; case SDLK_b: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-B toggle window border */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { const Uint32 flags = SDL_GetWindowFlags(window); const SDL_bool b = ((flags & SDL_WINDOW_BORDERLESS) != 0) ? SDL_TRUE : SDL_FALSE; SDL_SetWindowBordered(window, b); } } break; case SDLK_0: if (event->key.keysym.mod & KMOD_CTRL) { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Test Message", "You're awesome!", window); } break; case SDLK_1: if (event->key.keysym.mod & KMOD_CTRL) { FullscreenTo(0, event->key.windowID); } break; case SDLK_2: if (event->key.keysym.mod & KMOD_CTRL) { FullscreenTo(1, event->key.windowID); } break; case SDLK_ESCAPE: *done = 1; break; case SDLK_SPACE: { char message[256]; SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); SDL_snprintf(message, sizeof(message), "(%i, %i), rel (%i, %i)\n", lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Last mouse position", message, window); break; } default: break; } break; case SDL_QUIT: *done = 1; break; case SDL_MOUSEMOTION: lastEvent = event->motion; break; } }
void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) { int i; if (state->verbose & VERBOSE_EVENT) { SDLTest_PrintEvent(event); } switch (event->type) { case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { for (i = 0; i < state->num_windows; ++i) { if (window == state->windows[i] && (state->window_flags & SDL_WINDOW_RESIZABLE)) { SDL_Rect viewport; viewport.x = 0; viewport.y = 0; SDL_GetWindowSize(window, &viewport.w, &viewport.h); SDL_RenderSetViewport(state->renderers[i], &viewport); } } } } break; case SDL_WINDOWEVENT_CLOSE: { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { SDL_DestroyWindow(window); } } break; } break; case SDL_KEYDOWN: switch (event->key.keysym.sym) { /* Add hotkeys here */ case SDLK_PRINTSCREEN: { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { for (i = 0; i < state->num_windows; ++i) { if (window == state->windows[i]) { SDLTest_ScreenShot(state->renderers[i]); } } } } break; case SDLK_EQUALS: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrt-+ double the size of the window */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { int w, h; SDL_GetWindowSize(window, &w, &h); SDL_SetWindowSize(window, w*2, h*2); } } break; case SDLK_MINUS: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrt-- double the size of the window */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { int w, h; SDL_GetWindowSize(window, &w, &h); SDL_SetWindowSize(window, w/2, h/2); } } break; case SDLK_c: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-C copy awesome text! */ SDL_SetClipboardText("SDL rocks!\nYou know it!"); printf("Copied text to clipboard\n"); } break; case SDLK_v: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-V paste awesome text! */ char *text = SDL_GetClipboardText(); if (*text) { printf("Clipboard: %s\n", text); } else { printf("Clipboard is empty\n"); } SDL_free(text); } break; case SDLK_g: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-G toggle grab */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window)); } } break; case SDLK_m: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-M maximize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_MAXIMIZED) { SDL_RestoreWindow(window); } else { SDL_MaximizeWindow(window); } } } break; case SDLK_r: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-R toggle mouse relative mode */ SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode()); } break; case SDLK_z: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Z minimize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_MinimizeWindow(window); } } break; case SDLK_RETURN: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Enter toggle fullscreen */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_FULLSCREEN) { SDL_SetWindowFullscreen(window, SDL_FALSE); } else { SDL_SetWindowFullscreen(window, SDL_TRUE); } } } break; case SDLK_b: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-B toggle window border */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { const Uint32 flags = SDL_GetWindowFlags(window); const SDL_bool b = ((flags & SDL_WINDOW_BORDERLESS) != 0); SDL_SetWindowBordered(window, b); } } break; case SDLK_1: if (event->key.keysym.mod & KMOD_CTRL) { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Test Message", "You're awesome!", window); } break; case SDLK_ESCAPE: *done = 1; break; default: break; } break; case SDL_QUIT: *done = 1; break; } }
void CommonEvent(CommonState * state, SDL_Event * event, int *done) { int i; if (state->verbose & VERBOSE_EVENT) { PrintEvent(event); } switch (event->type) { case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_CLOSE: { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { SDL_DestroyWindow(window); } } break; } break; case SDL_KEYDOWN: switch (event->key.keysym.sym) { /* Add hotkeys here */ case SDLK_PRINTSCREEN: { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { for (i = 0; i < state->num_windows; ++i) { if (window == state->windows[i]) { ScreenShot(state->renderers[i]); } } } } break; case SDLK_c: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-C copy awesome text! */ SDL_SetClipboardText("SDL rocks!\nYou know it!"); printf("Copied text to clipboard\n"); } break; case SDLK_v: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-V paste awesome text! */ char *text = SDL_GetClipboardText(); if (*text) { printf("Clipboard: %s\n", text); } else { printf("Clipboard is empty\n"); } SDL_free(text); } break; case SDLK_g: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-G toggle grab */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window)); } } break; case SDLK_m: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-M maximize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_MAXIMIZED) { SDL_RestoreWindow(window); } else { SDL_MaximizeWindow(window); } } } break; case SDLK_r: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-R toggle mouse relative mode */ SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode()); } break; case SDLK_z: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Z minimize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_MinimizeWindow(window); } } break; case SDLK_RETURN: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Enter toggle fullscreen */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_FULLSCREEN) { SDL_SetWindowFullscreen(window, SDL_FALSE); } else { SDL_SetWindowFullscreen(window, SDL_TRUE); } } } break; case SDLK_ESCAPE: *done = 1; break; default: break; } break; case SDL_QUIT: *done = 1; break; } }
bool is_Mouse_captured( void ) { return SDL_TRUE == SDL_GetRelativeMouseMode(); }
void MainGame::processInput() { inputManager.Update(); SDL_Event evnt; float CAMERA_SPEED = 1.0f; while(SDL_PollEvent(&evnt)) { switch(evnt.type) { case SDL_QUIT: gameState=EXIT; break; case SDL_KEYDOWN: inputManager.PressKey(evnt.key.keysym.sym); break; case SDL_KEYUP: inputManager.ReleaseKey(evnt.key.keysym.sym); break; case SDL_MOUSEBUTTONDOWN: inputManager.PressKey(evnt.button.button); break; case SDL_MOUSEBUTTONUP: inputManager.ReleaseKey(evnt.button.button); break; case SDL_MOUSEMOTION: if(SDL_GetRelativeMouseMode() == SDL_TRUE) inputManager.SetMouseCoordsRel(evnt.motion.xrel, evnt.motion.yrel); else inputManager.SetMouseCoords(evnt.motion.x, evnt.motion.y); break; case SDL_WINDOWEVENT: switch(evnt.window.event) { case SDL_WINDOWEVENT_RESIZED: resize((int) evnt.window.data1, (int)evnt.window.data2); printf("%dx%d\n",(int) evnt.window.data1, (int)evnt.window.data2); break; } break; } } if(inputManager.IsKeyDown(SDLK_ESCAPE)) gameState = EXIT; if(inputManager.IsKeyDown(SDLK_LALT)) CAMERA_SPEED=10.0f; else if(inputManager.IsKeyDown(SDLK_LSHIFT)) CAMERA_SPEED=100.0f; else CAMERA_SPEED=1.0f; if(inputManager.IsKeyDownOnce(SDLK_F4)) window.Fullscreen(!window.IsFullscreen()); if(inputManager.IsKeyDownOnce(SDLK_v)) SDL_SetRelativeMouseMode(SDL_GetRelativeMouseMode()==SDL_TRUE ? SDL_FALSE:SDL_TRUE); if(inputManager.IsKeyDown(SDLK_w)) camera.Move(glm::vec3(0.0f, 0.0f, -CAMERA_SPEED)); if(inputManager.IsKeyDown(SDLK_s)) camera.Move(glm::vec3(0.0f, 0.0f, CAMERA_SPEED)); if(inputManager.IsKeyDown(SDLK_a)) camera.Move(glm::vec3(-CAMERA_SPEED, 0.0f, 0.0f)); if(inputManager.IsKeyDown(SDLK_d)) camera.Move(glm::vec3(CAMERA_SPEED, 0.0f, 0.0f)); if(inputManager.IsKeyDown(SDLK_SPACE)) camera.Move(glm::vec3(0.0f, CAMERA_SPEED, 0.0f)); if(inputManager.IsKeyDown(SDLK_c)) camera.Move(glm::vec3(0.0f, -CAMERA_SPEED, 0.0f)); if(inputManager.IsKeyDown(SDLK_UP)) sun->Update(camera, 0.3f); if(inputManager.IsKeyDown(SDLK_DOWN)) sun->Update(camera, -0.3f); if(SDL_GetRelativeMouseMode() == SDL_TRUE) { static const float MOUSE_SENSITIVITY = 0.2f; glm::vec2 mouseCoords = inputManager.GetMouseCoordsRel(); camera.Rotate(glm::vec3(mouseCoords.y*MOUSE_SENSITIVITY, mouseCoords.x*MOUSE_SENSITIVITY,0.0f)); } if(inputManager.IsKeyDownOnce(SDL_BUTTON_LEFT)) { int x = inputManager.GetMouseCoords().x; int y = inputManager.GetMouseCoords().y; GLbyte color[4]; GLfloat depth; GLuint index; glReadPixels(x, screenHeight - y - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, color); glReadPixels(x, screenHeight - y - 1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); glReadPixels(x, screenHeight - y - 1, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_INT, &index); printf("Clicked on pixel %d, %d, color %02hhx%02hhx%02hhx%02hhx, depth %f, stencil index %u\n", x, y, color[0], color[1], color[2], color[3], depth, index); glm::vec4 viewport = glm::vec4(0, 0, screenWidth, screenHeight); glm::vec3 wincoord = glm::vec3(x, screenHeight - y - 1, depth); glm::vec3 objcoord = glm::unProject(wincoord, camera.GetViewMatrix(), camera.GetProjectionMatrix(), viewport); printf("Coordinates in object space: %f, %f, %f\n", objcoord.x, objcoord.y, objcoord.z); modelManager->Position(objcoord.x, objcoord.y, objcoord.z); } if (inputManager.IsKeyDown(SDLK_h)) { if(inputManager.IsKeyDown(SDLK_RIGHTBRACKET)) modelManager->Height(CAMERA_SPEED); if(inputManager.IsKeyDown(SDLK_LEFTBRACKET)) modelManager->Height(-CAMERA_SPEED); } if (inputManager.IsKeyDown(SDLK_x)) { if(inputManager.IsKeyDown(SDLK_RIGHTBRACKET)) modelManager->Scale(CAMERA_SPEED); if(inputManager.IsKeyDown(SDLK_LEFTBRACKET)) modelManager->Scale(-CAMERA_SPEED); } if (inputManager.IsKeyDown(SDLK_r)) { if(inputManager.IsKeyDown(SDLK_RIGHTBRACKET)) modelManager->Rotate(CAMERA_SPEED); if(inputManager.IsKeyDown(SDLK_LEFTBRACKET)) modelManager->Rotate(-CAMERA_SPEED); } if (inputManager.IsKeyDownOnce(SDLK_COMMA)) modelManager->NextModel(); if (inputManager.IsKeyDownOnce(SDLK_PERIOD)) modelManager->NewModel(); if (inputManager.IsKeyDown(SDLK_LCTRL)) { if (inputManager.IsKeyDownOnce(SDLK_s)) modelManager->Save(); if (inputManager.IsKeyDownOnce(SDLK_LEFTBRACKET)) modelManager->PreviousSelection(); } }
bool input::is_mouse_held() const { const SDL_bool is_mouse_held = SDL_GetRelativeMouseMode(); return is_mouse_held ? true : false; }
bool SDL2EventHandler::relativeMouse() const { return SDL_GetRelativeMouseMode(); }
/******************************************************************** * isMouseCaptured() * Returns true if the mouse is being captured right now, false * if the mouse is not being captured right now. ********************************************************************/ bool Input :: isMouseCaptured() const { return SDL_GetRelativeMouseMode() == SDL_TRUE ? true : false; }