summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt10
-rw-r--r--src/core/hle/service/btm/btm.cpp272
-rw-r--r--src/core/hle/service/btm/btm.h4
-rw-r--r--src/core/hle/service/btm/btm_debug.cpp33
-rw-r--r--src/core/hle/service/btm/btm_debug.h21
-rw-r--r--src/core/hle/service/btm/btm_system.cpp32
-rw-r--r--src/core/hle/service/btm/btm_system.h25
-rw-r--r--src/core/hle/service/btm/btm_system_core.cpp92
-rw-r--r--src/core/hle/service/btm/btm_system_core.h37
-rw-r--r--src/core/hle/service/btm/btm_user.cpp32
-rw-r--r--src/core/hle/service/btm/btm_user.h25
-rw-r--r--src/core/hle/service/btm/btm_user_core.cpp106
-rw-r--r--src/core/hle/service/btm/btm_user_core.h47
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
545 hle/service/btdrv/btdrv.h 545 hle/service/btdrv/btdrv.h
546 hle/service/btm/btm.cpp 546 hle/service/btm/btm.cpp
547 hle/service/btm/btm.h 547 hle/service/btm/btm.h
548 hle/service/btm/btm_debug.cpp
549 hle/service/btm/btm_debug.h
550 hle/service/btm/btm_system.cpp
551 hle/service/btm/btm_system.h
552 hle/service/btm/btm_system_core.cpp
553 hle/service/btm/btm_system_core.h
554 hle/service/btm/btm_user.cpp
555 hle/service/btm/btm_user.h
556 hle/service/btm/btm_user_core.cpp
557 hle/service/btm/btm_user_core.h
548 hle/service/caps/caps.cpp 558 hle/service/caps/caps.cpp
549 hle/service/caps/caps.h 559 hle/service/caps/caps.h
550 hle/service/caps/caps_a.cpp 560 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 @@
3 3
4#include <memory> 4#include <memory>
5 5
6#include "common/logging/log.h"
7#include "core/core.h"
8#include "core/hle/kernel/k_event.h"
9#include "core/hle/service/btm/btm.h" 6#include "core/hle/service/btm/btm.h"
10#include "core/hle/service/ipc_helpers.h" 7#include "core/hle/service/btm/btm_debug.h"
11#include "core/hle/service/kernel_helpers.h" 8#include "core/hle/service/btm/btm_system.h"
9#include "core/hle/service/btm/btm_user.h"
12#include "core/hle/service/server_manager.h" 10#include "core/hle/service/server_manager.h"
13#include "core/hle/service/service.h" 11#include "core/hle/service/service.h"
14 12
15namespace Service::BTM { 13namespace Service::BTM {
16 14
17class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { 15class IBtm final : public ServiceFramework<IBtm> {
18public: 16public:
19 explicit IBtmUserCore(Core::System& system_) 17 explicit IBtm(Core::System& system_) : ServiceFramework{system_, "btm"} {
20 : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} {
21 // clang-format off
22 static const FunctionInfo functions[] = {
23 {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"},
24 {1, nullptr, "GetBleScanFilterParameter"},
25 {2, nullptr, "GetBleScanFilterParameter2"},
26 {3, nullptr, "StartBleScanForGeneral"},
27 {4, nullptr, "StopBleScanForGeneral"},
28 {5, nullptr, "GetBleScanResultsForGeneral"},
29 {6, nullptr, "StartBleScanForPaired"},
30 {7, nullptr, "StopBleScanForPaired"},
31 {8, nullptr, "StartBleScanForSmartDevice"},
32 {9, nullptr, "StopBleScanForSmartDevice"},
33 {10, nullptr, "GetBleScanResultsForSmartDevice"},
34 {17, &IBtmUserCore::AcquireBleConnectionEvent, "AcquireBleConnectionEvent"},
35 {18, nullptr, "BleConnect"},
36 {19, nullptr, "BleDisconnect"},
37 {20, nullptr, "BleGetConnectionState"},
38 {21, nullptr, "AcquireBlePairingEvent"},
39 {22, nullptr, "BlePairDevice"},
40 {23, nullptr, "BleUnPairDevice"},
41 {24, nullptr, "BleUnPairDevice2"},
42 {25, nullptr, "BleGetPairedDevices"},
43 {26, &IBtmUserCore::AcquireBleServiceDiscoveryEvent, "AcquireBleServiceDiscoveryEvent"},
44 {27, nullptr, "GetGattServices"},
45 {28, nullptr, "GetGattService"},
46 {29, nullptr, "GetGattIncludedServices"},
47 {30, nullptr, "GetBelongingGattService"},
48 {31, nullptr, "GetGattCharacteristics"},
49 {32, nullptr, "GetGattDescriptors"},
50 {33, &IBtmUserCore::AcquireBleMtuConfigEvent, "AcquireBleMtuConfigEvent"},
51 {34, nullptr, "ConfigureBleMtu"},
52 {35, nullptr, "GetBleMtu"},
53 {36, nullptr, "RegisterBleGattDataPath"},
54 {37, nullptr, "UnregisterBleGattDataPath"},
55 };
56 // clang-format on
57 RegisterHandlers(functions);
58
59 scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent");
60 connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent");
61 service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent");
62 config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent");
63 }
64
65 ~IBtmUserCore() override {
66 service_context.CloseEvent(scan_event);
67 service_context.CloseEvent(connection_event);
68 service_context.CloseEvent(service_discovery_event);
69 service_context.CloseEvent(config_event);
70 }
71
72private:
73 void AcquireBleScanEvent(HLERequestContext& ctx) {
74 LOG_WARNING(Service_BTM, "(STUBBED) called");
75
76 IPC::ResponseBuilder rb{ctx, 3, 1};
77 rb.Push(ResultSuccess);
78 rb.Push(true);
79 rb.PushCopyObjects(scan_event->GetReadableEvent());
80 }
81
82 void AcquireBleConnectionEvent(HLERequestContext& ctx) {
83 LOG_WARNING(Service_BTM, "(STUBBED) called");
84
85 IPC::ResponseBuilder rb{ctx, 3, 1};
86 rb.Push(ResultSuccess);
87 rb.Push(true);
88 rb.PushCopyObjects(connection_event->GetReadableEvent());
89 }
90
91 void AcquireBleServiceDiscoveryEvent(HLERequestContext& ctx) {
92 LOG_WARNING(Service_BTM, "(STUBBED) called");
93
94 IPC::ResponseBuilder rb{ctx, 3, 1};
95 rb.Push(ResultSuccess);
96 rb.Push(true);
97 rb.PushCopyObjects(service_discovery_event->GetReadableEvent());
98 }
99
100 void AcquireBleMtuConfigEvent(HLERequestContext& ctx) {
101 LOG_WARNING(Service_BTM, "(STUBBED) called");
102
103 IPC::ResponseBuilder rb{ctx, 3, 1};
104 rb.Push(ResultSuccess);
105 rb.Push(true);
106 rb.PushCopyObjects(config_event->GetReadableEvent());
107 }
108
109 KernelHelpers::ServiceContext service_context;
110
111 Kernel::KEvent* scan_event;
112 Kernel::KEvent* connection_event;
113 Kernel::KEvent* service_discovery_event;
114 Kernel::KEvent* config_event;
115};
116
117class BTM_USR final : public ServiceFramework<BTM_USR> {
118public:
119 explicit BTM_USR(Core::System& system_) : ServiceFramework{system_, "btm:u"} {
120 // clang-format off
121 static const FunctionInfo functions[] = {
122 {0, &BTM_USR::GetCore, "GetCore"},
123 };
124 // clang-format on
125 RegisterHandlers(functions);
126 }
127
128private:
129 void GetCore(HLERequestContext& ctx) {
130 LOG_WARNING(Service_BTM, "called");
131
132 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
133 rb.Push(ResultSuccess);
134 rb.PushIpcInterface<IBtmUserCore>(system);
135 }
136};
137
138class BTM final : public ServiceFramework<BTM> {
139public:
140 explicit BTM(Core::System& system_) : ServiceFramework{system_, "btm"} {
141 // clang-format off 18 // clang-format off
142 static const FunctionInfo functions[] = { 19 static const FunctionInfo functions[] = {
143 {0, nullptr, "GetState"}, 20 {0, nullptr, "GetState"},
@@ -232,144 +109,13 @@ public:
232 } 109 }
233}; 110};
234 111
235class BTM_DBG final : public ServiceFramework<BTM_DBG> {
236public:
237 explicit BTM_DBG(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} {
238 // clang-format off
239 static const FunctionInfo functions[] = {
240 {0, nullptr, "AcquireDiscoveryEvent"},
241 {1, nullptr, "StartDiscovery"},
242 {2, nullptr, "CancelDiscovery"},
243 {3, nullptr, "GetDeviceProperty"},
244 {4, nullptr, "CreateBond"},
245 {5, nullptr, "CancelBond"},
246 {6, nullptr, "SetTsiMode"},
247 {7, nullptr, "GeneralTest"},
248 {8, nullptr, "HidConnect"},
249 {9, nullptr, "GeneralGet"},
250 {10, nullptr, "GetGattClientDisconnectionReason"},
251 {11, nullptr, "GetBleConnectionParameter"},
252 {12, nullptr, "GetBleConnectionParameterRequest"},
253 {13, nullptr, "Unknown13"},
254 };
255 // clang-format on
256
257 RegisterHandlers(functions);
258 }
259};
260
261class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> {
262public:
263 explicit IBtmSystemCore(Core::System& system_) : ServiceFramework{system_, "IBtmSystemCore"} {
264 // clang-format off
265 static const FunctionInfo functions[] = {
266 {0, &IBtmSystemCore::StartGamepadPairing, "StartGamepadPairing"},
267 {1, &IBtmSystemCore::CancelGamepadPairing, "CancelGamepadPairing"},
268 {2, nullptr, "ClearGamepadPairingDatabase"},
269 {3, nullptr, "GetPairedGamepadCount"},
270 {4, nullptr, "EnableRadio"},
271 {5, nullptr, "DisableRadio"},
272 {6, &IBtmSystemCore::IsRadioEnabled, "IsRadioEnabled"},
273 {7, nullptr, "AcquireRadioEvent"},
274 {8, nullptr, "AcquireGamepadPairingEvent"},
275 {9, nullptr, "IsGamepadPairingStarted"},
276 {10, nullptr, "StartAudioDeviceDiscovery"},
277 {11, nullptr, "StopAudioDeviceDiscovery"},
278 {12, nullptr, "IsDiscoveryingAudioDevice"},
279 {13, nullptr, "GetDiscoveredAudioDevice"},
280 {14, nullptr, "AcquireAudioDeviceConnectionEvent"},
281 {15, nullptr, "ConnectAudioDevice"},
282 {16, nullptr, "IsConnectingAudioDevice"},
283 {17, &IBtmSystemCore::GetConnectedAudioDevices, "GetConnectedAudioDevices"},
284 {18, nullptr, "DisconnectAudioDevice"},
285 {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"},
286 {20, &IBtmSystemCore::GetPairedAudioDevices, "GetPairedAudioDevices"},
287 {21, nullptr, "RemoveAudioDevicePairing"},
288 {22, &IBtmSystemCore::RequestAudioDeviceConnectionRejection, "RequestAudioDeviceConnectionRejection"},
289 {23, &IBtmSystemCore::CancelAudioDeviceConnectionRejection, "CancelAudioDeviceConnectionRejection"}
290 };
291 // clang-format on
292
293 RegisterHandlers(functions);
294 }
295
296private:
297 void IsRadioEnabled(HLERequestContext& ctx) {
298 LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running
299
300 IPC::ResponseBuilder rb{ctx, 3};
301 rb.Push(ResultSuccess);
302 rb.Push(true);
303 }
304
305 void StartGamepadPairing(HLERequestContext& ctx) {
306 LOG_WARNING(Service_BTM, "(STUBBED) called");
307 IPC::ResponseBuilder rb{ctx, 2};
308 rb.Push(ResultSuccess);
309 }
310
311 void CancelGamepadPairing(HLERequestContext& ctx) {
312 LOG_WARNING(Service_BTM, "(STUBBED) called");
313 IPC::ResponseBuilder rb{ctx, 2};
314 rb.Push(ResultSuccess);
315 }
316
317 void CancelAudioDeviceConnectionRejection(HLERequestContext& ctx) {
318 LOG_WARNING(Service_BTM, "(STUBBED) called");
319 IPC::ResponseBuilder rb{ctx, 2};
320 rb.Push(ResultSuccess);
321 }
322
323 void GetConnectedAudioDevices(HLERequestContext& ctx) {
324 LOG_WARNING(Service_BTM, "(STUBBED) called");
325 IPC::ResponseBuilder rb{ctx, 3};
326 rb.Push(ResultSuccess);
327 rb.Push<u32>(0);
328 }
329
330 void GetPairedAudioDevices(HLERequestContext& ctx) {
331 LOG_WARNING(Service_BTM, "(STUBBED) called");
332 IPC::ResponseBuilder rb{ctx, 3};
333 rb.Push(ResultSuccess);
334 rb.Push<u32>(0);
335 }
336
337 void RequestAudioDeviceConnectionRejection(HLERequestContext& ctx) {
338 LOG_WARNING(Service_BTM, "(STUBBED) called");
339 IPC::ResponseBuilder rb{ctx, 2};
340 rb.Push(ResultSuccess);
341 }
342};
343
344class BTM_SYS final : public ServiceFramework<BTM_SYS> {
345public:
346 explicit BTM_SYS(Core::System& system_) : ServiceFramework{system_, "btm:sys"} {
347 // clang-format off
348 static const FunctionInfo functions[] = {
349 {0, &BTM_SYS::GetCore, "GetCore"},
350 };
351 // clang-format on
352
353 RegisterHandlers(functions);
354 }
355
356private:
357 void GetCore(HLERequestContext& ctx) {
358 LOG_WARNING(Service_BTM, "called");
359
360 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
361 rb.Push(ResultSuccess);
362 rb.PushIpcInterface<IBtmSystemCore>(system);
363 }
364};
365
366void LoopProcess(Core::System& system) { 112void LoopProcess(Core::System& system) {
367 auto server_manager = std::make_unique<ServerManager>(system); 113 auto server_manager = std::make_unique<ServerManager>(system);
368 114
369 server_manager->RegisterNamedService("btm", std::make_shared<BTM>(system)); 115 server_manager->RegisterNamedService("btm", std::make_shared<IBtm>(system));
370 server_manager->RegisterNamedService("btm:dbg", std::make_shared<BTM_DBG>(system)); 116 server_manager->RegisterNamedService("btm:dbg", std::make_shared<IBtmDebug>(system));
371 server_manager->RegisterNamedService("btm:sys", std::make_shared<BTM_SYS>(system)); 117 server_manager->RegisterNamedService("btm:sys", std::make_shared<IBtmSystem>(system));
372 server_manager->RegisterNamedService("btm:u", std::make_shared<BTM_USR>(system)); 118 server_manager->RegisterNamedService("btm:u", std::make_shared<IBtmUser>(system));
373 ServerManager::RunServer(std::move(server_manager)); 119 ServerManager::RunServer(std::move(server_manager));
374} 120}
375 121
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 @@
3 3
4#pragma once 4#pragma once
5 5
6namespace Service::SM {
7class ServiceManager;
8}
9
10namespace Core { 6namespace Core {
11class System; 7class System;
12}; 8};
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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include "core/hle/service/btm/btm_debug.h"
5
6namespace Service::BTM {
7
8IBtmDebug::IBtmDebug(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "AcquireDiscoveryEvent"},
12 {1, nullptr, "StartDiscovery"},
13 {2, nullptr, "CancelDiscovery"},
14 {3, nullptr, "GetDeviceProperty"},
15 {4, nullptr, "CreateBond"},
16 {5, nullptr, "CancelBond"},
17 {6, nullptr, "SetTsiMode"},
18 {7, nullptr, "GeneralTest"},
19 {8, nullptr, "HidConnect"},
20 {9, nullptr, "GeneralGet"},
21 {10, nullptr, "GetGattClientDisconnectionReason"},
22 {11, nullptr, "GetBleConnectionParameter"},
23 {12, nullptr, "GetBleConnectionParameterRequest"},
24 {13, nullptr, "Unknown13"},
25 };
26 // clang-format on
27
28 RegisterHandlers(functions);
29}
30
31IBtmDebug::~IBtmDebug() = default;
32
33} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::BTM {
14
15class IBtmDebug final : public ServiceFramework<IBtmDebug> {
16public:
17 explicit IBtmDebug(Core::System& system_);
18 ~IBtmDebug() override;
19};
20
21} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include "common/logging/log.h"
5#include "core/hle/service/btm/btm_system.h"
6#include "core/hle/service/btm/btm_system_core.h"
7#include "core/hle/service/cmif_serialization.h"
8#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/service.h"
10
11namespace Service::BTM {
12
13IBtmSystem::IBtmSystem(Core::System& system_) : ServiceFramework{system_, "btm:sys"} {
14 // clang-format off
15 static const FunctionInfo functions[] = {
16 {0, C<&IBtmSystem::GetCore>, "GetCore"},
17 };
18 // clang-format on
19
20 RegisterHandlers(functions);
21}
22
23IBtmSystem::~IBtmSystem() = default;
24
25Result IBtmSystem::GetCore(OutInterface<IBtmSystemCore> out_interface) {
26 LOG_WARNING(Service_BTM, "called");
27
28 *out_interface = std::make_shared<IBtmSystemCore>(system);
29 R_SUCCEED();
30}
31
32} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::BTM {
14class IBtmSystemCore;
15
16class IBtmSystem final : public ServiceFramework<IBtmSystem> {
17public:
18 explicit IBtmSystem(Core::System& system_);
19 ~IBtmSystem() override;
20
21private:
22 Result GetCore(OutInterface<IBtmSystemCore> out_interface);
23};
24
25} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include "common/logging/log.h"
5#include "core/hle/service/btm/btm_system_core.h"
6#include "core/hle/service/cmif_serialization.h"
7#include "core/hle/service/ipc_helpers.h"
8#include "core/hle/service/server_manager.h"
9#include "core/hle/service/service.h"
10
11namespace Service::BTM {
12
13IBtmSystemCore::IBtmSystemCore(Core::System& system_)
14 : ServiceFramework{system_, "IBtmSystemCore"} {
15 // clang-format off
16 static const FunctionInfo functions[] = {
17 {0, C<&IBtmSystemCore::StartGamepadPairing>, "StartGamepadPairing"},
18 {1, C<&IBtmSystemCore::CancelGamepadPairing>, "CancelGamepadPairing"},
19 {2, nullptr, "ClearGamepadPairingDatabase"},
20 {3, nullptr, "GetPairedGamepadCount"},
21 {4, nullptr, "EnableRadio"},
22 {5, nullptr, "DisableRadio"},
23 {6, C<&IBtmSystemCore::IsRadioEnabled>, "IsRadioEnabled"},
24 {7, nullptr, "AcquireRadioEvent"},
25 {8, nullptr, "AcquireGamepadPairingEvent"},
26 {9, nullptr, "IsGamepadPairingStarted"},
27 {10, nullptr, "StartAudioDeviceDiscovery"},
28 {11, nullptr, "StopAudioDeviceDiscovery"},
29 {12, nullptr, "IsDiscoveryingAudioDevice"},
30 {13, nullptr, "GetDiscoveredAudioDevice"},
31 {14, nullptr, "AcquireAudioDeviceConnectionEvent"},
32 {15, nullptr, "ConnectAudioDevice"},
33 {16, nullptr, "IsConnectingAudioDevice"},
34 {17, C<&IBtmSystemCore::GetConnectedAudioDevices>, "GetConnectedAudioDevices"},
35 {18, nullptr, "DisconnectAudioDevice"},
36 {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"},
37 {20, C<&IBtmSystemCore::GetPairedAudioDevices>, "GetPairedAudioDevices"},
38 {21, nullptr, "RemoveAudioDevicePairing"},
39 {22, C<&IBtmSystemCore::RequestAudioDeviceConnectionRejection>, "RequestAudioDeviceConnectionRejection"},
40 {23, C<&IBtmSystemCore::CancelAudioDeviceConnectionRejection>, "CancelAudioDeviceConnectionRejection"}
41 };
42 // clang-format on
43
44 RegisterHandlers(functions);
45}
46
47IBtmSystemCore::~IBtmSystemCore() = default;
48
49Result IBtmSystemCore::StartGamepadPairing() {
50 LOG_WARNING(Service_BTM, "(STUBBED) called");
51 R_SUCCEED();
52}
53
54Result IBtmSystemCore::CancelGamepadPairing() {
55 LOG_WARNING(Service_BTM, "(STUBBED) called");
56 R_SUCCEED();
57}
58
59Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) {
60 LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running
61
62 *out_is_enabled = true;
63 R_SUCCEED();
64}
65
66Result IBtmSystemCore::GetConnectedAudioDevices(
67 Out<s32> out_count, OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices) {
68 LOG_WARNING(Service_BTM, "(STUBBED) called");
69
70 *out_count = 0;
71 R_SUCCEED();
72}
73
74Result IBtmSystemCore::GetPairedAudioDevices(
75 Out<s32> out_count, OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices) {
76 LOG_WARNING(Service_BTM, "(STUBBED) called");
77
78 *out_count = 0;
79 R_SUCCEED();
80}
81
82Result IBtmSystemCore::RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid) {
83 LOG_WARNING(Service_BTM, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
84 R_SUCCEED();
85}
86
87Result IBtmSystemCore::CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid) {
88 LOG_WARNING(Service_BTM, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
89 R_SUCCEED();
90}
91
92} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::BTM {
14
15class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> {
16public:
17 explicit IBtmSystemCore(Core::System& system_);
18 ~IBtmSystemCore() override;
19
20private:
21 Result StartGamepadPairing();
22 Result CancelGamepadPairing();
23 Result IsRadioEnabled(Out<bool> out_is_enabled);
24
25 Result GetConnectedAudioDevices(
26 Out<s32> out_count,
27 OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices);
28
29 Result GetPairedAudioDevices(
30 Out<s32> out_count,
31 OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices);
32
33 Result RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid);
34 Result CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid);
35};
36
37} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include "common/logging/log.h"
5#include "core/hle/service/btm/btm_user.h"
6#include "core/hle/service/btm/btm_user_core.h"
7#include "core/hle/service/cmif_serialization.h"
8#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/service.h"
10
11namespace Service::BTM {
12
13IBtmUser::IBtmUser(Core::System& system_) : ServiceFramework{system_, "btm:u"} {
14 // clang-format off
15 static const FunctionInfo functions[] = {
16 {0, C<&IBtmUser::GetCore>, "GetCore"},
17 };
18 // clang-format on
19
20 RegisterHandlers(functions);
21}
22
23IBtmUser::~IBtmUser() = default;
24
25Result IBtmUser::GetCore(OutInterface<IBtmUserCore> out_interface) {
26 LOG_WARNING(Service_BTM, "called");
27
28 *out_interface = std::make_shared<IBtmUserCore>(system);
29 R_SUCCEED();
30}
31
32} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::BTM {
14class IBtmUserCore;
15
16class IBtmUser final : public ServiceFramework<IBtmUser> {
17public:
18 explicit IBtmUser(Core::System& system_);
19 ~IBtmUser() override;
20
21private:
22 Result GetCore(OutInterface<IBtmUserCore> out_interface);
23};
24
25} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include <memory>
5
6#include "common/logging/log.h"
7#include "core/core.h"
8#include "core/hle/kernel/k_event.h"
9#include "core/hle/service/btm/btm_user_core.h"
10#include "core/hle/service/cmif_serialization.h"
11#include "core/hle/service/ipc_helpers.h"
12#include "core/hle/service/server_manager.h"
13#include "core/hle/service/service.h"
14
15namespace Service::BTM {
16
17IBtmUserCore::IBtmUserCore(Core::System& system_)
18 : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} {
19 // clang-format off
20 static const FunctionInfo functions[] = {
21 {0, C<&IBtmUserCore::AcquireBleScanEvent>, "AcquireBleScanEvent"},
22 {1, nullptr, "GetBleScanFilterParameter"},
23 {2, nullptr, "GetBleScanFilterParameter2"},
24 {3, nullptr, "StartBleScanForGeneral"},
25 {4, nullptr, "StopBleScanForGeneral"},
26 {5, nullptr, "GetBleScanResultsForGeneral"},
27 {6, nullptr, "StartBleScanForPaired"},
28 {7, nullptr, "StopBleScanForPaired"},
29 {8, nullptr, "StartBleScanForSmartDevice"},
30 {9, nullptr, "StopBleScanForSmartDevice"},
31 {10, nullptr, "GetBleScanResultsForSmartDevice"},
32 {17, C<&IBtmUserCore::AcquireBleConnectionEvent>, "AcquireBleConnectionEvent"},
33 {18, nullptr, "BleConnect"},
34 {19, nullptr, "BleDisconnect"},
35 {20, nullptr, "BleGetConnectionState"},
36 {21, nullptr, "AcquireBlePairingEvent"},
37 {22, nullptr, "BlePairDevice"},
38 {23, nullptr, "BleUnPairDevice"},
39 {24, nullptr, "BleUnPairDevice2"},
40 {25, nullptr, "BleGetPairedDevices"},
41 {26, C<&IBtmUserCore::AcquireBleServiceDiscoveryEvent>, "AcquireBleServiceDiscoveryEvent"},
42 {27, nullptr, "GetGattServices"},
43 {28, nullptr, "GetGattService"},
44 {29, nullptr, "GetGattIncludedServices"},
45 {30, nullptr, "GetBelongingGattService"},
46 {31, nullptr, "GetGattCharacteristics"},
47 {32, nullptr, "GetGattDescriptors"},
48 {33, C<&IBtmUserCore::AcquireBleMtuConfigEvent>, "AcquireBleMtuConfigEvent"},
49 {34, nullptr, "ConfigureBleMtu"},
50 {35, nullptr, "GetBleMtu"},
51 {36, nullptr, "RegisterBleGattDataPath"},
52 {37, nullptr, "UnregisterBleGattDataPath"},
53 };
54 // clang-format on
55 RegisterHandlers(functions);
56
57 scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent");
58 connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent");
59 service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent");
60 config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent");
61}
62
63IBtmUserCore::~IBtmUserCore() {
64 service_context.CloseEvent(scan_event);
65 service_context.CloseEvent(connection_event);
66 service_context.CloseEvent(service_discovery_event);
67 service_context.CloseEvent(config_event);
68}
69
70Result IBtmUserCore::AcquireBleScanEvent(Out<bool> out_is_valid,
71 OutCopyHandle<Kernel::KReadableEvent> out_event) {
72 LOG_WARNING(Service_BTM, "(STUBBED) called");
73
74 *out_is_valid = true;
75 *out_event = &scan_event->GetReadableEvent();
76 R_SUCCEED();
77}
78
79Result IBtmUserCore::AcquireBleConnectionEvent(Out<bool> out_is_valid,
80 OutCopyHandle<Kernel::KReadableEvent> out_event) {
81 LOG_WARNING(Service_BTM, "(STUBBED) called");
82
83 *out_is_valid = true;
84 *out_event = &connection_event->GetReadableEvent();
85 R_SUCCEED();
86}
87
88Result IBtmUserCore::AcquireBleServiceDiscoveryEvent(
89 Out<bool> out_is_valid, OutCopyHandle<Kernel::KReadableEvent> out_event) {
90 LOG_WARNING(Service_BTM, "(STUBBED) called");
91
92 *out_is_valid = true;
93 *out_event = &service_discovery_event->GetReadableEvent();
94 R_SUCCEED();
95}
96
97Result IBtmUserCore::AcquireBleMtuConfigEvent(Out<bool> out_is_valid,
98 OutCopyHandle<Kernel::KReadableEvent> out_event) {
99 LOG_WARNING(Service_BTM, "(STUBBED) called");
100
101 *out_is_valid = true;
102 *out_event = &config_event->GetReadableEvent();
103 R_SUCCEED();
104}
105
106} // 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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/kernel_helpers.h"
8#include "core/hle/service/service.h"
9
10namespace Kernel {
11class KEvent;
12class KReadableEvent;
13}
14
15namespace Core {
16class System;
17}
18
19namespace Service::BTM {
20
21class IBtmUserCore final : public ServiceFramework<IBtmUserCore> {
22public:
23 explicit IBtmUserCore(Core::System& system_);
24 ~IBtmUserCore() override;
25
26private:
27 Result AcquireBleScanEvent(Out<bool> out_is_valid,
28 OutCopyHandle<Kernel::KReadableEvent> out_event);
29
30 Result AcquireBleConnectionEvent(Out<bool> out_is_valid,
31 OutCopyHandle<Kernel::KReadableEvent> out_event);
32
33 Result AcquireBleServiceDiscoveryEvent(Out<bool> out_is_valid,
34 OutCopyHandle<Kernel::KReadableEvent> out_event);
35
36 Result AcquireBleMtuConfigEvent(Out<bool> out_is_valid,
37 OutCopyHandle<Kernel::KReadableEvent> out_event);
38
39 KernelHelpers::ServiceContext service_context;
40
41 Kernel::KEvent* scan_event;
42 Kernel::KEvent* connection_event;
43 Kernel::KEvent* service_discovery_event;
44 Kernel::KEvent* config_event;
45};
46
47} // namespace Service::BTM