2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

service: btm: Implement function needed by QLaunch

This commit is contained in:
Narr the Reg 2024-02-15 20:24:20 -06:00 committed by german77
parent 9c0724b270
commit 110969e207
7 changed files with 149 additions and 97 deletions

View file

@ -5,7 +5,6 @@
#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 {

View file

@ -4,31 +4,30 @@
#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"
#include "core/hle/service/set/system_settings_server.h"
#include "core/hle/service/sm/sm.h"
namespace Service::BTM {
IBtmSystemCore::IBtmSystemCore(Core::System& system_)
: ServiceFramework{system_, "IBtmSystemCore"} {
: ServiceFramework{system_, "IBtmSystemCore"}, service_context{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"},
{4, C<&IBtmSystemCore::EnableRadio>, "EnableRadio"},
{5, C<&IBtmSystemCore::DisableRadio>, "DisableRadio"},
{6, C<&IBtmSystemCore::IsRadioEnabled>, "IsRadioEnabled"},
{7, nullptr, "AcquireRadioEvent"},
{7, C<&IBtmSystemCore::AcquireRadioEvent>, "AcquireRadioEvent"},
{8, nullptr, "AcquireGamepadPairingEvent"},
{9, nullptr, "IsGamepadPairingStarted"},
{10, nullptr, "StartAudioDeviceDiscovery"},
{11, nullptr, "StopAudioDeviceDiscovery"},
{12, nullptr, "IsDiscoveryingAudioDevice"},
{13, nullptr, "GetDiscoveredAudioDevice"},
{14, nullptr, "AcquireAudioDeviceConnectionEvent"},
{14, C<&IBtmSystemCore::AcquireAudioDeviceConnectionEvent>, "AcquireAudioDeviceConnectionEvent"},
{15, nullptr, "ConnectAudioDevice"},
{16, nullptr, "IsConnectingAudioDevice"},
{17, C<&IBtmSystemCore::GetConnectedAudioDevices>, "GetConnectedAudioDevices"},
@ -42,9 +41,18 @@ IBtmSystemCore::IBtmSystemCore(Core::System& system_)
// clang-format on
RegisterHandlers(functions);
radio_event = service_context.CreateEvent("IBtmSystemCore::RadioEvent");
audio_device_connection_event =
service_context.CreateEvent("IBtmSystemCore::AudioDeviceConnectionEvent");
m_set_sys =
system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
}
IBtmSystemCore::~IBtmSystemCore() = default;
IBtmSystemCore::~IBtmSystemCore() {
service_context.CloseEvent(radio_event);
service_context.CloseEvent(audio_device_connection_event);
}
Result IBtmSystemCore::StartGamepadPairing() {
LOG_WARNING(Service_BTM, "(STUBBED) called");
@ -56,10 +64,37 @@ Result IBtmSystemCore::CancelGamepadPairing() {
R_SUCCEED();
}
Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) {
LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running
Result IBtmSystemCore::EnableRadio() {
LOG_DEBUG(Service_BTM, "called");
*out_is_enabled = true;
R_RETURN(m_set_sys->SetBluetoothEnableFlag(true));
}
Result IBtmSystemCore::DisableRadio() {
LOG_DEBUG(Service_BTM, "called");
R_RETURN(m_set_sys->SetBluetoothEnableFlag(false));
}
Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) {
LOG_DEBUG(Service_BTM, "called");
R_RETURN(m_set_sys->GetBluetoothEnableFlag(out_is_enabled));
}
Result IBtmSystemCore::AcquireRadioEvent(Out<bool> out_is_valid,
OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_WARNING(Service_BTM, "(STUBBED) called");
*out_is_valid = true;
*out_event = &radio_event->GetReadableEvent();
R_SUCCEED();
}
Result IBtmSystemCore::AcquireAudioDeviceConnectionEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_WARNING(Service_BTM, "(STUBBED) called");
*out_event = &audio_device_connection_event->GetReadableEvent();
R_SUCCEED();
}

View file

@ -4,12 +4,22 @@
#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 Kernel
namespace Core {
class System;
}
namespace Service::Set {
class ISystemSettingsServer;
}
namespace Service::BTM {
class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> {
@ -20,8 +30,15 @@ public:
private:
Result StartGamepadPairing();
Result CancelGamepadPairing();
Result EnableRadio();
Result DisableRadio();
Result IsRadioEnabled(Out<bool> out_is_enabled);
Result AcquireRadioEvent(Out<bool> out_is_valid,
OutCopyHandle<Kernel::KReadableEvent> out_event);
Result AcquireAudioDeviceConnectionEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetConnectedAudioDevices(
Out<s32> out_count,
OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices);
@ -32,6 +49,12 @@ private:
Result RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid);
Result CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid);
KernelHelpers::ServiceContext service_context;
Kernel::KEvent* radio_event;
Kernel::KEvent* audio_device_connection_event;
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
};
} // namespace Service::BTM

View file

@ -5,8 +5,6 @@
#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 {

View file

@ -8,9 +8,6 @@
#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 {

View file

@ -10,7 +10,7 @@
namespace Kernel {
class KEvent;
class KReadableEvent;
}
} // namespace Kernel
namespace Core {
class System;