archivemuh
This commit is contained in:
43
src/input/input.c
Normal file
43
src/input/input.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "input.h"
|
||||
#include "assert/assert.h"
|
||||
#include "util/memory.h"
|
||||
|
||||
input_t INPUT;
|
||||
|
||||
void inputInit(void) {
|
||||
memoryZero(&INPUT, sizeof(input_t));
|
||||
}
|
||||
|
||||
void inputUpdate(void) {
|
||||
INPUT.previous = INPUT.current;
|
||||
INPUT.current = inputStateGet();
|
||||
}
|
||||
|
||||
inputstate_t inputStateGet(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool_t inputIsDown(const inputbind_t bind) {
|
||||
assertTrue(bind < INPUT_BIND_COUNT, "Input bind out of bounds");
|
||||
return (INPUT.current & bind) != 0;
|
||||
}
|
||||
|
||||
bool_t inputWasDown(const inputbind_t bind) {
|
||||
assertTrue(bind < INPUT_BIND_COUNT, "Input bind out of bounds");
|
||||
return (INPUT.previous & bind) != 0;
|
||||
}
|
||||
|
||||
bool_t inputPressed(const inputbind_t bind) {
|
||||
return inputIsDown(bind) && !inputWasDown(bind);
|
||||
}
|
||||
|
||||
bool_t inputReleased(const inputbind_t bind) {
|
||||
return !inputIsDown(bind) && inputWasDown(bind);
|
||||
}
|
||||
Reference in New Issue
Block a user