mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-28 16:40:08 +01:00
tools: hook up absolute pointer motion in the demo client
Prints the regions and sets the pointer to somewhere around 150/150 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0991660820
commit
5adf87cdda
1 changed files with 39 additions and 0 deletions
|
|
@ -131,6 +131,24 @@ handle_keymap(struct ei_event *event)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_regions(struct ei_device *device)
|
||||
{
|
||||
uint32_t idx = 0;
|
||||
struct ei_region *r;
|
||||
|
||||
while ((r = ei_device_get_region (device, idx++))) {
|
||||
int x, y, w, h;
|
||||
x = ei_region_get_x(r);
|
||||
y = ei_region_get_y(r);
|
||||
w = ei_region_get_width(r);
|
||||
h = ei_region_get_height(r);
|
||||
|
||||
colorprint("%s has region %dx%d@%d,%d\n",
|
||||
ei_device_get_name(device), w, h, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
usage(FILE *fp, const char *argv0)
|
||||
{
|
||||
|
|
@ -237,10 +255,12 @@ int main(int argc, char **argv)
|
|||
};
|
||||
_unref_(ei_device) *ptr = NULL;
|
||||
_unref_(ei_device) *kbd = NULL;
|
||||
_unref_(ei_device) *abs = NULL;
|
||||
|
||||
bool stop = false;
|
||||
bool have_ptr = false;
|
||||
bool have_kbd = false;
|
||||
bool have_abs = false;
|
||||
struct ei_seat *default_seat = NULL;
|
||||
|
||||
while (!stop && poll(&fds, 1, 2000) > -1) {
|
||||
|
|
@ -291,6 +311,11 @@ int main(int argc, char **argv)
|
|||
kbd = device;
|
||||
handle_keymap(e);
|
||||
}
|
||||
if (ei_device_has_capability(device, EI_DEVICE_CAP_POINTER_ABSOLUTE)) {
|
||||
colorprint("New abs pointer device: %s\n", ei_device_get_name(device));
|
||||
abs = device;
|
||||
handle_regions(device);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EI_EVENT_DEVICE_RESUMED:
|
||||
|
|
@ -302,6 +327,10 @@ int main(int argc, char **argv)
|
|||
colorprint("Keyboard device was resumed\n");
|
||||
have_kbd = true;
|
||||
}
|
||||
if (ei_event_get_device(e) == abs) {
|
||||
colorprint("Abs pointer device was resumed\n");
|
||||
have_abs = true;
|
||||
}
|
||||
break;
|
||||
case EI_EVENT_DEVICE_SUSPENDED:
|
||||
if (ei_event_get_device(e) == ptr) {
|
||||
|
|
@ -312,6 +341,10 @@ int main(int argc, char **argv)
|
|||
colorprint("Keyboard device was resumed\n");
|
||||
have_kbd = false;
|
||||
}
|
||||
if (ei_event_get_device(e) == abs) {
|
||||
colorprint("Abs pointer device was resumed\n");
|
||||
have_abs = false;
|
||||
}
|
||||
break;
|
||||
case EI_EVENT_DEVICE_REMOVED:
|
||||
{
|
||||
|
|
@ -342,6 +375,12 @@ int main(int argc, char **argv)
|
|||
ei_device_keyboard_key(kbd, KEY_Q + key, false); /* KEY_Q */
|
||||
key = (key + 1) % 6;
|
||||
}
|
||||
|
||||
if (have_abs) {
|
||||
static int x, y;
|
||||
colorprint("sending abs event\n");
|
||||
ei_device_pointer_motion_absolute(abs, 150 + ++x, 150 - ++y);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue