input_enums.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**************************************************************************/
  2. /* input_enums.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef INPUT_ENUMS_H
  31. #define INPUT_ENUMS_H
  32. enum class HatDir {
  33. UP = 0,
  34. RIGHT = 1,
  35. DOWN = 2,
  36. LEFT = 3,
  37. MAX = 4,
  38. };
  39. enum class HatMask {
  40. CENTER = 0,
  41. UP = 1,
  42. RIGHT = 2,
  43. DOWN = 4,
  44. LEFT = 8,
  45. };
  46. enum class JoyAxis {
  47. INVALID = -1,
  48. LEFT_X = 0,
  49. LEFT_Y = 1,
  50. RIGHT_X = 2,
  51. RIGHT_Y = 3,
  52. TRIGGER_LEFT = 4,
  53. TRIGGER_RIGHT = 5,
  54. SDL_MAX = 6,
  55. MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
  56. };
  57. enum class JoyButton {
  58. INVALID = -1,
  59. A = 0,
  60. B = 1,
  61. X = 2,
  62. Y = 3,
  63. BACK = 4,
  64. GUIDE = 5,
  65. START = 6,
  66. LEFT_STICK = 7,
  67. RIGHT_STICK = 8,
  68. LEFT_SHOULDER = 9,
  69. RIGHT_SHOULDER = 10,
  70. DPAD_UP = 11,
  71. DPAD_DOWN = 12,
  72. DPAD_LEFT = 13,
  73. DPAD_RIGHT = 14,
  74. MISC1 = 15,
  75. PADDLE1 = 16,
  76. PADDLE2 = 17,
  77. PADDLE3 = 18,
  78. PADDLE4 = 19,
  79. TOUCHPAD = 20,
  80. SDL_MAX = 21,
  81. MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons.
  82. };
  83. enum class MIDIMessage {
  84. NONE = 0,
  85. NOTE_OFF = 0x8,
  86. NOTE_ON = 0x9,
  87. AFTERTOUCH = 0xA,
  88. CONTROL_CHANGE = 0xB,
  89. PROGRAM_CHANGE = 0xC,
  90. CHANNEL_PRESSURE = 0xD,
  91. PITCH_BEND = 0xE,
  92. SYSTEM_EXCLUSIVE = 0xF0,
  93. QUARTER_FRAME = 0xF1,
  94. SONG_POSITION_POINTER = 0xF2,
  95. SONG_SELECT = 0xF3,
  96. TUNE_REQUEST = 0xF6,
  97. TIMING_CLOCK = 0xF8,
  98. START = 0xFA,
  99. CONTINUE = 0xFB,
  100. STOP = 0xFC,
  101. ACTIVE_SENSING = 0xFE,
  102. SYSTEM_RESET = 0xFF,
  103. };
  104. enum class MouseButton {
  105. NONE = 0,
  106. LEFT = 1,
  107. RIGHT = 2,
  108. MIDDLE = 3,
  109. WHEEL_UP = 4,
  110. WHEEL_DOWN = 5,
  111. WHEEL_LEFT = 6,
  112. WHEEL_RIGHT = 7,
  113. MB_XBUTTON1 = 8, // "XBUTTON1" is a reserved word on Windows.
  114. MB_XBUTTON2 = 9, // "XBUTTON2" is a reserved word on Windows.
  115. };
  116. enum class MouseButtonMask {
  117. NONE = 0,
  118. LEFT = (1 << (int(MouseButton::LEFT) - 1)),
  119. RIGHT = (1 << (int(MouseButton::RIGHT) - 1)),
  120. MIDDLE = (1 << (int(MouseButton::MIDDLE) - 1)),
  121. MB_XBUTTON1 = (1 << (int(MouseButton::MB_XBUTTON1) - 1)),
  122. MB_XBUTTON2 = (1 << (int(MouseButton::MB_XBUTTON2) - 1)),
  123. };
  124. inline MouseButtonMask mouse_button_to_mask(MouseButton button) {
  125. return MouseButtonMask(1 << ((int)button - 1));
  126. }
  127. #endif // INPUT_ENUMS_H