diff --git a/src/events.c b/src/events.c index 971a29d..080c264 100644 --- a/src/events.c +++ b/src/events.c @@ -8,11 +8,26 @@ void unigi_event_get(unigi_type_event * event) { 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; - } + event -> data.input_keyboard.down = (platform_event.type == SDL_KEYDOWN); + return; + } + + if (platform_event.type == SDL_MOUSEMOTION) { + event -> type = unigi_enum_event_input_mouse_move; + event -> data.input_mouse_move.rel_x = platform_event.motion.xrel; + event -> data.input_mouse_move.rel_y = platform_event.motion.yrel; + event -> data.input_mouse_move.abs_x = platform_event.motion.x; + event -> data.input_mouse_move.abs_y = platform_event.motion.y; + return; + } + + if ( + platform_event.type == SDL_MOUSEBUTTONDOWN || + platform_event.type == SDL_MOUSEBUTTONUP + ) { + event -> type = unigi_enum_event_input_mouse_button; + event -> data.input_mouse_button.button = platform_event.button.button; + event -> data.input_mouse_button.down = (platform_event.type == SDL_MOUSEBUTTONDOWN); return; }