/** * Copyright (c) 2024 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "input.h" input_t INPUT; void inputInit() { memset(&INPUT, 0, sizeof(input_t)); } void inputUpdate() { // Update the previous state memcpy( INPUT.previousState, INPUT.currentState, sizeof(INPUT.previousState) ); // Get the new state for(inputbind_t i = 0; i < INPUT_BIND_COUNT; i++) { INPUT.currentState[i] = inputGetState(i); } } inputstate_t inputIsDown(const inputbind_t bind) { return INPUT.currentState[bind]; } inputstate_t inputWasPressed(const inputbind_t bind) { return INPUT.currentState[bind] && !INPUT.previousState[bind]; } inputstate_t inputWasReleased(const inputbind_t bind) { return !INPUT.currentState[bind] && INPUT.previousState[bind]; }