1
0

litest-device-dell-canvas-totem.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright © 2018 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. /* We don't expect anything but slot 0 to be used, ever */
  27. #define TOTEM_SLOT 0
  28. static struct input_event down[] = {
  29. { .type = EV_ABS, .code = ABS_MT_SLOT, .value = TOTEM_SLOT },
  30. { .type = EV_ABS,
  31. .code = ABS_MT_TOOL_TYPE,
  32. .value = MT_TOOL_DIAL }, /* fixed value in device */
  33. { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
  34. { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
  35. { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
  36. { .type = EV_ABS, .code = ABS_MT_ORIENTATION, .value = LITEST_AUTO_ASSIGN },
  37. { .type = EV_ABS,
  38. .code = ABS_MT_TOUCH_MAJOR,
  39. .value = 718 }, /* fixed value in device */
  40. { .type = EV_ABS, .code = ABS_MT_TOUCH_MINOR, .value = 718 },
  41. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  42. { .type = -1, .code = -1 },
  43. };
  44. static struct input_event move[] = {
  45. { .type = EV_ABS, .code = ABS_MT_SLOT, .value = TOTEM_SLOT },
  46. { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
  47. { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
  48. { .type = EV_ABS, .code = ABS_MT_ORIENTATION, .value = LITEST_AUTO_ASSIGN },
  49. { .type = EV_ABS,
  50. .code = ABS_MT_TOUCH_MAJOR,
  51. .value = 718 }, /* fixed value in device */
  52. { .type = EV_ABS, .code = ABS_MT_TOUCH_MINOR, .value = 718 },
  53. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  54. { .type = -1, .code = -1 },
  55. };
  56. static struct input_event up[] = {
  57. { .type = EV_ABS, .code = ABS_MT_SLOT, .value = TOTEM_SLOT },
  58. { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
  59. { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
  60. { .type = -1, .code = -1 },
  61. };
  62. static int
  63. get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
  64. {
  65. switch (evcode) {
  66. case ABS_MT_ORIENTATION:
  67. *value = 0;
  68. return 0;
  69. }
  70. return 1;
  71. }
  72. static struct litest_device_interface interface = {
  73. .tablet_proximity_in_events = down,
  74. .tablet_proximity_out_events = up,
  75. .tablet_motion_events = move,
  76. .get_axis_default = get_axis_default,
  77. };
  78. /* clang-format off */
  79. static struct input_absinfo absinfo[] = {
  80. { ABS_MT_SLOT, 0, 4, 0, 0, 0 },
  81. { ABS_MT_TOUCH_MAJOR, 0, 32767, 0, 0, 10 },
  82. { ABS_MT_TOUCH_MINOR, 0, 32767, 0, 0, 10 },
  83. { ABS_MT_ORIENTATION, -89, 89, 0, 0, 0 },
  84. { ABS_MT_POSITION_X, 0, 32767, 0, 0, 55 },
  85. { ABS_MT_POSITION_Y, 0, 32767, 0, 0, 98 },
  86. /* The real device has a min/max of 10/10 but uinput didn't allow
  87. * this */
  88. { ABS_MT_TOOL_TYPE, 9, 10, 0, 0, 0 },
  89. { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
  90. { .value = -1 },
  91. };
  92. /* clang-format on */
  93. static struct input_id input_id = {
  94. .bustype = 0x3,
  95. .vendor = 0x2575,
  96. .product = 0x0204,
  97. .version = 0x111,
  98. };
  99. /* clang-format off */
  100. static int events[] = {
  101. EV_KEY, BTN_0,
  102. EV_MSC, MSC_TIMESTAMP,
  103. INPUT_PROP_MAX, INPUT_PROP_DIRECT,
  104. -1, -1,
  105. };
  106. /* clang-format on */
  107. TEST_DEVICE(LITEST_DELL_CANVAS_TOTEM,
  108. .features = LITEST_TOTEM | LITEST_TABLET,
  109. .interface = &interface,
  110. .name = "Advanced Silicon S.A. CoolTouch® System System Multi Axis",
  111. .id = &input_id,
  112. .events = events,
  113. .absinfo = absinfo,
  114. .udev_properties = {
  115. { "LIBINPUT_DEVICE_GROUP", "dell-canvas-totem-group" },
  116. { "ID_INTEGRATION", "external" },
  117. { NULL },
  118. }, )