Allowed binds to execute commands.

This commit is contained in:
2025-09-11 12:58:04 -05:00
parent fe9af039fc
commit 8b20f0bf31
13 changed files with 244 additions and 251 deletions

View File

@@ -7,10 +7,10 @@
#pragma once
#include "inputbutton.h"
#include "inputbind.h"
#include "inputaction.h"
typedef struct {
inputbinddata_t binds[INPUT_BIND_COUNT];
inputactiondata_t actions[INPUT_ACTION_COUNT];
#if INPUT_SDL2 == 1
#if INPUT_KEYBOARD == 1
@@ -32,85 +32,59 @@ void inputInit(void);
void inputUpdate(void);
/**
* Gets the current value of a specific input bind.
* Gets the current value of a specific input action.
*
* @param bind The input bind to get the value for.
* @return The current value of the bind (0.0f to 1.0f).
* @param action The input action to get the value for.
* @return The current value of the action (0.0f to 1.0f).
*/
float_t inputGetCurrentValue(const inputbind_t bind);
float_t inputGetCurrentValue(const inputaction_t action);
/**
* Gets the last value of a specific input bind.
* Gets the last value of a specific input action.
*
* @param bind The input bind to get the value for.
* @return The last value of the bind (0.0f to 1.0f).
* @param action The input action to get the value for.
* @return The last value of the action (0.0f to 1.0f).
*/
float_t inputGetLast(const inputbind_t bind);
float_t inputGetLast(const inputaction_t action);
/**
* Checks if a specific input bind is currently pressed.
* Checks if a specific input action is currently pressed.
*
* @param bind The input bind to check.
* @return true if the bind is currently pressed, false otherwise.
* @param action The input action to check.
* @return true if the action is currently pressed, false otherwise.
*/
bool_t inputIsDown(const inputbind_t bind);
bool_t inputIsDown(const inputaction_t action);
/**
* Checks if a specific input bind was pressed in the last update.
* Checks if a specific input action was pressed in the last update.
*
* @param bind The input bind to check.
* @return true if the bind was pressed in the last update, false otherwise.
* @param action The input action to check.
* @return true if the action was pressed in the last update, false otherwise.
*/
bool_t inputWasDown(const inputbind_t bind);
bool_t inputWasDown(const inputaction_t action);
/**
* Checks if a specific input bind was down this frame but not in the the
* Checks if a specific input action was down this frame but not in the the
* previous frame.
*
* @param bind The input bind to check.
* @return true if the bind is currently pressed, false otherwise.
* @param action The input action to check.
* @return true if the action is currently pressed, false otherwise.
*/
bool_t inputPressed(const inputbind_t bind);
bool_t inputPressed(const inputaction_t action);
/**
* Checks if a specific input bind was released this frame.
* Checks if a specific input action was released this frame.
*
* @param bind The input bind to check.
* @return true if the bind was released this frame, false otherwise.
* @param action The input action to check.
* @return true if the action was released this frame, false otherwise.
*/
bool_t inputReleased(const inputbind_t bind);
bool_t inputReleased(const inputaction_t action);
/**
* Binds an input button to a specific input bind.
* Binds an input button to an action. Will first check if a matching action
* exists, otherwise it will be treated as a command.
*
* @param bind The input bind to bind the button to.
* @param button The input button to bind.
* @param action The name of the input action or command to bind the button to.
*/
void inputBind(const inputbind_t bind, const inputbutton_t button);
/**
* Unbinds an input button from a specific input bind.
*
* @param bind The input bind to unbind the button from.
* @param button The input button to unbind.
*/
void inputUnbind(const inputbind_t bind, const inputbutton_t button);
/**
* Unbinds all input buttons from all input binds.
*/
void inputUnbindAll();
/**
* Unbinds an input button from all input binds.
*
* @param button The input button to unbind.
*/
void inputUnbindButton(const inputbutton_t button);
/**
* Unbinds all input buttons from a specific input bind.
*
* @param bind The input bind to unbind all buttons from.
*/
void inputUnbindBind(const inputbind_t bind);
void inputBind(const inputbutton_t data, const char_t *action);