当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_SetWindowGrab函数代码示例

本文整理汇总了C++中SDL_SetWindowGrab函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SetWindowGrab函数的具体用法?C++ SDL_SetWindowGrab怎么用?C++ SDL_SetWindowGrab使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_SetWindowGrab函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: input_grab

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"));
}
开发者ID:DUANISTON,项目名称:forsaken,代码行数:33,代码来源:input_sdl.c

示例2: sdlwindow_update_cursor_state

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
}
开发者ID:fesh0r,项目名称:old-mame,代码行数:60,代码来源:window.c

示例3: IN_ActivateMouse

/*
===============
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;
}
开发者ID:Kangz,项目名称:Unvanquished,代码行数:34,代码来源:sdl_input.cpp

示例4: IN_ActivateMouse

/*
===============
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;
}
开发者ID:pzychotic,项目名称:ioq3,代码行数:34,代码来源:sdl_input.c

示例5: FIntRect

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 );
	}
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:25,代码来源:LinuxCursor.cpp

示例6: window_grabCursor

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);
	}
}
开发者ID:lcthums,项目名称:C3D,代码行数:10,代码来源:window.c

示例7: SDL_ShowCursor

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);
	}
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:13,代码来源:window.cpp

示例8: sdlwindow_update_cursor_state

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
}
开发者ID:DarrenBranford,项目名称:MAME4iOS,代码行数:49,代码来源:window.c

示例9: Screen_Init

/**
 * 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);
}
开发者ID:jsdf,项目名称:previous,代码行数:38,代码来源:screen.c

示例10: Main_PauseEmulation

/**
 * 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;
}
开发者ID:jsdf,项目名称:previous,代码行数:41,代码来源:main.c

示例11: IN_GrabMouse

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;
	}
}
开发者ID:raedwulf,项目名称:etlegacy,代码行数:29,代码来源:sdl_input.c

示例12: sdl_grab_end

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);
}
开发者ID:AmesianX,项目名称:panda,代码行数:7,代码来源:sdl2.c

示例13: IN_DeactivateMouse

/*
===============
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;
    }
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:32,代码来源:sdl_input.c

示例14: GLimp_GrabInput

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
}
开发者ID:asd55,项目名称:RBDOOM-3-BFG,代码行数:30,代码来源:sdl_glimp.cpp

示例15: video_start_window

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 );
}
开发者ID:Protovision,项目名称:moonbase,代码行数:33,代码来源:video.c


注:本文中的SDL_SetWindowGrab函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。