summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/btdrv/btdrv.cpp
blob: 04c78e81abc811c525bf62ff7d3de2040205d81f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/hle_ipc.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/readable_event.h"
#include "core/hle/kernel/writable_event.h"
#include "core/hle/service/btdrv/btdrv.h"
#include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"

namespace Service::BtDrv {

class Bt final : public ServiceFramework<Bt> {
public:
    explicit Bt() : ServiceFramework{"bt"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "Unknown0"},
            {1, nullptr, "Unknown1"},
            {2, nullptr, "Unknown2"},
            {3, nullptr, "Unknown3"},
            {4, nullptr, "Unknown4"},
            {5, nullptr, "Unknown5"},
            {6, nullptr, "Unknown6"},
            {7, nullptr, "Unknown7"},
            {8, nullptr, "Unknown8"},
            {9, &Bt::RegisterEvent, "RegisterEvent"},
        };
        // clang-format on
        RegisterHandlers(functions);

        auto& kernel = Core::System::GetInstance().Kernel();
        register_event = Kernel::WritableEvent::CreateRegisteredEventPair(
            kernel, Kernel::ResetType::OneShot, "BT:RegisterEvent");
    }

private:
    void RegisterEvent(Kernel::HLERequestContext& ctx) {
        LOG_WARNING(Service_BTM, "(STUBBED) called");

        IPC::ResponseBuilder rb{ctx, 2, 1};
        rb.Push(RESULT_SUCCESS);
        const auto& event{Core::System::GetInstance().Kernel().FindNamedEvent("BT:RegisterEvent")};
        rb.PushCopyObjects(event->second);
    }
    Kernel::SharedPtr<Kernel::WritableEvent> register_event;
};

class BtDrv final : public ServiceFramework<BtDrv> {
public:
    explicit BtDrv() : ServiceFramework{"btdrv"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "Unknown"},
            {1, nullptr, "Init"},
            {2, nullptr, "Enable"},
            {3, nullptr, "Disable"},
            {4, nullptr, "CleanupAndShutdown"},
            {5, nullptr, "GetAdapterProperties"},
            {6, nullptr, "GetAdapterProperty"},
            {7, nullptr, "SetAdapterProperty"},
            {8, nullptr, "StartDiscovery"},
            {9, nullptr, "CancelDiscovery"},
            {10, nullptr, "CreateBond"},
            {11, nullptr, "RemoveBond"},
            {12, nullptr, "CancelBond"},
            {13, nullptr, "PinReply"},
            {14, nullptr, "SspReply"},
            {15, nullptr, "Unknown2"},
            {16, nullptr, "InitInterfaces"},
            {17, nullptr, "HidHostInterface_Connect"},
            {18, nullptr, "HidHostInterface_Disconnect"},
            {19, nullptr, "HidHostInterface_SendData"},
            {20, nullptr, "HidHostInterface_SendData2"},
            {21, nullptr, "HidHostInterface_SetReport"},
            {22, nullptr, "HidHostInterface_GetReport"},
            {23, nullptr, "HidHostInterface_WakeController"},
            {24, nullptr, "HidHostInterface_AddPairedDevice"},
            {25, nullptr, "HidHostInterface_GetPairedDevice"},
            {26, nullptr, "HidHostInterface_CleanupAndShutdown"},
            {27, nullptr, "Unknown3"},
            {28, nullptr, "ExtInterface_SetTSI"},
            {29, nullptr, "ExtInterface_SetBurstMode"},
            {30, nullptr, "ExtInterface_SetZeroRetran"},
            {31, nullptr, "ExtInterface_SetMcMode"},
            {32, nullptr, "ExtInterface_StartLlrMode"},
            {33, nullptr, "ExtInterface_ExitLlrMode"},
            {34, nullptr, "ExtInterface_SetRadio"},
            {35, nullptr, "ExtInterface_SetVisibility"},
            {36, nullptr, "Unknown4"},
            {37, nullptr, "Unknown5"},
            {38, nullptr, "HidHostInterface_GetLatestPlr"},
            {39, nullptr, "ExtInterface_GetPendingConnections"},
            {40, nullptr, "HidHostInterface_GetChannelMap"},
            {41, nullptr, "SetIsBluetoothBoostEnabled"},
            {42, nullptr, "GetIsBluetoothBoostEnabled"},
            {43, nullptr, "SetIsBluetoothAfhEnabled"},
            {44, nullptr, "GetIsBluetoothAfhEnabled"},
        };
        // clang-format on

        RegisterHandlers(functions);
    }
};

void InstallInterfaces(SM::ServiceManager& sm) {
    std::make_shared<BtDrv>()->InstallAsService(sm);
    std::make_shared<Bt>()->InstallAsService(sm);
}

} // namespace Service::BtDrv