diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-07-18 21:23:22 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-07-18 21:23:22 +0200 |
commit | ee3e51aa1624693217b1a4ae7bfb2730424c08f2 (patch) | |
tree | bebd430417bad79c9cd1aa91f48d168f90795621 /src/drivers/hdi/mouse.c | |
parent | 3a1570d0e6531e3f49e79bbbe4e24d6280e49b1a (diff) | |
download | abaos-ee3e51aa1624693217b1a4ae7bfb2730424c08f2.tar.gz abaos-ee3e51aa1624693217b1a4ae7bfb2730424c08f2.tar.bz2 |
added a virtual mouse driver interface, made the PS/2 mouse a specialization of it
Diffstat (limited to 'src/drivers/hdi/mouse.c')
-rw-r--r-- | src/drivers/hdi/mouse.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/drivers/hdi/mouse.c b/src/drivers/hdi/mouse.c new file mode 100644 index 0000000..85d4c82 --- /dev/null +++ b/src/drivers/hdi/mouse.c @@ -0,0 +1,65 @@ +#include "mouse.h" + +#include "string.h" +#include "kernel.h" + +static mouse_vtable_t const mouse_vtable = { + { + mouse_activate, + mouse_deactivate, + mouse_deinit, + mouse_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_deinit( void *obj ) +{ + // nothing to be done +} + +void mouse_activate( void *obj ) +{ + kernel_panic( "Activating generic mouse driver should not be called directly." ); +} + +void mouse_deactivate( void *obj ) +{ + kernel_panic( "Deactivating generic mouse driver should not be called directly." ); +} + +void mouse_print_info( void *obj ) +{ + kernel_panic( "Printing info of generic mouse driver should not be called directly." ); +} + +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; +} + |