input: Add mouse support
When running a simple GUI it is useful to support a mouse. This is similar to what is provided in UEFI's boot menu. Add a simple uclass and a way to read the mouse position. For sandbox add a driver that reads the position from SDL. Disable input for the tools-only build, since it is of no use there and causes build failures. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -100,3 +100,12 @@ config TWL4030_INPUT
|
||||
bool "Enable TWL4030 Input controller"
|
||||
help
|
||||
Enable TWL4030 Input controller
|
||||
|
||||
config MOUSE
|
||||
bool "Support for mice and other pointing devices"
|
||||
default y if SANDBOX
|
||||
help
|
||||
This allows U-Boot to access mouse input, typically needed for
|
||||
graphics boot menus and the like. The driver can provide mouse
|
||||
events based on user interaction and these can be used to control
|
||||
U-Boot's operation.
|
||||
|
||||
@@ -15,3 +15,5 @@ obj-$(CONFIG_I8042_KEYB) += i8042.o
|
||||
obj-$(CONFIG_TEGRA_KEYBOARD) += input.o tegra-kbc.o
|
||||
obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_MOUSE) += mouse-uclass.o
|
||||
|
||||
29
drivers/input/mouse-uclass.c
Normal file
29
drivers/input/mouse-uclass.c
Normal file
@@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <mouse.h>
|
||||
|
||||
int mouse_get_event(struct udevice *dev, struct mouse_event *evt)
|
||||
{
|
||||
struct mouse_ops *ops = mouse_get_ops(dev);
|
||||
int ret;
|
||||
|
||||
if (!ops->get_event)
|
||||
return -ENOSYS;
|
||||
|
||||
ret = ops->get_event(dev, evt);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(mouse) = {
|
||||
.id = UCLASS_MOUSE,
|
||||
.name = "mouse",
|
||||
};
|
||||
Reference in New Issue
Block a user