Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2254 lines
69 KiB

  1. #ifndef __ControlItems_h__
  2. #define __ControlItems_h__
  3. //@doc
  4. /**********************************************************************
  5. *
  6. * @module ControlItems.h |
  7. *
  8. * Declares basic structures for CControlItem and derived objects
  9. * that go in CControlItemCollections
  10. *
  11. * History
  12. * ----------------------------------------------------------
  13. * Mitchell S. Dernis Original
  14. *
  15. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  16. *
  17. * @topic ControlItems |
  18. * Control items represent a group of controls that share the same
  19. * HID UsagePage, Link-Collection, and are in a range of USAGES.
  20. *
  21. **********************************************************************/
  22. namespace ControlItemConst
  23. {
  24. //Device Item Types
  25. const USHORT usAxes = 1;
  26. const USHORT usDPAD = 2;
  27. const USHORT usPropDPAD = 3;
  28. const USHORT usWheel = 4;
  29. const USHORT usPOV = 5;
  30. const USHORT usThrottle = 6;
  31. const USHORT usRudder = 7;
  32. const USHORT usPedal = 8;
  33. const USHORT usButton = 9;
  34. const USHORT usZoneIndicator = 10;
  35. const USHORT usShiftedButton = 11;
  36. const USHORT usForceMap = 12;
  37. const USHORT usButtonLED = 13;
  38. const USHORT usAxisToKeyMapModel = 14;
  39. const USHORT usProfileSelectors = 15;
  40. const USHORT usDualZoneIndicator = 16;
  41. // To be used where there is more than one shift button
  42. // Reserve 255 of these: 0x101 Shift 1, 0x102 Shift 2, ..., 0x1ff Shift 255
  43. const USHORT usShiftedButtonN = 0x100;
  44. //DPAD and POV directions
  45. const LONG lCenter = -1;
  46. const LONG lNorth = 0;
  47. const LONG lNorthEast = 1;
  48. const LONG lEast = 2;
  49. const LONG lSouthEast = 3;
  50. const LONG lSouth = 4;
  51. const LONG lSouthWest = 5;
  52. const LONG lWest = 6;
  53. const LONG lNorthWest = 7;
  54. //Report Types
  55. const UCHAR ucReportTypeReadable = 0x80;
  56. const UCHAR ucReportTypeWriteable = 0x40;
  57. const UCHAR ucReportTypeInput = 0x01 | ucReportTypeReadable;
  58. const UCHAR ucReportTypeOutput = 0x02 | ucReportTypeWriteable;
  59. const UCHAR ucReportTypeFeature = 0x04;
  60. const UCHAR ucReportTypeFeatureRO = ucReportTypeFeature | ucReportTypeReadable;
  61. const UCHAR ucReportTypeFeatureWO = ucReportTypeFeature | ucReportTypeWriteable;
  62. const UCHAR ucReportTypeFeatureRW = ucReportTypeFeature | ucReportTypeReadable | ucReportTypeWriteable;
  63. //Non-standard HID definitions
  64. const USHORT HID_VENDOR_PAGE = 0xff01;
  65. const USHORT HID_VENDOR_TILT_SENSOR = 0x0001; //legacy
  66. const USHORT HID_VENDOR_PROPDPAD_MODE = 0x0030;
  67. const USHORT HID_VENDOR_PROPDPAD_SWITCH = 0x0030;
  68. const USHORT HID_VENDOR_ZONE_INDICATOR_X= 0x0046;
  69. const USHORT HID_VENDOR_ZONE_INDICATOR_Y= 0x0047;
  70. const USHORT HID_VENDOR_ZONE_INDICATOR_Z= 0x0048;
  71. const USHORT HID_VENDOR_PEDALS_PRESENT = 0x0049;
  72. // Behaviours of Button LEDS -- Default Modes
  73. const UCHAR LED_DEFAULT_MODE_ON = 0; // On
  74. const UCHAR LED_DEFAULT_MODE_OFF = 1; // Off
  75. const UCHAR LED_DEFAULT_MODE_BLINK = 2; // Blinking
  76. const UCHAR LED_DEFAULT_MODE_CORRESPOND_ON = 3; // On if corresp. button has action (else off)
  77. const UCHAR LED_DEFAULT_MODE_CORRESPOND_OFF = 4; // Off if corresp. button has action (else on)
  78. const UCHAR LED_DEFAULT_MODE_BLINK_OFF = 5; // Blinking if c. button has action (else off)
  79. const UCHAR LED_DEFAULT_MODE_BLINK_ON = 6; // Blinking if c. button has action (else on)
  80. };
  81. #pragma pack(push ,foo, 1)
  82. //
  83. // @struct MODIFIER_ITEM_DESC |
  84. // Contains all the data for reading a modifier button
  85. //
  86. struct MODIFIER_ITEM_DESC
  87. {
  88. USAGE UsagePage; // @field Usage Page of Modifier Button
  89. USAGE Usage; // @field Usage of Modifier Button
  90. USHORT usLinkCollection; // @field Link Collection Modifier Button is in
  91. USAGE LinkUsage; // @field Usage of Link Collection Modifier Button is in
  92. USAGE LinkUsagePage; // @field Usage Page of Link Collection Modifier Button is in
  93. USHORT usReportCount; // @field Report count of Buttons in same collection
  94. UCHAR ucReportType; // @field Report Type (Input\Feature(RO\WO\RW)\Output)
  95. UCHAR ucReportId; // @field Report ID for modifier
  96. };
  97. typedef MODIFIER_ITEM_DESC *PMODIFIER_ITEM_DESC;
  98. struct MODIFIER_DESC_TABLE
  99. {
  100. ULONG ulModifierCount;
  101. ULONG ulShiftButtonCount;
  102. PMODIFIER_ITEM_DESC pModifierArray;
  103. };
  104. typedef MODIFIER_DESC_TABLE *PMODIFIER_DESC_TABLE;
  105. typedef struct tagAXES_RANGE_TABLE
  106. {
  107. LONG lMinX; // @field Minimum value of X axis
  108. LONG lCenterX; // @field Center value for X
  109. LONG lMaxX; // @field Maximum value of X axis
  110. LONG lMinY; // @field Minimum value of Y axis
  111. LONG lCenterY; // @field Center value for Y
  112. LONG lMaxY; // @field Maximum value of Y axis
  113. LONG lNorth; // @field Cut off for North
  114. LONG lSouth; // @field Cut off for South
  115. LONG lWest; // @field Cut off for West
  116. LONG lEast; // @field Cut off for East
  117. } AXES_RANGE_TABLE, *PAXES_RANGE_TABLE;
  118. typedef struct tagDUALZONE_AXES_RANGE_TABLE
  119. {
  120. LONG lMin[2]; // @field Minimum value of each axis
  121. LONG lCenter[2]; // @field Center value for each axis
  122. LONG lMax[2]; // @field Maximum value of each axis
  123. LONG lDeadZone[2]; // @field DeadZone value of each axis
  124. } DUALZONE_RANGE_TABLE, *PDUALZONE_RANGE_TABLE;
  125. //
  126. // @struct RAW_CONTROL_ITEM_DESC |
  127. // This first raw structure is good for declaring tables, it contains all the information
  128. // an object needs to know about it self statically.
  129. //
  130. struct RAW_CONTROL_ITEM_DESC
  131. {
  132. ULONG ulItemIndex; // @field Index of item in collection
  133. USHORT usType; // @field Type of item (type defined in ControlItemConst namespace)
  134. USAGE UsagePage; // @field Usage Page of Item
  135. USHORT usLinkCollection; // @field Link of collection item is in
  136. USAGE LinkUsage; // @field Usage of link collection item is in
  137. USAGE LinkUsagePage; // @field Usage PAge of link collection item is in
  138. USHORT usBitSize; // @field Number of bits item occupies in report
  139. USHORT usReportCount; // @field Number of count of items if array (or buttons)
  140. PMODIFIER_DESC_TABLE pModifierDescTable; // @field Points to modifier descriptor table
  141. USAGE SubItemUsage1; // @field Interpretation depends on usType
  142. USAGE SubItemUsage2; // @field Interpretation depends on usType
  143. LONG lSubItemMin1; // @field Interpretation depends on usType
  144. LONG lSubItemMax1; // @field Interpretation depends on usType
  145. };
  146. typedef RAW_CONTROL_ITEM_DESC *PRAW_CONTROL_ITEM_DESC;
  147. //
  148. // @struct CONTROL_ITEM_DESC |
  149. // Same as RawControlItemDesc but uses Union to give better names to the SubItem fields.
  150. //
  151. struct CONTROL_ITEM_DESC
  152. {
  153. ULONG ulItemIndex; // @field Index of item in collection
  154. USHORT usType; // @field Type of item (type defined in ControlItemConst namespace)
  155. USAGE UsagePage; // @field Usage Page of Item
  156. USHORT usLinkCollection; // @field Link of collection item is in
  157. USAGE LinkUsage; // @field Usage of link collection item is in
  158. USAGE LinkUsagePage; // @field Usage Page of link collection item is in
  159. USHORT usBitSize; // @field Number of bits item occupies in report
  160. USHORT usReportCount; // @field Number of count of items if array (or buttons)
  161. PMODIFIER_DESC_TABLE pModifierDescTable; // @field Points to modifier descriptor table
  162. union
  163. {
  164. struct
  165. {
  166. USAGE UsageX; // @field Usage of X axis
  167. USAGE UsageY; // @field Usage of Y axis
  168. PAXES_RANGE_TABLE pRangeTable; // @field Pointer to range table
  169. LONG lReserved2; // @field Placeholder to match other structs in union
  170. } Axes, DPAD, PropDPAD;
  171. struct
  172. {
  173. USAGE Usage; // @field Usage of item
  174. USHORT usSubIndex; // @field If item is in array(usReportCount > 1), holds the index
  175. LONG lMin; // @field Minimum value of usage
  176. LONG lMax; // @field Maximum value of usage
  177. } Generic, Wheel, POV, Throttle, Rudder, Pedal;
  178. struct
  179. {
  180. USAGE UsageMin; // @field Usage of minimum buton
  181. USAGE UsageMax; // @field Usage of maximum buton
  182. LONG lReserved1; // @field Placeholder to match other structs in union
  183. LONG lReserved2; // @field Placeholder to match other structs in union
  184. } Buttons;
  185. struct
  186. {
  187. USAGE BaseIndicatorUsage; // @field Base Usage for Zone indicators
  188. USAGE ReservedUsage; // @field Placeholder to match other structs in union
  189. ULONG ulAxesBitField; // @field Bit field showing which indicators are available. X is bit 0
  190. LONG lReserved1; // @field Placeholder to match other structs in union
  191. } ZoneIndicators;
  192. struct
  193. {
  194. USAGE rgUsageAxis[2]; // @field Usage of the two axis
  195. PDUALZONE_RANGE_TABLE pZoneRangeTable; // @field Pointer to range table
  196. LONG lNumberOfZones; // @field How many zones does this divide into
  197. } DualZoneIndicators;
  198. struct
  199. {
  200. USAGE Usage; // @field Usage
  201. UCHAR bMapYToX; // @field Bool value
  202. USHORT usRTC; // @field return to center force (0-10000)
  203. USHORT usGain; // @field gain for the device
  204. UCHAR ucReserved; // @field Placeholder to match other structs in union
  205. } ForceMap;
  206. struct
  207. {
  208. USAGE UsageMinLED; // @field Usage of lowest LED (they better be consecutive)
  209. UCHAR ucReportType; // @field Report Type LED is in (Input\Feature(RO\WO\RW)\Output)
  210. UCHAR ucReportId; // @field Report ID for LED
  211. UCHAR ucCorrespondingButtonItem; // @field What button item does this refer to?
  212. UCHAR ucDefaultMode; // @field Defaullt LED behaviour (see ControlItemConst)
  213. UCHAR ucReserved; // @field Reserved (should be 0)
  214. ULONG ulReserved; // @field Reserved (should be 0)
  215. } ButtonLEDs;
  216. struct
  217. {
  218. USAGE UsageButtonMin; // @field Usage of first button for selector
  219. USAGE UsageButtonMax; // @field Usage of last button for selector
  220. ULONG ulFirstProfile; // @field What profile does the min select
  221. ULONG ulLastProfile; // @field What profile does the max select
  222. } ProfileSelectors;
  223. };
  224. };
  225. typedef CONTROL_ITEM_DESC *PCONTROL_ITEM_DESC;
  226. //
  227. // @struct CONTROL_ITEM_XFER |
  228. // Used to transfer states between device item objects in different collections - input to outputs.
  229. // Used to represent in the state of items in Actions, and to idendity the trigger element for an action.
  230. //
  231. struct CONTROL_ITEM_XFER
  232. {
  233. ULONG ulItemIndex;
  234. union
  235. {
  236. struct
  237. {
  238. LONG lValX;
  239. LONG lValY;
  240. } Axes, DPAD, PropDPAD;
  241. struct
  242. {
  243. LONG rglVal[2];
  244. } DualZoneIndicators;
  245. struct
  246. {
  247. LONG lVal;
  248. } Generic, Wheel, POV, Throttle, Rudder, Pedal, ProfileSelector;
  249. struct
  250. {
  251. USHORT usButtonNumber;
  252. ULONG ulButtonBitArray;
  253. } Button;
  254. struct
  255. {
  256. ULONG ulZoneIndicatorBits;
  257. } ZoneIndicators;
  258. struct
  259. {
  260. UCHAR ucModifierByte;
  261. UCHAR rgucKeysDown[6];
  262. } Keyboard;
  263. struct
  264. {
  265. ULONG bMapYToX : 1;
  266. ULONG usRTC : 15;
  267. ULONG usGain: 15;
  268. ULONG Reserved : 1;
  269. } ForceMap;
  270. struct
  271. {
  272. ULONG dwValue; // In milliseconds
  273. } Delay;
  274. struct
  275. {
  276. ULONG dwMouseButtons; // Bit field
  277. } MouseButtons;
  278. };
  279. ULONG ulModifiers;
  280. #ifdef __cplusplus
  281. bool operator==(const CONTROL_ITEM_XFER& rhs)
  282. {
  283. // Are we even the same type
  284. if (ulItemIndex != rhs.ulItemIndex)
  285. {
  286. return false;
  287. }
  288. return ((Axes.lValX == rhs.Axes.lValX) && (Axes.lValY == rhs.Axes.lValY) && (ulModifiers == rhs.ulModifiers));
  289. }
  290. bool operator!=(const CONTROL_ITEM_XFER& rhs)
  291. {
  292. if (ulItemIndex != rhs.ulItemIndex)
  293. {
  294. return true;
  295. }
  296. return ((Axes.lValX != rhs.Axes.lValX) || (Axes.lValY != rhs.Axes.lValY) || (ulModifiers != rhs.ulModifiers));
  297. }
  298. #endif __cplusplus
  299. };
  300. typedef CONTROL_ITEM_XFER *PCONTROL_ITEM_XFER;
  301. #pragma pack(pop , foo)
  302. #ifdef COMPILE_FOR_WDM_KERNEL_MODE
  303. namespace NonGameDeviceXfer
  304. {
  305. const ULONG c_ulMaxXFerKeys = 6;
  306. // Non game device XFers
  307. const ULONG ulKeyboardIndex = 0xFFFF0000;
  308. const ULONG ulMouseIndex = 0xFFFF0001;
  309. const ULONG ulDelayIndex = 0xFFFF0002;
  310. // Checks for non device xfer types
  311. inline BOOLEAN IsKeyboardXfer(const CONTROL_ITEM_XFER& crControlItemXfer)
  312. {
  313. return (crControlItemXfer.ulItemIndex == ulKeyboardIndex);
  314. }
  315. inline BOOLEAN IsMouseXfer(const CONTROL_ITEM_XFER& crControlItemXfer)
  316. {
  317. return (crControlItemXfer.ulItemIndex == ulMouseIndex);
  318. }
  319. inline BOOLEAN IsDelayXfer(const CONTROL_ITEM_XFER& crControlItemXfer)
  320. {
  321. return (crControlItemXfer.ulItemIndex == ulDelayIndex);
  322. }
  323. };
  324. #else
  325. #include "ieevents.h" // For IE_KEYEVENT definition
  326. namespace NonGameDeviceXfer
  327. {
  328. const ULONG c_ulMaxXFerKeys = 6;
  329. const ULONG ulKeyboardIndex = 0xFFFF0000;
  330. const ULONG ulMouseIndex = 0xFFFF0001;
  331. const ULONG ulDelayIndex = 0xFFFF0002;
  332. inline BOOLEAN IsKeyboardXfer(const CONTROL_ITEM_XFER& crControlItemXfer)
  333. {
  334. return (crControlItemXfer.ulItemIndex == ulKeyboardIndex);
  335. }
  336. inline BOOLEAN IsMouseXfer(const CONTROL_ITEM_XFER& crControlItemXfer)
  337. {
  338. return (crControlItemXfer.ulItemIndex == ulMouseIndex);
  339. }
  340. inline BOOLEAN IsDelayXfer(const CONTROL_ITEM_XFER& crControlItemXfer)
  341. {
  342. return (crControlItemXfer.ulItemIndex == ulDelayIndex);
  343. }
  344. void MakeKeyboardXfer(CONTROL_ITEM_XFER& rControlItemXfer, ULONG ulScanCodeCount, const USHORT* pusScanCodes);
  345. void MakeKeyboardXfer(CONTROL_ITEM_XFER& rControlItemXfer, const IE_KEYEVENT& rKeyEvent);
  346. void AddScanCodeToXfer(CONTROL_ITEM_XFER& rControlItemXfer, WORD wScanCode);
  347. void ScanCodesFromKeyboardXfer(const CONTROL_ITEM_XFER& crControlItemXfer, ULONG& rulScanCodeCount, USHORT* pusScanCodes);
  348. void MakeKeyboardXfer(CONTROL_ITEM_XFER& rControlItemXfer, const IE_KEYEVENT& rKeyEvent);
  349. void MakeDelayXfer(CONTROL_ITEM_XFER& rControlItemXfer, DWORD dwDelay);
  350. };
  351. #endif
  352. namespace ControlItemsFuncs
  353. {
  354. void Direction2XY(
  355. LONG& rlValX,
  356. LONG& rlValY,
  357. LONG lDirection,
  358. const CONTROL_ITEM_DESC& crControlItemDesc
  359. );
  360. void XY2Direction(
  361. LONG lValX,
  362. LONG lValY,
  363. LONG& rlDirection,
  364. const CONTROL_ITEM_DESC& crControlItemDesc
  365. );
  366. NTSTATUS ReadModifiersFromReport(
  367. PMODIFIER_DESC_TABLE pModifierDescTable,
  368. ULONG& rulModifiers,
  369. PHIDP_PREPARSED_DATA pHidPPreparsedData,
  370. PCHAR pcReport,
  371. LONG lReportLength
  372. );
  373. NTSTATUS WriteModifiersToReport(
  374. PMODIFIER_DESC_TABLE pModifierDescTable,
  375. ULONG rulModifiers,
  376. PHIDP_PREPARSED_DATA pHidPPreparsedData,
  377. PCHAR pcReport,
  378. LONG lReportLength
  379. );
  380. };
  381. /******************************************************************************/
  382. /** @class CControlItem |
  383. /** Base class for containing information about a control or group of controls
  384. /** on a device
  385. /******************************************************************************/
  386. class CControlItem
  387. {
  388. public:
  389. /**********************************************************************
  390. **
  391. ** CControlItem::CControlItem
  392. **
  393. ** @cmember c'tor initialize with pointer to table describing item
  394. **
  395. ***********************************************************************/
  396. CControlItem() : m_ulFirstDwordMask(0), m_ulSecondDwordMask(0)
  397. {
  398. memset(&m_ItemState, 0, sizeof(CONTROL_ITEM_XFER));
  399. }
  400. /**********************************************************************
  401. **
  402. ** virtual CControlItem::~CControlItem
  403. **
  404. ** @cmember c'tor initialize with pointer to table describing item
  405. **
  406. ***********************************************************************/
  407. virtual ~CControlItem(){}
  408. /***********************************************************************
  409. **
  410. ** inline USHORT CControlItem::GetType() const
  411. **
  412. ** @cmember Returns the type of the item. See ControlItemConst namespace
  413. ** for constants representing the type
  414. ***********************************************************************/
  415. inline USHORT CControlItem::GetType() const
  416. {
  417. return m_cpControlItemDesc->usType;
  418. }
  419. /***********************************************************************
  420. **
  421. ** inline void CControlItem::GetItemState
  422. **
  423. ** @cmember Returns the item state in a CONTROL_ITEM_XFER packet
  424. **
  425. ***********************************************************************/
  426. inline void GetItemState
  427. (
  428. CONTROL_ITEM_XFER& rControlItemXfer // @parm [out] state of device
  429. ) const
  430. {
  431. rControlItemXfer = m_ItemState;
  432. }
  433. /************************************************************************
  434. **
  435. ** inline BOOLEAN CControlItem::SetItemState
  436. **
  437. ** @cmember Set the control items state from a CONTROL_ITEM_XFER.
  438. **
  439. ** @rdesc TRUE if successful,
  440. ** FALSE if CONTROL_ITEM_XFER is not intended for item.
  441. **
  442. *************************************************************************/
  443. inline BOOLEAN SetItemState
  444. (
  445. const CONTROL_ITEM_XFER& crControlItemXfer // @parm [in] const reference to CONTROL_ITEM_XFER
  446. )
  447. {
  448. if(m_ItemState.ulItemIndex != crControlItemXfer.ulItemIndex)
  449. {
  450. return FALSE;
  451. }
  452. //Copy the data
  453. m_ItemState.Axes.lValX &= m_ulFirstDwordMask;
  454. m_ItemState.Axes.lValX |= crControlItemXfer.Axes.lValX;
  455. m_ItemState.Axes.lValY &= m_ulSecondDwordMask;
  456. m_ItemState.Axes.lValY |= crControlItemXfer.Axes.lValY;
  457. m_ItemState.ulModifiers = crControlItemXfer.ulModifiers;
  458. return TRUE;
  459. }
  460. virtual void SetDefaultState()=0;
  461. virtual BOOLEAN IsDefaultState()
  462. {
  463. return FALSE;
  464. }
  465. /****************************************************************************
  466. **
  467. ** inline ULONG CControlItem::GetNumModifiers
  468. **
  469. ** @cmember Gets the number of modifiers available.
  470. **
  471. *****************************************************************************/
  472. inline ULONG GetNumModifiers() const
  473. {
  474. if (m_cpControlItemDesc->pModifierDescTable == NULL)
  475. {
  476. return 0;
  477. }
  478. return m_cpControlItemDesc->pModifierDescTable->ulModifierCount;
  479. }
  480. /****************************************************************************
  481. **
  482. ** inline ULONG CControlItem::GetNumShiftButtons
  483. **
  484. ** @cmember Gets the number of modifiers available.
  485. **
  486. *****************************************************************************/
  487. inline ULONG GetNumShiftButtons() const
  488. {
  489. if (m_cpControlItemDesc->pModifierDescTable == NULL)
  490. {
  491. return 0;
  492. }
  493. return m_cpControlItemDesc->pModifierDescTable->ulShiftButtonCount;
  494. }
  495. /****************************************************************************
  496. **
  497. ** inline ULONG CControlItem::GetShiftButtonUsage
  498. **
  499. ** @cmember Gets the usage (bit array index) of the specified shift button
  500. **
  501. *****************************************************************************/
  502. inline USHORT GetShiftButtonUsage
  503. (
  504. USHORT uShiftButtonIndex // @parm [in] Zero-based index of shift button
  505. ) const
  506. {
  507. if ((m_cpControlItemDesc->pModifierDescTable == NULL) || (uShiftButtonIndex >= m_cpControlItemDesc->pModifierDescTable->ulShiftButtonCount))
  508. {
  509. return 0;
  510. }
  511. return m_cpControlItemDesc->pModifierDescTable->pModifierArray[uShiftButtonIndex].Usage;
  512. }
  513. /*****************************************************************************
  514. **
  515. ** inline void CControlItem::GetModifiers(ULONG& rulModifiers)
  516. **
  517. ** @cmember Gets modifier bit array of item state.
  518. **
  519. ******************************************************************************/
  520. inline void GetModifiers
  521. (
  522. ULONG& rulModifiers // @parm [out] Bit Array showing state of modifiers
  523. ) const
  524. {
  525. rulModifiers = m_ItemState.ulModifiers;
  526. }
  527. /*****************************************************************************
  528. **
  529. ** inline void CControlItem::GetShiftButtons(ULONG& rulShiftButtons)
  530. **
  531. ** @cmember Gets Shift buttons from the modifier bit array of item state.
  532. **
  533. ******************************************************************************/
  534. inline void GetShiftButtons
  535. (
  536. ULONG& rulShiftButtons // @parm [out] Bit Array showing state of modifiers
  537. ) const
  538. {
  539. if (m_cpControlItemDesc->pModifierDescTable == NULL)
  540. {
  541. rulShiftButtons = 0;
  542. }
  543. else
  544. {
  545. ULONG ulMask = (1 << m_cpControlItemDesc->pModifierDescTable->ulShiftButtonCount)-1;
  546. rulShiftButtons = m_ItemState.ulModifiers & ulMask;
  547. }
  548. return;
  549. }
  550. /*****************************************************************************
  551. **
  552. ** inline void CControlItem::SetModifiers(ULONG ulModifiers)
  553. **
  554. ** @cmember Set state modifier flags from bit array
  555. **
  556. ******************************************************************************/
  557. inline void SetModifiers
  558. (
  559. ULONG ulModifiers // @parm [in] Bit array showing state of modifiers
  560. )
  561. {
  562. m_ItemState.ulModifiers = ulModifiers;
  563. }
  564. /*****************************************************************************
  565. **
  566. ** inline void CControlItem::SetShiftButtons(ULONG ulShiftButtons)
  567. **
  568. ** @cmember Gets Shift buttons from the modifier bit array of item state.
  569. **
  570. ******************************************************************************/
  571. inline void SetShiftButtons
  572. (
  573. ULONG ulShiftButtons // @parm [out] Bit Array showing state of modifiers
  574. )
  575. {
  576. if (m_cpControlItemDesc->pModifierDescTable != NULL)
  577. {
  578. ULONG ulMask = (1 << m_cpControlItemDesc->pModifierDescTable->ulShiftButtonCount)-1;
  579. m_ItemState.ulModifiers = (ulShiftButtons & ulMask) | (m_ItemState.ulModifiers & ~ulMask);
  580. }
  581. return;
  582. }
  583. //
  584. // Read\Write to Report
  585. //
  586. virtual NTSTATUS ReadFromReport(
  587. PHIDP_PREPARSED_DATA,
  588. PCHAR,
  589. LONG
  590. )
  591. {
  592. //
  593. // Should always be overridden
  594. //
  595. ASSERT(FALSE);
  596. return E_FAIL;
  597. }
  598. virtual NTSTATUS WriteToReport(
  599. PHIDP_PREPARSED_DATA,
  600. PCHAR,
  601. LONG
  602. ) const
  603. {
  604. //
  605. // Should always be overridden
  606. //
  607. ASSERT(FALSE);
  608. return E_FAIL;
  609. }
  610. virtual void SetStateOverlayMode(BOOLEAN){}
  611. protected:
  612. //@cmember Pointer to entry in table describing item
  613. const CONTROL_ITEM_DESC *m_cpControlItemDesc;
  614. //
  615. // State of item
  616. //
  617. //@cmember State of item
  618. CONTROL_ITEM_XFER m_ItemState;
  619. //@cmember Oring mask for overlay flag
  620. ULONG m_ulFirstDwordMask;
  621. ULONG m_ulSecondDwordMask;
  622. private:
  623. //
  624. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  625. // anyone tries to use it.
  626. //
  627. CControlItem& operator =(const CControlItem& rControlItem);
  628. };
  629. /******************************************************************************/
  630. /** @class CAxesItem |
  631. /** Derived from CControlItem represents Axes of device
  632. ******************************************************************************/
  633. class CAxesItem : public virtual CControlItem
  634. {
  635. public:
  636. /***********************************************************************************
  637. **
  638. ** CAxesItem::CAxesItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  639. **
  640. ** @cmember c'tor initializes does nothing
  641. **
  642. *************************************************************************************/
  643. CAxesItem
  644. (
  645. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  646. )
  647. {
  648. m_cpControlItemDesc = cpControlItemDesc;
  649. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  650. SetDefaultState();
  651. }
  652. virtual void SetDefaultState()
  653. {
  654. m_ItemState.Axes.lValX = m_cpControlItemDesc->Axes.pRangeTable->lCenterX;
  655. m_ItemState.Axes.lValY= m_cpControlItemDesc->Axes.pRangeTable->lCenterY ;
  656. m_ItemState.ulModifiers = 0;
  657. }
  658. virtual BOOLEAN IsDefaultState()
  659. {
  660. if(
  661. m_ItemState.Axes.lValX == m_cpControlItemDesc->Axes.pRangeTable->lCenterX &&
  662. m_ItemState.Axes.lValY == m_cpControlItemDesc->Axes.pRangeTable->lCenterY
  663. ){
  664. return TRUE;
  665. }
  666. return FALSE;
  667. }
  668. /***********************************************************************************
  669. **
  670. ** inline void CAxesItem::SetXY(ULONG lValX, ULONG lValY)
  671. **
  672. ** @cmember Sets the X and Y states of the axes
  673. **
  674. *************************************************************************************/
  675. inline void SetXY
  676. (
  677. LONG lValX, // @parm [in] Position of X axis
  678. LONG lValY // @parm [in] Position of Y axis
  679. )
  680. {
  681. m_ItemState.Axes.lValX = lValX;
  682. m_ItemState.Axes.lValY = lValY;
  683. }
  684. /***********************************************************************************
  685. **
  686. ** inline void CAxesItem::GetXY(ULONG& rlValX, ULONG& rlValY) const
  687. **
  688. ** @cmember Get the X and Y states of the device
  689. **
  690. *************************************************************************************/
  691. inline void GetXY
  692. (
  693. LONG& rlValX, // @parm [out] X value of axis
  694. LONG& rlValY // @parm [out] Y value of axis
  695. ) const
  696. {
  697. rlValX = m_ItemState.Axes.lValX;
  698. rlValY = m_ItemState.Axes.lValY;
  699. }
  700. /***********************************************************************************
  701. **
  702. ** inline void CAxesItem::GetXYRange(LONG& rlMinX, LONG& rlMaxX, LONG& rlMinY, LONG& rlMaxY) const
  703. **
  704. ** @cmember Get the minimum and maximum values for X and Y
  705. **
  706. *************************************************************************************/
  707. inline void GetXYRange
  708. (
  709. LONG& rlMinX, // @parm [out] Minimum value X can attain
  710. LONG& rlMaxX, // @parm [out] Maximum value X can attain
  711. LONG& rlMinY, // @parm [out] Minimum value Y can attain
  712. LONG& rlMaxY // @parm [out] Maximum value Y can attain
  713. ) const
  714. {
  715. rlMinX = m_cpControlItemDesc->Axes.pRangeTable->lMinX;
  716. rlMaxX = m_cpControlItemDesc->Axes.pRangeTable->lMaxX;
  717. rlMinY = m_cpControlItemDesc->Axes.pRangeTable->lMinY;
  718. rlMaxY = m_cpControlItemDesc->Axes.pRangeTable->lMaxY;
  719. }
  720. //
  721. // Read\Write to Report
  722. //
  723. NTSTATUS ReadFromReport(
  724. PHIDP_PREPARSED_DATA pHidPreparsedData,
  725. PCHAR pcReport,
  726. LONG lReportLength
  727. );
  728. NTSTATUS WriteToReport(
  729. PHIDP_PREPARSED_DATA pHidPreparsedData,
  730. PCHAR pcReport,
  731. LONG lReportLength
  732. ) const;
  733. private:
  734. //
  735. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  736. // anyone tries to use it.
  737. //
  738. CAxesItem& operator =(const CAxesItem& rAxesItem);
  739. };
  740. /******************************************************************************/
  741. /** @class CDPADItem |
  742. /** Derived from CControlItem represents DPAD of device
  743. ******************************************************************************/
  744. class CDPADItem : public virtual CControlItem
  745. {
  746. public:
  747. /***********************************************************************************
  748. **
  749. ** CDPADItem::CDPADItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  750. **
  751. ** @cmember c'tor initializes DPAD to center
  752. **
  753. *************************************************************************************/
  754. CDPADItem
  755. (
  756. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  757. )
  758. {
  759. m_cpControlItemDesc = cpControlItemDesc;
  760. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  761. SetDefaultState();
  762. }
  763. virtual void SetDefaultState()
  764. {
  765. m_ItemState.DPAD.lValX = m_cpControlItemDesc->DPAD.pRangeTable->lCenterX;
  766. m_ItemState.DPAD.lValY= m_cpControlItemDesc->DPAD.pRangeTable->lCenterY;
  767. m_ItemState.ulModifiers = 0;
  768. }
  769. virtual BOOLEAN IsDefaultState()
  770. {
  771. LONG lDirection;
  772. ControlItemsFuncs::XY2Direction
  773. (
  774. m_ItemState.DPAD.lValX,
  775. m_ItemState.DPAD.lValY,
  776. lDirection,
  777. *m_cpControlItemDesc
  778. );
  779. if(ControlItemConst::lCenter == lDirection)
  780. {
  781. return TRUE;
  782. }
  783. return FALSE;
  784. }
  785. /***********************************************************************************
  786. **
  787. ** inline void CDPADItem::SetDirection(LONG lDirection)
  788. **
  789. ** @cmember Sets Direction of Item
  790. **
  791. *************************************************************************************/
  792. inline void SetDirection
  793. (
  794. LONG lDirection // @parm [in] Direction to set
  795. )
  796. {
  797. ControlItemsFuncs::Direction2XY
  798. (
  799. m_ItemState.DPAD.lValX,
  800. m_ItemState.DPAD.lValY,
  801. lDirection,
  802. *m_cpControlItemDesc
  803. );
  804. }
  805. /***********************************************************************************
  806. **
  807. ** inline void CDPADItem::GetDirection(LONG& rlDirection)
  808. **
  809. ** @cmember Get Direction of DPAD item
  810. **
  811. *************************************************************************************/
  812. inline void GetDirection
  813. (
  814. LONG& rlDirection // @parm [out] Direction of DPAD item
  815. ) const
  816. {
  817. ControlItemsFuncs::XY2Direction
  818. (
  819. m_ItemState.DPAD.lValX,
  820. m_ItemState.DPAD.lValY,
  821. rlDirection,
  822. *m_cpControlItemDesc
  823. );
  824. }
  825. //
  826. // Read\Write to Report
  827. //
  828. NTSTATUS ReadFromReport(
  829. PHIDP_PREPARSED_DATA pHidPreparsedData,
  830. PCHAR pcReport,
  831. LONG lReportLength
  832. );
  833. NTSTATUS WriteToReport(
  834. PHIDP_PREPARSED_DATA pHidPreparsedData,
  835. PCHAR pcReport,
  836. LONG lReportLength
  837. ) const;
  838. private:
  839. //
  840. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  841. // anyone tries to use it.
  842. //
  843. CDPADItem& operator =(const CDPADItem& rDPADItem);
  844. };
  845. /******************************************************************************/
  846. /** @class CPropDPADItem |
  847. /** Derived from CControlItem represents DPAD of device
  848. ******************************************************************************/
  849. class CPropDPADItem : public virtual CControlItem
  850. {
  851. public:
  852. /***********************************************************************************
  853. **
  854. ** CDPADItem::CPropDPADItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  855. **
  856. ** @cmember c'tor initializes PropDPAD to center
  857. **
  858. *************************************************************************************/
  859. CPropDPADItem
  860. (
  861. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  862. )
  863. {
  864. m_cpControlItemDesc = cpControlItemDesc;
  865. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  866. //Get PropDPAD switch Info
  867. InitDigitalModeInfo();
  868. SetDefaultState();
  869. }
  870. virtual void SetDefaultState()
  871. {
  872. m_ItemState.PropDPAD.lValX = m_cpControlItemDesc->PropDPAD.pRangeTable->lCenterX;
  873. m_ItemState.PropDPAD.lValY= m_cpControlItemDesc->PropDPAD.pRangeTable->lCenterY ;
  874. m_ItemState.ulModifiers = 0;
  875. }
  876. virtual BOOLEAN IsDefaultState()
  877. {
  878. if(IsDigitalMode())
  879. {
  880. LONG lDirection;
  881. ControlItemsFuncs::XY2Direction
  882. (
  883. m_ItemState.PropDPAD.lValX,
  884. m_ItemState.PropDPAD.lValY,
  885. lDirection,
  886. *m_cpControlItemDesc
  887. );
  888. if(ControlItemConst::lCenter == lDirection)
  889. {
  890. return TRUE;
  891. }
  892. }
  893. else
  894. {
  895. if(
  896. m_ItemState.PropDPAD.lValX == m_cpControlItemDesc->PropDPAD.pRangeTable->lCenterX &&
  897. m_ItemState.PropDPAD.lValY == m_cpControlItemDesc->PropDPAD.pRangeTable->lCenterY
  898. ) return TRUE;
  899. }
  900. return FALSE;
  901. }
  902. /***********************************************************************************
  903. **
  904. ** inline void CPropDPADItem::SetDigitalMode()
  905. **
  906. ** @cmember Sets the packet to indicate digital mode
  907. **
  908. *************************************************************************************/
  909. inline void CPropDPADItem::SetDigitalMode()
  910. {
  911. m_ItemState.ulModifiers |= (1 << m_ucDigitalModifierBit);
  912. }
  913. /***********************************************************************************
  914. **
  915. ** inline void CPropDPADItem::SetProportionalMode()
  916. **
  917. ** @cmember Sets the packet to indicate proportional mode
  918. **
  919. *************************************************************************************/
  920. inline void CPropDPADItem::SetProportionalMode()
  921. {
  922. m_ItemState.ulModifiers &= ~(1 << m_ucDigitalModifierBit);
  923. }
  924. /***********************************************************************************
  925. **
  926. ** inline BOOLEAN CPropDPADItem::IsDigitalMode()
  927. **
  928. ** @cmember Determines if th internal state is digital or proportional
  929. ** @rdesc TRUE if in digital mode, false if in proportional mode
  930. **
  931. *************************************************************************************/
  932. inline BOOLEAN CPropDPADItem::IsDigitalMode()
  933. {
  934. return (m_ItemState.ulModifiers & (1 << m_ucDigitalModifierBit)) ? TRUE : FALSE;
  935. }
  936. /***********************************************************************************
  937. **
  938. ** inline void CPropDPADItem::SetXY(ULONG lValX, ULONG lValY)
  939. **
  940. ** @cmember Sets the X and Y states of the axes
  941. **
  942. *************************************************************************************/
  943. inline void SetXY
  944. (
  945. LONG lValX, // @parm [in] Position of X axis
  946. LONG lValY // @parm [in] Position of Y axis
  947. )
  948. {
  949. m_ItemState.PropDPAD.lValX = lValX;
  950. m_ItemState.PropDPAD.lValY = lValY;
  951. }
  952. /***********************************************************************************
  953. **
  954. ** inline void CPropDPADItem::GetXY(ULONG& rlValX, ULONG& rlValY)
  955. **
  956. ** @cmember Get the X and Y states of the device
  957. **
  958. *************************************************************************************/
  959. inline void GetXY
  960. (
  961. LONG& rlValX, // @parm [out] X value of axis
  962. LONG& rlValY // @parm [out] Y value of axis
  963. ) const
  964. {
  965. rlValX = m_ItemState.PropDPAD.lValX;
  966. rlValY = m_ItemState.PropDPAD.lValY;
  967. }
  968. /***********************************************************************************
  969. **
  970. ** inline void CPropDPADItem::GetXYRange(LONG& rlMinX, LONG& rlMaxX, LONG& rlMinY, LONG& rlMaxY) const
  971. **
  972. ** @cmember Get the minimum and maximum values for X and Y
  973. **
  974. *************************************************************************************/
  975. inline void GetXYRange
  976. (
  977. LONG& rlMinX, // @parm [out] Minimum value X can attain
  978. LONG& rlMaxX, // @parm [out] Maximum value X can attain
  979. LONG& rlMinY, // @parm [out] Minimum value Y can attain
  980. LONG& rlMaxY // @parm [out] Maximum value Y can attain
  981. ) const
  982. {
  983. rlMinX = m_cpControlItemDesc->PropDPAD.pRangeTable->lMinX;
  984. rlMaxX = m_cpControlItemDesc->PropDPAD.pRangeTable->lMaxX;
  985. rlMinY = m_cpControlItemDesc->PropDPAD.pRangeTable->lMinY;
  986. rlMaxY = m_cpControlItemDesc->PropDPAD.pRangeTable->lMaxY;
  987. }
  988. /***********************************************************************************
  989. **
  990. ** inline void CPropDPADItem::SetDirection(LONG lDirection)
  991. **
  992. ** @cmember Sets Direction of Item
  993. **
  994. *************************************************************************************/
  995. inline void SetDirection
  996. (
  997. LONG lDirection // @parm [in] Direction to set
  998. )
  999. {
  1000. ControlItemsFuncs::Direction2XY
  1001. (
  1002. m_ItemState.PropDPAD.lValX,
  1003. m_ItemState.PropDPAD.lValY,
  1004. lDirection,
  1005. *m_cpControlItemDesc
  1006. );
  1007. }
  1008. /***********************************************************************************
  1009. **
  1010. ** inline void CPropDPADItem::GetDirection(LONG& rlDirection)
  1011. **
  1012. ** @cmember Get Direction of PropDPAD item
  1013. **
  1014. *************************************************************************************/
  1015. inline void GetDirection
  1016. (
  1017. LONG& rlDirection // @parm [out] Direction of PropDPAD item
  1018. ) const
  1019. {
  1020. ControlItemsFuncs::XY2Direction
  1021. (
  1022. m_ItemState.PropDPAD.lValX,
  1023. m_ItemState.PropDPAD.lValY,
  1024. rlDirection,
  1025. *m_cpControlItemDesc
  1026. );
  1027. }
  1028. //
  1029. // Read\Write to Report
  1030. //
  1031. NTSTATUS ReadFromReport(
  1032. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1033. PCHAR pcReport,
  1034. LONG lReportLength
  1035. );
  1036. NTSTATUS WriteToReport(
  1037. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1038. PCHAR pcReport,
  1039. LONG lReportLength
  1040. ) const;
  1041. // Init Digital Mode Info
  1042. void InitDigitalModeInfo();
  1043. BOOLEAN GetModeSwitchFeaturePacket(BOOLEAN fDigital, UCHAR rguReport[2], PHIDP_PREPARSED_DATA pHidPreparsedData);
  1044. private:
  1045. //
  1046. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1047. // anyone tries to use it.
  1048. //
  1049. CPropDPADItem& operator =(const CPropDPADItem& rPropDPADItem);
  1050. UCHAR m_ucDigitalModifierBit; //Bit in ulModifiers that identifies the State of the switch
  1051. protected:
  1052. BOOLEAN m_fProgrammable; //Means that SetFeature/GetFeature can be used
  1053. UCHAR m_ucProgramModifierIndex; //Index in Modifier table that describes feature for setting mode
  1054. };
  1055. /******************************************************************************/
  1056. /** @class CButtonsItem |
  1057. /** Derived from CControlItem represents group of buttons on device
  1058. ******************************************************************************/
  1059. class CButtonsItem : public virtual CControlItem
  1060. {
  1061. public:
  1062. /***********************************************************************************
  1063. **
  1064. ** CButtonsItem::CButtonsItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  1065. **
  1066. ** @cmember c'tor initializes all buttons up
  1067. **
  1068. *************************************************************************************/
  1069. CButtonsItem
  1070. (
  1071. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1072. )
  1073. {
  1074. m_cpControlItemDesc = cpControlItemDesc;
  1075. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  1076. SetDefaultState();
  1077. }
  1078. virtual void SetDefaultState()
  1079. {
  1080. m_ItemState.Button.usButtonNumber = 0;
  1081. m_ItemState.Button.ulButtonBitArray = 0x00000000;
  1082. m_ItemState.ulModifiers = 0;
  1083. }
  1084. virtual BOOLEAN IsDefaultState()
  1085. {
  1086. if(!m_ItemState.Button.usButtonNumber && !m_ItemState.Button.ulButtonBitArray)
  1087. {
  1088. return TRUE;
  1089. }
  1090. return FALSE;
  1091. }
  1092. /***********************************************************************************
  1093. **
  1094. ** inline USHORT CButtonsItem::GetButtonMin()
  1095. **
  1096. ** @cmember Gets the minimum button number
  1097. **
  1098. ** @rdesc Number of the minimum button
  1099. **
  1100. *************************************************************************************/
  1101. inline USHORT GetButtonMin() const
  1102. {
  1103. return static_cast<USHORT>(m_cpControlItemDesc->Buttons.UsageMin);
  1104. }
  1105. /***********************************************************************************
  1106. **
  1107. ** inline USHORT CButtonsItem::GetButtonMax()
  1108. **
  1109. ** @cmember Gets the maximum button number
  1110. **
  1111. ** @rdesc Number of the maximum button
  1112. **
  1113. *************************************************************************************/
  1114. inline USHORT GetButtonMax() const
  1115. {
  1116. return static_cast<USHORT>(m_cpControlItemDesc->Buttons.UsageMax);
  1117. }
  1118. /***********************************************************************************
  1119. **
  1120. ** inline void CButtonsItem::GetButtons(USHORT usButtonNum, ULONG ulButtonBitArray)
  1121. **
  1122. ** @cmember Returns the Button Number and BitArray - these are really independent
  1123. ** a client may use either field. As an Action trigger the button number
  1124. ** is used, as part of an Action Event the bit-array is used
  1125. ** Reading from a packet sets the bitarray and the button number as the lowest
  1126. ** button pressed. The Bitarray is biased by the minimum usage.
  1127. ** Writing to a report uses the BitArray and ignores the button number.
  1128. **
  1129. *************************************************************************************/
  1130. inline void GetButtons
  1131. (
  1132. USHORT& rusButtonNumber, // @parm [out] Button number that is down
  1133. ULONG& rulButtonBitArray // @parm [out] BitArray of Buttons that are down
  1134. ) const
  1135. {
  1136. rusButtonNumber = m_ItemState.Button.usButtonNumber;
  1137. rulButtonBitArray = m_ItemState.Button.ulButtonBitArray;
  1138. }
  1139. inline BOOLEAN IsButtonDown(USHORT usButtonNumber) const
  1140. {
  1141. //
  1142. // Range check DEBUG assert and return FALSE
  1143. //
  1144. if(
  1145. (usButtonNumber < m_cpControlItemDesc->Buttons.UsageMin) ||
  1146. (usButtonNumber > m_cpControlItemDesc->Buttons.UsageMax)
  1147. )
  1148. {
  1149. ASSERT(FALSE);
  1150. return FALSE;
  1151. }
  1152. //
  1153. // Return state
  1154. //
  1155. USHORT usBitPos = usButtonNumber - m_cpControlItemDesc->Buttons.UsageMin;
  1156. return (m_ItemState.Button.ulButtonBitArray & (1 << usBitPos)) ? TRUE : FALSE;
  1157. }
  1158. inline NTSTATUS SetButton(USHORT usButtonNumber)
  1159. {
  1160. //
  1161. // Range check DEBUG assert and return FALSE
  1162. //
  1163. if(
  1164. (usButtonNumber < m_cpControlItemDesc->Buttons.UsageMin) ||
  1165. (usButtonNumber > m_cpControlItemDesc->Buttons.UsageMax)
  1166. )
  1167. {
  1168. return E_INVALIDARG;
  1169. }
  1170. USHORT usBitPos = usButtonNumber - m_cpControlItemDesc->Buttons.UsageMin;
  1171. m_ItemState.Button.ulButtonBitArray |= (1 << usBitPos);
  1172. m_ItemState.Button.usButtonNumber = usButtonNumber;
  1173. return S_OK;
  1174. }
  1175. inline NTSTATUS ClearButton(USHORT usButtonNumber)
  1176. {
  1177. //
  1178. // Range check DEBUG assert and return FALSE
  1179. //
  1180. if(
  1181. (usButtonNumber < m_cpControlItemDesc->Buttons.UsageMin) ||
  1182. (usButtonNumber > m_cpControlItemDesc->Buttons.UsageMax)
  1183. )
  1184. {
  1185. return E_INVALIDARG;
  1186. }
  1187. USHORT usBitPos = usButtonNumber - m_cpControlItemDesc->Buttons.UsageMin;
  1188. m_ItemState.Button.ulButtonBitArray &= ~(1 << usBitPos);
  1189. return S_OK;
  1190. }
  1191. /***********************************************************************************
  1192. **
  1193. ** inline void CButtonsItem::SetButtons(USHORT usButtonNum, ULONG ulButtonBitArray)
  1194. **
  1195. ** @cmember Set the Button Number and BitArray - these are really independent
  1196. ** a client may use either field. As an Action trigger the button number
  1197. ** is used, as part of an Action Event the bit-array is used
  1198. ** Reading from a report sets the bitarray and the button number as the lowest
  1199. ** button pressed. The Bitarray is biased by the minimum usage.
  1200. ** Writing to a report uses the BitArray and ignores the button number.
  1201. **
  1202. *************************************************************************************/
  1203. inline void SetButtons
  1204. (
  1205. USHORT usButtonNumber, // @parm [in] Button number that is down
  1206. ULONG ulButtonBitArray // @parm [in] BitArray of Buttons that are down
  1207. )
  1208. {
  1209. m_ItemState.Button.usButtonNumber = usButtonNumber;
  1210. m_ItemState.Button.ulButtonBitArray = ulButtonBitArray;
  1211. }
  1212. //
  1213. // Read\Write to Report
  1214. //
  1215. NTSTATUS ReadFromReport(
  1216. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1217. PCHAR pcReport,
  1218. LONG lReportLength
  1219. );
  1220. NTSTATUS WriteToReport(
  1221. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1222. PCHAR pcReport,
  1223. LONG lReportLength
  1224. ) const;
  1225. virtual void SetStateOverlayMode(BOOLEAN fEnable)
  1226. {
  1227. if(fEnable)
  1228. {
  1229. m_ulFirstDwordMask = 0xFFFF0000;
  1230. m_ulSecondDwordMask = 0x0000FFFF;
  1231. }
  1232. else
  1233. {
  1234. m_ulFirstDwordMask = 0;
  1235. m_ulSecondDwordMask = 0;
  1236. }
  1237. return;
  1238. }
  1239. private:
  1240. //
  1241. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1242. // anyone tries to use it.
  1243. //
  1244. CButtonsItem& operator =(const CButtonsItem& rButtonsItem);
  1245. };
  1246. /******************************************************************************/
  1247. /** @class CGenericItem |
  1248. /** Derived from CControlItem represents generic control on device -
  1249. /** base class for POV, Throttle, Wheel, Pedals, etc.
  1250. ******************************************************************************/
  1251. class CGenericItem : public virtual CControlItem
  1252. {
  1253. public:
  1254. /***********************************************************************************
  1255. **
  1256. ** CGenericItem::CGenericItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  1257. **
  1258. ** @cmember default c'tor
  1259. **
  1260. *************************************************************************************/
  1261. CGenericItem
  1262. (
  1263. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1264. )
  1265. {
  1266. m_cpControlItemDesc = cpControlItemDesc;
  1267. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  1268. SetDefaultState();
  1269. }
  1270. virtual void SetDefaultState()
  1271. {
  1272. m_ItemState.Generic.lVal = m_cpControlItemDesc->Generic.lMin;
  1273. m_ItemState.ulModifiers = 0;
  1274. }
  1275. virtual BOOLEAN IsDefaultState()
  1276. {
  1277. if(m_ItemState.Generic.lVal == m_cpControlItemDesc->Generic.lMin)
  1278. {
  1279. return TRUE;
  1280. }
  1281. return FALSE;
  1282. }
  1283. /***********************************************************************************
  1284. **
  1285. ** inline void CGenericItem::GetValue(LONG& rlVal)
  1286. **
  1287. ** @cmember Gets value of item
  1288. **
  1289. *************************************************************************************/
  1290. inline void GetValue
  1291. (
  1292. LONG& rlVal // @parm [out] Value of control item
  1293. ) const
  1294. {
  1295. rlVal = m_ItemState.Generic.lVal;
  1296. }
  1297. /***********************************************************************************
  1298. **
  1299. ** inline void CGenericItem::SetValue(LONG& rlVal)
  1300. **
  1301. ** @cmember Sets value of item
  1302. **
  1303. *************************************************************************************/
  1304. inline void SetValue
  1305. (
  1306. LONG lVal // @parm [in] Value of control item
  1307. )
  1308. {
  1309. m_ItemState.Generic.lVal = lVal;
  1310. }
  1311. /***********************************************************************************
  1312. **
  1313. ** inline void CPropDPADItem::GetRange(LONG& rlMin, LONG& rlMax) const
  1314. **
  1315. ** @cmember Get the minimum and maximum values
  1316. **
  1317. *************************************************************************************/
  1318. inline void GetRange
  1319. (
  1320. LONG& rlMin, // @parm [out] Minimum value
  1321. LONG& rlMax // @parm [out] Maximum value
  1322. ) const
  1323. {
  1324. rlMin = m_cpControlItemDesc->Generic.lMin;
  1325. rlMax = m_cpControlItemDesc->Generic.lMax;
  1326. }
  1327. //
  1328. // Read\Write to Report
  1329. //
  1330. NTSTATUS ReadFromReport(
  1331. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1332. PCHAR pcReport,
  1333. LONG lReportLength
  1334. );
  1335. NTSTATUS WriteToReport(
  1336. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1337. PCHAR pcReport,
  1338. LONG lReportLength
  1339. ) const;
  1340. private:
  1341. //
  1342. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1343. // anyone tries to use it.
  1344. //
  1345. CGenericItem& operator =(const CGenericItem& rGenericItem);
  1346. };
  1347. /******************************************************************************/
  1348. /** @class CPOVItem |
  1349. /** Derived from CGenericItem represents POV control on device
  1350. ******************************************************************************/
  1351. class CPOVItem : public CGenericItem
  1352. {
  1353. public:
  1354. CPOVItem
  1355. (
  1356. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1357. ) : CGenericItem(cpControlItemDesc){}
  1358. virtual void SetDefaultState()
  1359. {
  1360. m_ItemState.Generic.lVal = -1;
  1361. }
  1362. virtual BOOLEAN IsDefaultState()
  1363. {
  1364. //POV is centered if not within range, which is the default
  1365. LONG lMin, lMax;
  1366. GetRange(lMin, lMax);
  1367. if(m_ItemState.Generic.lVal > lMax || m_ItemState.Generic.lVal < lMin)
  1368. {
  1369. return TRUE;
  1370. }
  1371. return FALSE;
  1372. }
  1373. private:
  1374. //
  1375. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1376. // anyone tries to use it.
  1377. //
  1378. CPOVItem& operator =(const CPOVItem& rPOVItem);
  1379. };
  1380. /******************************************************************************/
  1381. /** @class CThrottleItem |
  1382. /** Derived from CGenericItem represents Throttle control on device
  1383. ******************************************************************************/
  1384. class CThrottleItem : public CGenericItem
  1385. {
  1386. public:
  1387. CThrottleItem
  1388. (
  1389. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1390. ) : CGenericItem(cpControlItemDesc){}
  1391. private:
  1392. //
  1393. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1394. // anyone tries to use it.
  1395. //
  1396. CThrottleItem& operator =(const CThrottleItem& rThrottleItem);
  1397. };
  1398. /******************************************************************************/
  1399. /** @class CRudderItem |
  1400. /** Derived from CGenericItem represents rudder control on device
  1401. ******************************************************************************/
  1402. class CRudderItem : public CGenericItem
  1403. {
  1404. public:
  1405. CRudderItem
  1406. (
  1407. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1408. ) : CGenericItem(cpControlItemDesc){}
  1409. private:
  1410. //
  1411. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1412. // anyone tries to use it.
  1413. //
  1414. CRudderItem& operator =(const CRudderItem& rRudderItem);
  1415. };
  1416. /******************************************************************************/
  1417. /** @class CWheelItem |
  1418. /** Derived from CGenericItem represents Wheel control on device
  1419. ******************************************************************************/
  1420. class CWheelItem : public CGenericItem
  1421. {
  1422. public:
  1423. CWheelItem
  1424. (
  1425. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1426. ) : CGenericItem(cpControlItemDesc)
  1427. {
  1428. SetDefaultState();
  1429. }
  1430. virtual void SetDefaultState()
  1431. {
  1432. LONG lCenter = (m_cpControlItemDesc->Generic.lMin + m_cpControlItemDesc->Generic.lMax)/2;
  1433. m_ItemState.Generic.lVal = lCenter;
  1434. m_ItemState.ulModifiers = 0;
  1435. }
  1436. virtual BOOLEAN IsDefaultState()
  1437. {
  1438. LONG lCenter = (m_cpControlItemDesc->Generic.lMin + m_cpControlItemDesc->Generic.lMax)/2;
  1439. if(m_ItemState.Generic.lVal == lCenter)
  1440. {
  1441. return TRUE;
  1442. }
  1443. return FALSE;
  1444. }
  1445. private:
  1446. //
  1447. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1448. // anyone tries to use it.
  1449. //
  1450. CWheelItem& operator =(const CWheelItem& rWheelItem);
  1451. };
  1452. /******************************************************************************/
  1453. /** @class CPedalItem |
  1454. /** Derived from CGenericItem represents Pedal control on device
  1455. ******************************************************************************/
  1456. class CPedalItem : public CGenericItem
  1457. {
  1458. public:
  1459. CPedalItem
  1460. (
  1461. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1462. ) : CGenericItem(cpControlItemDesc), m_ucPedalsPresentModifierBit(0xFF)
  1463. {
  1464. //Setup m_ucPedalsPresentModifierBit
  1465. InitPedalPresentInfo();
  1466. SetDefaultState();
  1467. }
  1468. virtual void SetDefaultState()
  1469. {
  1470. if (IsYAxis())
  1471. {
  1472. m_ItemState.Generic.lVal = m_cpControlItemDesc->Generic.lMax;
  1473. }
  1474. else
  1475. {
  1476. m_ItemState.Generic.lVal = (m_cpControlItemDesc->Generic.lMax + m_cpControlItemDesc->Generic.lMin)/2;
  1477. }
  1478. m_ItemState.ulModifiers = 1 << m_ucPedalsPresentModifierBit;
  1479. }
  1480. virtual BOOLEAN IsDefaultState()
  1481. {
  1482. long int lDefault;
  1483. if (IsYAxis())
  1484. {
  1485. lDefault = m_cpControlItemDesc->Generic.lMax;
  1486. }
  1487. else
  1488. {
  1489. lDefault = (m_cpControlItemDesc->Generic.lMax + m_cpControlItemDesc->Generic.lMin)/2;
  1490. }
  1491. if(m_ItemState.Generic.lVal == lDefault)
  1492. {
  1493. return TRUE;
  1494. }
  1495. else
  1496. {
  1497. return FALSE;
  1498. }
  1499. }
  1500. void InitPedalPresentInfo();
  1501. inline BOOLEAN ArePedalsRemovable()
  1502. {
  1503. return (0xFF == m_ucPedalsPresentModifierBit) ? FALSE : TRUE;
  1504. }
  1505. inline BOOLEAN ArePedalsPresent()
  1506. {
  1507. return (m_ItemState.ulModifiers & (1 << m_ucPedalsPresentModifierBit)) ? TRUE : FALSE;
  1508. }
  1509. inline BOOLEAN IsYAxis()
  1510. {
  1511. return (HID_USAGE_GENERIC_Y == m_cpControlItemDesc->Pedal.Usage) ? TRUE : FALSE;
  1512. }
  1513. inline BOOLEAN IsRZAxis()
  1514. {
  1515. return (HID_USAGE_GENERIC_RZ == m_cpControlItemDesc->Pedal.Usage) ? TRUE : FALSE;
  1516. }
  1517. private:
  1518. //
  1519. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1520. // anyone tries to use it.
  1521. //
  1522. CPedalItem& operator =(const CPedalItem& rPedalItem);
  1523. UCHAR m_ucPedalsPresentModifierBit;
  1524. };
  1525. /******************************************************************************/
  1526. /** @class CZoneIndicatorItem |
  1527. /** A zone indicator is a binary hid usage that indicates that an axis
  1528. /** on the hardware has moved into a particular zone.
  1529. ******************************************************************************/
  1530. class CZoneIndicatorItem : public virtual CControlItem
  1531. {
  1532. public:
  1533. /***********************************************************************************
  1534. **
  1535. ** CZoneIndicatorItem::CZoneIndicatorItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  1536. **
  1537. ** @cmember c'tor initializes all buttons up
  1538. **
  1539. *************************************************************************************/
  1540. CZoneIndicatorItem
  1541. (
  1542. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1543. )
  1544. {
  1545. m_cpControlItemDesc = cpControlItemDesc;
  1546. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  1547. SetDefaultState();
  1548. }
  1549. virtual void SetDefaultState()
  1550. {
  1551. m_ItemState.ZoneIndicators.ulZoneIndicatorBits = 0x00000000;
  1552. m_ItemState.ulModifiers = 0;
  1553. }
  1554. virtual BOOLEAN IsDefaultState()
  1555. {
  1556. if(!m_ItemState.ZoneIndicators.ulZoneIndicatorBits)
  1557. {
  1558. return TRUE;
  1559. }
  1560. return FALSE;
  1561. }
  1562. /***********************************************************************************
  1563. **
  1564. ** inline BOOLEAN CZoneIndicatorItem::HasXIndicator() const
  1565. **
  1566. ** @cmember If this zone indicator group has X returns true, otherwise false
  1567. **
  1568. *************************************************************************************/
  1569. inline BOOLEAN HasXIndicator() const
  1570. {
  1571. if( CZoneIndicatorItem::X_ZONE & m_cpControlItemDesc->ZoneIndicators.ulAxesBitField)
  1572. {
  1573. return TRUE;
  1574. }
  1575. else
  1576. {
  1577. return FALSE;
  1578. }
  1579. }
  1580. /***********************************************************************************
  1581. **
  1582. ** inline BOOLEAN CZoneIndicatorItem::HasYIndicator() const
  1583. **
  1584. ** @cmember If this zone indicator group has Y returns true, otherwise false
  1585. **
  1586. *************************************************************************************/
  1587. inline BOOLEAN HasYIndicator() const
  1588. {
  1589. if( CZoneIndicatorItem::Y_ZONE & m_cpControlItemDesc->ZoneIndicators.ulAxesBitField)
  1590. {
  1591. return TRUE;
  1592. }
  1593. else
  1594. {
  1595. return FALSE;
  1596. }
  1597. }
  1598. /***********************************************************************************
  1599. **
  1600. ** inline BOOLEAN CZoneIndicatorItem::HasZIndicator() const
  1601. **
  1602. ** @cmember If this zone indicator group has Z returns true, otherwise false
  1603. **
  1604. *************************************************************************************/
  1605. inline BOOLEAN HasZIndicator() const
  1606. {
  1607. if( CZoneIndicatorItem::Z_ZONE & m_cpControlItemDesc->ZoneIndicators.ulAxesBitField)
  1608. {
  1609. return TRUE;
  1610. }
  1611. else
  1612. {
  1613. return FALSE;
  1614. }
  1615. }
  1616. /***********************************************************************************
  1617. **
  1618. ** inline BOOLEAN CZoneIndicatorItem::GetXIndicator() const
  1619. **
  1620. ** @cmember If the pointer is in the X zone returns true
  1621. **
  1622. *************************************************************************************/
  1623. inline BOOLEAN GetXIndicator() const
  1624. {
  1625. ASSERT(HasXIndicator());
  1626. if( CZoneIndicatorItem::X_ZONE & m_ItemState.ZoneIndicators.ulZoneIndicatorBits)
  1627. {
  1628. return TRUE;
  1629. }
  1630. else
  1631. {
  1632. return FALSE;
  1633. }
  1634. }
  1635. /***********************************************************************************
  1636. **
  1637. ** inline BOOLEAN CZoneIndicatorItem::GetYIndicator() const
  1638. **
  1639. ** @cmember If the pointer is in the Y zone returns true
  1640. **
  1641. *************************************************************************************/
  1642. inline BOOLEAN GetYIndicator() const
  1643. {
  1644. ASSERT(HasYIndicator());
  1645. if( CZoneIndicatorItem::Y_ZONE & m_ItemState.ZoneIndicators.ulZoneIndicatorBits)
  1646. {
  1647. return TRUE;
  1648. }
  1649. else
  1650. {
  1651. return FALSE;
  1652. }
  1653. }
  1654. /***********************************************************************************
  1655. **
  1656. ** inline BOOLEAN CZoneIndicatorItem::GetZIndicator() const
  1657. **
  1658. ** @cmember If the pointer is in the Z zone returns true
  1659. **
  1660. *************************************************************************************/
  1661. inline BOOLEAN GetZIndicator() const
  1662. {
  1663. ASSERT(HasZIndicator());
  1664. if( CZoneIndicatorItem::Z_ZONE & m_ItemState.ZoneIndicators.ulZoneIndicatorBits)
  1665. {
  1666. return TRUE;
  1667. }
  1668. else
  1669. {
  1670. return FALSE;
  1671. }
  1672. }
  1673. /***********************************************************************************
  1674. **
  1675. ** inline BOOLEAN CZoneIndicatorItem::SetXIndicator()
  1676. **
  1677. ** @cmember Sets to indicate X is in the zone
  1678. **
  1679. *************************************************************************************/
  1680. inline void SetXIndicator()
  1681. {
  1682. ASSERT(HasXIndicator());
  1683. m_ItemState.ZoneIndicators.ulZoneIndicatorBits |= CZoneIndicatorItem::X_ZONE;
  1684. }
  1685. /***********************************************************************************
  1686. **
  1687. ** inline BOOLEAN CZoneIndicatorItem::SetYIndicator()
  1688. **
  1689. ** @cmember Sets to indicate Y is in the zone
  1690. **
  1691. *************************************************************************************/
  1692. inline void SetYIndicator()
  1693. {
  1694. ASSERT(HasYIndicator());
  1695. m_ItemState.ZoneIndicators.ulZoneIndicatorBits |= CZoneIndicatorItem::Y_ZONE;
  1696. }
  1697. /***********************************************************************************
  1698. **
  1699. ** inline BOOLEAN CZoneIndicatorItem::SetZIndicator()
  1700. **
  1701. ** @cmember Sets to indicate Z is in the zone
  1702. **
  1703. *************************************************************************************/
  1704. inline void SetZIndicator()
  1705. {
  1706. ASSERT(HasZIndicator());
  1707. m_ItemState.ZoneIndicators.ulZoneIndicatorBits |= CZoneIndicatorItem::Z_ZONE;
  1708. }
  1709. /***********************************************************************************
  1710. **
  1711. ** inline BOOLEAN CZoneIndicatorItem::ClearXIndicator()
  1712. **
  1713. ** @cmember Sets to indicate X is not in the zone
  1714. **
  1715. *************************************************************************************/
  1716. inline void ClearXIndicator()
  1717. {
  1718. ASSERT(HasXIndicator());
  1719. m_ItemState.ZoneIndicators.ulZoneIndicatorBits &= ~CZoneIndicatorItem::X_ZONE;
  1720. }
  1721. /***********************************************************************************
  1722. **
  1723. ** inline BOOLEAN CZoneIndicatorItem::ClearYIndicator()
  1724. **
  1725. ** @cmember Sets to indicate Y is not in the zone
  1726. **
  1727. *************************************************************************************/
  1728. inline void ClearYIndicator()
  1729. {
  1730. ASSERT(HasYIndicator());
  1731. m_ItemState.ZoneIndicators.ulZoneIndicatorBits &= ~CZoneIndicatorItem::Y_ZONE;
  1732. }
  1733. /***********************************************************************************
  1734. **
  1735. ** inline BOOLEAN CZoneIndicatorItem::ClearZIndicator()
  1736. **
  1737. ** @cmember Sets to indicate Z is not in the zone
  1738. **
  1739. *************************************************************************************/
  1740. inline void ClearZIndicator()
  1741. {
  1742. ASSERT(HasZIndicator());
  1743. m_ItemState.ZoneIndicators.ulZoneIndicatorBits &= ~CZoneIndicatorItem::Z_ZONE;
  1744. }
  1745. //
  1746. // Read\Write to Report
  1747. //
  1748. NTSTATUS ReadFromReport(
  1749. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1750. PCHAR pcReport,
  1751. LONG lReportLength
  1752. );
  1753. NTSTATUS WriteToReport(
  1754. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1755. PCHAR pcReport,
  1756. LONG lReportLength
  1757. ) const;
  1758. private:
  1759. //
  1760. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1761. // anyone tries to use it.
  1762. //
  1763. CZoneIndicatorItem& operator =(const CZoneIndicatorItem& rZoneIndicatorItem);
  1764. public:
  1765. static const ULONG X_ZONE;
  1766. static const ULONG Y_ZONE;
  1767. static const ULONG Z_ZONE;
  1768. };
  1769. /******************************************************************************/
  1770. /** @class CDualZoneIndicatorItem |
  1771. /** A dual zone indicator is an item that indicate movement into a particular section
  1772. /** of a two axis plane.
  1773. ******************************************************************************/
  1774. class CDualZoneIndicatorItem : public virtual CControlItem
  1775. {
  1776. public:
  1777. /***********************************************************************************
  1778. **
  1779. ** CDualZoneIndicatorItem::CDualZoneIndicatorItem(const CONTROL_ITEM_DESC *cpControlItemDesc)
  1780. **
  1781. ** @cmember c'tor initializes item to default state (center)
  1782. **
  1783. *************************************************************************************/
  1784. CDualZoneIndicatorItem
  1785. (
  1786. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1787. )
  1788. {
  1789. m_cpControlItemDesc = cpControlItemDesc;
  1790. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  1791. SetDefaultState();
  1792. }
  1793. virtual void SetDefaultState()
  1794. {
  1795. m_ItemState.DualZoneIndicators.rglVal[0] = m_cpControlItemDesc->DualZoneIndicators.pZoneRangeTable->lCenter[0];
  1796. m_ItemState.DualZoneIndicators.rglVal[1] = m_cpControlItemDesc->DualZoneIndicators.pZoneRangeTable->lCenter[1];
  1797. m_ItemState.ulModifiers = 0;
  1798. }
  1799. virtual BOOLEAN IsDefaultState()
  1800. {
  1801. for (int n = 0; n < 2; n++)
  1802. {
  1803. if (m_ItemState.DualZoneIndicators.rglVal[n] != m_cpControlItemDesc->DualZoneIndicators.pZoneRangeTable->lCenter[n])
  1804. {
  1805. return FALSE;
  1806. }
  1807. }
  1808. return TRUE;
  1809. }
  1810. void SetActiveZone(LONG lZone);
  1811. void SetActiveZone(LONG posOne, LONG posTwo)
  1812. {
  1813. m_ItemState.DualZoneIndicators.rglVal[0] = posOne;
  1814. m_ItemState.DualZoneIndicators.rglVal[1] = posTwo;
  1815. }
  1816. LONG GetActiveZone();
  1817. LONG GetActiveZone(SHORT sXDeadZone, SHORT sYDeadZone);
  1818. LONG GetNumZones ()
  1819. {
  1820. return m_cpControlItemDesc->DualZoneIndicators.lNumberOfZones;
  1821. }
  1822. BOOLEAN IsXYIndicator()
  1823. {
  1824. return BOOLEAN(m_cpControlItemDesc->DualZoneIndicators.rgUsageAxis[0] == HID_USAGE_GENERIC_X);
  1825. }
  1826. BOOLEAN IsRzIndicator()
  1827. {
  1828. return (m_cpControlItemDesc->DualZoneIndicators.rgUsageAxis[0] == HID_USAGE_GENERIC_RZ);
  1829. }
  1830. //
  1831. // Read\Write to Report
  1832. //
  1833. NTSTATUS ReadFromReport(
  1834. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1835. PCHAR pcReport,
  1836. LONG lReportLength
  1837. );
  1838. NTSTATUS WriteToReport(
  1839. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1840. PCHAR pcReport,
  1841. LONG lReportLength
  1842. ) const;
  1843. private:
  1844. CDualZoneIndicatorItem& operator =(const CDualZoneIndicatorItem& rDualZoneIndicatorItem);
  1845. };
  1846. /******************************************************************************/
  1847. /** @class CForceMapItem |
  1848. /** Derived from CGenericItem represents the Wheel force feedback control on device
  1849. ******************************************************************************/
  1850. class CForceMapItem : public CGenericItem
  1851. {
  1852. public:
  1853. CForceMapItem
  1854. (
  1855. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1856. ) : CGenericItem(cpControlItemDesc)
  1857. {
  1858. SetDefaultState();
  1859. }
  1860. virtual void SetDefaultState()
  1861. {
  1862. m_ItemState.ForceMap.bMapYToX = m_cpControlItemDesc->ForceMap.bMapYToX;
  1863. m_ItemState.ForceMap.usRTC = m_cpControlItemDesc->ForceMap.usRTC;
  1864. m_ItemState.ForceMap.usGain = m_cpControlItemDesc->ForceMap.usGain;
  1865. m_ItemState.ulModifiers = 0;
  1866. }
  1867. virtual BOOLEAN IsDefaultState()
  1868. {
  1869. if (m_ItemState.ForceMap.bMapYToX == m_cpControlItemDesc->ForceMap.bMapYToX &&
  1870. m_ItemState.ForceMap.usRTC == m_cpControlItemDesc->ForceMap.usRTC &&
  1871. m_ItemState.ForceMap.usGain == m_cpControlItemDesc->ForceMap.usGain)
  1872. {
  1873. return TRUE;
  1874. }
  1875. return FALSE;
  1876. }
  1877. void SetMapYtoX (BOOLEAN a_bMapYToX)
  1878. {
  1879. m_ItemState.ForceMap.bMapYToX = a_bMapYToX ? 0x1 : 0x0;
  1880. }
  1881. void SetRTC (USHORT a_usRTC)
  1882. {
  1883. m_ItemState.ForceMap.usRTC = a_usRTC & 0x7fff;
  1884. }
  1885. void SetGain (USHORT a_usGain)
  1886. {
  1887. m_ItemState.ForceMap.usGain = a_usGain & 0x7fff;
  1888. }
  1889. BOOLEAN GetMapYToX ()
  1890. {
  1891. return m_ItemState.ForceMap.bMapYToX;
  1892. }
  1893. USHORT GetRTC ()
  1894. {
  1895. return m_ItemState.ForceMap.usRTC;
  1896. }
  1897. USHORT GetGain ()
  1898. {
  1899. return m_ItemState.ForceMap.usGain;
  1900. }
  1901. //
  1902. // Read\Write to Report
  1903. //
  1904. NTSTATUS ReadFromReport(
  1905. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1906. PCHAR pcReport,
  1907. LONG lReportLength
  1908. );
  1909. NTSTATUS WriteToReport(
  1910. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1911. PCHAR pcReport,
  1912. LONG lReportLength
  1913. ) const;
  1914. private:
  1915. //
  1916. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  1917. // anyone tries to use it.
  1918. //
  1919. CForceMapItem& operator =(const CForceMapItem& rWheelItem);
  1920. };
  1921. /******************************************************************************/
  1922. /** @class CProfileSelector |
  1923. /** Derived from CControlItem represents group of buttons on profile selector buttons
  1924. ******************************************************************************/
  1925. class CProfileSelector : public virtual CControlItem
  1926. {
  1927. public:
  1928. /***********************************************************************************
  1929. **
  1930. ** CProfileSelector::CProfileSelector(const CONTROL_ITEM_DESC *cpControlItemDesc)
  1931. **
  1932. ** @cmember c'tor initializes selector to 0
  1933. **
  1934. *************************************************************************************/
  1935. CProfileSelector
  1936. (
  1937. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  1938. )
  1939. {
  1940. m_cpControlItemDesc = cpControlItemDesc;
  1941. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  1942. SetDefaultState();
  1943. }
  1944. virtual void SetDefaultState()
  1945. {
  1946. m_ItemState.ProfileSelector.lVal = m_cpControlItemDesc->ProfileSelectors.ulFirstProfile;
  1947. }
  1948. virtual BOOLEAN IsDefaultState()
  1949. {
  1950. return FALSE; // there is no such thing
  1951. }
  1952. inline void GetSelectedProfile
  1953. (
  1954. UCHAR& rucSelectedProfile // @parm [out] Current selected profile (Slider Location)
  1955. ) const
  1956. {
  1957. rucSelectedProfile = UCHAR(m_ItemState.ProfileSelector.lVal);
  1958. }
  1959. inline void SetSelectedProfile
  1960. (
  1961. UCHAR ucSelectedProfile // @parm [out] Current selected profile (Slider Location)
  1962. )
  1963. {
  1964. m_ItemState.ProfileSelector.lVal = ucSelectedProfile;
  1965. }
  1966. /***********************************************************************************
  1967. **
  1968. ** inline USHORT CProfileSelectorsItem::GetProfileSelectorMin()
  1969. **
  1970. ** @cmember Gets the minimum button number for profile selector
  1971. **
  1972. ** @rdesc Number of the minimum button
  1973. **
  1974. *************************************************************************************/
  1975. inline USHORT GetProfileSelectorMin() const
  1976. {
  1977. return static_cast<USHORT>(m_cpControlItemDesc->ProfileSelectors.UsageButtonMin);
  1978. }
  1979. /***********************************************************************************
  1980. **
  1981. ** inline USHORT CProfileSelectorsItem::GetProfileSelectorMax()
  1982. **
  1983. ** @cmember Gets the maximum button number for profile selector
  1984. **
  1985. ** @rdesc Number of the maximum button
  1986. **
  1987. *************************************************************************************/
  1988. inline USHORT GetProfileSelectorMax() const
  1989. {
  1990. return static_cast<USHORT>(m_cpControlItemDesc->ProfileSelectors.UsageButtonMax);
  1991. }
  1992. //
  1993. // Read\Write to Report
  1994. //
  1995. NTSTATUS ReadFromReport(
  1996. PHIDP_PREPARSED_DATA pHidPreparsedData,
  1997. PCHAR pcReport,
  1998. LONG lReportLength
  1999. );
  2000. NTSTATUS WriteToReport(
  2001. PHIDP_PREPARSED_DATA pHidPreparsedData,
  2002. PCHAR pcReport,
  2003. LONG lReportLength
  2004. ) const;
  2005. private:
  2006. //
  2007. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  2008. // anyone tries to use it.
  2009. //
  2010. CProfileSelector& operator =(const CProfileSelector& rProfileSelectorItem);
  2011. };
  2012. /******************************************************************************/
  2013. /** @class CButtonLED |
  2014. /** Derived from CControlItem represents group of LEDs the encircle buttons
  2015. ******************************************************************************/
  2016. class CButtonLED : public virtual CControlItem
  2017. {
  2018. public:
  2019. /***********************************************************************************
  2020. **
  2021. ** CButtonLED::CButtonLED(const CONTROL_ITEM_DESC *cpControlItemDesc)
  2022. **
  2023. ** @cmember c'tor initializes selector to 0
  2024. **
  2025. *************************************************************************************/
  2026. CButtonLED
  2027. (
  2028. const CONTROL_ITEM_DESC *cpControlItemDesc // @parm Pointer to table entry describing item
  2029. )
  2030. {
  2031. m_cpControlItemDesc = cpControlItemDesc;
  2032. m_ItemState.ulItemIndex = cpControlItemDesc->ulItemIndex;
  2033. SetDefaultState();
  2034. }
  2035. virtual void SetDefaultState()
  2036. {
  2037. // Nothing to do here really
  2038. }
  2039. virtual BOOLEAN IsDefaultState()
  2040. {
  2041. return FALSE; // there is no such thing
  2042. }
  2043. //
  2044. // Read\Write to Report
  2045. //
  2046. NTSTATUS ReadFromReport(
  2047. PHIDP_PREPARSED_DATA pHidPreparsedData,
  2048. PCHAR pcReport,
  2049. LONG lReportLength
  2050. );
  2051. NTSTATUS WriteToReport(
  2052. PHIDP_PREPARSED_DATA pHidPreparsedData,
  2053. PCHAR pcReport,
  2054. LONG lReportLength
  2055. ) const;
  2056. private:
  2057. //
  2058. // Dissallow use of assignment operator. (Do not define - it will cause a link error if
  2059. // anyone tries to use it.
  2060. //
  2061. CButtonLED& operator =(const CButtonLED& rCButtonLED);
  2062. };
  2063. //NEWDEVICE
  2064. #endif __ControlItems_h__