1
0

litest-device-vmware-virtual-usb-mouse.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright © 2014 Red Hat, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #include "config.h"
  24. #include <assert.h>
  25. #include "litest-int.h"
  26. #include "litest.h"
  27. static bool
  28. touch_down(struct litest_device *d, unsigned int slot, double x, double y)
  29. {
  30. assert(slot == 0);
  31. litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x));
  32. litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y));
  33. litest_event(d, EV_SYN, SYN_REPORT, 0);
  34. return true; /* we handled the event */
  35. }
  36. static bool
  37. touch_move(struct litest_device *d, unsigned int slot, double x, double y)
  38. {
  39. assert(slot == 0);
  40. litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x));
  41. litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y));
  42. litest_event(d, EV_SYN, SYN_REPORT, 0);
  43. return true; /* we handled the event */
  44. }
  45. static bool
  46. touch_up(struct litest_device *d, unsigned int slot)
  47. {
  48. assert(slot == 0);
  49. litest_event(d, EV_SYN, SYN_REPORT, 0);
  50. return true; /* we handled the event */
  51. }
  52. static struct litest_device_interface interface = {
  53. .touch_down = touch_down,
  54. .touch_move = touch_move,
  55. .touch_up = touch_up,
  56. };
  57. /* clang-format off */
  58. static struct input_absinfo absinfo[] = {
  59. { ABS_X, 0, 32767, 0, 0, 0 },
  60. { ABS_Y, 0, 32767, 0, 0, 0 },
  61. { .value = -1 },
  62. };
  63. /* clang-format on */
  64. static struct input_id input_id = {
  65. .bustype = 0x03,
  66. .vendor = 0xe0f,
  67. .product = 0x03,
  68. };
  69. /* clang-format off */
  70. static int events[] = {
  71. EV_KEY, BTN_LEFT,
  72. EV_KEY, BTN_RIGHT,
  73. EV_KEY, BTN_MIDDLE,
  74. EV_KEY, BTN_SIDE,
  75. EV_KEY, BTN_EXTRA,
  76. EV_KEY, BTN_FORWARD,
  77. EV_KEY, BTN_BACK,
  78. EV_KEY, BTN_TASK,
  79. EV_KEY, 280,
  80. EV_KEY, 281,
  81. EV_KEY, 282,
  82. EV_KEY, 283,
  83. EV_KEY, 284,
  84. EV_KEY, 285,
  85. EV_KEY, 286,
  86. EV_KEY, 287,
  87. EV_REL, REL_WHEEL,
  88. EV_REL, REL_HWHEEL,
  89. -1, -1,
  90. };
  91. /* clang-format on */
  92. TEST_DEVICE(LITEST_VMWARE_VIRTMOUSE,
  93. .features = LITEST_WHEEL | LITEST_BUTTON | LITEST_ABSOLUTE |
  94. LITEST_NO_DEBOUNCE,
  95. .interface = &interface,
  96. .name = "VMware VMware Virtual USB Mouse",
  97. .id = &input_id,
  98. .events = events,
  99. .absinfo = absinfo,
  100. .udev_properties = {
  101. { "ID_INTEGRATION", "external" },
  102. { NULL },
  103. }, )