diff options
Diffstat (limited to 'src/core/settings.h')
| -rw-r--r-- | src/core/settings.h | 322 |
1 files changed, 285 insertions, 37 deletions
diff --git a/src/core/settings.h b/src/core/settings.h index a8954647f..a0c5fd447 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 11 | 12 | ||
| @@ -59,36 +60,7 @@ constexpr int BUTTON_NS_END = NumButtons; | |||
| 59 | constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN; | 60 | constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN; |
| 60 | constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN; | 61 | constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN; |
| 61 | 62 | ||
| 62 | static const std::array<const char*, NumButtons> mapping = {{ | 63 | extern const std::array<const char*, NumButtons> mapping; |
| 63 | "button_a", | ||
| 64 | "button_b", | ||
| 65 | "button_x", | ||
| 66 | "button_y", | ||
| 67 | "button_lstick", | ||
| 68 | "button_rstick", | ||
| 69 | "button_l", | ||
| 70 | "button_r", | ||
| 71 | "button_zl", | ||
| 72 | "button_zr", | ||
| 73 | "button_plus", | ||
| 74 | "button_minus", | ||
| 75 | "button_dleft", | ||
| 76 | "button_dup", | ||
| 77 | "button_dright", | ||
| 78 | "button_ddown", | ||
| 79 | "button_lstick_left", | ||
| 80 | "button_lstick_up", | ||
| 81 | "button_lstick_right", | ||
| 82 | "button_lstick_down", | ||
| 83 | "button_rstick_left", | ||
| 84 | "button_rstick_up", | ||
| 85 | "button_rstick_right", | ||
| 86 | "button_rstick_down", | ||
| 87 | "button_sl", | ||
| 88 | "button_sr", | ||
| 89 | "button_home", | ||
| 90 | "button_screenshot", | ||
| 91 | }}; | ||
| 92 | 64 | ||
| 93 | } // namespace NativeButton | 65 | } // namespace NativeButton |
| 94 | 66 | ||
| @@ -104,24 +76,298 @@ constexpr int STICK_HID_BEGIN = LStick; | |||
| 104 | constexpr int STICK_HID_END = NumAnalogs; | 76 | constexpr int STICK_HID_END = NumAnalogs; |
| 105 | constexpr int NUM_STICKS_HID = NumAnalogs; | 77 | constexpr int NUM_STICKS_HID = NumAnalogs; |
| 106 | 78 | ||
| 107 | static const std::array<const char*, NumAnalogs> mapping = {{ | 79 | extern const std::array<const char*, NumAnalogs> mapping; |
| 108 | "lstick", | ||
| 109 | "rstick", | ||
| 110 | }}; | ||
| 111 | } // namespace NativeAnalog | 80 | } // namespace NativeAnalog |
| 112 | 81 | ||
| 82 | namespace NativeMouseButton { | ||
| 83 | enum Values { | ||
| 84 | Left, | ||
| 85 | Right, | ||
| 86 | Middle, | ||
| 87 | Forward, | ||
| 88 | Back, | ||
| 89 | |||
| 90 | NumMouseButtons, | ||
| 91 | }; | ||
| 92 | |||
| 93 | constexpr int MOUSE_HID_BEGIN = Left; | ||
| 94 | constexpr int MOUSE_HID_END = NumMouseButtons; | ||
| 95 | constexpr int NUM_MOUSE_HID = NumMouseButtons; | ||
| 96 | |||
| 97 | extern const std::array<const char*, NumMouseButtons> mapping; | ||
| 98 | } // namespace NativeMouseButton | ||
| 99 | |||
| 100 | namespace NativeKeyboard { | ||
| 101 | enum Keys { | ||
| 102 | None, | ||
| 103 | Error, | ||
| 104 | |||
| 105 | A = 4, | ||
| 106 | B, | ||
| 107 | C, | ||
| 108 | D, | ||
| 109 | E, | ||
| 110 | F, | ||
| 111 | G, | ||
| 112 | H, | ||
| 113 | I, | ||
| 114 | J, | ||
| 115 | K, | ||
| 116 | L, | ||
| 117 | M, | ||
| 118 | N, | ||
| 119 | O, | ||
| 120 | P, | ||
| 121 | Q, | ||
| 122 | R, | ||
| 123 | S, | ||
| 124 | T, | ||
| 125 | U, | ||
| 126 | V, | ||
| 127 | W, | ||
| 128 | X, | ||
| 129 | Y, | ||
| 130 | Z, | ||
| 131 | N1, | ||
| 132 | N2, | ||
| 133 | N3, | ||
| 134 | N4, | ||
| 135 | N5, | ||
| 136 | N6, | ||
| 137 | N7, | ||
| 138 | N8, | ||
| 139 | N9, | ||
| 140 | N0, | ||
| 141 | Enter, | ||
| 142 | Escape, | ||
| 143 | Backspace, | ||
| 144 | Tab, | ||
| 145 | Space, | ||
| 146 | Minus, | ||
| 147 | Equal, | ||
| 148 | LeftBrace, | ||
| 149 | RightBrace, | ||
| 150 | Backslash, | ||
| 151 | Tilde, | ||
| 152 | Semicolon, | ||
| 153 | Apostrophe, | ||
| 154 | Grave, | ||
| 155 | Comma, | ||
| 156 | Dot, | ||
| 157 | Slash, | ||
| 158 | CapsLockKey, | ||
| 159 | |||
| 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 | |||
| 173 | SystemRequest, | ||
| 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 | |||
| 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 | |||
| 205 | Key102, | ||
| 206 | Compose, | ||
| 207 | Power, | ||
| 208 | KPEqual, | ||
| 209 | |||
| 210 | F13, | ||
| 211 | F14, | ||
| 212 | F15, | ||
| 213 | F16, | ||
| 214 | F17, | ||
| 215 | F18, | ||
| 216 | F19, | ||
| 217 | F20, | ||
| 218 | F21, | ||
| 219 | F22, | ||
| 220 | F23, | ||
| 221 | F24, | ||
| 222 | |||
| 223 | Open, | ||
| 224 | Help, | ||
| 225 | Properties, | ||
| 226 | Front, | ||
| 227 | Stop, | ||
| 228 | Repeat, | ||
| 229 | Undo, | ||
| 230 | Cut, | ||
| 231 | Copy, | ||
| 232 | Paste, | ||
| 233 | Find, | ||
| 234 | Mute, | ||
| 235 | VolumeUp, | ||
| 236 | VolumeDown, | ||
| 237 | CapsLockActive, | ||
| 238 | NumLockActive, | ||
| 239 | ScrollLockActive, | ||
| 240 | KPComma, | ||
| 241 | |||
| 242 | KPLeftParenthesis, | ||
| 243 | KPRightParenthesis, | ||
| 244 | |||
| 245 | LeftControlKey = 0xE0, | ||
| 246 | LeftShiftKey, | ||
| 247 | LeftAltKey, | ||
| 248 | LeftMetaKey, | ||
| 249 | RightControlKey, | ||
| 250 | RightShiftKey, | ||
| 251 | RightAltKey, | ||
| 252 | RightMetaKey, | ||
| 253 | |||
| 254 | MediaPlayPause, | ||
| 255 | MediaStopCD, | ||
| 256 | MediaPrevious, | ||
| 257 | MediaNext, | ||
| 258 | MediaEject, | ||
| 259 | MediaVolumeUp, | ||
| 260 | MediaVolumeDown, | ||
| 261 | MediaMute, | ||
| 262 | MediaWebsite, | ||
| 263 | MediaBack, | ||
| 264 | MediaForward, | ||
| 265 | MediaStop, | ||
| 266 | MediaFind, | ||
| 267 | MediaScrollUp, | ||
| 268 | MediaScrollDown, | ||
| 269 | MediaEdit, | ||
| 270 | MediaSleep, | ||
| 271 | MediaCoffee, | ||
| 272 | MediaRefresh, | ||
| 273 | MediaCalculator, | ||
| 274 | |||
| 275 | NumKeyboardKeys, | ||
| 276 | }; | ||
| 277 | |||
| 278 | static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys."); | ||
| 279 | |||
| 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 | |||
| 293 | NumKeyboardMods, | ||
| 294 | }; | ||
| 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 | |||
| 300 | constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl; | ||
| 301 | constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods; | ||
| 302 | constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods; | ||
| 303 | |||
| 304 | } // namespace NativeKeyboard | ||
| 305 | |||
| 306 | using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>; | ||
| 307 | using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>; | ||
| 308 | using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>; | ||
| 309 | using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>; | ||
| 310 | using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>; | ||
| 311 | |||
| 312 | constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; | ||
| 313 | constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; | ||
| 314 | constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6; | ||
| 315 | constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E; | ||
| 316 | |||
| 317 | enum class ControllerType { | ||
| 318 | ProController, | ||
| 319 | DualJoycon, | ||
| 320 | RightJoycon, | ||
| 321 | LeftJoycon, | ||
| 322 | }; | ||
| 323 | |||
| 324 | struct PlayerInput { | ||
| 325 | bool connected; | ||
| 326 | ControllerType type; | ||
| 327 | ButtonsRaw buttons; | ||
| 328 | AnalogsRaw analogs; | ||
| 329 | |||
| 330 | u32 body_color_right; | ||
| 331 | u32 button_color_right; | ||
| 332 | u32 body_color_left; | ||
| 333 | u32 button_color_left; | ||
| 334 | }; | ||
| 335 | |||
| 336 | struct TouchscreenInput { | ||
| 337 | bool enabled; | ||
| 338 | std::string device; | ||
| 339 | |||
| 340 | u32 finger; | ||
| 341 | u32 diameter_x; | ||
| 342 | u32 diameter_y; | ||
| 343 | u32 rotation_angle; | ||
| 344 | }; | ||
| 345 | |||
| 113 | struct Values { | 346 | struct Values { |
| 114 | // System | 347 | // System |
| 115 | bool use_docked_mode; | 348 | bool use_docked_mode; |
| 116 | bool enable_nfc; | 349 | bool enable_nfc; |
| 350 | std::optional<u32> rng_seed; | ||
| 117 | s32 current_user; | 351 | s32 current_user; |
| 118 | s32 language_index; | 352 | s32 language_index; |
| 119 | 353 | ||
| 120 | // Controls | 354 | // Controls |
| 121 | std::array<std::string, NativeButton::NumButtons> buttons; | 355 | std::array<PlayerInput, 10> players; |
| 122 | std::array<std::string, NativeAnalog::NumAnalogs> analogs; | 356 | |
| 357 | bool mouse_enabled; | ||
| 358 | std::string mouse_device; | ||
| 359 | MouseButtonsRaw mouse_buttons; | ||
| 360 | |||
| 361 | bool keyboard_enabled; | ||
| 362 | KeyboardKeysRaw keyboard_keys; | ||
| 363 | KeyboardModsRaw keyboard_mods; | ||
| 364 | |||
| 365 | bool debug_pad_enabled; | ||
| 366 | ButtonsRaw debug_pad_buttons; | ||
| 367 | AnalogsRaw debug_pad_analogs; | ||
| 368 | |||
| 123 | std::string motion_device; | 369 | std::string motion_device; |
| 124 | std::string touch_device; | 370 | TouchscreenInput touchscreen; |
| 125 | std::atomic_bool is_device_reload_pending{true}; | 371 | std::atomic_bool is_device_reload_pending{true}; |
| 126 | 372 | ||
| 127 | // Core | 373 | // Core |
| @@ -157,6 +403,8 @@ struct Values { | |||
| 157 | bool use_gdbstub; | 403 | bool use_gdbstub; |
| 158 | u16 gdbstub_port; | 404 | u16 gdbstub_port; |
| 159 | std::string program_args; | 405 | std::string program_args; |
| 406 | bool dump_exefs; | ||
| 407 | bool dump_nso; | ||
| 160 | 408 | ||
| 161 | // WebService | 409 | // WebService |
| 162 | bool enable_telemetry; | 410 | bool enable_telemetry; |