Añadido soporte para ejes en la clase Input
This commit is contained in:
@@ -135,24 +135,13 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
||||
if (gameControllerFound() && index < numGamepads)
|
||||
if ((device == INPUT_USE_GAMECONTROLLER) || (device == INPUT_USE_ANY))
|
||||
{
|
||||
if (repeat)
|
||||
successGameController = checkAxisInput(input, index);
|
||||
if (!successGameController)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
||||
{
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
successGameController = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gameControllerBindings[index][input].active)
|
||||
if (repeat)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
||||
{
|
||||
gameControllerBindings[index][input].active = true;
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
@@ -162,14 +151,29 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) == 0)
|
||||
if (!gameControllerBindings[index][input].active)
|
||||
{
|
||||
gameControllerBindings[index][input].active = false;
|
||||
successGameController = false;
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
||||
{
|
||||
gameControllerBindings[index][input].active = true;
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
successGameController = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
successGameController = false;
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) == 0)
|
||||
{
|
||||
gameControllerBindings[index][input].active = false;
|
||||
successGameController = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
successGameController = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,3 +498,45 @@ void Input::allActive(int index)
|
||||
gameControllerBindings[index][i].active = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el eje del mando
|
||||
bool Input::checkAxisInput(inputs_e input, int index)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case input_left:
|
||||
if (SDL_GameControllerGetAxis(connectedControllers[index], SDL_CONTROLLER_AXIS_LEFTX) < -30000)
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case input_right:
|
||||
if (SDL_GameControllerGetAxis(connectedControllers[index], SDL_CONTROLLER_AXIS_LEFTX) > 30000)
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case input_up:
|
||||
if (SDL_GameControllerGetAxis(connectedControllers[index], SDL_CONTROLLER_AXIS_LEFTY) < -30000)
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case input_down:
|
||||
if (SDL_GameControllerGetAxis(connectedControllers[index], SDL_CONTROLLER_AXIS_LEFTY) > 30000)
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -89,6 +89,9 @@ private:
|
||||
i_disable_e disabledUntil; // Tiempo que esta deshabilitado
|
||||
bool enabled; // Indica si está habilitado
|
||||
|
||||
// Comprueba el eje del mando
|
||||
bool checkAxisInput(inputs_e input, int index = 0);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
Reference in New Issue
Block a user