mouse: Replace press_state with bool pressed

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>
This commit is contained in:
Simon Glass
2025-10-07 06:02:15 -06:00
parent 90964bf740
commit 03c65c2b94
7 changed files with 16 additions and 22 deletions

View File

@@ -78,7 +78,7 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event)
u8 mask = 1 << i;
if (diff & mask) {
but->button = i;
but->press_state = (new_buttons & mask) ? 1 : 0;
but->pressed = (new_buttons & mask) ? true : false;
but->clicks = 1;
but->x = priv->x;
but->y = priv->y;

View File

@@ -51,18 +51,17 @@ int mouse_get_click(struct udevice *dev, struct vid_pos *pos)
/* Only process button events for left button */
if (event.type == MOUSE_EV_BUTTON &&
event.button.button == BUTTON_LEFT) {
bool pressed = event.button.press_state == BUTTON_PRESSED;
bool pending = false;
/* Detect press->release transition (click) */
if (uc_priv->left_pressed && !pressed) {
if (uc_priv->left_pressed && !event.button.pressed) {
pending = true;
uc_priv->click_pos.x = event.button.x;
uc_priv->click_pos.y = event.button.y;
}
/* Update button state */
uc_priv->left_pressed = pressed;
uc_priv->left_pressed = event.button.pressed;
/* If we just detected a click, return it */
if (pending) {

View File

@@ -142,7 +142,7 @@ static int usb_mouse_get_event(struct udevice *dev, struct mouse_event *event)
if (diff && mask) {
but->button = i;
but->press_state = priv->buttons & mask;
but->pressed = priv->buttons & mask;
but->clicks = 1;
but->x = priv->x;
but->y = priv->y;