| 271 | } |
| 272 | |
| 273 | void Input::refresh() { |
| 274 | bindings.clear(); |
| 275 | defaultBindings(); |
| 276 | #ifndef EDITOR |
| 277 | for ( auto& binding : kb_system_bindings ) |
| 278 | { |
| 279 | bind(binding.first.c_str(), binding.second.c_str()); |
| 280 | } |
| 281 | if ( getPlayerControlType() == playerControlType_t::PLAYER_CONTROLLED_BY_KEYBOARD ) |
| 282 | { |
| 283 | printlog("keyboard bindings for player %d", player); |
| 284 | for (auto& binding : getKeyboardBindings() ) |
| 285 | { |
| 286 | bind(binding.first.c_str(), binding.second.c_str()); |
| 287 | } |
| 288 | } |
| 289 | if ( getPlayerControlType() == playerControlType_t::PLAYER_CONTROLLED_BY_CONTROLLER ) |
| 290 | { |
| 291 | printlog("controller bindings for player %d", player); |
| 292 | for ( auto& binding : gamepad_system_bindings ) |
| 293 | { |
| 294 | bind(binding.first.c_str(), binding.second.c_str()); |
| 295 | } |
| 296 | |
| 297 | std::string prefix; |
| 298 | prefix.append("Pad"); |
| 299 | prefix.append(std::to_string(player)); |
| 300 | for (auto& binding : getGamepadBindings()) { |
| 301 | if ( binding.second == MainMenu::hiddenBinding ) |
| 302 | { |
| 303 | auto b = bindings.find(binding.first); |
| 304 | if ( b != bindings.end() && b->second.isBindingUsingGamepad() ) |
| 305 | { |
| 306 | // hidden binding, don't override existing bind by the defaults. |
| 307 | continue; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | bind(binding.first.c_str(), (prefix + binding.second).c_str()); |
| 312 | if ( binding.first == "Voice Chat" ) // special binding can be on gamepad or keyboard |
| 313 | { |
| 314 | if ( bindings[binding.first].type == binding_t::INVALID ) |
| 315 | { |
| 316 | // try bind to keyboard as fallback |
| 317 | bind(binding.first.c_str(), binding.second.c_str()); |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | if ( getPlayerControlType() == playerControlType_t::PLAYER_CONTROLLED_BY_JOYSTICK ) |
| 323 | { |
| 324 | printlog("joystick bindings for player %d", player); |
| 325 | for ( auto& binding : joystick_system_bindings ) |
| 326 | { |
| 327 | bind(binding.first.c_str(), binding.second.c_str()); |
| 328 | } |
| 329 | |
| 330 | std::string prefix; |
no test coverage detected