MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / BuildControllerConfig

Method BuildControllerConfig

Source/SysPSP/Input/InputManagerPSP.cpp:824–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

822//
823//*****************************************************************************
824CControllerConfig * IInputManager::BuildControllerConfig( const char * filename )
825{
826 CIniFile * p_ini_file( CIniFile::Create( filename ) );
827 if( p_ini_file == NULL )
828 {
829 return NULL;
830 }
831
832 const CIniFileProperty * p_property;
833 CControllerConfig * p_config( new CControllerConfig );
834
835 //
836 // Firstly parse the default section
837 //
838 const CIniFileSection * p_default_section( p_ini_file->GetDefaultSection() );
839
840 if( p_default_section->FindProperty( "Name", &p_property ) )
841 {
842 p_config->SetName( p_property->GetValue() );
843 }
844 if( p_default_section->FindProperty( "Description", &p_property ) )
845 {
846 p_config->SetDescription( p_property->GetValue() );
847 }
848 if( p_default_section->FindProperty( "JoystickSwap", &p_property ) )
849 {
850 p_config->SetJoySwap( p_property->GetValue() );
851 }
852 else
853 {
854 p_config->SetJoySwap( "A" );
855 }
856
857 //
858 // Now parse all the buttons
859 //
860 const CIniFileSection * p_button_section( p_ini_file->GetSectionByName( "Buttons" ) );
861
862 if( p_button_section != NULL )
863 {
864 CButtonMappingExpressionEvaluator eval;
865
866 for( u32 i = 0; i < NUM_N64_BUTTONS; ++i )
867 {
868 EN64Button button = EN64Button( i );
869 const char * button_name( GetN64ButtonName( button ) );
870
871 if( p_button_section->FindProperty( button_name, &p_property ) )
872 {
873 p_config->SetButtonMapping( button, eval.Parse( p_property->GetValue() ) );
874 }
875 else
876 {
877 //printf( "There was no property for %s\n", button_name );
878 }
879 }
880 }
881 else

Callers

nothing calls this directly

Calls 8

EN64ButtonEnum · 0.85
FindPropertyMethod · 0.80
SetNameMethod · 0.80
GetValueMethod · 0.80
SetDescriptionMethod · 0.80
SetJoySwapMethod · 0.80
SetButtonMappingMethod · 0.80
ParseMethod · 0.80

Tested by

no test coverage detected