mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 09:38:37 +08:00
nuttx: add open and close callback functions for the mouse.
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
This commit is contained in:
@@ -65,7 +65,7 @@ endif # FF_AW86225
|
|||||||
endif # INPUT_FF
|
endif # INPUT_FF
|
||||||
|
|
||||||
config INPUT_MOUSE
|
config INPUT_MOUSE
|
||||||
bool "Enable mouse support"
|
bool
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Enable support for mouse devices.
|
Enable support for mouse devices.
|
||||||
@@ -82,11 +82,11 @@ config INPUT_MOUSE_WHEEL
|
|||||||
endif # INPUT_MOUSE
|
endif # INPUT_MOUSE
|
||||||
|
|
||||||
config INPUT_TOUCHSCREEN
|
config INPUT_TOUCHSCREEN
|
||||||
bool "Enable touchscreen support"
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config INPUT_KEYBOARD
|
config INPUT_KEYBOARD
|
||||||
bool "Enable keyboard support"
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config INPUT_UINPUT
|
config INPUT_UINPUT
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ static int mouse_open(FAR struct file *filep)
|
|||||||
FAR struct mouse_openpriv_s *openpriv;
|
FAR struct mouse_openpriv_s *openpriv;
|
||||||
FAR struct inode *inode = filep->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct mouse_upperhalf_s *upper = inode->i_private;
|
FAR struct mouse_upperhalf_s *upper = inode->i_private;
|
||||||
|
FAR struct mouse_lowerhalf_s *lower = upper->lower;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nxmutex_lock(&upper->lock);
|
ret = nxmutex_lock(&upper->lock);
|
||||||
@@ -131,6 +132,11 @@ static int mouse_open(FAR struct file *filep)
|
|||||||
nxmutex_init(&openpriv->lock);
|
nxmutex_init(&openpriv->lock);
|
||||||
list_add_tail(&upper->head, &openpriv->node);
|
list_add_tail(&upper->head, &openpriv->node);
|
||||||
|
|
||||||
|
if (lower->open && list_is_singular(&openpriv->node))
|
||||||
|
{
|
||||||
|
ret = lower->open(lower);
|
||||||
|
}
|
||||||
|
|
||||||
/* Save the buffer node pointer so that it can be used directly
|
/* Save the buffer node pointer so that it can be used directly
|
||||||
* in the read operation.
|
* in the read operation.
|
||||||
*/
|
*/
|
||||||
@@ -149,6 +155,7 @@ static int mouse_close(FAR struct file *filep)
|
|||||||
FAR struct mouse_openpriv_s *openpriv = filep->f_priv;
|
FAR struct mouse_openpriv_s *openpriv = filep->f_priv;
|
||||||
FAR struct inode *inode = filep->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct mouse_upperhalf_s *upper = inode->i_private;
|
FAR struct mouse_upperhalf_s *upper = inode->i_private;
|
||||||
|
FAR struct mouse_lowerhalf_s *lower = upper->lower;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nxmutex_lock(&upper->lock);
|
ret = nxmutex_lock(&upper->lock);
|
||||||
@@ -157,6 +164,11 @@ static int mouse_close(FAR struct file *filep)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lower->close && list_is_singular(&openpriv->node))
|
||||||
|
{
|
||||||
|
ret = lower->close(lower);
|
||||||
|
}
|
||||||
|
|
||||||
list_delete(&openpriv->node);
|
list_delete(&openpriv->node);
|
||||||
circbuf_uninit(&openpriv->circbuf);
|
circbuf_uninit(&openpriv->circbuf);
|
||||||
nxsem_destroy(&openpriv->waitsem);
|
nxsem_destroy(&openpriv->waitsem);
|
||||||
|
|||||||
@@ -114,9 +114,7 @@ struct mouse_report_s
|
|||||||
/* Possibly padded with 1 byte here */
|
/* Possibly padded with 1 byte here */
|
||||||
int16_t x; /* X coordinate of the mouse position */
|
int16_t x; /* X coordinate of the mouse position */
|
||||||
int16_t y; /* Y coordinate of the mouse position */
|
int16_t y; /* Y coordinate of the mouse position */
|
||||||
#ifdef CONFIG_INPUT_MOUSE_WHEEL
|
|
||||||
int16_t wheel; /* Mouse wheel position */
|
int16_t wheel; /* Mouse wheel position */
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This structure is for mouse lower half driver */
|
/* This structure is for mouse lower half driver */
|
||||||
@@ -143,6 +141,45 @@ struct mouse_lowerhalf_s
|
|||||||
|
|
||||||
CODE int (*control)(FAR struct mouse_lowerhalf_s *lower,
|
CODE int (*control)(FAR struct mouse_lowerhalf_s *lower,
|
||||||
int cmd, unsigned long arg);
|
int cmd, unsigned long arg);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Name: open
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function pointer is used to open a connection to the mouse driver
|
||||||
|
* instance. It initializes the mouse and prepares it for subsequent
|
||||||
|
* interactions with the user. This function typically sets up the state
|
||||||
|
* of the driver and allocates any necessary resources.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - A pointer to the instance of the lower half mouse driver.
|
||||||
|
* filep - A pointer to the file structure representing the user.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* It returns zero (OK) on success; a negative errno value on failure.
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
CODE int (*open)(FAR struct mouse_lowerhalf_s *lower);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Name: close
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function pointer is used to close the connection to the mouse
|
||||||
|
* driver instance. It performs any necessary cleanup operations, such as
|
||||||
|
* releasing resources and resetting the state of the mouse driver,
|
||||||
|
* before ending theinteraction with the user.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - A pointer to the instance of the lower half mouse driver.
|
||||||
|
* filep - A pointer to the file structure representing the user closing
|
||||||
|
* the mouse connection.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Returns zero (OK) on success; a negative errno value on failure.
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
CODE int (*close)(FAR struct mouse_lowerhalf_s *lower);
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user