コード例 #1
0
ファイル: StepMania.cpp プロジェクト: augustg/stepmania-3.9
static void BoostAppPri()
{
	if(!ChangeAppPri())
		return;

#ifdef _WINDOWS
	/* We just want a slight boost, so we don't skip needlessly if something happens
	 * in the background.  We don't really want to be high-priority--above normal should
	 * be enough.  However, ABOVE_NORMAL_PRIORITY_CLASS is only supported in Win2000
	 * and later. */
	OSVERSIONINFO version;
	version.dwOSVersionInfoSize=sizeof(version);
	if(!GetVersionEx(&version))
	{
		LOG->Warn(werr_ssprintf(GetLastError(), "GetVersionEx failed"));
		return;
	}

#ifndef ABOVE_NORMAL_PRIORITY_CLASS
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#endif

	DWORD pri = HIGH_PRIORITY_CLASS;
	if(version.dwMajorVersion >= 5)
		pri = ABOVE_NORMAL_PRIORITY_CLASS;

	/* Be sure to boost the app, not the thread, to make sure the
	 * sound thread stays higher priority than the main thread. */
	SetPriorityClass(GetCurrentProcess(), pri);
#endif
}
コード例 #2
0
ファイル: StepMania.cpp プロジェクト: augustg/stepmania-3.9
static void RestoreAppPri()
{
	if(!ChangeAppPri())
		return;

#ifdef _WINDOWS
	SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
#endif
}
コード例 #3
0
ファイル: GameLoop.cpp プロジェクト: goofwear/stepmania
static void CheckFocus()
{
	if( !HOOKS->AppFocusChanged() )
		return;

	/* If we lose focus, we may lose input events, especially key releases. */
	INPUTFILTER->Reset();

	if( ChangeAppPri() )
	{
		if( HOOKS->AppHasFocus() )
			HOOKS->BoostPriority();
		else
			HOOKS->UnBoostPriority();
	}
}
コード例 #4
0
ファイル: GameLoop.cpp プロジェクト: goofwear/stepmania
void GameLoop::RunGameLoop()
{
	/* People may want to do something else while songs are loading, so do
	 * this after loading songs. */
	if( ChangeAppPri() )
		HOOKS->BoostPriority();

	while( !ArchHooks::UserQuit() )
	{
		if( !g_sNewTheme.empty() )
			DoChangeTheme();

		/*
		 * Update
		 */
		float fDeltaTime = g_GameplayTimer.GetDeltaTime();

		if( g_fConstantUpdateDeltaSeconds > 0 )
			fDeltaTime = g_fConstantUpdateDeltaSeconds;
		
		CheckGameLoopTimerSkips( fDeltaTime );

		fDeltaTime *= g_fUpdateRate;

		/* XXX
		PitchDetectionTest::Update();
		*/

		CheckFocus();

		/* Update SOUNDMAN early (before any RageSound::GetPosition calls), to flush position data. */
		SOUNDMAN->Update();

		/* Update song beat information -before- calling update on all the classes that
		 * depend on it.  If you don't do this first, the classes are all acting on old 
		 * information and will lag.  (but no longer fatally, due to timestamping -glenn) */
		SOUND->Update( fDeltaTime );
		TEXTUREMAN->Update( fDeltaTime );
		GAMESTATE->Update( fDeltaTime );
		SCREENMAN->Update( fDeltaTime );
		MEMCARDMAN->Update();
		NSMAN->Update( fDeltaTime );

		/* Important:  Process input AFTER updating game logic, or input will be acting on song beat from last frame */
		HandleInputEvents( fDeltaTime );

		if( INPUTMAN->DevicesChanged() )
		{
			INPUTFILTER->Reset();	// fix "buttons stuck" if button held while unplugged
			INPUTMAN->LoadDrivers();
			RString sMessage;
			if( INPUTMAPPER->CheckForChangedInputDevicesAndRemap(sMessage) )
				SCREENMAN->SystemMessage( sMessage );
		}

		LIGHTSMAN->Update( fDeltaTime );

		/*
		 * Render
		 */
		SCREENMAN->Draw();
	}

	/* If we ended mid-game, finish up. */
	GAMESTATE->SaveLocalData();

	if( ChangeAppPri() )
		HOOKS->UnBoostPriority();
}