From 96d1781a9ba365baef0f89ef85a2b103bfd6370a Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 25 Jun 2017 09:35:29 +0200 Subject: put the mouse object into the global context so we can adjust the resolution when switching video modes --- src/drivers/hdi/ps2/mouse.c | 17 ++++++++++------- src/drivers/hdi/ps2/mouse.h | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/hdi/ps2/mouse.c b/src/drivers/hdi/ps2/mouse.c index 46984eb..43b8e4f 100644 --- a/src/drivers/hdi/ps2/mouse.c +++ b/src/drivers/hdi/ps2/mouse.c @@ -85,19 +85,14 @@ static mouse_vtable_t mouse_vtable = { } }; -void mouse_init( mouse_t *mouse, mouse_event_handler_t handler, void *context ) +void mouse_init( mouse_t *mouse, mouse_event_handler_t handler, const uint32_t res_x, const uint32_t res_y, void *context ) { memset( mouse, 0, sizeof( mouse_t ) ); // TODO: we should probe for wheel mouse and more than 3 packets mouse->nof_packets = DEFAULT_NOF_PACKETS; - vga_text_t *vga_text = (vga_text_t *)context; - - mouse->res_x = vga_text->res_x; - mouse->res_y = vga_text->res_y; - mouse->cursor_x = mouse->res_x / 2; - mouse->cursor_y = mouse->res_y / 2; + mouse_set_resolution( mouse, res_x, res_y ); mouse->handler = handler; mouse->context = context; @@ -248,3 +243,11 @@ void mouse_print_info( void *obj ) { puts( "PS/2 mouse driver" ); } + +void mouse_set_resolution( mouse_t *mouse, const uint32_t res_x, const uint32_t res_y ) +{ + mouse->res_x = res_x; + mouse->res_y = res_y; + mouse->cursor_x = mouse->res_x / 2; + mouse->cursor_y = mouse->res_y / 2; +} diff --git a/src/drivers/hdi/ps2/mouse.h b/src/drivers/hdi/ps2/mouse.h index cbd02ef..166b4df 100644 --- a/src/drivers/hdi/ps2/mouse.h +++ b/src/drivers/hdi/ps2/mouse.h @@ -54,12 +54,14 @@ typedef struct { driver_vtable_t base; } mouse_vtable_t; -void mouse_init( mouse_t *mouse, mouse_event_handler_t handler, void *context ); +void mouse_init( mouse_t *mouse, mouse_event_handler_t handler, const uint32_t res_x, const uint32_t res_y, void *context ); void mouse_activate( void *obj ); void mouse_deactivate( void *obj ); void mouse_deinit( void *obj ); void mouse_print_info( void *obj ); +void mouse_set_resolution( mouse_t *mouse, const uint32_t x, const uint32_t y ); + uint32_t mouse_handle_interrupt( interrupt_handler_t *handler, uint32_t esp ); #endif // MOUSE_H -- cgit v1.2.3-54-g00ecf