settings_input.h 6.5 KB

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