summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nfc/mifare_interface.h
blob: 698c8a6b634e87dfa897e48bd912855a10808257 (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
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include <memory>
#include <optional>

#include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/service.h"

namespace Service::NFC {
class NfcDevice;

class MFInterface : public ServiceFramework<MFInterface> {
public:
    explicit MFInterface(Core::System& system_, const char* name);
    ~MFInterface();

    void Initialize(HLERequestContext& ctx);
    void Finalize(HLERequestContext& ctx);
    void ListDevices(HLERequestContext& ctx);
    void StartDetection(HLERequestContext& ctx);
    void StopDetection(HLERequestContext& ctx);
    void Read(HLERequestContext& ctx);
    void Write(HLERequestContext& ctx);
    void GetTagInfo(HLERequestContext& ctx);
    void GetActivateEventHandle(HLERequestContext& ctx);
    void GetDeactivateEventHandle(HLERequestContext& ctx);
    void GetState(HLERequestContext& ctx);
    void GetDeviceState(HLERequestContext& ctx);
    void GetNpadId(HLERequestContext& ctx);
    void GetAvailabilityChangeEventHandle(HLERequestContext& ctx);

private:
    enum class State : u32 {
        NonInitialized,
        Initialized,
    };

    std::optional<std::shared_ptr<NfcDevice>> GetNfcDevice(u64 handle);

    KernelHelpers::ServiceContext service_context;

    std::array<std::shared_ptr<NfcDevice>, 10> devices{};

    State state{State::NonInitialized};
    Kernel::KEvent* availability_change_event;
};

} // namespace Service::NFC