diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/frontend/input.h | 12 | ||||
| -rw-r--r-- | src/core/hle/kernel/transfer_memory.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/transfer_memory.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.cpp | 90 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.h | 80 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 30 | ||||
| -rw-r--r-- | src/input_common/motion_input.cpp | 10 |
10 files changed, 220 insertions, 17 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 04cf3f5b9..c28abc24c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -393,6 +393,8 @@ add_library(core STATIC | |||
| 393 | hle/service/hid/xcd.cpp | 393 | hle/service/hid/xcd.cpp |
| 394 | hle/service/hid/xcd.h | 394 | hle/service/hid/xcd.h |
| 395 | hle/service/hid/errors.h | 395 | hle/service/hid/errors.h |
| 396 | hle/service/hid/controllers/console_sixaxis.cpp | ||
| 397 | hle/service/hid/controllers/console_sixaxis.h | ||
| 396 | hle/service/hid/controllers/controller_base.cpp | 398 | hle/service/hid/controllers/controller_base.cpp |
| 397 | hle/service/hid/controllers/controller_base.h | 399 | hle/service/hid/controllers/controller_base.h |
| 398 | hle/service/hid/controllers/debug_pad.cpp | 400 | hle/service/hid/controllers/debug_pad.cpp |
diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 88ebc6497..0c5d2b3b0 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <utility> | 11 | #include <utility> |
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/param_package.h" | 13 | #include "common/param_package.h" |
| 14 | #include "common/quaternion.h" | ||
| 14 | #include "common/vector_math.h" | 15 | #include "common/vector_math.h" |
| 15 | 16 | ||
| 16 | namespace Input { | 17 | namespace Input { |
| @@ -143,9 +144,10 @@ using VibrationDevice = InputDevice<u8>; | |||
| 143 | 144 | ||
| 144 | /** | 145 | /** |
| 145 | * A motion status is an object that returns a tuple of accelerometer state vector, | 146 | * A motion status is an object that returns a tuple of accelerometer state vector, |
| 146 | * gyroscope state vector, rotation state vector and orientation state matrix. | 147 | * gyroscope state vector, rotation state vector, orientation state matrix and quaterion state |
| 148 | * vector. | ||
| 147 | * | 149 | * |
| 148 | * For both vectors: | 150 | * For both 3D vectors: |
| 149 | * x+ is the same direction as RIGHT on D-pad. | 151 | * x+ is the same direction as RIGHT on D-pad. |
| 150 | * y+ is normal to the touch screen, pointing outward. | 152 | * y+ is normal to the touch screen, pointing outward. |
| 151 | * z+ is the same direction as UP on D-pad. | 153 | * z+ is the same direction as UP on D-pad. |
| @@ -164,9 +166,13 @@ using VibrationDevice = InputDevice<u8>; | |||
| 164 | * x vector | 166 | * x vector |
| 165 | * y vector | 167 | * y vector |
| 166 | * z vector | 168 | * z vector |
| 169 | * | ||
| 170 | * For quaternion state vector | ||
| 171 | * xyz vector | ||
| 172 | * w float | ||
| 167 | */ | 173 | */ |
| 168 | using MotionStatus = std::tuple<Common::Vec3<float>, Common::Vec3<float>, Common::Vec3<float>, | 174 | using MotionStatus = std::tuple<Common::Vec3<float>, Common::Vec3<float>, Common::Vec3<float>, |
| 169 | std::array<Common::Vec3f, 3>>; | 175 | std::array<Common::Vec3f, 3>, Common::Quaternion<f32>>; |
| 170 | 176 | ||
| 171 | /** | 177 | /** |
| 172 | * A motion device is an input device that returns a motion status object | 178 | * A motion device is an input device that returns a motion status object |
diff --git a/src/core/hle/kernel/transfer_memory.cpp b/src/core/hle/kernel/transfer_memory.cpp index cad063e4d..1dd65468d 100644 --- a/src/core/hle/kernel/transfer_memory.cpp +++ b/src/core/hle/kernel/transfer_memory.cpp | |||
| @@ -36,6 +36,10 @@ std::shared_ptr<TransferMemory> TransferMemory::Create(KernelCore& kernel, | |||
| 36 | return transfer_memory; | 36 | return transfer_memory; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | u8* TransferMemory::GetPointer() { | ||
| 40 | return memory.GetPointer(base_address); | ||
| 41 | } | ||
| 42 | |||
| 39 | const u8* TransferMemory::GetPointer() const { | 43 | const u8* TransferMemory::GetPointer() const { |
| 40 | return memory.GetPointer(base_address); | 44 | return memory.GetPointer(base_address); |
| 41 | } | 45 | } |
diff --git a/src/core/hle/kernel/transfer_memory.h b/src/core/hle/kernel/transfer_memory.h index 521951424..59328c0fe 100644 --- a/src/core/hle/kernel/transfer_memory.h +++ b/src/core/hle/kernel/transfer_memory.h | |||
| @@ -57,6 +57,9 @@ public: | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /// Gets a pointer to the backing block of this instance. | 59 | /// Gets a pointer to the backing block of this instance. |
| 60 | u8* GetPointer(); | ||
| 61 | |||
| 62 | /// Gets a pointer to the backing block of this instance. | ||
| 60 | const u8* GetPointer() const; | 63 | const u8* GetPointer() const; |
| 61 | 64 | ||
| 62 | /// Gets the size of the memory backing this instance in bytes. | 65 | /// Gets the size of the memory backing this instance in bytes. |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp new file mode 100644 index 000000000..913768fab --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/settings.h" | ||
| 6 | #include "core/core_timing.h" | ||
| 7 | #include "core/hle/service/hid/controllers/console_sixaxis.h" | ||
| 8 | |||
| 9 | namespace Service::HID { | ||
| 10 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; | ||
| 11 | |||
| 12 | Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system) | ||
| 13 | : ControllerBase(system) {} | ||
| 14 | Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default; | ||
| 15 | |||
| 16 | void Controller_ConsoleSixAxis::OnInit() {} | ||
| 17 | |||
| 18 | void Controller_ConsoleSixAxis::OnRelease() {} | ||
| 19 | |||
| 20 | void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | ||
| 21 | std::size_t size) { | ||
| 22 | seven_six_axis.header.timestamp = core_timing.GetCPUTicks(); | ||
| 23 | seven_six_axis.header.total_entry_count = 17; | ||
| 24 | |||
| 25 | if (!IsControllerActivated() || !is_transfer_memory_set) { | ||
| 26 | seven_six_axis.header.entry_count = 0; | ||
| 27 | seven_six_axis.header.last_entry_index = 0; | ||
| 28 | return; | ||
| 29 | } | ||
| 30 | seven_six_axis.header.entry_count = 16; | ||
| 31 | |||
| 32 | const auto& last_entry = | ||
| 33 | seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 34 | seven_six_axis.header.last_entry_index = (seven_six_axis.header.last_entry_index + 1) % 17; | ||
| 35 | auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 36 | |||
| 37 | cur_entry.sampling_number = last_entry.sampling_number + 1; | ||
| 38 | cur_entry.sampling_number2 = cur_entry.sampling_number; | ||
| 39 | |||
| 40 | // Try to read sixaxis sensor states | ||
| 41 | MotionDevice motion_device{}; | ||
| 42 | const auto& device = motions[0]; | ||
| 43 | if (device) { | ||
| 44 | std::tie(motion_device.accel, motion_device.gyro, motion_device.rotation, | ||
| 45 | motion_device.orientation, motion_device.quaternion) = device->GetStatus(); | ||
| 46 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_device.gyro.Length2() < 0.0001f; | ||
| 47 | } | ||
| 48 | |||
| 49 | cur_entry.accel = motion_device.accel; | ||
| 50 | // Zero gyro values as they just mess up with the camera | ||
| 51 | // Note: Probably a correct sensivity setting must be set | ||
| 52 | cur_entry.gyro = {}; | ||
| 53 | cur_entry.quaternion = { | ||
| 54 | { | ||
| 55 | motion_device.quaternion.xyz.y, | ||
| 56 | motion_device.quaternion.xyz.x, | ||
| 57 | -motion_device.quaternion.w, | ||
| 58 | }, | ||
| 59 | -motion_device.quaternion.xyz.z, | ||
| 60 | }; | ||
| 61 | |||
| 62 | console_six_axis.sampling_number++; | ||
| 63 | // TODO(German77): Find the purpose of those values | ||
| 64 | console_six_axis.verticalization_error = 0.0f; | ||
| 65 | console_six_axis.gyro_bias = {0.0f, 0.0f, 0.0f}; | ||
| 66 | |||
| 67 | // Update console six axis shared memory | ||
| 68 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); | ||
| 69 | // Update seven six axis transfer memory | ||
| 70 | std::memcpy(transfer_memory, &seven_six_axis, sizeof(seven_six_axis)); | ||
| 71 | } | ||
| 72 | |||
| 73 | void Controller_ConsoleSixAxis::OnLoadInputDevices() { | ||
| 74 | const auto player = Settings::values.players.GetValue()[0]; | ||
| 75 | std::transform(player.motions.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, | ||
| 76 | player.motions.begin() + Settings::NativeMotion::MOTION_HID_END, motions.begin(), | ||
| 77 | Input::CreateDevice<Input::MotionDevice>); | ||
| 78 | } | ||
| 79 | |||
| 80 | void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { | ||
| 81 | is_transfer_memory_set = true; | ||
| 82 | transfer_memory = t_mem; | ||
| 83 | } | ||
| 84 | |||
| 85 | void Controller_ConsoleSixAxis::ResetTimestamp() { | ||
| 86 | auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 87 | cur_entry.sampling_number = 0; | ||
| 88 | cur_entry.sampling_number2 = 0; | ||
| 89 | } | ||
| 90 | } // 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 new file mode 100644 index 000000000..1fae98e94 --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include "common/bit_field.h" | ||
| 9 | #include "common/common_types.h" | ||
| 10 | #include "common/quaternion.h" | ||
| 11 | #include "core/frontend/input.h" | ||
| 12 | #include "core/hle/service/hid/controllers/controller_base.h" | ||
| 13 | |||
| 14 | namespace Service::HID { | ||
| 15 | class Controller_ConsoleSixAxis final : public ControllerBase { | ||
| 16 | public: | ||
| 17 | explicit Controller_ConsoleSixAxis(Core::System& system); | ||
| 18 | ~Controller_ConsoleSixAxis() override; | ||
| 19 | |||
| 20 | // Called when the controller is initialized | ||
| 21 | void OnInit() override; | ||
| 22 | |||
| 23 | // When the controller is released | ||
| 24 | void OnRelease() override; | ||
| 25 | |||
| 26 | // When the controller is requesting an update for the shared memory | ||
| 27 | void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, size_t size) override; | ||
| 28 | |||
| 29 | // Called when input devices should be loaded | ||
| 30 | void OnLoadInputDevices() override; | ||
| 31 | |||
| 32 | // Called on InitializeSevenSixAxisSensor | ||
| 33 | void SetTransferMemoryPointer(u8* t_mem); | ||
| 34 | |||
| 35 | // Called on ResetSevenSixAxisSensorTimestamp | ||
| 36 | void ResetTimestamp(); | ||
| 37 | |||
| 38 | private: | ||
| 39 | struct SevenSixAxisState { | ||
| 40 | INSERT_PADDING_WORDS(4); // unused | ||
| 41 | s64_le sampling_number{}; | ||
| 42 | s64_le sampling_number2{}; | ||
| 43 | u64 unknown{}; | ||
| 44 | Common::Vec3f accel{}; | ||
| 45 | Common::Vec3f gyro{}; | ||
| 46 | Common::Quaternion<f32> quaternion{}; | ||
| 47 | }; | ||
| 48 | static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); | ||
| 49 | |||
| 50 | struct SevenSixAxisMemory { | ||
| 51 | CommonHeader header{}; | ||
| 52 | std::array<SevenSixAxisState, 0x21> sevensixaxis_states{}; | ||
| 53 | }; | ||
| 54 | static_assert(sizeof(SevenSixAxisMemory) == 0xA70, "SevenSixAxisMemory is an invalid size"); | ||
| 55 | |||
| 56 | struct ConsoleSharedMemory { | ||
| 57 | u64_le sampling_number{}; | ||
| 58 | bool is_seven_six_axis_sensor_at_rest{}; | ||
| 59 | f32 verticalization_error{}; | ||
| 60 | Common::Vec3f gyro_bias{}; | ||
| 61 | }; | ||
| 62 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); | ||
| 63 | |||
| 64 | struct MotionDevice { | ||
| 65 | Common::Vec3f accel; | ||
| 66 | Common::Vec3f gyro; | ||
| 67 | Common::Vec3f rotation; | ||
| 68 | std::array<Common::Vec3f, 3> orientation; | ||
| 69 | Common::Quaternion<f32> quaternion; | ||
| 70 | }; | ||
| 71 | |||
| 72 | using MotionArray = | ||
| 73 | std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>; | ||
| 74 | MotionArray motions; | ||
| 75 | u8* transfer_memory = nullptr; | ||
| 76 | bool is_transfer_memory_set = false; | ||
| 77 | ConsoleSharedMemory console_six_axis{}; | ||
| 78 | SevenSixAxisMemory seven_six_axis{}; | ||
| 79 | }; | ||
| 80 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 113a41254..249c300f6 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -654,8 +654,8 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
| 654 | const auto& device = motions[i][e]; | 654 | const auto& device = motions[i][e]; |
| 655 | if (device) { | 655 | if (device) { |
| 656 | std::tie(motion_devices[e].accel, motion_devices[e].gyro, | 656 | std::tie(motion_devices[e].accel, motion_devices[e].gyro, |
| 657 | motion_devices[e].rotation, motion_devices[e].orientation) = | 657 | motion_devices[e].rotation, motion_devices[e].orientation, |
| 658 | device->GetStatus(); | 658 | motion_devices[e].quaternion) = device->GetStatus(); |
| 659 | sixaxis_at_rest = sixaxis_at_rest && motion_devices[e].gyro.Length2() < 0.0001f; | 659 | sixaxis_at_rest = sixaxis_at_rest && motion_devices[e].gyro.Length2() < 0.0001f; |
| 660 | } | 660 | } |
| 661 | } | 661 | } |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index c3b07bd41..085f42c48 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include "common/bit_field.h" | 9 | #include "common/bit_field.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/quaternion.h" | ||
| 11 | #include "common/settings.h" | 12 | #include "common/settings.h" |
| 12 | #include "core/frontend/input.h" | 13 | #include "core/frontend/input.h" |
| 13 | #include "core/hle/kernel/object.h" | 14 | #include "core/hle/kernel/object.h" |
| @@ -467,6 +468,7 @@ private: | |||
| 467 | Common::Vec3f gyro; | 468 | Common::Vec3f gyro; |
| 468 | Common::Vec3f rotation; | 469 | Common::Vec3f rotation; |
| 469 | std::array<Common::Vec3f, 3> orientation; | 470 | std::array<Common::Vec3f, 3> orientation; |
| 471 | Common::Quaternion<f32> quaternion; | ||
| 470 | }; | 472 | }; |
| 471 | 473 | ||
| 472 | struct NfcXcdHandle { | 474 | struct NfcXcdHandle { |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 2aa1942cb..9c4bf6d16 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "core/hle/service/hid/xcd.h" | 26 | #include "core/hle/service/hid/xcd.h" |
| 27 | #include "core/hle/service/service.h" | 27 | #include "core/hle/service/service.h" |
| 28 | 28 | ||
| 29 | #include "core/hle/service/hid/controllers/console_sixaxis.h" | ||
| 29 | #include "core/hle/service/hid/controllers/controller_base.h" | 30 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 30 | #include "core/hle/service/hid/controllers/debug_pad.h" | 31 | #include "core/hle/service/hid/controllers/debug_pad.h" |
| 31 | #include "core/hle/service/hid/controllers/gesture.h" | 32 | #include "core/hle/service/hid/controllers/gesture.h" |
| @@ -67,7 +68,7 @@ IAppletResource::IAppletResource(Core::System& system_) | |||
| 67 | MakeController<Controller_Stubbed>(HidController::UniquePad); | 68 | MakeController<Controller_Stubbed>(HidController::UniquePad); |
| 68 | MakeController<Controller_NPad>(HidController::NPad); | 69 | MakeController<Controller_NPad>(HidController::NPad); |
| 69 | MakeController<Controller_Gesture>(HidController::Gesture); | 70 | MakeController<Controller_Gesture>(HidController::Gesture); |
| 70 | MakeController<Controller_Stubbed>(HidController::ConsoleSixAxisSensor); | 71 | MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor); |
| 71 | 72 | ||
| 72 | // Homebrew doesn't try to activate some controllers, so we activate them by default | 73 | // Homebrew doesn't try to activate some controllers, so we activate them by default |
| 73 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); | 74 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); |
| @@ -78,8 +79,6 @@ IAppletResource::IAppletResource(Core::System& system_) | |||
| 78 | GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); | 79 | GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); |
| 79 | GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); | 80 | GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); |
| 80 | GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); | 81 | GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); |
| 81 | GetController<Controller_Stubbed>(HidController::ConsoleSixAxisSensor) | ||
| 82 | .SetCommonHeaderOffset(0x3C200); | ||
| 83 | 82 | ||
| 84 | // Register update callbacks | 83 | // Register update callbacks |
| 85 | pad_update_event = Core::Timing::CreateEvent( | 84 | pad_update_event = Core::Timing::CreateEvent( |
| @@ -1404,8 +1403,9 @@ void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
| 1404 | IPC::RequestParser rp{ctx}; | 1403 | IPC::RequestParser rp{ctx}; |
| 1405 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1404 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1406 | 1405 | ||
| 1407 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1406 | applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); |
| 1408 | applet_resource_user_id); | 1407 | |
| 1408 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 1409 | 1409 | ||
| 1410 | IPC::ResponseBuilder rb{ctx, 2}; | 1410 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1411 | rb.Push(RESULT_SUCCESS); | 1411 | rb.Push(RESULT_SUCCESS); |
| @@ -1455,8 +1455,9 @@ void Hid::ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
| 1455 | IPC::RequestParser rp{ctx}; | 1455 | IPC::RequestParser rp{ctx}; |
| 1456 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1456 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1457 | 1457 | ||
| 1458 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1458 | applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); |
| 1459 | applet_resource_user_id); | 1459 | |
| 1460 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 1460 | 1461 | ||
| 1461 | IPC::ResponseBuilder rb{ctx, 2}; | 1462 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1462 | rb.Push(RESULT_SUCCESS); | 1463 | rb.Push(RESULT_SUCCESS); |
| @@ -1518,8 +1519,15 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
| 1518 | ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); | 1519 | ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); |
| 1519 | ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); | 1520 | ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); |
| 1520 | 1521 | ||
| 1522 | // Activate console six axis controller | ||
| 1523 | applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | ||
| 1524 | .ActivateController(); | ||
| 1525 | |||
| 1526 | applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | ||
| 1527 | .SetTransferMemoryPointer(t_mem_1->GetPointer()); | ||
| 1528 | |||
| 1521 | LOG_WARNING(Service_HID, | 1529 | LOG_WARNING(Service_HID, |
| 1522 | "(STUBBED) called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " | 1530 | "called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " |
| 1523 | "applet_resource_user_id={}", | 1531 | "applet_resource_user_id={}", |
| 1524 | t_mem_1_handle, t_mem_2_handle, applet_resource_user_id); | 1532 | t_mem_1_handle, t_mem_2_handle, applet_resource_user_id); |
| 1525 | 1533 | ||
| @@ -1542,8 +1550,10 @@ void Hid::ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx) { | |||
| 1542 | IPC::RequestParser rp{ctx}; | 1550 | IPC::RequestParser rp{ctx}; |
| 1543 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1551 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1544 | 1552 | ||
| 1545 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1553 | applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) |
| 1546 | applet_resource_user_id); | 1554 | .ResetTimestamp(); |
| 1555 | |||
| 1556 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 1547 | 1557 | ||
| 1548 | IPC::ResponseBuilder rb{ctx, 2}; | 1558 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1549 | rb.Push(RESULT_SUCCESS); | 1559 | rb.Push(RESULT_SUCCESS); |
diff --git a/src/input_common/motion_input.cpp b/src/input_common/motion_input.cpp index 6a65f175e..1c9d561c0 100644 --- a/src/input_common/motion_input.cpp +++ b/src/input_common/motion_input.cpp | |||
| @@ -195,7 +195,8 @@ Input::MotionStatus MotionInput::GetMotion() const { | |||
| 195 | const Common::Vec3f accelerometer = GetAcceleration(); | 195 | const Common::Vec3f accelerometer = GetAcceleration(); |
| 196 | const Common::Vec3f rotation = GetRotations(); | 196 | const Common::Vec3f rotation = GetRotations(); |
| 197 | const std::array<Common::Vec3f, 3> orientation = GetOrientation(); | 197 | const std::array<Common::Vec3f, 3> orientation = GetOrientation(); |
| 198 | return {accelerometer, gyroscope, rotation, orientation}; | 198 | const Common::Quaternion<f32> quaternion = GetQuaternion(); |
| 199 | return {accelerometer, gyroscope, rotation, orientation, quaternion}; | ||
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const { | 202 | Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const { |
| @@ -218,7 +219,12 @@ Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_m | |||
| 218 | Common::Vec3f{0.0f, 1.0f, 0.0f}, | 219 | Common::Vec3f{0.0f, 1.0f, 0.0f}, |
| 219 | Common::Vec3f{0.0f, 0.0f, 1.0f}, | 220 | Common::Vec3f{0.0f, 0.0f, 1.0f}, |
| 220 | }; | 221 | }; |
| 221 | return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation}; | 222 | constexpr Common::Quaternion<f32> quaternion{ |
| 223 | {0.0f, 0.0f, 0.0f}, | ||
| 224 | 1.0f, | ||
| 225 | }; | ||
| 226 | return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation, | ||
| 227 | quaternion}; | ||
| 222 | } | 228 | } |
| 223 | 229 | ||
| 224 | void MotionInput::ResetOrientation() { | 230 | void MotionInput::ResetOrientation() { |