[Concept,02/14] mouse: Use struct vid_pos for click position

Message ID 20251006165452.1675349-3-sjg@u-boot.org
State New
Headers
Series expo: Continue development of expo with mouse |

Commit Message

Simon Glass Oct. 6, 2025, 4:54 p.m. UTC
  From: 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>
---

 drivers/input/mouse-uclass.c | 8 ++++----
 include/mouse.h              | 7 +++----
 2 files changed, 7 insertions(+), 8 deletions(-)
  

Patch

diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c
index 256642ef55e..0e5faccf1e2 100644
--- a/drivers/input/mouse-uclass.c
+++ b/drivers/input/mouse-uclass.c
@@ -44,8 +44,8 @@  int mouse_get_click(struct udevice *dev, int *xp, int *yp)
 		if (uc_priv->left_button_state == BUTTON_PRESSED &&
 		    new_state == BUTTON_RELEASED) {
 			pending = true;
-			uc_priv->click_x = event.button.x;
-			uc_priv->click_y = event.button.y;
+			uc_priv->click_pos.x = event.button.x;
+			uc_priv->click_pos.y = event.button.y;
 		}
 
 		/* Update button state */
@@ -54,9 +54,9 @@  int mouse_get_click(struct udevice *dev, int *xp, int *yp)
 		/* If we just detected a click, return it */
 		if (pending) {
 			if (xp)
-				*xp = uc_priv->click_x;
+				*xp = uc_priv->click_pos.x;
 			if (yp)
-				*yp = uc_priv->click_y;
+				*yp = uc_priv->click_pos.y;
 
 			return 0;
 		}
diff --git a/include/mouse.h b/include/mouse.h
index 0d20f8ffdbc..8e65ac79b94 100644
--- a/include/mouse.h
+++ b/include/mouse.h
@@ -9,6 +9,7 @@ 
 #define _MOUSE_H
 
 #include <stdbool.h>
+#include <video_defs.h>
 
 struct udevice;
 
@@ -35,13 +36,11 @@  enum mouse_press_state_t {
  * struct mouse_uc_priv - private data for mouse uclass
  *
  * @left_button_state: Current state of left button (BUTTON_PRESSED/BUTTON_RELEASED)
- * @click_x: X coordinate where the click occurred
- * @click_y: Y coordinate where the click occurred
+ * @click_pos: Position where the click occurred
  */
 struct mouse_uc_priv {
 	enum mouse_press_state_t left_button_state;
-	int click_x;
-	int click_y;
+	struct vid_pos click_pos;
 };
 
 /**