diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2022-04-20 19:00:26 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2022-04-24 00:11:43 +0200 |
commit | 0f3ad939a85494a8a9bdcb6f357c774f385f647e (patch) | |
tree | 1c050188b8ffb83815adcef9fd3efd200627cb90 /src/core/hle | |
parent | service: hid: Access shared memory directly (diff) | |
download | yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.tar yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.tar.gz yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.tar.bz2 yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.tar.lz yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.tar.xz yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.tar.zst yuzu-0f3ad939a85494a8a9bdcb6f357c774f385f647e.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.h | 8 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/debug_pad.h | 15 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/gesture.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/gesture.h | 30 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.h | 12 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/mouse.cpp | 3 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/mouse.h | 4 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 9 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/stubbed.h | 10 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 3 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 16 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/xpad.cpp | 3 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/xpad.h | 12 |
15 files changed, 69 insertions, 68 deletions
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp index c93bcd678..bb3cba910 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.cpp +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp @@ -15,8 +15,8 @@ Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::HID::HIDCore& hid_cor console = hid_core.GetEmulatedConsole(); static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size, "ConsoleSharedMemory is bigger than the shared memory"); - shared_memory = - std::construct_at(reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); + shared_memory = std::construct_at( + reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); } Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default; diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h index 85b281957..2fd11538f 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.h +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h @@ -61,13 +61,13 @@ private: Lifo<SevenSixAxisState, 0x21> seven_sixaxis_lifo{}; static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size"); - ConsoleSharedMemory* shared_memory; - - Core::HID::EmulatedConsole* console; + SevenSixAxisState next_seven_sixaxis_state{}; u8* transfer_memory = nullptr; + ConsoleSharedMemory* shared_memory = nullptr; + Core::HID::EmulatedConsole* console = nullptr; + bool is_transfer_memory_set = false; u64 last_saved_timestamp{}; u64 last_global_timestamp{}; - SevenSixAxisState next_seven_sixaxis_state{}; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/debug_pad.h b/src/core/hle/service/hid/controllers/debug_pad.h index 543e9f3a6..68ff0ea79 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.h +++ b/src/core/hle/service/hid/controllers/debug_pad.h @@ -41,11 +41,11 @@ private: // This is nn::hid::DebugPadState struct DebugPadState { - s64 sampling_number; - DebugPadAttribute attribute; - Core::HID::DebugPadButton pad_state; - Core::HID::AnalogStickState r_stick; - Core::HID::AnalogStickState l_stick; + s64 sampling_number{}; + DebugPadAttribute attribute{}; + Core::HID::DebugPadButton pad_state{}; + Core::HID::AnalogStickState r_stick{}; + Core::HID::AnalogStickState l_stick{}; }; static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state"); @@ -57,9 +57,8 @@ private: }; static_assert(sizeof(DebugPadSharedMemory) == 0x400, "DebugPadSharedMemory is an invalid size"); - DebugPadSharedMemory* shared_memory; - DebugPadState next_state{}; - Core::HID::EmulatedController* controller; + DebugPadSharedMemory* shared_memory = nullptr; + Core::HID::EmulatedController* controller = nullptr; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index e03d47ef3..3eae1ae35 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -27,8 +27,8 @@ Controller_Gesture::Controller_Gesture(Core::HID::HIDCore& hid_core_, u8* raw_sh : ControllerBase(hid_core_) { static_assert(SHARED_MEMORY_OFFSET + sizeof(GestureSharedMemory) < shared_memory_size, "GestureSharedMemory is bigger than the shared memory"); - shared_memory = - std::construct_at(reinterpret_cast<GestureSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); + shared_memory = std::construct_at( + reinterpret_cast<GestureSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); console = hid_core.GetEmulatedConsole(); } Controller_Gesture::~Controller_Gesture() = default; diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index c8edb35e1..c62a341bf 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h @@ -66,19 +66,19 @@ private: // This is nn::hid::GestureState struct GestureState { - s64 sampling_number; - s64 detection_count; - GestureType type; - GestureDirection direction; - Common::Point<s32> pos; - Common::Point<s32> delta; - f32 vel_x; - f32 vel_y; - GestureAttribute attributes; - f32 scale; - f32 rotation_angle; - s32 point_count; - std::array<Common::Point<s32>, 4> points; + s64 sampling_number{}; + s64 detection_count{}; + GestureType type{GestureType::Idle}; + GestureDirection direction{GestureDirection::None}; + Common::Point<s32> pos{}; + Common::Point<s32> delta{}; + f32 vel_x{}; + f32 vel_y{}; + GestureAttribute attributes{}; + f32 scale{}; + f32 rotation_angle{}; + s32 point_count{}; + std::array<Common::Point<s32>, 4> points{}; }; static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); @@ -142,9 +142,9 @@ private: // Returns the average distance, angle and middle point of the active fingers GestureProperties GetGestureProperties(); - GestureSharedMemory* shared_memory; GestureState next_state{}; - Core::HID::EmulatedConsole* console; + GestureSharedMemory* shared_memory = nullptr; + Core::HID::EmulatedConsole* console = nullptr; std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{}; GestureProperties last_gesture{}; diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index 534a3ff18..117d87433 100644 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp @@ -16,8 +16,8 @@ Controller_Keyboard::Controller_Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_ : ControllerBase{hid_core_} { static_assert(SHARED_MEMORY_OFFSET + sizeof(KeyboardSharedMemory) < shared_memory_size, "KeyboardSharedMemory is bigger than the shared memory"); - shared_memory = - std::construct_at(reinterpret_cast<KeyboardSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); + shared_memory = std::construct_at( + reinterpret_cast<KeyboardSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); emulated_devices = hid_core.GetEmulatedDevices(); } diff --git a/src/core/hle/service/hid/controllers/keyboard.h b/src/core/hle/service/hid/controllers/keyboard.h index 4c9c06a39..7532f53c6 100644 --- a/src/core/hle/service/hid/controllers/keyboard.h +++ b/src/core/hle/service/hid/controllers/keyboard.h @@ -31,10 +31,10 @@ public: private: // This is nn::hid::detail::KeyboardState struct KeyboardState { - s64 sampling_number; - Core::HID::KeyboardModifier modifier; - Core::HID::KeyboardAttribute attribute; - Core::HID::KeyboardKey key; + s64 sampling_number{}; + Core::HID::KeyboardModifier modifier{}; + Core::HID::KeyboardAttribute attribute{}; + Core::HID::KeyboardKey key{}; }; static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size"); @@ -46,8 +46,8 @@ private: }; static_assert(sizeof(KeyboardSharedMemory) == 0x400, "KeyboardSharedMemory is an invalid size"); - KeyboardSharedMemory* shared_memory; KeyboardState next_state{}; - Core::HID::EmulatedDevices* emulated_devices; + KeyboardSharedMemory* shared_memory = nullptr; + Core::HID::EmulatedDevices* emulated_devices = nullptr; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp index 730be33cd..b11cb438d 100644 --- a/src/core/hle/service/hid/controllers/mouse.cpp +++ b/src/core/hle/service/hid/controllers/mouse.cpp @@ -16,7 +16,8 @@ Controller_Mouse::Controller_Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared : ControllerBase{hid_core_} { static_assert(SHARED_MEMORY_OFFSET + sizeof(MouseSharedMemory) < shared_memory_size, "MouseSharedMemory is bigger than the shared memory"); - shared_memory = std::construct_at(reinterpret_cast<MouseSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); + shared_memory = std::construct_at( + reinterpret_cast<MouseSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); emulated_devices = hid_core.GetEmulatedDevices(); } diff --git a/src/core/hle/service/hid/controllers/mouse.h b/src/core/hle/service/hid/controllers/mouse.h index a9395c44b..733d00577 100644 --- a/src/core/hle/service/hid/controllers/mouse.h +++ b/src/core/hle/service/hid/controllers/mouse.h @@ -37,9 +37,9 @@ private: }; static_assert(sizeof(MouseSharedMemory) == 0x400, "MouseSharedMemory is an invalid size"); - MouseSharedMemory* shared_memory; Core::HID::MouseState next_state{}; Core::HID::AnalogStickState last_mouse_wheel_state{}; - Core::HID::EmulatedDevices* emulated_devices; + MouseSharedMemory* shared_memory = nullptr; + Core::HID::EmulatedDevices* emulated_devices = nullptr; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 425b84abd..0a96825a5 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -187,7 +187,7 @@ public: static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); private: - static const std::size_t NPAD_COUNT = 10; + static constexpr std::size_t NPAD_COUNT = 10; // This is nn::hid::detail::ColorAttribute enum class ColorAttribute : u32 { @@ -470,9 +470,9 @@ private: }; struct NpadControllerData { - Core::HID::EmulatedController* device; Kernel::KEvent* styleset_changed_event{}; - NpadInternalState* shared_memory; + NpadInternalState* shared_memory = nullptr; + Core::HID::EmulatedController* device = nullptr; std::array<VibrationData, 2> vibration{}; bool unintended_home_button_input_protection{}; @@ -502,8 +502,7 @@ private: SixAxisSensorState sixaxis_dual_right_state{}; SixAxisSensorState sixaxis_left_lifo_state{}; SixAxisSensorState sixaxis_right_lifo_state{}; - - int callback_key; + int callback_key{}; }; void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx); diff --git a/src/core/hle/service/hid/controllers/stubbed.h b/src/core/hle/service/hid/controllers/stubbed.h index 5973358bc..1483a968e 100644 --- a/src/core/hle/service/hid/controllers/stubbed.h +++ b/src/core/hle/service/hid/controllers/stubbed.h @@ -25,14 +25,14 @@ public: private: struct CommonHeader { - s64 timestamp; - s64 total_entry_count; - s64 last_entry_index; - s64 entry_count; + s64 timestamp{}; + s64 total_entry_count{}; + s64 last_entry_index{}; + s64 entry_count{}; }; static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); - u8* raw_shared_memory; + u8* raw_shared_memory = nullptr; bool smart_update{}; std::size_t common_offset{}; }; diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 5f584586b..108ce5a41 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -20,7 +20,8 @@ Controller_Touchscreen::Controller_Touchscreen(Core::HID::HIDCore& hid_core_, : ControllerBase{hid_core_} { static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size, "TouchSharedMemory is bigger than the shared memory"); - shared_memory = std::construct_at(reinterpret_cast<TouchSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); + shared_memory = std::construct_at( + reinterpret_cast<TouchSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); console = hid_core.GetEmulatedConsole(); } diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 2e1dde2f1..e57a3a80e 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -25,7 +25,7 @@ public: // This is nn::hid::TouchScreenConfigurationForNx struct TouchScreenConfigurationForNx { - TouchScreenModeForNx mode; + TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting}; INSERT_PADDING_BYTES_NOINIT(0x7); INSERT_PADDING_BYTES_NOINIT(0xF); // Reserved }; @@ -49,10 +49,10 @@ private: // This is nn::hid::TouchScreenState struct TouchScreenState { - s64 sampling_number; - s32 entry_count; + s64 sampling_number{}; + s32 entry_count{}; INSERT_PADDING_BYTES(4); // Reserved - std::array<Core::HID::TouchState, MAX_FINGERS> states; + std::array<Core::HID::TouchState, MAX_FINGERS> states{}; }; static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); @@ -64,10 +64,10 @@ private: }; static_assert(sizeof(TouchSharedMemory) == 0x3000, "TouchSharedMemory is an invalid size"); - TouchSharedMemory* shared_memory; - TouchScreenState next_state{}; - std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers; - Core::HID::EmulatedConsole* console; + TouchSharedMemory* shared_memory = nullptr; + Core::HID::EmulatedConsole* console = nullptr; + + std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{}; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/xpad.cpp b/src/core/hle/service/hid/controllers/xpad.cpp index a35632560..62119e2c5 100644 --- a/src/core/hle/service/hid/controllers/xpad.cpp +++ b/src/core/hle/service/hid/controllers/xpad.cpp @@ -14,7 +14,8 @@ Controller_XPad::Controller_XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_m : ControllerBase{hid_core_} { static_assert(SHARED_MEMORY_OFFSET + sizeof(XpadSharedMemory) < shared_memory_size, "XpadSharedMemory is bigger than the shared memory"); - shared_memory = std::construct_at(reinterpret_cast<XpadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); + shared_memory = std::construct_at( + reinterpret_cast<XpadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); } Controller_XPad::~Controller_XPad() = default; diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h index 7ed8d5d97..d01dee5fc 100644 --- a/src/core/hle/service/hid/controllers/xpad.h +++ b/src/core/hle/service/hid/controllers/xpad.h @@ -90,11 +90,11 @@ private: // This is nn::hid::detail::BasicXpadState struct BasicXpadState { - s64 sampling_number; - BasicXpadAttributeSet attributes; - BasicXpadButtonSet pad_states; - Core::HID::AnalogStickState l_stick; - Core::HID::AnalogStickState r_stick; + s64 sampling_number{}; + BasicXpadAttributeSet attributes{}; + BasicXpadButtonSet pad_states{}; + Core::HID::AnalogStickState l_stick{}; + Core::HID::AnalogStickState r_stick{}; }; static_assert(sizeof(BasicXpadState) == 0x20, "BasicXpadState is an invalid size"); @@ -106,7 +106,7 @@ private: }; static_assert(sizeof(XpadSharedMemory) == 0x400, "XpadSharedMemory is an invalid size"); - XpadSharedMemory* shared_memory; BasicXpadState next_state{}; + XpadSharedMemory* shared_memory = nullptr; }; } // namespace Service::HID |