| 938 | } |
| 939 | |
| 940 | void Input::SetFromConfig(const Config& config) { |
| 941 | bindings_.erase("gamepad_0"); |
| 942 | bindings_.erase("gamepad_1"); |
| 943 | bindings_.erase("gamepad_2"); |
| 944 | bindings_.erase("gamepad_3"); |
| 945 | for (Config::Map::const_iterator iter = config.map_.begin(); iter != config.map_.end(); ++iter) { |
| 946 | CheckBinding(iter, "key", bindings_); |
| 947 | CheckBinding(iter, "gamepad", bindings_); |
| 948 | CheckBinding(iter, "gamepad_0", bindings_); |
| 949 | CheckBinding(iter, "gamepad_1", bindings_); |
| 950 | CheckBinding(iter, "gamepad_2", bindings_); |
| 951 | CheckBinding(iter, "gamepad_3", bindings_); |
| 952 | CheckBinding(iter, "controller", bindings_); |
| 953 | CheckBinding(iter, "bind", bindings_); |
| 954 | CheckBinding(iter, "bind_win", bindings_); |
| 955 | CheckBinding(iter, "bind_unix", bindings_); |
| 956 | } |
| 957 | CompleteGamepadBindings("gamepad_0", bindings_); |
| 958 | CompleteGamepadBindings("gamepad_1", bindings_); |
| 959 | CompleteGamepadBindings("gamepad_2", bindings_); |
| 960 | CompleteGamepadBindings("gamepad_3", bindings_); |
| 961 | use_raw_input = config["use_raw_input"].toNumber<bool>(); |
| 962 | // Process hotkey bindings |
| 963 | StrMap& binds = bindings_["bind"]; |
| 964 | for (StrMap::const_iterator iter = binds.begin(); iter != binds.end(); ++iter) { |
| 965 | KeyCommand::BindString((iter->second + ": " + iter->first).c_str()); |
| 966 | } |
| 967 | #ifdef WIN32 |
| 968 | StrMap& platform_binds = bindings_["bind_win"]; |
| 969 | #else |
| 970 | StrMap& platform_binds = bindings_["bind_unix"]; |
| 971 | #endif |
| 972 | for (StrMap::const_iterator iter = platform_binds.begin(); iter != platform_binds.end(); ++iter) { |
| 973 | KeyCommand::BindString((iter->second + ": " + iter->first).c_str()); |
| 974 | } |
| 975 | KeyCommand::FinalizeBindings(); |
| 976 | mouse_sensitivity_ = config["mouse_sensitivity"].toNumber<float>(); |
| 977 | UpdateGamepadLookSensitivity(); |
| 978 | UpdateGamepadDeadzone(); |
| 979 | SetInvertXMouseLook(config["invert_x_mouse_look"].toNumber<bool>()); |
| 980 | SetInvertYMouseLook(config["invert_y_mouse_look"].toNumber<bool>()); |
| 981 | debug_keys = config["debug_keys"].toNumber<bool>(); |
| 982 | if (!open_joysticks_.empty()) { |
| 983 | ProcessBindings(); |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | void Input::ClearQuitRequested() { |
| 988 | quit_requested_ = false; |
no test coverage detected