[Concept,06/17] input: sandbox: Provide a mouse driver
Commit Message
From: Simon Glass <sjg@chromium.org>
Add a sandbox driver for the mouse, so it can be used as an input
device.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
drivers/input/Kconfig | 1 +
drivers/input/Makefile | 3 +++
drivers/input/sandbox_mouse.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+)
create mode 100644 drivers/input/sandbox_mouse.c
@@ -103,6 +103,7 @@ config TWL4030_INPUT
config MOUSE
bool "Support for mice and other pointing devices"
+ depends on INPUT
default y if SANDBOX
help
This allows U-Boot to access mouse input, typically needed for
@@ -17,3 +17,6 @@ obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
endif
obj-$(CONFIG_MOUSE) += mouse-uclass.o
+ifdef CONFIG_MOUSE
+obj-$(CONFIG_SANDBOX) += sandbox_mouse.o
+endif
new file mode 100644
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <dm.h>
+#include <mouse.h>
+#include <asm/sdl.h>
+
+static int mouse_sandbox_get_event(struct udevice *dev,
+ struct mouse_event *event)
+{
+ int ret;
+
+ ret = sandbox_sdl_get_mouse_event(event);
+
+ return ret;
+}
+
+const struct mouse_ops mouse_sandbox_ops = {
+ .get_event = mouse_sandbox_get_event,
+};
+
+static const struct udevice_id mouse_sandbox_ids[] = {
+ { .compatible = "sandbox,mouse" },
+ { }
+};
+
+U_BOOT_DRIVER(mouse_sandbox) = {
+ .name = "mouse_sandbox",
+ .id = UCLASS_MOUSE,
+ .of_match = mouse_sandbox_ids,
+ .ops = &mouse_sandbox_ops,
+};