summaryrefslogtreecommitdiff
path: root/src/drivers/hdi/mouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/hdi/mouse.c')
-rw-r--r--src/drivers/hdi/mouse.c65
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;
+}
+