diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 9f6d5a4633..f0a1ad850a 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -1966,7 +1966,7 @@ StyleIcon=1 [ScreenInputOptions] HelpText=&UP; &DOWN; to change line &LEFT; &RIGHT; to select between options::START to accept changes BACK to discard changes -AutoMapJoysticks=&oq;ON&cq; will cause StepMania automatically create::mappings for the joysticks attached to your computer::at the time the program starts. This will::override any manually defined mappings. +AutoMapOnJoyChange=&oq;ON&cq; will cause StepMania automatically remap::all the joysticks attached to your computer if the joysticks::attached to your system are different than the last time you::started the game. Auto mapping will override any::manually defined mappings. MenuButtons=The default setting allows the dance pad's panels to navigate::the menus. Changing this to &oq;dedicated only&cq; will restrict::menu navigation to only the Menu* set of buttons. Be sure to map::the Menu* set of buttons before setting this to &oq;dedicated&cq;! AutoPlay=This option is useful for those who would like to play::without using a pad. However, you will not be able to set::high scores or earn extra stages while this options is ON. BackDelayed=Turning this option ON will require that you hold the Back button::for 0.5 seconds before it will regiser. This is useful if you find::yourself accidentally pressing the Back button on your controller. @@ -1978,7 +1978,7 @@ PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster OptionMenuFlags=rows,6;together;explanations -Line1=conf,AutoMapJoysticks +Line1=conf,AutoMapOnJoyChange Line2=conf,MenuButtons Line3=conf,AutoPlay Line4=conf,BackDelayed diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index b105d413b9..06d498d40f 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -91,7 +91,7 @@ PrefsManager::PrefsManager() m_ShowDancingCharacters = CO_OFF; m_bUseUnlockSystem = false; m_bFirstRun = true; - m_bAutoMapJoysticks = true; + m_bAutoMapOnJoyChange = true; m_fGlobalOffsetSeconds = 0; m_bForceLogFlush = false; m_bLogging = true; @@ -261,9 +261,10 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ) ini.GetValue( "Options", "UseUnlockSystem", m_bUseUnlockSystem ); ini.GetValue( "Options", "FirstRun", m_bFirstRun ); - ini.GetValue( "Options", "AutoMapJoysticks", m_bAutoMapJoysticks ); + ini.GetValue( "Options", "AutoMapJoysticks", m_bAutoMapOnJoyChange ); ini.GetValue( "Options", "VideoRenderers", m_sVideoRenderers ); ini.GetValue( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); + ini.GetValue( "Options", "LastSeenInputDevices", m_sLastSeenInputDevices ); #if defined(WIN32) ini.GetValue( "Options", "LastSeenMemory", m_iLastSeenMemory ); #endif @@ -366,9 +367,10 @@ void PrefsManager::SaveGlobalPrefsToDisk() ini.SetValue( "Options", "ShowDancingCharacters", m_ShowDancingCharacters ); ini.SetValue( "Options", "UseUnlockSystem", m_bUseUnlockSystem ); ini.SetValue( "Options", "FirstRun", m_bFirstRun ); - ini.SetValue( "Options", "AutoMapJoysticks", m_bAutoMapJoysticks ); + ini.SetValue( "Options", "AutoMapJoysticks", m_bAutoMapOnJoyChange ); ini.SetValue ( "Options", "VideoRenderers", m_sVideoRenderers ); ini.SetValue ( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); + ini.SetValue ( "Options", "LastSeenInputDevices", m_sLastSeenInputDevices ); #if defined(WIN32) ini.SetValue ( "Options", "LastSeenMemory", m_iLastSeenMemory ); #endif diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index c3af3126bf..381680e4f8 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -85,7 +85,7 @@ public: CharacterOption m_ShowDancingCharacters; bool m_bUseUnlockSystem; bool m_bFirstRun; - bool m_bAutoMapJoysticks; + bool m_bAutoMapOnJoyChange; float m_fGlobalOffsetSeconds; bool m_bForceLogFlush; bool m_bLogging; @@ -115,6 +115,7 @@ public: CString m_DWIPath; CString m_sLastSeenVideoDriver; + CString m_sLastSeenInputDevices; #if defined(WIN32) int m_iLastSeenMemory; #endif diff --git a/stepmania/src/ScreenInputOptions.cpp b/stepmania/src/ScreenInputOptions.cpp index 6c2ac455ab..6c6be3e93e 100644 --- a/stepmania/src/ScreenInputOptions.cpp +++ b/stepmania/src/ScreenInputOptions.cpp @@ -35,12 +35,12 @@ enum { /* Hmm. Ignore JoyAxes and Back Delayed probably belong in "key/joy config", * preferably alongside button configuration. */ OptionRow g_InputOptionsLines[NUM_INPUT_OPTIONS_LINES] = { - OptionRow( "Auto Map\nJoysticks", true, "OFF","ON (recommended)" ), - OptionRow( "Menu\nButtons", true, "USE GAMEPLAY BUTTONS","ONLY DEDICATED BUTTONS" ), - OptionRow( "AutoPlay", true, "OFF","ON" ), - OptionRow( "Back\nDelayed", true, "INSTANT","HOLD" ), - OptionRow( "Options\nNavigation", true, "SM STYLE","ARCADE STYLE" ), - OptionRow( "Wheel\nSpeed", true, "SLOW","NORMAL","FAST","REALLY FAST" ), + OptionRow( "Auto Map\nOn Joy Change", true, "OFF","ON (recommended)" ), + OptionRow( "Menu\nButtons", true, "USE GAMEPLAY BUTTONS","ONLY DEDICATED BUTTONS" ), + OptionRow( "AutoPlay", true, "OFF","ON" ), + OptionRow( "Back\nDelayed", true, "INSTANT","HOLD" ), + OptionRow( "Options\nNavigation", true, "SM STYLE","ARCADE STYLE" ), + OptionRow( "Wheel\nSpeed", true, "SLOW","NORMAL","FAST","REALLY FAST" ), }; ScreenInputOptions::ScreenInputOptions( CString sName ) : @@ -60,7 +60,7 @@ ScreenInputOptions::ScreenInputOptions( CString sName ) : void ScreenInputOptions::ImportOptions() { - m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] = PREFSMAN->m_bAutoMapJoysticks ? 1:0; + m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] = PREFSMAN->m_bAutoMapOnJoyChange ? 1:0; m_iSelectedOption[0][IO_DEDICATED_MENU_BUTTONS] = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1:0; m_iSelectedOption[0][IO_AUTOPLAY] = PREFSMAN->m_bAutoPlay; m_iSelectedOption[0][IO_DELAYED_ESCAPE] = PREFSMAN->m_bDelayedEscape ? 1:0; @@ -73,7 +73,7 @@ void ScreenInputOptions::ImportOptions() void ScreenInputOptions::ExportOptions() { - PREFSMAN->m_bAutoMapJoysticks = m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] == 1; + PREFSMAN->m_bAutoMapOnJoyChange = m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] == 1; PREFSMAN->m_bOnlyDedicatedMenuButtons= m_iSelectedOption[0][IO_DEDICATED_MENU_BUTTONS] == 1; PREFSMAN->m_bDelayedEscape = m_iSelectedOption[0][IO_DELAYED_ESCAPE] == 1; PREFSMAN->m_bAutoPlay = m_iSelectedOption[0][IO_AUTOPLAY] == 1; diff --git a/stepmania/src/ScreenOptionsMasterPrefs.cpp b/stepmania/src/ScreenOptionsMasterPrefs.cpp index 12875952e1..655329b9df 100644 --- a/stepmania/src/ScreenOptionsMasterPrefs.cpp +++ b/stepmania/src/ScreenOptionsMasterPrefs.cpp @@ -233,7 +233,7 @@ static void NumBackgrounds( int &sel, bool ToSel, const CStringArray &choices ) } /* Input options */ -MOVE( AutoMapJoysticks, PREFSMAN->m_bAutoMapJoysticks ); +MOVE( AutoMapOnJoyChange, PREFSMAN->m_bAutoMapOnJoyChange ); MOVE( MenuButtons, PREFSMAN->m_bOnlyDedicatedMenuButtons ); MOVE( AutoPlay, PREFSMAN->m_bAutoPlay ); MOVE( BackDelayed, PREFSMAN->m_bDelayedEscape ); @@ -408,12 +408,12 @@ static const ConfOption g_ConfOptions[] = ConfOption( "Random\nBackgrounds", NumBackgrounds, "5","10","15","20" ), /* Input options */ - ConfOption( "Auto Map\nJoysticks", AutoMapJoysticks, "OFF","ON (recommended)" ), - ConfOption( "MenuButtons", MenuButtons, "USE GAMEPLAY BUTTONS","ONLY DEDICATED BUTTONS" ), - ConfOption( "AutoPlay", AutoPlay, "OFF","ON" ), - ConfOption( "Back\nDelayed", BackDelayed, "INSTANT","HOLD" ), - ConfOption( "Options\nNavigation", OptionsNavigation, "SM STYLE","ARCADE STYLE" ), - ConfOption( "Wheel\nSpeed", WheelSpeed, "SLOW","NORMAL","FAST","REALLY FAST" ), + ConfOption( "Auto Map\nOn Joy Change", AutoMapOnJoyChange, "OFF","ON (recommended)" ), + ConfOption( "MenuButtons", MenuButtons, "USE GAMEPLAY BUTTONS","ONLY DEDICATED BUTTONS" ), + ConfOption( "AutoPlay", AutoPlay, "OFF","ON" ), + ConfOption( "Back\nDelayed", BackDelayed, "INSTANT","HOLD" ), + ConfOption( "Options\nNavigation", OptionsNavigation, "SM STYLE","ARCADE STYLE" ), + ConfOption( "Wheel\nSpeed", WheelSpeed, "SLOW","NORMAL","FAST","REALLY FAST" ), /* Gameplay options */ ConfOption( "Solo\nSingles", SoloSingles, "OFF","ON" ), diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 16f4761026..9ad48a4b4f 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -219,8 +219,31 @@ void ResetGame( bool ReturnToFirstScreen ) PREFSMAN->m_bFirstRun = false; - if( PREFSMAN->m_bAutoMapJoysticks ) - INPUTMAPPER->AutoMapJoysticksForCurrentGame(); + + // + // update last seen joysticks + // + vector vDevices; + vector vDescriptions; + INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions); + + vector vOldDescriptions; + split( PREFSMAN->m_sLastSeenInputDevices, ",", vOldDescriptions ); + CString sInputDevices = join( ",", vDescriptions ); + + if( PREFSMAN->m_sLastSeenInputDevices != sInputDevices ) + { + LOG->Info( "Input devices changed from '%s' to '%s'.", PREFSMAN->m_sLastSeenInputDevices.c_str(), sInputDevices.c_str() ); + + if( PREFSMAN->m_bAutoMapOnJoyChange ) + { + LOG->Info( "Remapping joysticks." ); + INPUTMAPPER->AutoMapJoysticksForCurrentGame(); + } + + PREFSMAN->m_sLastSeenInputDevices = sInputDevices; + } + if( ReturnToFirstScreen ) SCREENMAN->SetNewScreen( THEME->GetMetric("Common","InitialScreen") );