Implement unigi_event_get()
This commit is contained in:
parent
fbe7b14110
commit
a5c52ebb76
25
src/events.h
Normal file
25
src/events.h
Normal file
@ -0,0 +1,25 @@
|
||||
void unigi_event_get(unigi_type_event * event) {
|
||||
SDL_Event platform_event;
|
||||
if (SDL_PollEvent(&platform_event)) {
|
||||
if (
|
||||
platform_event.type == SDL_KEYDOWN ||
|
||||
platform_event.type == SDL_KEYUP
|
||||
) {
|
||||
event -> type = unigi_enum_event_input_keyboard;
|
||||
event -> data.input_keyboard.device = 0;
|
||||
event -> data.input_keyboard.button = platform_event.key.keysym.scancode;
|
||||
if (platform_event.type == SDL_KEYDOWN) {
|
||||
event -> data.input_keyboard.down = 1;
|
||||
} else {
|
||||
event -> data.input_keyboard.down = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
event -> type = unigi_enum_event_unknown;
|
||||
return;
|
||||
} else {
|
||||
event -> type = unigi_enum_event_none;
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include "graphics.h"
|
||||
#include "input.h"
|
||||
#include "events.h"
|
||||
|
||||
unigi_type_error unigi_init() {
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user