input: Provide a way for tests to register a mouse click
In tests it is useful to fake a mouse click to check that expo handles it correctly. Create a function for this. Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -107,6 +107,19 @@ int mouse_set_video(struct udevice *dev, struct udevice *video_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_queue_click_for_test(struct udevice *dev, int x, int y)
|
||||
{
|
||||
struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
|
||||
uc_priv->click_pending = true;
|
||||
uc_priv->click_pos.x = x;
|
||||
uc_priv->click_pos.y = y;
|
||||
uc_priv->last_pos.x = x;
|
||||
uc_priv->last_pos.y = y;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(mouse) = {
|
||||
.id = UCLASS_MOUSE,
|
||||
.name = "mouse",
|
||||
|
||||
@@ -176,4 +176,18 @@ int mouse_set_ptr_visible(struct udevice *dev, bool visible);
|
||||
*/
|
||||
int mouse_set_video(struct udevice *dev, struct udevice *video_dev);
|
||||
|
||||
/**
|
||||
* mouse_queue_click_for_test() - Queue a click event for testing
|
||||
*
|
||||
* This is a back-door function for tests to simulate a mouse click at a
|
||||
* specific position. The click will be returned by the next call to
|
||||
* mouse_get_click().
|
||||
*
|
||||
* @dev: Mouse device
|
||||
* @x: X coordinate of click
|
||||
* @y: Y coordinate of click
|
||||
* Returns: 0 if OK, -ve on error
|
||||
*/
|
||||
int mouse_queue_click_for_test(struct udevice *dev, int x, int y);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user