void input_grab( bool grab ) { // 1. always acquire and hide mouse if in fullscreen // 2. took this out cause a player asked... if there is issues add it back... // 3. don't remember who asked or why ? need to enable again. if( render_info.fullscreen ) { input_grabbed = true; #if SDL_VERSION_ATLEAST(2,0,0) SDL_SetWindowGrab( render_info.window, SDL_TRUE ); #else SDL_WM_GrabInput( SDL_GRAB_ON ); #endif SDL_ShowCursor( SDL_DISABLE ); return; } // window mode input_grabbed = grab; #ifdef LUA_BOT SDL_WM_GrabInput( SDL_GRAB_OFF ); SDL_ShowCursor( SDL_ENABLE ); #else #if SDL_VERSION_ATLEAST(2,0,0) SDL_SetWindowGrab( render_info.window, grab ? SDL_TRUE : SDL_FALSE ); #else SDL_WM_GrabInput( grab ? SDL_GRAB_ON : SDL_GRAB_OFF ); #endif SDL_ShowCursor( grab ? SDL_DISABLE : SDL_ENABLE ); #endif //DebugPrintf("input state: %s\n",(grab?"grabbed":"free")); }
static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window) { #if (USE_XINPUT) // Hack for wii-lightguns: // they stop working with a grabbed mouse; // even a ShowCursor(SDL_DISABLE) already does this. // To make the cursor disappear, we'll just set an empty cursor image. unsigned char data[]={0,0,0,0,0,0,0,0}; SDL_Cursor *c; c=SDL_CreateCursor(data, data, 8, 8, 0, 0); SDL_SetCursor(c); #else #if (SDLMAME_SDL2) // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) { //FIXME: SDL1.3: really broken: the whole SDL code // will only work correct with relative mouse movements ... //SDL_SetRelativeMouseMode if (!window->fullscreen && !sdlinput_should_hide_mouse(machine)) { SDL_ShowCursor(SDL_ENABLE); if (SDL_GetWindowGrab(window->sdl_window )) SDL_SetWindowGrab(window->sdl_window, SDL_FALSE); } else { SDL_ShowCursor(SDL_DISABLE); if (!SDL_GetWindowGrab(window->sdl_window)) SDL_SetWindowGrab(window->sdl_window, SDL_TRUE); } SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility } #else // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) { if ( window->fullscreen || sdlinput_should_hide_mouse(machine) ) { SDL_ShowCursor(SDL_DISABLE); if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) { SDL_WM_GrabInput(SDL_GRAB_ON); } } else { SDL_ShowCursor(SDL_ENABLE); if (SDL_WM_GrabInput(SDL_GRAB_QUERY)) { SDL_WM_GrabInput(SDL_GRAB_OFF); } } } #endif #endif }
/* =============== IN_ActivateMouse =============== */ static void IN_ActivateMouse() { if (!mouseAvailable || !SDL_WasInit(SDL_INIT_VIDEO)) { return; } if (!mouseActive) { SDL_ShowCursor(0); SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetWindowGrab(window, SDL_TRUE); IN_GobbleMotionEvents(); } // in_nograb makes no sense in fullscreen mode if (!cls.glconfig.isFullscreen) { if (in_nograb->modified || !mouseActive) { if (in_nograb->integer) { SDL_SetWindowGrab(window, SDL_FALSE); } else { SDL_SetWindowGrab(window, SDL_TRUE); } in_nograb->modified = false; } } mouseActive = true; }
/* =============== IN_ActivateMouse =============== */ static void IN_ActivateMouse( void ) { if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) ) return; if( !mouseActive ) { SDL_SetRelativeMouseMode( SDL_TRUE ); SDL_SetWindowGrab( SDL_window, 1 ); IN_GobbleMotionEvents( ); } // in_nograb makes no sense in fullscreen mode if( !Cvar_VariableIntegerValue("r_fullscreen") ) { if( in_nograb->modified || !mouseActive ) { if( in_nograb->integer ) SDL_SetWindowGrab( SDL_window, 0 ); else SDL_SetWindowGrab( SDL_window, 1 ); in_nograb->modified = qfalse; } } mouseActive = qtrue; }
void FLinuxCursor::Lock( const RECT* const Bounds ) { LinuxApplication->OnMouseCursorLock( Bounds != NULL ); // Lock/Unlock the cursor if ( Bounds == NULL ) { CursorClipRect = FIntRect(); SDL_SetWindowGrab( NULL, SDL_FALSE ); } else { SDL_SetWindowGrab( NULL, SDL_TRUE ); CursorClipRect.Min.X = FMath::TruncToInt(Bounds->left); CursorClipRect.Min.Y = FMath::TruncToInt(Bounds->top); CursorClipRect.Max.X = FMath::TruncToInt(Bounds->right) - 1; CursorClipRect.Max.Y = FMath::TruncToInt(Bounds->bottom) - 1; } FVector2D CurrentPosition = GetPosition(); if( UpdateCursorClipping( CurrentPosition ) ) { SetPosition( CurrentPosition.X, CurrentPosition.Y ); } }
void window_grabCursor(SDL_Window *window, bool grab) { if (grab) { SDL_ShowCursor(SDL_DISABLE); SDL_SetWindowGrab(window, SDL_TRUE); } else { SDL_ShowCursor(SDL_ENABLE); SDL_SetWindowGrab(window, SDL_FALSE); } }
void Window::ShowMouseCursor(bool value) { if (value) { SDL_ShowCursor(SDL_ENABLE); SDL_SetWindowGrab(window, SDL_FALSE); } else { SDL_ShowCursor(SDL_DISABLE); SDL_SetWindowGrab(window, SDL_TRUE); } }
static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_info *window) { #if (SDL_VERSION_ATLEAST(1,3,0)) // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)) { //FIXME: SDL1.3: really broken: the whole SDL code // will only work correct with relative mouse movements ... //SDL_SetRelativeMouseMode if (!window->fullscreen && !sdlinput_should_hide_mouse(machine)) { SDL_ShowCursor(SDL_ENABLE); if (SDL_GetWindowGrab(window->sdl_window )) SDL_SetWindowGrab(window->sdl_window, 0); } else { SDL_ShowCursor(SDL_DISABLE); if (!SDL_GetWindowGrab(window->sdl_window)) SDL_SetWindowGrab(window->sdl_window, 1); } SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility } #else // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)) { if ( window->fullscreen || sdlinput_should_hide_mouse(machine) ) { SDL_ShowCursor(SDL_DISABLE); if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) { SDL_WM_GrabInput(SDL_GRAB_ON); } } else { SDL_ShowCursor(SDL_ENABLE); if (SDL_WM_GrabInput(SDL_GRAB_QUERY)) { SDL_WM_GrabInput(SDL_GRAB_OFF); } } } #endif }
/** * Init Screen bitmap and buffers/tables needed for ST to PC screen conversion */ void Screen_Init(void) { int i; /* Clear frame buffer structures and set current pointer */ memset(FrameBuffers, 0, NUM_FRAMEBUFFERS * sizeof(FRAMEBUFFER)); /* Allocate previous screen check workspace. We are going to double-buffer a double-buffered screen. Oh. */ for (i = 0; i < NUM_FRAMEBUFFERS; i++) { FrameBuffers[i].pNEXTScreen = malloc(((1024)/8)*768); FrameBuffers[i].pNEXTScreenCopy = malloc(((1024)/8)*768); if (!FrameBuffers[i].pNEXTScreen || !FrameBuffers[i].pNEXTScreenCopy) { fprintf(stderr, "Failed to allocate frame buffer memory.\n"); exit(-1); } } pFrameBuffer = &FrameBuffers[0]; /* Set initial window resolution */ bInFullScreen = ConfigureParams.Screen.bFullScreen; Screen_SetResolution(); if (bGrabMouse) { SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetWindowGrab(sdlWindow, SDL_TRUE); } Video_SetScreenRasters(); /* Set rasters ready for first screen */ Screen_CreatePalette(); /* Configure some SDL stuff: */ SDL_ShowCursor(SDL_DISABLE); }
/** * Pause emulation, stop sound. 'visualize' should be set true, * unless unpause will be called immediately afterwards. * * @return true if paused now, false if was already paused */ bool Main_PauseEmulation(bool visualize) { if ( !bEmulationActive ) return false; //Audio_Output_Enable(false); bEmulationActive = false; if (visualize) { if (nFirstMilliTick) { int interval = Main_GetTicks() - nFirstMilliTick; static float previous; float current; current = (1000.0 * nVBLCount) / interval; printf("SPEED: %.1f VBL/s (%d/%.1fs), diff=%.1f%%\n", current, nVBLCount, interval/1000.0, previous>0.0 ? 100*(current-previous)/previous : 0.0); nVBLCount = nFirstMilliTick = 0; previous = current; } Statusbar_AddMessage("Emulation paused", 100); /* make sure msg gets shown */ Statusbar_Update(sdlscrn); if (bGrabMouse && !bInFullScreen) { /* Un-grab mouse pointer in windowed mode */ SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetWindowGrab(sdlWindow, SDL_FALSE); } } return true; }
static void IN_GrabMouse(qboolean grab, qboolean relative) { static qboolean mouse_grabbed = qfalse, mouse_relative = qfalse; int relative_result = 0; if (relative == !mouse_relative) { SDL_ShowCursor(!relative); if ((relative_result = SDL_SetRelativeMouseMode((SDL_bool)relative)) != 0) { // FIXME: this happens on some systems (IR4) if (relative_result == -1) { Com_Error(ERR_FATAL, "Setting relative mouse location fails (system not supported)\n"); } else { Com_Error(ERR_FATAL, "Setting relative mouse location fails: %s\n", SDL_GetError()); } } mouse_relative = relative; } if (grab == !mouse_grabbed) { SDL_SetWindowGrab(mainScreen, (SDL_bool)grab); mouse_grabbed = grab; } }
static void sdl_grab_end(struct sdl2_console *scon) { SDL_SetWindowGrab(scon->real_window, SDL_FALSE); gui_grab = 0; sdl_show_cursor(); sdl_update_caption(scon); }
/* =============== IN_DeactivateMouse =============== */ static void IN_DeactivateMouse( void ) { if( !SDL_WasInit( SDL_INIT_VIDEO ) ) return; // Always show the cursor when the mouse is disabled, // but not when fullscreen if( !Cvar_VariableIntegerValue("r_fullscreen") ) SDL_ShowCursor( 1 ); if( !mouseAvailable ) return; if( mouseActive ) { IN_GobbleMotionEvents( ); SDL_SetWindowGrab( SDL_window, 0 ); SDL_SetRelativeMouseMode( SDL_FALSE ); // Don't warp the mouse unless the cursor is within the window if( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_MOUSE_FOCUS ) SDL_WarpMouseInWindow( SDL_window, cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 ); mouseActive = qfalse; } }
void GLimp_GrabInput( int flags ) { bool grab = flags & GRAB_ENABLE; if( grab && ( flags & GRAB_REENABLE ) ) grab = false; if( flags & GRAB_SETSTATE ) grabbed = grab; if( in_nograb.GetBool() ) grab = false; if( !window ) { common->Warning( "GLimp_GrabInput called without window" ); return; } #if SDL_VERSION_ATLEAST(2, 0, 0) // DG: disabling the cursor is now done once in GLimp_Init() because it should always be disabled // DG: check for GRAB_ENABLE instead of GRAB_HIDECURSOR because we always wanna hide it SDL_SetRelativeMouseMode( flags & GRAB_ENABLE ? SDL_TRUE : SDL_FALSE ); SDL_SetWindowGrab( window, grab ? SDL_TRUE : SDL_FALSE ); #else // DG end SDL_WM_GrabInput( grab ? SDL_GRAB_ON : SDL_GRAB_OFF ); #endif }
void video_start_window( ) { if ( SDL_VideoInit(video_options.driver) ) { fatal( "%s", SDL_GetError() ); } video_window = SDL_CreateWindow( video_options.title, video_options.position.x, video_options.position.y, video_options.size.w, video_options.size.h, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI ); if ( video_window == NULL ) { fatal( "%s", SDL_GetError() ); } video_renderer = SDL_CreateRenderer( video_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ); if ( video_renderer == NULL ) { fatal( "%s", SDL_GetError() ); } SDL_SetRenderDrawBlendMode( video_renderer, SDL_BLENDMODE_BLEND ); SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ); SDL_RenderSetLogicalSize( video_renderer, video_options.logical_size.w, video_options.logical_size.h ); SDL_SetWindowGrab( video_window, video_options.grab_input ); if ( video_options.set_mode ) { SDL_SetWindowDisplayMode( video_window, &video_options.mode ); } else { SDL_SetWindowDisplayMode( video_window, NULL ); } SDL_SetWindowFullscreen( video_window, video_options.fullscreen ); }
void video_set_input_grabbed( int input_grabbed ) { video_options.grab_input = input_grabbed; if ( video_window != NULL ) { SDL_SetWindowGrab( video_window, input_grabbed ); } }
SDL_Window* window_create(int width, int height, const char* title) { SDL_Window* window; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "%s\n", SDL_GetError()); return NULL; } SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL); SDL_ShowCursor(SDL_DISABLE); SDL_SetWindowGrab(window, SDL_TRUE); SDL_WarpMouseInWindow(window, width/2, height/2); if (window == NULL) { fprintf(stderr, "Could not create window: %s\n", SDL_GetError()); SDL_Quit(); return NULL; } SDL_GLContext context = SDL_GL_CreateContext(window); // TODO: destroy context on fail / on program ending glClearColor(0.0f, 0.0f, 0.0f, 0.0f); return window; }
void fatal(const char *s, ...) // failure exit { static int errors = 0; errors++; if(errors <= 2) // print up to one extra recursive error { defvformatstring(msg,s,s); logoutf("%s", msg); if(errors <= 1) // avoid recursion { if(SDL_WasInit(SDL_INIT_VIDEO)) { if(screen) SDL_SetWindowGrab(screen, SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE); SDL_ShowCursor(SDL_TRUE); cleargamma(); } #ifdef WIN32 MessageBox(NULL, msg, "Cube 2: Sauerbraten fatal error", MB_OK|MB_SYSTEMMODAL); #endif SDL_Quit(); } } exit(EXIT_FAILURE); }
void GLimp_GrabInput(int flags) { bool grab = flags & GRAB_ENABLE; if ( grab && (flags & GRAB_REENABLE) ) grab = false; if ( flags & GRAB_SETSTATE ) grabbed = grab; if ( in_nograb.GetBool() ) grab = false; if ( !SDL_window ) { common->Warning("GLimp_GrabInput called without window"); return; } #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_ShowCursor(flags & GRAB_HIDECURSOR ? SDL_DISABLE : SDL_ENABLE); SDL_SetRelativeMouseMode(flags & GRAB_HIDECURSOR ? SDL_TRUE : SDL_FALSE); SDL_SetWindowGrab(SDL_window, grab ? SDL_TRUE : SDL_FALSE); #else SDL_ShowCursor(flags & GRAB_HIDECURSOR ? SDL_DISABLE : SDL_ENABLE); SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); #endif }
static void set_screen_grabbed(int grabbed) { int w, h; if(grabbed) { SDL_SetWindowGrab(window, SDL_TRUE); SDL_GetWindowSize(window, &w, &h); SDL_WarpMouseInWindow(window, w/2, h/2); SDL_ShowCursor(0); screen_grabbed = 1; } else { SDL_SetWindowGrab(window, SDL_FALSE); SDL_ShowCursor(1); screen_grabbed = 0; } }
/// cleans up game memory and SDL at exit void cleanup() { extern void clear_command(); extern void clear_console(); extern void clear_mdls(); extern void clear_sound(); recorder::stop(); cleanupserver(); /// "Use this function to set a window's input grab mode." /// https://wiki.libsdl.org/SDL_SetWindowGrab if(screen) SDL_SetWindowGrab(screen, SDL_FALSE); /// "Use this function to set relative mouse mode." /// https://wiki.libsdl.org/SDL_SetRelativeMouseMode SDL_SetRelativeMouseMode(SDL_FALSE); /// "Use this function to toggle whether or not the cursor is shown." /// https://wiki.libsdl.org/SDL_ShowCursor SDL_ShowCursor(SDL_TRUE); cleargamma(); /// free octree memory freeocta(worldroot); clear_command(); clear_console(); clear_mdls(); clear_sound(); closelogfile(); /// "Use this function to clean up all initialized subsystems. You should call it upon all exit conditions." /// https://wiki.libsdl.org/SDL_Quit SDL_Quit(); }
static void sdl_grab_start(struct sdl2_console *scon) { QemuConsole *con = scon ? scon->dcl.con : NULL; if (!con || !qemu_console_is_graphic(con)) { return; } /* * If the application is not active, do not try to enter grab state. This * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the * application (SDL bug). */ if (!(SDL_GetWindowFlags(scon->real_window) & SDL_WINDOW_INPUT_FOCUS)) { return; } if (guest_cursor) { SDL_SetCursor(guest_sprite); if (!qemu_input_is_absolute() && !absolute_enabled) { SDL_WarpMouseInWindow(scon->real_window, guest_x, guest_y); } } else { sdl_hide_cursor(); } SDL_SetWindowGrab(scon->real_window, SDL_TRUE); gui_grab = 1; sdl_update_caption(scon); }
void InputWrapper::updateMouseSettings() { mGrabPointer = mWantGrab && mMouseInWindow && mWindowHasFocus; SDL_SetWindowGrab(mSDLWindow, mGrabPointer && mAllowGrab ? SDL_TRUE : SDL_FALSE); SDL_ShowCursor(mWantMouseVisible || !mWindowHasFocus); bool relative = mWantRelative && mMouseInWindow && mWindowHasFocus; if(mMouseRelative == relative) return; mMouseRelative = relative; mWrapPointer = false; //eep, wrap the pointer manually if the input driver doesn't support //relative positioning natively int success = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE); if(relative && success != 0) mWrapPointer = true; //now remove all mouse events using the old setting from the queue SDL_PumpEvents(); SDL_FlushEvent(SDL_MOUSEMOTION); }
static void GrabMouse(qbool grab, qbool raw) { if ((grab && mouse_active && raw == in_raw.integer) || (!grab && !mouse_active) || !mouseinitialized || !sdl_window) return; if (!r_fullscreen.integer && in_grab_windowed_mouse.integer == 0) { if (!mouse_active) return; grab = 0; } // set initial position if (!raw && grab) { SDL_WarpMouseInWindow(sdl_window, glConfig.vidWidth / 2, glConfig.vidHeight / 2); old_x = glConfig.vidWidth / 2; old_y = glConfig.vidHeight / 2; } SDL_SetWindowGrab(sdl_window, grab ? SDL_TRUE : SDL_FALSE); SDL_SetRelativeMouseMode((raw && grab) ? SDL_TRUE : SDL_FALSE); SDL_GetRelativeMouseState(NULL, NULL); SDL_ShowCursor(grab ? SDL_DISABLE : SDL_ENABLE); SDL_SetCursor(NULL); /* Force rewrite of it */ mouse_active = grab; }
static void IN_DeactivateMouse(void) { if (!SDL_WasInit(SDL_INIT_VIDEO)) { return; } SDL_SetRelativeMouseMode( SDL_FALSE ); // Always show the cursor when the mouse is disabled, // but not when fullscreen if (!Cvar_VariableIntegerValue("r_fullscreen")) SDL_ShowCursor(1); if (!mouseAvailable) { return; } if (mouseActive) { IN_GobbleMotionEvents(); SDL_SetWindowGrab( SDLvidscreen, SDL_FALSE ); mouseActive = qfalse; } }
void ApplicationContextSDL::setWindowGrab(NativeWindowType* win, bool _grab) { SDL_bool grab = SDL_bool(_grab); SDL_SetWindowGrab(win, grab); SDL_SetRelativeMouseMode(grab); }
static void post_main_loop(void) { /* We want to improve the transitioning from FS-UAE back to e.g. * FS-UAE Game Center - avoid blinking cursor - so we try to move it (to * the bottom right of the screen). This probably requires that the * cursor is not grabbed (SDL often keeps the cursor in the center of the * screen then). */ if (g_fs_emu_video_fullscreen) { if (SDL_getenv("FSGS_RETURN_CURSOR_TO") && SDL_getenv("FSGS_RETURN_CURSOR_TO")[0]) { int x = -1; int y = -1; sscanf(SDL_getenv("FSGS_RETURN_CURSOR_TO"), "%d,%d", &x, &y); if (x != -1 && y != -1) { #if 0 fs_log("trying to move mouse cursor to x=%d y=%d\n", x, y); #endif Uint8 data[] = "\0"; SDL_SetWindowGrab(g_fs_ml_window, SDL_FALSE); /* Setting invisible cursor so we won't see it when we * enable the cursor in order to move it. */ SDL_Cursor *cursor = SDL_CreateCursor(data, data, 8, 1, 0, 0); SDL_SetCursor(cursor); SDL_ShowCursor(SDL_ENABLE); SDL_WarpMouseInWindow(g_fs_ml_window, x, y); } } } }
void InputWrapper::updateMouseSettings() { mGrabPointer = mWantGrab && mMouseInWindow && mWindowHasFocus; SDL_SetWindowGrab(mSDLWindow, mGrabPointer && mAllowGrab ? SDL_TRUE : SDL_FALSE); SDL_ShowCursor(mWantMouseVisible || !mWindowHasFocus); bool relative = mWantRelative && mMouseInWindow && mWindowHasFocus; if(mMouseRelative == relative) return; mMouseRelative = relative; mWrapPointer = false; // eep, wrap the pointer manually if the input driver doesn't support // relative positioning natively // also use wrapping if no-grab was specified in options (SDL_SetRelativeMouseMode // appears to eat the mouse cursor when pausing in a debugger) bool success = mAllowGrab && SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE) == 0; if(relative && !success) mWrapPointer = true; //now remove all mouse events using the old setting from the queue SDL_PumpEvents(); SDL_FlushEvent(SDL_MOUSEMOTION); }
Window::Window( const std::string& title, unsigned int width, unsigned int height, bool fullscreen ) { Uint32 flags = SDL_WINDOW_OPENGL; if ( fullscreen ) { flags |= SDL_WINDOW_FULLSCREEN; } m_pWindow = SDL_CreateWindow( title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags ); m_Width = width; m_Height = height; if ( m_pWindow == nullptr ) { Genesis::FrameWork::GetLogger()->LogError( "Failed to create window: %s", SDL_GetError() ); } m_Context = SDL_GL_CreateContext( m_pWindow ); SetupSwapInterval(); SetupBackground(); SDL_SetWindowGrab( m_pWindow, SDL_TRUE ); }
void SDL2WindowBackend::lockCursor(bool lock) { if(isOpen()) { SDL_SetRelativeMouseMode((SDL_bool)lock); SDL_SetWindowGrab(mWindow, (SDL_bool)lock); } }