diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2024-02-15 18:05:36 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2024-02-16 19:15:06 +0100 |
commit | 9c0724b27073e5f6cdf7ec9d10852cc5a073d863 (patch) | |
tree | ed79eb5d39128ec70409cf71300f704d5f740be5 | |
parent | Merge pull request #13016 from german77/set-interface2 (diff) | |
download | yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.tar yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.tar.gz yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.tar.bz2 yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.tar.lz yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.tar.xz yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.tar.zst yuzu-9c0724b27073e5f6cdf7ec9d10852cc5a073d863.zip |
-rw-r--r-- | src/core/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm.cpp | 272 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm.h | 4 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_debug.cpp | 33 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_debug.h | 21 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_system.cpp | 32 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_system.h | 25 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_system_core.cpp | 92 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_system_core.h | 37 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_user.cpp | 32 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_user.h | 25 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_user_core.cpp | 106 | ||||
-rw-r--r-- | src/core/hle/service/btm/btm_user_core.h | 47 |
13 files changed, 469 insertions, 267 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7770dbeae..93c548942 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -545,6 +545,16 @@ add_library(core STATIC hle/service/btdrv/btdrv.h hle/service/btm/btm.cpp hle/service/btm/btm.h + hle/service/btm/btm_debug.cpp + hle/service/btm/btm_debug.h + hle/service/btm/btm_system.cpp + hle/service/btm/btm_system.h + hle/service/btm/btm_system_core.cpp + hle/service/btm/btm_system_core.h + hle/service/btm/btm_user.cpp + hle/service/btm/btm_user.h + hle/service/btm/btm_user_core.cpp + hle/service/btm/btm_user_core.h hle/service/caps/caps.cpp hle/service/caps/caps.h hle/service/caps/caps_a.cpp diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 2dc23e674..d120dade8 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp @@ -3,141 +3,18 @@ #include <memory> -#include "common/logging/log.h" -#include "core/core.h" -#include "core/hle/kernel/k_event.h" #include "core/hle/service/btm/btm.h" -#include "core/hle/service/ipc_helpers.h" -#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/btm/btm_debug.h" +#include "core/hle/service/btm/btm_system.h" +#include "core/hle/service/btm/btm_user.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" namespace Service::BTM { -class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { +class IBtm final : public ServiceFramework<IBtm> { public: - explicit IBtmUserCore(Core::System& system_) - : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, - {1, nullptr, "GetBleScanFilterParameter"}, - {2, nullptr, "GetBleScanFilterParameter2"}, - {3, nullptr, "StartBleScanForGeneral"}, - {4, nullptr, "StopBleScanForGeneral"}, - {5, nullptr, "GetBleScanResultsForGeneral"}, - {6, nullptr, "StartBleScanForPaired"}, - {7, nullptr, "StopBleScanForPaired"}, - {8, nullptr, "StartBleScanForSmartDevice"}, - {9, nullptr, "StopBleScanForSmartDevice"}, - {10, nullptr, "GetBleScanResultsForSmartDevice"}, - {17, &IBtmUserCore::AcquireBleConnectionEvent, "AcquireBleConnectionEvent"}, - {18, nullptr, "BleConnect"}, - {19, nullptr, "BleDisconnect"}, - {20, nullptr, "BleGetConnectionState"}, - {21, nullptr, "AcquireBlePairingEvent"}, - {22, nullptr, "BlePairDevice"}, - {23, nullptr, "BleUnPairDevice"}, - {24, nullptr, "BleUnPairDevice2"}, - {25, nullptr, "BleGetPairedDevices"}, - {26, &IBtmUserCore::AcquireBleServiceDiscoveryEvent, "AcquireBleServiceDiscoveryEvent"}, - {27, nullptr, "GetGattServices"}, - {28, nullptr, "GetGattService"}, - {29, nullptr, "GetGattIncludedServices"}, - {30, nullptr, "GetBelongingGattService"}, - {31, nullptr, "GetGattCharacteristics"}, - {32, nullptr, "GetGattDescriptors"}, - {33, &IBtmUserCore::AcquireBleMtuConfigEvent, "AcquireBleMtuConfigEvent"}, - {34, nullptr, "ConfigureBleMtu"}, - {35, nullptr, "GetBleMtu"}, - {36, nullptr, "RegisterBleGattDataPath"}, - {37, nullptr, "UnregisterBleGattDataPath"}, - }; - // clang-format on - RegisterHandlers(functions); - - scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent"); - connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent"); - service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent"); - config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent"); - } - - ~IBtmUserCore() override { - service_context.CloseEvent(scan_event); - service_context.CloseEvent(connection_event); - service_context.CloseEvent(service_discovery_event); - service_context.CloseEvent(config_event); - } - -private: - void AcquireBleScanEvent(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 3, 1}; - rb.Push(ResultSuccess); - rb.Push(true); - rb.PushCopyObjects(scan_event->GetReadableEvent()); - } - - void AcquireBleConnectionEvent(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 3, 1}; - rb.Push(ResultSuccess); - rb.Push(true); - rb.PushCopyObjects(connection_event->GetReadableEvent()); - } - - void AcquireBleServiceDiscoveryEvent(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 3, 1}; - rb.Push(ResultSuccess); - rb.Push(true); - rb.PushCopyObjects(service_discovery_event->GetReadableEvent()); - } - - void AcquireBleMtuConfigEvent(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 3, 1}; - rb.Push(ResultSuccess); - rb.Push(true); - rb.PushCopyObjects(config_event->GetReadableEvent()); - } - - KernelHelpers::ServiceContext service_context; - - Kernel::KEvent* scan_event; - Kernel::KEvent* connection_event; - Kernel::KEvent* service_discovery_event; - Kernel::KEvent* config_event; -}; - -class BTM_USR final : public ServiceFramework<BTM_USR> { -public: - explicit BTM_USR(Core::System& system_) : ServiceFramework{system_, "btm:u"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &BTM_USR::GetCore, "GetCore"}, - }; - // clang-format on - RegisterHandlers(functions); - } - -private: - void GetCore(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<IBtmUserCore>(system); - } -}; - -class BTM final : public ServiceFramework<BTM> { -public: - explicit BTM(Core::System& system_) : ServiceFramework{system_, "btm"} { + explicit IBtm(Core::System& system_) : ServiceFramework{system_, "btm"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetState"}, @@ -232,144 +109,13 @@ public: } }; -class BTM_DBG final : public ServiceFramework<BTM_DBG> { -public: - explicit BTM_DBG(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "AcquireDiscoveryEvent"}, - {1, nullptr, "StartDiscovery"}, - {2, nullptr, "CancelDiscovery"}, - {3, nullptr, "GetDeviceProperty"}, - {4, nullptr, "CreateBond"}, - {5, nullptr, "CancelBond"}, - {6, nullptr, "SetTsiMode"}, - {7, nullptr, "GeneralTest"}, - {8, nullptr, "HidConnect"}, - {9, nullptr, "GeneralGet"}, - {10, nullptr, "GetGattClientDisconnectionReason"}, - {11, nullptr, "GetBleConnectionParameter"}, - {12, nullptr, "GetBleConnectionParameterRequest"}, - {13, nullptr, "Unknown13"}, - }; - // clang-format on - - RegisterHandlers(functions); - } -}; - -class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> { -public: - explicit IBtmSystemCore(Core::System& system_) : ServiceFramework{system_, "IBtmSystemCore"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &IBtmSystemCore::StartGamepadPairing, "StartGamepadPairing"}, - {1, &IBtmSystemCore::CancelGamepadPairing, "CancelGamepadPairing"}, - {2, nullptr, "ClearGamepadPairingDatabase"}, - {3, nullptr, "GetPairedGamepadCount"}, - {4, nullptr, "EnableRadio"}, - {5, nullptr, "DisableRadio"}, - {6, &IBtmSystemCore::IsRadioEnabled, "IsRadioEnabled"}, - {7, nullptr, "AcquireRadioEvent"}, - {8, nullptr, "AcquireGamepadPairingEvent"}, - {9, nullptr, "IsGamepadPairingStarted"}, - {10, nullptr, "StartAudioDeviceDiscovery"}, - {11, nullptr, "StopAudioDeviceDiscovery"}, - {12, nullptr, "IsDiscoveryingAudioDevice"}, - {13, nullptr, "GetDiscoveredAudioDevice"}, - {14, nullptr, "AcquireAudioDeviceConnectionEvent"}, - {15, nullptr, "ConnectAudioDevice"}, - {16, nullptr, "IsConnectingAudioDevice"}, - {17, &IBtmSystemCore::GetConnectedAudioDevices, "GetConnectedAudioDevices"}, - {18, nullptr, "DisconnectAudioDevice"}, - {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"}, - {20, &IBtmSystemCore::GetPairedAudioDevices, "GetPairedAudioDevices"}, - {21, nullptr, "RemoveAudioDevicePairing"}, - {22, &IBtmSystemCore::RequestAudioDeviceConnectionRejection, "RequestAudioDeviceConnectionRejection"}, - {23, &IBtmSystemCore::CancelAudioDeviceConnectionRejection, "CancelAudioDeviceConnectionRejection"} - }; - // clang-format on - - RegisterHandlers(functions); - } - -private: - void IsRadioEnabled(HLERequestContext& ctx) { - LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(true); - } - - void StartGamepadPairing(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - void CancelGamepadPairing(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - void CancelAudioDeviceConnectionRejection(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - void GetConnectedAudioDevices(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push<u32>(0); - } - - void GetPairedAudioDevices(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push<u32>(0); - } - - void RequestAudioDeviceConnectionRejection(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } -}; - -class BTM_SYS final : public ServiceFramework<BTM_SYS> { -public: - explicit BTM_SYS(Core::System& system_) : ServiceFramework{system_, "btm:sys"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &BTM_SYS::GetCore, "GetCore"}, - }; - // clang-format on - - RegisterHandlers(functions); - } - -private: - void GetCore(HLERequestContext& ctx) { - LOG_WARNING(Service_BTM, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<IBtmSystemCore>(system); - } -}; - void LoopProcess(Core::System& system) { auto server_manager = std::make_unique<ServerManager>(system); - server_manager->RegisterNamedService("btm", std::make_shared<BTM>(system)); - server_manager->RegisterNamedService("btm:dbg", std::make_shared<BTM_DBG>(system)); - server_manager->RegisterNamedService("btm:sys", std::make_shared<BTM_SYS>(system)); - server_manager->RegisterNamedService("btm:u", std::make_shared<BTM_USR>(system)); + server_manager->RegisterNamedService("btm", std::make_shared<IBtm>(system)); + server_manager->RegisterNamedService("btm:dbg", std::make_shared<IBtmDebug>(system)); + server_manager->RegisterNamedService("btm:sys", std::make_shared<IBtmSystem>(system)); + server_manager->RegisterNamedService("btm:u", std::make_shared<IBtmUser>(system)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/btm/btm.h b/src/core/hle/service/btm/btm.h index a99b34364..0bf77d053 100644 --- a/src/core/hle/service/btm/btm.h +++ b/src/core/hle/service/btm/btm.h @@ -3,10 +3,6 @@ #pragma once -namespace Service::SM { -class ServiceManager; -} - namespace Core { class System; }; diff --git a/src/core/hle/service/btm/btm_debug.cpp b/src/core/hle/service/btm/btm_debug.cpp new file mode 100644 index 000000000..67d206560 --- /dev/null +++ b/src/core/hle/service/btm/btm_debug.cpp @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "core/hle/service/btm/btm_debug.h" + +namespace Service::BTM { + +IBtmDebug::IBtmDebug(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "AcquireDiscoveryEvent"}, + {1, nullptr, "StartDiscovery"}, + {2, nullptr, "CancelDiscovery"}, + {3, nullptr, "GetDeviceProperty"}, + {4, nullptr, "CreateBond"}, + {5, nullptr, "CancelBond"}, + {6, nullptr, "SetTsiMode"}, + {7, nullptr, "GeneralTest"}, + {8, nullptr, "HidConnect"}, + {9, nullptr, "GeneralGet"}, + {10, nullptr, "GetGattClientDisconnectionReason"}, + {11, nullptr, "GetBleConnectionParameter"}, + {12, nullptr, "GetBleConnectionParameterRequest"}, + {13, nullptr, "Unknown13"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IBtmDebug::~IBtmDebug() = default; + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_debug.h b/src/core/hle/service/btm/btm_debug.h new file mode 100644 index 000000000..bf4f7e14f --- /dev/null +++ b/src/core/hle/service/btm/btm_debug.h @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::BTM { + +class IBtmDebug final : public ServiceFramework<IBtmDebug> { +public: + explicit IBtmDebug(Core::System& system_); + ~IBtmDebug() override; +}; + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_system.cpp b/src/core/hle/service/btm/btm_system.cpp new file mode 100644 index 000000000..f6ac6bdba --- /dev/null +++ b/src/core/hle/service/btm/btm_system.cpp @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "common/logging/log.h" +#include "core/hle/service/btm/btm_system.h" +#include "core/hle/service/btm/btm_system_core.h" +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/service.h" + +namespace Service::BTM { + +IBtmSystem::IBtmSystem(Core::System& system_) : ServiceFramework{system_, "btm:sys"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, C<&IBtmSystem::GetCore>, "GetCore"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IBtmSystem::~IBtmSystem() = default; + +Result IBtmSystem::GetCore(OutInterface<IBtmSystemCore> out_interface) { + LOG_WARNING(Service_BTM, "called"); + + *out_interface = std::make_shared<IBtmSystemCore>(system); + R_SUCCEED(); +} + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_system.h b/src/core/hle/service/btm/btm_system.h new file mode 100644 index 000000000..fe1c6dbd7 --- /dev/null +++ b/src/core/hle/service/btm/btm_system.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::BTM { +class IBtmSystemCore; + +class IBtmSystem final : public ServiceFramework<IBtmSystem> { +public: + explicit IBtmSystem(Core::System& system_); + ~IBtmSystem() override; + +private: + Result GetCore(OutInterface<IBtmSystemCore> out_interface); +}; + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_system_core.cpp b/src/core/hle/service/btm/btm_system_core.cpp new file mode 100644 index 000000000..42628badb --- /dev/null +++ b/src/core/hle/service/btm/btm_system_core.cpp @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "common/logging/log.h" +#include "core/hle/service/btm/btm_system_core.h" +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/server_manager.h" +#include "core/hle/service/service.h" + +namespace Service::BTM { + +IBtmSystemCore::IBtmSystemCore(Core::System& system_) + : ServiceFramework{system_, "IBtmSystemCore"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, C<&IBtmSystemCore::StartGamepadPairing>, "StartGamepadPairing"}, + {1, C<&IBtmSystemCore::CancelGamepadPairing>, "CancelGamepadPairing"}, + {2, nullptr, "ClearGamepadPairingDatabase"}, + {3, nullptr, "GetPairedGamepadCount"}, + {4, nullptr, "EnableRadio"}, + {5, nullptr, "DisableRadio"}, + {6, C<&IBtmSystemCore::IsRadioEnabled>, "IsRadioEnabled"}, + {7, nullptr, "AcquireRadioEvent"}, + {8, nullptr, "AcquireGamepadPairingEvent"}, + {9, nullptr, "IsGamepadPairingStarted"}, + {10, nullptr, "StartAudioDeviceDiscovery"}, + {11, nullptr, "StopAudioDeviceDiscovery"}, + {12, nullptr, "IsDiscoveryingAudioDevice"}, + {13, nullptr, "GetDiscoveredAudioDevice"}, + {14, nullptr, "AcquireAudioDeviceConnectionEvent"}, + {15, nullptr, "ConnectAudioDevice"}, + {16, nullptr, "IsConnectingAudioDevice"}, + {17, C<&IBtmSystemCore::GetConnectedAudioDevices>, "GetConnectedAudioDevices"}, + {18, nullptr, "DisconnectAudioDevice"}, + {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"}, + {20, C<&IBtmSystemCore::GetPairedAudioDevices>, "GetPairedAudioDevices"}, + {21, nullptr, "RemoveAudioDevicePairing"}, + {22, C<&IBtmSystemCore::RequestAudioDeviceConnectionRejection>, "RequestAudioDeviceConnectionRejection"}, + {23, C<&IBtmSystemCore::CancelAudioDeviceConnectionRejection>, "CancelAudioDeviceConnectionRejection"} + }; + // clang-format on + + RegisterHandlers(functions); +} + +IBtmSystemCore::~IBtmSystemCore() = default; + +Result IBtmSystemCore::StartGamepadPairing() { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + R_SUCCEED(); +} + +Result IBtmSystemCore::CancelGamepadPairing() { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + R_SUCCEED(); +} + +Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) { + LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running + + *out_is_enabled = true; + R_SUCCEED(); +} + +Result IBtmSystemCore::GetConnectedAudioDevices( + Out<s32> out_count, OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices) { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + + *out_count = 0; + R_SUCCEED(); +} + +Result IBtmSystemCore::GetPairedAudioDevices( + Out<s32> out_count, OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices) { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + + *out_count = 0; + R_SUCCEED(); +} + +Result IBtmSystemCore::RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid) { + LOG_WARNING(Service_BTM, "(STUBBED) called, applet_resource_user_id={}", aruid.pid); + R_SUCCEED(); +} + +Result IBtmSystemCore::CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid) { + LOG_WARNING(Service_BTM, "(STUBBED) called, applet_resource_user_id={}", aruid.pid); + R_SUCCEED(); +} + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_system_core.h b/src/core/hle/service/btm/btm_system_core.h new file mode 100644 index 000000000..f1ca11f37 --- /dev/null +++ b/src/core/hle/service/btm/btm_system_core.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::BTM { + +class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> { +public: + explicit IBtmSystemCore(Core::System& system_); + ~IBtmSystemCore() override; + +private: + Result StartGamepadPairing(); + Result CancelGamepadPairing(); + Result IsRadioEnabled(Out<bool> out_is_enabled); + + Result GetConnectedAudioDevices( + Out<s32> out_count, + OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices); + + Result GetPairedAudioDevices( + Out<s32> out_count, + OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices); + + Result RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid); + Result CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid); +}; + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_user.cpp b/src/core/hle/service/btm/btm_user.cpp new file mode 100644 index 000000000..0c3b41208 --- /dev/null +++ b/src/core/hle/service/btm/btm_user.cpp @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "common/logging/log.h" +#include "core/hle/service/btm/btm_user.h" +#include "core/hle/service/btm/btm_user_core.h" +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/service.h" + +namespace Service::BTM { + +IBtmUser::IBtmUser(Core::System& system_) : ServiceFramework{system_, "btm:u"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, C<&IBtmUser::GetCore>, "GetCore"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IBtmUser::~IBtmUser() = default; + +Result IBtmUser::GetCore(OutInterface<IBtmUserCore> out_interface) { + LOG_WARNING(Service_BTM, "called"); + + *out_interface = std::make_shared<IBtmUserCore>(system); + R_SUCCEED(); +} + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_user.h b/src/core/hle/service/btm/btm_user.h new file mode 100644 index 000000000..d9ee5db45 --- /dev/null +++ b/src/core/hle/service/btm/btm_user.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::BTM { +class IBtmUserCore; + +class IBtmUser final : public ServiceFramework<IBtmUser> { +public: + explicit IBtmUser(Core::System& system_); + ~IBtmUser() override; + +private: + Result GetCore(OutInterface<IBtmUserCore> out_interface); +}; + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_user_core.cpp b/src/core/hle/service/btm/btm_user_core.cpp new file mode 100644 index 000000000..b1e38da65 --- /dev/null +++ b/src/core/hle/service/btm/btm_user_core.cpp @@ -0,0 +1,106 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include <memory> + +#include "common/logging/log.h" +#include "core/core.h" +#include "core/hle/kernel/k_event.h" +#include "core/hle/service/btm/btm_user_core.h" +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/server_manager.h" +#include "core/hle/service/service.h" + +namespace Service::BTM { + +IBtmUserCore::IBtmUserCore(Core::System& system_) + : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, C<&IBtmUserCore::AcquireBleScanEvent>, "AcquireBleScanEvent"}, + {1, nullptr, "GetBleScanFilterParameter"}, + {2, nullptr, "GetBleScanFilterParameter2"}, + {3, nullptr, "StartBleScanForGeneral"}, + {4, nullptr, "StopBleScanForGeneral"}, + {5, nullptr, "GetBleScanResultsForGeneral"}, + {6, nullptr, "StartBleScanForPaired"}, + {7, nullptr, "StopBleScanForPaired"}, + {8, nullptr, "StartBleScanForSmartDevice"}, + {9, nullptr, "StopBleScanForSmartDevice"}, + {10, nullptr, "GetBleScanResultsForSmartDevice"}, + {17, C<&IBtmUserCore::AcquireBleConnectionEvent>, "AcquireBleConnectionEvent"}, + {18, nullptr, "BleConnect"}, + {19, nullptr, "BleDisconnect"}, + {20, nullptr, "BleGetConnectionState"}, + {21, nullptr, "AcquireBlePairingEvent"}, + {22, nullptr, "BlePairDevice"}, + {23, nullptr, "BleUnPairDevice"}, + {24, nullptr, "BleUnPairDevice2"}, + {25, nullptr, "BleGetPairedDevices"}, + {26, C<&IBtmUserCore::AcquireBleServiceDiscoveryEvent>, "AcquireBleServiceDiscoveryEvent"}, + {27, nullptr, "GetGattServices"}, + {28, nullptr, "GetGattService"}, + {29, nullptr, "GetGattIncludedServices"}, + {30, nullptr, "GetBelongingGattService"}, + {31, nullptr, "GetGattCharacteristics"}, + {32, nullptr, "GetGattDescriptors"}, + {33, C<&IBtmUserCore::AcquireBleMtuConfigEvent>, "AcquireBleMtuConfigEvent"}, + {34, nullptr, "ConfigureBleMtu"}, + {35, nullptr, "GetBleMtu"}, + {36, nullptr, "RegisterBleGattDataPath"}, + {37, nullptr, "UnregisterBleGattDataPath"}, + }; + // clang-format on + RegisterHandlers(functions); + + scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent"); + connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent"); + service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent"); + config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent"); +} + +IBtmUserCore::~IBtmUserCore() { + service_context.CloseEvent(scan_event); + service_context.CloseEvent(connection_event); + service_context.CloseEvent(service_discovery_event); + service_context.CloseEvent(config_event); +} + +Result IBtmUserCore::AcquireBleScanEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event) { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + + *out_is_valid = true; + *out_event = &scan_event->GetReadableEvent(); + R_SUCCEED(); +} + +Result IBtmUserCore::AcquireBleConnectionEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event) { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + + *out_is_valid = true; + *out_event = &connection_event->GetReadableEvent(); + R_SUCCEED(); +} + +Result IBtmUserCore::AcquireBleServiceDiscoveryEvent( + Out<bool> out_is_valid, OutCopyHandle<Kernel::KReadableEvent> out_event) { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + + *out_is_valid = true; + *out_event = &service_discovery_event->GetReadableEvent(); + R_SUCCEED(); +} + +Result IBtmUserCore::AcquireBleMtuConfigEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event) { + LOG_WARNING(Service_BTM, "(STUBBED) called"); + + *out_is_valid = true; + *out_event = &config_event->GetReadableEvent(); + R_SUCCEED(); +} + +} // namespace Service::BTM diff --git a/src/core/hle/service/btm/btm_user_core.h b/src/core/hle/service/btm/btm_user_core.h new file mode 100644 index 000000000..5346933cb --- /dev/null +++ b/src/core/hle/service/btm/btm_user_core.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/service.h" + +namespace Kernel { +class KEvent; +class KReadableEvent; +} + +namespace Core { +class System; +} + +namespace Service::BTM { + +class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { +public: + explicit IBtmUserCore(Core::System& system_); + ~IBtmUserCore() override; + +private: + Result AcquireBleScanEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event); + + Result AcquireBleConnectionEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event); + + Result AcquireBleServiceDiscoveryEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event); + + Result AcquireBleMtuConfigEvent(Out<bool> out_is_valid, + OutCopyHandle<Kernel::KReadableEvent> out_event); + + KernelHelpers::ServiceContext service_context; + + Kernel::KEvent* scan_event; + Kernel::KEvent* connection_event; + Kernel::KEvent* service_discovery_event; + Kernel::KEvent* config_event; +}; + +} // namespace Service::BTM |