Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | /* SPDX-License-Identifier: GPL-2.0+ */ /* * Mouse/trackpad/touchscreen input uclass * * Copyright 2020 Google LLC */ #ifndef _MOUSE_H #define _MOUSE_H #include <stdbool.h> struct udevice; enum mouse_ev_t { MOUSE_EV_NULL, MOUSE_EV_MOTION, MOUSE_EV_BUTTON, }; enum mouse_state_t { BUTTON_LEFT = 1 << 0, BUTTON_MIDDLE = 1 << 1, BUTTON_RIGHT = 1 << 2, BUTTON_SCROLL_PLUS = 1 << 3, BUTTON_SCROLL_MINUS = 1 << 4, }; enum mouse_press_state_t { BUTTON_RELEASED = 0, BUTTON_PRESSED, }; /** * 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 */ struct mouse_uc_priv { enum mouse_press_state_t left_button_state; int click_x; int click_y; }; /** * struct mouse_event - information about a mouse event * * @type: Mouse event ype */ struct mouse_event { enum mouse_ev_t type; union { /** * @state: Mouse state (enum mouse_state_t bitmask) * @x: X position of mouse * @y: Y position of mouse * @xrel: Relative motion in X direction * @yrel: Relative motion in Y direction */ struct mouse_motion { unsigned char state; unsigned short x; unsigned short y; short xrel; short yrel; } motion; /** * @button: Button number that was pressed/released (BUTTON_...) * @state: BUTTON_PRESSED / BUTTON_RELEASED * @clicks: number of clicks (normally 1; 2 = double-click) * @x: X position of mouse * @y: Y position of mouse */ struct mouse_button { unsigned char button; unsigned char press_state; unsigned char clicks; unsigned short x; unsigned short y; } button; }; }; struct mouse_ops { int (*get_event)(struct udevice *dev, struct mouse_event *event); }; #define mouse_get_ops(dev) ((struct mouse_ops *)(dev)->driver->ops) int mouse_get_event(struct udevice *dev, struct mouse_event *event); /** * mouse_get_click() - Check if a left mouse button click has occurred * * @dev: Mouse device * @xp: Returns X coordinate of click (can be NULL) * @yp: Returns Y coordinate of click (can be NULL) * Returns: 0 if a click has occurred, -EAGAIN if no click pending */ int mouse_get_click(struct udevice *dev, int *xp, int *py); #endif |