first commit

This commit is contained in:
2024-04-11 01:05:03 -04:00
commit 3398c52f8b
272 changed files with 35195 additions and 0 deletions

32
src/engine/keyboard.c Normal file
View File

@@ -0,0 +1,32 @@
#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]);
}