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.

529 lines
16 KiB

  1. #ifndef __ACTIONS_H__
  2. #define __ACTIONS_H__
  3. // @doc
  4. /**********************************************************************
  5. *
  6. * @module Actions.h |
  7. *
  8. * Definitions of data structures for representing Actions and Events
  9. *
  10. * History
  11. * ----------------------------------------------------------
  12. * Mitchell S. Dernis Original
  13. * Jeffrey A. Davis Modifications.
  14. *
  15. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  16. *
  17. * @index Actions | ACTIONS
  18. *
  19. * @topic Actions |
  20. * Contains definitions of structures, constants, and macros
  21. * for building up and working with Actions and their constituent Events
  22. *
  23. **********************************************************************/
  24. #include "controlitems.h"
  25. #include "profile.h" // legacy data structures.
  26. #define CF_RAWSCHEME (0x201)
  27. #pragma pack(push, actions_previous_alignment)
  28. #pragma pack(1)
  29. //
  30. // Flags included as part of commands type.
  31. // used to define different properties of some commands
  32. #define COMMAND_TYPE_FLAG_ASSIGNMENT 0x8000
  33. //
  34. // Different types of command that can be sent to GcKernel
  35. //
  36. #define COMMAND_TYPE_ASSIGNMENT_TARGET 0x0001
  37. #define COMMAND_TYPE_RECORDABLE (0x0002 | COMMAND_TYPE_FLAG_ASSIGNMENT)
  38. #define COMMAND_TYPE_BEHAVIOR (0x0003 | COMMAND_TYPE_FLAG_ASSIGNMENT)
  39. #define COMMAND_TYPE_FEEDBACK (0x0004 | COMMAND_TYPE_FLAG_ASSIGNMENT)
  40. #define COMMAND_TYPE_TRANSLATE 0x0005
  41. #define COMMAND_TYPE_QUEUE 0x0006
  42. #define COMMAND_TYPE_GENERAL 0x0007
  43. //
  44. // @enum COMMAND_ID |
  45. // a.k.a ACTION_OBJECT_ID, and BEHAVIOR_OBJECT_ID
  46. // defines the sepcific command.
  47. //
  48. typedef enum COMMAND_ID
  49. {
  50. eDirectory = 0, //@field Directory.
  51. //
  52. // Assignment Targets IDs
  53. //
  54. eAssignmentTargetPlaceTag = (COMMAND_TYPE_ASSIGNMENT_TARGET << 16), //Beginning of Assignment Targets
  55. eRecordableAction, //@field Recordable Action
  56. eBehaviorAction, //@field Behavior Action
  57. eFeedbackAction, //@field Feedback Action
  58. //
  59. // Recordable Assignment IDs
  60. //
  61. eAssignmentPlaceTag = (COMMAND_TYPE_RECORDABLE << 16), //Beginning of assignments
  62. eTimedMacro, //@field A timed macro
  63. eKeyString, //@field An untimed string of keys
  64. eButtonMap, //@field A single button mapped (or direction)
  65. eKeyMap, //@field A single keyboard key mapped
  66. eCycleMap, //@field A single keyboard key mapped
  67. eNone, //@field Was eAxisMap used as NONE
  68. //
  69. // Mouse Input Assignment IDs - use with eRecordableAction assignment targets.
  70. // These are mutually exclusive with Macors and other recordable assignments.
  71. // The ones with FX (all except eMouseButtonMap) do nothing unless eMouseFXModel is sent to the device(below)
  72. eMouseButtonMap, //@field Maps a mouse button
  73. eMouseFXAxisMap, //@field Maps a mouse axis
  74. eMouseFXClutchMap, //@field Maps the button to turn clutch on in Mouse FX model
  75. eMouseFXDampenMap, //@field Maps the button to turn dampen on in Mouse FX model
  76. eMouseFXZoneIndicator, //@field Maps an an input to indicate zone in Mouse FX model
  77. //
  78. // Axis IDs
  79. //
  80. eAxisMap, //@field A mapping of one axis to another
  81. eAxisToKeyMap, //@field A mapping of an axis to key (Used in Attila)
  82. // Atilla Macro (MultiMap?)
  83. eMultiMap, //@field Maps to keys, delays, and mouse clicks
  84. //
  85. // Behavior Assignment IDs
  86. //
  87. eBehaviorPlaceTag = (COMMAND_TYPE_BEHAVIOR << 16), //Beginning of Behaviors
  88. eStandardBehaviorCurve, //@field A behavior curve assigned to and axes
  89. //
  90. // Feedback Assignment IDs
  91. //
  92. eFeedbackPlaceTag = (COMMAND_TYPE_FEEDBACK << 16), //Beginning of Feedback types
  93. eForceMap, //MapYToX, RTC, Gain (Driver Should Ignore) Sparky Zep Additions
  94. //
  95. // Translation IDs
  96. //
  97. eTranslatePlaceTag = (COMMAND_TYPE_TRANSLATE << 16), //Beginning of Translate types
  98. eAtlasProfile, //@field ATLAS entire Profile.
  99. eXenaProfile, //@field XENA entire profile.
  100. eAtlasKeyboardMacro, //@field ATLAS macro.
  101. eXenaKeyboardMacro, //@field XENA macro.
  102. eAtlasTimedMacro, //@field ATLAS macro.
  103. eXenaTimedMacro, //@field XENA macro.
  104. eAtlasSetting, //@field ATLAS Settings flags
  105. eXenaSetting, //@field XENA Settings flags
  106. //
  107. // Queue Command IDs
  108. //
  109. eQueuePlaceTag = (COMMAND_TYPE_QUEUE << 16), //Beginning of Queue
  110. eSetQueueInterruptMode, //@field Cause one macro to interupt another
  111. eSetQueueOverlayMode, //@field Causes macros to overlay each other
  112. eSetQueueSequenceMode, //@field Causes macros to play in sequence
  113. //
  114. // General Command IDs
  115. //
  116. eGeneralCommandsPlaceTag = (COMMAND_TYPE_GENERAL << 16),//Beginning of General Commands
  117. eResetScheme, //@field Resets all the settings of a scheme
  118. } ACTION_OBJECT_ID, BEHAVIOR_OBJECT_ID;
  119. // There are the different type of proportional axes
  120. typedef enum AXIS_ID
  121. {
  122. eX = 0,
  123. eY,
  124. eZ,
  125. eRX,
  126. eRY,
  127. eRZ
  128. };
  129. //
  130. // @struct COMMAND_HEADER |
  131. // Each command begins with a COMMAND_HEADER
  132. typedef struct
  133. {
  134. COMMAND_ID eID; //@field ID of command
  135. ULONG ulByteSize; //@field Length of command including this header
  136. } COMMAND_HEADER, *PCOMMAND_HEADER;
  137. //
  138. // @struct COMMAND_DIRECTORY |
  139. // Dirtectory block that lists one or more sets of commands.
  140. typedef struct tagCOMMAND_DIRECTORY
  141. {
  142. COMMAND_HEADER CommandHeader; //@field Command header
  143. USHORT usNumEntries; //@field Number of IDs that follow.
  144. ULONG ulEntireSize;
  145. } COMMAND_DIRECTORY,
  146. *PCOMMAND_DIRECTORY;
  147. //
  148. // @struct ASSIGNMENT_BLOCK |
  149. // Assignment blocks are any block with a
  150. // COMMAND_ID that has the COMMAND_TYPE_FLAG_ASSIGNMENT
  151. // set. You can assume that these blocks start
  152. // with this structure as an extension of the COMMAND_HEADER
  153. // structure.
  154. typedef struct ASSIGNMENT_BLOCK
  155. {
  156. COMMAND_HEADER CommandHeader; //@field Command header
  157. ULONG ulVidPid; //@field VIDPID.
  158. } *PASSIGNMENT_BLOCK;
  159. //
  160. // @func Get the type of command from a COMMAND_ID.,
  161. //
  162. // @rdesc COMMAND_TYPE_ASSIGNMENT Command is an action assignment.
  163. // @rdesc COMMAND_TYPE_BEHAVIOR Command is a behavior assignment.
  164. // @rdesc COMMAND_TYPE_QUEUE Command changes properties of Action queue.
  165. // @rdesc COMMAND_TYPE_GENERAL Command modifies a general property of the filter.
  166. //
  167. #ifdef __cplusplus
  168. inline ULONG
  169. CommandType
  170. (
  171. COMMAND_ID eID //@parm COMMAND_ID to get type of
  172. )
  173. {
  174. return static_cast<ULONG>(eID >> 16) & 0x0000FFFF;
  175. }
  176. #else //if not __cplusplus, define as macro instead
  177. #define CommandType(__ID__) ((ULONG)(__ID__ >> 16) & 0x0000FFFF)
  178. #endif //__cplusplus
  179. //
  180. // @struct EVENT | Describes a single untimed event which may contain
  181. // device data or keystrokes.
  182. //
  183. // @field ULONG | ulNumXfers | Number CONTROL_ITEM_XFER's in EVENT
  184. // @field CONTROL_ITEM_XFER | rgXfers[] | Array of events
  185. typedef struct tagEVENT
  186. {
  187. ULONG ulNumXfers;
  188. CONTROL_ITEM_XFER rgXfers[1];
  189. //
  190. // @mfunc static ULONG | EVENT | RequiredByteSize |
  191. // Calculates the bytes required for an event given the number
  192. // CONTROL_ITEM_XFER's.
  193. //
  194. #ifdef __cplusplus
  195. static ULONG RequiredByteSize(
  196. ULONG ulNumXfers //@parm Number of CONTROL_ITEM_XFERs
  197. )
  198. {
  199. ASSERT(0!=ulNumXfers);
  200. return (ulNumXfers-1)*sizeof(CONTROL_ITEM_XFER)+sizeof(tagEVENT);
  201. }
  202. // Simple accessor for retrieval of Xfers by index
  203. CONTROL_ITEM_XFER& GetControlItemXfer(ULONG ulXferIndex)
  204. {
  205. ASSERT(ulXferIndex < ulNumXfers); // && TEXT("Requested Xfer is greater than the number of xfers"));
  206. return rgXfers[ulXferIndex];
  207. }
  208. // Assumes XFers are in the same order!!
  209. bool operator==(const tagEVENT& rhs)
  210. {
  211. if (ulNumXfers != rhs.ulNumXfers)
  212. {
  213. return false;
  214. }
  215. for (UINT i = 0; i < ulNumXfers; i++)
  216. {
  217. if (rgXfers[i] != rhs.rgXfers[i])
  218. {
  219. return false;
  220. }
  221. }
  222. // If we got this far all matched
  223. return true;
  224. }
  225. bool operator!=(const tagEVENT& rhs)
  226. {
  227. return !(operator==(rhs));
  228. }
  229. #endif __cplusplus
  230. } EVENT, *PEVENT;
  231. //
  232. // @struct TIMED_EVENT | Describes a single timed event which may contain
  233. // device data or keystrokes.
  234. //
  235. // @field ULONG | ulDuration | Duration of timed event.
  236. // @field EVENT | Event | Untimed EVENT
  237. typedef struct tagTIMED_EVENT
  238. {
  239. ULONG ulDuration;
  240. EVENT Event;
  241. //
  242. // @mfunc static ULONG | TIMED_EVENT | RequiredByteSize |
  243. // Calculates the bytes required for an event given the number
  244. // CONTROL_ITEM_XFER's.
  245. //
  246. #ifdef __cplusplus
  247. static ULONG RequiredByteSize(
  248. ULONG ulNumXfers //@parm Number of CONTROL_ITEM_XFERs
  249. )
  250. {
  251. // ASSERT(0!=ulNumXfers);
  252. return (ulNumXfers-1)*sizeof(CONTROL_ITEM_XFER)+sizeof(tagTIMED_EVENT);
  253. }
  254. #endif
  255. } TIMED_EVENT, *PTIMED_EVENT;
  256. const ULONG ACTION_FLAG_AUTO_REPEAT = 0x00000001;
  257. const ULONG ACTION_FLAG_BLEED_THROUGH = 0x00000002;
  258. const ULONG ACTION_FLAG_PREVENT_INTERRUPT = 0x00000004;
  259. //
  260. // @struct TIMED_MACRO | Structure to represent a timed macro.
  261. // @field COMMAND_HEADER | CmdHeader | Command header must have eID = eTimedMacro.
  262. // @field ULONG | ulFlags | Flags modify the properties of the macro.<nl>
  263. // ACTION_FLAG_AUTO_REPEAT - Macro repeats as long as trigger is held.<nl>
  264. // ACTION_FLAG_BLEED_THROUGH - Allows bleed-through and coexisting macros <nl>
  265. // ACTION_FLAG_PREVENT_INTERRUPT - Prevents a macro from being interrupted by another.<nl>
  266. // @field ULONG | ulEventCount | Number of events in Macro.
  267. // @field TIMED_EVENT | rgEvents[1] | Events in macro - do not access directly, use accessors
  268. // @xref TIMED_MACRO::GetEvent
  269. // @xref TIMED_MACRO::GetNextEvent
  270. typedef struct tagTIMED_MACRO
  271. {
  272. //
  273. // Data for TIMED_MACROS
  274. //
  275. ASSIGNMENT_BLOCK AssignmentBlock;
  276. ULONG ulFlags;
  277. ULONG ulEventCount;
  278. #ifdef __cplusplus
  279. //
  280. // Accessor functions for events which are variable length,
  281. // so do not access private item directly
  282. PTIMED_EVENT GetEvent(ULONG uEventNum);
  283. PTIMED_EVENT GetNextEvent(PTIMED_EVENT pCurrentEvent, ULONG& ulCurrentEvent);
  284. static tagTIMED_MACRO *Init(ULONG ulVidPid,ULONG ulFlagsParm, PCHAR pcBuffer, ULONG& rulRemainingBuffer);
  285. HRESULT AddEvent(PTIMED_EVENT pTimedEvent, ULONG& rulRemainingBuffer);
  286. private:
  287. #endif //__cplusplus
  288. TIMED_EVENT rgEvents[1];
  289. } TIMED_MACRO, *PTIMED_MACRO;
  290. typedef struct tagMULTI_MACRO
  291. {
  292. //
  293. // Data for MULTI_MACRO
  294. //
  295. ASSIGNMENT_BLOCK AssignmentBlock;
  296. ULONG ulFlags;
  297. ULONG ulEventCount;
  298. #ifdef __cplusplus
  299. //
  300. // Accessor functions for events which are variable length,
  301. // so do not access private item directly
  302. PEVENT GetEvent(ULONG uEventNum);
  303. PEVENT GetNextEvent(EVENT* pCurrentEvent, ULONG& ulCurrentEvent);
  304. static tagMULTI_MACRO *Init(ULONG ulVidPid, ULONG ulFlagsParm, PCHAR pcBuffer, ULONG& rulRemainingBuffer);
  305. HRESULT AddEvent(EVENT* pEvent, ULONG& rulRemainingBuffer);
  306. private:
  307. #endif //__cplusplus
  308. EVENT rgEvents[1];
  309. } MULTI_MACRO, *PMULTI_MACRO;
  310. typedef struct
  311. {
  312. ASSIGNMENT_BLOCK AssignmentBlock;
  313. MACRO Macro;
  314. } XENA_MACRO_BLOCK, *PXENA_MACRO_BLOCK;
  315. typedef struct
  316. {
  317. ASSIGNMENT_BLOCK AssignmentBlock;
  318. ATLAS_MACRO Macro;
  319. } ATLAS_MACRO_BLOCK, *PATLAS_MACRO_BLOCK;
  320. typedef struct
  321. {
  322. ASSIGNMENT_BLOCK AssignmentBlock;
  323. SETTING Setting;
  324. } XENA_SETTING_BLOCK, *PXENA_SETTING_BLOCK;
  325. typedef struct
  326. {
  327. ASSIGNMENT_BLOCK AssignmentBlock;
  328. ATLAS_SETTING Setting;
  329. } ATLAS_SETTING_BLOCK, *PATLAS_SETTING_BLOCK;
  330. typedef struct tagMAP_LIST
  331. {
  332. ASSIGNMENT_BLOCK AssignmentBlock;
  333. ULONG ulFlags;
  334. ULONG ulEventCount;
  335. #ifdef __cplusplus
  336. //
  337. // Accessor functions for events which are variable length,
  338. // so do not access private item directly
  339. PEVENT GetEvent(ULONG uEventNum);
  340. PEVENT GetNextEvent(PEVENT pCurrentEvent, ULONG& ulCurrentEvent);
  341. static tagMAP_LIST* Init(ULONG ulVidPid,ULONG ulFlagsParm, PCHAR pcBuffer, ULONG& rulRemainingBuffer);
  342. HRESULT AddEvent(EVENT* pTimedEvent, ULONG& rulRemainingBuffer);
  343. private:
  344. #endif
  345. EVENT rgEvents[1];
  346. } MAP_LIST, *PMAP_LIST, CYCLE_MAP, *PCYCLE_MAP, KEYSTRING_MAP, *PKEYSTRING_MAP;
  347. typedef struct tagX_MAP
  348. {
  349. ASSIGNMENT_BLOCK AssignmentBlock;
  350. ULONG ulFlags;
  351. ULONG ulEventCount; // Not gauranteeing, but should always be 1
  352. EVENT Event;
  353. } KEY_MAP, *PKEY_MAP, BUTTON_MAP, *PBUTTON_MAP;
  354. /*
  355. * BUGBUG This structure is only useful for mapping axes of type CGenericItem or derivatives.
  356. * BUGBUG This is due to limitations in GcKernel. For example the Y-Z axis swap for
  357. * BUGBUG for joysticks is currently broken. See the comment in the declaration of CAxisMap
  358. * BUGBUG in filter.h in the GcKernel.sys project for details.
  359. */
  360. typedef struct tagAXIS_MAP
  361. {
  362. ASSIGNMENT_BLOCK AssignmentBlock; //eAxisMap is the type
  363. LONG lCoefficient1024x; //A mapping coeffiecient times 1024 (should be between -1024 and 1024)
  364. CONTROL_ITEM_XFER cixDestinationAxis; //Axis to map to.
  365. } AXIS_MAP, *PAXIS_MAP;
  366. typedef struct
  367. {
  368. short sX;
  369. short sY;
  370. }CURVE_POINT;
  371. typedef struct tagBEHAVIOR_CURVE
  372. {
  373. ASSIGNMENT_BLOCK AssignmentBlock;
  374. BOOLEAN fDigital; //This flag is only flag for PROPDPads that are software programmable.
  375. ULONG ulRange;
  376. USHORT usPointCount;
  377. CURVE_POINT rgPoints[1];
  378. #ifdef __cplusplus
  379. static ULONG RequiredByteSize(USHORT usNumPoints)
  380. {
  381. return (usNumPoints-1)*sizeof(CURVE_POINT)+sizeof(tagBEHAVIOR_CURVE);
  382. }
  383. #endif
  384. } BEHAVIOR_CURVE, *PBEHAVIOR_CURVE;
  385. typedef struct
  386. {
  387. COMMAND_HEADER CommandHeader;
  388. CONTROL_ITEM_XFER cixAssignment;
  389. } ASSIGNMENT_TARGET, *PASSIGNMENT_TARGET;
  390. typedef struct
  391. {
  392. ASSIGNMENT_BLOCK AssignmentBlock;
  393. UCHAR ucButtonNumber;
  394. } MOUSE_BUTTON_MAP, *PMOUSE_BUTTON_MAP;
  395. typedef struct tagMOUSE_MODEL_FX_PARAMETERS
  396. {
  397. ULONG ulAbsZoneSense;
  398. ULONG ulContZoneMaxRate;
  399. ULONG ulPulseWidth;
  400. ULONG ulPulsePeriod;
  401. ULONG ulInertiaTime;
  402. ULONG ulAcceleration;
  403. BOOLEAN fAccelerate;
  404. BOOLEAN fPulse;
  405. USHORT usReserved;
  406. } MOUSE_MODEL_PARAMETERS, *PMOUSE_MODEL_PARAMETERS;
  407. typedef struct
  408. {
  409. ASSIGNMENT_BLOCK AssignmentBlock;
  410. BOOLEAN fIsX; //TRUE = x; FALSE = y
  411. MOUSE_MODEL_PARAMETERS AxisModelParameters;
  412. } MOUSE_FX_AXIS_MAP, *PMOUSE_FX_AXIS_MAP;
  413. typedef struct
  414. {
  415. ASSIGNMENT_BLOCK AssignmentBlock;
  416. } MOUSE_FX_CLUTCH_MAP, *PMOUSE_FX_CLUTCH_MAP;
  417. typedef struct
  418. {
  419. ASSIGNMENT_BLOCK AssignmentBlock;
  420. } MOUSE_FX_DAMPEN_MAP, *PMOUSE_FX_DAMPEN_MAP;
  421. typedef struct
  422. {
  423. ASSIGNMENT_BLOCK AssignmentBlock;
  424. UCHAR ucAxis; //0 = X, 1=Y, 2=Z
  425. } MOUSE_FX_ZONE_INDICATOR, *PMOUSE_FX_ZONE_INDICATOR;
  426. typedef struct
  427. {
  428. ASSIGNMENT_BLOCK AssignmentBlock;
  429. UCHAR bMapYToX; //@field Bool value
  430. USHORT usRTC; //@field return to center force (0-10000)
  431. USHORT usGain; //@field gain for the device
  432. } *PFORCE_BLOCK, FORCE_BLOCK;
  433. typedef struct tagAXISTOKEYMAPMODEL
  434. {
  435. //
  436. // Data for AXISTOKEYMAPMODEL
  437. //
  438. ASSIGNMENT_BLOCK AssignmentBlock;
  439. ULONG ulActiveAxes; //@field Which axes have mappings
  440. ULONG ulEventCount; //@field How many axis have mappings
  441. #ifdef __cplusplus
  442. //
  443. // Accessor functions for events which are variable length,
  444. // so do not access private item directly
  445. // PEVENT GetEvent(ULONG uEventNum);
  446. // PEVENT GetNextEvent(EVENT* pCurrentEvent, ULONG& ulCurrentEvent);
  447. // static tagMULTI_MACRO *Init(ULONG ulVidPid, ULONG ulFlagsParm, PCHAR pcBuffer, ULONG& rulRemainingBuffer);
  448. // HRESULT AddEvent(EVENT* pEvent, ULONG& rulRemainingBuffer);
  449. private:
  450. #endif //__cplusplus
  451. EVENT rgEvents[1]; //@field Variable size array of events for mappings
  452. } *PAXISTOKEYMAPMODEL_BLOCK, AXISTOKEYMAPMODEL_BLOCK;
  453. #pragma pack(pop, actions_previous_alignment)
  454. #endif //__ACTIONS_H__