Input.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System.Runtime.CompilerServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Input
  7. * @{
  8. */
  9. /// <summary>
  10. /// Contains data about a button input event.
  11. /// </summary>
  12. public struct ButtonEvent
  13. {
  14. internal ButtonCode buttonCode;
  15. internal int deviceIdx;
  16. internal bool isUsed;
  17. /// <summary>
  18. /// Creates a new button input event. For runtime use only.
  19. /// </summary>
  20. /// <param name="buttonCode">Button code this event is referring to.</param>
  21. /// <param name="deviceIdx">Index of the device that the event originated from.</param>
  22. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  23. internal ButtonEvent(ButtonCode buttonCode, int deviceIdx, bool isUsed)
  24. {
  25. this.buttonCode = buttonCode;
  26. this.deviceIdx = deviceIdx;
  27. this.isUsed = isUsed;
  28. }
  29. /// <summary>
  30. /// Button code this event is referring to.
  31. /// </summary>
  32. public ButtonCode Button { get { return buttonCode; } }
  33. /// <summary>
  34. /// Index of the device that the event originated from.
  35. /// </summary>
  36. public int DeviceIndex { get { return deviceIdx; } }
  37. /// <summary>
  38. /// Query is the pressed button a keyboard button.
  39. /// </summary>
  40. public bool IsKeyboard { get { return ((int)buttonCode & 0xC0000000) == 0; }}
  41. /// <summary>
  42. /// Query is the pressed button a mouse button.
  43. /// </summary>
  44. public bool IsMouse { get { return ((int)buttonCode & 0x80000000) != 0; } }
  45. /// <summary>
  46. /// Query is the pressed button a gamepad button.
  47. /// </summary>
  48. public bool IsGamepad { get { return ((int)buttonCode & 0x40000000) != 0; } }
  49. /// <summary>
  50. /// Returns true if the event was handled previously by some internal system (like GUI).
  51. /// </summary>
  52. public bool IsUsed { get { return isUsed; } }
  53. };
  54. /// <summary>
  55. /// Pointer buttons. Generally these correspond to mouse buttons, but may be used in some form for touch input as well.
  56. /// </summary>
  57. public enum PointerButton // Note: Must match C++ enum PointerEventButton
  58. {
  59. Left, Middle, Right, Count
  60. };
  61. /// <summary>
  62. /// Event that gets sent out when user interacts with the screen in some way, usually by moving the mouse cursor or
  63. /// using touch input.
  64. /// </summary>
  65. public struct PointerEvent
  66. {
  67. internal Vector2I screenPos;
  68. internal Vector2I delta;
  69. internal PointerButton button;
  70. internal bool shift;
  71. internal bool control;
  72. internal bool alt;
  73. internal float mouseWheelScrollAmount;
  74. internal bool isUsed;
  75. /// <summary>
  76. /// Creates a new pointer event. For runtime use only.
  77. /// </summary>
  78. /// <param name="screenPos">Screen position where the input event occurred.</param>
  79. /// <param name="delta">Change in movement since last sent event.</param>
  80. /// <param name="button">Button that triggered the pointer event. Might be irrelevant depending on event type.
  81. /// (for example move events don't correspond to a button.</param>
  82. /// <param name="shift">Is shift button on the keyboard being held down.</param>
  83. /// <param name="control">Is control button on the keyboard being held down.</param>
  84. /// <param name="alt">Is alt button on the keyboard being held down.</param>
  85. /// <param name="mouseWheelScrollAmount">If mouse wheel is being scrolled, what is the amount. Only relevant for
  86. /// move events.</param>
  87. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  88. internal PointerEvent(Vector2I screenPos, Vector2I delta, PointerButton button,
  89. bool shift, bool control, bool alt, float mouseWheelScrollAmount, bool isUsed)
  90. {
  91. this.screenPos = screenPos;
  92. this.delta = delta;
  93. this.button = button;
  94. this.shift = shift;
  95. this.control = control;
  96. this.alt = alt;
  97. this.mouseWheelScrollAmount = mouseWheelScrollAmount;
  98. this.isUsed = isUsed;
  99. }
  100. /// <summary>
  101. /// Screen position where the input event occurred.
  102. /// </summary>
  103. public Vector2I ScreenPos { get { return screenPos; } }
  104. /// <summary>
  105. /// Change in movement since last sent event.
  106. /// </summary>
  107. public Vector2I Delta { get { return delta; } }
  108. /// <summary>
  109. /// Button that triggered the pointer event. Might be irrelevant depending on event type.
  110. /// (for example move events don't correspond to a button.
  111. /// </summary>
  112. public PointerButton Button { get { return button; } }
  113. /// <summary>
  114. /// Is shift button on the keyboard being held down.
  115. /// </summary>
  116. public bool Shift { get { return shift; } }
  117. /// <summary>
  118. /// Is control button on the keyboard being held down.
  119. /// </summary>
  120. public bool Control { get { return control; } }
  121. /// <summary>
  122. /// Is alt button on the keyboard being held down.
  123. /// </summary>
  124. public bool Alt { get { return alt; } }
  125. /// <summary>
  126. /// If mouse wheel is being scrolled, what is the amount. Only relevant for move events.
  127. /// </summary>
  128. public float ScrollAmount { get { return mouseWheelScrollAmount; } }
  129. /// <summary>
  130. /// Returns true if the event was handled previously by some internal system (like GUI).
  131. /// </summary>
  132. public bool IsUsed { get { return isUsed; } }
  133. }
  134. /// <summary>
  135. /// Event that gets sent out when user inputs some text. These events may be preceeded by normal button events if user
  136. /// is typing on a keyboard.
  137. /// </summary>
  138. public struct TextInputEvent
  139. {
  140. internal int textChar;
  141. internal bool isUsed;
  142. /// <summary>
  143. /// Creates a new text input event. For runtime use only.
  144. /// </summary>
  145. /// <param name="textChar">Character the that was input.</param>
  146. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  147. internal TextInputEvent(int textChar, bool isUsed)
  148. {
  149. this.textChar = textChar;
  150. this.isUsed = isUsed;
  151. }
  152. /// <summary>
  153. /// Character the that was input.
  154. /// </summary>
  155. public int Char { get { return textChar; } }
  156. /// <summary>
  157. /// Returns true if the event was handled previously by some internal system (like GUI).
  158. /// </summary>
  159. public bool IsUsed { get { return isUsed; } }
  160. }
  161. /// <summary>
  162. /// Allows you to query and receive events from all connected input devices.
  163. /// </summary>
  164. public static class Input
  165. {
  166. public delegate void ButtonEventDelegate(ButtonEvent ev);
  167. public delegate void TextInputEventDelegate(TextInputEvent ev);
  168. public delegate void PointerEventDelegate(PointerEvent ev);
  169. /// <summary>
  170. /// Triggered when a button on any device is pressed.
  171. /// </summary>
  172. public static event ButtonEventDelegate OnButtonDown;
  173. /// <summary>
  174. /// Triggered when a button on any device is released.
  175. /// </summary>
  176. public static event ButtonEventDelegate OnButtonUp;
  177. /// <summary>
  178. /// Triggered when a textual character is entered.
  179. /// </summary>
  180. public static event TextInputEventDelegate OnCharInput;
  181. /// <summary>
  182. /// Triggered when the pointing device (mouse, touch) is moved.
  183. /// </summary>
  184. public static event PointerEventDelegate OnPointerMoved;
  185. /// <summary>
  186. /// Triggered when a button on the pointing device (mouse, touch) is pressed.
  187. /// </summary>
  188. public static event PointerEventDelegate OnPointerPressed;
  189. /// <summary>
  190. /// Triggered when a button on the pointing device (mouse, touch) is released.
  191. /// </summary>
  192. public static event PointerEventDelegate OnPointerReleased;
  193. /// <summary>
  194. /// Triggered when a button on the pointing device (mouse, touch) is pressed twice in rapid succession.
  195. /// </summary>
  196. public static event PointerEventDelegate OnPointerDoubleClick;
  197. /// <summary>
  198. /// Returns value of the specified input axis.
  199. /// </summary>
  200. /// <param name="axis">Type of axis to query.</param>
  201. /// <param name="deviceIdx">Index of the device in case more than one is hooked up (0 - primary).</param>
  202. /// <returns>Value of the axis in range [-1.0, 1.0]. Canan be outside the range for devices with unbound axes
  203. /// (for example mouse).</returns>
  204. public static float GetAxisValue(InputAxis axis, int deviceIdx = 0)
  205. {
  206. return Internal_GetAxisValue(axis, deviceIdx);
  207. }
  208. /// <summary>
  209. /// Query if the provided button is currently being held (true for every frame the button is held for).
  210. /// </summary>
  211. /// <param name="code">Code of the button to query.</param>
  212. /// <param name="deviceIdx">Device to query the button on (0 - primary).</param>
  213. /// <returns>True if the button is held.</returns>
  214. public static bool IsButtonHeld(ButtonCode code, int deviceIdx = 0)
  215. {
  216. return Internal_IsButtonHeld(code, deviceIdx);
  217. }
  218. /// <summary>
  219. /// Query if the provided button is currently being released (only true for one frame).
  220. /// </summary>
  221. /// <param name="code">Code of the button to query.</param>
  222. /// <param name="deviceIdx">Device to query the button on (0 - primary).</param>
  223. /// <returns>True if the button is being released.</returns>
  224. public static bool IsButtonUp(ButtonCode code, int deviceIdx = 0)
  225. {
  226. return Internal_IsButtonUp(code, deviceIdx);
  227. }
  228. /// <summary>
  229. /// Query if the provided button is currently being pressed (only true for one frame).
  230. /// </summary>
  231. /// <param name="code">Code of the button to query.</param>
  232. /// <param name="deviceIdx">Device to query the button on (0 - primary).</param>
  233. /// <returns>True if the button is being pressed.</returns>
  234. public static bool IsButtonDown(ButtonCode code, int deviceIdx = 0)
  235. {
  236. return Internal_IsButtonDown(code, deviceIdx);
  237. }
  238. /// <summary>
  239. /// Query if the provided pointer button is currently being held (true for every frame the button is held for).
  240. /// </summary>
  241. /// <param name="code">Code of the button to query.</param>
  242. /// <returns>True if the button is being held.</returns>
  243. public static bool IsPointerButtonHeld(PointerButton code)
  244. {
  245. return Internal_IsPointerButtonHeld(code);
  246. }
  247. /// <summary>
  248. /// Query if the provided pointer button is currently being being released (only true for one frame).
  249. /// </summary>
  250. /// <param name="code">Code of the button to query.</param>
  251. /// <returns>True if the button is being released.</returns>
  252. public static bool IsPointerButtonUp(PointerButton code)
  253. {
  254. return Internal_IsPointerButtonUp(code);
  255. }
  256. /// <summary>
  257. /// Query if the provided pointer button is currently being being pressed (only true for one frame).
  258. /// </summary>
  259. /// <param name="code">Code of the button to query.</param>
  260. /// <returns>True if the button is being pressed.</returns>
  261. public static bool IsPointerButtonDown(PointerButton code)
  262. {
  263. return Internal_IsPointerButtonDown(code);
  264. }
  265. /// <summary>
  266. /// Query has the left pointer button been double-clicked this frame.
  267. /// </summary>
  268. /// <returns>True if double-click occurred.</returns>
  269. public static bool IsPointerDoubleClicked()
  270. {
  271. return Internal_IsPointerDoubleClicked();
  272. }
  273. /// <summary>
  274. /// Returns position of the pointer (for example mouse cursor) relative to the screen.
  275. /// </summary>
  276. public static Vector2I PointerPosition
  277. {
  278. get
  279. {
  280. Vector2I value;
  281. Internal_GetPointerPosition(out value);
  282. return value;
  283. }
  284. }
  285. /// <summary>
  286. /// Returns difference pointer position of the current and last frame.
  287. /// </summary>
  288. public static Vector2I PointerDelta
  289. {
  290. get
  291. {
  292. Vector2I value;
  293. Internal_GetPointerDelta(out value);
  294. return value;
  295. }
  296. }
  297. /// <summary>
  298. /// Triggered by runtime when a button is pressed.
  299. /// </summary>
  300. /// <param name="code">Code of the pressed button.</param>
  301. /// <param name="deviceIdx">Device the event originated from.</param>
  302. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  303. private static void Internal_TriggerButtonDown(ButtonCode code, int deviceIdx, bool isUsed)
  304. {
  305. ButtonEvent ev = new ButtonEvent(code, deviceIdx, isUsed);
  306. if (OnButtonDown != null)
  307. OnButtonDown(ev);
  308. }
  309. /// <summary>
  310. /// Triggered by runtime when a button is released.
  311. /// </summary>
  312. /// <param name="code">Code of the released button.</param>
  313. /// <param name="deviceIdx">Device the event originated from.</param>
  314. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  315. private static void Internal_TriggerButtonUp(ButtonCode code, int deviceIdx, bool isUsed)
  316. {
  317. ButtonEvent ev = new ButtonEvent(code, deviceIdx, isUsed);
  318. if (OnButtonUp != null)
  319. OnButtonUp(ev);
  320. }
  321. /// <summary>
  322. /// Triggered by runtime when character is input.
  323. /// </summary>
  324. /// <param name="textChar">Code of input character.</param>
  325. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  326. private static void Internal_TriggerCharInput(int textChar, bool isUsed)
  327. {
  328. TextInputEvent ev = new TextInputEvent(textChar, isUsed);
  329. if (OnCharInput != null)
  330. OnCharInput(ev);
  331. }
  332. /// <summary>
  333. /// Triggers when some pointing device (mouse cursor, touch) moves.
  334. /// </summary>
  335. /// <param name="screenPos">Screen position where the input event occurred.</param>
  336. /// <param name="delta">Change in movement since last sent event.</param>
  337. /// <param name="button">Button that triggered the pointer event. Might be irrelevant depending on event type.
  338. /// (for example move events don't correspond to a button.</param>
  339. /// <param name="shift">Is shift button on the keyboard being held down.</param>
  340. /// <param name="ctrl">Is control button on the keyboard being held down.</param>
  341. /// <param name="alt">Is alt button on the keyboard being held down.</param>
  342. /// <param name="scrollAmount">If mouse wheel is being scrolled, what is the amount. Only relevant for
  343. /// move events.</param>
  344. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  345. private static void Internal_TriggerPointerMove(Vector2I screenPos, Vector2I delta, PointerButton button, bool shift,
  346. bool ctrl, bool alt, float scrollAmount, bool isUsed)
  347. {
  348. PointerEvent ev = new PointerEvent(screenPos, delta, button, shift, ctrl, alt, scrollAmount, isUsed);
  349. if (OnPointerMoved != null)
  350. OnPointerMoved(ev);
  351. }
  352. /// <summary>
  353. /// Triggers when some pointing device (mouse cursor, touch) button is pressed.
  354. /// </summary>
  355. /// <param name="screenPos">Screen position where the input event occurred.</param>
  356. /// <param name="delta">Change in movement since last sent event.</param>
  357. /// <param name="button">Button that triggered the pointer event. Might be irrelevant depending on event type.
  358. /// (for example move events don't correspond to a button.</param>
  359. /// <param name="shift">Is shift button on the keyboard being held down.</param>
  360. /// <param name="ctrl">Is control button on the keyboard being held down.</param>
  361. /// <param name="alt">Is alt button on the keyboard being held down.</param>
  362. /// <param name="scrollAmount">If mouse wheel is being scrolled, what is the amount. Only relevant for
  363. /// move events.</param>
  364. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  365. private static void Internal_TriggerPointerPressed(Vector2I screenPos, Vector2I delta, PointerButton button, bool shift,
  366. bool ctrl, bool alt, float scrollAmount, bool isUsed)
  367. {
  368. PointerEvent ev = new PointerEvent(screenPos, delta, button, shift, ctrl, alt, scrollAmount, isUsed);
  369. if (OnPointerPressed != null)
  370. OnPointerPressed(ev);
  371. }
  372. /// <summary>
  373. /// Triggers when some pointing device (mouse cursor, touch) button is released.
  374. /// </summary>
  375. /// <param name="screenPos">Screen position where the input event occurred.</param>
  376. /// <param name="delta">Change in movement since last sent event.</param>
  377. /// <param name="button">Button that triggered the pointer event. Might be irrelevant depending on event type.
  378. /// (for example move events don't correspond to a button.</param>
  379. /// <param name="shift">Is shift button on the keyboard being held down.</param>
  380. /// <param name="ctrl">Is control button on the keyboard being held down.</param>
  381. /// <param name="alt">Is alt button on the keyboard being held down.</param>
  382. /// <param name="scrollAmount">If mouse wheel is being scrolled, what is the amount. Only relevant for
  383. /// move events.</param>
  384. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  385. private static void Internal_TriggerPointerReleased(Vector2I screenPos, Vector2I delta, PointerButton button, bool shift,
  386. bool ctrl, bool alt, float scrollAmount, bool isUsed)
  387. {
  388. PointerEvent ev = new PointerEvent(screenPos, delta, button, shift, ctrl, alt, scrollAmount, isUsed);
  389. if (OnPointerReleased != null)
  390. OnPointerReleased(ev);
  391. }
  392. /// <summary>
  393. /// Triggers when some pointing device (mouse cursor, touch) button is double clicked.
  394. /// </summary>
  395. /// <param name="screenPos">Screen position where the input event occurred.</param>
  396. /// <param name="delta">Change in movement since last sent event.</param>
  397. /// <param name="button">Button that triggered the pointer event. Might be irrelevant depending on event type.
  398. /// (for example move events don't correspond to a button.</param>
  399. /// <param name="shift">Is shift button on the keyboard being held down.</param>
  400. /// <param name="ctrl">Is control button on the keyboard being held down.</param>
  401. /// <param name="alt">Is alt button on the keyboard being held down.</param>
  402. /// <param name="scrollAmount">If mouse wheel is being scrolled, what is the amount. Only relevant for
  403. /// move events.</param>
  404. /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param>
  405. private static void Internal_TriggerPointerDoubleClick(Vector2I screenPos, Vector2I delta, PointerButton button, bool shift,
  406. bool ctrl, bool alt, float scrollAmount, bool isUsed)
  407. {
  408. PointerEvent ev = new PointerEvent(screenPos, delta, button, shift, ctrl, alt, scrollAmount, isUsed);
  409. if (OnPointerDoubleClick != null)
  410. OnPointerDoubleClick(ev);
  411. }
  412. [MethodImpl(MethodImplOptions.InternalCall)]
  413. private static extern float Internal_GetAxisValue(InputAxis axis, int deviceIdx);
  414. [MethodImpl(MethodImplOptions.InternalCall)]
  415. private static extern bool Internal_IsButtonHeld(ButtonCode keyCode, int deviceIdx);
  416. [MethodImpl(MethodImplOptions.InternalCall)]
  417. private static extern bool Internal_IsButtonUp(ButtonCode keyCode, int deviceIdx);
  418. [MethodImpl(MethodImplOptions.InternalCall)]
  419. private static extern bool Internal_IsButtonDown(ButtonCode keyCode, int deviceIdx);
  420. [MethodImpl(MethodImplOptions.InternalCall)]
  421. private static extern bool Internal_IsPointerDoubleClicked();
  422. [MethodImpl(MethodImplOptions.InternalCall)]
  423. private static extern bool Internal_IsPointerButtonHeld(PointerButton keyCode);
  424. [MethodImpl(MethodImplOptions.InternalCall)]
  425. private static extern bool Internal_IsPointerButtonUp(PointerButton keyCode);
  426. [MethodImpl(MethodImplOptions.InternalCall)]
  427. private static extern bool Internal_IsPointerButtonDown(PointerButton keyCode);
  428. [MethodImpl(MethodImplOptions.InternalCall)]
  429. private static extern void Internal_GetPointerPosition(out Vector2I position);
  430. [MethodImpl(MethodImplOptions.InternalCall)]
  431. private static extern void Internal_GetPointerDelta(out Vector2I delta);
  432. }
  433. /// <summary>
  434. /// Contains all possible input buttons, including keyboard scan codes, mouse buttons and gamepad buttons.
  435. /// </summary>
  436. public enum ButtonCode : uint // Note: Must match C++ enum ButtonCode
  437. {
  438. Unassigned = 0x00,
  439. Escape = 0x01,
  440. Num1 = 0x02,
  441. Num2 = 0x03,
  442. Num3 = 0x04,
  443. Num4 = 0x05,
  444. Num5 = 0x06,
  445. Num6 = 0x07,
  446. Num7 = 0x08,
  447. Num8 = 0x09,
  448. Num9 = 0x0A,
  449. Num0 = 0x0B,
  450. Minus = 0x0C,
  451. Equals = 0x0D,
  452. Back = 0x0E,
  453. Tab = 0x0F,
  454. Q = 0x10,
  455. W = 0x11,
  456. E = 0x12,
  457. R = 0x13,
  458. T = 0x14,
  459. Y = 0x15,
  460. U = 0x16,
  461. I = 0x17,
  462. O = 0x18,
  463. P = 0x19,
  464. LeftBracket = 0x1A,
  465. RightBracket = 0x1B,
  466. Return = 0x1C,
  467. LeftControl = 0x1D,
  468. A = 0x1E,
  469. S = 0x1F,
  470. D = 0x20,
  471. F = 0x21,
  472. G = 0x22,
  473. H = 0x23,
  474. J = 0x24,
  475. K = 0x25,
  476. L = 0x26,
  477. Semicolon = 0x27,
  478. Apostrophe = 0x28,
  479. Grave = 0x29,
  480. LeftShift = 0x2A,
  481. Backslash = 0x2B,
  482. Z = 0x2C,
  483. X = 0x2D,
  484. C = 0x2E,
  485. V = 0x2F,
  486. B = 0x30,
  487. N = 0x31,
  488. M = 0x32,
  489. Comma = 0x33,
  490. Period = 0x34,
  491. Slash = 0x35,
  492. RightShift = 0x36,
  493. KeypadMultiply = 0x37,
  494. LeftMenu = 0x38,
  495. Space = 0x39,
  496. CapsLock = 0x3A,
  497. F1 = 0x3B,
  498. F2 = 0x3C,
  499. F3 = 0x3D,
  500. F4 = 0x3E,
  501. F5 = 0x3F,
  502. F6 = 0x40,
  503. F7 = 0x41,
  504. F8 = 0x42,
  505. F9 = 0x43,
  506. F10 = 0x44,
  507. NumLock = 0x45,
  508. ScrollLock = 0x46,
  509. Keypad7 = 0x47,
  510. Keypad8 = 0x48,
  511. Keypad9 = 0x49,
  512. KeypadSubtract = 0x4A,
  513. Keypad4 = 0x4B,
  514. Keypad5 = 0x4C,
  515. Keypad6 = 0x4D,
  516. KeypadAdd = 0x4E,
  517. Keypad1 = 0x4F,
  518. Keypad2 = 0x50,
  519. Keypad3 = 0x51,
  520. Keypad0 = 0x52,
  521. KeypadDecimal = 0x53,
  522. F11 = 0x57,
  523. F12 = 0x58,
  524. F13 = 0x64,
  525. F14 = 0x65,
  526. F15 = 0x66,
  527. KeypadEquals = 0x8D,
  528. At = 0x91,
  529. Colon = 0x92,
  530. NumpadEnter = 0x9C,
  531. RightControl = 0x9D,
  532. KeypadComma = 0xB3,
  533. KeypadDivide = 0xB5,
  534. RightMenu = 0xB8,
  535. Pause = 0xC5,
  536. Home = 0xC7,
  537. Up = 0xC8,
  538. PageUp = 0xC9,
  539. Left = 0xCB,
  540. Right = 0xCD,
  541. End = 0xCF,
  542. Down = 0xD0,
  543. PageDown = 0xD1,
  544. Insert = 0xD2,
  545. Delete = 0xD3,
  546. LeftWindows = 0xDB,
  547. RightWindows = 0xDC,
  548. MouseLeft = 0x800000EE,
  549. MouseRight = 0x800000EF,
  550. MouseMiddle = 0x800000F0,
  551. MouseBtn4 = 0x800000F1,
  552. MouseBtn5 = 0x800000F2,
  553. MouseBtn6 = 0x800000F3,
  554. MouseBtn7 = 0x800000F4,
  555. MouseBtn8 = 0x800000F5,
  556. MouseBtn9 = 0x800000F6,
  557. MouseBtn10 = 0x800000F7,
  558. MouseBtn11 = 0x800000F8,
  559. MouseBtn12 = 0x800000F9,
  560. MouseBtn13 = 0x800000FA,
  561. MouseBtn14 = 0x800000FB,
  562. MouseBtn15 = 0x800000FC,
  563. MouseBtn16 = 0x800000FD,
  564. GamepadA = 0x4000010F,
  565. GamepadB = 0x40000110,
  566. GamepadX = 0x40000111,
  567. GamepadY = 0x40000112,
  568. GamepadLB = 0x40000113,
  569. GamepadRB = 0x40000114,
  570. GamepadLS = 0x40000115,
  571. GamepadRS = 0x40000116,
  572. GamepadBack = 0x40000117,
  573. GamepadStart = 0x40000118,
  574. GamepadDPadLeft = 0x40000119,
  575. GamepadDPadRight = 0x4000011A,
  576. GamepadDPadUp = 0x4000011B,
  577. GamepadDPatDown = 0x4000011C,
  578. GamepadBtn1 = 0x4000011D,
  579. GamepadBtn2 = 0x4000011E,
  580. GamepadBtn3 = 0x4000011F,
  581. GamepadBtn4 = 0x40000120,
  582. GamepadBtn5 = 0x40000121,
  583. GamepadBtn6 = 0x40000122,
  584. GamepadBtn7 = 0x40000123,
  585. GamepadBtn8 = 0x40000124,
  586. GamepadBtn9 = 0x40000125,
  587. GamepadBtn10 = 0x40000126,
  588. GamepadBtn11 = 0x40000127,
  589. GamepadBtn12 = 0x40000128,
  590. GamepadBtn13 = 0x40000129,
  591. GamepadBtn14 = 0x4000012A,
  592. GamepadBtn15 = 0x4000012B,
  593. GamepadBtn16 = 0x4000012C,
  594. Count = 249,
  595. NumKeys = 203, // IMPORTANT: Make sure to update these if you modify the values above
  596. NumMouseButtons = 16,
  597. NumGamepadButtons = 30,
  598. };
  599. /// <summary>
  600. /// Available types of input axes.
  601. /// </summary>
  602. public enum InputAxis // Note: Must match C++ enum InputAxis
  603. {
  604. MouseX,
  605. MouseY,
  606. MouseZ,
  607. LeftStickX,
  608. LeftStickY,
  609. RightStickX,
  610. RightStickY,
  611. LeftTrigger,
  612. RightTrigger,
  613. Count // Keep at end
  614. };
  615. /** @} */
  616. }