Input: model upate/poll finalitzat
This commit is contained in:
@@ -63,7 +63,7 @@ constexpr bool INPUT_ALLOW_REPEAT = true;
|
||||
constexpr bool INPUT_DO_NOT_ALLOW_REPEAT = false;
|
||||
|
||||
// Tipos de dispositivos de entrada
|
||||
enum class InputDeviceToUse : int
|
||||
enum class InputDevice : int
|
||||
{
|
||||
KEYBOARD = 0,
|
||||
CONTROLLER = 1,
|
||||
@@ -85,10 +85,10 @@ public:
|
||||
void bindGameControllerButton(int controller_index, InputAction inputTarget, InputAction inputSource); // Asigna inputs a otros inputs del mando
|
||||
|
||||
// --- Métodos de consulta de entrada ---
|
||||
void update(); // Comprueba fisicamente los botones y teclas que se han pulsado
|
||||
bool checkInput(InputAction input, bool repeat = true, InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); // Comprueba si un input está activo
|
||||
bool checkAnyInput(InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); // Comprueba si hay al menos un input activo
|
||||
int checkAnyButton(bool repeat = INPUT_DO_NOT_ALLOW_REPEAT); // Comprueba si hay algún botón pulsado
|
||||
void update(); // Comprueba fisicamente los botones y teclas que se han pulsado
|
||||
bool checkInput(InputAction input, bool repeat = true, InputDevice device = InputDevice::ANY, int controller_index = 0); // Comprueba si un input está activo
|
||||
bool checkAnyInput(InputDevice device = InputDevice::ANY, int controller_index = 0); // Comprueba si hay al menos un input activo
|
||||
int checkAnyButton(bool repeat = INPUT_DO_NOT_ALLOW_REPEAT); // Comprueba si hay algún botón pulsado
|
||||
|
||||
// --- Métodos de gestión de mandos ---
|
||||
bool discoverGameControllers(); // Busca si hay mandos conectados
|
||||
@@ -98,11 +98,11 @@ public:
|
||||
int getJoyIndex(SDL_JoystickID id) const; // Obtiene el índice del controlador a partir de un event.id
|
||||
|
||||
// --- Métodos de consulta y utilidades ---
|
||||
void printBindings(InputDeviceToUse device = InputDeviceToUse::KEYBOARD, int controller_index = 0) const; // Muestra por consola los controles asignados
|
||||
SDL_GamepadButton getControllerBinding(int controller_index, InputAction input) const; // Obtiene el SDL_GamepadButton asignado a un input
|
||||
std::string to_string(InputAction input) const; // Convierte un InputAction a std::string
|
||||
InputAction to_inputs_e(const std::string &name) const; // Convierte un std::string a InputAction
|
||||
int getIndexByName(const std::string &name) const; // Obtiene el índice a partir del nombre del mando
|
||||
void printBindings(InputDevice device = InputDevice::KEYBOARD, int controller_index = 0) const; // Muestra por consola los controles asignados
|
||||
SDL_GamepadButton getControllerBinding(int controller_index, InputAction input) const; // Obtiene el SDL_GamepadButton asignado a un input
|
||||
std::string to_string(InputAction input) const; // Convierte un InputAction a std::string
|
||||
InputAction to_inputs_e(const std::string &name) const; // Convierte un std::string a InputAction
|
||||
int getIndexByName(const std::string &name) const; // Obtiene el índice a partir del nombre del mando
|
||||
|
||||
// --- Métodos de reseteo de estado de entrada ---
|
||||
void resetInputStates(); // Pone todos los KeyBindings.active y ControllerBindings.active a false
|
||||
@@ -133,6 +133,9 @@ private:
|
||||
: button(btn), is_held(is_held), just_pressed(just_pressed), axis_active(axis_act) {}
|
||||
};
|
||||
|
||||
// --- Constantes ---
|
||||
static constexpr Sint16 AXIS_THRESHOLD_ = 30000;
|
||||
|
||||
// --- Variables internas ---
|
||||
std::vector<SDL_Gamepad *> connected_controllers_; // Vector con todos los mandos conectados
|
||||
std::vector<SDL_Joystick *> joysticks_; // Vector con todos los joysticks conectados
|
||||
|
||||
Reference in New Issue
Block a user