settings.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 NativeMouseButton {
  53. enum Values {
  54. Left,
  55. Right,
  56. Middle,
  57. Forward,
  58. Back,
  59. NumMouseButtons,
  60. };
  61. constexpr int MOUSE_HID_BEGIN = Left;
  62. constexpr int MOUSE_HID_END = NumMouseButtons;
  63. constexpr int NUM_MOUSE_HID = NumMouseButtons;
  64. extern const std::array<const char*, NumMouseButtons> mapping;
  65. } // namespace NativeMouseButton
  66. namespace NativeKeyboard {
  67. enum Keys {
  68. None,
  69. Error,
  70. A = 4,
  71. B,
  72. C,
  73. D,
  74. E,
  75. F,
  76. G,
  77. H,
  78. I,
  79. J,
  80. K,
  81. L,
  82. M,
  83. N,
  84. O,
  85. P,
  86. Q,
  87. R,
  88. S,
  89. T,
  90. U,
  91. V,
  92. W,
  93. X,
  94. Y,
  95. Z,
  96. N1,
  97. N2,
  98. N3,
  99. N4,
  100. N5,
  101. N6,
  102. N7,
  103. N8,
  104. N9,
  105. N0,
  106. Enter,
  107. Escape,
  108. Backspace,
  109. Tab,
  110. Space,
  111. Minus,
  112. Equal,
  113. LeftBrace,
  114. RightBrace,
  115. Backslash,
  116. Tilde,
  117. Semicolon,
  118. Apostrophe,
  119. Grave,
  120. Comma,
  121. Dot,
  122. Slash,
  123. CapsLockKey,
  124. F1,
  125. F2,
  126. F3,
  127. F4,
  128. F5,
  129. F6,
  130. F7,
  131. F8,
  132. F9,
  133. F10,
  134. F11,
  135. F12,
  136. SystemRequest,
  137. ScrollLockKey,
  138. Pause,
  139. Insert,
  140. Home,
  141. PageUp,
  142. Delete,
  143. End,
  144. PageDown,
  145. Right,
  146. Left,
  147. Down,
  148. Up,
  149. NumLockKey,
  150. KPSlash,
  151. KPAsterisk,
  152. KPMinus,
  153. KPPlus,
  154. KPEnter,
  155. KP1,
  156. KP2,
  157. KP3,
  158. KP4,
  159. KP5,
  160. KP6,
  161. KP7,
  162. KP8,
  163. KP9,
  164. KP0,
  165. KPDot,
  166. Key102,
  167. Compose,
  168. Power,
  169. KPEqual,
  170. F13,
  171. F14,
  172. F15,
  173. F16,
  174. F17,
  175. F18,
  176. F19,
  177. F20,
  178. F21,
  179. F22,
  180. F23,
  181. F24,
  182. Open,
  183. Help,
  184. Properties,
  185. Front,
  186. Stop,
  187. Repeat,
  188. Undo,
  189. Cut,
  190. Copy,
  191. Paste,
  192. Find,
  193. Mute,
  194. VolumeUp,
  195. VolumeDown,
  196. CapsLockActive,
  197. NumLockActive,
  198. ScrollLockActive,
  199. KPComma,
  200. KPLeftParenthesis,
  201. KPRightParenthesis,
  202. LeftControlKey = 0xE0,
  203. LeftShiftKey,
  204. LeftAltKey,
  205. LeftMetaKey,
  206. RightControlKey,
  207. RightShiftKey,
  208. RightAltKey,
  209. RightMetaKey,
  210. MediaPlayPause,
  211. MediaStopCD,
  212. MediaPrevious,
  213. MediaNext,
  214. MediaEject,
  215. MediaVolumeUp,
  216. MediaVolumeDown,
  217. MediaMute,
  218. MediaWebsite,
  219. MediaBack,
  220. MediaForward,
  221. MediaStop,
  222. MediaFind,
  223. MediaScrollUp,
  224. MediaScrollDown,
  225. MediaEdit,
  226. MediaSleep,
  227. MediaCoffee,
  228. MediaRefresh,
  229. MediaCalculator,
  230. NumKeyboardKeys,
  231. };
  232. static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys.");
  233. enum Modifiers {
  234. LeftControl,
  235. LeftShift,
  236. LeftAlt,
  237. LeftMeta,
  238. RightControl,
  239. RightShift,
  240. RightAlt,
  241. RightMeta,
  242. CapsLock,
  243. ScrollLock,
  244. NumLock,
  245. NumKeyboardMods,
  246. };
  247. constexpr int KEYBOARD_KEYS_HID_BEGIN = None;
  248. constexpr int KEYBOARD_KEYS_HID_END = NumKeyboardKeys;
  249. constexpr int NUM_KEYBOARD_KEYS_HID = NumKeyboardKeys;
  250. constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl;
  251. constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods;
  252. constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
  253. } // namespace NativeKeyboard
  254. using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
  255. using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
  256. using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>;
  257. using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>;
  258. using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>;
  259. constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
  260. constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
  261. constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
  262. constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
  263. enum class ControllerType {
  264. ProController,
  265. DualJoyconDetached,
  266. LeftJoycon,
  267. RightJoycon,
  268. Handheld,
  269. };
  270. struct PlayerInput {
  271. bool connected;
  272. ControllerType controller_type;
  273. ButtonsRaw buttons;
  274. AnalogsRaw analogs;
  275. std::string lstick_mod;
  276. std::string rstick_mod;
  277. u32 body_color_left;
  278. u32 body_color_right;
  279. u32 button_color_left;
  280. u32 button_color_right;
  281. };
  282. struct TouchscreenInput {
  283. bool enabled;
  284. std::string device;
  285. u32 finger;
  286. u32 diameter_x;
  287. u32 diameter_y;
  288. u32 rotation_angle;
  289. };
  290. } // namespace Settings