input_enums.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #include "core/error/error_macros.h"
  33. enum class HatDir {
  34. UP = 0,
  35. RIGHT = 1,
  36. DOWN = 2,
  37. LEFT = 3,
  38. MAX = 4,
  39. };
  40. enum class HatMask {
  41. CENTER = 0,
  42. UP = 1,
  43. RIGHT = 2,
  44. DOWN = 4,
  45. LEFT = 8,
  46. };
  47. enum class JoyAxis {
  48. INVALID = -1,
  49. LEFT_X = 0,
  50. LEFT_Y = 1,
  51. RIGHT_X = 2,
  52. RIGHT_Y = 3,
  53. TRIGGER_LEFT = 4,
  54. TRIGGER_RIGHT = 5,
  55. SDL_MAX = 6,
  56. MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
  57. };
  58. enum class JoyButton {
  59. INVALID = -1,
  60. A = 0,
  61. B = 1,
  62. X = 2,
  63. Y = 3,
  64. BACK = 4,
  65. GUIDE = 5,
  66. START = 6,
  67. LEFT_STICK = 7,
  68. RIGHT_STICK = 8,
  69. LEFT_SHOULDER = 9,
  70. RIGHT_SHOULDER = 10,
  71. DPAD_UP = 11,
  72. DPAD_DOWN = 12,
  73. DPAD_LEFT = 13,
  74. DPAD_RIGHT = 14,
  75. MISC1 = 15,
  76. PADDLE1 = 16,
  77. PADDLE2 = 17,
  78. PADDLE3 = 18,
  79. PADDLE4 = 19,
  80. TOUCHPAD = 20,
  81. SDL_MAX = 21,
  82. MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons.
  83. };
  84. enum class MIDIMessage {
  85. NONE = 0,
  86. NOTE_OFF = 0x8,
  87. NOTE_ON = 0x9,
  88. AFTERTOUCH = 0xA,
  89. CONTROL_CHANGE = 0xB,
  90. PROGRAM_CHANGE = 0xC,
  91. CHANNEL_PRESSURE = 0xD,
  92. PITCH_BEND = 0xE,
  93. SYSTEM_EXCLUSIVE = 0xF0,
  94. QUARTER_FRAME = 0xF1,
  95. SONG_POSITION_POINTER = 0xF2,
  96. SONG_SELECT = 0xF3,
  97. TUNE_REQUEST = 0xF6,
  98. TIMING_CLOCK = 0xF8,
  99. START = 0xFA,
  100. CONTINUE = 0xFB,
  101. STOP = 0xFC,
  102. ACTIVE_SENSING = 0xFE,
  103. SYSTEM_RESET = 0xFF,
  104. };
  105. enum class MouseButton {
  106. NONE = 0,
  107. LEFT = 1,
  108. RIGHT = 2,
  109. MIDDLE = 3,
  110. WHEEL_UP = 4,
  111. WHEEL_DOWN = 5,
  112. WHEEL_LEFT = 6,
  113. WHEEL_RIGHT = 7,
  114. MB_XBUTTON1 = 8, // "XBUTTON1" is a reserved word on Windows.
  115. MB_XBUTTON2 = 9, // "XBUTTON2" is a reserved word on Windows.
  116. };
  117. enum class MouseButtonMask {
  118. NONE = 0,
  119. LEFT = (1 << (int(MouseButton::LEFT) - 1)),
  120. RIGHT = (1 << (int(MouseButton::RIGHT) - 1)),
  121. MIDDLE = (1 << (int(MouseButton::MIDDLE) - 1)),
  122. MB_XBUTTON1 = (1 << (int(MouseButton::MB_XBUTTON1) - 1)),
  123. MB_XBUTTON2 = (1 << (int(MouseButton::MB_XBUTTON2) - 1)),
  124. };
  125. inline MouseButtonMask mouse_button_to_mask(MouseButton button) {
  126. ERR_FAIL_COND_V(button == MouseButton::NONE, MouseButtonMask::NONE);
  127. return MouseButtonMask(1 << ((int)button - 1));
  128. }
  129. #endif // INPUT_ENUMS_H