input prog

This commit is contained in:
2026-03-07 22:11:11 -06:00
parent 71e6079054
commit 5c4537b2fa
9 changed files with 189 additions and 75 deletions
+54
View File
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef struct inputbutton_s inputbutton_t;
#ifdef DUSK_INPUT_KEYBOARD
typedef SDL_Scancode inputscancodesdl2_t;
#endif
#ifdef DUSK_INPUT_GAMEPAD
typedef SDL_GameControllerButton inputgamepadbuttonsdl2_t;
typedef SDL_GameControllerAxis inputgamepadaxissdl2_t;
#endif
#ifdef DUSK_INPUT_POINTER
typedef enum {
INPUT_POINTER_AXIS_X,
INPUT_POINTER_AXIS_Y,
INPUT_POINTER_AXIS_Z,
INPUT_POINTER_AXIS_WHEEL_X,
INPUT_POINTER_AXIS_WHEEL_Y,
} inputpointeraxissdl2_t;
#endif
typedef struct {
#if INPUT_GAMEPAD == 1
SDL_GameController *controller;
#endif
#if INPUT_KEYBOARD == 1
const uint8_t *keyboardState;
#endif
#if INPUT_POINTER == 1
#if INPUT_SDL2 == 1
float_t mouseX, mouseY;
#endif
#endif
} inputsdl2_t;
/**
* Returns the input value (between 0 and 1) of the given button.
*
* @param button The button to get the value of.
* @return The value of the button, between 0 and 1.
*/
float_t inputButtonGetValueSDL2(const inputbutton_t button);