| 822 | // |
| 823 | //***************************************************************************** |
| 824 | CControllerConfig * 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 |
nothing calls this directly
no test coverage detected