settings_input.h 6.3 KB

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