gameinput.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332
  1. // Copyright (c) Microsoft Corporation.
  2. //
  3. // This file is licensed under the MIT License.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in all
  13. // copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. // SOFTWARE.
  22. #pragma once
  23. #ifndef __cplusplus
  24. #error GameInput requires C++
  25. #endif
  26. #include <stdint.h>
  27. #include <unknwn.h>
  28. #pragma region Application Family or OneCore Family or Games Family
  29. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
  30. #define GAMEINPUT_API_VERSION 3
  31. namespace GameInput { namespace v3 {
  32. enum GameInputKind
  33. {
  34. GameInputKindUnknown = 0x00000000,
  35. GameInputKindRawDeviceReport = 0x00000001,
  36. GameInputKindControllerAxis = 0x00000002,
  37. GameInputKindControllerButton = 0x00000004,
  38. GameInputKindControllerSwitch = 0x00000008,
  39. GameInputKindController = 0x0000000E,
  40. GameInputKindKeyboard = 0x00000010,
  41. GameInputKindMouse = 0x00000020,
  42. GameInputKindSensors = 0x00000040,
  43. GameInputKindArcadeStick = 0x00010000,
  44. GameInputKindFlightStick = 0x00020000,
  45. GameInputKindGamepad = 0x00040000,
  46. GameInputKindRacingWheel = 0x00080000,
  47. };
  48. DEFINE_ENUM_FLAG_OPERATORS(GameInputKind)
  49. enum GameInputEnumerationKind
  50. {
  51. GameInputNoEnumeration = 0,
  52. GameInputAsyncEnumeration = 1,
  53. GameInputBlockingEnumeration = 2
  54. };
  55. enum GameInputFocusPolicy
  56. {
  57. GameInputDefaultFocusPolicy = 0x00000000,
  58. GameInputExclusiveForegroundInput = 0x00000002,
  59. GameInputExclusiveForegroundGuideButton = 0x00000008,
  60. GameInputExclusiveForegroundShareButton = 0x00000020,
  61. GameInputEnableBackgroundInput = 0x00000040,
  62. GameInputEnableBackgroundGuideButton = 0x00000080,
  63. GameInputEnableBackgroundShareButton = 0x00000100
  64. };
  65. DEFINE_ENUM_FLAG_OPERATORS(GameInputFocusPolicy)
  66. enum GameInputSwitchKind
  67. {
  68. GameInputUnknownSwitchKind = -1,
  69. GameInput2WaySwitch = 0,
  70. GameInput4WaySwitch = 1,
  71. GameInput8WaySwitch = 2
  72. };
  73. enum GameInputSwitchPosition
  74. {
  75. GameInputSwitchCenter = 0,
  76. GameInputSwitchUp = 1,
  77. GameInputSwitchUpRight = 2,
  78. GameInputSwitchRight = 3,
  79. GameInputSwitchDownRight = 4,
  80. GameInputSwitchDown = 5,
  81. GameInputSwitchDownLeft = 6,
  82. GameInputSwitchLeft = 7,
  83. GameInputSwitchUpLeft = 8
  84. };
  85. enum GameInputKeyboardKind
  86. {
  87. GameInputUnknownKeyboard = -1,
  88. GameInputAnsiKeyboard = 0,
  89. GameInputIsoKeyboard = 1,
  90. GameInputKsKeyboard = 2,
  91. GameInputAbntKeyboard = 3,
  92. GameInputJisKeyboard = 4
  93. };
  94. enum GameInputMouseButtons
  95. {
  96. GameInputMouseNone = 0x00000000,
  97. GameInputMouseLeftButton = 0x00000001,
  98. GameInputMouseRightButton = 0x00000002,
  99. GameInputMouseMiddleButton = 0x00000004,
  100. GameInputMouseButton4 = 0x00000008,
  101. GameInputMouseButton5 = 0x00000010,
  102. GameInputMouseWheelTiltLeft = 0x00000020,
  103. GameInputMouseWheelTiltRight = 0x00000040
  104. };
  105. DEFINE_ENUM_FLAG_OPERATORS(GameInputMouseButtons)
  106. enum GameInputMousePositions
  107. {
  108. GameInputMouseNoPosition = 0x00000000,
  109. GameInputMouseAbsolutePosition = 0x00000001,
  110. GameInputMouseRelativePosition = 0x00000002
  111. };
  112. DEFINE_ENUM_FLAG_OPERATORS(GameInputMousePositions)
  113. enum GameInputSensorsKind
  114. {
  115. GameInputSensorsNone = 0x00000000,
  116. GameInputSensorsAccelerometer = 0x00000001,
  117. GameInputSensorsGyrometer = 0x00000002,
  118. GameInputSensorsCompass = 0x00000004,
  119. GameInputSensorsOrientation = 0x00000008
  120. };
  121. DEFINE_ENUM_FLAG_OPERATORS(GameInputSensorsKind)
  122. enum GameInputSensorAccuracy
  123. {
  124. GameInputSensorAccuracyUnknown = 0x00000000,
  125. GameInputSensorAccuracyUnreliable = 0x00000001,
  126. GameInputSensorAccuracyApproximate = 0x00000002,
  127. GameInputSensorAccuracyHigh = 0x00000003
  128. };
  129. enum GameInputArcadeStickButtons
  130. {
  131. GameInputArcadeStickNone = 0x00000000,
  132. GameInputArcadeStickMenu = 0x00000001,
  133. GameInputArcadeStickView = 0x00000002,
  134. GameInputArcadeStickUp = 0x00000004,
  135. GameInputArcadeStickDown = 0x00000008,
  136. GameInputArcadeStickLeft = 0x00000010,
  137. GameInputArcadeStickRight = 0x00000020,
  138. GameInputArcadeStickAction1 = 0x00000040,
  139. GameInputArcadeStickAction2 = 0x00000080,
  140. GameInputArcadeStickAction3 = 0x00000100,
  141. GameInputArcadeStickAction4 = 0x00000200,
  142. GameInputArcadeStickAction5 = 0x00000400,
  143. GameInputArcadeStickAction6 = 0x00000800,
  144. GameInputArcadeStickSpecial1 = 0x00001000,
  145. GameInputArcadeStickSpecial2 = 0x00002000
  146. };
  147. DEFINE_ENUM_FLAG_OPERATORS(GameInputArcadeStickButtons)
  148. enum GameInputFlightStickButtons
  149. {
  150. GameInputFlightStickNone = 0x00000000,
  151. GameInputFlightStickMenu = 0x00000001,
  152. GameInputFlightStickView = 0x00000002,
  153. GameInputFlightStickFirePrimary = 0x00000004,
  154. GameInputFlightStickFireSecondary = 0x00000008,
  155. GameInputFlightStickHatSwitchUp = 0x00000010,
  156. GameInputFlightStickHatSwitchDown = 0x00000020,
  157. GameInputFlightStickHatSwitchLeft = 0x00000040,
  158. GameInputFlightStickHatSwitchRight = 0x00000080,
  159. GameInputFlightStickA = 0x00000100,
  160. GameInputFlightStickB = 0x00000200,
  161. GameInputFlightStickX = 0x00000400,
  162. GameInputFlightStickY = 0x00000800,
  163. GameInputFlightStickLeftShoulder = 0x00001000,
  164. GameInputFlightStickRightShoulder = 0x00002000,
  165. };
  166. DEFINE_ENUM_FLAG_OPERATORS(GameInputFlightStickButtons)
  167. enum GameInputGamepadButtons
  168. {
  169. GameInputGamepadNone = 0x00000000,
  170. GameInputGamepadMenu = 0x00000001,
  171. GameInputGamepadView = 0x00000002,
  172. GameInputGamepadA = 0x00000004,
  173. GameInputGamepadB = 0x00000008,
  174. GameInputGamepadC = 0x00004000,
  175. GameInputGamepadX = 0x00000010,
  176. GameInputGamepadY = 0x00000020,
  177. GameInputGamepadZ = 0x00008000,
  178. GameInputGamepadDPadUp = 0x00000040,
  179. GameInputGamepadDPadDown = 0x00000080,
  180. GameInputGamepadDPadLeft = 0x00000100,
  181. GameInputGamepadDPadRight = 0x00000200,
  182. GameInputGamepadLeftShoulder = 0x00000400,
  183. GameInputGamepadRightShoulder = 0x00000800,
  184. GameInputGamepadLeftTriggerButton = 0x00010000,
  185. GameInputGamepadRightTriggerButton = 0x00020000,
  186. GameInputGamepadLeftThumbstick = 0x00001000,
  187. GameInputGamepadLeftThumbstickUp = 0x00040000,
  188. GameInputGamepadLeftThumbstickDown = 0x00080000,
  189. GameInputGamepadLeftThumbstickLeft = 0x00100000,
  190. GameInputGamepadLeftThumbstickRight = 0x00200000,
  191. GameInputGamepadRightThumbstick = 0x00002000,
  192. GameInputGamepadRightThumbstickUp = 0x00400000,
  193. GameInputGamepadRightThumbstickDown = 0x00800000,
  194. GameInputGamepadRightThumbstickLeft = 0x01000000,
  195. GameInputGamepadRightThumbstickRight = 0x02000000,
  196. GameInputGamepadPaddleLeft1 = 0x04000000,
  197. GameInputGamepadPaddleLeft2 = 0x08000000,
  198. GameInputGamepadPaddleRight1 = 0x10000000,
  199. GameInputGamepadPaddleRight2 = 0x20000000,
  200. };
  201. DEFINE_ENUM_FLAG_OPERATORS(GameInputGamepadButtons)
  202. enum GameInputRawDeviceReportKind
  203. {
  204. GameInputRawInputReport = 0,
  205. GameInputRawOutputReport = 1,
  206. };
  207. // Gamepad modules (Groupings of gamepad elements commonly found together)
  208. const GameInputGamepadButtons GameInputGamepadModuleSystemDuo =
  209. GameInputGamepadMenu |
  210. GameInputGamepadView;
  211. const GameInputGamepadButtons GameInputGamepadModuleDpad =
  212. GameInputGamepadDPadUp |
  213. GameInputGamepadDPadDown |
  214. GameInputGamepadDPadLeft |
  215. GameInputGamepadDPadRight;
  216. const GameInputGamepadButtons GameInputGamepadModuleShoulders =
  217. GameInputGamepadLeftShoulder |
  218. GameInputGamepadRightShoulder;
  219. const GameInputGamepadButtons GameInputGamepadModuleTriggers =
  220. GameInputGamepadLeftTriggerButton |
  221. GameInputGamepadRightTriggerButton;
  222. const GameInputGamepadButtons GameInputGamepadModuleThumbsticks =
  223. GameInputGamepadLeftThumbstickUp |
  224. GameInputGamepadLeftThumbstickDown |
  225. GameInputGamepadLeftThumbstickLeft |
  226. GameInputGamepadLeftThumbstickRight |
  227. GameInputGamepadRightThumbstickUp |
  228. GameInputGamepadRightThumbstickDown |
  229. GameInputGamepadRightThumbstickLeft |
  230. GameInputGamepadRightThumbstickRight;
  231. const GameInputGamepadButtons GameInputGamepadModulePaddles2 =
  232. GameInputGamepadPaddleLeft1 |
  233. GameInputGamepadPaddleRight1;
  234. const GameInputGamepadButtons GameInputGamepadModulePaddles4 =
  235. GameInputGamepadPaddleLeft1 |
  236. GameInputGamepadPaddleLeft2 |
  237. GameInputGamepadPaddleRight1 |
  238. GameInputGamepadPaddleRight2;
  239. // Commonly found gamepad layouts. Custom layouts are possible and encouraged.
  240. const GameInputGamepadButtons GameInputGamepadLayoutBasic =
  241. GameInputGamepadModuleSystemDuo |
  242. GameInputGamepadModuleDpad |
  243. GameInputGamepadA |
  244. GameInputGamepadB;
  245. const GameInputGamepadButtons GameInputGamepadLayoutButtons =
  246. GameInputGamepadLayoutBasic |
  247. GameInputGamepadX |
  248. GameInputGamepadY |
  249. GameInputGamepadModuleShoulders;
  250. const GameInputGamepadButtons GameInputGamepadLayoutStandard =
  251. GameInputGamepadLayoutButtons |
  252. GameInputGamepadModuleTriggers |
  253. GameInputGamepadModuleThumbsticks |
  254. GameInputGamepadLeftThumbstick |
  255. GameInputGamepadRightThumbstick;
  256. const GameInputGamepadButtons GameInputGamepadLayoutElite =
  257. GameInputGamepadLayoutStandard |
  258. GameInputGamepadModulePaddles4;
  259. enum GameInputRacingWheelButtons
  260. {
  261. GameInputRacingWheelNone = 0x00000000,
  262. GameInputRacingWheelMenu = 0x00000001,
  263. GameInputRacingWheelView = 0x00000002,
  264. GameInputRacingWheelPreviousGear = 0x00000004,
  265. GameInputRacingWheelNextGear = 0x00000008,
  266. GameInputRacingWheelA = 0x00000100,
  267. GameInputRacingWheelB = 0x00000200,
  268. GameInputRacingWheelX = 0x00000400,
  269. GameInputRacingWheelY = 0x00000800,
  270. GameInputRacingWheelDpadUp = 0x00000010,
  271. GameInputRacingWheelDpadDown = 0x00000020,
  272. GameInputRacingWheelDpadLeft = 0x00000040,
  273. GameInputRacingWheelDpadRight = 0x00000080,
  274. GameInputRacingWheelLeftThumbstick = 0x00001000,
  275. GameInputRacingWheelRightThumbstick = 0x00002000,
  276. };
  277. DEFINE_ENUM_FLAG_OPERATORS(GameInputRacingWheelButtons)
  278. enum GameInputSystemButtons
  279. {
  280. GameInputSystemButtonNone = 0x00000000,
  281. GameInputSystemButtonGuide = 0x00000001,
  282. GameInputSystemButtonShare = 0x00000002
  283. };
  284. DEFINE_ENUM_FLAG_OPERATORS(GameInputSystemButtons)
  285. enum GameInputFlightStickAxes
  286. {
  287. GameInputFlightStickAxesNone = 0x00000000,
  288. GameInputFlightStickRoll = 0x00000010,
  289. GameInputFlightStickPitch = 0x00000020,
  290. GameInputFlightStickYaw = 0x00000040,
  291. GameInputFlightStickThrottle = 0x00000080,
  292. };
  293. DEFINE_ENUM_FLAG_OPERATORS(GameInputFlightStickAxes)
  294. enum GameInputGamepadAxes
  295. {
  296. GameInputGamepadAxesNone = 0x00000000,
  297. GameInputGamepadLeftTrigger = 0x00000001,
  298. GameInputGamepadRightTrigger = 0x00000002,
  299. GameInputGamepadLeftThumbstickX = 0x00000004,
  300. GameInputGamepadLeftThumbstickY = 0x00000008,
  301. GameInputGamepadRightThumbstickX = 0x00000010,
  302. GameInputGamepadRightThumbstickY = 0x00000020,
  303. };
  304. DEFINE_ENUM_FLAG_OPERATORS(GameInputGamepadAxes)
  305. enum GameInputRacingWheelAxes
  306. {
  307. GameInputRacingWheelAxesNone = 0x00000000,
  308. GameInputRacingWheelSteering = 0x00000100,
  309. GameInputRacingWheelThrottle = 0x00000200,
  310. GameInputRacingWheelBrake = 0x00000400,
  311. GameInputRacingWheelClutch = 0x00000800,
  312. GameInputRacingWheelHandbrake = 0x00001000,
  313. GameInputRacingWheelPatternShifter = 0x00002000,
  314. };
  315. DEFINE_ENUM_FLAG_OPERATORS(GameInputRacingWheelAxes)
  316. enum GameInputDeviceStatus
  317. {
  318. GameInputDeviceNoStatus = 0x00000000,
  319. GameInputDeviceConnected = 0x00000001,
  320. GameInputDeviceHapticInfoReady = 0x00200000,
  321. GameInputDeviceAnyStatus = 0xFFFFFFFF
  322. };
  323. DEFINE_ENUM_FLAG_OPERATORS(GameInputDeviceStatus)
  324. enum GameInputDeviceFamily
  325. {
  326. GameInputFamilyVirtual = -1,
  327. GameInputFamilyUnknown = 0,
  328. GameInputFamilyXboxOne = 1,
  329. GameInputFamilyXbox360 = 2,
  330. GameInputFamilyHid = 3,
  331. GameInputFamilyI8042 = 4,
  332. GameInputFamilyAggregate = 5,
  333. };
  334. enum GameInputLabel
  335. {
  336. GameInputLabelUnknown = -1,
  337. GameInputLabelNone = 0,
  338. GameInputLabelXboxGuide = 1,
  339. GameInputLabelXboxBack = 2,
  340. GameInputLabelXboxStart = 3,
  341. GameInputLabelXboxMenu = 4,
  342. GameInputLabelXboxView = 5,
  343. GameInputLabelXboxA = 7,
  344. GameInputLabelXboxB = 8,
  345. GameInputLabelXboxX = 9,
  346. GameInputLabelXboxY = 10,
  347. GameInputLabelXboxDPadUp = 11,
  348. GameInputLabelXboxDPadDown = 12,
  349. GameInputLabelXboxDPadLeft = 13,
  350. GameInputLabelXboxDPadRight = 14,
  351. GameInputLabelXboxLeftShoulder = 15,
  352. GameInputLabelXboxLeftTrigger = 16,
  353. GameInputLabelXboxLeftStickButton = 17,
  354. GameInputLabelXboxRightShoulder = 18,
  355. GameInputLabelXboxRightTrigger = 19,
  356. GameInputLabelXboxRightStickButton = 20,
  357. GameInputLabelXboxPaddle1 = 21,
  358. GameInputLabelXboxPaddle2 = 22,
  359. GameInputLabelXboxPaddle3 = 23,
  360. GameInputLabelXboxPaddle4 = 24,
  361. GameInputLabelLetterA = 25,
  362. GameInputLabelLetterB = 26,
  363. GameInputLabelLetterC = 27,
  364. GameInputLabelLetterD = 28,
  365. GameInputLabelLetterE = 29,
  366. GameInputLabelLetterF = 30,
  367. GameInputLabelLetterG = 31,
  368. GameInputLabelLetterH = 32,
  369. GameInputLabelLetterI = 33,
  370. GameInputLabelLetterJ = 34,
  371. GameInputLabelLetterK = 35,
  372. GameInputLabelLetterL = 36,
  373. GameInputLabelLetterM = 37,
  374. GameInputLabelLetterN = 38,
  375. GameInputLabelLetterO = 39,
  376. GameInputLabelLetterP = 40,
  377. GameInputLabelLetterQ = 41,
  378. GameInputLabelLetterR = 42,
  379. GameInputLabelLetterS = 43,
  380. GameInputLabelLetterT = 44,
  381. GameInputLabelLetterU = 45,
  382. GameInputLabelLetterV = 46,
  383. GameInputLabelLetterW = 47,
  384. GameInputLabelLetterX = 48,
  385. GameInputLabelLetterY = 49,
  386. GameInputLabelLetterZ = 50,
  387. GameInputLabelNumber0 = 51,
  388. GameInputLabelNumber1 = 52,
  389. GameInputLabelNumber2 = 53,
  390. GameInputLabelNumber3 = 54,
  391. GameInputLabelNumber4 = 55,
  392. GameInputLabelNumber5 = 56,
  393. GameInputLabelNumber6 = 57,
  394. GameInputLabelNumber7 = 58,
  395. GameInputLabelNumber8 = 59,
  396. GameInputLabelNumber9 = 60,
  397. GameInputLabelArrowUp = 61,
  398. GameInputLabelArrowUpRight = 62,
  399. GameInputLabelArrowRight = 63,
  400. GameInputLabelArrowDownRight = 64,
  401. GameInputLabelArrowDown = 65,
  402. GameInputLabelArrowDownLLeft = 66,
  403. GameInputLabelArrowLeft = 67,
  404. GameInputLabelArrowUpLeft = 68,
  405. GameInputLabelArrowUpDown = 69,
  406. GameInputLabelArrowLeftRight = 70,
  407. GameInputLabelArrowUpDownLeftRight = 71,
  408. GameInputLabelArrowClockwise = 72,
  409. GameInputLabelArrowCounterClockwise = 73,
  410. GameInputLabelArrowReturn = 74,
  411. GameInputLabelIconBranding = 75,
  412. GameInputLabelIconHome = 76,
  413. GameInputLabelIconMenu = 77,
  414. GameInputLabelIconCross = 78,
  415. GameInputLabelIconCircle = 79,
  416. GameInputLabelIconSquare = 80,
  417. GameInputLabelIconTriangle = 81,
  418. GameInputLabelIconStar = 82,
  419. GameInputLabelIconDPadUp = 83,
  420. GameInputLabelIconDPadDown = 84,
  421. GameInputLabelIconDPadLeft = 85,
  422. GameInputLabelIconDPadRight = 86,
  423. GameInputLabelIconDialClockwise = 87,
  424. GameInputLabelIconDialCounterClockwise = 88,
  425. GameInputLabelIconSliderLeftRight = 89,
  426. GameInputLabelIconSliderUpDown = 90,
  427. GameInputLabelIconWheelUpDown = 91,
  428. GameInputLabelIconPlus = 92,
  429. GameInputLabelIconMinus = 93,
  430. GameInputLabelIconSuspension = 94,
  431. GameInputLabelHome = 95,
  432. GameInputLabelGuide = 96,
  433. GameInputLabelMode = 97,
  434. GameInputLabelSelect = 98,
  435. GameInputLabelMenu = 99,
  436. GameInputLabelView = 100,
  437. GameInputLabelBack = 101,
  438. GameInputLabelStart = 102,
  439. GameInputLabelOptions = 103,
  440. GameInputLabelShare = 104,
  441. GameInputLabelUp = 105,
  442. GameInputLabelDown = 106,
  443. GameInputLabelLeft = 107,
  444. GameInputLabelRight = 108,
  445. GameInputLabelLB = 109,
  446. GameInputLabelLT = 110,
  447. GameInputLabelLSB = 111,
  448. GameInputLabelL1 = 112,
  449. GameInputLabelL2 = 113,
  450. GameInputLabelL3 = 114,
  451. GameInputLabelRB = 115,
  452. GameInputLabelRT = 116,
  453. GameInputLabelRSB = 117,
  454. GameInputLabelR1 = 118,
  455. GameInputLabelR2 = 119,
  456. GameInputLabelR3 = 120,
  457. GameInputLabelPaddleLeft1 = 121,
  458. GameInputLabelPaddleLeft2 = 122,
  459. GameInputLabelPaddleRight1 = 123,
  460. GameInputLabelPaddleRight2 = 124,
  461. };
  462. enum GameInputFeedbackAxes
  463. {
  464. GameInputFeedbackAxisNone = 0x00000000,
  465. GameInputFeedbackAxisLinearX = 0x00000001,
  466. GameInputFeedbackAxisLinearY = 0x00000002,
  467. GameInputFeedbackAxisLinearZ = 0x00000004,
  468. GameInputFeedbackAxisAngularX = 0x00000008,
  469. GameInputFeedbackAxisAngularY = 0x00000010,
  470. GameInputFeedbackAxisAngularZ = 0x00000020,
  471. GameInputFeedbackAxisNormal = 0x00000040
  472. };
  473. DEFINE_ENUM_FLAG_OPERATORS(GameInputFeedbackAxes)
  474. enum GameInputFeedbackEffectState
  475. {
  476. GameInputFeedbackStopped = 0,
  477. GameInputFeedbackRunning = 1,
  478. GameInputFeedbackPaused = 2
  479. };
  480. enum GameInputForceFeedbackEffectKind
  481. {
  482. GameInputForceFeedbackConstant = 0,
  483. GameInputForceFeedbackRamp = 1,
  484. GameInputForceFeedbackSineWave = 2,
  485. GameInputForceFeedbackSquareWave = 3,
  486. GameInputForceFeedbackTriangleWave = 4,
  487. GameInputForceFeedbackSawtoothUpWave = 5,
  488. GameInputForceFeedbackSawtoothDownWave = 6,
  489. GameInputForceFeedbackSpring = 7,
  490. GameInputForceFeedbackFriction = 8,
  491. GameInputForceFeedbackDamper = 9,
  492. GameInputForceFeedbackInertia = 10
  493. };
  494. enum GameInputRumbleMotors
  495. {
  496. GameInputRumbleNone = 0x00000000,
  497. GameInputRumbleLowFrequency = 0x00000001,
  498. GameInputRumbleHighFrequency = 0x00000002,
  499. GameInputRumbleLeftTrigger = 0x00000004,
  500. GameInputRumbleRightTrigger = 0x00000008
  501. };
  502. DEFINE_ENUM_FLAG_OPERATORS(GameInputRumbleMotors)
  503. interface IGameInput;
  504. interface IGameInputReading;
  505. interface IGameInputDevice;
  506. interface IGameInputDispatcher;
  507. interface IGameInputForceFeedbackEffect;
  508. interface IGameInputMapper;
  509. typedef uint64_t GameInputCallbackToken;
  510. constexpr GUID GAMEINPUT_HAPTIC_LOCATION_NONE = { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
  511. constexpr GUID GAMEINPUT_HAPTIC_LOCATION_GRIP_LEFT = { 0x08c707c2, 0x66bb, 0x406c, { 0xa8, 0x4a, 0xdf, 0xe0, 0x85, 0x12, 0x0a, 0x92 } };
  512. constexpr GUID GAMEINPUT_HAPTIC_LOCATION_GRIP_RIGHT = { 0x155a0b77, 0x8bb2, 0x40db, { 0x86, 0x90, 0xb6, 0xd4, 0x11, 0x26, 0xdf, 0xc1 } };
  513. constexpr GUID GAMEINPUT_HAPTIC_LOCATION_TRIGGER_LEFT = { 0x8de4d896, 0x5559, 0x4081, { 0x86, 0xe5, 0x17, 0x24, 0xcc, 0x07, 0xc6, 0xbc } };
  514. constexpr GUID GAMEINPUT_HAPTIC_LOCATION_TRIGGER_RIGHT = { 0xff0cb557, 0x3af5, 0x406b, { 0x8b, 0x0f, 0x55, 0x5a, 0x2d, 0x92, 0xa2, 0x20 } };
  515. const uint32_t GAMEINPUT_HAPTIC_MAX_LOCATIONS = 8;
  516. const uint32_t GAMEINPUT_HAPTIC_MAX_AUDIO_ENDPOINT_ID_SIZE = 256;
  517. typedef void (CALLBACK* GameInputReadingCallback)(
  518. _In_ GameInputCallbackToken callbackToken,
  519. _In_ void* context,
  520. _In_ IGameInputReading* reading);
  521. typedef void (CALLBACK* GameInputDeviceCallback)(
  522. _In_ GameInputCallbackToken callbackToken,
  523. _In_ void* context,
  524. _In_ IGameInputDevice* device,
  525. _In_ uint64_t timestamp,
  526. _In_ GameInputDeviceStatus currentStatus,
  527. _In_ GameInputDeviceStatus previousStatus);
  528. typedef void (CALLBACK* GameInputSystemButtonCallback)(
  529. _In_ GameInputCallbackToken callbackToken,
  530. _In_ void* context,
  531. _In_ IGameInputDevice* device,
  532. _In_ uint64_t timestamp,
  533. _In_ GameInputSystemButtons currentButtons,
  534. _In_ GameInputSystemButtons previousButtons);
  535. typedef void (CALLBACK* GameInputKeyboardLayoutCallback)(
  536. _In_ GameInputCallbackToken callbackToken,
  537. _In_ void* context,
  538. _In_ IGameInputDevice* device,
  539. _In_ uint64_t timestamp,
  540. _In_ uint32_t currentLayout,
  541. _In_ uint32_t previousLayout);
  542. struct GameInputKeyState
  543. {
  544. uint32_t scanCode;
  545. uint32_t codePoint;
  546. uint8_t virtualKey;
  547. bool isDeadKey;
  548. };
  549. struct GameInputMouseState
  550. {
  551. GameInputMouseButtons buttons;
  552. GameInputMousePositions positions;
  553. int64_t positionX;
  554. int64_t positionY;
  555. int64_t absolutePositionX;
  556. int64_t absolutePositionY;
  557. int64_t wheelX;
  558. int64_t wheelY;
  559. };
  560. struct GameInputVersion
  561. {
  562. uint16_t major;
  563. uint16_t minor;
  564. uint16_t build;
  565. uint16_t revision;
  566. };
  567. struct GameInputSensorsState
  568. {
  569. // GameInputSensorsAccelerometer
  570. float accelerationInGX;
  571. float accelerationInGY;
  572. float accelerationInGZ;
  573. // GameInputSensorsGyrometer
  574. float angularVelocityInRadPerSecX;
  575. float angularVelocityInRadPerSecY;
  576. float angularVelocityInRadPerSecZ;
  577. // GameInputSensorsCompass
  578. float headingInDegreesFromMagneticNorth;
  579. GameInputSensorAccuracy headingAccuracy;
  580. // GameInputSensorsOrientation
  581. float orientationW;
  582. float orientationX;
  583. float orientationY;
  584. float orientationZ;
  585. };
  586. struct GameInputArcadeStickState
  587. {
  588. GameInputArcadeStickButtons buttons;
  589. };
  590. struct GameInputFlightStickState
  591. {
  592. GameInputFlightStickButtons buttons;
  593. GameInputSwitchPosition hatSwitch;
  594. float roll;
  595. float pitch;
  596. float yaw;
  597. float throttle;
  598. };
  599. struct GameInputGamepadState
  600. {
  601. GameInputGamepadButtons buttons;
  602. float leftTrigger;
  603. float rightTrigger;
  604. float leftThumbstickX;
  605. float leftThumbstickY;
  606. float rightThumbstickX;
  607. float rightThumbstickY;
  608. };
  609. struct GameInputRacingWheelState
  610. {
  611. GameInputRacingWheelButtons buttons;
  612. int32_t patternShifterGear;
  613. float wheel;
  614. float throttle;
  615. float brake;
  616. float clutch;
  617. float handbrake;
  618. };
  619. struct GameInputUsage
  620. {
  621. uint16_t page;
  622. uint16_t id;
  623. };
  624. const uint32_t GAMEINPUT_MAX_SWITCH_STATES = 8;
  625. struct GameInputControllerSwitchInfo
  626. {
  627. GameInputLabel labels[GAMEINPUT_MAX_SWITCH_STATES];
  628. GameInputSwitchKind kind;
  629. };
  630. struct GameInputControllerInfo
  631. {
  632. uint32_t controllerAxisCount;
  633. _Field_size_full_(controllerAxisCount) const GameInputLabel* controllerAxisLabels;
  634. uint32_t controllerButtonCount;
  635. _Field_size_full_(controllerButtonCount) const GameInputLabel* controllerButtonLabels;
  636. uint32_t controllerSwitchCount;
  637. _Field_size_full_(controllerSwitchCount) const GameInputControllerSwitchInfo* controllerSwitchInfo;
  638. };
  639. struct GameInputKeyboardInfo
  640. {
  641. GameInputKeyboardKind kind;
  642. uint32_t layout;
  643. uint32_t keyCount;
  644. uint32_t functionKeyCount;
  645. uint32_t maxSimultaneousKeys;
  646. uint32_t platformType;
  647. uint32_t platformSubtype;
  648. };
  649. struct GameInputMouseInfo
  650. {
  651. GameInputMouseButtons supportedButtons;
  652. uint32_t sampleRate;
  653. bool hasWheelX;
  654. bool hasWheelY;
  655. };
  656. struct GameInputSensorsInfo
  657. {
  658. GameInputSensorsKind supportedSensors;
  659. };
  660. struct GameInputArcadeStickInfo
  661. {
  662. GameInputLabel menuButtonLabel;
  663. GameInputLabel viewButtonLabel;
  664. GameInputLabel stickUpLabel;
  665. GameInputLabel stickDownLabel;
  666. GameInputLabel stickLeftLabel;
  667. GameInputLabel stickRightLabel;
  668. GameInputLabel actionButton1Label;
  669. GameInputLabel actionButton2Label;
  670. GameInputLabel actionButton3Label;
  671. GameInputLabel actionButton4Label;
  672. GameInputLabel actionButton5Label;
  673. GameInputLabel actionButton6Label;
  674. GameInputLabel specialButton1Label;
  675. GameInputLabel specialButton2Label;
  676. uint32_t extraButtonCount;
  677. uint32_t extraAxisCount;
  678. };
  679. struct GameInputFlightStickInfo
  680. {
  681. GameInputLabel menuButtonLabel;
  682. GameInputLabel viewButtonLabel;
  683. GameInputLabel firePrimaryButtonLabel;
  684. GameInputLabel fireSecondaryButtonLabel;
  685. GameInputLabel hatSwitchUpLabel;
  686. GameInputLabel hatSwitchDownLabel;
  687. GameInputLabel hatSwitchLeftLabel;
  688. GameInputLabel hatSwitchRightLabel;
  689. GameInputLabel aButtonLabel;
  690. GameInputLabel bButtonLabel;
  691. GameInputLabel xButtonLabel;
  692. GameInputLabel yButtonLabel;
  693. GameInputLabel leftShoulderButtonLabel;
  694. GameInputLabel rightShoulderButtonLabel;
  695. uint32_t extraButtonCount;
  696. uint32_t extraAxisCount;
  697. };
  698. struct GameInputGamepadInfo
  699. {
  700. GameInputGamepadButtons supportedLayout;
  701. GameInputLabel menuButtonLabel;
  702. GameInputLabel viewButtonLabel;
  703. GameInputLabel aButtonLabel;
  704. GameInputLabel bButtonLabel;
  705. GameInputLabel cButtonLabel;
  706. GameInputLabel xButtonLabel;
  707. GameInputLabel yButtonLabel;
  708. GameInputLabel zButtonLabel;
  709. GameInputLabel dpadUpLabel;
  710. GameInputLabel dpadDownLabel;
  711. GameInputLabel dpadLeftLabel;
  712. GameInputLabel dpadRightLabel;
  713. GameInputLabel leftShoulderButtonLabel;
  714. GameInputLabel rightShoulderButtonLabel;
  715. GameInputLabel leftThumbstickButtonLabel;
  716. GameInputLabel rightThumbstickButtonLabel;
  717. uint32_t extraButtonCount;
  718. uint32_t extraAxisCount;
  719. };
  720. struct GameInputRacingWheelInfo
  721. {
  722. GameInputLabel menuButtonLabel;
  723. GameInputLabel viewButtonLabel;
  724. GameInputLabel previousGearButtonLabel;
  725. GameInputLabel nextGearButtonLabel;
  726. GameInputLabel dpadUpLabel;
  727. GameInputLabel dpadDownLabel;
  728. GameInputLabel dpadLeftLabel;
  729. GameInputLabel dpadRightLabel;
  730. GameInputLabel aButtonLabel;
  731. GameInputLabel bButtonLabel;
  732. GameInputLabel xButtonLabel;
  733. GameInputLabel yButtonLabel;
  734. GameInputLabel leftThumbstickButtonLabel;
  735. GameInputLabel rightThumbstickButtonLabel;
  736. bool hasClutch;
  737. bool hasHandbrake;
  738. bool hasPatternShifter;
  739. int32_t minPatternShifterGear;
  740. int32_t maxPatternShifterGear;
  741. float maxWheelAngle;
  742. uint32_t extraButtonCount;
  743. uint32_t extraAxisCount;
  744. };
  745. struct GameInputForceFeedbackMotorInfo
  746. {
  747. GameInputFeedbackAxes supportedAxes;
  748. bool isConstantEffectSupported;
  749. bool isRampEffectSupported;
  750. bool isSineWaveEffectSupported;
  751. bool isSquareWaveEffectSupported;
  752. bool isTriangleWaveEffectSupported;
  753. bool isSawtoothUpWaveEffectSupported;
  754. bool isSawtoothDownWaveEffectSupported;
  755. bool isSpringEffectSupported;
  756. bool isFrictionEffectSupported;
  757. bool isDamperEffectSupported;
  758. bool isInertiaEffectSupported;
  759. };
  760. struct GameInputRawDeviceReportInfo
  761. {
  762. GameInputRawDeviceReportKind kind;
  763. uint32_t id;
  764. uint32_t size;
  765. };
  766. struct GameInputDeviceInfo
  767. {
  768. uint16_t vendorId;
  769. uint16_t productId;
  770. uint16_t revisionNumber;
  771. GameInputUsage usage;
  772. GameInputVersion hardwareVersion;
  773. GameInputVersion firmwareVersion;
  774. APP_LOCAL_DEVICE_ID deviceId;
  775. APP_LOCAL_DEVICE_ID deviceRootId;
  776. GameInputDeviceFamily deviceFamily;
  777. GameInputKind supportedInput;
  778. GameInputRumbleMotors supportedRumbleMotors;
  779. GameInputSystemButtons supportedSystemButtons;
  780. GUID containerId;
  781. const char* displayName;
  782. const char* pnpPath;
  783. _Field_size_full_opt_(1) const GameInputKeyboardInfo* keyboardInfo;
  784. _Field_size_full_opt_(1) const GameInputMouseInfo* mouseInfo;
  785. _Field_size_full_opt_(1) const GameInputSensorsInfo* sensorsInfo;
  786. _Field_size_full_opt_(1) const GameInputControllerInfo* controllerInfo;
  787. _Field_size_full_opt_(1) const GameInputArcadeStickInfo* arcadeStickInfo;
  788. _Field_size_full_opt_(1) const GameInputFlightStickInfo* flightStickInfo;
  789. _Field_size_full_opt_(1) const GameInputGamepadInfo* gamepadInfo;
  790. _Field_size_full_opt_(1) const GameInputRacingWheelInfo* racingWheelInfo;
  791. uint32_t forceFeedbackMotorCount;
  792. _Field_size_full_(forceFeedbackMotorCount) const GameInputForceFeedbackMotorInfo* forceFeedbackMotorInfo;
  793. uint32_t inputReportCount;
  794. _Field_size_full_opt_(inputReportCount) const GameInputRawDeviceReportInfo* inputReportInfo;
  795. uint32_t outputReportCount;
  796. _Field_size_full_opt_(outputReportCount) const GameInputRawDeviceReportInfo* outputReportInfo;
  797. };
  798. struct GameInputHapticInfo
  799. {
  800. _Field_z_ wchar_t audioEndpointId[GAMEINPUT_HAPTIC_MAX_AUDIO_ENDPOINT_ID_SIZE];
  801. _Field_range_(1, GAMEINPUT_HAPTIC_MAX_LOCATIONS) uint32_t locationCount;
  802. _Field_size_full_(locationCount) GUID locations[GAMEINPUT_HAPTIC_MAX_LOCATIONS];
  803. };
  804. struct GameInputForceFeedbackEnvelope
  805. {
  806. uint64_t attackDuration;
  807. uint64_t sustainDuration;
  808. uint64_t releaseDuration;
  809. float attackGain;
  810. float sustainGain;
  811. float releaseGain;
  812. uint32_t playCount;
  813. uint64_t repeatDelay;
  814. };
  815. struct GameInputForceFeedbackMagnitude
  816. {
  817. float linearX;
  818. float linearY;
  819. float linearZ;
  820. float angularX;
  821. float angularY;
  822. float angularZ;
  823. float normal;
  824. };
  825. struct GameInputForceFeedbackConditionParams
  826. {
  827. GameInputForceFeedbackMagnitude magnitude;
  828. float positiveCoefficient;
  829. float negativeCoefficient;
  830. float maxPositiveMagnitude;
  831. float maxNegativeMagnitude;
  832. float deadZone;
  833. float bias;
  834. };
  835. struct GameInputForceFeedbackConstantParams
  836. {
  837. GameInputForceFeedbackEnvelope envelope;
  838. GameInputForceFeedbackMagnitude magnitude;
  839. };
  840. struct GameInputForceFeedbackPeriodicParams
  841. {
  842. GameInputForceFeedbackEnvelope envelope;
  843. GameInputForceFeedbackMagnitude magnitude;
  844. float frequency;
  845. float phase;
  846. float bias;
  847. };
  848. struct GameInputForceFeedbackRampParams
  849. {
  850. GameInputForceFeedbackEnvelope envelope;
  851. GameInputForceFeedbackMagnitude startMagnitude;
  852. GameInputForceFeedbackMagnitude endMagnitude;
  853. };
  854. struct GameInputForceFeedbackParams
  855. {
  856. GameInputForceFeedbackEffectKind kind;
  857. union
  858. {
  859. GameInputForceFeedbackConstantParams constant;
  860. GameInputForceFeedbackRampParams ramp;
  861. GameInputForceFeedbackPeriodicParams sineWave;
  862. GameInputForceFeedbackPeriodicParams squareWave;
  863. GameInputForceFeedbackPeriodicParams triangleWave;
  864. GameInputForceFeedbackPeriodicParams sawtoothUpWave;
  865. GameInputForceFeedbackPeriodicParams sawtoothDownWave;
  866. GameInputForceFeedbackConditionParams spring;
  867. GameInputForceFeedbackConditionParams friction;
  868. GameInputForceFeedbackConditionParams damper;
  869. GameInputForceFeedbackConditionParams inertia;
  870. } data;
  871. };
  872. struct GameInputRumbleParams
  873. {
  874. float lowFrequency;
  875. float highFrequency;
  876. float leftTrigger;
  877. float rightTrigger;
  878. };
  879. enum GameInputElementKind
  880. {
  881. GameInputElementKindNone = 0,
  882. GameInputElementKindAxis = 1,
  883. GameInputElementKindButton = 2,
  884. GameInputElementKindSwitch = 3
  885. };
  886. struct GameInputAxisMapping
  887. {
  888. GameInputElementKind controllerElementKind;
  889. uint32_t controllerIndex;
  890. // When axis is mapped from a axis
  891. bool isInverted;
  892. // When the axis is mapped from a button
  893. bool fromTwoButtons;
  894. uint32_t buttonMinIndexValue;
  895. // When the axis is mapped from a switch
  896. GameInputSwitchPosition referenceDirection;
  897. };
  898. struct GameInputButtonMapping
  899. {
  900. GameInputElementKind controllerElementKind;
  901. uint32_t controllerIndex;
  902. // When the button is mapped from an axis
  903. bool isInverted;
  904. // Button mapped from button only needs the index
  905. // When the button is mapped from a switch
  906. GameInputSwitchPosition switchPosition;
  907. };
  908. const IID IID_IGameInput = {0x20efc1c7, 0x5d9a, 0x43ba, {0xb2, 0x6f, 0xb8, 0x07, 0xfa, 0x48, 0x60, 0x9c}};
  909. DECLARE_INTERFACE_IID_(IGameInput, IUnknown, "20EFC1C7-5D9A-43BA-B26F-B807FA48609C")
  910. {
  911. IFACEMETHOD_(uint64_t, GetCurrentTimestamp)() PURE;
  912. IFACEMETHOD(GetCurrentReading)(
  913. _In_ GameInputKind inputKind,
  914. _In_opt_ IGameInputDevice* device,
  915. _COM_Outptr_ IGameInputReading** reading) PURE;
  916. IFACEMETHOD(GetNextReading)(
  917. _In_ IGameInputReading* referenceReading,
  918. _In_ GameInputKind inputKind,
  919. _In_opt_ IGameInputDevice* device,
  920. _COM_Outptr_ IGameInputReading** reading) PURE;
  921. IFACEMETHOD(GetPreviousReading)(
  922. _In_ IGameInputReading* referenceReading,
  923. _In_ GameInputKind inputKind,
  924. _In_opt_ IGameInputDevice* device,
  925. _COM_Outptr_ IGameInputReading** reading) PURE;
  926. IFACEMETHOD(RegisterReadingCallback)(
  927. _In_opt_ IGameInputDevice* device,
  928. _In_ GameInputKind inputKind,
  929. _In_opt_ void* context,
  930. _In_ GameInputReadingCallback callbackFunc,
  931. _Out_opt_ _Result_zeroonfailure_ GameInputCallbackToken* callbackToken) PURE;
  932. IFACEMETHOD(RegisterDeviceCallback)(
  933. _In_opt_ IGameInputDevice* device,
  934. _In_ GameInputKind inputKind,
  935. _In_ GameInputDeviceStatus statusFilter,
  936. _In_ GameInputEnumerationKind enumerationKind,
  937. _In_opt_ void* context,
  938. _In_ GameInputDeviceCallback callbackFunc,
  939. _Out_opt_ _Result_zeroonfailure_ GameInputCallbackToken* callbackToken) PURE;
  940. IFACEMETHOD(RegisterSystemButtonCallback)(
  941. _In_opt_ IGameInputDevice* device,
  942. _In_ GameInputSystemButtons buttonFilter,
  943. _In_opt_ void* context,
  944. _In_ GameInputSystemButtonCallback callbackFunc,
  945. _Out_opt_ _Result_zeroonfailure_ GameInputCallbackToken* callbackToken) PURE;
  946. IFACEMETHOD(RegisterKeyboardLayoutCallback)(
  947. _In_opt_ IGameInputDevice* device,
  948. _In_opt_ void* context,
  949. _In_ GameInputKeyboardLayoutCallback callbackFunc,
  950. _Out_opt_ _Result_zeroonfailure_ GameInputCallbackToken* callbackToken) PURE;
  951. IFACEMETHOD_(void, StopCallback)(
  952. _In_ GameInputCallbackToken callbackToken) PURE;
  953. IFACEMETHOD_(bool, UnregisterCallback)(
  954. _In_ GameInputCallbackToken callbackToken) PURE;
  955. IFACEMETHOD(CreateDispatcher)(
  956. _COM_Outptr_ IGameInputDispatcher** dispatcher) PURE;
  957. IFACEMETHOD(FindDeviceFromId)(
  958. _In_ const APP_LOCAL_DEVICE_ID* value,
  959. _COM_Outptr_ IGameInputDevice** device) PURE;
  960. IFACEMETHOD(FindDeviceFromPlatformString)(
  961. _In_ LPCWSTR value,
  962. _COM_Outptr_ IGameInputDevice** device) PURE;
  963. IFACEMETHOD_(void, SetFocusPolicy)(
  964. _In_ GameInputFocusPolicy policy) PURE;
  965. IFACEMETHOD(CreateAggregateDevice)(
  966. _In_ GameInputKind inputKind,
  967. _Out_ APP_LOCAL_DEVICE_ID* deviceId) PURE;
  968. IFACEMETHOD(DisableAggregateDevice)(
  969. _In_ const APP_LOCAL_DEVICE_ID* deviceId) PURE;
  970. };
  971. DECLARE_INTERFACE_IID_(IGameInputRawDeviceReport, IUnknown, "05A42D89-2CB6-45A3-874D-E635723587AB")
  972. {
  973. IFACEMETHOD_(void, GetDevice)(
  974. _Outptr_ IGameInputDevice** device) PURE;
  975. IFACEMETHOD_(void, GetReportInfo)(
  976. _Out_ GameInputRawDeviceReportInfo* reportInfo) PURE;
  977. IFACEMETHOD_(size_t, GetRawDataSize)() PURE;
  978. IFACEMETHOD_(size_t, GetRawData)(
  979. _In_ size_t bufferSize,
  980. _Out_writes_(bufferSize) void* buffer) PURE;
  981. IFACEMETHOD_(bool, SetRawData)(
  982. _In_ size_t bufferSize,
  983. _In_reads_(bufferSize) const void* buffer) PURE;
  984. };
  985. DECLARE_INTERFACE_IID_(IGameInputReading, IUnknown, "C81C4CDE-ED1A-4631-A30F-C556A6241A1F")
  986. {
  987. IFACEMETHOD_(GameInputKind, GetInputKind)() PURE;
  988. IFACEMETHOD_(uint64_t, GetTimestamp)() PURE;
  989. IFACEMETHOD_(void, GetDevice)(
  990. _Outptr_ IGameInputDevice** device) PURE;
  991. IFACEMETHOD_(uint32_t, GetControllerAxisCount)() PURE;
  992. IFACEMETHOD_(uint32_t, GetControllerAxisState)(
  993. _In_ uint32_t stateArrayCount,
  994. _Out_writes_(stateArrayCount) float* stateArray) PURE;
  995. IFACEMETHOD_(uint32_t, GetControllerButtonCount)() PURE;
  996. IFACEMETHOD_(uint32_t, GetControllerButtonState)(
  997. _In_ uint32_t stateArrayCount,
  998. _Out_writes_(stateArrayCount) bool* stateArray) PURE;
  999. IFACEMETHOD_(uint32_t, GetControllerSwitchCount)() PURE;
  1000. IFACEMETHOD_(uint32_t, GetControllerSwitchState)(
  1001. _In_ uint32_t stateArrayCount,
  1002. _Out_writes_(stateArrayCount) GameInputSwitchPosition* stateArray) PURE;
  1003. IFACEMETHOD_(uint32_t, GetKeyCount)() PURE;
  1004. IFACEMETHOD_(uint32_t, GetKeyState)(
  1005. _In_ uint32_t stateArrayCount,
  1006. _Out_writes_(stateArrayCount) GameInputKeyState* stateArray) PURE;
  1007. IFACEMETHOD_(bool, GetMouseState)(
  1008. _Out_ GameInputMouseState* state) PURE;
  1009. IFACEMETHOD_(bool, GetSensorsState)(
  1010. _Out_ GameInputSensorsState* state) PURE;
  1011. IFACEMETHOD_(bool, GetArcadeStickState)(
  1012. _Out_ GameInputArcadeStickState* state) PURE;
  1013. IFACEMETHOD_(bool, GetFlightStickState)(
  1014. _Out_ GameInputFlightStickState* state) PURE;
  1015. IFACEMETHOD_(bool, GetGamepadState)(
  1016. _Out_ GameInputGamepadState* state) PURE;
  1017. IFACEMETHOD_(bool, GetRacingWheelState)(
  1018. _Out_ GameInputRacingWheelState* state) PURE;
  1019. IFACEMETHOD_(bool, GetRawReport)(
  1020. _Outptr_result_maybenull_ IGameInputRawDeviceReport** report) PURE;
  1021. };
  1022. DECLARE_INTERFACE_IID_(IGameInputDevice, IUnknown, "63E2F38B-A399-4275-8AE7-D4C6E524D12A")
  1023. {
  1024. IFACEMETHOD(GetDeviceInfo)(
  1025. _Outptr_ const GameInputDeviceInfo** info) PURE;
  1026. IFACEMETHOD(GetHapticInfo)(
  1027. _Out_ GameInputHapticInfo* info) PURE;
  1028. IFACEMETHOD_(GameInputDeviceStatus, GetDeviceStatus)() PURE;
  1029. IFACEMETHOD(CreateForceFeedbackEffect)(
  1030. _In_ uint32_t motorIndex,
  1031. _In_ const GameInputForceFeedbackParams* params,
  1032. _COM_Outptr_ IGameInputForceFeedbackEffect** effect) PURE;
  1033. IFACEMETHOD_(bool, IsForceFeedbackMotorPoweredOn)(
  1034. _In_ uint32_t motorIndex) PURE;
  1035. IFACEMETHOD_(void, SetForceFeedbackMotorGain)(
  1036. _In_ uint32_t motorIndex,
  1037. _In_ float masterGain) PURE;
  1038. IFACEMETHOD_(void, SetRumbleState)(
  1039. _In_opt_ const GameInputRumbleParams* params) PURE;
  1040. IFACEMETHOD(DirectInputEscape)(
  1041. _In_ uint32_t command,
  1042. _In_reads_bytes_(bufferInSize) const void* bufferIn,
  1043. _In_ uint32_t bufferInSize,
  1044. _Out_writes_bytes_(bufferOutSize) void* bufferOut,
  1045. _In_ uint32_t bufferOutSize,
  1046. _Out_opt_ uint32_t* bufferOutSizeWritten) PURE;
  1047. IFACEMETHOD(CreateInputMapper)(
  1048. _COM_Outptr_ IGameInputMapper** inputMapper) PURE;
  1049. IFACEMETHOD(GetExtraAxisCount)(
  1050. _In_ GameInputKind inputKind,
  1051. _Out_ uint32_t* extraAxisCount) PURE;
  1052. IFACEMETHOD(GetExtraButtonCount)(
  1053. _In_ GameInputKind inputKind,
  1054. _Out_ uint32_t* extraButtonCount) PURE;
  1055. IFACEMETHOD(GetExtraAxisIndexes)(
  1056. _In_ GameInputKind inputKind,
  1057. _In_ uint32_t extraAxisCount,
  1058. _Out_writes_(extraAxisCount) uint8_t* extraAxisIndexes) PURE;
  1059. IFACEMETHOD(GetExtraButtonIndexes)(
  1060. _In_ GameInputKind inputKind,
  1061. _In_ uint32_t extraButtonCount,
  1062. _Out_writes_(extraButtonCount) uint8_t* extraButtonIndexes) PURE;
  1063. IFACEMETHOD(CreateRawDeviceReport)(
  1064. _In_ uint32_t reportId,
  1065. _In_ GameInputRawDeviceReportKind reportKind,
  1066. _COM_Outptr_ IGameInputRawDeviceReport** report) PURE;
  1067. IFACEMETHOD(SendRawDeviceOutput)(
  1068. _In_ IGameInputRawDeviceReport* report) PURE;
  1069. };
  1070. DECLARE_INTERFACE_IID_(IGameInputDispatcher, IUnknown, "415EED2E-98CB-42C2-8F28-B94601074E31")
  1071. {
  1072. IFACEMETHOD_(bool, Dispatch)(
  1073. _In_ uint64_t quotaInMicroseconds) PURE;
  1074. IFACEMETHOD(OpenWaitHandle)(
  1075. _Outptr_result_nullonfailure_ HANDLE* waitHandle) PURE;
  1076. };
  1077. DECLARE_INTERFACE_IID_(IGameInputForceFeedbackEffect, IUnknown, "FF61096A-3373-4093-A1DF-6D31846B3511")
  1078. {
  1079. IFACEMETHOD_(void, GetDevice)(
  1080. _Outptr_ IGameInputDevice** device) PURE;
  1081. IFACEMETHOD_(uint32_t, GetMotorIndex)() PURE;
  1082. IFACEMETHOD_(float, GetGain)() PURE;
  1083. IFACEMETHOD_(void, SetGain)(
  1084. _In_ float gain) PURE;
  1085. IFACEMETHOD_(void, GetParams)(
  1086. _Out_ GameInputForceFeedbackParams* params) PURE;
  1087. IFACEMETHOD_(bool, SetParams)(
  1088. _In_ const GameInputForceFeedbackParams* params) PURE;
  1089. IFACEMETHOD_(GameInputFeedbackEffectState, GetState)() PURE;
  1090. IFACEMETHOD_(void, SetState)(
  1091. _In_ GameInputFeedbackEffectState state) PURE;
  1092. };
  1093. DECLARE_INTERFACE_IID_(IGameInputMapper, IUnknown, "3C600700-F16C-49CE-9BE6-6A2EF752ED5E")
  1094. {
  1095. IFACEMETHOD_(bool, GetArcadeStickButtonMappingInfo)(
  1096. _In_ GameInputArcadeStickButtons buttonElement,
  1097. _Out_ GameInputButtonMapping* mapping) PURE;
  1098. IFACEMETHOD_(bool, GetFlightStickAxisMappingInfo)(
  1099. _In_ GameInputFlightStickAxes axisElement,
  1100. _Out_ GameInputAxisMapping* mapping) PURE;
  1101. IFACEMETHOD_(bool, GetFlightStickButtonMappingInfo)(
  1102. _In_ GameInputFlightStickButtons buttonElement,
  1103. _Out_ GameInputButtonMapping* mapping) PURE;
  1104. IFACEMETHOD_(bool, GetGamepadAxisMappingInfo)(
  1105. _In_ GameInputGamepadAxes axisElement,
  1106. _Out_ GameInputAxisMapping* mapping) PURE;
  1107. IFACEMETHOD_(bool, GetGamepadButtonMappingInfo)(
  1108. _In_ GameInputGamepadButtons buttonElement,
  1109. _Out_ GameInputButtonMapping* mapping) PURE;
  1110. IFACEMETHOD_(bool, GetRacingWheelAxisMappingInfo)(
  1111. _In_ GameInputRacingWheelAxes axisElement,
  1112. _Out_ GameInputAxisMapping* mapping) PURE;
  1113. IFACEMETHOD_(bool, GetRacingWheelButtonMappingInfo)(
  1114. _In_ GameInputRacingWheelButtons buttonElement,
  1115. _Out_ GameInputButtonMapping* mapping) PURE;
  1116. };
  1117. STDAPI GameInputInitialize(
  1118. _In_ REFIID riid,
  1119. _COM_Outptr_ LPVOID* ppv);
  1120. inline HRESULT GameInputCreate(
  1121. _COM_Outptr_ IGameInput** gameInput)
  1122. {
  1123. return GameInputInitialize(
  1124. IID_IGameInput,
  1125. reinterpret_cast<void**>(gameInput));
  1126. }
  1127. const LONG GAMEINPUT_FACILITY = 0x38A;
  1128. const HRESULT GAMEINPUT_E_DEVICE_DISCONNECTED = _HRESULT_TYPEDEF_(0x838A0001L);
  1129. const HRESULT GAMEINPUT_E_DEVICE_NOT_FOUND = _HRESULT_TYPEDEF_(0x838A0002L);
  1130. const HRESULT GAMEINPUT_E_READING_NOT_FOUND = _HRESULT_TYPEDEF_(0x838A0003L);
  1131. const HRESULT GAMEINPUT_E_REFERENCE_READING_TOO_OLD = _HRESULT_TYPEDEF_(0x838A0004L);
  1132. const HRESULT GAMEINPUT_E_FEEDBACK_NOT_SUPPORTED = _HRESULT_TYPEDEF_(0x838A0007L);
  1133. const HRESULT GAMEINPUT_E_OBJECT_NO_LONGER_EXISTS = _HRESULT_TYPEDEF_(0x838A0008L);
  1134. const HRESULT GAMEINPUT_E_CALLBACK_NOT_FOUND = _HRESULT_TYPEDEF_(0x838A0009L);
  1135. const HRESULT GAMEINPUT_E_HAPTIC_INFO_NOT_FOUND = _HRESULT_TYPEDEF_(0x838A000AL);
  1136. const HRESULT GAMEINPUT_E_AGGREGATE_OPERATION_NOT_SUPPORTED = _HRESULT_TYPEDEF_(0x838A000BL);
  1137. const HRESULT GAMEINPUT_E_INPUT_KIND_NOT_PRESENT = _HRESULT_TYPEDEF_(0x838A000CL);
  1138. }} // namespace GameInput::v3
  1139. #endif // #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
  1140. #pragma endregion // Application Family or OneCore Family or Games Family