From eebd736891e7d34421d12996fc1de08a02c069e5 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Thu, 17 Feb 2022 11:00:03 +0800 Subject: [PATCH] board/sim: update uinput init & Kconfig Signed-off-by: yinshengkai --- boards/sim/sim/sim/src/sim_bringup.c | 14 +++++++---- drivers/input/Kconfig | 19 +++++++++++++-- drivers/input/uinput.c | 35 ++++++++++++++++------------ include/nuttx/input/uinput.h | 4 ++++ 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/boards/sim/sim/sim/src/sim_bringup.c b/boards/sim/sim/sim/src/sim_bringup.c index 55d2d8e4bd..7d41cda928 100644 --- a/boards/sim/sim/sim/src/sim_bringup.c +++ b/boards/sim/sim/sim/src/sim_bringup.c @@ -319,15 +319,21 @@ int sim_bringup(void) } #endif -#ifdef CONFIG_INPUT_UINPUT - /* Initialize the touchscreen uinput */ - +#ifdef CONFIG_UINPUT_TOUCHSCREEN ret = uinput_touch_initialize("utouch", 1, 4); if (ret < 0) { syslog(LOG_ERR, "ERROR: uinput_touch_initialize failed: %d\n", ret); } -#endif +#endif /* CONFIG_UINPUT_TOUCHSCREEN */ + +#ifdef CONFIG_UINPUT_BUTTONS + ret = uinput_button_initialize("ubutton"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: uinput_button_initialize failed: %d\n", ret); + } +#endif /* CONFIG_UINPUT_BUTTONS */ #ifdef CONFIG_IEEE802154_LOOPBACK /* Initialize and register the IEEE802.15.4 MAC network loop device */ diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index ed89a30f7b..2605191a47 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -36,12 +36,27 @@ config INPUT_TOUCHSCREEN default n config INPUT_UINPUT - bool "Enable uinput" - select INPUT_TOUCHSCREEN + bool default n ---help--- Enable support virtual input device driver +config UINPUT_TOUCHSCREEN + bool "Enable uinput touchscreen" + select INPUT_TOUCHSCREEN + select INPUT_UINPUT + default n + ---help--- + Enable support virtual input touchscreen device driver + +config UINPUT_BUTTONS + bool "Enable uinput buttons" + select INPUT_BUTTONS + select INPUT_UINPUT + default n + ---help--- + Enable support virtual input button device driver + config INPUT_MAX11802 bool "MAX11802 touchscreen controller" default n diff --git a/drivers/input/uinput.c b/drivers/input/uinput.c index cc4ab5cf8d..78aa743d96 100644 --- a/drivers/input/uinput.c +++ b/drivers/input/uinput.c @@ -51,12 +51,15 @@ struct uinput_button_lowerhalf_s * Private Function Prototypes ****************************************************************************/ -#ifdef CONFIG_INPUT_TOUCHSCREEN +#ifdef CONFIG_UINPUT_TOUCHSCREEN + static ssize_t uinput_touch_write(FAR struct touch_lowerhalf_s *lower, FAR const char *buffer, size_t buflen); -#endif -#ifdef CONFIG_INPUT_BUTTONS +#endif /* CONFIG_UINPUT_TOUCHSCREEN */ + +#ifdef CONFIG_UINPUT_BUTTONS + static ssize_t uinput_button_write(FAR const struct btn_lowerhalf_s *lower, FAR const char *buffer, size_t buflen); @@ -71,13 +74,14 @@ static void uinput_button_enable(FAR const struct btn_lowerhalf_s *lower, btn_buttonset_t release, btn_handler_t handler, FAR void *arg); -#endif + +#endif /* CONFIG_UINPUT_BUTTONS */ /**************************************************************************** * Private Functions ****************************************************************************/ -#ifdef CONFIG_INPUT_TOUCHSCREEN +#ifdef CONFIG_UINPUT_TOUCHSCREEN /**************************************************************************** * Name: uinput_touch_write @@ -97,13 +101,10 @@ static ssize_t uinput_touch_write(FAR struct touch_lowerhalf_s *lower, touch_event(lower->priv, sample); return buflen; } -#endif /* CONFIG_INPUT_TOUCHSCREEN */ -#ifdef CONFIG_INPUT_BUTTONS +#endif /* CONFIG_UINPUT_TOUCHSCREEN */ -/**************************************************************************** - * Name: uinput_button_write - ****************************************************************************/ +#ifdef CONFIG_UINPUT_BUTTONS /**************************************************************************** * Name: uinput_button_write @@ -165,7 +166,7 @@ static void uinput_button_enable(FAR const struct btn_lowerhalf_s *lower, ubtn_lower->handler = handler; } -#endif /* CONFIG_INPUT_BUTTONS */ +#endif /* CONFIG_UINPUT_BUTTONS */ /**************************************************************************** * Public Functions @@ -188,7 +189,8 @@ static void uinput_button_enable(FAR const struct btn_lowerhalf_s *lower, * ****************************************************************************/ -#ifdef CONFIG_INPUT_TOUCHSCREEN +#ifdef CONFIG_UINPUT_TOUCHSCREEN + int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums) { char devname[UINPUT_NAME_SIZE]; @@ -215,7 +217,8 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums) return ret; } -#endif + +#endif /* CONFIG_UINPUT_TOUCHSCREEN */ /**************************************************************************** * Name: uinput_button_initialize @@ -232,7 +235,8 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums) * ****************************************************************************/ -#ifdef CONFIG_INPUT_BUTTONS +#ifdef CONFIG_UINPUT_BUTTONS + int uinput_button_initialize(FAR const char *name) { char devname[UINPUT_NAME_SIZE]; @@ -254,4 +258,5 @@ int uinput_button_initialize(FAR const char *name) return ret; } -#endif /* CONFIG_INPUT_BUTTONS */ + +#endif /* CONFIG_UINPUT_BUTTONS */ diff --git a/include/nuttx/input/uinput.h b/include/nuttx/input/uinput.h index f55afba943..fc0d5bf224 100644 --- a/include/nuttx/input/uinput.h +++ b/include/nuttx/input/uinput.h @@ -46,8 +46,10 @@ * ****************************************************************************/ +#ifdef CONFIG_UINPUT_TOUCHSCREEN int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums); +#endif /**************************************************************************** * Name: uinput_button_initialize @@ -64,6 +66,8 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, * ****************************************************************************/ +#ifdef CONFIG_UINPUT_BUTTONS int uinput_button_initialize(FAR const char *name); +#endif #endif /* __INCLUDE_NUTTX_INPUT_UINPUT_H */