first commit

This commit is contained in:
2024-08-24 00:47:58 -04:00
commit f6ef842a28
400 changed files with 43479 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]);
}