diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hid/hid_types.h | 26 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 16 | ||||
-rw-r--r-- | src/core/hle/service/hid/hid.cpp | 68 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_producer.cpp | 1 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/window.h | 1 | ||||
-rw-r--r-- | src/core/hle/service/ssl/ssl_backend_securetransport.cpp | 2 | ||||
-rw-r--r-- | src/core/memory.h | 125 |
7 files changed, 154 insertions, 85 deletions
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 6b35f448c..00beb40dd 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h @@ -289,6 +289,19 @@ enum class GyroscopeZeroDriftMode : u32 { Tight = 2, }; +// This is nn::settings::system::TouchScreenMode +enum class TouchScreenMode : u32 { + Stylus = 0, + Standard = 1, +}; + +// This is nn::hid::TouchScreenModeForNx +enum class TouchScreenModeForNx : u8 { + UseSystemSetting, + Finger, + Heat2, +}; + // This is nn::hid::NpadStyleTag struct NpadStyleTag { union { @@ -334,6 +347,14 @@ struct TouchState { }; static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size"); +// This is nn::hid::TouchScreenConfigurationForNx +struct TouchScreenConfigurationForNx { + TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting}; + INSERT_PADDING_BYTES(0xF); +}; +static_assert(sizeof(TouchScreenConfigurationForNx) == 0x10, + "TouchScreenConfigurationForNx is an invalid size"); + struct NpadColor { u8 r{}; u8 g{}; @@ -662,6 +683,11 @@ struct MouseState { }; static_assert(sizeof(MouseState) == 0x28, "MouseState is an invalid size"); +struct UniquePadId { + u64 id; +}; +static_assert(sizeof(UniquePadId) == 0x8, "UniquePadId is an invalid size"); + /// Converts a NpadIdType to an array index. constexpr size_t NpadIdTypeToIndex(NpadIdType npad_id_type) { switch (npad_id_type) { diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index e57a3a80e..dd00921fd 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -16,22 +16,6 @@ class EmulatedConsole; namespace Service::HID { class Controller_Touchscreen final : public ControllerBase { public: - // This is nn::hid::TouchScreenModeForNx - enum class TouchScreenModeForNx : u8 { - UseSystemSetting, - Finger, - Heat2, - }; - - // This is nn::hid::TouchScreenConfigurationForNx - struct TouchScreenConfigurationForNx { - TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting}; - INSERT_PADDING_BYTES_NOINIT(0x7); - INSERT_PADDING_BYTES_NOINIT(0xF); // Reserved - }; - static_assert(sizeof(TouchScreenConfigurationForNx) == 0x17, - "TouchScreenConfigurationForNx is an invalid size"); - explicit Controller_Touchscreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); ~Controller_Touchscreen() override; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 2bf1d8a27..fd466db7b 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -2368,7 +2368,7 @@ void Hid::GetNpadCommunicationMode(HLERequestContext& ctx) { void Hid::SetTouchScreenConfiguration(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto touchscreen_mode{rp.PopRaw<Controller_Touchscreen::TouchScreenConfigurationForNx>()}; + const auto touchscreen_mode{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}", @@ -2543,7 +2543,8 @@ public: class HidSys final : public ServiceFramework<HidSys> { public: - explicit HidSys(Core::System& system_) : ServiceFramework{system_, "hid:sys"} { + explicit HidSys(Core::System& system_) + : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"} { // clang-format off static const FunctionInfo functions[] = { {31, nullptr, "SendKeyboardLockKeyEvent"}, @@ -2568,7 +2569,7 @@ public: {303, &HidSys::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"}, {304, nullptr, "EnableAssigningSingleOnSlSrPress"}, {305, nullptr, "DisableAssigningSingleOnSlSrPress"}, - {306, nullptr, "GetLastActiveNpad"}, + {306, &HidSys::GetLastActiveNpad, "GetLastActiveNpad"}, {307, nullptr, "GetNpadSystemExtStyle"}, {308, nullptr, "ApplyNpadSystemCommonPolicyFull"}, {309, nullptr, "GetNpadFullKeyGripColor"}, @@ -2624,7 +2625,7 @@ public: {700, nullptr, "ActivateUniquePad"}, {702, nullptr, "AcquireUniquePadConnectionEventHandle"}, {703, nullptr, "GetUniquePadIds"}, - {751, nullptr, "AcquireJoyDetachOnBluetoothOffEventHandle"}, + {751, &HidSys::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"}, {800, nullptr, "ListSixAxisSensorHandles"}, {801, nullptr, "IsSixAxisSensorUserCalibrationSupported"}, {802, nullptr, "ResetSixAxisSensorCalibrationValues"}, @@ -2650,7 +2651,7 @@ public: {830, nullptr, "SetNotificationLedPattern"}, {831, nullptr, "SetNotificationLedPatternWithTimeout"}, {832, nullptr, "PrepareHidsForNotificationWake"}, - {850, nullptr, "IsUsbFullKeyControllerEnabled"}, + {850, &HidSys::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, {851, nullptr, "EnableUsbFullKeyController"}, {852, nullptr, "IsUsbConnected"}, {870, nullptr, "IsHandheldButtonPressedOnConsoleMode"}, @@ -2682,7 +2683,7 @@ public: {1150, nullptr, "SetTouchScreenMagnification"}, {1151, nullptr, "GetTouchScreenFirmwareVersion"}, {1152, nullptr, "SetTouchScreenDefaultConfiguration"}, - {1153, nullptr, "GetTouchScreenDefaultConfiguration"}, + {1153, &HidSys::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"}, {1154, nullptr, "IsFirmwareAvailableForNotification"}, {1155, nullptr, "SetForceHandheldStyleVibration"}, {1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"}, @@ -2749,6 +2750,8 @@ public: // clang-format on RegisterHandlers(functions); + + joy_detach_event = service_context.CreateEvent("HidSys::JoyDetachEvent"); } private: @@ -2760,17 +2763,66 @@ private: rb.Push(ResultSuccess); } + void GetLastActiveNpad(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.PushEnum(Core::HID::NpadIdType::Handheld); + } + void GetUniquePadsFromNpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()}; - const s64 total_entries = 0; LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type); + const std::vector<Core::HID::UniquePadId> unique_pads{}; + + ctx.WriteBuffer(unique_pads); + IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(total_entries); + rb.Push(static_cast<u32>(unique_pads.size())); } + + void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) { + LOG_INFO(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(joy_detach_event->GetReadableEvent()); + } + + void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) { + const bool is_enabled = false; + + LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(is_enabled); + } + + void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) { + LOG_WARNING(Service_HID, "(STUBBED) called"); + + Core::HID::TouchScreenConfigurationForNx touchscreen_config{ + .mode = Core::HID::TouchScreenModeForNx::Finger, + }; + + if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 && + touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) { + touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting; + } + + IPC::ResponseBuilder rb{ctx, 6}; + rb.Push(ResultSuccess); + rb.PushRaw(touchscreen_config); + } + + Kernel::KEvent* joy_detach_event; + KernelHelpers::ServiceContext service_context; }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index b16f9933f..dc6917d5d 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -449,6 +449,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, case NativeWindowScalingMode::ScaleToWindow: case NativeWindowScalingMode::ScaleCrop: case NativeWindowScalingMode::NoScaleCrop: + case NativeWindowScalingMode::PreserveAspectRatio: break; default: LOG_ERROR(Service_Nvnflinger, "unknown scaling mode {}", scaling_mode); diff --git a/src/core/hle/service/nvnflinger/window.h b/src/core/hle/service/nvnflinger/window.h index 61cca5b01..36d6cde3d 100644 --- a/src/core/hle/service/nvnflinger/window.h +++ b/src/core/hle/service/nvnflinger/window.h @@ -41,6 +41,7 @@ enum class NativeWindowScalingMode : s32 { ScaleToWindow = 1, ScaleCrop = 2, NoScaleCrop = 3, + PreserveAspectRatio = 4, }; /// Transform parameter for QueueBuffer diff --git a/src/core/hle/service/ssl/ssl_backend_securetransport.cpp b/src/core/hle/service/ssl/ssl_backend_securetransport.cpp index 370678f48..c48914f64 100644 --- a/src/core/hle/service/ssl/ssl_backend_securetransport.cpp +++ b/src/core/hle/service/ssl/ssl_backend_securetransport.cpp @@ -100,7 +100,7 @@ public: Result DoHandshake() override { OSStatus status = SSLHandshake(context); - return HandleReturn("SSLHandshake", 0, status).Code(); + return HandleReturn("SSLHandshake", 0, status); } Result Read(size_t* out_size, std::span<u8> data) override { diff --git a/src/core/memory.h b/src/core/memory.h index 2eb61ffd3..13047a545 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -509,9 +509,9 @@ class GuestMemory { public: GuestMemory() = delete; - explicit GuestMemory(M& memory_, u64 addr_, std::size_t size_, + explicit GuestMemory(M& memory, u64 addr, std::size_t size, Common::ScratchBuffer<T>* backup = nullptr) - : memory{memory_}, addr{addr_}, size{size_} { + : m_memory{memory}, m_addr{addr}, m_size{size} { static_assert(FLAGS & GuestMemoryFlags::Read || FLAGS & GuestMemoryFlags::Write); if constexpr (FLAGS & GuestMemoryFlags::Read) { Read(addr, size, backup); @@ -521,89 +521,97 @@ public: ~GuestMemory() = default; T* data() noexcept { - return data_span.data(); + return m_data_span.data(); } const T* data() const noexcept { - return data_span.data(); + return m_data_span.data(); + } + + size_t size() const noexcept { + return m_size; + } + + size_t size_bytes() const noexcept { + return this->size() * sizeof(T); } [[nodiscard]] T* begin() noexcept { - return data(); + return this->data(); } [[nodiscard]] const T* begin() const noexcept { - return data(); + return this->data(); } [[nodiscard]] T* end() noexcept { - return data() + size; + return this->data() + this->size(); } [[nodiscard]] const T* end() const noexcept { - return data() + size; + return this->data() + this->size(); } T& operator[](size_t index) noexcept { - return data_span[index]; + return m_data_span[index]; } const T& operator[](size_t index) const noexcept { - return data_span[index]; + return m_data_span[index]; } - void SetAddressAndSize(u64 addr_, std::size_t size_) noexcept { - addr = addr_; - size = size_; - addr_changed = true; + void SetAddressAndSize(u64 addr, std::size_t size) noexcept { + m_addr = addr; + m_size = size; + m_addr_changed = true; } - std::span<T> Read(u64 addr_, std::size_t size_, + std::span<T> Read(u64 addr, std::size_t size, Common::ScratchBuffer<T>* backup = nullptr) noexcept { - addr = addr_; - size = size_; - if (size == 0) { - is_data_copy = true; + m_addr = addr; + m_size = size; + if (m_size == 0) { + m_is_data_copy = true; return {}; } - if (TrySetSpan()) { + if (this->TrySetSpan()) { if constexpr (FLAGS & GuestMemoryFlags::Safe) { - memory.FlushRegion(addr, size * sizeof(T)); + m_memory.FlushRegion(m_addr, this->size_bytes()); } } else { if (backup) { - backup->resize_destructive(size); - data_span = *backup; + backup->resize_destructive(this->size()); + m_data_span = *backup; } else { - data_copy.resize(size); - data_span = std::span(data_copy); + m_data_copy.resize(this->size()); + m_data_span = std::span(m_data_copy); } - is_data_copy = true; - span_valid = true; + m_is_data_copy = true; + m_span_valid = true; if constexpr (FLAGS & GuestMemoryFlags::Safe) { - memory.ReadBlock(addr, data_span.data(), size * sizeof(T)); + m_memory.ReadBlock(m_addr, this->data(), this->size_bytes()); } else { - memory.ReadBlockUnsafe(addr, data_span.data(), size * sizeof(T)); + m_memory.ReadBlockUnsafe(m_addr, this->data(), this->size_bytes()); } } - return data_span; + return m_data_span; } void Write(std::span<T> write_data) noexcept { if constexpr (FLAGS & GuestMemoryFlags::Cached) { - memory.WriteBlockCached(addr, write_data.data(), size * sizeof(T)); + m_memory.WriteBlockCached(m_addr, write_data.data(), this->size_bytes()); } else if constexpr (FLAGS & GuestMemoryFlags::Safe) { - memory.WriteBlock(addr, write_data.data(), size * sizeof(T)); + m_memory.WriteBlock(m_addr, write_data.data(), this->size_bytes()); } else { - memory.WriteBlockUnsafe(addr, write_data.data(), size * sizeof(T)); + m_memory.WriteBlockUnsafe(m_addr, write_data.data(), this->size_bytes()); } } bool TrySetSpan() noexcept { - if (u8* ptr = memory.GetSpan(addr, size * sizeof(T)); ptr) { - data_span = {reinterpret_cast<T*>(ptr), size}; - span_valid = true; + if (u8* ptr = m_memory.GetSpan(m_addr, this->size_bytes()); ptr) { + m_data_span = {reinterpret_cast<T*>(ptr), this->size()}; + m_span_valid = true; return true; } return false; @@ -611,36 +619,36 @@ public: protected: bool IsDataCopy() const noexcept { - return is_data_copy; + return m_is_data_copy; } bool AddressChanged() const noexcept { - return addr_changed; + return m_addr_changed; } - M& memory; - u64 addr; - size_t size; - std::span<T> data_span{}; - std::vector<T> data_copy; - bool span_valid{false}; - bool is_data_copy{false}; - bool addr_changed{false}; + M& m_memory; + u64 m_addr{}; + size_t m_size{}; + std::span<T> m_data_span{}; + std::vector<T> m_data_copy{}; + bool m_span_valid{false}; + bool m_is_data_copy{false}; + bool m_addr_changed{false}; }; template <typename M, typename T, GuestMemoryFlags FLAGS> class GuestMemoryScoped : public GuestMemory<M, T, FLAGS> { public: GuestMemoryScoped() = delete; - explicit GuestMemoryScoped(M& memory_, u64 addr_, std::size_t size_, + explicit GuestMemoryScoped(M& memory, u64 addr, std::size_t size, Common::ScratchBuffer<T>* backup = nullptr) - : GuestMemory<M, T, FLAGS>(memory_, addr_, size_, backup) { + : GuestMemory<M, T, FLAGS>(memory, addr, size, backup) { if constexpr (!(FLAGS & GuestMemoryFlags::Read)) { if (!this->TrySetSpan()) { if (backup) { - this->data_span = *backup; - this->span_valid = true; - this->is_data_copy = true; + this->m_data_span = *backup; + this->m_span_valid = true; + this->m_is_data_copy = true; } } } @@ -648,24 +656,21 @@ public: ~GuestMemoryScoped() { if constexpr (FLAGS & GuestMemoryFlags::Write) { - if (this->size == 0) [[unlikely]] { + if (this->size() == 0) [[unlikely]] { return; } if (this->AddressChanged() || this->IsDataCopy()) { - ASSERT(this->span_valid); + ASSERT(this->m_span_valid); if constexpr (FLAGS & GuestMemoryFlags::Cached) { - this->memory.WriteBlockCached(this->addr, this->data_span.data(), - this->size * sizeof(T)); + this->m_memory.WriteBlockCached(this->m_addr, this->data(), this->size_bytes()); } else if constexpr (FLAGS & GuestMemoryFlags::Safe) { - this->memory.WriteBlock(this->addr, this->data_span.data(), - this->size * sizeof(T)); + this->m_memory.WriteBlock(this->m_addr, this->data(), this->size_bytes()); } else { - this->memory.WriteBlockUnsafe(this->addr, this->data_span.data(), - this->size * sizeof(T)); + this->m_memory.WriteBlockUnsafe(this->m_addr, this->data(), this->size_bytes()); } } else if constexpr (FLAGS & GuestMemoryFlags::Safe) { - this->memory.InvalidateRegion(this->addr, this->size * sizeof(T)); + this->m_memory.InvalidateRegion(this->m_addr, this->size_bytes()); } } } |