1
0

litest-device-ploopy-pavonis-stylus.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright © 2025 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. /* Device from https://gitlab.freedesktop.org/libinput/libinput/-/issues/1152 */
  24. #include "config.h"
  25. #include "litest-int.h"
  26. #include "litest.h"
  27. /*
  28. * Copyright © 2014 Red Hat, Inc.
  29. *
  30. * Permission is hereby granted, free of charge, to any person obtaining a
  31. * copy of this software and associated documentation files (the "Software"),
  32. * to deal in the Software without restriction, including without limitation
  33. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  34. * and/or sell copies of the Software, and to permit persons to whom the
  35. * Software is furnished to do so, subject to the following conditions:
  36. *
  37. * The above copyright notice and this permission notice (including the next
  38. * paragraph) shall be included in all copies or substantial portions of the
  39. * Software.
  40. *
  41. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  44. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  46. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  47. * DEALINGS IN THE SOFTWARE.
  48. */
  49. #include "config.h"
  50. #include "litest-int.h"
  51. #include "litest.h"
  52. static struct input_event proximity_in[] = {
  53. { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
  54. { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
  55. { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
  56. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  57. { .type = -1, .code = -1 },
  58. };
  59. static struct input_event proximity_out[] = {
  60. { .type = EV_ABS, .code = ABS_X, .value = 0 },
  61. { .type = EV_ABS, .code = ABS_Y, .value = 0 },
  62. { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
  63. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  64. { .type = -1, .code = -1 },
  65. };
  66. static struct input_event motion[] = {
  67. { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
  68. { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
  69. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  70. { .type = -1, .code = -1 },
  71. };
  72. static int
  73. get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
  74. {
  75. abort();
  76. return 1;
  77. }
  78. static struct litest_device_interface interface = {
  79. .tablet_proximity_in_events = proximity_in,
  80. .tablet_proximity_out_events = proximity_out,
  81. .tablet_motion_events = motion,
  82. .get_axis_default = get_axis_default,
  83. };
  84. /* clang-format off */
  85. static struct input_absinfo absinfo[] = {
  86. { ABS_X, 0, 15600, 0, 0, 100 },
  87. { ABS_Y, 0, 9900, 0, 0, 100 },
  88. { .value = -1 },
  89. };
  90. /* clang-format on */
  91. static struct input_id input_id = {
  92. .bustype = 0x3,
  93. .vendor = 0xfeed,
  94. .product = 0x0000,
  95. };
  96. /* clang-format off */
  97. static int events[] = {
  98. EV_KEY, BTN_TOOL_PEN,
  99. EV_KEY, BTN_TOUCH,
  100. EV_KEY, BTN_STYLUS,
  101. EV_MSC, MSC_SCAN,
  102. INPUT_PROP_MAX, INPUT_PROP_DIRECT,
  103. -1, -1,
  104. };
  105. /* clang-format on */
  106. TEST_DEVICE(LITEST_PLOOPY_PAVONIS_STYLUS,
  107. .features = LITEST_TABLET,
  108. .interface = &interface,
  109. .name = "Ploopy Corporation Ploopy Pavonis Trackpad Stylus",
  110. .id = &input_id,
  111. .events = events,
  112. .absinfo = absinfo,
  113. .udev_properties = {
  114. { "ID_INTEGRATION", "external" },
  115. { NULL },
  116. }, )