mouse: Use struct vid_pos for click position
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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user