Arreglos en la estructura i format del codi
This commit is contained in:
@@ -35,12 +35,12 @@ Input::Input(const std::string &game_controller_db_path)
|
||||
keyBindings_t kb;
|
||||
kb.scancode = 0;
|
||||
kb.active = false;
|
||||
key_bindings_.resize(input_number_of_inputs, kb);
|
||||
key_bindings_.resize(static_cast<int>(InputAction::SIZE), kb);
|
||||
|
||||
GameControllerBindings_t gcb;
|
||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
gcb.active = false;
|
||||
game_controller_bindings_.resize(input_number_of_inputs, gcb);
|
||||
game_controller_bindings_.resize(static_cast<int>(InputAction::SIZE), gcb);
|
||||
}
|
||||
|
||||
// Actualiza el estado del objeto
|
||||
@@ -53,19 +53,19 @@ void Input::update()
|
||||
}
|
||||
|
||||
// Asigna inputs a teclas
|
||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||
void Input::bindKey(InputAction input, SDL_Scancode code)
|
||||
{
|
||||
key_bindings_[input].scancode = code;
|
||||
key_bindings_.at(static_cast<int>(input)).scancode = code;
|
||||
}
|
||||
|
||||
// Asigna inputs a botones del mando
|
||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
||||
void Input::bindGameControllerButton(InputAction input, SDL_GameControllerButton button)
|
||||
{
|
||||
game_controller_bindings_[input].button = button;
|
||||
game_controller_bindings_.at(static_cast<int>(input)).button = button;
|
||||
}
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
bool Input::checkInput(InputAction input, bool repeat, int device, int index)
|
||||
{
|
||||
if (!enabled_)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
|
||||
if (repeat)
|
||||
{
|
||||
if (keyStates[key_bindings_[input].scancode] != 0)
|
||||
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] != 0)
|
||||
{
|
||||
successKeyboard = true;
|
||||
}
|
||||
@@ -97,11 +97,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!key_bindings_[input].active)
|
||||
if (!key_bindings_.at(static_cast<int>(input)).active)
|
||||
{
|
||||
if (keyStates[key_bindings_[input].scancode] != 0)
|
||||
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] != 0)
|
||||
{
|
||||
key_bindings_[input].active = true;
|
||||
key_bindings_.at(static_cast<int>(input)).active = true;
|
||||
successKeyboard = true;
|
||||
}
|
||||
else
|
||||
@@ -111,9 +111,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyStates[key_bindings_[input].scancode] == 0)
|
||||
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] == 0)
|
||||
{
|
||||
key_bindings_[input].active = false;
|
||||
key_bindings_.at(static_cast<int>(input)).active = false;
|
||||
successKeyboard = false;
|
||||
}
|
||||
else
|
||||
@@ -129,7 +129,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
{
|
||||
if (repeat)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_.at(static_cast<int>(input)).button) != 0)
|
||||
{
|
||||
successGameController = true;
|
||||
}
|
||||
@@ -140,11 +140,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!game_controller_bindings_[input].active)
|
||||
if (!game_controller_bindings_.at(static_cast<int>(input)).active)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_.at(static_cast<int>(input)).button) != 0)
|
||||
{
|
||||
game_controller_bindings_[input].active = true;
|
||||
game_controller_bindings_.at(static_cast<int>(input)).active = true;
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
@@ -154,9 +154,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[input].button) == 0)
|
||||
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_.at(static_cast<int>(input)).button) == 0)
|
||||
{
|
||||
game_controller_bindings_[input].active = false;
|
||||
game_controller_bindings_.at(static_cast<int>(input)).active = false;
|
||||
successGameController = false;
|
||||
}
|
||||
else
|
||||
@@ -197,7 +197,7 @@ bool Input::checkAnyInput(int device, int index)
|
||||
{
|
||||
for (int i = 0; i < (int)game_controller_bindings_.size(); ++i)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[i].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_[i].button) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user