diff options
| author | 2021-11-01 19:49:14 -0600 | |
|---|---|---|
| committer | 2021-11-24 20:30:27 -0600 | |
| commit | 136eb9c4c2b2425c2dd45a79cf444dee7170714d (patch) | |
| tree | 74a055a08126fdd33b2071baa08125177847db6e /src/core/hid/input_converter.cpp | |
| parent | second commit lion review (diff) | |
| download | yuzu-136eb9c4c2b2425c2dd45a79cf444dee7170714d.tar.gz yuzu-136eb9c4c2b2425c2dd45a79cf444dee7170714d.tar.xz yuzu-136eb9c4c2b2425c2dd45a79cf444dee7170714d.zip | |
core/hid: Fully emulate motion from button
Diffstat (limited to 'src/core/hid/input_converter.cpp')
| -rw-r--r-- | src/core/hid/input_converter.cpp | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 5b123bd3a..480b862fd 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -74,45 +74,53 @@ Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatu | |||
| 74 | Common::Input::MotionStatus status{}; | 74 | Common::Input::MotionStatus status{}; |
| 75 | switch (callback.type) { | 75 | switch (callback.type) { |
| 76 | case Common::Input::InputType::Button: { | 76 | case Common::Input::InputType::Button: { |
| 77 | Common::Input::AnalogProperties properties{ | ||
| 78 | .deadzone = 0.0f, | ||
| 79 | .range = 1.0f, | ||
| 80 | .offset = 0.0f, | ||
| 81 | }; | ||
| 82 | status.delta_timestamp = 5000; | ||
| 83 | status.force_update = true; | ||
| 84 | status.accel.x = { | ||
| 85 | .value = 0.0f, | ||
| 86 | .raw_value = 0.0f, | ||
| 87 | .properties = properties, | ||
| 88 | }; | ||
| 89 | status.accel.y = { | ||
| 90 | .value = 0.0f, | ||
| 91 | .raw_value = 0.0f, | ||
| 92 | .properties = properties, | ||
| 93 | }; | ||
| 94 | status.accel.z = { | ||
| 95 | .value = 0.0f, | ||
| 96 | .raw_value = -1.0f, | ||
| 97 | .properties = properties, | ||
| 98 | }; | ||
| 99 | status.gyro.x = { | ||
| 100 | .value = 0.0f, | ||
| 101 | .raw_value = 0.0f, | ||
| 102 | .properties = properties, | ||
| 103 | }; | ||
| 104 | status.gyro.y = { | ||
| 105 | .value = 0.0f, | ||
| 106 | .raw_value = 0.0f, | ||
| 107 | .properties = properties, | ||
| 108 | }; | ||
| 109 | status.gyro.z = { | ||
| 110 | .value = 0.0f, | ||
| 111 | .raw_value = 0.0f, | ||
| 112 | .properties = properties, | ||
| 113 | }; | ||
| 77 | if (TransformToButton(callback).value) { | 114 | if (TransformToButton(callback).value) { |
| 78 | std::random_device device; | 115 | std::random_device device; |
| 79 | std::mt19937 gen(device()); | 116 | std::mt19937 gen(device()); |
| 80 | std::uniform_int_distribution<s16> distribution(-1000, 1000); | 117 | std::uniform_int_distribution<s16> distribution(-1000, 1000); |
| 81 | Common::Input::AnalogProperties properties{ | 118 | status.accel.x.raw_value = static_cast<f32>(distribution(gen)) * 0.001f; |
| 82 | .deadzone = 0.0, | 119 | status.accel.y.raw_value = static_cast<f32>(distribution(gen)) * 0.001f; |
| 83 | .range = 1.0f, | 120 | status.accel.z.raw_value = static_cast<f32>(distribution(gen)) * 0.001f; |
| 84 | .offset = 0.0, | 121 | status.gyro.x.raw_value = static_cast<f32>(distribution(gen)) * 0.001f; |
| 85 | }; | 122 | status.gyro.y.raw_value = static_cast<f32>(distribution(gen)) * 0.001f; |
| 86 | status.accel.x = { | 123 | status.gyro.z.raw_value = static_cast<f32>(distribution(gen)) * 0.001f; |
| 87 | .value = 0, | ||
| 88 | .raw_value = static_cast<f32>(distribution(gen)) * 0.001f, | ||
| 89 | .properties = properties, | ||
| 90 | }; | ||
| 91 | status.accel.y = { | ||
| 92 | .value = 0, | ||
| 93 | .raw_value = static_cast<f32>(distribution(gen)) * 0.001f, | ||
| 94 | .properties = properties, | ||
| 95 | }; | ||
| 96 | status.accel.z = { | ||
| 97 | .value = 0, | ||
| 98 | .raw_value = static_cast<f32>(distribution(gen)) * 0.001f, | ||
| 99 | .properties = properties, | ||
| 100 | }; | ||
| 101 | status.gyro.x = { | ||
| 102 | .value = 0, | ||
| 103 | .raw_value = static_cast<f32>(distribution(gen)) * 0.001f, | ||
| 104 | .properties = properties, | ||
| 105 | }; | ||
| 106 | status.gyro.y = { | ||
| 107 | .value = 0, | ||
| 108 | .raw_value = static_cast<f32>(distribution(gen)) * 0.001f, | ||
| 109 | .properties = properties, | ||
| 110 | }; | ||
| 111 | status.gyro.z = { | ||
| 112 | .value = 0, | ||
| 113 | .raw_value = static_cast<f32>(distribution(gen)) * 0.001f, | ||
| 114 | .properties = properties, | ||
| 115 | }; | ||
| 116 | } | 124 | } |
| 117 | break; | 125 | break; |
| 118 | } | 126 | } |