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 (gameControllerFound() && index < numGamepads)
|
||||||
if ((device == INPUT_USE_GAMECONTROLLER) || (device == INPUT_USE_ANY))
|
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)
|
if (repeat)
|
||||||
{
|
|
||||||
successGameController = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
successGameController = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!gameControllerBindings[index][input].active)
|
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings[index][input].active = true;
|
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -162,14 +151,29 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) == 0)
|
if (!gameControllerBindings[index][input].active)
|
||||||
{
|
{
|
||||||
gameControllerBindings[index][input].active = false;
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
||||||
successGameController = false;
|
{
|
||||||
|
gameControllerBindings[index][input].active = true;
|
||||||
|
successGameController = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
successGameController = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
successGameController = false;
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) == 0)
|
||||||
|
{
|
||||||
|
gameControllerBindings[index][input].active = false;
|
||||||
|
successGameController = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
successGameController = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -493,4 +497,46 @@ void Input::allActive(int index)
|
|||||||
{
|
{
|
||||||
gameControllerBindings[index][i].active = true;
|
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
|
i_disable_e disabledUntil; // Tiempo que esta deshabilitado
|
||||||
bool enabled; // Indica si está habilitado
|
bool enabled; // Indica si está habilitado
|
||||||
|
|
||||||
|
// Comprueba el eje del mando
|
||||||
|
bool checkAxisInput(inputs_e input, int index = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Input(std::string file);
|
Input(std::string file);
|
||||||
|
|||||||
Reference in New Issue
Block a user