MCPcopy Create free account
hub / github.com/TurningWheel/Barony / refresh

Method refresh

src/input.cpp:273–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273void 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;

Callers 7

followerDebugEquipmentFunction · 0.80
doStatueEditorFunction · 0.80
actPlayerFunction · 0.80
bindControllerToPlayerFunction · 0.80
handleEventsFunction · 0.80
doNewGameFunction · 0.80
consolecommand.cppFile · 0.80

Calls 6

printlogFunction · 0.85
c_strMethod · 0.80
appendMethod · 0.80
isBindingUsingGamepadMethod · 0.80
clearMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected