diff options
| -rw-r--r-- | src/core/hle/service/nfp/nfp.cpp | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 761d0d3c6..e8d3a6b53 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -120,12 +120,13 @@ private: | |||
| 120 | state = State::Initialized; | 120 | state = State::Initialized; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | void GetState(Kernel::HLERequestContext& ctx) { | 123 | void Finalize(Kernel::HLERequestContext& ctx) { |
| 124 | LOG_DEBUG(Service_NFC, "called"); | 124 | LOG_DEBUG(Service_NFP, "called"); |
| 125 | 125 | ||
| 126 | IPC::ResponseBuilder rb{ctx, 3, 0}; | 126 | device_state = DeviceState::Finalized; |
| 127 | |||
| 128 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 127 | rb.Push(ResultSuccess); | 129 | rb.Push(ResultSuccess); |
| 128 | rb.PushRaw<u32>(static_cast<u32>(state)); | ||
| 129 | } | 130 | } |
| 130 | 131 | ||
| 131 | void ListDevices(Kernel::HLERequestContext& ctx) { | 132 | void ListDevices(Kernel::HLERequestContext& ctx) { |
| @@ -140,35 +141,14 @@ private: | |||
| 140 | rb.Push<u32>(1); | 141 | rb.Push<u32>(1); |
| 141 | } | 142 | } |
| 142 | 143 | ||
| 143 | void GetNpadId(Kernel::HLERequestContext& ctx) { | 144 | void StartDetection(Kernel::HLERequestContext& ctx) { |
| 144 | IPC::RequestParser rp{ctx}; | 145 | LOG_DEBUG(Service_NFP, "called"); |
| 145 | const u64 dev_handle = rp.Pop<u64>(); | ||
| 146 | LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle); | ||
| 147 | |||
| 148 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 149 | rb.Push(ResultSuccess); | ||
| 150 | rb.Push<u32>(npad_id); | ||
| 151 | } | ||
| 152 | |||
| 153 | void AttachActivateEvent(Kernel::HLERequestContext& ctx) { | ||
| 154 | IPC::RequestParser rp{ctx}; | ||
| 155 | const u64 dev_handle = rp.Pop<u64>(); | ||
| 156 | LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle); | ||
| 157 | |||
| 158 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 159 | rb.Push(ResultSuccess); | ||
| 160 | rb.PushCopyObjects(nfp_interface.GetNFCEvent()); | ||
| 161 | has_attached_handle = true; | ||
| 162 | } | ||
| 163 | |||
| 164 | void AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { | ||
| 165 | IPC::RequestParser rp{ctx}; | ||
| 166 | const u64 dev_handle = rp.Pop<u64>(); | ||
| 167 | LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle); | ||
| 168 | 146 | ||
| 169 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 147 | if (device_state == DeviceState::Initialized || device_state == DeviceState::TagRemoved) { |
| 148 | device_state = DeviceState::SearchingForTag; | ||
| 149 | } | ||
| 150 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 170 | rb.Push(ResultSuccess); | 151 | rb.Push(ResultSuccess); |
| 171 | rb.PushCopyObjects(deactivate_event->GetReadableEvent()); | ||
| 172 | } | 152 | } |
| 173 | 153 | ||
| 174 | void StopDetection(Kernel::HLERequestContext& ctx) { | 154 | void StopDetection(Kernel::HLERequestContext& ctx) { |
| @@ -191,22 +171,37 @@ private: | |||
| 191 | rb.Push(ResultSuccess); | 171 | rb.Push(ResultSuccess); |
| 192 | } | 172 | } |
| 193 | 173 | ||
| 194 | void GetDeviceState(Kernel::HLERequestContext& ctx) { | 174 | void Mount(Kernel::HLERequestContext& ctx) { |
| 195 | LOG_DEBUG(Service_NFP, "called"); | 175 | LOG_DEBUG(Service_NFP, "called"); |
| 196 | 176 | ||
| 197 | IPC::ResponseBuilder rb{ctx, 3}; | 177 | device_state = DeviceState::TagNearby; |
| 178 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 198 | rb.Push(ResultSuccess); | 179 | rb.Push(ResultSuccess); |
| 199 | rb.Push<u32>(static_cast<u32>(device_state)); | ||
| 200 | } | 180 | } |
| 201 | 181 | ||
| 202 | void StartDetection(Kernel::HLERequestContext& ctx) { | 182 | void Unmount(Kernel::HLERequestContext& ctx) { |
| 203 | LOG_DEBUG(Service_NFP, "called"); | 183 | LOG_DEBUG(Service_NFP, "called"); |
| 204 | 184 | ||
| 205 | if (device_state == DeviceState::Initialized || device_state == DeviceState::TagRemoved) { | 185 | device_state = DeviceState::TagFound; |
| 206 | device_state = DeviceState::SearchingForTag; | 186 | |
| 207 | } | 187 | IPC::ResponseBuilder rb{ctx, 2}; |
| 188 | rb.Push(ResultSuccess); | ||
| 189 | } | ||
| 190 | |||
| 191 | void OpenApplicationArea(Kernel::HLERequestContext& ctx) { | ||
| 192 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | ||
| 208 | IPC::ResponseBuilder rb{ctx, 2}; | 193 | IPC::ResponseBuilder rb{ctx, 2}; |
| 194 | rb.Push(ErrCodes::ERR_NO_APPLICATION_AREA); | ||
| 195 | } | ||
| 196 | |||
| 197 | void GetApplicationArea(Kernel::HLERequestContext& ctx) { | ||
| 198 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | ||
| 199 | |||
| 200 | // TODO(ogniK): Pull application area from amiibo | ||
| 201 | |||
| 202 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 209 | rb.Push(ResultSuccess); | 203 | rb.Push(ResultSuccess); |
| 204 | rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub | ||
| 210 | } | 205 | } |
| 211 | 206 | ||
| 212 | void GetTagInfo(Kernel::HLERequestContext& ctx) { | 207 | void GetTagInfo(Kernel::HLERequestContext& ctx) { |
| @@ -226,75 +221,82 @@ private: | |||
| 226 | rb.Push(ResultSuccess); | 221 | rb.Push(ResultSuccess); |
| 227 | } | 222 | } |
| 228 | 223 | ||
| 229 | void Mount(Kernel::HLERequestContext& ctx) { | 224 | void GetRegisterInfo(Kernel::HLERequestContext& ctx) { |
| 230 | LOG_DEBUG(Service_NFP, "called"); | 225 | LOG_WARNING(Service_NFP, "(STUBBED) called"); |
| 231 | |||
| 232 | device_state = DeviceState::TagNearby; | ||
| 233 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 234 | rb.Push(ResultSuccess); | ||
| 235 | } | ||
| 236 | 226 | ||
| 237 | void GetModelInfo(Kernel::HLERequestContext& ctx) { | 227 | // TODO(ogniK): Pull Mii and owner data from amiibo |
| 238 | LOG_DEBUG(Service_NFP, "called"); | ||
| 239 | 228 | ||
| 240 | IPC::ResponseBuilder rb{ctx, 2}; | 229 | IPC::ResponseBuilder rb{ctx, 2}; |
| 241 | const auto& amiibo = nfp_interface.GetAmiiboBuffer(); | ||
| 242 | ctx.WriteBuffer(amiibo.model_info); | ||
| 243 | rb.Push(ResultSuccess); | 230 | rb.Push(ResultSuccess); |
| 244 | } | 231 | } |
| 245 | 232 | ||
| 246 | void Unmount(Kernel::HLERequestContext& ctx) { | 233 | void GetCommonInfo(Kernel::HLERequestContext& ctx) { |
| 247 | LOG_DEBUG(Service_NFP, "called"); | 234 | LOG_WARNING(Service_NFP, "(STUBBED) called"); |
| 248 | 235 | ||
| 249 | device_state = DeviceState::TagFound; | 236 | // TODO(ogniK): Pull common information from amiibo |
| 237 | |||
| 238 | CommonInfo common_info{}; | ||
| 239 | common_info.application_area_size = 0; | ||
| 240 | ctx.WriteBuffer(common_info); | ||
| 250 | 241 | ||
| 251 | IPC::ResponseBuilder rb{ctx, 2}; | 242 | IPC::ResponseBuilder rb{ctx, 2}; |
| 252 | rb.Push(ResultSuccess); | 243 | rb.Push(ResultSuccess); |
| 253 | } | 244 | } |
| 254 | 245 | ||
| 255 | void Finalize(Kernel::HLERequestContext& ctx) { | 246 | void GetModelInfo(Kernel::HLERequestContext& ctx) { |
| 256 | LOG_DEBUG(Service_NFP, "called"); | 247 | LOG_DEBUG(Service_NFP, "called"); |
| 257 | 248 | ||
| 258 | device_state = DeviceState::Finalized; | ||
| 259 | |||
| 260 | IPC::ResponseBuilder rb{ctx, 2}; | 249 | IPC::ResponseBuilder rb{ctx, 2}; |
| 250 | const auto& amiibo = nfp_interface.GetAmiiboBuffer(); | ||
| 251 | ctx.WriteBuffer(amiibo.model_info); | ||
| 261 | rb.Push(ResultSuccess); | 252 | rb.Push(ResultSuccess); |
| 262 | } | 253 | } |
| 263 | 254 | ||
| 264 | void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { | 255 | void AttachActivateEvent(Kernel::HLERequestContext& ctx) { |
| 265 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | 256 | IPC::RequestParser rp{ctx}; |
| 257 | const u64 dev_handle = rp.Pop<u64>(); | ||
| 258 | LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle); | ||
| 266 | 259 | ||
| 267 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 260 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 268 | rb.Push(ResultSuccess); | 261 | rb.Push(ResultSuccess); |
| 269 | rb.PushCopyObjects(availability_change_event->GetReadableEvent()); | 262 | rb.PushCopyObjects(nfp_interface.GetNFCEvent()); |
| 263 | has_attached_handle = true; | ||
| 270 | } | 264 | } |
| 271 | 265 | ||
| 272 | void GetRegisterInfo(Kernel::HLERequestContext& ctx) { | 266 | void AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { |
| 273 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | 267 | IPC::RequestParser rp{ctx}; |
| 274 | 268 | const u64 dev_handle = rp.Pop<u64>(); | |
| 275 | // TODO(ogniK): Pull Mii and owner data from amiibo | 269 | LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle); |
| 276 | 270 | ||
| 277 | IPC::ResponseBuilder rb{ctx, 2}; | 271 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 278 | rb.Push(ResultSuccess); | 272 | rb.Push(ResultSuccess); |
| 273 | rb.PushCopyObjects(deactivate_event.GetReadableEvent()); | ||
| 279 | } | 274 | } |
| 280 | 275 | ||
| 281 | void GetCommonInfo(Kernel::HLERequestContext& ctx) { | 276 | void GetState(Kernel::HLERequestContext& ctx) { |
| 282 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | 277 | LOG_DEBUG(Service_NFC, "called"); |
| 283 | 278 | ||
| 284 | // TODO(ogniK): Pull common information from amiibo | 279 | IPC::ResponseBuilder rb{ctx, 3, 0}; |
| 280 | rb.Push(ResultSuccess); | ||
| 281 | rb.PushRaw<u32>(static_cast<u32>(state)); | ||
| 282 | } | ||
| 285 | 283 | ||
| 286 | CommonInfo common_info{}; | 284 | void GetDeviceState(Kernel::HLERequestContext& ctx) { |
| 287 | common_info.application_area_size = 0; | 285 | LOG_DEBUG(Service_NFP, "called"); |
| 288 | ctx.WriteBuffer(common_info); | ||
| 289 | 286 | ||
| 290 | IPC::ResponseBuilder rb{ctx, 2}; | 287 | IPC::ResponseBuilder rb{ctx, 3}; |
| 291 | rb.Push(ResultSuccess); | 288 | rb.Push(ResultSuccess); |
| 289 | rb.Push<u32>(static_cast<u32>(device_state)); | ||
| 292 | } | 290 | } |
| 293 | 291 | ||
| 294 | void OpenApplicationArea(Kernel::HLERequestContext& ctx) { | 292 | void GetNpadId(Kernel::HLERequestContext& ctx) { |
| 295 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | 293 | IPC::RequestParser rp{ctx}; |
| 296 | IPC::ResponseBuilder rb{ctx, 2}; | 294 | const u64 dev_handle = rp.Pop<u64>(); |
| 297 | rb.Push(ErrCodes::ERR_NO_APPLICATION_AREA); | 295 | LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle); |
| 296 | |||
| 297 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 298 | rb.Push(ResultSuccess); | ||
| 299 | rb.Push<u32>(npad_id); | ||
| 298 | } | 300 | } |
| 299 | 301 | ||
| 300 | void GetApplicationAreaSize(Kernel::HLERequestContext& ctx) { | 302 | void GetApplicationAreaSize(Kernel::HLERequestContext& ctx) { |
| @@ -305,14 +307,12 @@ private: | |||
| 305 | rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub | 307 | rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub |
| 306 | } | 308 | } |
| 307 | 309 | ||
| 308 | void GetApplicationArea(Kernel::HLERequestContext& ctx) { | 310 | void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { |
| 309 | LOG_WARNING(Service_NFP, "(STUBBED) called"); | 311 | LOG_WARNING(Service_NFP, "(STUBBED) called"); |
| 310 | 312 | ||
| 311 | // TODO(ogniK): Pull application area from amiibo | 313 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 312 | |||
| 313 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 314 | rb.Push(ResultSuccess); | 314 | rb.Push(ResultSuccess); |
| 315 | rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub | 315 | rb.PushCopyObjects(availability_change_event.GetReadableEvent()); |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | Module::Interface& nfp_interface; | 318 | Module::Interface& nfp_interface; |