#include "mouse.h" #include "string.h" #include "kernel.h" static mouse_vtable_t const mouse_vtable = { { driver_activate, driver_deactivate, driver_deinit, driver_print_name, driver_print_info }, mouse_set_resolution, mouse_set_position }; void mouse_init( mouse_t *mouse, mouse_event_handler_t handler, interrupt_t *interrupt, void *context ) { memset( mouse, 0, sizeof( mouse_t ) ); driver_init( (driver_t *)mouse, DRIVER_TYPE_MOUSE, interrupt, context ); mouse->handler = handler; ((driver_t *)mouse)->vtable = (driver_vtable_t *)&mouse_vtable; } void mouse_set_resolution( void *obj, const uint32_t res_x, const uint32_t res_y ) { mouse_t *mouse = (mouse_t *)obj; mouse->res_x = res_x; mouse->res_y = res_y; mouse->cursor_x = mouse->res_x / 2; mouse->cursor_y = mouse->res_y / 2; } void mouse_set_position( void *obj, const uint32_t x, const uint32_t y ) { mouse_t *mouse = (mouse_t *)obj; mouse->cursor_x = x; mouse->cursor_y = y; }