mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 06:39:01 +08:00
nuttx: Support for the mouse ioctl interface
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
This commit is contained in:
@@ -68,6 +68,8 @@ static int mouse_open(FAR struct file *filep);
|
||||
static int mouse_close(FAR struct file *filep);
|
||||
static ssize_t mouse_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static int mouse_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
static int mouse_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
|
||||
@@ -82,7 +84,7 @@ static const struct file_operations g_mouse_fops =
|
||||
mouse_read, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* seek */
|
||||
NULL, /* ioctl */
|
||||
mouse_ioctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
NULL, /* truncate */
|
||||
mouse_poll /* poll */
|
||||
@@ -217,6 +219,36 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mouse_ioctl
|
||||
****************************************************************************/
|
||||
|
||||
static int mouse_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct mouse_upperhalf_s *upper = inode->i_private;
|
||||
FAR struct mouse_lowerhalf_s *lower = upper->lower;
|
||||
int ret;
|
||||
|
||||
ret = nxmutex_lock(&upper->lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (lower->control)
|
||||
{
|
||||
ret = lower->control(lower, cmd, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENOTTY;
|
||||
}
|
||||
|
||||
nxmutex_unlock(&upper->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mouse_poll
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user