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


C++ SDL_GetAppState函数代码示例

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


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

示例1: native_drainevents

static int native_drainevents (SADisplay *display, VisEventQueue *eventqueue)
{
        SDLNative *native = SDL_NATIVE (display->native);
        SDL_Event event;

        /* Visible or not */
        if (((SDL_GetAppState () & SDL_APPACTIVE) == 0) && (native->active == TRUE)) {
                native->active = FALSE;
                visual_event_queue_add_visibility (eventqueue, FALSE);
        } else if (((SDL_GetAppState () & SDL_APPACTIVE) != 0) && (native->active == FALSE)) {
                native->active = TRUE;
                visual_event_queue_add_visibility (eventqueue, TRUE);
        }

        /* Events */
        while (SDL_PollEvent (&event)) {

                switch (event.type) {
                        case SDL_KEYUP:
                                visual_event_queue_add_keyboard (eventqueue, event.key.keysym.sym, event.key.keysym.mod,
                                                                 VISUAL_KEY_UP);
                                break;

                        case SDL_KEYDOWN:
                                visual_event_queue_add_keyboard (eventqueue, event.key.keysym.sym, event.key.keysym.mod,
                                                                 VISUAL_KEY_DOWN);
                                break;

                        case SDL_VIDEORESIZE:
                                visual_event_queue_add_resize (eventqueue, display->screen, event.resize.w, event.resize.h);

                                native_create (display, display->screen->depth, NULL, event.resize.w, event.resize.h, native->resizable);
                                break;

                        case SDL_MOUSEMOTION:
                                visual_event_queue_add_mousemotion (eventqueue, event.motion.x, event.motion.y);
                                break;

                        case SDL_MOUSEBUTTONDOWN:
                                visual_event_queue_add_mousebutton (eventqueue, event.button.button, VISUAL_MOUSE_DOWN,
                                                                    event.button.x, event.button.y);
                                break;

                        case SDL_MOUSEBUTTONUP:
                                visual_event_queue_add_mousebutton (eventqueue, event.button.button, VISUAL_MOUSE_UP,
                                                                    event.button.x, event.button.y);
                                break;

                        case SDL_QUIT:
                                visual_event_queue_add_quit (eventqueue, FALSE);
                                break;

                        default:
                                break;
                }
        }

        return 0;
}
开发者ID:Libvisual,项目名称:DroidVisuals,代码行数:59,代码来源:sdl_driver.c

示例2: IN_DeactivateMouse

/*
===============
IN_DeactivateMouse
===============
*/
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( !r_fullscreen->integer )
	{
		if( ( Key_GetCatcher( ) == KEYCATCH_UI ) &&
				( SDL_GetAppState( ) & (SDL_APPMOUSEFOCUS|SDL_APPINPUTFOCUS) ) == (SDL_APPMOUSEFOCUS|SDL_APPINPUTFOCUS) )
			SDL_ShowCursor( 0 );
		else
			SDL_ShowCursor( 1 );
	}

	if( !mouseAvailable )
		return;

