settings_input.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include <string>
  7. #include "common/common_types.h"
  8. namespace Settings {
  9. namespace NativeButton {
  10. enum Values : int {
  11. A,
  12. B,
  13. X,
  14. Y,
  15. LStick,
  16. RStick,
  17. L,
  18. R,
  19. ZL,
  20. ZR,
  21. Plus,
  22. Minus,
  23. DLeft,
  24. DUp,
  25. DRight,
  26. DDown,
  27. SL,
  28. SR,
  29. Home,
  30. Screenshot,
  31. NumButtons,
  32. };
  33. constexpr int BUTTON_HID_BEGIN = A;
  34. constexpr int BUTTON_NS_BEGIN = Home;
  35. constexpr int BUTTON_HID_END = BUTTON_NS_BEGIN;
  36. constexpr int BUTTON_NS_END = NumButtons;
  37. constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN;
  38. constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN;
  39. extern const std::array<const char*, NumButtons> mapping;
  40. } // namespace NativeButton
  41. namespace NativeAnalog {
  42. enum Values : int {
  43. LStick,
  44. RStick,
  45. NumAnalogs,
  46. };
  47. constexpr int STICK_HID_BEGIN = LStick;
  48. constexpr int STICK_HID_END = NumAnalogs;
  49. constexpr int NUM_STICKS_HID = NumAnalogs;
  50. extern const std::array<const char*, NumAnalogs> mapping;
  51. } // namespace NativeAnalog
  52. namespace NativeVibration {
  53. enum Values : int {
  54. LeftVibrationDevice,
  55. RightVibrationDevice,
  56. NumVibrations,
  57. };
  58. constexpr int VIBRATION_HID_BEGIN = LeftVibrationDevice;
  59. constexpr int VIBRATION_HID_END = NumVibrations;
  60. constexpr int NUM_VIBRATIONS_HID = NumVibrations;
  61. extern const std::array<const char*, NumVibrations> mapping;
  62. }; // namespace NativeVibration
  63. namespace NativeMotion {
  64. enum Values : int {
  65. MotionLeft,
  66. MotionRight,
  67. NumMotions,
  68. };
  69. constexpr int MOTION_HID_BEGIN = MotionLeft;
  70. constexpr int MOTION_HID_END = NumMotions;
  71. constexpr int NUM_MOTIONS_HID = NumMotions;
  72. extern const std::array<const char*, NumMotions> mapping;
  73. } // namespace NativeMotion
  74. namespace NativeMouseButton {
  75. enum Values {
  76. Left,
  77. Right,
  78. Middle,
  79. Forward,
  80. Back,
  81. NumMouseButtons,
  82. };
  83. constexpr int MOUSE_HID_BEGIN = Left;
  84. constexpr int MOUSE_HID_END = NumMouseButtons;
  85. constexpr int NUM_MOUSE_HID = NumMouseButtons;
  86. extern const std::array<const char*, NumMouseButtons> mapping;
  87. } // namespace NativeMouseButton
  88. namespace NativeKeyboard {
  89. enum Keys {
  90. None,
  91. Error,
  92. A = 4,
  93. B,
  94. C,
  95. D,
  96. E,
  97. F,
  98. G,
  99. H,
  100. I,
  101. J,
  102. K,
  103. L,
  104. M,
  105. N,
  106. O,
  107. P,
  108. Q,
  109. R,
  110. S,
  111. T,
  112. U,
  113. V,
  114. W,
  115. X,
  116. Y,
  117. Z,
  118. N1,
  119. N2,
  120. N3,
  121. N4,
  122. N5,
  123. N6,
  124. N7,
  125. N8,
  126. N9,
  127. N0,
  128. Enter,
  129. Escape,
  130. Backspace,
  131. Tab,
  132. Space,
  133. Minus,
  134. Equal,
  135. LeftBrace,
  136. RightBrace,
  137. Backslash,
  138. Tilde,
  139. Semicolon,
  140. Apostrophe,
  141. Grave,
  142. Comma,
  143. Dot,
  144. Slash,
  145. CapsLockKey,
  146. F1,
  147. F2,
  148. F3,
  149. F4,
  150. F5,
  151. F6,
  152. F7,
  153. F8,
  154. F9,
  155. F10,
  156. F11,
  157. F12,
  158. SystemRequest,
  159. ScrollLockKey,
  160. Pause,
  161. Insert,
  162. Home,
  163. PageUp,
  164. Delete,
  165. End,
  166. PageDown,
  167. Right,
  168. Left,
  169. Down,
  170. Up,
  171. NumLockKey,
  172. KPSlash,
  173. KPAsterisk,
  174. KPMinus,
  175. KPPlus,
  176. KPEnter,
  177. KP1,
  178. KP2,
  179. KP3,
  180. KP4,
  181. KP5,
  182. KP6,
  183. KP7,
  184. KP8,
  185. KP9,
  186. KP0,
  187. KPDot,
  188. Key102,
  189. Compose,
  190. Power,
  191. KPEqual,
  192. F13,
  193. F14,
  194. F15,
  195. F16,
  196. F17,
  197. F18,
  198. F19,
  199. F20,
  200. F21,
  201. F22,
  202. F23,
  203. F24,
  204. Open,
  205. Help,
  206. Properties,
  207. Front,
  208. Stop,
  209. Repeat,
  210. Undo,
  211. Cut,
  212. Copy,
  213. Paste,
  214. Find,
  215. Mute,
  216. VolumeUp,
  217. VolumeDown,
  218. CapsLockActive,
  219. NumLockActive,
  220. ScrollLockActive,
  221. KPComma,
  222. KPLeftParenthesis,
  223. KPRightParenthesis,
  224. LeftControlKey = 0xE0,
  225. LeftShiftKey,
  226. LeftAltKey,
  227. LeftMetaKey,
  228. RightControlKey,
  229. RightShiftKey,
  230. RightAltKey,
  231. RightMetaKey,
  232. MediaPlayPause,
  233. MediaStopCD,
  234. MediaPrevious,
  235. MediaNext,
  236. MediaEject,
  237. MediaVolumeUp,
  238. MediaVolumeDown,
  239. MediaMute,
  240. MediaWebsite,
  241. MediaBack,
  242. MediaForward,
  243. MediaStop,
  244. MediaFind,
  245. MediaScrollUp,
  246. MediaScrollDown,
  247. MediaEdit,
  248. MediaSleep,
  249. MediaCoffee,
  250. MediaRefresh,
  251. MediaCalculator,
  252. NumKeyboardKeys,
  253. };
  254. static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys.");
  255. enum Modifiers {
  256. LeftControl,
  257. LeftShift,
  258. LeftAlt,
  259. LeftMeta,
  260. RightControl,
  261. RightShift,
  262. RightAlt,
  263. RightMeta,
  264. CapsLock,
  265. ScrollLock,
  266. NumLock,
  267. NumKeyboardMods,
  268. };
  269. constexpr int KEYBOARD_KEYS_HID_BEGIN = None;
  270. constexpr int KEYBOARD_KEYS_HID_END = NumKeyboardKeys;
  271. constexpr int NUM_KEYBOARD_KEYS_HID = NumKeyboardKeys;
  272. constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl;
  273. constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods;
  274. constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
  275. } // namespace NativeKeyboard
  276. using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
  277. using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
  278. using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>;
  279. using VibrationsRaw = std::array<std::string, NativeVibration::NumVibrations>;
  280. using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>;
  281. using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>;
  282. using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>;
  283. constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
  284. constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
  285. constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
  286. constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
  287. enum class ControllerType {
  288. ProController,
  289. DualJoyconDetached,
  290. LeftJoycon,
  291. RightJoycon,
  292. Handheld,
  293. GameCube,
  294. };
  295. struct PlayerInput {
  296. bool connected;
  297. ControllerType controller_type;
  298. ButtonsRaw buttons;
  299. AnalogsRaw analogs;
  300. VibrationsRaw vibrations;
  301. MotionsRaw motions;
  302. bool vibration_enabled;
  303. int vibration_strength;
  304. u32 body_color_left;
  305. u32 body_color_right;
  306. u32 button_color_left;
  307. u32 button_color_right;
  308. };
  309. struct TouchscreenInput {
  310. bool enabled;
  311. std::string device;
  312. u32 finger;
  313. u32 diameter_x;
  314. u32 diameter_y;
  315. u32 rotation_angle;
  316. };
  317. } // namespace Settings