IOHIDEventData.h 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. /*
  2. *
  3. * @APPLE_LICENSE_HEADER_START@
  4. *
  5. * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
  6. *
  7. * This file contains Original Code and/or Modifications of Original Code
  8. * as defined in and that are subject to the Apple Public Source License
  9. * Version 2.0 (the 'License'). You may not use this file except in
  10. * compliance with the License. Please obtain a copy of the License at
  11. * http://www.opensource.apple.com/apsl/ and read it before using this
  12. * file.
  13. *
  14. * The Original Code and all software distributed under the License are
  15. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  16. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  17. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  19. * Please see the License for the specific language governing rights and
  20. * limitations under the License.
  21. *
  22. * @APPLE_LICENSE_HEADER_END@
  23. */
  24. #ifndef _IOKIT_HID_IOHIDEVENTDATA_H
  25. #define _IOKIT_HID_IOHIDEVENTDATA_H
  26. #include <IOKit/IOTypes.h>
  27. #include <IOKit/hid/IOHIDEventTypes.h>
  28. #ifdef KERNEL
  29. #include <IOKit/IOLib.h>
  30. #define IOHIDEventRef IOHIDEvent *
  31. #else
  32. #include <IOKit/hid/IOHIDEvent.h>
  33. typedef struct IOHIDEventData IOHIDEventData;
  34. #endif
  35. //==============================================================================
  36. // IOHIDEventData Declarations
  37. //==============================================================================
  38. #define IOHIDEVENT_BASE \
  39. uint32_t size; \
  40. IOHIDEventType type; \
  41. uint64_t timestamp; \
  42. uint32_t options;
  43. /*!
  44. @typedef IOHIDEventData
  45. @abstract
  46. @discussion
  47. @field size Size, in bytes, of the memory detailing this
  48. particular event
  49. @field type Type of this particular event
  50. @field options Event specific options
  51. */
  52. struct IOHIDEventData{
  53. IOHIDEVENT_BASE;
  54. };
  55. typedef struct _IOHIDVendorDefinedEventData {
  56. IOHIDEVENT_BASE;
  57. uint16_t usagePage;
  58. uint16_t usage;
  59. uint32_t version;
  60. uint32_t length;
  61. uint8_t data[0];
  62. } IOHIDVendorDefinedEventData;
  63. enum {
  64. kIOHIDKeyboardIsRepeat = 0x00010000
  65. };
  66. typedef struct _IOHIDKeyboardEventData {
  67. IOHIDEVENT_BASE; // options = kHIDKeyboardRepeat
  68. uint16_t usagePage;
  69. uint16_t usage;
  70. boolean_t down;
  71. } IOHIDKeyboardEventData;
  72. enum {
  73. kIOHIDEventOptionIgnore = 0xf0000000
  74. };
  75. enum {
  76. kIOHIDTransducerRange = 0x00010000,
  77. kIOHIDTransducerTouch = 0x00020000,
  78. kIOHIDTransducerInvert = 0x00040000,
  79. };
  80. enum {
  81. kIOHIDDigitizerOrientationTypeTilt = 0,
  82. kIOHIDDigitizerOrientationTypePolar,
  83. kIOHIDDigitizerOrientationTypeQuality
  84. };
  85. typedef uint8_t IOHIDDigitizerOrientationType;
  86. #define IOHIDAXISEVENT_BASE \
  87. struct { \
  88. IOFixed x; \
  89. IOFixed y; \
  90. IOFixed z; \
  91. } position;
  92. typedef struct _IOHIDAxisEventData {
  93. IOHIDEVENT_BASE; // options = kHIDAxisRelative
  94. IOHIDAXISEVENT_BASE;
  95. } IOHIDAxisEventData, IOHIDTranslationData, IOHIDRotationEventData, IOHIDScrollEventData, IOHIDScaleEventData, IOHIDVelocityData, IOHIDOrientationEventData;
  96. typedef struct _IOHIDAccelerometerEventData {
  97. IOHIDEVENT_BASE; // options = kHIDAxisRelative
  98. IOHIDAXISEVENT_BASE;
  99. uint32_t acclType;
  100. } IOHIDAccelerometerEventData;
  101. typedef struct _IOHIDAmbientLightSensorEventData {
  102. IOHIDEVENT_BASE; // options = kHIDAxisRelative
  103. uint32_t level;
  104. uint32_t ch0;
  105. uint32_t ch1;
  106. Boolean brightnessChanged;
  107. } IOHIDAmbientLightSensorEventData;
  108. typedef struct _IOHIDTemperatureEventData {
  109. IOHIDEVENT_BASE;
  110. IOFixed level;
  111. } IOHIDTemperatureEventData;
  112. typedef struct _IOHIDProximityEventData {
  113. IOHIDEVENT_BASE;
  114. uint32_t detectionMask;
  115. } IOHIDProximityEventData;
  116. typedef struct _IOHIDProgressEventData {
  117. IOHIDEVENT_BASE;
  118. uint32_t eventType;
  119. IOFixed level;
  120. } IOHIDProgressEventData;
  121. #define IOHIDBUTTONEVENT_BASE \
  122. struct { \
  123. uint32_t buttonMask; \
  124. IOFixed pressure; \
  125. uint8_t buttonNumber; \
  126. uint8_t clickState; \
  127. } button;
  128. typedef struct _IOHIDButtonEventData {
  129. IOHIDEVENT_BASE;
  130. IOHIDBUTTONEVENT_BASE;
  131. } IOHIDButtonEventData;
  132. typedef struct _IOHIDMouseEventData {
  133. IOHIDEVENT_BASE;
  134. IOHIDAXISEVENT_BASE;
  135. IOHIDBUTTONEVENT_BASE;
  136. } IOHIDMouseEventData;
  137. typedef struct _IOHIDDigitizerEventData {
  138. IOHIDEVENT_BASE; // options = kIOHIDTransducerRange, kHIDTransducerTouch, kHIDTransducerInvert
  139. IOHIDAXISEVENT_BASE; // 3c, 40, 44
  140. uint32_t transducerIndex;
  141. uint32_t transducerType; // could overload this to include that both the hand and finger id.
  142. uint32_t identity; // Specifies a unique ID of the current transducer action.
  143. uint32_t eventMask; // the type of event that has occurred: range, touch, position
  144. uint32_t childEventMask; // CHILD: the type of event that has occurred: range, touch, position
  145. uint32_t buttonMask; // Bit field representing the current button state
  146. // Pressure field are assumed to be scaled from 0.0 to 1.0
  147. IOFixed tipPressure; // Force exerted against the digitizer surface by the transducer.
  148. IOFixed barrelPressure; // Force exerted directly by the user on a transducer sensor.
  149. IOFixed twist; // Specifies the clockwise rotation of the cursor around its own major axis. Unsure it the device should declare units via properties or event. My first inclination is force degrees as the is the unit already expected by AppKit, Carbon and OpenGL.
  150. uint32_t orientationType; // Specifies the orientation type used by the transducer.
  151. union {
  152. struct { // X Tilt and Y Tilt are used together to specify the tilt away from normal of a digitizer transducer. In its normal position, the values of X Tilt and Y Tilt for a transducer are both zero.
  153. IOFixed x; // This quantity is used in conjunction with Y Tilt to represent the tilt away from normal of a transducer, such as a stylus. The X Tilt value represents the plane angle between the Y-Z plane and the plane containing the transducer axis and the Y axis. A positive X Tilt is to the right.
  154. IOFixed y; // This value represents the angle between the X-Z and transducer-X planes. A positive Y Tilt is toward the user.
  155. } tilt;
  156. struct { // X Tilt and Y Tilt are used together to specify the tilt away from normal of a digitizer transducer. In its normal position, the values of X Tilt and Y Tilt for a transducer are both zero.
  157. IOFixed altitude; //The angle with the X-Y plane though a signed, semicicular range. Positive values specify an angle downward and toward the positive Z axis.
  158. IOFixed azimuth; // Specifies the counter clockwise rotation of the cursor around the Z axis though a full circular range.
  159. } polar;
  160. struct {
  161. IOFixed quality; // If set, indicates that the transducer is sensed to be in a relatively noise-free region of digitizing.
  162. IOFixed density;
  163. IOFixed irregularity;
  164. IOFixed majorRadius; // units in mm
  165. IOFixed minorRadius; // units in mm
  166. } quality;
  167. }orientation;
  168. } IOHIDDigitizerEventData;
  169. typedef struct _IOHIDSwipeEventData {
  170. IOHIDEVENT_BASE;
  171. IOHIDSwipeMask swipeMask;
  172. } IOHIDSwipeEventData;
  173. /*!
  174. @typedef IOHIDSystemQueueElement
  175. @abstract Memory structure defining the layout of each event queue element
  176. @discussion The IOHIDEventQueueElement represents a portion of mememory in the
  177. new IOHIDEventQueue. It is possible that a event queue element
  178. can contain multiple interpretations of a given event. The first
  179. event is always considered the primary event.
  180. @field version Version of the event queue element
  181. @field size Size, in bytes, of this particular event queue element
  182. @field timeStamp Time at which event was dispatched
  183. @field deviceID ID of the sending device
  184. @field options Options for further developement
  185. @field eventCount The number of events contained in this transaction
  186. @field events Begining offset of contiguous mememory that contains the
  187. pertinent event data
  188. */
  189. typedef struct _IOHIDSystemQueueElement {
  190. uint64_t timeStamp;
  191. uint64_t deviceID;
  192. uint32_t options;
  193. uint32_t eventCount;
  194. IOHIDEventData events[];
  195. } IOHIDSystemQueueElement;
  196. //******************************************************************************
  197. // MACROS
  198. //******************************************************************************
  199. #define IOHIDEventFieldEventType(field) ((field >> 16) & 0xffff)
  200. #define IOHIDEventFieldOffset(field) (field & 0xffff)
  201. #define IOHIDEventGetSize(type,size) \
  202. { \
  203. switch ( type ) { \
  204. case kIOHIDEventTypeNULL: \
  205. size = sizeof(IOHIDEventData);\
  206. break; \
  207. case kIOHIDEventTypeVendorDefined:\
  208. size = sizeof(IOHIDVendorDefinedEventData);\
  209. break; \
  210. case kIOHIDEventTypeKeyboard: \
  211. size = sizeof(IOHIDKeyboardEventData);\
  212. break; \
  213. case kIOHIDEventTypeTranslation:\
  214. case kIOHIDEventTypeRotation: \
  215. case kIOHIDEventTypeScroll: \
  216. case kIOHIDEventTypeScale: \
  217. case kIOHIDEventTypeVelocity: \
  218. case kIOHIDEventTypeOrientation:\
  219. size = sizeof(IOHIDAxisEventData);\
  220. break; \
  221. case kIOHIDEventTypeAccelerometer:\
  222. size = sizeof(IOHIDAccelerometerEventData);\
  223. break;\
  224. case kIOHIDEventTypeAmbientLightSensor:\
  225. size = sizeof(IOHIDAmbientLightSensorEventData);\
  226. break; \
  227. case kIOHIDEventTypeProximity: \
  228. size = sizeof(IOHIDProximityEventData);\
  229. break; \
  230. case kIOHIDEventTypeButton: \
  231. size = sizeof(IOHIDButtonEventData);\
  232. break; \
  233. case kIOHIDEventTypeDigitizer: \
  234. size = sizeof(IOHIDDigitizerEventData);\
  235. break; \
  236. case kIOHIDEventTypeTemperature:\
  237. size = sizeof(IOHIDTemperatureEventData);\
  238. break; \
  239. case kIOHIDEventTypeSwipe:\
  240. size = sizeof(IOHIDSwipeEventData);\
  241. break; \
  242. case kIOHIDEventTypeMouse:\
  243. size = sizeof(IOHIDMouseEventData);\
  244. break; \
  245. case kIOHIDEventTypeProgress:\
  246. size = sizeof(IOHIDProgressEventData);\
  247. break; \
  248. default: \
  249. size = 0; \
  250. break; \
  251. } \
  252. }
  253. #define IOHIDEventGetQueueElementSize(type,size)\
  254. { \
  255. IOHIDEventGetSize(type,size); \
  256. size += sizeof(IOHIDSystemQueueElement); \
  257. }
  258. #ifdef KERNEL
  259. #ifdef HIDEVENTFIXED
  260. #define IOHIDEventValueFloat(value) (value)
  261. #define IOHIDEventValueFixed(value) (value)
  262. #else
  263. #define IOHIDEventValueFloat(value) (value >> 16)
  264. #define IOHIDEventValueFixed(value) (value << 16)
  265. #endif
  266. #define IOHIDEventGetEventWithOptions(event, type, options) event->getEvent(type, options)
  267. #define GET_EVENTDATA(event) event->_data
  268. #else
  269. #define IOHIDEventValueFloat(value) (value / 65536.0)
  270. #define IOHIDEventValueFixed(value) (value * 65536)
  271. #define GET_EVENTDATA(event) event->eventData
  272. #endif
  273. //==============================================================================
  274. // IOHIDEventGetValue MACRO
  275. //==============================================================================
  276. #define GET_EVENTDATA_VALUE(eventData, fieldEvType, fieldOffset, value)\
  277. { \
  278. switch ( fieldEvType ) { \
  279. case kIOHIDEventTypeNULL: \
  280. switch ( fieldOffset ) { \
  281. case IOHIDEventFieldOffset(kIOHIDEventFieldIsRelative): \
  282. value = (eventData->options & kIOHIDEventOptionIsAbsolute) == 0; \
  283. break; \
  284. case IOHIDEventFieldOffset(kIOHIDEventFieldIsCollection): \
  285. value = (eventData->options & kIOHIDEventOptionIsCollection) != 0; \
  286. break; \
  287. }; break; \
  288. case kIOHIDEventTypeVendorDefined: \
  289. { \
  290. IOHIDVendorDefinedEventData * sysDef = (IOHIDVendorDefinedEventData*)eventData; \
  291. switch ( fieldOffset ) { \
  292. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedUsagePage): \
  293. value = sysDef->usagePage; \
  294. break; \
  295. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedUsage): \
  296. value = sysDef->usage; \
  297. break; \
  298. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedVersion): \
  299. value = sysDef->version; \
  300. break; \
  301. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedDataLength): \
  302. value = sysDef->length; \
  303. break; \
  304. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedData): \
  305. if (sysDef->data) \
  306. value = *((typeof(value)*) sysDef->data); \
  307. break; \
  308. }; \
  309. } \
  310. break; \
  311. case kIOHIDEventTypeProgress: \
  312. { \
  313. IOHIDProgressEventData * progress = (IOHIDProgressEventData*)eventData; \
  314. switch ( fieldOffset ) { \
  315. case IOHIDEventFieldOffset(kIOHIDEventFieldProgressEventType): \
  316. value = progress->eventType; \
  317. break; \
  318. case IOHIDEventFieldOffset(kIOHIDEventFieldProgressLevel): \
  319. value = IOHIDEventValueFloat(progress->level); \
  320. break; \
  321. }; \
  322. } \
  323. break; \
  324. case kIOHIDEventTypeButton: \
  325. { \
  326. IOHIDButtonEventData * button = (IOHIDButtonEventData*)eventData; \
  327. switch ( fieldOffset ) { \
  328. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonMask): \
  329. value = button->button.buttonMask; \
  330. break; \
  331. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonNumber): \
  332. value = button->button.buttonNumber; \
  333. break; \
  334. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonClickCount): \
  335. value = button->button.clickState; \
  336. break; \
  337. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonPressure): \
  338. value = IOHIDEventValueFloat(button->button.pressure); \
  339. break; \
  340. }; \
  341. } \
  342. break; \
  343. case kIOHIDEventTypeAccelerometer: \
  344. { \
  345. IOHIDAccelerometerEventData * accl = (IOHIDAccelerometerEventData*)eventData; \
  346. switch ( fieldOffset ) { \
  347. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerX): \
  348. value = IOHIDEventValueFloat(accl->position.x); \
  349. break; \
  350. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerY): \
  351. value = IOHIDEventValueFloat(accl->position.y); \
  352. break; \
  353. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerZ): \
  354. value = IOHIDEventValueFloat(accl->position.z); \
  355. break; \
  356. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerType): \
  357. value = accl->acclType; \
  358. break; \
  359. }; \
  360. } \
  361. break; \
  362. case kIOHIDEventTypeMouse: \
  363. { \
  364. IOHIDMouseEventData * mouse = (IOHIDMouseEventData*)eventData; \
  365. switch ( fieldOffset ) { \
  366. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseX): \
  367. value = IOHIDEventValueFloat(mouse->position.x); \
  368. break; \
  369. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseY): \
  370. value = IOHIDEventValueFloat(mouse->position.y); \
  371. break; \
  372. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseZ): \
  373. value = IOHIDEventValueFloat(mouse->position.z); \
  374. break; \
  375. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseButtonMask): \
  376. value = mouse->button.buttonMask; \
  377. break; \
  378. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseNumber): \
  379. value = mouse->button.buttonNumber; \
  380. break; \
  381. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseClickCount): \
  382. value = mouse->button.clickState; \
  383. break; \
  384. case IOHIDEventFieldOffset(kIOHIDEventFieldMousePressure): \
  385. value = IOHIDEventValueFloat(mouse->button.pressure); \
  386. break; \
  387. }; \
  388. } \
  389. break; \
  390. case kIOHIDEventTypeSwipe: \
  391. { \
  392. IOHIDSwipeEventData * swipe = (IOHIDSwipeEventData *)eventData; \
  393. switch ( fieldOffset ) { \
  394. case IOHIDEventFieldOffset(kIOHIDEventFieldSwipeMask): \
  395. value = swipe->swipeMask; \
  396. break; \
  397. }; \
  398. } \
  399. break; \
  400. case kIOHIDEventTypeTemperature: \
  401. { \
  402. IOHIDTemperatureEventData * temp = (IOHIDTemperatureEventData *)eventData; \
  403. switch ( fieldOffset ) { \
  404. case IOHIDEventFieldOffset(kIOHIDEventFieldTemperatureLevel): \
  405. value = IOHIDEventValueFloat(temp->level);\
  406. break; \
  407. }; \
  408. } \
  409. break; \
  410. case kIOHIDEventTypeTranslation: \
  411. case kIOHIDEventTypeRotation: \
  412. case kIOHIDEventTypeScroll: \
  413. case kIOHIDEventTypeScale: \
  414. case kIOHIDEventTypeVelocity: \
  415. case kIOHIDEventTypeOrientation: \
  416. { \
  417. IOHIDAxisEventData * axis = (IOHIDAxisEventData *)eventData; \
  418. switch ( fieldOffset ) { \
  419. case IOHIDEventFieldOffset(kIOHIDEventFieldTranslationX): \
  420. /* \
  421. case IOHIDEventFieldOffset(kIOHIDEventFieldRotationX): \
  422. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollX): \
  423. case IOHIDEventFieldOffset(kIOHIDEventFieldScaleX): \
  424. case IOHIDEventFieldOffset(kIOHIDEventFieldVelocityX): \
  425. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerX); \
  426. case IOHIDEventFieldOffset(kIOHIDEventFieldOrientationRadius): \
  427. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerX): \
  428. */ \
  429. value = IOHIDEventValueFloat(axis->position.x); \
  430. break; \
  431. case IOHIDEventFieldOffset(kIOHIDEventFieldTranslationY): \
  432. /* \
  433. case IOHIDEventFieldOffset(kIOHIDEventFieldRotationY): \
  434. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollY): \
  435. case IOHIDEventFieldOffset(kIOHIDEventFieldScaleY): \
  436. case IOHIDEventFieldOffset(kIOHIDEventFieldVelocityY): \
  437. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerY); \
  438. case IOHIDEventFieldOffset(kIOHIDEventFieldOrientationAzimuth): \
  439. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerY): \
  440. */ \
  441. value = IOHIDEventValueFloat(axis->position.y); \
  442. break; \
  443. case IOHIDEventFieldOffset(kIOHIDEventFieldTranslationZ): \
  444. /* \
  445. case IOHIDEventFieldOffset(kIOHIDEventFieldRotationZ): \
  446. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollZ): \
  447. case IOHIDEventFieldOffset(kIOHIDEventFieldScaleZ): \
  448. case IOHIDEventFieldOffset(kIOHIDEventFieldVelocityZ): \
  449. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerZ); \
  450. case IOHIDEventFieldOffset(kIOHIDEventFieldOrientationAltitude):\
  451. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerZ): \
  452. */ \
  453. value = IOHIDEventValueFloat(axis->position.z); \
  454. break; \
  455. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollIsPixels): \
  456. value = ((axis->options & kIOHIDEventOptionPixelUnits) != 0);\
  457. break; \
  458. }; \
  459. } \
  460. break; \
  461. case kIOHIDEventTypeAmbientLightSensor: \
  462. { \
  463. IOHIDAmbientLightSensorEventData * alsEvent = (IOHIDAmbientLightSensorEventData *)eventData;\
  464. switch ( fieldOffset ) { \
  465. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightSensorLevel): \
  466. value = alsEvent->level; \
  467. break; \
  468. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightSensorRawChannel0): \
  469. value = alsEvent->ch0; \
  470. break; \
  471. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightSensorRawChannel1): \
  472. value = alsEvent->ch1; \
  473. break; \
  474. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightDisplayBrightnessChanged): \
  475. value = alsEvent->brightnessChanged; \
  476. break; \
  477. }; \
  478. } \
  479. break; \
  480. case kIOHIDEventTypeProximity: \
  481. { \
  482. IOHIDProximityEventData * proxEvent = (IOHIDProximityEventData *)eventData;\
  483. switch ( fieldOffset ) { \
  484. case IOHIDEventFieldOffset(kIOHIDEventFieldProximityDetectionMask): \
  485. value = proxEvent->detectionMask; \
  486. break; \
  487. }; \
  488. } \
  489. break; \
  490. case kIOHIDEventTypeKeyboard: \
  491. { \
  492. IOHIDKeyboardEventData * keyEvent = (IOHIDKeyboardEventData *)eventData;\
  493. switch ( fieldOffset ) { \
  494. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardUsagePage): \
  495. value = keyEvent->usagePage; \
  496. break; \
  497. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardUsage): \
  498. value = keyEvent->usage; \
  499. break; \
  500. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardDown): \
  501. value = keyEvent->down; \
  502. break; \
  503. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardRepeat): \
  504. value = (keyEvent->options & kIOHIDKeyboardIsRepeat);\
  505. break; \
  506. }; \
  507. } \
  508. break; \
  509. case kIOHIDEventTypeDigitizer: \
  510. { \
  511. IOHIDDigitizerEventData * digEvent = (IOHIDDigitizerEventData *)eventData; \
  512. switch ( fieldOffset ) { \
  513. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerX): \
  514. value = IOHIDEventValueFloat(digEvent->position.x); \
  515. break; \
  516. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerY): \
  517. value = IOHIDEventValueFloat(digEvent->position.y); \
  518. break; \
  519. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerZ): \
  520. value = IOHIDEventValueFloat(digEvent->position.z); \
  521. break; \
  522. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerButtonMask): \
  523. value = digEvent->buttonMask; \
  524. break; \
  525. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIndex): \
  526. value = digEvent->transducerIndex; \
  527. break; \
  528. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIdentity): \
  529. value = digEvent->identity; \
  530. break; \
  531. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerEventMask): \
  532. value = digEvent->eventMask; \
  533. break; \
  534. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerChildEventMask): \
  535. value = digEvent->childEventMask; \
  536. break; \
  537. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerRange): \
  538. value = (digEvent->options & kIOHIDTransducerRange) != 0;\
  539. break; \
  540. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTouch): \
  541. value = (digEvent->options & kIOHIDTransducerTouch) != 0;\
  542. break; \
  543. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerCollection): \
  544. value = (digEvent->options & kIOHIDEventOptionIsCollection) != 0;\
  545. break; \
  546. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerPressure): \
  547. value = IOHIDEventValueFloat(digEvent->tipPressure); \
  548. break; \
  549. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerBarrelPressure): \
  550. value = IOHIDEventValueFloat(digEvent->barrelPressure); \
  551. break; \
  552. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTwist): \
  553. value = IOHIDEventValueFloat(digEvent->twist); \
  554. break; \
  555. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltX): \
  556. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltY): \
  557. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerQuality): \
  558. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerDensity): \
  559. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIrregularity): \
  560. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMajorRadius): \
  561. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMinorRadius): \
  562. switch ( digEvent->orientationType ) {\
  563. case kIOHIDDigitizerOrientationTypeTilt:\
  564. switch ( fieldOffset ) {\
  565. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltX): \
  566. value = IOHIDEventValueFloat(digEvent->orientation.tilt.x); \
  567. break; \
  568. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltY): \
  569. value = IOHIDEventValueFloat(digEvent->orientation.tilt.y); \
  570. break; \
  571. }; \
  572. break; \
  573. case kIOHIDDigitizerOrientationTypePolar:\
  574. switch ( fieldOffset ) {\
  575. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerAltitude): \
  576. value = IOHIDEventValueFloat(digEvent->orientation.polar.altitude); \
  577. break; \
  578. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerAzimuth): \
  579. value = IOHIDEventValueFloat(digEvent->orientation.polar.azimuth); \
  580. break; \
  581. }; \
  582. break; \
  583. case kIOHIDDigitizerOrientationTypeQuality:\
  584. switch ( fieldOffset ) {\
  585. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerQuality): \
  586. value = IOHIDEventValueFloat(digEvent->orientation.quality.quality); \
  587. break; \
  588. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerDensity): \
  589. value = IOHIDEventValueFloat(digEvent->orientation.quality.density); \
  590. break; \
  591. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIrregularity): \
  592. value = IOHIDEventValueFloat(digEvent->orientation.quality.irregularity); \
  593. break; \
  594. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMajorRadius): \
  595. value = IOHIDEventValueFloat(digEvent->orientation.quality.majorRadius); \
  596. break; \
  597. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMinorRadius): \
  598. value = IOHIDEventValueFloat(digEvent->orientation.quality.minorRadius); \
  599. break; \
  600. }; \
  601. break; \
  602. }; \
  603. break; \
  604. }; \
  605. } \
  606. break; \
  607. }; \
  608. }
  609. #define GET_EVENT_VALUE(event, field, value, options) \
  610. { IOHIDEventType fieldEvType = IOHIDEventFieldEventType(field); \
  611. uint32_t fieldOffset = IOHIDEventFieldOffset(field); \
  612. IOHIDEventRef ev = NULL; \
  613. if ( (ev = IOHIDEventGetEventWithOptions(event, fieldEvType, options)) ) {\
  614. GET_EVENTDATA_VALUE(GET_EVENTDATA(ev),fieldEvType,fieldOffset,value);\
  615. } \
  616. }
  617. //==============================================================================
  618. // IOHIDEventSetValue MACRO
  619. //==============================================================================
  620. #define SET_EVENTDATA_VALUE(eventData, fieldEvType, fieldOffset, value) \
  621. { switch ( fieldEvType ) { \
  622. case kIOHIDEventTypeNULL: \
  623. switch ( fieldOffset ) { \
  624. case IOHIDEventFieldOffset(kIOHIDEventFieldIsRelative): \
  625. if ( value ) \
  626. eventData->options &= ~kIOHIDEventOptionIsAbsolute; \
  627. else \
  628. eventData->options |= kIOHIDEventOptionIsAbsolute; \
  629. break; \
  630. case IOHIDEventFieldOffset(kIOHIDEventFieldIsCollection): \
  631. if ( value ) \
  632. eventData->options |= kIOHIDEventOptionIsCollection; \
  633. else \
  634. eventData->options &= ~kIOHIDEventOptionIsCollection; \
  635. break; \
  636. }; break; \
  637. case kIOHIDEventTypeVendorDefined: \
  638. { \
  639. IOHIDVendorDefinedEventData * sysDef = (IOHIDVendorDefinedEventData*)eventData; \
  640. switch ( fieldOffset ) { \
  641. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedUsagePage): \
  642. sysDef->usagePage = value; \
  643. break; \
  644. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedUsage): \
  645. sysDef->usage = value; \
  646. break; \
  647. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedVersion): \
  648. sysDef->version = value; \
  649. break; \
  650. case IOHIDEventFieldOffset(kIOHIDEventFieldVendorDefinedData): \
  651. if (sysDef->data) \
  652. *((typeof(value)*) sysDef->data) = value; \
  653. break; \
  654. }; \
  655. } \
  656. break; \
  657. case kIOHIDEventTypeProgress: \
  658. { \
  659. IOHIDProgressEventData * progress = (IOHIDProgressEventData*)eventData; \
  660. switch ( fieldOffset ) { \
  661. case IOHIDEventFieldOffset(kIOHIDEventFieldProgressEventType): \
  662. progress->eventType = value; \
  663. break; \
  664. case IOHIDEventFieldOffset(kIOHIDEventFieldProgressLevel): \
  665. progress->level = IOHIDEventValueFixed(value); \
  666. break; \
  667. }; \
  668. } \
  669. break; \
  670. case kIOHIDEventTypeButton: \
  671. { \
  672. IOHIDButtonEventData * button = (IOHIDButtonEventData*)eventData; \
  673. switch ( fieldOffset ) { \
  674. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonMask): \
  675. button->button.buttonMask = value; \
  676. break; \
  677. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonNumber): \
  678. button->button.buttonNumber = value; \
  679. break; \
  680. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonClickCount): \
  681. button->button.clickState = value; \
  682. break; \
  683. case IOHIDEventFieldOffset(kIOHIDEventFieldButtonPressure): \
  684. button->button.pressure = IOHIDEventValueFixed(value); \
  685. break; \
  686. }; \
  687. } \
  688. break; \
  689. case kIOHIDEventTypeAccelerometer: \
  690. { \
  691. IOHIDAccelerometerEventData * accl = (IOHIDAccelerometerEventData*)eventData; \
  692. switch ( fieldOffset ) { \
  693. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerX): \
  694. accl->position.x = IOHIDEventValueFixed(value); \
  695. break; \
  696. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerY): \
  697. accl->position.y = IOHIDEventValueFixed(value); \
  698. break; \
  699. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerZ): \
  700. accl->position.z = IOHIDEventValueFixed(value); \
  701. break; \
  702. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerType): \
  703. accl->acclType = value; \
  704. break; \
  705. }; \
  706. } \
  707. break; \
  708. case kIOHIDEventTypeMouse: \
  709. { \
  710. IOHIDMouseEventData * mouse = (IOHIDMouseEventData*)eventData; \
  711. switch ( fieldOffset ) { \
  712. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseX): \
  713. mouse->position.x = IOHIDEventValueFixed(value); \
  714. break; \
  715. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseY): \
  716. mouse->position.y = IOHIDEventValueFixed(value); \
  717. break; \
  718. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseZ): \
  719. mouse->position.z = IOHIDEventValueFixed(value); \
  720. break; \
  721. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseButtonMask): \
  722. mouse->button.buttonMask = value; \
  723. break; \
  724. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseNumber): \
  725. mouse->button.buttonNumber = value; \
  726. break; \
  727. case IOHIDEventFieldOffset(kIOHIDEventFieldMouseClickCount): \
  728. mouse->button.clickState = value; \
  729. break; \
  730. case IOHIDEventFieldOffset(kIOHIDEventFieldMousePressure): \
  731. mouse->button.pressure = IOHIDEventValueFixed(value); \
  732. break; \
  733. }; \
  734. } \
  735. break; \
  736. case kIOHIDEventTypeSwipe: \
  737. { \
  738. IOHIDSwipeEventData * swipe = (IOHIDSwipeEventData *)eventData; \
  739. switch ( fieldOffset ) { \
  740. case IOHIDEventFieldOffset(kIOHIDEventFieldSwipeMask): \
  741. swipe->swipeMask = value;\
  742. break; \
  743. }; \
  744. } \
  745. break; \
  746. case kIOHIDEventTypeTemperature: \
  747. { \
  748. IOHIDTemperatureEventData * temp = (IOHIDTemperatureEventData *)eventData; \
  749. switch ( fieldOffset ) { \
  750. case IOHIDEventFieldOffset(kIOHIDEventFieldTemperatureLevel): \
  751. temp->level = IOHIDEventValueFixed(value);\
  752. break; \
  753. }; \
  754. } \
  755. break; \
  756. case kIOHIDEventTypeTranslation: \
  757. case kIOHIDEventTypeRotation: \
  758. case kIOHIDEventTypeScroll: \
  759. case kIOHIDEventTypeScale: \
  760. case kIOHIDEventTypeVelocity: \
  761. case kIOHIDEventTypeOrientation: \
  762. { \
  763. IOHIDAxisEventData * axis = (IOHIDAxisEventData *)eventData; \
  764. switch ( fieldOffset ) { \
  765. case IOHIDEventFieldOffset(kIOHIDEventFieldTranslationX): \
  766. /* \
  767. case IOHIDEventFieldOffset(kIOHIDEventFieldRotationX): \
  768. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollX): \
  769. case IOHIDEventFieldOffset(kIOHIDEventFieldScaleX): \
  770. case IOHIDEventFieldOffset(kIOHIDEventFieldVelocityX): \
  771. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerX); \
  772. case IOHIDEventFieldOffset(kIOHIDEventFieldOrientationRadius): \
  773. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerX): \
  774. */ \
  775. axis->position.x = IOHIDEventValueFixed(value); \
  776. break; \
  777. case IOHIDEventFieldOffset(kIOHIDEventFieldTranslationY): \
  778. /* \
  779. case IOHIDEventFieldOffset(kIOHIDEventFieldRotationY): \
  780. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollY): \
  781. case IOHIDEventFieldOffset(kIOHIDEventFieldScaleY): \
  782. case IOHIDEventFieldOffset(kIOHIDEventFieldVelocityY): \
  783. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerY); \
  784. case IOHIDEventFieldOffset(kIOHIDEventFieldOrientationAzimuth): \
  785. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerY): \
  786. */ \
  787. axis->position.y = IOHIDEventValueFixed(value); \
  788. break; \
  789. case IOHIDEventFieldOffset(kIOHIDEventFieldTranslationZ): \
  790. /* \
  791. case IOHIDEventFieldOffset(kIOHIDEventFieldRotationZ): \
  792. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollZ): \
  793. case IOHIDEventFieldOffset(kIOHIDEventFieldScaleZ): \
  794. case IOHIDEventFieldOffset(kIOHIDEventFieldVelocityZ): \
  795. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerZ); \
  796. case IOHIDEventFieldOffset(kIOHIDEventFieldOrientationAltitude):\
  797. case IOHIDEventFieldOffset(kIOHIDEventFieldAccelerometerZ): \
  798. */ \
  799. axis->position.z = IOHIDEventValueFixed(value); \
  800. break; \
  801. case IOHIDEventFieldOffset(kIOHIDEventFieldScrollIsPixels): \
  802. if ( value ) \
  803. axis->options |= kIOHIDEventOptionPixelUnits; \
  804. else \
  805. axis->options &= ~kIOHIDEventOptionPixelUnits; \
  806. break; \
  807. }; \
  808. } \
  809. break; \
  810. case kIOHIDEventTypeAmbientLightSensor: \
  811. { \
  812. IOHIDAmbientLightSensorEventData * alsEvent = (IOHIDAmbientLightSensorEventData *)eventData;\
  813. switch ( fieldOffset ) { \
  814. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightSensorLevel): \
  815. alsEvent->level = value; \
  816. break; \
  817. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightSensorRawChannel0): \
  818. alsEvent->ch0 = value; \
  819. break; \
  820. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightSensorRawChannel1): \
  821. alsEvent->ch1 = value; \
  822. break; \
  823. case IOHIDEventFieldOffset(kIOHIDEventFieldAmbientLightDisplayBrightnessChanged): \
  824. alsEvent->brightnessChanged = value; \
  825. break; \
  826. }; \
  827. } \
  828. break; \
  829. case kIOHIDEventTypeProximity: \
  830. { \
  831. IOHIDProximityEventData * proxEvent = (IOHIDProximityEventData *)eventData;\
  832. switch ( fieldOffset ) { \
  833. case IOHIDEventFieldOffset(kIOHIDEventFieldProximityDetectionMask): \
  834. proxEvent->detectionMask = value; \
  835. break; \
  836. }; \
  837. } \
  838. break; \
  839. case kIOHIDEventTypeKeyboard: \
  840. { \
  841. IOHIDKeyboardEventData * keyEvent = (IOHIDKeyboardEventData *)eventData;\
  842. switch ( fieldOffset ) { \
  843. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardUsagePage): \
  844. keyEvent->usagePage = value; \
  845. break; \
  846. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardUsage): \
  847. keyEvent->usage = value; \
  848. break; \
  849. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardDown): \
  850. keyEvent->down = value; \
  851. break; \
  852. case IOHIDEventFieldOffset(kIOHIDEventFieldKeyboardRepeat): \
  853. if ( value ) \
  854. keyEvent->options |= kIOHIDKeyboardIsRepeat; \
  855. else \
  856. keyEvent->options &= ~kIOHIDKeyboardIsRepeat; \
  857. break; \
  858. }; \
  859. } \
  860. break; \
  861. case kIOHIDEventTypeDigitizer: \
  862. { \
  863. IOHIDDigitizerEventData * digEvent = (IOHIDDigitizerEventData *)eventData; \
  864. switch ( fieldOffset ) { \
  865. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerX): \
  866. digEvent->position.x = IOHIDEventValueFixed(value); \
  867. break; \
  868. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerY): \
  869. digEvent->position.y = IOHIDEventValueFixed(value); \
  870. break; \
  871. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerZ): \
  872. digEvent->position.z = IOHIDEventValueFixed(value); \
  873. break; \
  874. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerButtonMask): \
  875. digEvent->buttonMask = value; \
  876. break; \
  877. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIndex): \
  878. digEvent->transducerIndex = value; \
  879. break; \
  880. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIdentity): \
  881. digEvent->identity = value; \
  882. break; \
  883. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerEventMask): \
  884. digEvent->eventMask = value; \
  885. break; \
  886. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerChildEventMask): \
  887. digEvent->childEventMask = value; \
  888. break; \
  889. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerRange): \
  890. if ( value ) \
  891. digEvent->options |= kIOHIDTransducerRange; \
  892. else \
  893. digEvent->options &= ~kIOHIDTransducerRange; \
  894. break; \
  895. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTouch): \
  896. if ( value ) \
  897. digEvent->options |= kIOHIDTransducerTouch; \
  898. else \
  899. digEvent->options &= ~kIOHIDTransducerTouch; \
  900. break; \
  901. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerCollection): \
  902. if ( value ) \
  903. digEvent->options |= kIOHIDEventOptionIsCollection; \
  904. else \
  905. digEvent->options &= ~kIOHIDEventOptionIsCollection; \
  906. break; \
  907. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerPressure): \
  908. digEvent->tipPressure = IOHIDEventValueFixed(value); \
  909. break; \
  910. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerBarrelPressure): \
  911. digEvent->barrelPressure = IOHIDEventValueFixed(value); \
  912. break; \
  913. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTwist): \
  914. digEvent->twist = IOHIDEventValueFixed(value); \
  915. break; \
  916. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltX): \
  917. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltY): \
  918. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerQuality): \
  919. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerDensity): \
  920. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIrregularity): \
  921. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMajorRadius): \
  922. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMinorRadius): \
  923. switch ( digEvent->orientationType ) {\
  924. case kIOHIDDigitizerOrientationTypeTilt:\
  925. switch ( fieldOffset ) {\
  926. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltX): \
  927. digEvent->orientation.tilt.x = IOHIDEventValueFixed(value); \
  928. break; \
  929. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerTiltY): \
  930. digEvent->orientation.tilt.y = IOHIDEventValueFixed(value); \
  931. break; \
  932. }; \
  933. break; \
  934. case kIOHIDDigitizerOrientationTypePolar:\
  935. switch ( fieldOffset ) {\
  936. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerAltitude): \
  937. digEvent->orientation.polar.altitude = IOHIDEventValueFixed(value); \
  938. break; \
  939. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerAzimuth): \
  940. digEvent->orientation.polar.azimuth = IOHIDEventValueFixed(value); \
  941. break; \
  942. }; \
  943. break; \
  944. case kIOHIDDigitizerOrientationTypeQuality:\
  945. switch ( fieldOffset ) {\
  946. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerQuality): \
  947. digEvent->orientation.quality.quality = IOHIDEventValueFixed(value); \
  948. break; \
  949. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerDensity): \
  950. digEvent->orientation.quality.density = IOHIDEventValueFixed(value); \
  951. break; \
  952. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerIrregularity): \
  953. digEvent->orientation.quality.irregularity = IOHIDEventValueFixed(value); \
  954. break; \
  955. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMajorRadius): \
  956. digEvent->orientation.quality.majorRadius = IOHIDEventValueFixed(value); \
  957. break; \
  958. case IOHIDEventFieldOffset(kIOHIDEventFieldDigitizerMinorRadius): \
  959. digEvent->orientation.quality.minorRadius = IOHIDEventValueFixed(value); \
  960. break; \
  961. }; \
  962. break; \
  963. }; \
  964. break; \
  965. }; \
  966. } \
  967. break; \
  968. }; \
  969. }
  970. #define SET_EVENT_VALUE(event, field, value, options) \
  971. { IOHIDEventType fieldEvType = IOHIDEventFieldEventType(field); \
  972. uint32_t fieldOffset = IOHIDEventFieldOffset(field); \
  973. IOHIDEventRef ev = NULL; \
  974. if ( (ev = IOHIDEventGetEventWithOptions(event, fieldEvType, options)) ) {\
  975. SET_EVENTDATA_VALUE(GET_EVENTDATA(ev),fieldEvType,fieldOffset,value);\
  976. } \
  977. }
  978. #endif /* _IOKIT_HID_IOHIDEVENTDATA_H */