xinput.pp 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451
  1. (************************************************************
  2. Copyright 1989, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
  20. All Rights Reserved
  21. Permission to use, copy, modify, and distribute this software and its
  22. documentation for any purpose and without fee is hereby granted,
  23. provided that the above copyright notice appear in all copies and that
  24. both that copyright notice and this permission notice appear in
  25. supporting documentation, and that the name of Hewlett-Packard not be
  26. used in advertising or publicity pertaining to distribution of the
  27. software without specific, written prior permission.
  28. HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. ********************************************************)
  36. { Definitions used by the library and client }
  37. unit xinput;
  38. interface
  39. {$PACKRECORDS C}
  40. {$MODE objfpc}
  41. uses
  42. ctypes, x, xlib, xi;
  43. const
  44. libXi = 'Xi';
  45. _deviceKeyPress = 0;
  46. _deviceKeyRelease = 1;
  47. _deviceButtonPress = 0;
  48. _deviceButtonRelease = 1;
  49. _deviceMotionNotify = 0;
  50. _deviceFocusIn = 0;
  51. _deviceFocusOut = 1;
  52. _proximityIn = 0;
  53. _proximityOut = 1;
  54. _deviceStateNotify = 0;
  55. _deviceMappingNotify = 1;
  56. _changeDeviceNotify = 2;
  57. (* Space of 3 between is necessary! Reserved for DeviceKeyStateNotify,
  58. DeviceButtonStateNotify, DevicePresenceNotify (essentially unused). This
  59. code has to be in sync with FixExtensionEvents() in xserver/Xi/extinit.c *)
  60. _propertyNotify = 6;
  61. { We need the declaration for DevicePresence. }
  62. function _XiGetDevicePresenceNotifyEvent(dpy: PDisplay): cint; cdecl; external libXi;
  63. procedure _xibaddevice(dpy: PDisplay; error: Pcint); cdecl; external libXi;
  64. procedure _xibadclass(dpy: PDisplay; error: Pcint); cdecl; external libXi;
  65. procedure _xibadevent(dpy: PDisplay; error: Pcint); cdecl; external libXi;
  66. procedure _xibadmode(dpy: PDisplay; error: Pcint); cdecl; external libXi;
  67. procedure _xidevicebusy(dpy: PDisplay; error: Pcint); cdecl; external libXi;
  68. procedure DevicePresence(dpy: PDisplay; out event_type: cint; event_class: TXEventClass); inline;
  69. { Errors }
  70. procedure BadDevice(dpy: PDisplay; out error: cint); inline;
  71. procedure BadClass(dpy: PDisplay; out error: cint); inline;
  72. procedure BadEvent(dpy: PDisplay; out error: cint); inline;
  73. procedure BadMode(dpy: PDisplay; out error: cint); inline;
  74. procedure DeviceBusy(dpy: PDisplay; out error: cint); inline;
  75. type
  76. (***************************************************************
  77. *
  78. * DeviceKey events. These events are sent by input devices that
  79. * support input class Keys.
  80. * The location of the X pointer is reported in the coordinate
  81. * fields of the x,y and x_root,y_root fields.
  82. *
  83. *)
  84. PXDeviceKeyEvent = ^TXDeviceKeyEvent;
  85. TXDeviceKeyEvent = record
  86. _type: cint; { of event }
  87. serial: culong; { # of last request processed }
  88. send_event: TBool; { true if from SendEvent request }
  89. display: PDisplay; { Display the event was read from }
  90. window: TWindow; { "event" window reported relative to }
  91. deviceid: TXID;
  92. root: TWindow; { root window event occurred on }
  93. subwindow: TWindow; { child window }
  94. time: TTime; { milliseconds }
  95. x, y: cint; { x, y coordinates in event window }
  96. x_root: cint; { coordinates relative to root }
  97. y_root: cint; { coordinates relative to root }
  98. state: cuint; { key or button mask }
  99. keycode: cuint; { detail }
  100. same_screen: TBool; { same screen flag }
  101. device_state: cuint; { device key or button mask }
  102. axes_count: cuchar;
  103. first_axis: cuchar;
  104. axis_data: array [0..5] of cint;
  105. end;
  106. PXDeviceKeyPressedEvent = ^TXDeviceKeyPressedEvent;
  107. TXDeviceKeyPressedEvent = TXDeviceKeyEvent;
  108. PXDeviceKeyReleasedEvent = ^TXDeviceKeyReleasedEvent;
  109. TXDeviceKeyReleasedEvent = TXDeviceKeyEvent;
  110. (*******************************************************************
  111. *
  112. * DeviceButton events. These events are sent by extension devices
  113. * that support input class Buttons.
  114. *
  115. *)
  116. PXDeviceButtonEvent = ^TXDeviceButtonEvent;
  117. TXDeviceButtonEvent = record
  118. _type: cint; { of event }
  119. serial: culong; { # of last request processed by server }
  120. send_event: TBool; { true if from a SendEvent request }
  121. display: PDisplay; { Display the event was read from }
  122. window: TWindow; { "event" window reported relative to }
  123. deviceid: TXID;
  124. root: TWindow; { root window that the event occurred on }
  125. subwindow: TWindow; { child window }
  126. time: TTime; { milliseconds }
  127. x, y: cint; { x, y coordinates in event window }
  128. x_root: cint; { coordinates relative to root }
  129. y_root: cint; { coordinates relative to root }
  130. state: cuint; { key or button mask }
  131. button: cuint; { detail }
  132. same_screen: TBool; { same screen flag }
  133. device_state: cuint; { device key or button mask }
  134. axes_count: cuchar;
  135. first_axis: cuchar;
  136. axis_data: array [0..5] of cint;
  137. end;
  138. PXDeviceButtonPressedEvent = ^TXDeviceButtonPressedEvent;
  139. TXDeviceButtonPressedEvent = TXDeviceButtonEvent;
  140. PXDeviceButtonReleasedEvent = ^TXDeviceButtonReleasedEvent;
  141. TXDeviceButtonReleasedEvent = TXDeviceButtonEvent;
  142. (*******************************************************************
  143. *
  144. * DeviceMotionNotify event. These events are sent by extension devices
  145. * that support input class Valuators.
  146. *
  147. *)
  148. PXDeviceMotionEvent = ^TXDeviceMotionEvent;
  149. TXDeviceMotionEvent = record
  150. _type: cint; { of event }
  151. serial: culong; { # of last request processed by server }
  152. send_event: TBool; { true if from a SendEvent request }
  153. display: PDisplay; { Display the event was read from }
  154. window: TWindow; { "event" window reported relative to }
  155. deviceid: TXID;
  156. root: TWindow; { root window that the event occurred on }
  157. subwindow: TWindow; { child window }
  158. time: TTime; { milliseconds }
  159. x, y: cint; { x, y coordinates in event window }
  160. x_root: cint; { coordinates relative to root }
  161. y_root: cint; { coordinates relative to root }
  162. state: cuint; { key or button mask }
  163. is_hint: char; { detail }
  164. same_screen: TBool; { same screen flag }
  165. device_state: cuint; { device key or button mask }
  166. axes_count: cuchar;
  167. first_axis: cuchar;
  168. axis_data: array [0..5] of cint;
  169. end;
  170. (*******************************************************************
  171. *
  172. * DeviceFocusChange events. These events are sent when the focus
  173. * of an extension device that can be focused is changed.
  174. *
  175. *)
  176. PXDeviceFocusChangeEvent = ^TXDeviceFocusChangeEvent;
  177. TXDeviceFocusChangeEvent = record
  178. _type: cint; { of event }
  179. serial: culong; { # of last request processed by server }
  180. send_event: TBool; { true if from a SendEvent request }
  181. display: PDisplay; { Display the event was read from }
  182. window: TWindow; { "event" window reported relative to }
  183. deviceid: TXID;
  184. mode: cint; { NotifyNormal, NotifyGrab, NotifyUngrab }
  185. detail: cint;
  186. (*
  187. * NotifyAncestor, NotifyVirtual, NotifyInferior,
  188. * NotifyNonLinear,NotifyNonLinearVirtual, NotifyPointer,
  189. * NotifyPointerRoot, NotifyDetailNone
  190. *)
  191. time: TTime;
  192. end;
  193. PXDeviceFocusInEvent = ^TXDeviceFocusInEvent;
  194. TXDeviceFocusInEvent = TXDeviceFocusChangeEvent;
  195. PXDeviceFocusOutEvent = ^TXDeviceFocusOutEvent;
  196. TXDeviceFocusOutEvent = TXDeviceFocusChangeEvent;
  197. (*******************************************************************
  198. *
  199. * ProximityNotify events. These events are sent by those absolute
  200. * positioning devices that are capable of generating proximity information.
  201. *
  202. *)
  203. PXProximityNotifyEvent = ^TXProximityNotifyEvent;
  204. TXProximityNotifyEvent = record
  205. _type: cint; { ProximityIn or ProximityOut }
  206. serial: culong; { # of last request processed by server }
  207. send_event: TBool; { true if this came from a SendEvent request }
  208. display: PDisplay; { Display the event was read from }
  209. window: TWindow;
  210. deviceid: TXID;
  211. root: TWindow;
  212. subwindow: TWindow;
  213. time: TTime;
  214. x, y: cint;
  215. x_root, y_root: cint;
  216. state: cuint;
  217. same_screen: TBool;
  218. device_state: cuint; { device key or button mask }
  219. axes_count: cuchar;
  220. first_axis: cuchar;
  221. axis_data: array [0..5] of cint;
  222. end;
  223. PXProximityInEvent = ^TXProximityInEvent;
  224. TXProximityInEvent = TXProximityNotifyEvent;
  225. PXProximityOutEvent = ^TXProximityOutEvent;
  226. TXProximityOutEvent = TXProximityNotifyEvent;
  227. (*******************************************************************
  228. *
  229. * DeviceStateNotify events are generated on EnterWindow and FocusIn
  230. * for those clients who have selected DeviceState.
  231. *
  232. *)
  233. PXInputClass = ^TXInputClass;
  234. TXInputClass = record
  235. c_class: cuchar;
  236. length: cuchar;
  237. end;
  238. PXDeviceStateNotifyEvent = ^TXDeviceStateNotifyEvent;
  239. TXDeviceStateNotifyEvent = record
  240. _type: cint;
  241. serial: culong; { # of last request processed by server }
  242. send_event: TBool; { true if this came from a SendEvent request }
  243. display: PDisplay; { Display the event was read from }
  244. window: TWindow;
  245. deviceid: TXID;
  246. time: TTime;
  247. num_classes: cint;
  248. data: array [0..63] of cchar;
  249. end;
  250. PXValuatorStatus = ^TXValuatorStatus;
  251. TXValuatorStatus = record
  252. c_class: cuchar;
  253. length: cuchar;
  254. num_valuators: cuchar;
  255. mode: cuchar;
  256. valuators: array [0..5] of cint;
  257. end;
  258. PXKeyStatus = ^TXKeyStatus;
  259. TXKeyStatus = record
  260. c_class: cuchar;
  261. length: cuchar;
  262. num_keys: cshort;
  263. keys: array [0..31] of cchar;
  264. end;
  265. PXButtonStatus = ^TXButtonStatus;
  266. TXButtonStatus = record
  267. c_class: cuchar;
  268. length: cuchar;
  269. num_buttons: cshort ;
  270. buttons: array [0..31] of cchar;
  271. end;
  272. (*******************************************************************
  273. *
  274. * DeviceMappingNotify event. This event is sent when the key mapping,
  275. * modifier mapping, or button mapping of an extension device is changed.
  276. *
  277. *)
  278. PXDeviceMappingEvent = ^TXDeviceMappingEvent;
  279. TXDeviceMappingEvent = record
  280. _type: cint;
  281. serial: culong; { # of last request processed by server }
  282. send_event: TBool; { true if this came from a SendEvent request }
  283. display: PDisplay; { Display the event was read from }
  284. window: TWindow; { unused }
  285. deviceid: TXID;
  286. time: TTime;
  287. request: cint; { one of MappingModifier, MappingKeyboard,
  288. MappingPointer }
  289. first_keycode: cint; { first keycode }
  290. count: cint; { defines range of change w. first_keycode }
  291. end;
  292. (*******************************************************************
  293. *
  294. * ChangeDeviceNotify event. This event is sent when an
  295. * XChangeKeyboard or XChangePointer request is made.
  296. *
  297. *)
  298. PXChangeDeviceNotifyEvent = ^TXChangeDeviceNotifyEvent;
  299. TXChangeDeviceNotifyEvent = record
  300. _type: cint;
  301. serial: culong; { # of last request processed by server }
  302. send_event: TBool; { true if this came from a SendEvent request }
  303. display: PDisplay; { Display the event was read from }
  304. window: TWindow; { unused }
  305. deviceid: TXID;
  306. time: TTime;
  307. request: cint; { NewPointer or NewKeyboard }
  308. end;
  309. (*******************************************************************
  310. *
  311. * DevicePresenceNotify event. This event is sent when the list of
  312. * input devices changes, in which case devchange will be false, and
  313. * no information about the change will be contained in the event;
  314. * the client should use XListInputDevices() to learn what has changed.
  315. *
  316. * If devchange is true, an attribute that the server believes is
  317. * important has changed on a device, and the client should use
  318. * XGetDeviceControl to examine the device. If control is non-zero,
  319. * then that control has changed meaningfully.
  320. *)
  321. PXDevicePresenceNotifyEvent = ^TXDevicePresenceNotifyEvent;
  322. TXDevicePresenceNotifyEvent = record
  323. _type: cint;
  324. serial: culong; { # of last request processed by server }
  325. send_event: TBool; { true if this came from a SendEvent request }
  326. display: PDisplay; { Display the event was read from }
  327. window: TWindow; { unused }
  328. time: TTime;
  329. devchange: TBool;
  330. deviceid: TXID;
  331. control: TXID;
  332. end;
  333. (*
  334. * Notifies the client that a property on a device has changed value. The
  335. * client is expected to query the server for updated value of the property.
  336. *)
  337. PXDevicePropertyNotifyEvent = ^TXDevicePropertyNotifyEvent;
  338. TXDevicePropertyNotifyEvent = record
  339. _type: cint;
  340. serial: culong; { # of last request processed by server }
  341. send_event: TBool; { true if this came from a SendEvent request }
  342. display: PDisplay; { Display the event was read from }
  343. window: TWindow; { unused }
  344. time: TTime;
  345. deviceid: TXID; { id of the device that changed }
  346. atom: TAtom; { the property that changed }
  347. state: cint; { PropertyNewValue or PropertyDeleted }
  348. end;
  349. (*******************************************************************
  350. *
  351. * Control structures for input devices that support input class
  352. * Feedback. These are used by the XGetFeedbackControl and
  353. * XChangeFeedbackControl functions.
  354. *
  355. *)
  356. PXFeedbackState = ^TXFeedbackState;
  357. TXFeedbackState = record
  358. c_class: TXID;
  359. length: cint;
  360. id: TXID;
  361. end;
  362. PXKbdFeedbackState = ^TXKbdFeedbackState;
  363. TXKbdFeedbackState = record
  364. c_class: TXID;
  365. length: cint;
  366. id: TXID;
  367. click: cint;
  368. percent: cint;
  369. pitch: cint;
  370. duration: cint;
  371. led_mask: cint;
  372. global_auto_repeat: cint;
  373. auto_repeats: array [0..31] of cchar;
  374. end;
  375. PXPtrFeedbackState = ^TXPtrFeedbackState;
  376. TXPtrFeedbackState = record
  377. c_class: TXID;
  378. length: cint;
  379. id: TXID;
  380. accelNum: cint;
  381. accelDenom: cint;
  382. threshold: cint;
  383. end;
  384. PXIntegerFeedbackState = ^TXIntegerFeedbackState;
  385. TXIntegerFeedbackState = record
  386. c_class: TXID;
  387. length: cint;
  388. id: TXID;
  389. resolution: cint;
  390. minVal: cint;
  391. maxVal: cint;
  392. end;
  393. PXStringFeedbackState = ^TXStringFeedbackState;
  394. TXStringFeedbackState = record
  395. c_class: TXID;
  396. length: cint;
  397. id: TXID;
  398. max_symbols: cint;
  399. num_syms_supported: cint;
  400. syms_supported: PKeySym;
  401. end;
  402. PXBellFeedbackState = ^TXBellFeedbackState;
  403. TXBellFeedbackState = record
  404. c_class: TXID;
  405. length: cint;
  406. id: TXID;
  407. percent: cint;
  408. pitch: cint;
  409. duration: cint;
  410. end;
  411. PXLedFeedbackState = ^TXLedFeedbackState;
  412. TXLedFeedbackState = record
  413. c_class: TXID;
  414. length: cint;
  415. id: TXID;
  416. led_values: cint;
  417. led_mask: cint;
  418. end;
  419. PXFeedbackControl = ^TXFeedbackControl;
  420. TXFeedbackControl = record
  421. c_class: TXID;
  422. length: cint;
  423. id: TXID;
  424. end;
  425. PXPtrFeedbackControl = ^TXPtrFeedbackControl;
  426. TXPtrFeedbackControl = record
  427. c_class: TXID;
  428. length: cint;
  429. id: TXID;
  430. accelNum: cint;
  431. accelDenom: cint;
  432. threshold: cint;
  433. end;
  434. PXKbdFeedbackControl = ^TXKbdFeedbackControl;
  435. TXKbdFeedbackControl = record
  436. c_class: TXID;
  437. length: cint;
  438. id: TXID;
  439. click: cint;
  440. percent: cint;
  441. pitch: cint;
  442. duration: cint;
  443. led_mask: cint;
  444. led_value: cint;
  445. key: cint;
  446. auto_repeat_mode: cint;
  447. end;
  448. PXStringFeedbackControl = ^TXStringFeedbackControl;
  449. TXStringFeedbackControl = record
  450. c_class: TXID;
  451. length: cint;
  452. id: TXID;
  453. num_keysyms: cint;
  454. syms_to_display: PKeySym;
  455. end;
  456. PXIntegerFeedbackControl = ^TXIntegerFeedbackControl;
  457. TXIntegerFeedbackControl = record
  458. c_class: TXID;
  459. length: cint;
  460. id: TXID;
  461. int_to_display: cint;
  462. end;
  463. PXBellFeedbackControl = ^TXBellFeedbackControl;
  464. TXBellFeedbackControl = record
  465. c_class: TXID;
  466. length: cint;
  467. id: TXID;
  468. percent: cint;
  469. pitch: cint;
  470. duration: cint;
  471. end;
  472. PXLedFeedbackControl = ^TXLedFeedbackControl;
  473. TXLedFeedbackControl = record
  474. c_class: TXID;
  475. length: cint;
  476. id: TXID;
  477. led_mask: cint;
  478. led_values: cint;
  479. end;
  480. (*******************************************************************
  481. *
  482. * Device control structures.
  483. *
  484. *)
  485. PXDeviceControl = ^TXDeviceControl;
  486. TXDeviceControl = record
  487. control: TXID;
  488. length: cint;
  489. end;
  490. PXDeviceResolutionControl = ^TXDeviceResolutionControl;
  491. TXDeviceResolutionControl = record
  492. control: TXID;
  493. length: cint;
  494. first_valuator: cint;
  495. num_valuators: cint;
  496. resolutions: Pcint;
  497. end;
  498. PXDeviceResolutionState = ^TXDeviceResolutionState;
  499. TXDeviceResolutionState = record
  500. control: TXID;
  501. length: cint;
  502. num_valuators: cint;
  503. resolutions: Pcint;
  504. min_resolutions: Pcint;
  505. max_resolutions: Pcint;
  506. end;
  507. PXDeviceAbsCalibControl = ^TXDeviceAbsCalibControl;
  508. TXDeviceAbsCalibControl = record
  509. control: TXID;
  510. length: cint;
  511. min_x: cint;
  512. max_x: cint;
  513. min_y: cint;
  514. max_y: cint;
  515. flip_x: cint;
  516. flip_y: cint;
  517. rotation: cint;
  518. button_threshold: cint;
  519. end;
  520. PXDeviceAbsCalibState = ^TXDeviceAbsCalibState;
  521. TXDeviceAbsCalibState = TXDeviceAbsCalibControl;
  522. PXDeviceAbsAreaControl = ^TXDeviceAbsAreaControl;
  523. TXDeviceAbsAreaControl = record
  524. control: TXID;
  525. length: cint;
  526. offset_x: cint;
  527. offset_y: cint;
  528. width: cint;
  529. height: cint;
  530. screen: cint;
  531. following: TXID;
  532. end;
  533. PXDeviceAbsAreaState = ^TXDeviceAbsAreaState;
  534. TXDeviceAbsAreaState = TXDeviceAbsAreaControl;
  535. PXDeviceCoreControl = ^TXDeviceCoreControl;
  536. TXDeviceCoreControl = record
  537. control: TXID;
  538. length: cint;
  539. status: cint;
  540. end;
  541. PXDeviceCoreState = ^TXDeviceCoreState;
  542. TXDeviceCoreState = record
  543. control: TXID;
  544. length: cint;
  545. status: cint;
  546. iscore: cint;
  547. end;
  548. PXDeviceEnableControl = ^TXDeviceEnableControl;
  549. TXDeviceEnableControl = record
  550. control: TXID;
  551. length: cint;
  552. enable: cint;
  553. end;
  554. PXDeviceEnableState = ^TXDeviceEnableState;
  555. TXDeviceEnableState = TXDeviceEnableControl;
  556. (*******************************************************************
  557. *
  558. * An array of XDeviceList structures is returned by the
  559. * XListInputDevices function. Each entry contains information
  560. * about one input device. Among that information is an array of
  561. * pointers to structures that describe the characteristics of
  562. * the input device.
  563. *
  564. *)
  565. PXAnyClassInfo = ^TXAnyClassInfo;
  566. TXAnyClassPtr = PXAnyClassInfo;
  567. TXAnyClassInfo = record
  568. c_classs: TXID;
  569. length: cint;
  570. end;
  571. PXDeviceInfo = ^TXDeviceInfo;
  572. TXDeviceInfoPtr = PXDeviceInfo;
  573. TXDeviceInfo = record
  574. id: TXID;
  575. _type: TAtom;
  576. name: PChar;
  577. num_classes: cint;
  578. use: cint;
  579. inputclassinfo: TXAnyClassPtr;
  580. end;
  581. PXKeyInfo = ^TXKeyInfo;
  582. TXKeyInfoPtr = PXKeyInfo;
  583. TXKeyInfo = record
  584. c_class: TXID;
  585. length: cint;
  586. min_keycode: cushort;
  587. max_keycode: cushort;
  588. num_keys: cushort;
  589. end;
  590. PXButtonInfo = ^TXButtonInfo;
  591. TXButtonInfoPtr = PXButtonInfo;
  592. TXButtonInfo = record
  593. c_class: TXID;
  594. length: cint;
  595. num_buttons: cshort;
  596. end;
  597. PXAxisInfo = ^TXAxisInfo;
  598. TXAxisInfoPtr = PXAxisInfo;
  599. TXAxisInfo = record
  600. resolution: cint;
  601. min_value: cint;
  602. max_value: cint;
  603. end;
  604. PXValuatorInfo = ^TXValuatorInfo;
  605. TXValuatorInfoPtr = PXValuatorInfo;
  606. TXValuatorInfo = record
  607. c_class: TXID;
  608. length: cint;
  609. num_axes: cuchar;
  610. mode: cuchar;
  611. motion_buffer: culong;
  612. axes: TXAxisInfoPtr;
  613. end;
  614. (*******************************************************************
  615. *
  616. * An XDevice structure is returned by the XOpenDevice function.
  617. * It contains an array of pointers to XInputClassInfo structures.
  618. * Each contains information about a class of input supported by the
  619. * device, including a pointer to an array of data for each type of event
  620. * the device reports.
  621. *
  622. *)
  623. PXInputClassInfo = ^TXInputClassInfo;
  624. TXInputClassInfo = record
  625. input_class: cuchar;
  626. event_type_base: cuchar;
  627. end;
  628. PXDevice = ^TXDevice;
  629. TXDevice = record
  630. device_id: TXID;
  631. num_classes: cint;
  632. classes: PXInputClassInfo;
  633. end;
  634. (*******************************************************************
  635. *
  636. * The following structure is used to return information for the
  637. * XGetSelectedExtensionEvents function.
  638. *
  639. *)
  640. PXEventList = ^TXEventList;
  641. TXEventList = record
  642. event_type: TXEventClass;
  643. device: TXID;
  644. end;
  645. (*******************************************************************
  646. *
  647. * The following structure is used to return motion history data from
  648. * an input device that supports the input class Valuators.
  649. * This information is returned by the XGetDeviceMotionEvents function.
  650. *
  651. *)
  652. PXDeviceTimeCoord = ^TXDeviceTimeCoord;
  653. TXDeviceTimeCoord = record
  654. time: TTime;
  655. data: Pcint;
  656. end;
  657. (*******************************************************************
  658. *
  659. * Device state structure.
  660. * This is returned by the XQueryDeviceState request.
  661. *
  662. *)
  663. PXDeviceState = ^TXDeviceState;
  664. TXDeviceState = record
  665. device_id: TXID;
  666. num_classes: cint;
  667. data: PXInputClass;
  668. end;
  669. (*******************************************************************
  670. *
  671. * Note that the mode field is a bitfield that reports the Proximity
  672. * status of the device as well as the mode. The mode field should
  673. * be OR'd with the mask DeviceMode and compared with the values
  674. * Absolute and Relative to determine the mode, and should be OR'd
  675. * with the mask ProximityState and compared with the values InProximity
  676. * and OutOfProximity to determine the proximity state.
  677. *
  678. *)
  679. PXValuatorState = ^TXValuatorState;
  680. TXValuatorState = record
  681. c_class: cuchar;
  682. length: cuchar;
  683. num_valuators: cuchar;
  684. mode: cuchar;
  685. valuators: Pcint;
  686. end;
  687. PXKeyState = ^TXKeyState;
  688. TXKeyState = record
  689. c_class: cuchar;
  690. length: cuchar;
  691. num_keys: cshort;
  692. keys: array [0..31] of cchar;
  693. end;
  694. PXButtonState = ^TXButtonState;
  695. TXButtonState = record
  696. c_class: cuchar;
  697. length: cuchar;
  698. num_buttons: cshort;
  699. buttons: array [0..31] of cchar;
  700. end;
  701. procedure FindTypeAndClass(d: PXDevice; out event_type: cint; out event_class: TXEventClass; classid: cuchar; offset: cint); inline;
  702. procedure DeviceKeyPress(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  703. procedure DeviceKeyRelease(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  704. procedure DeviceButtonPress(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  705. procedure DeviceButtonRelease(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  706. procedure DeviceMotionNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  707. procedure DeviceFocusIn(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  708. procedure DeviceFocusOut(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  709. procedure ProximityIn(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  710. procedure ProximityOut(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  711. procedure DeviceStateNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  712. procedure DeviceMappingNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  713. procedure ChangeDeviceNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  714. procedure DevicePropertyNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  715. procedure DevicePointerMotionHint(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  716. procedure DeviceButton1Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  717. procedure DeviceButton2Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  718. procedure DeviceButton3Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  719. procedure DeviceButton4Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  720. procedure DeviceButton5Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  721. procedure DeviceButtonMotion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  722. procedure DeviceOwnerGrabButton(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  723. procedure DeviceButtonPressGrab(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  724. procedure NoExtensionEvent(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  725. (*******************************************************************
  726. *
  727. * Function definitions.
  728. *
  729. *)
  730. //_XFUNCPROTOBEGIN
  731. function XChangeKeyboardDevice(
  732. display: PDisplay;
  733. device: PXDevice
  734. ): cint; cdecl; external libXi;
  735. function XChangePointerDevice(
  736. display: PDisplay;
  737. device: PXDevice;
  738. xaxis: cint;
  739. yaxis: cint
  740. ): cint; cdecl; external libXi;
  741. function XGrabDevice(
  742. display: PDisplay;
  743. device: PXDevice;
  744. grab_window: TWindow;
  745. ownerEvents: TBool;
  746. event_count: cint;
  747. event_list: PXEventClass;
  748. this_device_mode: cint;
  749. other_devices_mode: cint;
  750. time: TTime
  751. ): cint; cdecl; external libXi;
  752. { boolean overload for the TBool parameter }
  753. function XGrabDevice(
  754. display: PDisplay;
  755. device: PXDevice;
  756. grab_window: TWindow;
  757. ownerEvents: Boolean;
  758. event_count: cint;
  759. event_list: PXEventClass;
  760. this_device_mode: cint;
  761. other_devices_mode: cint;
  762. time: TTime
  763. ): cint; inline;
  764. function XUngrabDevice(
  765. display: PDisplay;
  766. device: PXDevice;
  767. time: TTime
  768. ): cint; cdecl; external libXi;
  769. function XGrabDeviceKey(
  770. display: PDisplay;
  771. device: PXDevice;
  772. key: cuint;
  773. modifiers: cuint;
  774. modifier_device: PXDevice;
  775. grab_window: TWindow;
  776. owner_events: TBool;
  777. event_count: cuint;
  778. event_list: PXEventClass;
  779. this_device_mode: cint;
  780. other_devices_mode: cint
  781. ): cint; cdecl; external libXi;
  782. { boolean overload for the TBool parameter }
  783. function XGrabDeviceKey(
  784. display: PDisplay;
  785. device: PXDevice;
  786. key: cuint;
  787. modifiers: cuint;
  788. modifier_device: PXDevice;
  789. grab_window: TWindow;
  790. owner_events: Boolean;
  791. event_count: cuint;
  792. event_list: PXEventClass;
  793. this_device_mode: cint;
  794. other_devices_mode: cint
  795. ): cint; inline;
  796. function XUngrabDeviceKey(
  797. display: PDisplay;
  798. device: PXDevice;
  799. key: cuint;
  800. modifiers: cuint;
  801. modifier_dev: PXDevice;
  802. grab_window: TWindow
  803. ): cint; cdecl; external libXi;
  804. function XGrabDeviceButton(
  805. display: PDisplay;
  806. device: PXDevice;
  807. button: cuint;
  808. modifiers: cuint;
  809. modifier_device: PXDevice;
  810. grab_window: TWindow;
  811. owner_events: TBool;
  812. event_count: cuint;
  813. event_list: PXEventClass;
  814. this_device_mode: cint;
  815. other_devices_mode: cint
  816. ): cint; cdecl; external libXi;
  817. { boolean overload for the TBool parameter }
  818. function XGrabDeviceButton(
  819. display: PDisplay;
  820. device: PXDevice;
  821. button: cuint;
  822. modifiers: cuint;
  823. modifier_device: PXDevice;
  824. grab_window: TWindow;
  825. owner_events: Boolean;
  826. event_count: cuint;
  827. event_list: PXEventClass;
  828. this_device_mode: cint;
  829. other_devices_mode: cint
  830. ): cint; inline;
  831. function XUngrabDeviceButton(
  832. display: PDisplay;
  833. device: PXDevice;
  834. button: cuint;
  835. modifiers: cuint;
  836. modifier_dev: PXDevice;
  837. grab_window: TWindow
  838. ): cint; cdecl; external libXi;
  839. function XAllowDeviceEvents(
  840. display: PDisplay;
  841. device: PXDevice;
  842. event_mode: cint;
  843. time: TTime
  844. ): cint; cdecl; external libXi;
  845. function XGetDeviceFocus(
  846. display: PDisplay;
  847. device: PXDevice;
  848. focus: PWindow;
  849. revert_to: Pcint;
  850. time: PTime
  851. ): cint; cdecl; external libXi;
  852. function XSetDeviceFocus(
  853. display: PDisplay;
  854. device: PXDevice;
  855. focus: TWindow;
  856. revert_to: cint;
  857. time: TTime
  858. ): cint; cdecl; external libXi;
  859. function XGetFeedbackControl(
  860. display: PDisplay;
  861. device: PXDevice;
  862. num_feedbacks: Pcint
  863. ): PXFeedbackState; cdecl; external libXi;
  864. procedure XFreeFeedbackList(
  865. list: PXFeedbackState
  866. ); cdecl; external libXi;
  867. function XChangeFeedbackControl(
  868. display: PDisplay;
  869. device: PXDevice;
  870. mask: culong;
  871. f: PXFeedbackControl
  872. ): cint; cdecl; external libXi;
  873. function XDeviceBell(
  874. display: PDisplay;
  875. device: PXDevice;
  876. feedbackclass: TXID;
  877. feedbackid: TXID;
  878. percent: cint
  879. ): cint; cdecl; external libXi;
  880. function XGetDeviceKeyMapping(
  881. display: PDisplay;
  882. device: PXDevice;
  883. {$ifdef NeedWidePrototypes}
  884. first: cuint;
  885. {$else}
  886. first: TKeyCode;
  887. {$endif}
  888. keycount: cint;
  889. syms_per_code: Pcint
  890. ): PKeySym; cdecl; external libXi;
  891. function XChangeDeviceKeyMapping(
  892. display: PDisplay;
  893. device: PXDevice;
  894. first: cint;
  895. syms_per_code: cint;
  896. keysyms: PKeySym;
  897. count: cint
  898. ): cint; cdecl; external libXi;
  899. function XGetDeviceModifierMapping(
  900. display: PDisplay;
  901. device: PXDevice
  902. ): PXModifierKeymap; cdecl; external libXi;
  903. function XSetDeviceModifierMapping(
  904. display: PDisplay;
  905. device: PXDevice;
  906. modmap: PXModifierKeymap
  907. ): cint; cdecl; external libXi;
  908. function XSetDeviceButtonMapping(
  909. display: PDisplay;
  910. device: PXDevice;
  911. map: Pcuchar;
  912. nmap: cint
  913. ): cint; cdecl; external libXi;
  914. function XGetDeviceButtonMapping(
  915. display: PDisplay;
  916. device: PXDevice;
  917. map: Pcuchar;
  918. nmap: cuint
  919. ): cint; cdecl; external libXi;
  920. function XQueryDeviceState(
  921. display: PDisplay;
  922. device: PXDevice
  923. ): PXDeviceState; cdecl; external libXi;
  924. procedure XFreeDeviceState(
  925. list: PXDeviceState
  926. ); cdecl; external libXi;
  927. function XGetExtensionVersion(
  928. display: PDisplay;
  929. name: {_Xconst} Pchar
  930. ): PXExtensionVersion; cdecl; external libXi;
  931. function XListInputDevices(
  932. display: PDisplay;
  933. ndevices: Pcint
  934. ): PXDeviceInfo; cdecl; external libXi;
  935. procedure XFreeDeviceList(
  936. list: PXDeviceInfo
  937. ); cdecl; external libXi;
  938. function XOpenDevice(
  939. display: PDisplay;
  940. id: TXID
  941. ): PXDevice; cdecl; external libXi;
  942. function XCloseDevice(
  943. display: PDisplay;
  944. device: PXDevice
  945. ): cint; cdecl; external libXi;
  946. function XSetDeviceMode(
  947. display: PDisplay;
  948. device: PXDevice;
  949. mode: cint
  950. ): cint; cdecl; external libXi;
  951. function XSetDeviceValuators(
  952. display: PDisplay;
  953. device: PXDevice;
  954. valuators: Pcint;
  955. first_valuator: cint;
  956. num_valuators: cint
  957. ): cint; cdecl; external libXi;
  958. function XGetDeviceControl(
  959. display: PDisplay;
  960. device: PXDevice;
  961. control: cint
  962. ): PXDeviceControl; cdecl; external libXi;
  963. function XChangeDeviceControl(
  964. display: PDisplay;
  965. device: PXDevice;
  966. control: cint;
  967. d: PXDeviceControl
  968. ): cint; cdecl; external libXi;
  969. function XSelectExtensionEvent(
  970. display: PDisplay;
  971. w: TWindow;
  972. event_list: PXEventClass;
  973. count: cint
  974. ): cint; cdecl; external libXi;
  975. function XGetSelectedExtensionEvents(
  976. display: PDisplay;
  977. w: TWindow;
  978. this_client_count: Pcint;
  979. this_client_list: PPXEventClass;
  980. all_clients_count: Pcint;
  981. all_clients_list: PPXEventClass
  982. ): cint; cdecl; external libXi;
  983. function XChangeDeviceDontPropagateList(
  984. display: PDisplay;
  985. window: TWindow;
  986. count: cint;
  987. events: PXEventClass;
  988. mode: cint
  989. ): cint; cdecl; external libXi;
  990. function XGetDeviceDontPropagateList(
  991. display: PDisplay;
  992. window: TWindow;
  993. count: Pcint
  994. ): PXEventClass; cdecl; external libXi;
  995. function XSendExtensionEvent(
  996. display: PDisplay;
  997. device: PXDevice;
  998. dest: TWindow;
  999. prop: TBool;
  1000. count: cint;
  1001. list: PXEventClass;
  1002. event: PXEvent
  1003. ): TStatus; cdecl; external libXi;
  1004. { boolean overload for the TBool parameter }
  1005. function XSendExtensionEvent(
  1006. display: PDisplay;
  1007. device: PXDevice;
  1008. dest: TWindow;
  1009. prop: Boolean;
  1010. count: cint;
  1011. list: PXEventClass;
  1012. event: PXEvent
  1013. ): TStatus; inline;
  1014. function XGetDeviceMotionEvents(
  1015. display: PDisplay;
  1016. device: PXDevice;
  1017. start: TTime;
  1018. stop: TTime;
  1019. nEvents: Pcint;
  1020. mode: Pcint;
  1021. axis_count: Pcint
  1022. ): PXDeviceTimeCoord; cdecl; external libXi;
  1023. procedure XFreeDeviceMotionEvents(
  1024. events: PXDeviceTimeCoord
  1025. ); cdecl; external libXi;
  1026. procedure XFreeDeviceControl(
  1027. control: PXDeviceControl
  1028. ); cdecl; external libXi;
  1029. function XListDeviceProperties(
  1030. dpy: PDisplay;
  1031. dev: PXDevice;
  1032. nprops_return: Pcint
  1033. ): PAtom; cdecl; external libXi;
  1034. procedure XChangeDeviceProperty(
  1035. dpy: PDisplay;
  1036. dev: PXDevice;
  1037. _property: TAtom;
  1038. _type: TAtom;
  1039. format: cint;
  1040. mode: cint;
  1041. data: {_Xconst} Pcuchar;
  1042. nelements: cint
  1043. ); cdecl; external libXi;
  1044. procedure XDeleteDeviceProperty(
  1045. dpy: PDisplay;
  1046. dev: PXDevice;
  1047. _property: TAtom
  1048. ); cdecl; external libXi;
  1049. function XGetDeviceProperty(
  1050. dpy: PDisplay;
  1051. dev: PXDevice;
  1052. _property: TAtom;
  1053. offset: clong;
  1054. length: clong;
  1055. delete: TBool;
  1056. req_type: TAtom;
  1057. actual_type: PAtom;
  1058. actual_format: Pcint;
  1059. nitems: Pculong;
  1060. bytes_after: Pculong;
  1061. prop: PPcuchar
  1062. ): TStatus; cdecl; external libXi;
  1063. { boolean overload for the TBool parameter }
  1064. function XGetDeviceProperty(
  1065. dpy: PDisplay;
  1066. dev: PXDevice;
  1067. _property: TAtom;
  1068. offset: clong;
  1069. length: clong;
  1070. delete: Boolean;
  1071. req_type: TAtom;
  1072. actual_type: PAtom;
  1073. actual_format: Pcint;
  1074. nitems: Pculong;
  1075. bytes_after: Pculong;
  1076. prop: PPcuchar
  1077. ): TStatus; inline;
  1078. //_XFUNCPROTOEND
  1079. implementation
  1080. procedure DevicePresence(dpy: PDisplay; out event_type: cint; event_class: TXEventClass); inline;
  1081. begin
  1082. event_type := _XiGetDevicePresenceNotifyEvent(dpy);
  1083. event_class := $10000 or _devicePresence;
  1084. end;
  1085. procedure BadDevice(dpy: PDisplay; out error: cint); inline;
  1086. begin
  1087. _xibaddevice(dpy, @error);
  1088. end;
  1089. procedure BadClass(dpy: PDisplay; out error: cint); inline;
  1090. begin
  1091. _xibadclass(dpy, @error);
  1092. end;
  1093. procedure BadEvent(dpy: PDisplay; out error: cint); inline;
  1094. begin
  1095. _xibadevent(dpy, @error);
  1096. end;
  1097. procedure BadMode(dpy: PDisplay; out error: cint); inline;
  1098. begin
  1099. _xibadmode(dpy, @error);
  1100. end;
  1101. procedure DeviceBusy(dpy: PDisplay; out error: cint); inline;
  1102. begin
  1103. _xidevicebusy(dpy, @error);
  1104. end;
  1105. procedure FindTypeAndClass(d: PXDevice; out event_type: cint; out event_class: TXEventClass; classid: cuchar; offset: cint); inline;
  1106. var
  1107. _i : cint = 0;
  1108. _ip: PXInputClassInfo;
  1109. begin
  1110. event_type := 0;
  1111. event_class := 0;
  1112. _ip := d^.classes;
  1113. for _i := 0 to d^.num_classes - 1 do
  1114. begin
  1115. if _ip^.input_class = classid then
  1116. begin
  1117. event_type := _ip^.event_type_base + offset;
  1118. event_class := (d^.device_id shl 8) or event_type;
  1119. end;
  1120. Inc(_ip);
  1121. end;
  1122. end;
  1123. procedure DeviceKeyPress(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1124. begin
  1125. FindTypeAndClass(d, event_type, event_class, KeyClass, _deviceKeyPress);
  1126. end;
  1127. procedure DeviceKeyRelease(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1128. begin
  1129. FindTypeAndClass(d, event_type, event_class, KeyClass, _deviceKeyRelease);
  1130. end;
  1131. procedure DeviceButtonPress(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1132. begin
  1133. FindTypeAndClass(d, event_type, event_class, ButtonClass, _deviceButtonPress);
  1134. end;
  1135. procedure DeviceButtonRelease(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1136. begin
  1137. FindTypeAndClass(d, event_type, event_class, ButtonClass, _deviceButtonRelease);
  1138. end;
  1139. procedure DeviceMotionNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1140. begin
  1141. FindTypeAndClass(d, event_type, event_class, ValuatorClass, _deviceMotionNotify);
  1142. end;
  1143. procedure DeviceFocusIn(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1144. begin
  1145. FindTypeAndClass(d, event_type, event_class, FocusClass, _deviceFocusIn);
  1146. end;
  1147. procedure DeviceFocusOut(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1148. begin
  1149. FindTypeAndClass(d, event_type, event_class, FocusClass, _deviceFocusOut);
  1150. end;
  1151. procedure ProximityIn(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1152. begin
  1153. FindTypeAndClass(d, event_type, event_class, ProximityClass, _proximityIn);
  1154. end;
  1155. procedure ProximityOut(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1156. begin
  1157. FindTypeAndClass(d, event_type, event_class, ProximityClass, _proximityOut);
  1158. end;
  1159. procedure DeviceStateNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1160. begin
  1161. FindTypeAndClass(d, event_type, event_class, OtherClass, _deviceStateNotify);
  1162. end;
  1163. procedure DeviceMappingNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1164. begin
  1165. FindTypeAndClass(d, event_type, event_class, OtherClass, _deviceMappingNotify);
  1166. end;
  1167. procedure ChangeDeviceNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1168. begin
  1169. FindTypeAndClass(d, event_type, event_class, OtherClass, _changeDeviceNotify);
  1170. end;
  1171. procedure DevicePropertyNotify(d: PXDevice; out event_type: cint; out event_class: TXEventClass); inline;
  1172. begin
  1173. FindTypeAndClass(d, event_type, event_class, OtherClass, _propertyNotify);
  1174. end;
  1175. procedure DevicePointerMotionHint(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1176. begin
  1177. event_class := (d^.device_id shl 8) or _devicePointerMotionHint;
  1178. end;
  1179. procedure DeviceButton1Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1180. begin
  1181. event_class := (d^.device_id shl 8) or _deviceButton1Motion;
  1182. end;
  1183. procedure DeviceButton2Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1184. begin
  1185. event_class := (d^.device_id shl 8) or _deviceButton2Motion;
  1186. end;
  1187. procedure DeviceButton3Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1188. begin
  1189. event_class := (d^.device_id shl 8) or _deviceButton3Motion;
  1190. end;
  1191. procedure DeviceButton4Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1192. begin
  1193. event_class := (d^.device_id shl 8) or _deviceButton4Motion;
  1194. end;
  1195. procedure DeviceButton5Motion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1196. begin
  1197. event_class := (d^.device_id shl 8) or _deviceButton5Motion;
  1198. end;
  1199. procedure DeviceButtonMotion(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1200. begin
  1201. event_class := (d^.device_id shl 8) or _deviceButtonMotion;
  1202. end;
  1203. procedure DeviceOwnerGrabButton(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1204. begin
  1205. event_class := (d^.device_id shl 8) or _deviceOwnerGrabButton;
  1206. end;
  1207. procedure DeviceButtonPressGrab(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1208. begin
  1209. event_class := (d^.device_id shl 8) or _deviceButtonGrab;
  1210. end;
  1211. procedure NoExtensionEvent(d: PXDevice; event_type: cint; out event_class: TXEventClass); inline;
  1212. begin
  1213. event_class := (d^.device_id shl 8) or _noExtensionEvent;
  1214. end;
  1215. function XGrabDevice(display: PDisplay; device: PXDevice; grab_window: TWindow;
  1216. ownerEvents: Boolean; event_count: cint; event_list: PXEventClass;
  1217. this_device_mode: cint; other_devices_mode: cint; time: TTime): cint; inline;
  1218. begin
  1219. XGrabDevice := XGrabDevice(display, device, grab_window, Ord(ownerEvents), event_count, event_list, this_device_mode,
  1220. other_devices_mode, time);
  1221. end;
  1222. function XGrabDeviceKey(display: PDisplay; device: PXDevice; key: cuint;
  1223. modifiers: cuint; modifier_device: PXDevice; grab_window: TWindow;
  1224. owner_events: Boolean; event_count: cuint; event_list: PXEventClass;
  1225. this_device_mode: cint; other_devices_mode: cint): cint; inline;
  1226. begin
  1227. XGrabDeviceKey := XGrabDeviceKey(display, device, key, modifiers, modifier_device, grab_window,
  1228. Ord(owner_events), event_count, event_list, this_device_mode, other_devices_mode);
  1229. end;
  1230. function XGrabDeviceButton(display: PDisplay; device: PXDevice; button: cuint;
  1231. modifiers: cuint; modifier_device: PXDevice; grab_window: TWindow;
  1232. owner_events: Boolean; event_count: cuint; event_list: PXEventClass;
  1233. this_device_mode: cint; other_devices_mode: cint): cint; inline;
  1234. begin
  1235. XGrabDeviceButton := XGrabDeviceButton(display, device, button, modifiers, modifier_device, grab_window, Ord(owner_events),
  1236. event_count, event_list, this_device_mode, other_devices_mode);
  1237. end;
  1238. function XSendExtensionEvent(display: PDisplay; device: PXDevice;
  1239. dest: TWindow; prop: Boolean; count: cint; list: PXEventClass; event: PXEvent
  1240. ): TStatus; inline;
  1241. begin
  1242. XSendExtensionEvent := XSendExtensionEvent(display, device, dest, Ord(prop), count, list, event);
  1243. end;
  1244. function XGetDeviceProperty(dpy: PDisplay; dev: PXDevice; _property: TAtom;
  1245. offset: clong; length: clong; delete: Boolean; req_type: TAtom;
  1246. actual_type: PAtom; actual_format: Pcint; nitems: Pculong;
  1247. bytes_after: Pculong; prop: PPcuchar): TStatus; inline;
  1248. begin
  1249. XGetDeviceProperty := XGetDeviceProperty(dpy, dev, _property, offset, length, Ord(delete), req_type, actual_type,
  1250. actual_format, nitems, bytes_after, prop);
  1251. end;
  1252. end.