summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/applets/applets.h
blob: a6a9bf77b29e022b9ec0a262e82127a62b687948 (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
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <functional>
#include <memory>
#include <queue>
#include "common/swap.h"

union ResultCode;

namespace Frontend {
class SoftwareKeyboardApplet;
}

namespace Service::AM {

class IStorage;

namespace Applets {

using AppletStorageProxyFunction = std::function<void(IStorage)>;
using AppletStateProxyFunction = std::function<void()>;

class Applet {
public:
    Applet();
    virtual ~Applet();

    virtual void Initialize(std::queue<std::shared_ptr<IStorage>> storage);

    virtual bool TransactionComplete() const = 0;
    virtual ResultCode GetStatus() const = 0;
    virtual void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) = 0;
    virtual void Execute(AppletStorageProxyFunction out_data,
                         AppletStorageProxyFunction out_interactive_data,
                         AppletStateProxyFunction state) = 0;

    bool IsInitialized() const {
        return initialized;
    }

protected:
    struct CommonArguments {
        u32_le arguments_version;
        u32_le size;
        u32_le library_version;
        u32_le theme_color;
        u8 play_startup_sound;
        u64_le system_tick;
    };
    static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size.");

    CommonArguments common_args;
    std::queue<std::shared_ptr<IStorage>> storage_stack;
    bool initialized = false;
};

} // namespace Applets
} // namespace Service::AM