test-pad.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. /*
  2. * Copyright © 2016 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 <errno.h>
  25. #include <fcntl.h>
  26. #include <libinput.h>
  27. #include <stdbool.h>
  28. #include <unistd.h>
  29. #ifdef HAVE_LIBWACOM
  30. #include <libwacom/libwacom.h>
  31. #endif
  32. #include "libinput-util.h"
  33. #include "litest.h"
  34. START_TEST(pad_cap)
  35. {
  36. struct litest_device *dev = litest_current_device();
  37. struct libinput_device *device = dev->libinput_device;
  38. litest_assert(
  39. libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD));
  40. }
  41. END_TEST
  42. START_TEST(pad_no_cap)
  43. {
  44. struct litest_device *dev = litest_current_device();
  45. struct libinput_device *device = dev->libinput_device;
  46. litest_assert(!libinput_device_has_capability(device,
  47. LIBINPUT_DEVICE_CAP_TABLET_PAD));
  48. }
  49. END_TEST
  50. START_TEST(pad_time)
  51. {
  52. struct litest_device *dev = litest_current_device();
  53. struct libinput *li = dev->libinput;
  54. struct libinput_event *ev;
  55. struct libinput_event_tablet_pad *pev;
  56. unsigned int code;
  57. uint64_t time, time_usec, oldtime;
  58. bool has_buttons = false;
  59. litest_drain_events(li);
  60. for (code = BTN_0; code < BTN_DIGI; code++) {
  61. if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
  62. continue;
  63. has_buttons = true;
  64. litest_button_click(dev, code, 1);
  65. litest_button_click(dev, code, 0);
  66. litest_dispatch(li);
  67. break;
  68. }
  69. if (!has_buttons)
  70. return LITEST_NOT_APPLICABLE;
  71. ev = libinput_get_event(li);
  72. litest_assert_notnull(ev);
  73. litest_assert_event_type(ev, LIBINPUT_EVENT_TABLET_PAD_BUTTON);
  74. pev = libinput_event_get_tablet_pad_event(ev);
  75. time = libinput_event_tablet_pad_get_time(pev);
  76. time_usec = libinput_event_tablet_pad_get_time_usec(pev);
  77. litest_assert(time != 0);
  78. litest_assert(time == time_usec / 1000);
  79. libinput_event_destroy(ev);
  80. litest_drain_events(li);
  81. msleep(10);
  82. litest_button_click(dev, code, 1);
  83. litest_button_click(dev, code, 0);
  84. litest_dispatch(li);
  85. ev = libinput_get_event(li);
  86. litest_assert_event_type(ev, LIBINPUT_EVENT_TABLET_PAD_BUTTON);
  87. pev = libinput_event_get_tablet_pad_event(ev);
  88. oldtime = time;
  89. time = libinput_event_tablet_pad_get_time(pev);
  90. time_usec = libinput_event_tablet_pad_get_time_usec(pev);
  91. litest_assert(time > oldtime);
  92. litest_assert(time != 0);
  93. litest_assert(time == time_usec / 1000);
  94. libinput_event_destroy(ev);
  95. }
  96. END_TEST
  97. START_TEST(pad_num_buttons_libwacom)
  98. {
  99. #ifdef HAVE_LIBWACOM
  100. struct litest_device *dev = litest_current_device();
  101. struct libinput_device *device = dev->libinput_device;
  102. WacomDeviceDatabase *db = NULL;
  103. WacomDevice *wacom = NULL;
  104. unsigned int nb_lw, nb;
  105. db = libwacom_database_new();
  106. litest_assert_notnull(db);
  107. wacom = libwacom_new_from_usbid(db,
  108. libevdev_get_id_vendor(dev->evdev),
  109. libevdev_get_id_product(dev->evdev),
  110. NULL);
  111. litest_assert_notnull(wacom);
  112. nb_lw = libwacom_get_num_buttons(wacom);
  113. nb = libinput_device_tablet_pad_get_num_buttons(device);
  114. litest_assert_int_eq(nb, nb_lw);
  115. libwacom_destroy(wacom);
  116. libwacom_database_destroy(db);
  117. #endif
  118. }
  119. END_TEST
  120. START_TEST(pad_num_buttons)
  121. {
  122. struct litest_device *dev = litest_current_device();
  123. struct libinput_device *device = dev->libinput_device;
  124. unsigned int code;
  125. int nbuttons = 0;
  126. for (code = BTN_0; code < KEY_OK; code++) {
  127. /* BTN_STYLUS is set for compatibility reasons but not
  128. * actually hooked up */
  129. if (code == BTN_STYLUS)
  130. continue;
  131. if (libevdev_has_event_code(dev->evdev, EV_KEY, code))
  132. nbuttons++;
  133. }
  134. litest_assert_int_eq(libinput_device_tablet_pad_get_num_buttons(device),
  135. nbuttons);
  136. }
  137. END_TEST
  138. START_TEST(pad_button_intuos)
  139. {
  140. #ifndef HAVE_LIBWACOM
  141. struct litest_device *dev = litest_current_device();
  142. struct libinput *li = dev->libinput;
  143. unsigned int code;
  144. unsigned int expected_number = 0;
  145. struct libinput_event *ev;
  146. struct libinput_event_tablet_pad *pev;
  147. unsigned int count = 0;
  148. /* Intuos button mapping is sequential up from BTN_0 and continues
  149. * with BTN_A */
  150. if (!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_0))
  151. return LITEST_NOT_APPLICABLE;
  152. litest_drain_events(li);
  153. for (code = BTN_0; code < BTN_DIGI; code++) {
  154. /* Skip over the BTN_MOUSE and BTN_JOYSTICK range */
  155. if ((code >= BTN_MOUSE && code < BTN_JOYSTICK) || (code >= BTN_DIGI)) {
  156. litest_assert(
  157. !libevdev_has_event_code(dev->evdev, EV_KEY, code));
  158. continue;
  159. }
  160. if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
  161. continue;
  162. litest_button_click(dev, code, 1);
  163. litest_button_click(dev, code, 0);
  164. litest_dispatch(li);
  165. count++;
  166. ev = libinput_get_event(li);
  167. pev = litest_is_pad_button_event(ev,
  168. expected_number,
  169. LIBINPUT_BUTTON_STATE_PRESSED);
  170. ev = libinput_event_tablet_pad_get_base_event(pev);
  171. libinput_event_destroy(ev);
  172. ev = libinput_get_event(li);
  173. pev = litest_is_pad_button_event(ev,
  174. expected_number,
  175. LIBINPUT_BUTTON_STATE_RELEASED);
  176. ev = libinput_event_tablet_pad_get_base_event(pev);
  177. libinput_event_destroy(ev);
  178. expected_number++;
  179. }
  180. litest_assert_empty_queue(li);
  181. litest_assert_int_ge(count, 1U);
  182. #endif
  183. }
  184. END_TEST
  185. START_TEST(pad_button_bamboo)
  186. {
  187. #ifndef HAVE_LIBWACOM
  188. struct litest_device *dev = litest_current_device();
  189. struct libinput *li = dev->libinput;
  190. unsigned int code;
  191. unsigned int expected_number = 0;
  192. struct libinput_event *ev;
  193. struct libinput_event_tablet_pad *pev;
  194. unsigned int count = 0;
  195. if (!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_LEFT))
  196. return LITEST_NOT_APPLICABLE;
  197. litest_drain_events(li);
  198. for (code = BTN_LEFT; code < BTN_JOYSTICK; code++) {
  199. if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
  200. continue;
  201. litest_button_click(dev, code, 1);
  202. litest_button_click(dev, code, 0);
  203. litest_dispatch(li);
  204. count++;
  205. ev = libinput_get_event(li);
  206. pev = litest_is_pad_button_event(ev,
  207. expected_number,
  208. LIBINPUT_BUTTON_STATE_PRESSED);
  209. ev = libinput_event_tablet_pad_get_base_event(pev);
  210. libinput_event_destroy(ev);
  211. ev = libinput_get_event(li);
  212. pev = litest_is_pad_button_event(ev,
  213. expected_number,
  214. LIBINPUT_BUTTON_STATE_RELEASED);
  215. ev = libinput_event_tablet_pad_get_base_event(pev);
  216. libinput_event_destroy(ev);
  217. expected_number++;
  218. }
  219. litest_assert_empty_queue(li);
  220. litest_assert_int_gt(count, 3U);
  221. #endif
  222. }
  223. END_TEST
  224. START_TEST(pad_button_libwacom)
  225. {
  226. #ifdef HAVE_LIBWACOM
  227. struct litest_device *dev = litest_current_device();
  228. struct libinput *li = dev->libinput;
  229. WacomDeviceDatabase *db = NULL;
  230. WacomDevice *wacom = NULL;
  231. db = libwacom_database_new();
  232. assert(db);
  233. wacom = libwacom_new_from_usbid(db,
  234. libevdev_get_id_vendor(dev->evdev),
  235. libevdev_get_id_product(dev->evdev),
  236. NULL);
  237. assert(wacom);
  238. litest_drain_events(li);
  239. for (int i = 0; i < libwacom_get_num_buttons(wacom); i++) {
  240. unsigned int code;
  241. code = libwacom_get_button_evdev_code(wacom, 'A' + i);
  242. litest_button_click(dev, code, 1);
  243. litest_button_click(dev, code, 0);
  244. litest_dispatch(li);
  245. litest_assert_pad_button_event(li, i, LIBINPUT_BUTTON_STATE_PRESSED);
  246. litest_assert_pad_button_event(li, i, LIBINPUT_BUTTON_STATE_RELEASED);
  247. }
  248. libwacom_destroy(wacom);
  249. libwacom_database_destroy(db);
  250. #endif
  251. }
  252. END_TEST
  253. START_TEST(pad_button_mode_groups)
  254. {
  255. struct litest_device *dev = litest_current_device();
  256. struct libinput *li = dev->libinput;
  257. struct libinput_event *ev;
  258. struct libinput_event_tablet_pad *pev;
  259. unsigned int expected_mode = 0;
  260. int evdev_codes[KEY_OK - BTN_0] = { 0 };
  261. #ifdef HAVE_LIBWACOM
  262. WacomDeviceDatabase *db = NULL;
  263. WacomDevice *wacom = NULL;
  264. db = libwacom_database_new();
  265. litest_assert_notnull(db);
  266. wacom = libwacom_new_from_usbid(db,
  267. libevdev_get_id_vendor(dev->evdev),
  268. libevdev_get_id_product(dev->evdev),
  269. NULL);
  270. if (wacom) {
  271. for (size_t i = 0; i < ARRAY_LENGTH(evdev_codes); i++) {
  272. evdev_codes[i] = libwacom_get_button_evdev_code(wacom, 'A' + i);
  273. }
  274. }
  275. libwacom_destroy(wacom);
  276. libwacom_database_destroy(db);
  277. #else
  278. for (size_t i = 0; i < ARRAY_LENGTH(evdev_codes); i++) {
  279. evdev_codes[i] = BTN_0 + 1;
  280. }
  281. #endif
  282. litest_drain_events(li);
  283. for (unsigned int b = 0; b < ARRAY_LENGTH(evdev_codes) && evdev_codes[b] != 0;
  284. b++) {
  285. unsigned int code = evdev_codes[b];
  286. unsigned int mode, index;
  287. struct libinput_tablet_pad_mode_group *group;
  288. if (!libevdev_has_event_code(dev->evdev, EV_KEY, code))
  289. continue;
  290. litest_button_click(dev, code, 1);
  291. litest_button_click(dev, code, 0);
  292. litest_dispatch(li);
  293. switch (code) {
  294. case BTN_STYLUS:
  295. litest_assert_empty_queue(li);
  296. continue;
  297. default:
  298. break;
  299. }
  300. ev = libinput_get_event(li);
  301. litest_assert_event_type(ev, LIBINPUT_EVENT_TABLET_PAD_BUTTON);
  302. pev = libinput_event_get_tablet_pad_event(ev);
  303. group = libinput_event_tablet_pad_get_mode_group(pev);
  304. #ifdef HAVE_LIBWACOM_BUTTON_MODESWITCH_MODE
  305. /* One of the few devices that has very specific mode switch buttons
  306. * so we hardcode these here in the test */
  307. if (dev->which == LITEST_WACOM_MOBILESTUDIO_PRO_16_PAD) {
  308. switch (code) {
  309. case BTN_9:
  310. expected_mode = 0;
  311. break;
  312. case BTN_A:
  313. expected_mode = 1;
  314. break;
  315. case BTN_B:
  316. expected_mode = 2;
  317. break;
  318. case BTN_C:
  319. expected_mode = 3;
  320. break;
  321. default:
  322. break;
  323. }
  324. } else
  325. #endif
  326. if (libinput_tablet_pad_mode_group_button_is_toggle(group, b)) {
  327. int num_modes =
  328. libinput_tablet_pad_mode_group_get_num_modes(group);
  329. expected_mode = (expected_mode + 1) % num_modes;
  330. }
  331. mode = libinput_event_tablet_pad_get_mode(pev);
  332. litest_assert_int_eq(mode, expected_mode);
  333. index = libinput_tablet_pad_mode_group_get_index(group);
  334. litest_assert_int_eq(index, 0U);
  335. libinput_event_destroy(ev);
  336. ev = libinput_get_event(li);
  337. litest_assert_event_type(ev, LIBINPUT_EVENT_TABLET_PAD_BUTTON);
  338. pev = libinput_event_get_tablet_pad_event(ev);
  339. mode = libinput_event_tablet_pad_get_mode(pev);
  340. litest_assert_int_eq(mode, expected_mode);
  341. group = libinput_event_tablet_pad_get_mode_group(pev);
  342. index = libinput_tablet_pad_mode_group_get_index(group);
  343. litest_assert_int_eq(index, 0U);
  344. libinput_event_destroy(ev);
  345. }
  346. litest_assert_empty_queue(li);
  347. }
  348. END_TEST
  349. START_TEST(pad_has_ring)
  350. {
  351. struct litest_device *dev = litest_current_device();
  352. struct libinput_device *device = dev->libinput_device;
  353. int nrings;
  354. nrings = libinput_device_tablet_pad_get_num_rings(device);
  355. litest_assert_int_ge(nrings, 1);
  356. }
  357. END_TEST
  358. START_TEST(pad_ring)
  359. {
  360. struct litest_device *dev = litest_current_device();
  361. struct libinput *li = dev->libinput;
  362. struct libinput_event *ev;
  363. struct libinput_event_tablet_pad *pev;
  364. int val;
  365. double degrees, expected;
  366. int min, max;
  367. int step_size;
  368. int nevents = 0;
  369. litest_pad_ring_start(dev, 10);
  370. litest_drain_events(li);
  371. /* Wacom's 0 value is at 275 degrees */
  372. expected = 270;
  373. min = libevdev_get_abs_minimum(dev->evdev, ABS_WHEEL);
  374. max = libevdev_get_abs_maximum(dev->evdev, ABS_WHEEL);
  375. step_size = 360 / (max - min + 1);
  376. /* This is a bit strange because we rely on kernel filtering here.
  377. The litest_*() functions take a percentage, but mapping this to
  378. the pads 72 or 36 range pad ranges is lossy and a bit
  379. unpredictable. So instead we increase by a small percentage,
  380. expecting *most* events to be filtered by the kernel because they
  381. resolve to the same integer value as the previous event. Whenever
  382. an event gets through, we expect that to be the next integer
  383. value in the range and thus the next step on the circle.
  384. */
  385. for (val = 0; val < 100.0; val += 1) {
  386. litest_pad_ring_change(dev, val);
  387. litest_dispatch(li);
  388. ev = libinput_get_event(li);
  389. if (!ev)
  390. continue;
  391. nevents++;
  392. pev = litest_is_pad_ring_event(ev,
  393. 0,
  394. LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER);
  395. degrees = libinput_event_tablet_pad_get_ring_position(pev);
  396. litest_assert_double_ge(degrees, 0.0);
  397. litest_assert_double_lt(degrees, 360.0);
  398. litest_assert_double_eq(degrees, expected);
  399. libinput_event_destroy(ev);
  400. expected = fmod(degrees + step_size, 360);
  401. }
  402. litest_assert_int_eq(nevents, 360 / step_size - 1);
  403. litest_pad_ring_end(dev);
  404. }
  405. END_TEST
  406. START_TEST(pad_ring_finger_up)
  407. {
  408. struct litest_device *dev = litest_current_device();
  409. struct libinput *li = dev->libinput;
  410. struct libinput_event *ev;
  411. struct libinput_event_tablet_pad *pev;
  412. double degrees;
  413. litest_pad_ring_start(dev, 10);
  414. litest_drain_events(li);
  415. litest_pad_ring_end(dev);
  416. litest_dispatch(li);
  417. ev = libinput_get_event(li);
  418. pev = litest_is_pad_ring_event(ev, 0, LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER);
  419. degrees = libinput_event_tablet_pad_get_ring_position(pev);
  420. litest_assert_double_eq(degrees, -1.0);
  421. libinput_event_destroy(ev);
  422. litest_assert_empty_queue(li);
  423. }
  424. END_TEST
  425. START_TEST(pad_has_dial)
  426. {
  427. struct litest_device *dev = litest_current_device();
  428. struct libinput_device *device = dev->libinput_device;
  429. int ndials;
  430. int expected_ndials = 1;
  431. if (libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL))
  432. expected_ndials = 2;
  433. ndials = libinput_device_tablet_pad_get_num_dials(device);
  434. litest_assert_int_eq(ndials, expected_ndials);
  435. }
  436. END_TEST
  437. START_TEST(pad_dial_low_res)
  438. {
  439. struct litest_device *dev = litest_current_device();
  440. struct libinput *li = dev->libinput;
  441. unsigned int code = 0;
  442. if (libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL))
  443. code = REL_WHEEL;
  444. if (libevdev_has_event_code(dev->evdev, EV_REL, REL_DIAL))
  445. code = REL_DIAL;
  446. litest_drain_events(li);
  447. for (int i = 0; i < 10; i++) {
  448. int direction = -1 + 2 * i % 2;
  449. litest_event(dev, EV_REL, code, direction);
  450. if (code == REL_WHEEL)
  451. litest_event(dev, EV_REL, REL_WHEEL_HI_RES, direction * 120);
  452. litest_event(dev, EV_SYN, SYN_REPORT, 0);
  453. litest_dispatch(li);
  454. struct libinput_event *ev = libinput_get_event(li);
  455. struct libinput_event_tablet_pad *pev = litest_is_pad_dial_event(ev, 0);
  456. double v120 = libinput_event_tablet_pad_get_dial_delta_v120(pev);
  457. switch (code) {
  458. case REL_WHEEL: /* inverted */
  459. litest_assert_double_eq(v120, -120.0 * direction);
  460. break;
  461. case REL_DIAL:
  462. litest_assert_double_eq(v120, 120.0 * direction);
  463. break;
  464. default:
  465. litest_abort_msg("Invalid dial code");
  466. }
  467. libinput_event_destroy(ev);
  468. }
  469. }
  470. END_TEST
  471. START_TEST(pad_dial_hi_res)
  472. {
  473. struct litest_device *dev = litest_current_device();
  474. struct libinput *li = dev->libinput;
  475. const int increment = 30;
  476. int accumulated = 0;
  477. if (!libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL_HI_RES))
  478. return LITEST_NOT_APPLICABLE;
  479. litest_drain_events(li);
  480. for (int i = 0; i < 10; i++) {
  481. litest_event(dev, EV_REL, REL_WHEEL_HI_RES, increment);
  482. accumulated += increment;
  483. if (accumulated % 120 == 0)
  484. litest_event(dev, EV_REL, REL_WHEEL, 1);
  485. litest_event(dev, EV_SYN, SYN_REPORT, 0);
  486. litest_dispatch(li);
  487. struct libinput_event *ev = libinput_get_event(li);
  488. struct libinput_event_tablet_pad *pev = litest_is_pad_dial_event(ev, 0);
  489. double v120 = libinput_event_tablet_pad_get_dial_delta_v120(pev);
  490. litest_assert_double_eq(v120, -increment); /* REL_WHEEL is inverted */
  491. libinput_event_destroy(ev);
  492. }
  493. }
  494. END_TEST
  495. START_TEST(pad_has_strip)
  496. {
  497. struct litest_device *dev = litest_current_device();
  498. struct libinput_device *device = dev->libinput_device;
  499. int nstrips;
  500. nstrips = libinput_device_tablet_pad_get_num_strips(device);
  501. litest_assert_int_ge(nstrips, 1);
  502. }
  503. END_TEST
  504. START_TEST(pad_strip)
  505. {
  506. struct litest_device *dev = litest_current_device();
  507. struct libinput *li = dev->libinput;
  508. struct libinput_event *ev;
  509. struct libinput_event_tablet_pad *pev;
  510. int val;
  511. double pos, expected;
  512. litest_pad_strip_start(dev, 10);
  513. litest_drain_events(li);
  514. expected = 0;
  515. /* 9.5 works with the generic axis scaling without jumping over a
  516. * value. */
  517. for (val = 0; val < 100; val += 9.5) {
  518. litest_pad_strip_change(dev, val);
  519. litest_dispatch(li);
  520. ev = libinput_get_event(li);
  521. pev = litest_is_pad_strip_event(
  522. ev,
  523. 0,
  524. LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER);
  525. pos = libinput_event_tablet_pad_get_strip_position(pev);
  526. litest_assert_double_ge(pos, 0.0);
  527. litest_assert_double_lt(pos, 1.0);
  528. /* rounding errors, mostly caused by small physical range */
  529. litest_assert_double_ge(pos, expected - 0.02);
  530. litest_assert_double_le(pos, expected + 0.02);
  531. libinput_event_destroy(ev);
  532. expected = pos + 0.08;
  533. }
  534. litest_pad_strip_change(dev, 100);
  535. litest_dispatch(li);
  536. ev = libinput_get_event(li);
  537. pev = litest_is_pad_strip_event(ev, 0, LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER);
  538. pos = libinput_event_tablet_pad_get_strip_position(pev);
  539. litest_assert_double_eq(pos, 1.0);
  540. libinput_event_destroy(ev);
  541. litest_pad_strip_end(dev);
  542. }
  543. END_TEST
  544. START_TEST(pad_strip_finger_up)
  545. {
  546. struct litest_device *dev = litest_current_device();
  547. struct libinput *li = dev->libinput;
  548. struct libinput_event *ev;
  549. struct libinput_event_tablet_pad *pev;
  550. double pos;
  551. litest_pad_strip_start(dev, 10);
  552. litest_drain_events(li);
  553. litest_pad_strip_end(dev);
  554. litest_dispatch(li);
  555. ev = libinput_get_event(li);
  556. pev = litest_is_pad_strip_event(ev, 0, LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER);
  557. pos = libinput_event_tablet_pad_get_strip_position(pev);
  558. litest_assert_double_eq(pos, -1.0);
  559. libinput_event_destroy(ev);
  560. litest_assert_empty_queue(li);
  561. }
  562. END_TEST
  563. START_TEST(pad_left_handed_default)
  564. {
  565. #ifdef HAVE_LIBWACOM
  566. struct litest_device *dev = litest_current_device();
  567. struct libinput_device *device = dev->libinput_device;
  568. enum libinput_config_status status;
  569. litest_assert(libinput_device_config_left_handed_is_available(device));
  570. litest_assert_int_eq(libinput_device_config_left_handed_get_default(device), 0);
  571. litest_assert_int_eq(libinput_device_config_left_handed_get(device), 0);
  572. status = libinput_device_config_left_handed_set(dev->libinput_device, 1);
  573. litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
  574. litest_assert_int_eq(libinput_device_config_left_handed_get(device), 1);
  575. litest_assert_int_eq(libinput_device_config_left_handed_get_default(device), 0);
  576. status = libinput_device_config_left_handed_set(dev->libinput_device, 0);
  577. litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
  578. litest_assert_int_eq(libinput_device_config_left_handed_get(device), 0);
  579. litest_assert_int_eq(libinput_device_config_left_handed_get_default(device), 0);
  580. #endif
  581. }
  582. END_TEST
  583. START_TEST(pad_no_left_handed)
  584. {
  585. struct litest_device *dev = litest_current_device();
  586. struct libinput_device *device = dev->libinput_device;
  587. /* Without libwacom we default to left-handed being available */
  588. #ifdef HAVE_LIBWACOM
  589. litest_assert(!libinput_device_config_left_handed_is_available(device));
  590. #else
  591. litest_assert(libinput_device_config_left_handed_is_available(device));
  592. #endif
  593. litest_assert_int_eq(libinput_device_config_left_handed_get_default(device), 0);
  594. litest_assert_int_eq(libinput_device_config_left_handed_get(device), 0);
  595. #ifdef HAVE_LIBWACOM
  596. enum libinput_config_status status;
  597. status = libinput_device_config_left_handed_set(dev->libinput_device, 1);
  598. litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
  599. litest_assert_int_eq(libinput_device_config_left_handed_get(device), 0);
  600. litest_assert_int_eq(libinput_device_config_left_handed_get_default(device), 0);
  601. status = libinput_device_config_left_handed_set(dev->libinput_device, 0);
  602. litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
  603. litest_assert_int_eq(libinput_device_config_left_handed_get(device), 0);
  604. litest_assert_int_eq(libinput_device_config_left_handed_get_default(device), 0);
  605. #endif
  606. }
  607. END_TEST
  608. START_TEST(pad_left_handed_ring)
  609. {
  610. #ifdef HAVE_LIBWACOM
  611. struct litest_device *dev = litest_current_device();
  612. struct libinput *li = dev->libinput;
  613. struct libinput_event *ev;
  614. struct libinput_event_tablet_pad *pev;
  615. int val;
  616. double degrees, expected;
  617. libinput_device_config_left_handed_set(dev->libinput_device, 1);
  618. litest_pad_ring_start(dev, 10);
  619. litest_drain_events(li);
  620. /* Wacom's 0 value is at 275 degrees -> 90 in left-handed mode*/
  621. expected = 90;
  622. for (val = 0; val < 100; val += 10) {
  623. litest_pad_ring_change(dev, val);
  624. litest_dispatch(li);
  625. ev = libinput_get_event(li);
  626. pev = litest_is_pad_ring_event(ev,
  627. 0,
  628. LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER);
  629. degrees = libinput_event_tablet_pad_get_ring_position(pev);
  630. litest_assert_double_ge(degrees, 0.0);
  631. litest_assert_double_lt(degrees, 360.0);
  632. /* rounding errors, mostly caused by small physical range */
  633. litest_assert_double_ge(degrees, expected - 2);
  634. litest_assert_double_le(degrees, expected + 2);
  635. libinput_event_destroy(ev);
  636. expected = fmod(degrees + 36, 360);
  637. }
  638. litest_pad_ring_end(dev);
  639. #endif
  640. }
  641. END_TEST
  642. static bool
  643. pad_has_groups(struct litest_device *dev)
  644. {
  645. bool rc = false;
  646. #ifdef HAVE_LIBWACOM
  647. WacomDeviceDatabase *db = NULL;
  648. WacomDevice *wacom = NULL;
  649. db = libwacom_database_new();
  650. litest_assert_notnull(db);
  651. wacom = libwacom_new_from_usbid(db,
  652. libevdev_get_id_vendor(dev->evdev),
  653. libevdev_get_id_product(dev->evdev),
  654. NULL);
  655. if (wacom && (libwacom_get_ring_num_modes(wacom) != 0 ||
  656. libwacom_get_ring2_num_modes(wacom) != 0 ||
  657. libwacom_get_strips_num_modes(wacom) != 0))
  658. rc = true;
  659. libwacom_destroy(wacom);
  660. libwacom_database_destroy(db);
  661. #endif
  662. return rc;
  663. }
  664. START_TEST(pad_mode_groups)
  665. {
  666. struct litest_device *dev = litest_current_device();
  667. struct libinput_device *device = dev->libinput_device;
  668. struct libinput_tablet_pad_mode_group *group;
  669. int ngroups;
  670. unsigned int i;
  671. ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
  672. litest_assert_int_ge(ngroups, 1);
  673. for (i = 0; i < (unsigned int)ngroups; i++) {
  674. group = libinput_device_tablet_pad_get_mode_group(device, i);
  675. litest_assert_notnull(group);
  676. litest_assert_int_eq(libinput_tablet_pad_mode_group_get_index(group),
  677. i);
  678. }
  679. group = libinput_device_tablet_pad_get_mode_group(device, ngroups);
  680. litest_assert(group == NULL);
  681. group = libinput_device_tablet_pad_get_mode_group(device, ngroups + 1);
  682. litest_assert(group == NULL);
  683. }
  684. END_TEST
  685. START_TEST(pad_mode_groups_userdata)
  686. {
  687. struct litest_device *dev = litest_current_device();
  688. struct libinput_device *device = dev->libinput_device;
  689. struct libinput_tablet_pad_mode_group *group;
  690. int rc;
  691. void *userdata = &rc;
  692. group = libinput_device_tablet_pad_get_mode_group(device, 0);
  693. litest_assert(libinput_tablet_pad_mode_group_get_user_data(group) == NULL);
  694. libinput_tablet_pad_mode_group_set_user_data(group, userdata);
  695. litest_assert(libinput_tablet_pad_mode_group_get_user_data(group) == &rc);
  696. libinput_tablet_pad_mode_group_set_user_data(group, NULL);
  697. litest_assert(libinput_tablet_pad_mode_group_get_user_data(group) == NULL);
  698. }
  699. END_TEST
  700. START_TEST(pad_mode_groups_ref)
  701. {
  702. struct litest_device *dev = litest_current_device();
  703. struct libinput_device *device = dev->libinput_device;
  704. struct libinput_tablet_pad_mode_group *group, *g;
  705. group = libinput_device_tablet_pad_get_mode_group(device, 0);
  706. g = libinput_tablet_pad_mode_group_ref(group);
  707. litest_assert_ptr_eq(g, group);
  708. /* We don't expect this to be freed. Any leaks should be caught by
  709. * valgrind. */
  710. g = libinput_tablet_pad_mode_group_unref(group);
  711. litest_assert_ptr_eq(g, group);
  712. }
  713. END_TEST
  714. START_TEST(pad_mode_group_mode)
  715. {
  716. struct litest_device *dev = litest_current_device();
  717. struct libinput_device *device = dev->libinput_device;
  718. struct libinput_tablet_pad_mode_group *group;
  719. int ngroups;
  720. unsigned int nmodes, mode;
  721. if (pad_has_groups(dev))
  722. return LITEST_NOT_APPLICABLE;
  723. ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
  724. litest_assert_int_ge(ngroups, 1);
  725. group = libinput_device_tablet_pad_get_mode_group(device, 0);
  726. nmodes = libinput_tablet_pad_mode_group_get_num_modes(group);
  727. litest_assert_int_eq(nmodes, 1U);
  728. mode = libinput_tablet_pad_mode_group_get_mode(group);
  729. litest_assert_int_lt(mode, nmodes);
  730. }
  731. END_TEST
  732. START_TEST(pad_mode_group_has)
  733. {
  734. struct litest_device *dev = litest_current_device();
  735. struct libinput_device *device = dev->libinput_device;
  736. struct libinput_tablet_pad_mode_group *group;
  737. int ngroups, nbuttons, nrings, nstrips;
  738. int i, b, r, s;
  739. ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
  740. litest_assert_int_ge(ngroups, 1);
  741. nbuttons = libinput_device_tablet_pad_get_num_buttons(device);
  742. nrings = libinput_device_tablet_pad_get_num_rings(device);
  743. nstrips = libinput_device_tablet_pad_get_num_strips(device);
  744. for (b = 0; b < nbuttons; b++) {
  745. bool found = false;
  746. for (i = 0; i < ngroups; i++) {
  747. group = libinput_device_tablet_pad_get_mode_group(device, i);
  748. if (libinput_tablet_pad_mode_group_has_button(group, b)) {
  749. litest_assert(!found);
  750. found = true;
  751. }
  752. }
  753. litest_assert(found);
  754. }
  755. for (s = 0; s < nstrips; s++) {
  756. bool found = false;
  757. for (i = 0; i < ngroups; i++) {
  758. group = libinput_device_tablet_pad_get_mode_group(device, i);
  759. if (libinput_tablet_pad_mode_group_has_strip(group, s)) {
  760. litest_assert(!found);
  761. found = true;
  762. }
  763. }
  764. litest_assert(found);
  765. }
  766. for (r = 0; r < nrings; r++) {
  767. bool found = false;
  768. for (i = 0; i < ngroups; i++) {
  769. group = libinput_device_tablet_pad_get_mode_group(device, i);
  770. if (libinput_tablet_pad_mode_group_has_ring(group, r)) {
  771. litest_assert(!found);
  772. found = true;
  773. }
  774. }
  775. litest_assert(found);
  776. }
  777. }
  778. END_TEST
  779. START_TEST(pad_mode_group_has_invalid)
  780. {
  781. struct litest_device *dev = litest_current_device();
  782. struct libinput_device *device = dev->libinput_device;
  783. struct libinput_tablet_pad_mode_group *group;
  784. int ngroups, nbuttons, nrings, nstrips;
  785. int i;
  786. int rc;
  787. ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
  788. litest_assert_int_ge(ngroups, 1);
  789. nbuttons = libinput_device_tablet_pad_get_num_buttons(device);
  790. nrings = libinput_device_tablet_pad_get_num_rings(device);
  791. nstrips = libinput_device_tablet_pad_get_num_strips(device);
  792. for (i = 0; i < ngroups; i++) {
  793. group = libinput_device_tablet_pad_get_mode_group(device, i);
  794. rc = libinput_tablet_pad_mode_group_has_button(group, nbuttons);
  795. litest_assert_int_eq(rc, 0);
  796. rc = libinput_tablet_pad_mode_group_has_button(group, nbuttons + 1);
  797. litest_assert_int_eq(rc, 0);
  798. rc = libinput_tablet_pad_mode_group_has_button(group, 0x1000000);
  799. litest_assert_int_eq(rc, 0);
  800. }
  801. for (i = 0; i < ngroups; i++) {
  802. group = libinput_device_tablet_pad_get_mode_group(device, i);
  803. rc = libinput_tablet_pad_mode_group_has_strip(group, nstrips);
  804. litest_assert_int_eq(rc, 0);
  805. rc = libinput_tablet_pad_mode_group_has_strip(group, nstrips + 1);
  806. litest_assert_int_eq(rc, 0);
  807. rc = libinput_tablet_pad_mode_group_has_strip(group, 0x1000000);
  808. litest_assert_int_eq(rc, 0);
  809. }
  810. for (i = 0; i < ngroups; i++) {
  811. group = libinput_device_tablet_pad_get_mode_group(device, i);
  812. rc = libinput_tablet_pad_mode_group_has_ring(group, nrings);
  813. litest_assert_int_eq(rc, 0);
  814. rc = libinput_tablet_pad_mode_group_has_ring(group, nrings + 1);
  815. litest_assert_int_eq(rc, 0);
  816. rc = libinput_tablet_pad_mode_group_has_ring(group, 0x1000000);
  817. litest_assert_int_eq(rc, 0);
  818. }
  819. }
  820. END_TEST
  821. START_TEST(pad_mode_group_has_no_toggle)
  822. {
  823. #ifdef HAVE_LIBWACOM
  824. struct litest_device *dev = litest_current_device();
  825. struct libinput_device *device = dev->libinput_device;
  826. struct libinput_tablet_pad_mode_group *group;
  827. int ngroups, nbuttons;
  828. int i, b;
  829. if (pad_has_groups(dev))
  830. return LITEST_NOT_APPLICABLE;
  831. ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
  832. litest_assert_int_eq(ngroups, 1);
  833. /* Button must not be toggle buttons */
  834. nbuttons = libinput_device_tablet_pad_get_num_buttons(device);
  835. for (i = 0; i < ngroups; i++) {
  836. group = libinput_device_tablet_pad_get_mode_group(device, i);
  837. for (b = 0; b < nbuttons; b++) {
  838. litest_assert(
  839. !libinput_tablet_pad_mode_group_button_is_toggle(group,
  840. b));
  841. }
  842. }
  843. #endif
  844. }
  845. END_TEST
  846. static bool
  847. pad_has_keys(struct litest_device *dev)
  848. {
  849. struct libevdev *evdev = dev->evdev;
  850. return (libevdev_has_event_code(evdev, EV_KEY, KEY_BUTTONCONFIG) ||
  851. libevdev_has_event_code(evdev, EV_KEY, KEY_ONSCREEN_KEYBOARD) ||
  852. libevdev_has_event_code(evdev, EV_KEY, KEY_CONTROLPANEL));
  853. }
  854. static void
  855. pad_key_down(struct litest_device *dev, unsigned int which)
  856. {
  857. litest_event(dev, EV_ABS, ABS_MISC, 15);
  858. litest_event(dev, EV_KEY, which, 1);
  859. litest_event(dev, EV_SYN, SYN_REPORT, 0);
  860. }
  861. static void
  862. pad_key_up(struct litest_device *dev, unsigned int which)
  863. {
  864. litest_event(dev, EV_ABS, ABS_MISC, 0);
  865. litest_event(dev, EV_KEY, which, 0);
  866. litest_event(dev, EV_SYN, SYN_REPORT, 0);
  867. }
  868. START_TEST(pad_keys)
  869. {
  870. struct litest_device *dev = litest_current_device();
  871. struct libinput *li = dev->libinput;
  872. unsigned int key;
  873. if (!pad_has_keys(dev))
  874. return LITEST_NOT_APPLICABLE;
  875. litest_drain_events(li);
  876. key = KEY_BUTTONCONFIG;
  877. pad_key_down(dev, key);
  878. litest_dispatch(li);
  879. litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_PRESSED);
  880. pad_key_up(dev, key);
  881. litest_dispatch(li);
  882. litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_RELEASED);
  883. key = KEY_ONSCREEN_KEYBOARD;
  884. pad_key_down(dev, key);
  885. litest_dispatch(li);
  886. litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_PRESSED);
  887. pad_key_up(dev, key);
  888. litest_dispatch(li);
  889. litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_RELEASED);
  890. key = KEY_CONTROLPANEL;
  891. pad_key_down(dev, key);
  892. litest_dispatch(li);
  893. litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_PRESSED);
  894. pad_key_up(dev, key);
  895. litest_dispatch(li);
  896. litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_RELEASED);
  897. }
  898. END_TEST
  899. START_TEST(pad_strip_wacom_degenerate_max)
  900. {
  901. struct libinput_event *ev;
  902. struct libinput_event_tablet_pad *pev;
  903. double pos;
  904. /* Override ABS_RX to have maximum=1, which would cause
  905. * log2(1) = 0 and division by zero in normalize_wacom_strip()
  906. * without the guard. */
  907. /* clang-format off */
  908. struct input_absinfo abs_override[] = {
  909. { ABS_RX, 0, 1, 0, 0, 0 },
  910. { -1, -1, -1, -1, -1, -1 },
  911. };
  912. /* clang-format on */
  913. _litest_context_destroy_ struct libinput *li = litest_create_context();
  914. struct litest_device *dev =
  915. litest_add_device_with_overrides(li,
  916. LITEST_WACOM_INTUOS3_PAD,
  917. NULL,
  918. NULL,
  919. abs_override,
  920. NULL);
  921. litest_drain_events(li);
  922. /* Send strip events - value 1 with max 1 triggers
  923. * log2(1)/log2(1) = 0/0 = NaN without the guard */
  924. litest_pad_strip_start(dev, 100);
  925. litest_dispatch(li);
  926. ev = libinput_get_event(li);
  927. pev = litest_is_pad_strip_event(ev, 0, LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER);
  928. pos = libinput_event_tablet_pad_get_strip_position(pev);
  929. /* Without the fix, pos would be NaN from 0/0 division.
  930. * With the fix, pos must be a valid finite number. */
  931. litest_assert_double_ge(pos, 0.0);
  932. litest_assert_double_le(pos, 1.0);
  933. libinput_event_destroy(ev);
  934. litest_pad_strip_end(dev);
  935. litest_drain_events(li);
  936. litest_device_destroy(dev);
  937. }
  938. END_TEST
  939. START_TEST(pad_send_events_disabled)
  940. {
  941. struct litest_device *dev = litest_current_device();
  942. struct libinput *li = dev->libinput;
  943. enum libinput_config_status status;
  944. litest_drain_events(li);
  945. status = libinput_device_config_send_events_set_mode(
  946. dev->libinput_device,
  947. LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
  948. litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
  949. litest_pad_strip_start(dev, 10);
  950. litest_assert_empty_queue(li);
  951. litest_pad_strip_change(dev, 100);
  952. litest_assert_empty_queue(li);
  953. litest_pad_strip_end(dev);
  954. litest_assert_empty_queue(li);
  955. litest_pad_ring_start(dev, 10);
  956. litest_assert_empty_queue(li);
  957. litest_pad_ring_change(dev, 100);
  958. litest_assert_empty_queue(li);
  959. litest_pad_ring_end(dev);
  960. litest_assert_empty_queue(li);
  961. pad_key_down(dev, KEY_BUTTONCONFIG);
  962. litest_assert_empty_queue(li);
  963. pad_key_up(dev, KEY_BUTTONCONFIG);
  964. litest_assert_empty_queue(li);
  965. }
  966. END_TEST
  967. TEST_COLLECTION(pad)
  968. {
  969. /* clang-format off */
  970. litest_add(pad_cap, LITEST_TABLET_PAD, LITEST_ANY);
  971. litest_add(pad_no_cap, LITEST_ANY, LITEST_TABLET_PAD);
  972. litest_add(pad_time, LITEST_TABLET_PAD, LITEST_ANY);
  973. litest_add(pad_num_buttons, LITEST_TABLET_PAD, LITEST_ANY);
  974. /* None of our dial devices have libwacom entries */
  975. litest_add(pad_num_buttons_libwacom, LITEST_TABLET_PAD, LITEST_DIAL);
  976. litest_add(pad_button_intuos, LITEST_TABLET_PAD, LITEST_ANY);
  977. litest_add(pad_button_bamboo, LITEST_TABLET_PAD, LITEST_ANY);
  978. /* None of our dial devices have libwacom entries */
  979. litest_add(pad_button_libwacom, LITEST_TABLET_PAD, LITEST_DIAL);
  980. litest_add(pad_button_mode_groups, LITEST_TABLET_PAD, LITEST_ANY);
  981. litest_add(pad_has_ring, LITEST_RING, LITEST_ANY);
  982. litest_add(pad_ring, LITEST_RING, LITEST_ANY);
  983. litest_add(pad_ring_finger_up, LITEST_RING, LITEST_ANY);
  984. litest_add(pad_has_strip, LITEST_STRIP, LITEST_ANY);
  985. litest_add(pad_strip, LITEST_STRIP, LITEST_ANY);
  986. litest_add(pad_strip_finger_up, LITEST_STRIP, LITEST_ANY);
  987. litest_add_no_device(pad_strip_wacom_degenerate_max);
  988. litest_add(pad_has_dial, LITEST_DIAL, LITEST_ANY);
  989. litest_add(pad_dial_low_res, LITEST_DIAL, LITEST_ANY);
  990. litest_add(pad_dial_hi_res, LITEST_DIAL, LITEST_ANY);
  991. litest_add_for_device(pad_left_handed_default, LITEST_WACOM_INTUOS5_PAD);
  992. litest_add_for_device(pad_no_left_handed, LITEST_WACOM_INTUOS3_PAD);
  993. litest_add_for_device(pad_left_handed_ring, LITEST_WACOM_INTUOS5_PAD);
  994. /* None of the current strip tablets are left-handed */
  995. litest_add(pad_mode_groups, LITEST_TABLET_PAD, LITEST_ANY);
  996. litest_add(pad_mode_groups_userdata, LITEST_TABLET_PAD, LITEST_ANY);
  997. litest_add(pad_mode_groups_ref, LITEST_TABLET_PAD, LITEST_ANY);
  998. litest_add(pad_mode_group_mode, LITEST_TABLET_PAD, LITEST_ANY);
  999. litest_add(pad_mode_group_has, LITEST_TABLET_PAD, LITEST_ANY);
  1000. litest_add(pad_mode_group_has_invalid, LITEST_TABLET_PAD, LITEST_ANY);
  1001. litest_add(pad_mode_group_has_no_toggle, LITEST_TABLET_PAD, LITEST_ANY);
  1002. litest_add(pad_keys, LITEST_TABLET_PAD, LITEST_ANY);
  1003. litest_add(pad_send_events_disabled, LITEST_TABLET_PAD, LITEST_ANY);
  1004. /* clang-format on */
  1005. }