#ifdef MACOS_X_ACCELERATION_HACK
	if (mouseActive) // mac os x mouse accel hack
	{
		if(originalMouseSpeed != -1.0)
		{
			io_connect_t mouseDev = IN_GetIOHandle();
			if(mouseDev != 0)
			{
				Com_Printf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
				if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
					Com_Printf("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
				IOServiceClose(mouseDev);
			}
			else
				Com_Printf("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
		}
	}
#endif

	if( mouseActive )
	{
		IN_GobbleMotionEvents( );

		SDL_WM_GrabInput( SDL_GRAB_OFF );

		// Don't warp the mouse unless the cursor is within the window
		if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
		{
			int x, y;
			x = glConfig.vidWidth / 2, y = glConfig.vidHeight / 2;
			SDL_WarpMouse( x, y );
		}

		mouseActive = qfalse;
	}
}
开发者ID:AlienHoboken,项目名称:Tremulous-Z-Server,代码行数:60,代码来源:sdl_input.c

示例3: SDL_GetAppState

bool SDLWindow::hasFocus() const {
    uint8 s = SDL_GetAppState();
    
    return ((s & SDL_APPMOUSEFOCUS) != 0) &&
           ((s & SDL_APPINPUTFOCUS) != 0) &&
           ((s & SDL_APPACTIVE) != 0);
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:7,代码来源:SDLWindow.cpp

示例4: UNUSED

BOOL System::Update(f32 dt)
{
	UNUSED(dt);

	u8 state = SDL_GetAppState();
	if ((state & SDL_APPACTIVE) != SDL_APPACTIVE || (state & SDL_APPINPUTFOCUS) != SDL_APPINPUTFOCUS)
	{
		if (!this->bSleeping)
		{
			this->bSleeping = TRUE;

			EventSystem ev;
			this->SendEventSleep(&ev);
		}
	}
	else
	{
		if (this->bSleeping)
		{
			this->bSleeping = FALSE;

			EventSystem ev;
			this->SendEventSleep(&ev);
		}
	}

	//this->WaitForRetrace(this->iFrameRate);
	return TRUE;
}
开发者ID:fungos,项目名称:seed1,代码行数:29,代码来源:SdlSystem.cpp

示例5: UpdateFocus

static void UpdateFocus(void)
{
	static bool curfocus = false;

	SDL_PumpEvents();

	Uint8 state = SDL_GetAppState();

	// We should have input (keyboard) focus and be visible (not minimized)
	havefocus = (state & SDL_APPINPUTFOCUS) && (state & SDL_APPACTIVE);

	// [CG] Handle focus changes, this is all necessary to avoid repeat events.
	// [AM] This fixes the tab key sticking when alt-tabbing away from the
	//      program, but does not seem to solve the problem of tab being 'dead'
	//      for one keypress after switching back.
	if (curfocus != havefocus)
	{
		if (havefocus)
		{
			SDL_Event event;
			while (SDL_PollEvent(&event))
			{
				// Do nothing
			}
		}

		curfocus = havefocus;
	}
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:29,代码来源:i_input.cpp

示例6: DIB_GenerateMouseMotionEvent

static void DIB_GenerateMouseMotionEvent(_THIS)
{
	extern int mouse_relative;
	extern int posted;

	POINT mouse;
	GetCursorPos( &mouse );

	if ( mouse_relative ) {
		POINT center;
		center.x = (SDL_VideoSurface->w/2);
		center.y = (SDL_VideoSurface->h/2);
		ClientToScreen(SDL_Window, &center);

		mouse.x -= (Sint16)center.x;
		mouse.y -= (Sint16)center.y;
		if ( mouse.x || mouse.y ) {
			SetCursorPos(center.x, center.y);
			posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y);
		}
	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
		ScreenToClient(SDL_Window, &mouse);
#ifdef SDL_VIDEO_DRIVER_GAPI
       if (SDL_VideoSurface && this->hidden->gapiInfo)
			GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y);
#endif
		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
	}
}
开发者ID:Brennan123,项目名称:SDL-1.2,代码行数:29,代码来源:SDL_dibevents.c

示例7: SDL_VERSION_ATLEAST

bool MouseCursor::hasFocus() const {
#if SDL_VERSION_ATLEAST(2,0,0)
    return (SDL_GetMouseFocus() == display.sdl_window);
#else
    return (SDL_GetAppState() & SDL_APPMOUSEFOCUS);
#endif
}
开发者ID:acaudwell,项目名称:Core,代码行数:7,代码来源:mousecursor.cpp

示例8: get_display

void controller_base::play_slice(bool is_delay_enabled)
{
	display& gui = get_display();

	CKey key;
	events::pump();
	events::raise_process_event();
	events::raise_draw_event();

	slice_before_scroll();

	int mousex, mousey;
	Uint8 mouse_flags = SDL_GetMouseState(&mousex, &mousey);
	bool was_scrolling = scrolling_;
	scrolling_ = handle_scroll(key, mousex, mousey, mouse_flags);

	get_display().draw();

	// be nice when window is not visible
	// NOTE should be handled by display instead, to only disable drawing
	if (is_delay_enabled && (SDL_GetAppState(gui.video().getWindow()) & SDL_APPACTIVE) == 0) {
		get_display().delay(200);
	}

	if (!scrolling_ && was_scrolling) {
#if (defined(__APPLE__) && TARGET_OS_IPHONE) || defined(ANDROID)
	
#else
		// scrolling ended, update the cursor and the brightened hex
		get_mouse_handler_base().mouse_update(browse_);
#endif
	}
	slice_end();
}
开发者ID:suxinde2009,项目名称:Rose,代码行数:34,代码来源:controller_base.cpp

示例9: IN_Frame

/*
===============
IN_Frame
===============
*/
void IN_Frame( void )
{
	qboolean loading;

	IN_JoyMove( );
	IN_ProcessEvents( );

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading = ( clc.state != CA_DISCONNECTED && clc.state != CA_ACTIVE );

	if( !Cvar_VariableIntegerValue("r_fullscreen") && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
	{
		// Console is down in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !Cvar_VariableIntegerValue("r_fullscreen") && loading )
	{
		// Loading in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
	{
		// Window not got focus
		IN_DeactivateMouse( );
	}
	else
		IN_ActivateMouse( );

	/* in case we had to delay actual restart of video system... */
	if ( (vidRestartTime != 0) && (vidRestartTime < Sys_Milliseconds()) )
	{
		vidRestartTime = 0;
		Cbuf_AddText( "vid_restart\n" );
	}
}
开发者ID:0culus,项目名称:ioq3,代码行数:40,代码来源:sdl_input.c

示例10: AppMinimized

void AppMinimized(void)
{
    stat("Game minimized or lost focus--pausing...");

#ifdef _SDL_MIXER
    Mix_Pause(-1);
    Mix_PauseMusic();
#else
    SDL_PauseAudio(1);
#endif

    for(;;)
    {
        if ((SDL_GetAppState() & VISFLAGS) == VISFLAGS)
        {
            break;
        }

        input_poll();
        SDL_Delay(20);
    }
#ifdef _SDL_MIXER
    Mix_Resume(-1);
    Mix_ResumeMusic();
#else
    SDL_PauseAudio(0);
#endif
    stat("Focus regained, resuming play...");
}
开发者ID:EXL,项目名称:NXEngine,代码行数:29,代码来源:main.cpp

示例11: IN_Frame

/*
===============
IN_Frame
===============
*/
void IN_Frame( void )
{
	qboolean loading;

	IN_JoyMove( );
	IN_ProcessEvents( );

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading = !!( cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE );

	if( !r_fullscreen->integer && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
	{
		// Console is down in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !r_fullscreen->integer && loading )
	{
		// Loading in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
	{
		// Window not got focus
		IN_DeactivateMouse( );
	}
	else
		IN_ActivateMouse( );
}
开发者ID:AbandonedCart,项目名称:XperiaPlayNative,代码行数:33,代码来源:sdl_input.c

示例12: MenuLoop

void MenuLoop(MenuSystem *menu)
{
	assert(menu->numExitTypes > 0);
	for (;; SDL_Delay(10))
	{
		MusicSetPlaying(&gSoundDevice, SDL_GetAppState() & SDL_APPINPUTFOCUS);
		// Input
		InputPoll(menu->inputDevices, SDL_GetTicks());
		// Update
		if (menu->current->type == MENU_TYPE_KEYS &&
			menu->current->u.normal.changeKeyMenu != NULL)
		{
			MenuProcessChangeKey(menu->current);
		}
		else
		{
			int cmd = GetMenuCmd(gPlayerDatas);
			MenuProcessCmd(menu, cmd);
		}
		if (MenuIsExit(menu))
		{
			break;
		}
		// Draw
		GraphicsBlitBkg(menu->graphics);
		ShowControls();
		MenuDisplay(menu);
		BlitFlip(menu->graphics, &gConfig.Graphics);
	}
}
开发者ID:MrDesTinY,项目名称:cdogs-sdl,代码行数:30,代码来源:menu.c

示例13: DIB_SetGammaRamp

int DIB_SetGammaRamp(_THIS, Uint16 *ramp)
{
#ifdef NO_GAMMA_SUPPORT
	SDL_SetError("SDL compiled without gamma ramp support");
	return -1;
#else
	HDC hdc;
	BOOL succeeded;

	/* Set the ramp for the display */
	if ( ! gamma_saved ) {
		gamma_saved = (WORD *)malloc(3*256*sizeof(*gamma_saved));
		if ( ! gamma_saved ) {
			SDL_OutOfMemory();
			return -1;
		}
		hdc = GetDC(SDL_Window);
		GetDeviceGammaRamp(hdc, gamma_saved);
		ReleaseDC(SDL_Window, hdc);
	}
	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
		hdc = GetDC(SDL_Window);
		succeeded = SetDeviceGammaRamp(hdc, ramp);
		ReleaseDC(SDL_Window, hdc);
	} else {
		succeeded = TRUE;
	}
	return succeeded ? 0 : -1;
#endif /* !NO_GAMMA_SUPPORT */
}
开发者ID:Goettsch,项目名称:game-editor,代码行数:30,代码来源:SDL_dibvideo.c

示例14: drawCursor

/**
    This function draws the cursor to the screen. The coordinate is read from
    the two global variables drawnMouseX and drawnMouseY.
*/
void drawCursor() {
    if(!(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) {
        return;
    }



	SDL_Surface* surface = pGFXManager->getUIGraphic(cursorFrame);

    SDL_Rect dest = { drawnMouseX, drawnMouseY, surface->w, surface->h };

	//reposition image so pointing on right spot

	if (cursorFrame == UI_CursorRight) {
		dest.x -= dest.w/2;
	} else if (cursorFrame == UI_CursorDown) {
		dest.y -= dest.h/2;
	}

	if ((cursorFrame == UI_CursorAttack_Zoomlevel0) || (cursorFrame == UI_CursorMove_Zoomlevel0)) {
		dest.x -= dest.w/2;
		dest.y -= dest.h/2;
	}

	if(SDL_BlitSurface(surface, NULL, screen, &dest) != 0) {
        fprintf(stderr,"drawCursor(): %s\n", SDL_GetError());
	}
}
开发者ID:binarycrusader,项目名称:dunelegacy,代码行数:32,代码来源:sand.cpp

示例15: DIB_GenerateMouseMotionEvent

static void DIB_GenerateMouseMotionEvent(void)
{
	extern int mouse_relative;
	extern int posted;

	POINT mouse;
	GetCursorPos( &mouse );

	if ( mouse_relative ) {
		POINT center;
		center.x = (SDL_VideoSurface->w/2);
		center.y = (SDL_VideoSurface->h/2);
		ClientToScreen(SDL_Window, &center);

		mouse.x -= (Sint16)center.x;
		mouse.y -= (Sint16)center.y;
		if ( mouse.x || mouse.y ) {
			SetCursorPos(center.x, center.y);
			posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y);
		}
	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
		ScreenToClient(SDL_Window, &mouse);
#ifdef _WIN32_WCE
		if (SDL_VideoSurface)
			GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &mouse.x, &mouse.y);
#endif
		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
	}
}
开发者ID:RDCH106,项目名称:n64oid,代码行数:29,代码来源:SDL_dibevents.c


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