diff options
| author | 2024-02-24 00:38:13 -0500 | |
|---|---|---|
| committer | 2024-02-24 00:38:13 -0500 | |
| commit | d1e0039bc87a28e42b05b324d0f15dc063a898b1 (patch) | |
| tree | c17bd7729a3e6ec78a9e261c38a7dd013a4f3832 /src/input_common/drivers/android.h | |
| parent | Merge pull request #13146 from wheremyfoodat/patch-1 (diff) | |
| parent | android: Play vibrations asynchronously (diff) | |
| download | yuzu-d1e0039bc87a28e42b05b324d0f15dc063a898b1.tar.gz yuzu-d1e0039bc87a28e42b05b324d0f15dc063a898b1.tar.xz yuzu-d1e0039bc87a28e42b05b324d0f15dc063a898b1.zip | |
Merge pull request #13142 from t895/vibration-queue
android: Play vibrations asynchronously
Diffstat (limited to 'src/input_common/drivers/android.h')
| -rw-r--r-- | src/input_common/drivers/android.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/input_common/drivers/android.h b/src/input_common/drivers/android.h index 8a386c1b1..03e2b2c98 100644 --- a/src/input_common/drivers/android.h +++ b/src/input_common/drivers/android.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <set> | 6 | #include <set> |
| 7 | #include <common/threadsafe_queue.h> | ||
| 7 | #include <jni.h> | 8 | #include <jni.h> |
| 8 | #include "input_common/input_engine.h" | 9 | #include "input_common/input_engine.h" |
| 9 | 10 | ||
| @@ -16,6 +17,8 @@ class Android final : public InputEngine { | |||
| 16 | public: | 17 | public: |
| 17 | explicit Android(std::string input_engine_); | 18 | explicit Android(std::string input_engine_); |
| 18 | 19 | ||
| 20 | ~Android() override; | ||
| 21 | |||
| 19 | /** | 22 | /** |
| 20 | * Registers controller number to accept new inputs. | 23 | * Registers controller number to accept new inputs. |
| 21 | * @param j_input_device YuzuInputDevice object from the Android frontend to register. | 24 | * @param j_input_device YuzuInputDevice object from the Android frontend to register. |
| @@ -89,6 +92,9 @@ private: | |||
| 89 | /// Returns the correct identifier corresponding to the player index | 92 | /// Returns the correct identifier corresponding to the player index |
| 90 | PadIdentifier GetIdentifier(const std::string& guid, size_t port) const; | 93 | PadIdentifier GetIdentifier(const std::string& guid, size_t port) const; |
| 91 | 94 | ||
| 95 | /// Takes all vibrations from the queue and sends the command to the controller | ||
| 96 | void SendVibrations(JNIEnv* env, std::stop_token token); | ||
| 97 | |||
| 92 | static constexpr s32 AXIS_X = 0; | 98 | static constexpr s32 AXIS_X = 0; |
| 93 | static constexpr s32 AXIS_Y = 1; | 99 | static constexpr s32 AXIS_Y = 1; |
| 94 | static constexpr s32 AXIS_Z = 11; | 100 | static constexpr s32 AXIS_Z = 11; |
| @@ -133,6 +139,10 @@ private: | |||
| 133 | redmagic_vid, backbone_labs_vid, xbox_vid}; | 139 | redmagic_vid, backbone_labs_vid, xbox_vid}; |
| 134 | const std::vector<std::string> flipped_xy_vids{sony_vid, razer_vid, redmagic_vid, | 140 | const std::vector<std::string> flipped_xy_vids{sony_vid, razer_vid, redmagic_vid, |
| 135 | backbone_labs_vid, xbox_vid}; | 141 | backbone_labs_vid, xbox_vid}; |
| 142 | |||
| 143 | /// Queue of vibration request to controllers | ||
| 144 | Common::SPSCQueue<VibrationRequest> vibration_queue; | ||
| 145 | std::jthread vibration_thread; | ||
| 136 | }; | 146 | }; |
| 137 | 147 | ||
| 138 | } // namespace InputCommon | 148 | } // namespace InputCommon |