settings_input.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. extern const std::array<const char*, NumAnalogs> mapping;
  50. } // namespace NativeAnalog
  51. namespace NativeTrigger {
  52. enum Values : int {
  53. LTrigger,
  54. RTrigger,
  55. NumTriggers,
  56. };
  57. constexpr int TRIGGER_HID_BEGIN = LTrigger;
  58. constexpr int TRIGGER_HID_END = NumTriggers;
  59. } // namespace NativeTrigger
  60. namespace NativeVibration {
  61. enum Values : int {
  62. LeftVibrationDevice,
  63. RightVibrationDevice,
  64. NumVibrations,
  65. };
  66. constexpr int VIBRATION_HID_BEGIN = LeftVibrationDevice;
  67. constexpr int VIBRATION_HID_END = NumVibrations;
  68. constexpr int NUM_VIBRATIONS_HID = NumVibrations;
  69. extern const std::array<const char*, NumVibrations> mapping;
  70. }; // namespace NativeVibration
  71. namespace NativeMotion {
  72. enum Values : int {
  73. MotionLeft,
  74. MotionRight,
  75. NumMotions,
  76. };
  77. constexpr int MOTION_HID_BEGIN = MotionLeft;
  78. constexpr int MOTION_HID_END = NumMotions;
  79. constexpr int NUM_MOTIONS_HID = NumMotions;
  80. extern const std::array<const char*, NumMotions> mapping;
  81. } // namespace NativeMotion
  82. namespace NativeMouseButton {
  83. enum Values {
  84. Left,
  85. Right,
  86. Middle,
  87. Forward,
  88. Back,
  89. NumMouseButtons,
  90. };
  91. constexpr int MOUSE_HID_BEGIN = Left;
  92. constexpr int MOUSE_HID_END = NumMouseButtons;
  93. constexpr int NUM_MOUSE_HID = NumMouseButtons;
  94. extern const std::array<const char*, NumMouseButtons> mapping;
  95. } // namespace NativeMouseButton
  96. namespace NativeMouseWheel {
  97. enum Values {
  98. X,
  99. Y,
  100. NumMouseWheels,
  101. };
  102. extern const std::array<const char*, NumMouseWheels> mapping;
  103. } // namespace NativeMouseWheel
  104. namespace NativeKeyboard {
  105. enum Keys {
  106. None,
  107. A = 4,
  108. B,
  109. C,
  110. D,
  111. E,
  112. F,
  113. G,
  114. H,
  115. I,
  116. J,
  117. K,
  118. L,
  119. M,
  120. N,
  121. O,
  122. P,
  123. Q,
  124. R,
  125. S,
  126. T,
  127. U,
  128. V,
  129. W,
  130. X,
  131. Y,
  132. Z,
  133. N1,
  134. N2,
  135. N3,
  136. N4,
  137. N5,
  138. N6,
  139. N7,
  140. N8,
  141. N9,
  142. N0,
  143. Return,
  144. Escape,
  145. Backspace,
  146. Tab,
  147. Space,
  148. Minus,
  149. Plus,
  150. OpenBracket,
  151. CloseBracket,
  152. Pipe,
  153. Tilde,
  154. Semicolon,
  155. Quote,
  156. Backquote,
  157. Comma,
  158. Period,
  159. Slash,
  160. CapsLockKey,
  161. F1,
  162. F2,
  163. F3,
  164. F4,
  165. F5,
  166. F6,
  167. F7,
  168. F8,
  169. F9,
  170. F10,
  171. F11,
  172. F12,
  173. PrintScreen,
  174. ScrollLockKey,
  175. Pause,
  176. Insert,
  177. Home,
  178. PageUp,
  179. Delete,
  180. End,
  181. PageDown,
  182. Right,
  183. Left,
  184. Down,
  185. Up,
  186. NumLockKey,
  187. KPSlash,
  188. KPAsterisk,
  189. KPMinus,
  190. KPPlus,
  191. KPEnter,
  192. KP1,
  193. KP2,
  194. KP3,
  195. KP4,
  196. KP5,
  197. KP6,
  198. KP7,
  199. KP8,
  200. KP9,
  201. KP0,
  202. KPDot,
  203. Key102,
  204. Compose,
  205. Power,
  206. KPEqual,
  207. F13,
  208. F14,
  209. F15,
  210. F16,
  211. F17,
  212. F18,
  213. F19,
  214. F20,
  215. F21,
  216. F22,
  217. F23,
  218. F24,
  219. Open,
  220. Help,
  221. Properties,
  222. Front,
  223. Stop,
  224. Repeat,
  225. Undo,
  226. Cut,
  227. Copy,
  228. Paste,
  229. Find,
  230. Mute,
  231. VolumeUp,
  232. VolumeDown,
  233. CapsLockActive,
  234. NumLockActive,
  235. ScrollLockActive,
  236. KPComma,
  237. Ro = 0x87,
  238. KatakanaHiragana,
  239. Yen,
  240. Henkan,
  241. Muhenkan,
  242. NumPadCommaPc98,
  243. HangulEnglish = 0x90,
  244. Hanja,
  245. KatakanaKey,
  246. HiraganaKey,
  247. ZenkakuHankaku,
  248. LeftControlKey = 0xE0,
  249. LeftShiftKey,
  250. LeftAltKey,
  251. LeftMetaKey,
  252. RightControlKey,
  253. RightShiftKey,
  254. RightAltKey,
  255. RightMetaKey,
  256. MediaPlayPause,
  257. MediaStopCD,
  258. MediaPrevious,
  259. MediaNext,
  260. MediaEject,
  261. MediaVolumeUp,
  262. MediaVolumeDown,
  263. MediaMute,
  264. MediaWebsite,
  265. MediaBack,
  266. MediaForward,
  267. MediaStop,
  268. MediaFind,
  269. MediaScrollUp,
  270. MediaScrollDown,
  271. MediaEdit,
  272. MediaSleep,
  273. MediaCoffee,
  274. MediaRefresh,
  275. MediaCalculator,
  276. NumKeyboardKeys,
  277. };
  278. static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys.");
  279. enum Modifiers {
  280. LeftControl,
  281. LeftShift,
  282. LeftAlt,
  283. LeftMeta,
  284. RightControl,
  285. RightShift,
  286. RightAlt,
  287. RightMeta,
  288. CapsLock,
  289. ScrollLock,
  290. NumLock,
  291. Katakana,
  292. Hiragana,
  293. NumKeyboardMods,
  294. };
  295. constexpr int KEYBOARD_KEYS_HID_BEGIN = None;
  296. constexpr int KEYBOARD_KEYS_HID_END = NumKeyboardKeys;
  297. constexpr int NUM_KEYBOARD_KEYS_HID = NumKeyboardKeys;
  298. constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl;
  299. constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods;
  300. constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
  301. } // namespace NativeKeyboard
  302. using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
  303. using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
  304. using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>;
  305. constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
  306. constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
  307. constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
  308. constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
  309. enum class ControllerType {
  310. ProController,
  311. DualJoyconDetached,
  312. LeftJoycon,
  313. RightJoycon,
  314. Handheld,
  315. GameCube,
  316. Pokeball,
  317. NES,
  318. SNES,
  319. N64,
  320. SegaGenesis,
  321. };
  322. struct PlayerInput {
  323. bool connected;
  324. ControllerType controller_type;
  325. ButtonsRaw buttons;
  326. AnalogsRaw analogs;
  327. MotionsRaw motions;
  328. bool vibration_enabled;
  329. int vibration_strength;
  330. u32 body_color_left;
  331. u32 body_color_right;
  332. u32 button_color_left;
  333. u32 button_color_right;
  334. };
  335. struct TouchscreenInput {
  336. bool enabled;
  337. std::string device;
  338. u32 finger;
  339. u32 diameter_x;
  340. u32 diameter_y;
  341. u32 rotation_angle;
  342. };
  343. } // namespace Settings