/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "inputbutton.h" #include "inputaction.h" typedef struct { inputactiondata_t actions[INPUT_ACTION_COUNT]; #if INPUT_SDL2 == 1 #if INPUT_KEYBOARD == 1 const uint8_t *keyboardState; #endif #endif } input_t; extern input_t INPUT; /** * Initialize the input system. */ void inputInit(void); /** * Updates the input state. */ void inputUpdate(void); /** * Gets the current value of a specific input action. * * @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 inputaction_t action); /** * Gets the last value of a specific input action. * * @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 inputaction_t action); /** * Checks if a specific input action is currently pressed. * * @param action The input action to check. * @return true if the action is currently pressed, false otherwise. */ bool_t inputIsDown(const inputaction_t action); /** * Checks if a specific input action was pressed in the last update. * * @param action The input action to check. * @return true if the action was pressed in the last update, false otherwise. */ bool_t inputWasDown(const inputaction_t action); /** * Checks if a specific input action was down this frame but not in the the * previous frame. * * @param action The input action to check. * @return true if the action is currently pressed, false otherwise. */ bool_t inputPressed(const inputaction_t action); /** * Checks if a specific input action was released this frame. * * @param action The input action to check. * @return true if the action was released this frame, false otherwise. */ bool_t inputReleased(const inputaction_t action); /** * Gets the value of an input axis, defined by two actions (negative and * positive). * * @param neg The action representing the negative direction of the axis. * @param pos The action representing the positive direction of the axis. * @return The current value of the axis (-1.0f to 1.0f). */ float_t inputAxis(const inputaction_t neg, const inputaction_t pos); /** * Binds an input button to an action. Will first check if a matching action * exists, otherwise it will be treated as a command. * * @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 inputbutton_t data, const char_t *action);