forked from jaildesigner-jailgames/jaildoctors_dilemma
Commit to continue on other pc
This commit is contained in:
87
source/input.h
Normal file
87
source/input.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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 INPUT_BUTTON_PAUSE 15
|
||||
#define INPUT_BUTTON_ESCAPE 16
|
||||
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
// Clase Input
|
||||
class Input
|
||||
{
|
||||
private:
|
||||
struct keyBindings_t
|
||||
{
|
||||
Uint8 scancode; // Scancode asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
keyBindings_t mKeyBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
|
||||
struct GameControllerBindings_t
|
||||
{
|
||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
|
||||
//SDL_GameController *mGameController; // Manejador para el mando
|
||||
std::vector<SDL_GameController*> mConnectedControllers;
|
||||
std::vector<std::string> mControllerNames;
|
||||
int mNumGamepads;
|
||||
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
bool discoverGameController();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
// Destructor
|
||||
~Input();
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY, int index=0);
|
||||
|
||||
// Comprueba si hay algun mando conectado
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int getNumControllers();
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user