better encapsulation, reduce GameLoop.cpp depending on StepMania.cpp: move

CheckForChangedInputDevicesAndRemap into InputMapper
This commit is contained in:
Glenn Maynard
2005-12-18 23:45:46 +00:00
parent 304c31d29d
commit 3fbde68e4a
4 changed files with 43 additions and 43 deletions
+39
View File
@@ -512,6 +512,45 @@ void InputMapper::SaveMappingsToDisk()
ini.WriteFile( SpecialFiles::KEYMAPS_PATH );
}
bool InputMapper::CheckForChangedInputDevicesAndRemap( CString &sMessage )
{
//
// update last seen joysticks
//
vector<InputDevice> vDevices;
vector<CString> vsDescriptions;
INPUTMAN->GetDevicesAndDescriptions( vDevices, vsDescriptions );
CString sInputDevices = join( ",", vsDescriptions );
if( PREFSMAN->m_sLastSeenInputDevices.Get() == sInputDevices )
return false;
vector<CString> vsLastSeen;
split( PREFSMAN->m_sLastSeenInputDevices, ",", vsLastSeen );
vector<CString> vsConnects, vsDisconnects;
GetConnectsDisconnects( vsLastSeen, vsDescriptions, vsDisconnects, vsConnects );
sMessage.clear();
if( !vsConnects.empty() )
sMessage += "Connected: " + join( "\n", vsConnects ) + "\n";
if( !vsDisconnects.empty() )
sMessage += "Disconnected: " + join( "\n", vsDisconnects ) + "\n";
if( PREFSMAN->m_bAutoMapOnJoyChange )
{
sMessage += "Remapping all joysticks.";
AutoMapJoysticksForCurrentGame();
SaveMappingsToDisk();
}
LOG->Info( sMessage );
PREFSMAN->m_sLastSeenInputDevices.Set( sInputDevices );
PREFSMAN->SavePrefsToDisk();
return true;
}
void InputMapper::SetInputMap( const DeviceInput &DeviceI, const GameInput &GameI, int iSlotIndex )
{
+1
View File
@@ -28,6 +28,7 @@ public:
void AddDefaultMappingsForCurrentGameIfUnmapped();
void AutoMapJoysticksForCurrentGame();
bool CheckForChangedInputDevicesAndRemap( CString &sMessageOut );
bool IsMapped( const DeviceInput &DeviceI );
bool IsMapped( const GameInput &GameI );
+3 -42
View File
@@ -292,47 +292,6 @@ void StepMania::ResetGame()
PREFSMAN->SavePrefsToDisk();
}
void StepMania::CheckForChangedInputDevicesAndRemap()
{
//
// update last seen joysticks
//
vector<InputDevice> vDevices;
vector<CString> vsDescriptions;
INPUTMAN->GetDevicesAndDescriptions( vDevices, vsDescriptions );
CString sInputDevices = join( ",", vsDescriptions );
if( PREFSMAN->m_sLastSeenInputDevices.Get() != sInputDevices )
{
vector<CString> vsLastSeen;
split( PREFSMAN->m_sLastSeenInputDevices, ",", vsLastSeen );
vector<CString> vsConnects, vsDisconnects;
GetConnectsDisconnects( vsLastSeen, vsDescriptions, vsDisconnects, vsConnects );
CString sMessage;
if( !vsConnects.empty() )
sMessage += "Connected: " + join( "\n", vsConnects ) + "\n";
if( !vsDisconnects.empty() )
sMessage += "Disconnected: " + join( "\n", vsDisconnects ) + "\n";
if( PREFSMAN->m_bAutoMapOnJoyChange )
{
sMessage += "Remapping all joysticks.";
INPUTMAPPER->AutoMapJoysticksForCurrentGame();
INPUTMAPPER->SaveMappingsToDisk();
}
LOG->Info( sMessage );
SCREENMAN->SystemMessage( sMessage );
PREFSMAN->m_sLastSeenInputDevices.Set( sInputDevices );
}
PREFSMAN->SavePrefsToDisk();
}
static bool ChangeAppPri()
{
if( PREFSMAN->m_BoostAppPriority.Get() == PrefsManager::BOOST_NO )
@@ -1142,7 +1101,9 @@ int main(int argc, char* argv[])
SCREENMAN->SetNewScreen( CommonMetrics::INITIAL_SCREEN );
// Do this after ThemeChanged so that we can show a system message
StepMania::CheckForChangedInputDevicesAndRemap();
CString sMessage;
if( INPUTMAPPER->CheckForChangedInputDevicesAndRemap(sMessage) )
SCREENMAN->SystemMessage( sMessage );
CodeDetector::RefreshCacheItems();
-1
View File
@@ -16,7 +16,6 @@ namespace StepMania
void ApplyGraphicOptions();
void NORETURN HandleException( CString error );
void ResetGame();
void CheckForChangedInputDevicesAndRemap();
void ChangeCurrentGame( const Game* g );
void FocusChanged( bool bHasFocus );
bool AppHasFocus();