93 lines
1.9 KiB
C
93 lines
1.9 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "dusk.h"
|
|
|
|
typedef enum {
|
|
INPUT_UP,
|
|
INPUT_DOWN,
|
|
INPUT_LEFT,
|
|
INPUT_RIGHT,
|
|
INPUT_ACCEPT,
|
|
INPUT_CANCEL,
|
|
INPUT_TOGGLE_CONSOLE,
|
|
} inputbind_t;
|
|
|
|
#define INPUT_BIND_COUNT INPUT_TOGGLE_CONSOLE + 1
|
|
|
|
typedef struct {
|
|
const int32_t key;
|
|
const inputbind_t bind;
|
|
} inputbindmap_t;
|
|
|
|
typedef struct {
|
|
bool_t current[INPUT_BIND_COUNT];
|
|
bool_t previous[INPUT_BIND_COUNT];
|
|
int32_t keyPressed;
|
|
char_t charPressed;
|
|
} input_t;
|
|
|
|
extern input_t INPUT;
|
|
|
|
/**
|
|
* Initializes the input system.
|
|
*/
|
|
void inputInit(void);
|
|
|
|
/**
|
|
* Updates the input system.
|
|
*/
|
|
void inputUpdate(void);
|
|
|
|
/**
|
|
* Returns whether a given input is currently pressed.
|
|
*
|
|
* @param input The input to check.
|
|
* @return True if the input is pressed, false otherwise.
|
|
*/
|
|
bool_t inputIsDown(const inputbind_t input);
|
|
|
|
/**
|
|
* Returns whether a given input is currently up.
|
|
*
|
|
* @param input The input to check.
|
|
* @return True if the input is up, false otherwise.
|
|
*/
|
|
bool_t inputIsUp(const inputbind_t input);
|
|
|
|
/**
|
|
* Returns whether a given input was just pressed.
|
|
*
|
|
* @param input The input to check.
|
|
* @return True if the input was just pressed, false otherwise.
|
|
*/
|
|
bool_t inputWasDown(const inputbind_t input);
|
|
|
|
/**
|
|
* Returns whether a given input was just released.
|
|
*
|
|
* @param input The input to check.
|
|
* @return True if the input was just released, false otherwise.
|
|
*/
|
|
bool_t inputWasUp(const inputbind_t input);
|
|
|
|
/**
|
|
* Returns whether a given input was just pressed.
|
|
*
|
|
* @param input The input to check.
|
|
* @return True if the input was just pressed, false otherwise.
|
|
*/
|
|
bool_t inputIsPressed(const inputbind_t input);
|
|
|
|
/**
|
|
* Returns whether a given input was just released.
|
|
*
|
|
* @param input The input to check.
|
|
* @return True if the input was just released, false otherwise.
|
|
*/
|
|
bool_t inputIsReleased(const inputbind_t input); |