Files
coffee_crisis/source/input.h

59 lines
1.3 KiB
C++

#pragma once
#include "ifdefs.h"
#ifndef INPUT_H
#define INPUT_H
#define INPUT_NULL 0
#define INPUT_UP 1
#define INPUT_DOWN 2
#define INPUT_LEFT 3
#define INPUT_RIGHT 4
#define INPUT_ACCEPT 5
#define INPUT_CANCEL 6
#define INPUT_BUTTON_1 7
#define INPUT_BUTTON_2 8
#define INPUT_BUTTON_3 9
#define INPUT_BUTTON_4 10
#define INPUT_BUTTON_5 11
#define INPUT_BUTTON_6 12
#define INPUT_BUTTON_7 13
#define INPUT_BUTTON_8 14
#define REPEAT_TRUE true
#define REPEAT_FALSE false
// Clase Input
class Input
{
private:
struct input_t
{
Uint8 scancode; // Scancode asociado
bool active; // Indica si está activo
};
input_t mInput[15]; // Vector con las teclas asociadas a los inputs predefinidos
//SDL_Joystick *mGameController; // Manejador para el mando 1
//SDL_Haptic *mControllerHaptic; // Manejador para el mando con vibración
//bool mGameControllerFound; // Variable para saber si hay un mando conectado
public:
// Constructor
Input();
// Destructor
~Input();
// Asigna uno de los posibles inputs a una tecla del teclado
void bindKey(Uint8 input, SDL_Scancode code);
// Comprueba si un input esta activo
bool checkInput(Uint8 input, bool repeat);
// Gestiona las entradas desde el mando de juego
bool checkGameController(Uint8 state);
};
#endif