diff --git a/drivers/input/touchscreen_upper.c b/drivers/input/touchscreen_upper.c index e1a53f03d5..683fbe7fbe 100644 --- a/drivers/input/touchscreen_upper.c +++ b/drivers/input/touchscreen_upper.c @@ -81,6 +81,11 @@ static int touch_ioctl(FAR struct file *filep, int cmd, static int touch_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); +#ifdef CONFIG_INPUT_UINPUT +static ssize_t touch_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +#endif + /**************************************************************************** * Private Data ****************************************************************************/ @@ -90,7 +95,11 @@ static const struct file_operations g_touch_fops = touch_open, /* open */ touch_close, /* close */ touch_read, /* read */ +#ifdef CONFIG_INPUT_UINPUT + touch_write, /* write */ +#else NULL, /* write */ +#endif NULL, /* seek */ touch_ioctl, /* ioctl */ touch_poll /* poll */ @@ -197,6 +206,27 @@ static int touch_close(FAR struct file *filep) return ret; } +/**************************************************************************** + * Name: touch_write + ****************************************************************************/ + +#ifdef CONFIG_INPUT_UINPUT +static ssize_t touch_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct touch_upperhalf_s *upper = inode->i_private; + FAR struct touch_lowerhalf_s *lower = upper->lower; + + if (!lower->write) + { + return -ENOSYS; + } + + return lower->write(lower, buffer, buflen); +} +#endif + /**************************************************************************** * Name: touch_read ****************************************************************************/ diff --git a/include/nuttx/input/touchscreen.h b/include/nuttx/input/touchscreen.h index 6b8f4ed754..7a6a61cde1 100644 --- a/include/nuttx/input/touchscreen.h +++ b/include/nuttx/input/touchscreen.h @@ -175,6 +175,25 @@ struct touch_lowerhalf_s CODE int (*control)(FAR struct touch_lowerhalf_s *lower, int cmd, unsigned long arg); + + /************************************************************************** + * Name: write + * + * Description: + * Users can use this interface to implement custom write. + * + * Arguments: + * lower - The instance of lower half of touchscreen device. + * buffer - User defined specific buffer. + * buflen - User defined specific buffer size. + * + * Return Value: + * Number of bytes written;a negated errno value on failure. + * + **************************************************************************/ + + CODE ssize_t (*write)(FAR struct touch_lowerhalf_s *lower, + FAR const char *buffer, size_t buflen); }; /****************************************************************************