diff options
author | german77 <juangerman-13@hotmail.com> | 2021-04-22 20:15:59 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2021-04-24 05:12:41 +0200 |
commit | c19ad21ae855c9143a871e378e8d8c59abcaebfa (patch) | |
tree | 90499012c2bcac1620ca69e4ef6b10edb5ffe009 /src/core/hle/service/hid/controllers/console_sixaxis.h | |
parent | Merge pull request #6224 from Morph1984/hid_InitializeSevenSixAxisSensor (diff) | |
download | yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.tar yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.tar.gz yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.tar.bz2 yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.tar.lz yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.tar.xz yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.tar.zst yuzu-c19ad21ae855c9143a871e378e8d8c59abcaebfa.zip |
Diffstat (limited to 'src/core/hle/service/hid/controllers/console_sixaxis.h')
-rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.h | 80 |
1 files changed, 80 insertions, 0 deletions
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..ac0501683 --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h @@ -0,0 +1,80 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include "common/bit_field.h" +#include "common/common_types.h" +#include "common/quaternion.h" +#include "core/frontend/input.h" +#include "core/hle/service/hid/controllers/controller_base.h" + +namespace Service::HID { +class Controller_ConsoleSixAxis final : public ControllerBase { +public: + explicit Controller_ConsoleSixAxis(Core::System& system); + ~Controller_ConsoleSixAxis() override; + + // Called when the controller is initialized + void OnInit() override; + + // When the controller is released + void OnRelease() override; + + // When the controller is requesting an update for the shared memory + void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, size_t size) override; + + // Called when input devices should be loaded + void OnLoadInputDevices() override; + + // Called on InitializeSevenSixAxisSensor + void SetTransferMemoryPointer(u8* t_mem_1); + + // Called on ResetSevenSixAxisSensorTimestamp + void ResetTimestamp(); + +private: + struct SevenSixAxisState { + INSERT_PADDING_WORDS(4); // unused + s64_le sampling_number{}; + s64_le sampling_number2{}; + u64 unknown{}; + Common::Vec3f accel{}; + Common::Vec3f gyro{}; + Common::Quaternion<f32> quaternion{}; + }; + static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); + + struct SevenSixAxisMemory { + CommonHeader header{}; + std::array<SevenSixAxisState, 0x21> sevensixaxis_states{}; + }; + static_assert(sizeof(SevenSixAxisMemory) == 0xA70, "SevenSixAxisMemory is an invalid size"); + + struct ConsoleSharedMemory { + u64_le sampling_number{}; + bool is_seven_six_axis_sensor_at_rest{}; + f32 verticalization_error{}; + Common::Vec3f gyro_bias{}; + }; + static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); + + struct MotionDevice { + Common::Vec3f accel; + Common::Vec3f gyro; + Common::Vec3f rotation; + std::array<Common::Vec3f, 3> orientation; + Common::Quaternion<f32> quaternion; + }; + + using MotionArray = + std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>; + u8* transfer_memory; + MotionArray motions; + bool is_transfer_memory_set = false; + ConsoleSharedMemory console_six_axis{}; + SevenSixAxisMemory seven_six_axis{}; +}; +} // namespace Service::HID |