litest-device-aiptek-tablet.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright © 2017 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 "litest-int.h"
  25. #include "litest.h"
  26. static struct input_event proximity_in[] = {
  27. /* Note: this device does not send BTN_TOOL_PEN */
  28. { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
  29. { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
  30. /* Note: this device does not send tilt, despite claiming it has it */
  31. { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
  32. { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
  33. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  34. { .type = -1, .code = -1 },
  35. };
  36. static struct input_event proximity_out[] = {
  37. /* This tablet doesn't report BTN_TOOL_PEN 0 on proximity out but I *think*
  38. * it still reports pressure values of zero? Who knows, we'd have to
  39. * get our hands on the tablet again. Meanwhile, let's force the
  40. * pressure to zero at least so other tests don't have to guess.
  41. */
  42. { .type = EV_ABS, .code = ABS_PRESSURE, .value = 0 },
  43. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  44. { .type = -1, .code = -1 },
  45. };
  46. static struct input_event motion[] = {
  47. { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
  48. { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
  49. /* Note: this device does not send tilt, despite claiming it has it */
  50. { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
  51. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  52. { .type = -1, .code = -1 },
  53. };
  54. static int
  55. get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
  56. {
  57. switch (evcode) {
  58. case ABS_PRESSURE:
  59. *value = 100;
  60. return 0;
  61. }
  62. return 1;
  63. }
  64. static struct litest_device_interface interface = {
  65. .tablet_proximity_in_events = proximity_in,
  66. .tablet_proximity_out_events = proximity_out,
  67. .tablet_motion_events = motion,
  68. .get_axis_default = get_axis_default,
  69. };
  70. /* clang-format off */
  71. static struct input_absinfo absinfo[] = {
  72. { ABS_X, 0, 5999, 0, 0, 26 },
  73. { ABS_Y, 0, 4499, 0, 0, 15 },
  74. { ABS_WHEEL, 0, 1023, 0, 0, 0 }, /* mute axis */
  75. { ABS_PRESSURE, 0, 1023, 0, 0, 0 },
  76. { ABS_TILT_X, -128, 127, 0, 0, 0 }, /* mute axis */
  77. { ABS_TILT_Y, -128, 127, 0, 0, 0 }, /* mute axis */
  78. { .value = -1 },
  79. };
  80. /* clang-format on */
  81. static struct input_id input_id = {
  82. .bustype = 0x3,
  83. .vendor = 0x8ca,
  84. .product = 0x10,
  85. };
  86. /* clang-format off */
  87. static int events[] = {
  88. EV_KEY, KEY_ESC,
  89. EV_KEY, KEY_F1,
  90. EV_KEY, KEY_F2,
  91. EV_KEY, KEY_F3,
  92. EV_KEY, KEY_F4,
  93. EV_KEY, KEY_F5,
  94. EV_KEY, KEY_F6,
  95. EV_KEY, KEY_F7,
  96. EV_KEY, KEY_F8,
  97. EV_KEY, KEY_F9,
  98. EV_KEY, KEY_F10,
  99. EV_KEY, KEY_F11,
  100. EV_KEY, KEY_F12,
  101. EV_KEY, KEY_STOP,
  102. EV_KEY, KEY_AGAIN,
  103. EV_KEY, KEY_PROPS,
  104. EV_KEY, KEY_UNDO,
  105. EV_KEY, KEY_FRONT,
  106. EV_KEY, KEY_COPY,
  107. EV_KEY, KEY_OPEN,
  108. EV_KEY, KEY_PASTE,
  109. EV_KEY, KEY_F13,
  110. EV_KEY, KEY_F14,
  111. EV_KEY, KEY_F15,
  112. EV_KEY, KEY_F16,
  113. EV_KEY, KEY_F17,
  114. EV_KEY, KEY_F18,
  115. EV_KEY, KEY_F19,
  116. EV_KEY, KEY_F20,
  117. EV_KEY, KEY_F21,
  118. EV_KEY, KEY_F22,
  119. EV_KEY, KEY_F23,
  120. EV_KEY, KEY_F24,
  121. EV_KEY, BTN_LEFT,
  122. EV_KEY, BTN_RIGHT,
  123. EV_KEY, BTN_MIDDLE,
  124. EV_KEY, BTN_TOOL_PEN,
  125. EV_KEY, BTN_TOOL_RUBBER,
  126. EV_KEY, BTN_TOOL_BRUSH,
  127. EV_KEY, BTN_TOOL_PENCIL,
  128. EV_KEY, BTN_TOOL_AIRBRUSH,
  129. EV_KEY, BTN_TOOL_MOUSE,
  130. EV_KEY, BTN_TOOL_LENS,
  131. EV_KEY, BTN_TOUCH,
  132. EV_KEY, BTN_STYLUS,
  133. EV_KEY, BTN_STYLUS2,
  134. EV_REL, REL_X,
  135. EV_REL, REL_Y,
  136. EV_REL, REL_WHEEL,
  137. EV_MSC, MSC_SERIAL,
  138. -1, -1,
  139. };
  140. /* clang-format on */
  141. TEST_DEVICE(LITEST_AIPTEK,
  142. .features = LITEST_TABLET | LITEST_HOVER | LITEST_FORCED_PROXOUT,
  143. .interface = &interface,
  144. .name = "Aiptek",
  145. .id = &input_id,
  146. .events = events,
  147. .absinfo = absinfo,
  148. .udev_properties = {
  149. { "ID_INTEGRATION", "external" },
  150. { NULL },
  151. }, )