#include "keyboard.h" void keyboard_update(Keyboard* self) { const u8* state; memcpy(&self->previous, &self->current, sizeof(u8) * KEYBOARD_KEY_COUNT); memset(&self->current, '\0', sizeof(u8) * KEYBOARD_KEY_COUNT); state = SDL_GetKeyboardState(NULL); memcpy(&self->current, state, KEYBOARD_KEY_COUNT); } bool keyboard_press(Keyboard* self, KeyboardKeyType type) { return (self->current[type] && !self->previous[type]); } bool keyboard_held(Keyboard* self, KeyboardKeyType type) { return (self->current[type] && self->previous[type]); } bool keyboard_release(Keyboard* self, KeyboardKeyType type) { return (!self->current[type] && self->previous[type]); }