Restore console, server/client stuff.

This commit is contained in:
2025-04-21 08:23:58 -05:00
parent 697b5f7ee2
commit 4aaabb3882
22 changed files with 549 additions and 47 deletions

93
src/input.h Normal file
View File

@ -0,0 +1,93 @@
/**
* 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);