diff options
| author | 2021-11-29 12:40:29 -0600 | |
|---|---|---|
| committer | 2021-12-12 23:26:04 -0600 | |
| commit | 316f80af87c3290ad3ceda99fe9cf02f1d935b0c (patch) | |
| tree | 6b933d2399f02ff42c077d0f2f342b9ffbb21cf5 /src/core/hle | |
| parent | Merge pull request #7488 from vonchenplus/support_multiple_videos_playing (diff) | |
| download | yuzu-316f80af87c3290ad3ceda99fe9cf02f1d935b0c.tar.gz yuzu-316f80af87c3290ad3ceda99fe9cf02f1d935b0c.tar.xz yuzu-316f80af87c3290ad3ceda99fe9cf02f1d935b0c.zip | |
service/hid: Improve console motion accuracy
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.h | 10 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp index f0f3105dc..a727b3582 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.cpp +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp | |||
| @@ -33,15 +33,14 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti | |||
| 33 | const auto& last_entry = seven_sixaxis_lifo.ReadCurrentEntry().state; | 33 | const auto& last_entry = seven_sixaxis_lifo.ReadCurrentEntry().state; |
| 34 | next_seven_sixaxis_state.sampling_number = last_entry.sampling_number + 1; | 34 | next_seven_sixaxis_state.sampling_number = last_entry.sampling_number + 1; |
| 35 | 35 | ||
| 36 | // Try to read sixaxis sensor states | ||
| 37 | const auto motion_status = console->GetMotion(); | 36 | const auto motion_status = console->GetMotion(); |
| 37 | last_global_timestamp = core_timing.GetGlobalTimeNs().count(); | ||
| 38 | 38 | ||
| 39 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; | 39 | // This value increments every time the switch goes to sleep |
| 40 | 40 | next_seven_sixaxis_state.unknown = 1; | |
| 41 | next_seven_sixaxis_state.timestamp = last_global_timestamp - last_saved_timestamp; | ||
| 41 | next_seven_sixaxis_state.accel = motion_status.accel; | 42 | next_seven_sixaxis_state.accel = motion_status.accel; |
| 42 | // Zero gyro values as they just mess up with the camera | 43 | next_seven_sixaxis_state.gyro = motion_status.gyro; |
| 43 | // Note: Probably a correct sensivity setting must be set | ||
| 44 | next_seven_sixaxis_state.gyro = {}; | ||
| 45 | next_seven_sixaxis_state.quaternion = { | 44 | next_seven_sixaxis_state.quaternion = { |
| 46 | { | 45 | { |
| 47 | motion_status.quaternion.xyz.y, | 46 | motion_status.quaternion.xyz.y, |
| @@ -52,9 +51,9 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti | |||
| 52 | }; | 51 | }; |
| 53 | 52 | ||
| 54 | console_six_axis.sampling_number++; | 53 | console_six_axis.sampling_number++; |
| 55 | // TODO(German77): Find the purpose of those values | 54 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; |
| 56 | console_six_axis.verticalization_error = 0.0f; | 55 | console_six_axis.verticalization_error = motion_status.verticalization_error; |
| 57 | console_six_axis.gyro_bias = {0.0f, 0.0f, 0.0f}; | 56 | console_six_axis.gyro_bias = motion_status.gyro_bias; |
| 58 | 57 | ||
| 59 | // Update console six axis shared memory | 58 | // Update console six axis shared memory |
| 60 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); | 59 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); |
| @@ -69,7 +68,6 @@ void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { | |||
| 69 | } | 68 | } |
| 70 | 69 | ||
| 71 | void Controller_ConsoleSixAxis::ResetTimestamp() { | 70 | void Controller_ConsoleSixAxis::ResetTimestamp() { |
| 72 | seven_sixaxis_lifo.buffer_count = 0; | 71 | last_saved_timestamp = last_global_timestamp; |
| 73 | seven_sixaxis_lifo.buffer_tail = 0; | ||
| 74 | } | 72 | } |
| 75 | } // namespace Service::HID | 73 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h index 279241858..26d153f0c 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.h +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h | |||
| @@ -39,8 +39,9 @@ public: | |||
| 39 | 39 | ||
| 40 | private: | 40 | private: |
| 41 | struct SevenSixAxisState { | 41 | struct SevenSixAxisState { |
| 42 | INSERT_PADDING_WORDS(4); // unused | 42 | INSERT_PADDING_WORDS(2); // unused |
| 43 | s64 sampling_number{}; | 43 | u64 timestamp{}; |
| 44 | u64 sampling_number{}; | ||
| 44 | u64 unknown{}; | 45 | u64 unknown{}; |
| 45 | Common::Vec3f accel{}; | 46 | Common::Vec3f accel{}; |
| 46 | Common::Vec3f gyro{}; | 47 | Common::Vec3f gyro{}; |
| @@ -52,9 +53,10 @@ private: | |||
| 52 | struct ConsoleSharedMemory { | 53 | struct ConsoleSharedMemory { |
| 53 | u64 sampling_number{}; | 54 | u64 sampling_number{}; |
| 54 | bool is_seven_six_axis_sensor_at_rest{}; | 55 | bool is_seven_six_axis_sensor_at_rest{}; |
| 55 | INSERT_PADDING_BYTES(4); // padding | 56 | INSERT_PADDING_BYTES(3); // padding |
| 56 | f32 verticalization_error{}; | 57 | f32 verticalization_error{}; |
| 57 | Common::Vec3f gyro_bias{}; | 58 | Common::Vec3f gyro_bias{}; |
| 59 | INSERT_PADDING_BYTES(4); // padding | ||
| 58 | }; | 60 | }; |
| 59 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); | 61 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); |
| 60 | 62 | ||
| @@ -64,6 +66,8 @@ private: | |||
| 64 | Core::HID::EmulatedConsole* console; | 66 | Core::HID::EmulatedConsole* console; |
| 65 | u8* transfer_memory = nullptr; | 67 | u8* transfer_memory = nullptr; |
| 66 | bool is_transfer_memory_set = false; | 68 | bool is_transfer_memory_set = false; |
| 69 | u64 last_saved_timestamp{}; | ||
| 70 | u64 last_global_timestamp{}; | ||
| 67 | ConsoleSharedMemory console_six_axis{}; | 71 | ConsoleSharedMemory console_six_axis{}; |
| 68 | SevenSixAxisState next_seven_sixaxis_state{}; | 72 | SevenSixAxisState next_seven_sixaxis_state{}; |
| 69 | }; | 73 | }; |