diff options
| author | 2021-10-17 00:33:00 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:24 -0600 | |
| commit | 72e5920240381cbe775dc38fcdff88cf46b55101 (patch) | |
| tree | 3f981ca452357b19ae104fdde3692c8ad4a3bf0f /src/core/hid/emulated_console.h | |
| parent | kraken: Fix errors from rebase and format files (diff) | |
| download | yuzu-72e5920240381cbe775dc38fcdff88cf46b55101.tar.gz yuzu-72e5920240381cbe775dc38fcdff88cf46b55101.tar.xz yuzu-72e5920240381cbe775dc38fcdff88cf46b55101.zip | |
core/hid: Documment some files
Diffstat (limited to 'src/core/hid/emulated_console.h')
| -rw-r--r-- | src/core/hid/emulated_console.h | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/src/core/hid/emulated_console.h b/src/core/hid/emulated_console.h index d9e275042..7d6cf9506 100644 --- a/src/core/hid/emulated_console.h +++ b/src/core/hid/emulated_console.h | |||
| @@ -38,9 +38,10 @@ struct TouchFinger { | |||
| 38 | Common::Point<float> position{}; | 38 | Common::Point<float> position{}; |
| 39 | u32_le id{}; | 39 | u32_le id{}; |
| 40 | bool pressed{}; | 40 | bool pressed{}; |
| 41 | Core::HID::TouchAttribute attribute{}; | 41 | TouchAttribute attribute{}; |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | // Contains all motion related data that is used on the services | ||
| 44 | struct ConsoleMotion { | 45 | struct ConsoleMotion { |
| 45 | bool is_at_rest{}; | 46 | bool is_at_rest{}; |
| 46 | Common::Vec3f accel{}; | 47 | Common::Vec3f accel{}; |
| @@ -57,7 +58,7 @@ struct ConsoleStatus { | |||
| 57 | ConsoleMotionValues motion_values{}; | 58 | ConsoleMotionValues motion_values{}; |
| 58 | TouchValues touch_values{}; | 59 | TouchValues touch_values{}; |
| 59 | 60 | ||
| 60 | // Data for Nintendo devices; | 61 | // Data for HID services |
| 61 | ConsoleMotion motion_state{}; | 62 | ConsoleMotion motion_state{}; |
| 62 | TouchFingerState touch_state{}; | 63 | TouchFingerState touch_state{}; |
| 63 | }; | 64 | }; |
| @@ -75,52 +76,90 @@ struct ConsoleUpdateCallback { | |||
| 75 | class EmulatedConsole { | 76 | class EmulatedConsole { |
| 76 | public: | 77 | public: |
| 77 | /** | 78 | /** |
| 78 | * TODO: Write description | 79 | * Contains all input data related to the console like motion and touch input |
| 79 | * | ||
| 80 | * @param npad_id_type | ||
| 81 | */ | 80 | */ |
| 82 | explicit EmulatedConsole(); | 81 | EmulatedConsole(); |
| 83 | ~EmulatedConsole(); | 82 | ~EmulatedConsole(); |
| 84 | 83 | ||
| 85 | YUZU_NON_COPYABLE(EmulatedConsole); | 84 | YUZU_NON_COPYABLE(EmulatedConsole); |
| 86 | YUZU_NON_MOVEABLE(EmulatedConsole); | 85 | YUZU_NON_MOVEABLE(EmulatedConsole); |
| 87 | 86 | ||
| 88 | void ReloadFromSettings(); | 87 | /// Removes all callbacks created from input devices |
| 89 | void ReloadInput(); | ||
| 90 | void UnloadInput(); | 88 | void UnloadInput(); |
| 91 | 89 | ||
| 90 | /// Sets the emulated console into configuring mode. Locking all HID service events from being | ||
| 91 | /// moddified | ||
| 92 | void EnableConfiguration(); | 92 | void EnableConfiguration(); |
| 93 | |||
| 94 | /// Returns the emulated console to the normal behaivour | ||
| 93 | void DisableConfiguration(); | 95 | void DisableConfiguration(); |
| 96 | |||
| 97 | /// Returns true if the emulated console is on configuring mode | ||
| 94 | bool IsConfiguring() const; | 98 | bool IsConfiguring() const; |
| 99 | |||
| 100 | /// Reload all input devices | ||
| 101 | void ReloadInput(); | ||
| 102 | |||
| 103 | /// Overrides current mapped devices with the stored configuration and reloads all input devices | ||
| 104 | void ReloadFromSettings(); | ||
| 105 | |||
| 106 | /// Saves the current mapped configuration | ||
| 95 | void SaveCurrentConfig(); | 107 | void SaveCurrentConfig(); |
| 108 | |||
| 109 | /// Reverts any mapped changes made that weren't saved | ||
| 96 | void RestoreConfig(); | 110 | void RestoreConfig(); |
| 97 | 111 | ||
| 112 | // Returns the current mapped motion device | ||
| 98 | Common::ParamPackage GetMotionParam() const; | 113 | Common::ParamPackage GetMotionParam() const; |
| 99 | 114 | ||
| 115 | /** | ||
| 116 | * Updates the current mapped motion device | ||
| 117 | * @param ParamPackage with controller data to be mapped | ||
| 118 | */ | ||
| 100 | void SetMotionParam(Common::ParamPackage param); | 119 | void SetMotionParam(Common::ParamPackage param); |
| 101 | 120 | ||
| 121 | /// Returns the latest status of motion input from the console with parameters | ||
| 102 | ConsoleMotionValues GetMotionValues() const; | 122 | ConsoleMotionValues GetMotionValues() const; |
| 123 | |||
| 124 | /// Returns the latest status of touch input from the console with parameters | ||
| 103 | TouchValues GetTouchValues() const; | 125 | TouchValues GetTouchValues() const; |
| 104 | 126 | ||
| 127 | /// Returns the latest status of motion input from the console | ||
| 105 | ConsoleMotion GetMotion() const; | 128 | ConsoleMotion GetMotion() const; |
| 129 | |||
| 130 | /// Returns the latest status of touch input from the console | ||
| 106 | TouchFingerState GetTouch() const; | 131 | TouchFingerState GetTouch() const; |
| 107 | 132 | ||
| 133 | /** | ||
| 134 | * Adds a callback to the list of events | ||
| 135 | * @param ConsoleUpdateCallback that will be triggered | ||
| 136 | * @return an unique key corresponding to the callback index in the list | ||
| 137 | */ | ||
| 108 | int SetCallback(ConsoleUpdateCallback update_callback); | 138 | int SetCallback(ConsoleUpdateCallback update_callback); |
| 139 | |||
| 140 | /** | ||
| 141 | * Removes a callback from the list stopping any future events to this object | ||
| 142 | * @param Key corresponding to the callback index in the list | ||
| 143 | */ | ||
| 109 | void DeleteCallback(int key); | 144 | void DeleteCallback(int key); |
| 110 | 145 | ||
| 111 | private: | 146 | private: |
| 112 | /** | 147 | /** |
| 113 | * Sets the status of a button. Applies toggle properties to the output. | 148 | * Updates the motion status of the console |
| 114 | * | 149 | * @param A CallbackStatus containing gyro and accelerometer data |
| 115 | * @param A CallbackStatus and a button index number | ||
| 116 | */ | 150 | */ |
| 117 | void SetMotion(Input::CallbackStatus callback); | 151 | void SetMotion(Input::CallbackStatus callback); |
| 152 | |||
| 153 | /** | ||
| 154 | * Updates the touch status of the console | ||
| 155 | * @param callback: A CallbackStatus containing the touch position | ||
| 156 | * @param index: Finger ID to be updated | ||
| 157 | */ | ||
| 118 | void SetTouch(Input::CallbackStatus callback, std::size_t index); | 158 | void SetTouch(Input::CallbackStatus callback, std::size_t index); |
| 119 | 159 | ||
| 120 | /** | 160 | /** |
| 121 | * Triggers a callback that something has changed | 161 | * Triggers a callback that something has changed on the console status |
| 122 | * | 162 | * @param Input type of the event to trigger |
| 123 | * @param Input type of the trigger | ||
| 124 | */ | 163 | */ |
| 125 | void TriggerOnChange(ConsoleTriggerType type); | 164 | void TriggerOnChange(ConsoleTriggerType type); |
| 126 | 165 | ||
| @@ -136,6 +175,8 @@ private: | |||
| 136 | mutable std::mutex mutex; | 175 | mutable std::mutex mutex; |
| 137 | std::unordered_map<int, ConsoleUpdateCallback> callback_list; | 176 | std::unordered_map<int, ConsoleUpdateCallback> callback_list; |
| 138 | int last_callback_key = 0; | 177 | int last_callback_key = 0; |
| 178 | |||
| 179 | // Stores the current status of all console input | ||
| 139 | ConsoleStatus console; | 180 | ConsoleStatus console; |
| 140 | }; | 181 | }; |
| 141 | 182 | ||