unigi.platform.sdl1/src/events.c

26 lines
664 B
C

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;
}
}