summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/controllers/palma.cpp
blob: 51a18335f5dc0a403127d74c85d4c0b10fa9fc81 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "core/core_timing.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
#include "core/hid/hid_types.h"
#include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/service/hid/controllers/palma.h"
#include "core/hle/service/kernel_helpers.h"

namespace Service::HID {

Controller_Palma::Controller_Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
                                   KernelHelpers::ServiceContext& service_context_)
    : ControllerBase{hid_core_}, service_context{service_context_} {
    controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other);
    operation_complete_event = service_context.CreateEvent("hid:PalmaOperationCompleteEvent");
}

Controller_Palma::~Controller_Palma() {
    service_context.CloseEvent(operation_complete_event);
};

void Controller_Palma::OnInit() {}

void Controller_Palma::OnRelease() {}

void Controller_Palma::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
    if (!IsControllerActivated()) {
        return;
    }
}

Result Controller_Palma::GetPalmaConnectionHandle(Core::HID::NpadIdType npad_id,
                                                  PalmaConnectionHandle& handle) {
    active_handle.npad_id = npad_id;
    handle = active_handle;
    return ResultSuccess;
}

Result Controller_Palma::InitializePalma(const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    Activate();
    return ResultSuccess;
}

Kernel::KReadableEvent& Controller_Palma::AcquirePalmaOperationCompleteEvent(
    const PalmaConnectionHandle& handle) const {
    if (handle.npad_id != active_handle.npad_id) {
        LOG_ERROR(Service_HID, "Invalid npad id {}", handle.npad_id);
    }
    return operation_complete_event->GetReadableEvent();
}

Result Controller_Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle,
                                               PalmaOperationType& operation_type,
                                               PalmaOperationData& data) const {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation_type = operation.operation;
    data = operation.data;
    return ResultSuccess;
}

Result Controller_Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle,
                                           u64 palma_activity) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::PlayActivity;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

Result Controller_Palma::SetPalmaFrModeType(const PalmaConnectionHandle& handle,
                                            PalmaFrModeType fr_mode_) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    fr_mode = fr_mode_;
    return ResultSuccess;
}

Result Controller_Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::ReadStep;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

Result Controller_Palma::EnablePalmaStep(const PalmaConnectionHandle& handle, bool is_enabled) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    return ResultSuccess;
}

Result Controller_Palma::ResetPalmaStep(const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    return ResultSuccess;
}

void Controller_Palma::ReadPalmaApplicationSection() {}

void Controller_Palma::WritePalmaApplicationSection() {}

Result Controller_Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::ReadUniqueCode;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

Result Controller_Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::SetUniqueCodeInvalid;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

void Controller_Palma::WritePalmaActivityEntry() {}

Result Controller_Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle,
                                                      u64 unknown) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::WriteRgbLedPatternEntry;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

Result Controller_Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave,
                                             Common::ProcessAddress t_mem, u64 size) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::WriteWaveEntry;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

Result Controller_Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle,
                                                               s32 database_id_version_) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    database_id_version = database_id_version_;
    operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion;
    operation.result = PalmaResultSuccess;
    operation.data[0] = {};
    operation_complete_event->Signal();
    return ResultSuccess;
}

Result Controller_Palma::GetPalmaDataBaseIdentificationVersion(
    const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion;
    operation.result = PalmaResultSuccess;
    operation.data = {};
    operation.data[0] = static_cast<u8>(database_id_version);
    operation_complete_event->Signal();
    return ResultSuccess;
}

void Controller_Palma::SuspendPalmaFeature() {}

Result Controller_Palma::GetPalmaOperationResult(const PalmaConnectionHandle& handle) const {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    return operation.result;
}
void Controller_Palma::ReadPalmaPlayLog() {}

void Controller_Palma::ResetPalmaPlayLog() {}

void Controller_Palma::SetIsPalmaAllConnectable(bool is_all_connectable) {
    // If true controllers are able to be paired
    is_connectable = is_all_connectable;
}

void Controller_Palma::SetIsPalmaPairedConnectable() {}

Result Controller_Palma::PairPalma(const PalmaConnectionHandle& handle) {
    if (handle.npad_id != active_handle.npad_id) {
        return InvalidPalmaHandle;
    }
    // TODO: Do something
    return ResultSuccess;
}

void Controller_Palma::SetPalmaBoostMode(bool boost_mode) {}

void Controller_Palma::CancelWritePalmaWaveEntry() {}

void Controller_Palma::EnablePalmaBoostMode() {}

void Controller_Palma::GetPalmaBluetoothAddress() {}

void Controller_Palma::SetDisallowedPalmaConnection() {}

} // namespace Service::HID