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

Function bindControllerToPlayer

src/game.cpp:4073–4096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4071-------------------------------------------------------------------------------*/
4072
4073static void bindControllerToPlayer(int id, int player) {
4074 inputs.removeControllerWithDeviceID(id); // clear any other player using this
4075 inputs.setControllerID(player, id);
4076 inputs.getVirtualMouse(player)->draw_cursor = false;
4077 inputs.getVirtualMouse(player)->lastMovementFromController = true;
4078 printlog("(Device %d bound to player %d)", id, player);
4079 for (int c = 0; c < 4; ++c) {
4080 auto& input = Input::inputs[c];
4081 input.refresh();
4082 }
4083 auto& input = Input::inputs[player];
4084 if (event.cbutton.button == SDL_CONTROLLER_BUTTON_A)
4085 {
4086 input.consumeBinary("MenuConfirm");
4087 }
4088 if (event.cbutton.button == SDL_CONTROLLER_BUTTON_B)
4089 {
4090 input.consumeBinary("MenuBack");
4091 }
4092 if (event.cbutton.button == SDL_CONTROLLER_BUTTON_START)
4093 {
4094 input.consumeBinary("MenuStart");
4095 }
4096}
4097
4098bool handleEvents(void)
4099{

Callers 2

handleEventsFunction · 0.85
mainFunction · 0.85

Calls 6

printlogFunction · 0.85
setControllerIDMethod · 0.80
getVirtualMouseMethod · 0.80
refreshMethod · 0.80
consumeBinaryMethod · 0.80

Tested by

no test coverage detected