XInput2.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * Copyright © 2009 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. */
  24. /* Definitions used by the library and client */
  25. #ifndef _XINPUT2_H_
  26. #define _XINPUT2_H_
  27. #include <X11/Xlib.h>
  28. #include <X11/extensions/XI2.h>
  29. #include <X11/extensions/Xge.h>
  30. #include <X11/extensions/Xfixes.h> /* PointerBarrier */
  31. /*******************************************************************
  32. *
  33. */
  34. typedef struct {
  35. int type;
  36. char* name;
  37. Bool send_core;
  38. Bool enable;
  39. } XIAddMasterInfo;
  40. typedef struct {
  41. int type;
  42. int deviceid;
  43. int return_mode; /* AttachToMaster, Floating */
  44. int return_pointer;
  45. int return_keyboard;
  46. } XIRemoveMasterInfo;
  47. typedef struct {
  48. int type;
  49. int deviceid;
  50. int new_master;
  51. } XIAttachSlaveInfo;
  52. typedef struct {
  53. int type;
  54. int deviceid;
  55. } XIDetachSlaveInfo;
  56. typedef union {
  57. int type; /* must be first element */
  58. XIAddMasterInfo add;
  59. XIRemoveMasterInfo remove;
  60. XIAttachSlaveInfo attach;
  61. XIDetachSlaveInfo detach;
  62. } XIAnyHierarchyChangeInfo;
  63. typedef struct
  64. {
  65. int base;
  66. int latched;
  67. int locked;
  68. int effective;
  69. } XIModifierState;
  70. typedef XIModifierState XIGroupState;
  71. typedef struct {
  72. int mask_len;
  73. unsigned char *mask;
  74. } XIButtonState;
  75. typedef struct {
  76. int mask_len;
  77. unsigned char *mask;
  78. double *values;
  79. } XIValuatorState;
  80. typedef struct
  81. {
  82. int deviceid;
  83. int mask_len;
  84. unsigned char* mask;
  85. } XIEventMask;
  86. typedef struct
  87. {
  88. int type;
  89. int sourceid;
  90. } XIAnyClassInfo;
  91. typedef struct
  92. {
  93. int type;
  94. int sourceid;
  95. int num_buttons;
  96. Atom *labels;
  97. XIButtonState state;
  98. } XIButtonClassInfo;
  99. typedef struct
  100. {
  101. int type;
  102. int sourceid;
  103. int num_keycodes;
  104. int *keycodes;
  105. } XIKeyClassInfo;
  106. typedef struct
  107. {
  108. int type;
  109. int sourceid;
  110. int number;
  111. Atom label;
  112. double min;
  113. double max;
  114. double value;
  115. int resolution;
  116. int mode;
  117. } XIValuatorClassInfo;
  118. /* new in XI 2.1 */
  119. typedef struct
  120. {
  121. int type;
  122. int sourceid;
  123. int number;
  124. int scroll_type;
  125. double increment;
  126. int flags;
  127. } XIScrollClassInfo;
  128. typedef struct
  129. {
  130. int type;
  131. int sourceid;
  132. int mode;
  133. int num_touches;
  134. } XITouchClassInfo;
  135. typedef struct
  136. {
  137. int deviceid;
  138. char *name;
  139. int use;
  140. int attachment;
  141. Bool enabled;
  142. int num_classes;
  143. XIAnyClassInfo **classes;
  144. } XIDeviceInfo;
  145. typedef struct
  146. {
  147. int modifiers;
  148. int status;
  149. } XIGrabModifiers;
  150. typedef unsigned int BarrierEventID;
  151. typedef struct
  152. {
  153. int deviceid;
  154. PointerBarrier barrier;
  155. BarrierEventID eventid;
  156. } XIBarrierReleasePointerInfo;
  157. /**
  158. * Generic XI2 event. All XI2 events have the same header.
  159. */
  160. typedef struct {
  161. int type; /* GenericEvent */
  162. unsigned long serial; /* # of last request processed by server */
  163. Bool send_event; /* true if this came from a SendEvent request */
  164. Display *display; /* Display the event was read from */
  165. int extension; /* XI extension offset */
  166. int evtype;
  167. Time time;
  168. } XIEvent;
  169. typedef struct {
  170. int deviceid;
  171. int attachment;
  172. int use;
  173. Bool enabled;
  174. int flags;
  175. } XIHierarchyInfo;
  176. /*
  177. * Notifies the client that the device hierarchy has been changed. The client
  178. * is expected to re-query the server for the device hierarchy.
  179. */
  180. typedef struct {
  181. int type; /* GenericEvent */
  182. unsigned long serial; /* # of last request processed by server */
  183. Bool send_event; /* true if this came from a SendEvent request */
  184. Display *display; /* Display the event was read from */
  185. int extension; /* XI extension offset */
  186. int evtype; /* XI_HierarchyChanged */
  187. Time time;
  188. int flags;
  189. int num_info;
  190. XIHierarchyInfo *info;
  191. } XIHierarchyEvent;
  192. /*
  193. * Notifies the client that the classes have been changed. This happens when
  194. * the slave device that sends through the master changes.
  195. */
  196. typedef struct {
  197. int type; /* GenericEvent */
  198. unsigned long serial; /* # of last request processed by server */
  199. Bool send_event; /* true if this came from a SendEvent request */
  200. Display *display; /* Display the event was read from */
  201. int extension; /* XI extension offset */
  202. int evtype; /* XI_DeviceChanged */
  203. Time time;
  204. int deviceid; /* id of the device that changed */
  205. int sourceid; /* Source for the new classes. */
  206. int reason; /* Reason for the change */
  207. int num_classes;
  208. XIAnyClassInfo **classes; /* same as in XIDeviceInfo */
  209. } XIDeviceChangedEvent;
  210. typedef struct {
  211. int type; /* GenericEvent */
  212. unsigned long serial; /* # of last request processed by server */
  213. Bool send_event; /* true if this came from a SendEvent request */
  214. Display *display; /* Display the event was read from */
  215. int extension; /* XI extension offset */
  216. int evtype;
  217. Time time;
  218. int deviceid;
  219. int sourceid;
  220. int detail;
  221. Window root;
  222. Window event;
  223. Window child;
  224. double root_x;
  225. double root_y;
  226. double event_x;
  227. double event_y;
  228. int flags;
  229. XIButtonState buttons;
  230. XIValuatorState valuators;
  231. XIModifierState mods;
  232. XIGroupState group;
  233. } XIDeviceEvent;
  234. typedef struct {
  235. int type; /* GenericEvent */
  236. unsigned long serial; /* # of last request processed by server */
  237. Bool send_event; /* true if this came from a SendEvent request */
  238. Display *display; /* Display the event was read from */
  239. int extension; /* XI extension offset */
  240. int evtype; /* XI_RawKeyPress, XI_RawKeyRelease, etc. */
  241. Time time;
  242. int deviceid;
  243. int sourceid; /* Bug: Always 0. https://bugs.freedesktop.org//show_bug.cgi?id=34240 */
  244. int detail;
  245. int flags;
  246. XIValuatorState valuators;
  247. double *raw_values;
  248. } XIRawEvent;
  249. typedef struct {
  250. int type; /* GenericEvent */
  251. unsigned long serial; /* # of last request processed by server */
  252. Bool send_event; /* true if this came from a SendEvent request */
  253. Display *display; /* Display the event was read from */
  254. int extension; /* XI extension offset */
  255. int evtype;
  256. Time time;
  257. int deviceid;
  258. int sourceid;
  259. int detail;
  260. Window root;
  261. Window event;
  262. Window child;
  263. double root_x;
  264. double root_y;
  265. double event_x;
  266. double event_y;
  267. int mode;
  268. Bool focus;
  269. Bool same_screen;
  270. XIButtonState buttons;
  271. XIModifierState mods;
  272. XIGroupState group;
  273. } XIEnterEvent;
  274. typedef XIEnterEvent XILeaveEvent;
  275. typedef XIEnterEvent XIFocusInEvent;
  276. typedef XIEnterEvent XIFocusOutEvent;
  277. typedef struct {
  278. int type; /* GenericEvent */
  279. unsigned long serial; /* # of last request processed by server */
  280. Bool send_event; /* true if this came from a SendEvent request */
  281. Display *display; /* Display the event was read from */
  282. int extension; /* XI extension offset */
  283. int evtype; /* XI_PropertyEvent */
  284. Time time;
  285. int deviceid; /* id of the device that changed */
  286. Atom property;
  287. int what;
  288. } XIPropertyEvent;
  289. typedef struct {
  290. int type; /* GenericEvent */
  291. unsigned long serial; /* # of last request processed by server */
  292. Bool send_event; /* true if this came from a SendEvent request */
  293. Display *display; /* Display the event was read from */
  294. int extension; /* XI extension offset */
  295. int evtype;
  296. Time time;
  297. int deviceid;
  298. int sourceid;
  299. unsigned int touchid;
  300. Window root;
  301. Window event;
  302. Window child;
  303. int flags;
  304. } XITouchOwnershipEvent;
  305. typedef struct {
  306. int type; /* GenericEvent */
  307. unsigned long serial; /* # of last request processed by server */
  308. Bool send_event; /* true if this came from a SendEvent request */
  309. Display *display; /* Display the event was read from */
  310. int extension; /* XI extension offset */
  311. int evtype;
  312. Time time;
  313. int deviceid;
  314. int sourceid;
  315. Window event;
  316. Window root;
  317. double root_x;
  318. double root_y;
  319. double dx;
  320. double dy;
  321. int dtime;
  322. int flags;
  323. PointerBarrier barrier;
  324. BarrierEventID eventid;
  325. } XIBarrierEvent;
  326. _XFUNCPROTOBEGIN
  327. extern Bool XIQueryPointer(
  328. Display* display,
  329. int deviceid,
  330. Window win,
  331. Window* root,
  332. Window* child,
  333. double* root_x,
  334. double* root_y,
  335. double* win_x,
  336. double* win_y,
  337. XIButtonState *buttons,
  338. XIModifierState *mods,
  339. XIGroupState *group
  340. );
  341. extern Bool XIWarpPointer(
  342. Display* display,
  343. int deviceid,
  344. Window src_win,
  345. Window dst_win,
  346. double src_x,
  347. double src_y,
  348. unsigned int src_width,
  349. unsigned int src_height,
  350. double dst_x,
  351. double dst_y
  352. );
  353. extern Status XIDefineCursor(
  354. Display* display,
  355. int deviceid,
  356. Window win,
  357. Cursor cursor
  358. );
  359. extern Status XIUndefineCursor(
  360. Display* display,
  361. int deviceid,
  362. Window win
  363. );
  364. extern Status XIChangeHierarchy(
  365. Display* display,
  366. XIAnyHierarchyChangeInfo* changes,
  367. int num_changes
  368. );
  369. extern Status XISetClientPointer(
  370. Display* dpy,
  371. Window win,
  372. int deviceid
  373. );
  374. extern Bool XIGetClientPointer(
  375. Display* dpy,
  376. Window win,
  377. int* deviceid
  378. );
  379. extern int XISelectEvents(
  380. Display* dpy,
  381. Window win,
  382. XIEventMask *masks,
  383. int num_masks
  384. );
  385. extern XIEventMask *XIGetSelectedEvents(
  386. Display* dpy,
  387. Window win,
  388. int *num_masks_return
  389. );
  390. extern Status XIQueryVersion(
  391. Display* dpy,
  392. int* major_version_inout,
  393. int* minor_version_inout
  394. );
  395. extern XIDeviceInfo* XIQueryDevice(
  396. Display* dpy,
  397. int deviceid,
  398. int* ndevices_return
  399. );
  400. extern Status XISetFocus(
  401. Display* dpy,
  402. int deviceid,
  403. Window focus,
  404. Time time
  405. );
  406. extern Status XIGetFocus(
  407. Display* dpy,
  408. int deviceid,
  409. Window *focus_return);
  410. extern Status XIGrabDevice(
  411. Display* dpy,
  412. int deviceid,
  413. Window grab_window,
  414. Time time,
  415. Cursor cursor,
  416. int grab_mode,
  417. int paired_device_mode,
  418. Bool owner_events,
  419. XIEventMask *mask
  420. );
  421. extern Status XIUngrabDevice(
  422. Display* dpy,
  423. int deviceid,
  424. Time time
  425. );
  426. extern Status XIAllowEvents(
  427. Display* display,
  428. int deviceid,
  429. int event_mode,
  430. Time time
  431. );
  432. extern Status XIAllowTouchEvents(
  433. Display* display,
  434. int deviceid,
  435. unsigned int touchid,
  436. Window grab_window,
  437. int event_mode
  438. );
  439. extern int XIGrabButton(
  440. Display* display,
  441. int deviceid,
  442. int button,
  443. Window grab_window,
  444. Cursor cursor,
  445. int grab_mode,
  446. int paired_device_mode,
  447. int owner_events,
  448. XIEventMask *mask,
  449. int num_modifiers,
  450. XIGrabModifiers *modifiers_inout
  451. );
  452. extern int XIGrabKeycode(
  453. Display* display,
  454. int deviceid,
  455. int keycode,
  456. Window grab_window,
  457. int grab_mode,
  458. int paired_device_mode,
  459. int owner_events,
  460. XIEventMask *mask,
  461. int num_modifiers,
  462. XIGrabModifiers *modifiers_inout
  463. );
  464. extern int XIGrabEnter(
  465. Display* display,
  466. int deviceid,
  467. Window grab_window,
  468. Cursor cursor,
  469. int grab_mode,
  470. int paired_device_mode,
  471. int owner_events,
  472. XIEventMask *mask,
  473. int num_modifiers,
  474. XIGrabModifiers *modifiers_inout
  475. );
  476. extern int XIGrabFocusIn(
  477. Display* display,
  478. int deviceid,
  479. Window grab_window,
  480. int grab_mode,
  481. int paired_device_mode,
  482. int owner_events,
  483. XIEventMask *mask,
  484. int num_modifiers,
  485. XIGrabModifiers *modifiers_inout
  486. );
  487. extern int XIGrabTouchBegin(
  488. Display* display,
  489. int deviceid,
  490. Window grab_window,
  491. int owner_events,
  492. XIEventMask *mask,
  493. int num_modifiers,
  494. XIGrabModifiers *modifiers_inout
  495. );
  496. extern Status XIUngrabButton(
  497. Display* display,
  498. int deviceid,
  499. int button,
  500. Window grab_window,
  501. int num_modifiers,
  502. XIGrabModifiers *modifiers
  503. );
  504. extern Status XIUngrabKeycode(
  505. Display* display,
  506. int deviceid,
  507. int keycode,
  508. Window grab_window,
  509. int num_modifiers,
  510. XIGrabModifiers *modifiers
  511. );
  512. extern Status XIUngrabEnter(
  513. Display* display,
  514. int deviceid,
  515. Window grab_window,
  516. int num_modifiers,
  517. XIGrabModifiers *modifiers
  518. );
  519. extern Status XIUngrabFocusIn(
  520. Display* display,
  521. int deviceid,
  522. Window grab_window,
  523. int num_modifiers,
  524. XIGrabModifiers *modifiers
  525. );
  526. extern Status XIUngrabTouchBegin(
  527. Display* display,
  528. int deviceid,
  529. Window grab_window,
  530. int num_modifiers,
  531. XIGrabModifiers *modifiers
  532. );
  533. extern Atom *XIListProperties(
  534. Display* display,
  535. int deviceid,
  536. int *num_props_return
  537. );
  538. extern void XIChangeProperty(
  539. Display* display,
  540. int deviceid,
  541. Atom property,
  542. Atom type,
  543. int format,
  544. int mode,
  545. unsigned char *data,
  546. int num_items
  547. );
  548. extern void
  549. XIDeleteProperty(
  550. Display* display,
  551. int deviceid,
  552. Atom property
  553. );
  554. extern Status
  555. XIGetProperty(
  556. Display* display,
  557. int deviceid,
  558. Atom property,
  559. long offset,
  560. long length,
  561. Bool delete_property,
  562. Atom type,
  563. Atom *type_return,
  564. int *format_return,
  565. unsigned long *num_items_return,
  566. unsigned long *bytes_after_return,
  567. unsigned char **data
  568. );
  569. extern void
  570. XIBarrierReleasePointers(
  571. Display* display,
  572. XIBarrierReleasePointerInfo *barriers,
  573. int num_barriers
  574. );
  575. extern void
  576. XIBarrierReleasePointer(
  577. Display* display,
  578. int deviceid,
  579. PointerBarrier barrier,
  580. BarrierEventID eventid
  581. );
  582. extern void XIFreeDeviceInfo(XIDeviceInfo *info);
  583. _XFUNCPROTOEND
  584. #endif /* XINPUT2_H */