MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ProcessBindings

Method ProcessBindings

Source/UserInput/input.cpp:784–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

782}
783
784void Input::ProcessBindings() {
785 for (auto& open_joystick : open_joysticks_) {
786 RC_JoystickStruct js = open_joystick.second;
787 js->joystick.ClearBinding();
788 char gamepad_name[32];
789 FormatString(gamepad_name, 32, "gamepad_%i", js->player_input);
790 if (!js->gamepad_bind.empty()) {
791 StrMap& gamepad_map = bindings_[gamepad_name];
792 for (auto& xb_iter : gamepad_map) {
793 const std::string& input_str = xb_iter.second;
794 ControllerInput::Input input = SDLStringToController(input_str.c_str());
795 if (input != ControllerInput::NONE) {
796 SDL_GameControllerButtonBind bind;
797 // Input comes as an internal value, so map it to a physical
798 // (SDL) input, but send the internal input to ProcessBinding
799 switch (input) {
800 case ControllerInput::L_STICK_XN:
801 case ControllerInput::L_STICK_XP:
802 bind = js->gamepad_bind[ControllerInput::L_STICK_X];
803 break;
804 case ControllerInput::L_STICK_YN:
805 case ControllerInput::L_STICK_YP:
806 bind = js->gamepad_bind[ControllerInput::L_STICK_Y];
807 break;
808 case ControllerInput::R_STICK_XN:
809 case ControllerInput::R_STICK_XP:
810 bind = js->gamepad_bind[ControllerInput::R_STICK_X];
811 break;
812 case ControllerInput::R_STICK_YN:
813 case ControllerInput::R_STICK_YP:
814 bind = js->gamepad_bind[ControllerInput::R_STICK_Y];
815 break;
816 default:
817 bind = js->gamepad_bind[input];
818 break;
819 }
820 if (bind.bindType != SDL_CONTROLLER_BINDTYPE_NONE) {
821 js->joystick.ProcessBinding(input, xb_iter.first);
822 }
823 }
824 }
825 } else {
826 // TODO: Generic controller support
827 /*const StrMap &map = bindings_["controller"];
828 for( StrMap::const_iterator iter = map.begin(); iter != map.end(); ++iter ) {
829 js->joystick.ProcessBinding(iter->second, iter->first);
830 }*/
831 }
832 }
833}
834
835void Input::ProcessControllers(float timestep) {
836 PROFILER_ZONE(g_profiler_ctx, "ProcessControllers");

Callers

nothing calls this directly

Calls 6

FormatStringFunction · 0.85
SDLStringToControllerFunction · 0.85
ClearBindingMethod · 0.80
ProcessBindingMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected