summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/btm/btm_debug.cpp32
-rw-r--r--src/core/hle/service/btm/btm_system.cpp7
-rw-r--r--src/core/hle/service/btm/btm_system_core.cpp101
-rw-r--r--src/core/hle/service/btm/btm_system_core.h23
-rw-r--r--src/core/hle/service/btm/btm_user.cpp8
-rw-r--r--src/core/hle/service/btm/btm_user_core.cpp71
-rw-r--r--src/core/hle/service/btm/btm_user_core.h2
7 files changed, 148 insertions, 96 deletions
diff --git a/src/core/hle/service/btm/btm_debug.cpp b/src/core/hle/service/btm/btm_debug.cpp
index 67d206560..4d61d2641 100644
--- a/src/core/hle/service/btm/btm_debug.cpp
+++ b/src/core/hle/service/btm/btm_debug.cpp
@@ -7,22 +7,22 @@ namespace Service::BTM {
7 7
8IBtmDebug::IBtmDebug(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} { 8IBtmDebug::IBtmDebug(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} {
9 // clang-format off 9 // clang-format off
10 static const FunctionInfo functions[] = { 10 static const FunctionInfo functions[] = {
11 {0, nullptr, "AcquireDiscoveryEvent"}, 11 {0, nullptr, "AcquireDiscoveryEvent"},
12 {1, nullptr, "StartDiscovery"}, 12 {1, nullptr, "StartDiscovery"},
13 {2, nullptr, "CancelDiscovery"}, 13 {2, nullptr, "CancelDiscovery"},
14 {3, nullptr, "GetDeviceProperty"}, 14 {3, nullptr, "GetDeviceProperty"},
15 {4, nullptr, "CreateBond"}, 15 {4, nullptr, "CreateBond"},
16 {5, nullptr, "CancelBond"}, 16 {5, nullptr, "CancelBond"},
17 {6, nullptr, "SetTsiMode"}, 17 {6, nullptr, "SetTsiMode"},
18 {7, nullptr, "GeneralTest"}, 18 {7, nullptr, "GeneralTest"},
19 {8, nullptr, "HidConnect"}, 19 {8, nullptr, "HidConnect"},
20 {9, nullptr, "GeneralGet"}, 20 {9, nullptr, "GeneralGet"},
21 {10, nullptr, "GetGattClientDisconnectionReason"}, 21 {10, nullptr, "GetGattClientDisconnectionReason"},
22 {11, nullptr, "GetBleConnectionParameter"}, 22 {11, nullptr, "GetBleConnectionParameter"},
23 {12, nullptr, "GetBleConnectionParameterRequest"}, 23 {12, nullptr, "GetBleConnectionParameterRequest"},
24 {13, nullptr, "Unknown13"}, 24 {13, nullptr, "Unknown13"},
25 }; 25 };
26 // clang-format on 26 // clang-format on
27 27
28 RegisterHandlers(functions); 28 RegisterHandlers(functions);
diff --git a/src/core/hle/service/btm/btm_system.cpp b/src/core/hle/service/btm/btm_system.cpp
index f6ac6bdba..99718a7b0 100644
--- a/src/core/hle/service/btm/btm_system.cpp
+++ b/src/core/hle/service/btm/btm_system.cpp
@@ -5,16 +5,15 @@
5#include "core/hle/service/btm/btm_system.h" 5#include "core/hle/service/btm/btm_system.h"
6#include "core/hle/service/btm/btm_system_core.h" 6#include "core/hle/service/btm/btm_system_core.h"
7#include "core/hle/service/cmif_serialization.h" 7#include "core/hle/service/cmif_serialization.h"
8#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
10 9
11namespace Service::BTM { 10namespace Service::BTM {
12 11
13IBtmSystem::IBtmSystem(Core::System& system_) : ServiceFramework{system_, "btm:sys"} { 12IBtmSystem::IBtmSystem(Core::System& system_) : ServiceFramework{system_, "btm:sys"} {
14 // clang-format off 13 // clang-format off
15 static const FunctionInfo functions[] = { 14 static const FunctionInfo functions[] = {
16 {0, C<&IBtmSystem::GetCore>, "GetCore"}, 15 {0, C<&IBtmSystem::GetCore>, "GetCore"},
17 }; 16 };
18 // clang-format on 17 // clang-format on
19 18
20 RegisterHandlers(functions); 19 RegisterHandlers(functions);
diff --git a/src/core/hle/service/btm/btm_system_core.cpp b/src/core/hle/service/btm/btm_system_core.cpp
index 42628badb..4bc8a9e8b 100644
--- a/src/core/hle/service/btm/btm_system_core.cpp
+++ b/src/core/hle/service/btm/btm_system_core.cpp
@@ -4,47 +4,55 @@
4#include "common/logging/log.h" 4#include "common/logging/log.h"
5#include "core/hle/service/btm/btm_system_core.h" 5#include "core/hle/service/btm/btm_system_core.h"
6#include "core/hle/service/cmif_serialization.h" 6#include "core/hle/service/cmif_serialization.h"
7#include "core/hle/service/ipc_helpers.h" 7#include "core/hle/service/set/system_settings_server.h"
8#include "core/hle/service/server_manager.h" 8#include "core/hle/service/sm/sm.h"
9#include "core/hle/service/service.h"
10 9
11namespace Service::BTM { 10namespace Service::BTM {
12 11
13IBtmSystemCore::IBtmSystemCore(Core::System& system_) 12IBtmSystemCore::IBtmSystemCore(Core::System& system_)
14 : ServiceFramework{system_, "IBtmSystemCore"} { 13 : ServiceFramework{system_, "IBtmSystemCore"}, service_context{system_, "IBtmSystemCore"} {
15 // clang-format off 14 // clang-format off
16 static const FunctionInfo functions[] = { 15 static const FunctionInfo functions[] = {
17 {0, C<&IBtmSystemCore::StartGamepadPairing>, "StartGamepadPairing"}, 16 {0, C<&IBtmSystemCore::StartGamepadPairing>, "StartGamepadPairing"},
18 {1, C<&IBtmSystemCore::CancelGamepadPairing>, "CancelGamepadPairing"}, 17 {1, C<&IBtmSystemCore::CancelGamepadPairing>, "CancelGamepadPairing"},
19 {2, nullptr, "ClearGamepadPairingDatabase"}, 18 {2, nullptr, "ClearGamepadPairingDatabase"},
20 {3, nullptr, "GetPairedGamepadCount"}, 19 {3, nullptr, "GetPairedGamepadCount"},
21 {4, nullptr, "EnableRadio"}, 20 {4, C<&IBtmSystemCore::EnableRadio>, "EnableRadio"},
22 {5, nullptr, "DisableRadio"}, 21 {5, C<&IBtmSystemCore::DisableRadio>, "DisableRadio"},
23 {6, C<&IBtmSystemCore::IsRadioEnabled>, "IsRadioEnabled"}, 22 {6, C<&IBtmSystemCore::IsRadioEnabled>, "IsRadioEnabled"},
24 {7, nullptr, "AcquireRadioEvent"}, 23 {7, C<&IBtmSystemCore::AcquireRadioEvent>, "AcquireRadioEvent"},
25 {8, nullptr, "AcquireGamepadPairingEvent"}, 24 {8, nullptr, "AcquireGamepadPairingEvent"},
26 {9, nullptr, "IsGamepadPairingStarted"}, 25 {9, nullptr, "IsGamepadPairingStarted"},
27 {10, nullptr, "StartAudioDeviceDiscovery"}, 26 {10, nullptr, "StartAudioDeviceDiscovery"},
28 {11, nullptr, "StopAudioDeviceDiscovery"}, 27 {11, nullptr, "StopAudioDeviceDiscovery"},
29 {12, nullptr, "IsDiscoveryingAudioDevice"}, 28 {12, nullptr, "IsDiscoveryingAudioDevice"},
30 {13, nullptr, "GetDiscoveredAudioDevice"}, 29 {13, nullptr, "GetDiscoveredAudioDevice"},
31 {14, nullptr, "AcquireAudioDeviceConnectionEvent"}, 30 {14, C<&IBtmSystemCore::AcquireAudioDeviceConnectionEvent>, "AcquireAudioDeviceConnectionEvent"},
32 {15, nullptr, "ConnectAudioDevice"}, 31 {15, nullptr, "ConnectAudioDevice"},
33 {16, nullptr, "IsConnectingAudioDevice"}, 32 {16, nullptr, "IsConnectingAudioDevice"},
34 {17, C<&IBtmSystemCore::GetConnectedAudioDevices>, "GetConnectedAudioDevices"}, 33 {17, C<&IBtmSystemCore::GetConnectedAudioDevices>, "GetConnectedAudioDevices"},
35 {18, nullptr, "DisconnectAudioDevice"}, 34 {18, nullptr, "DisconnectAudioDevice"},
36 {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"}, 35 {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"},
37 {20, C<&IBtmSystemCore::GetPairedAudioDevices>, "GetPairedAudioDevices"}, 36 {20, C<&IBtmSystemCore::GetPairedAudioDevices>, "GetPairedAudioDevices"},
38 {21, nullptr, "RemoveAudioDevicePairing"}, 37 {21, nullptr, "RemoveAudioDevicePairing"},
39 {22, C<&IBtmSystemCore::RequestAudioDeviceConnectionRejection>, "RequestAudioDeviceConnectionRejection"}, 38 {22, C<&IBtmSystemCore::RequestAudioDeviceConnectionRejection>, "RequestAudioDeviceConnectionRejection"},
40 {23, C<&IBtmSystemCore::CancelAudioDeviceConnectionRejection>, "CancelAudioDeviceConnectionRejection"} 39 {23, C<&IBtmSystemCore::CancelAudioDeviceConnectionRejection>, "CancelAudioDeviceConnectionRejection"}
41 }; 40 };
42 // clang-format on 41 // clang-format on
43 42
44 RegisterHandlers(functions); 43 RegisterHandlers(functions);
44 radio_event = service_context.CreateEvent("IBtmSystemCore::RadioEvent");
45 audio_device_connection_event =
46 service_context.CreateEvent("IBtmSystemCore::AudioDeviceConnectionEvent");
47
48 m_set_sys =
49 system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
45} 50}
46 51
47IBtmSystemCore::~IBtmSystemCore() = default; 52IBtmSystemCore::~IBtmSystemCore() {
53 service_context.CloseEvent(radio_event);
54 service_context.CloseEvent(audio_device_connection_event);
55}
48 56
49Result IBtmSystemCore::StartGamepadPairing() { 57Result IBtmSystemCore::StartGamepadPairing() {
50 LOG_WARNING(Service_BTM, "(STUBBED) called"); 58 LOG_WARNING(Service_BTM, "(STUBBED) called");
@@ -56,10 +64,37 @@ Result IBtmSystemCore::CancelGamepadPairing() {
56 R_SUCCEED(); 64 R_SUCCEED();
57} 65}
58 66
67Result IBtmSystemCore::EnableRadio() {
68 LOG_DEBUG(Service_BTM, "called");
69
70 R_RETURN(m_set_sys->SetBluetoothEnableFlag(true));
71}
72Result IBtmSystemCore::DisableRadio() {
73 LOG_DEBUG(Service_BTM, "called");
74
75 R_RETURN(m_set_sys->SetBluetoothEnableFlag(false));
76}
77
59Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) { 78Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) {
60 LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running 79 LOG_DEBUG(Service_BTM, "called");
80
81 R_RETURN(m_set_sys->GetBluetoothEnableFlag(out_is_enabled));
82}
83
84Result IBtmSystemCore::AcquireRadioEvent(Out<bool> out_is_valid,
85 OutCopyHandle<Kernel::KReadableEvent> out_event) {
86 LOG_WARNING(Service_BTM, "(STUBBED) called");
87
88 *out_is_valid = true;
89 *out_event = &radio_event->GetReadableEvent();
90 R_SUCCEED();
91}
92
93Result IBtmSystemCore::AcquireAudioDeviceConnectionEvent(
94 OutCopyHandle<Kernel::KReadableEvent> out_event) {
95 LOG_WARNING(Service_BTM, "(STUBBED) called");
61 96
62 *out_is_enabled = true; 97 *out_event = &audio_device_connection_event->GetReadableEvent();
63 R_SUCCEED(); 98 R_SUCCEED();
64} 99}
65 100
diff --git a/src/core/hle/service/btm/btm_system_core.h b/src/core/hle/service/btm/btm_system_core.h
index f1ca11f37..06498b21e 100644
--- a/src/core/hle/service/btm/btm_system_core.h
+++ b/src/core/hle/service/btm/btm_system_core.h
@@ -4,12 +4,22 @@
4#pragma once 4#pragma once
5 5
6#include "core/hle/service/cmif_types.h" 6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/kernel_helpers.h"
7#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
8 9
10namespace Kernel {
11class KEvent;
12class KReadableEvent;
13} // namespace Kernel
14
9namespace Core { 15namespace Core {
10class System; 16class System;
11} 17}
12 18
19namespace Service::Set {
20class ISystemSettingsServer;
21}
22
13namespace Service::BTM { 23namespace Service::BTM {
14 24
15class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> { 25class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> {
@@ -20,8 +30,15 @@ public:
20private: 30private:
21 Result StartGamepadPairing(); 31 Result StartGamepadPairing();
22 Result CancelGamepadPairing(); 32 Result CancelGamepadPairing();
33 Result EnableRadio();
34 Result DisableRadio();
23 Result IsRadioEnabled(Out<bool> out_is_enabled); 35 Result IsRadioEnabled(Out<bool> out_is_enabled);
24 36
37 Result AcquireRadioEvent(Out<bool> out_is_valid,
38 OutCopyHandle<Kernel::KReadableEvent> out_event);
39
40 Result AcquireAudioDeviceConnectionEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
41
25 Result GetConnectedAudioDevices( 42 Result GetConnectedAudioDevices(
26 Out<s32> out_count, 43 Out<s32> out_count,
27 OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices); 44 OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices);
@@ -32,6 +49,12 @@ private:
32 49
33 Result RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid); 50 Result RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid);
34 Result CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid); 51 Result CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid);
52
53 KernelHelpers::ServiceContext service_context;
54
55 Kernel::KEvent* radio_event;
56 Kernel::KEvent* audio_device_connection_event;
57 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
35}; 58};
36 59
37} // namespace Service::BTM 60} // namespace Service::BTM
diff --git a/src/core/hle/service/btm/btm_user.cpp b/src/core/hle/service/btm/btm_user.cpp
index 0c3b41208..d2e228f8d 100644
--- a/src/core/hle/service/btm/btm_user.cpp
+++ b/src/core/hle/service/btm/btm_user.cpp
@@ -5,16 +5,14 @@
5#include "core/hle/service/btm/btm_user.h" 5#include "core/hle/service/btm/btm_user.h"
6#include "core/hle/service/btm/btm_user_core.h" 6#include "core/hle/service/btm/btm_user_core.h"
7#include "core/hle/service/cmif_serialization.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 8
11namespace Service::BTM { 9namespace Service::BTM {
12 10
13IBtmUser::IBtmUser(Core::System& system_) : ServiceFramework{system_, "btm:u"} { 11IBtmUser::IBtmUser(Core::System& system_) : ServiceFramework{system_, "btm:u"} {
14 // clang-format off 12 // clang-format off
15 static const FunctionInfo functions[] = { 13 static const FunctionInfo functions[] = {
16 {0, C<&IBtmUser::GetCore>, "GetCore"}, 14 {0, C<&IBtmUser::GetCore>, "GetCore"},
17 }; 15 };
18 // clang-format on 16 // clang-format on
19 17
20 RegisterHandlers(functions); 18 RegisterHandlers(functions);
diff --git a/src/core/hle/service/btm/btm_user_core.cpp b/src/core/hle/service/btm/btm_user_core.cpp
index b1e38da65..6f9fa589b 100644
--- a/src/core/hle/service/btm/btm_user_core.cpp
+++ b/src/core/hle/service/btm/btm_user_core.cpp
@@ -8,49 +8,46 @@
8#include "core/hle/kernel/k_event.h" 8#include "core/hle/kernel/k_event.h"
9#include "core/hle/service/btm/btm_user_core.h" 9#include "core/hle/service/btm/btm_user_core.h"
10#include "core/hle/service/cmif_serialization.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 11
15namespace Service::BTM { 12namespace Service::BTM {
16 13
17IBtmUserCore::IBtmUserCore(Core::System& system_) 14IBtmUserCore::IBtmUserCore(Core::System& system_)
18 : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { 15 : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} {
19 // clang-format off 16 // clang-format off
20 static const FunctionInfo functions[] = { 17 static const FunctionInfo functions[] = {
21 {0, C<&IBtmUserCore::AcquireBleScanEvent>, "AcquireBleScanEvent"}, 18 {0, C<&IBtmUserCore::AcquireBleScanEvent>, "AcquireBleScanEvent"},
22 {1, nullptr, "GetBleScanFilterParameter"}, 19 {1, nullptr, "GetBleScanFilterParameter"},
23 {2, nullptr, "GetBleScanFilterParameter2"}, 20 {2, nullptr, "GetBleScanFilterParameter2"},
24 {3, nullptr, "StartBleScanForGeneral"}, 21 {3, nullptr, "StartBleScanForGeneral"},
25 {4, nullptr, "StopBleScanForGeneral"}, 22 {4, nullptr, "StopBleScanForGeneral"},
26 {5, nullptr, "GetBleScanResultsForGeneral"}, 23 {5, nullptr, "GetBleScanResultsForGeneral"},
27 {6, nullptr, "StartBleScanForPaired"}, 24 {6, nullptr, "StartBleScanForPaired"},
28 {7, nullptr, "StopBleScanForPaired"}, 25 {7, nullptr, "StopBleScanForPaired"},
29 {8, nullptr, "StartBleScanForSmartDevice"}, 26 {8, nullptr, "StartBleScanForSmartDevice"},
30 {9, nullptr, "StopBleScanForSmartDevice"}, 27 {9, nullptr, "StopBleScanForSmartDevice"},
31 {10, nullptr, "GetBleScanResultsForSmartDevice"}, 28 {10, nullptr, "GetBleScanResultsForSmartDevice"},
32 {17, C<&IBtmUserCore::AcquireBleConnectionEvent>, "AcquireBleConnectionEvent"}, 29 {17, C<&IBtmUserCore::AcquireBleConnectionEvent>, "AcquireBleConnectionEvent"},
33 {18, nullptr, "BleConnect"}, 30 {18, nullptr, "BleConnect"},
34 {19, nullptr, "BleDisconnect"}, 31 {19, nullptr, "BleDisconnect"},
35 {20, nullptr, "BleGetConnectionState"}, 32 {20, nullptr, "BleGetConnectionState"},
36 {21, nullptr, "AcquireBlePairingEvent"}, 33 {21, nullptr, "AcquireBlePairingEvent"},
37 {22, nullptr, "BlePairDevice"}, 34 {22, nullptr, "BlePairDevice"},
38 {23, nullptr, "BleUnPairDevice"}, 35 {23, nullptr, "BleUnPairDevice"},
39 {24, nullptr, "BleUnPairDevice2"}, 36 {24, nullptr, "BleUnPairDevice2"},
40 {25, nullptr, "BleGetPairedDevices"}, 37 {25, nullptr, "BleGetPairedDevices"},
41 {26, C<&IBtmUserCore::AcquireBleServiceDiscoveryEvent>, "AcquireBleServiceDiscoveryEvent"}, 38 {26, C<&IBtmUserCore::AcquireBleServiceDiscoveryEvent>, "AcquireBleServiceDiscoveryEvent"},
42 {27, nullptr, "GetGattServices"}, 39 {27, nullptr, "GetGattServices"},
43 {28, nullptr, "GetGattService"}, 40 {28, nullptr, "GetGattService"},
44 {29, nullptr, "GetGattIncludedServices"}, 41 {29, nullptr, "GetGattIncludedServices"},
45 {30, nullptr, "GetBelongingGattService"}, 42 {30, nullptr, "GetBelongingGattService"},
46 {31, nullptr, "GetGattCharacteristics"}, 43 {31, nullptr, "GetGattCharacteristics"},
47 {32, nullptr, "GetGattDescriptors"}, 44 {32, nullptr, "GetGattDescriptors"},
48 {33, C<&IBtmUserCore::AcquireBleMtuConfigEvent>, "AcquireBleMtuConfigEvent"}, 45 {33, C<&IBtmUserCore::AcquireBleMtuConfigEvent>, "AcquireBleMtuConfigEvent"},
49 {34, nullptr, "ConfigureBleMtu"}, 46 {34, nullptr, "ConfigureBleMtu"},
50 {35, nullptr, "GetBleMtu"}, 47 {35, nullptr, "GetBleMtu"},
51 {36, nullptr, "RegisterBleGattDataPath"}, 48 {36, nullptr, "RegisterBleGattDataPath"},
52 {37, nullptr, "UnregisterBleGattDataPath"}, 49 {37, nullptr, "UnregisterBleGattDataPath"},
53 }; 50 };
54 // clang-format on 51 // clang-format on
55 RegisterHandlers(functions); 52 RegisterHandlers(functions);
56 53
diff --git a/src/core/hle/service/btm/btm_user_core.h b/src/core/hle/service/btm/btm_user_core.h
index 5346933cb..dc0a22e81 100644
--- a/src/core/hle/service/btm/btm_user_core.h
+++ b/src/core/hle/service/btm/btm_user_core.h
@@ -10,7 +10,7 @@
10namespace Kernel { 10namespace Kernel {
11class KEvent; 11class KEvent;
12class KReadableEvent; 12class KReadableEvent;
13} 13} // namespace Kernel
14 14
15namespace Core { 15namespace Core {
16class System; 16class System;