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>
It is possible that there is already a mouse click available, so
mouse_get_click() should check that first, before reading any further
events.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 90e109789e ("mouse: Move click detection into mouse_get_event()")
Currently mouse_get_click() processes events by calling
mouse_get_event() and tracking the press->release transition. But if
other code calls mouse_get_event() directly, those button events are
consumed and mouse_get_click() never sees them.
Fix this by moving the click detection logic into mouse_get_event()
itself. Add a click_pending flag to track when a click has been
detected, and simplify mouse_get_click() to just check and clear this
flag.
This ensures clicks are properly registered regardless of whether callers
use mouse_get_event() or mouse_get_click().
Series-changes: 2
- Add new patch to move click detection into mouse_get_event()
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Change the mouse_button structure to use a bool pressed field instead
of an unsigned char press_state. This simplifies the API by using a
natural boolean type for a binary state.
Remove the BUTTON_PRESSED/BUTTON_RELEASED defines as they're no longer
needed.
Update all mouse drivers, tests, and the mouse command to use the new
field name and type.
Series-changes: 2
- Add new patch to replace press_state with bool pressed
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Replace the mouse_press_state_t enum with a simpler bool left_pressed
field in mouse_uc_priv. Convert BUTTON_PRESSED/BUTTON_RELEASED to defines
since they're still used in the mouse_event button structure.
This simplifies the code by directly tracking whether the left button
is pressed rather than using an enum to represent a binary state.
Clarify the comment to struct mouse_uc_priv while here.
Series-changes: 2
- Add new patch to replace mouse_press_state_t enum with bool
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a mouse_set_video() function to set up the video device associated
with the mouse. This allows mouse drivers to scale coordinates to match
the display resolution.
The video device information is stored in mouse_uc_priv rather than
being driver-specific, providing a common place for all mouse drivers to
access display dimensions for coordinate scaling.
Update expo_set_mouse_enable() to call mouse_set_video() to configure
the mouse with the display device.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new set_ptr_visible() method to the mouse uclass to allow hiding
and showing the system mouse pointer. This is useful with sandbox when
rendering a custom mouse pointer, such as in expo mode.
The method is optional and returns -ENOSYS if not supported by the
driver.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add tracking of the last mouse position received, separate from the
click position. This allows callers to query the current mouse position
using mouse_get_pos() regardless of whether a click occurred.
The position is updated in mouse_get_event() for both motion and button
events, ensuring it always reflects the most recent mouse coordinates.
This avoid the problem of mouse_get_click() 'swallowing' motion events
so that a position change is not noticed, e.g. for showing a pointer.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Change the API to use struct vid_pos instead of separate x/y pointers.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Use the new vid_pos struct instead of separate x/y fields.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
A mouse click is defined as pressing the mouse and then releasing it
over a given spot. Add a function the tracks the mouse state and
returns the most recent mouse click, if any.
Signed-off-by: Simon Glass <sjg@chromium.org>
When running a simple GUI it is useful to support a mouse. This is
similar to what is provided in UEFI's boot menu. Add a simple uclass and
a way to read the mouse position.
For sandbox add a driver that reads the position from SDL. Disable input
for the tools-only build, since it is of no use there and causes build
failures.
Signed-off-by: Simon Glass <sjg@chromium.org>