summaryrefslogtreecommitdiffstats
path: root/src/core/hle/applets/applet.h
blob: f50f7d604764d418c9050d3932d35d575c8a82bb (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
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include "common/common_types.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/apt/apt.h"

namespace HLE {
namespace Applets {

class Applet : public std::enable_shared_from_this<Applet> {
public:
    virtual ~Applet() {};
    Applet(Service::APT::AppletId id) : id(id) {};

    /**
     * Creates an instance of the Applet subclass identified by the parameter.
     * and stores it in a global map.
     * @param id Id of the applet to create.
     * @returns ResultCode Whether the operation was successful or not.
     */
    static ResultCode Create(Service::APT::AppletId id);

    /**
     * Retrieves the Applet instance identified by the specified id.
     * @param id Id of the Applet to retrieve.
     * @returns Requested Applet or nullptr if not found.
     */
    static std::shared_ptr<Applet> Get(Service::APT::AppletId id);

    /**
     * Handles a parameter from the application.
     * @param parameter Parameter data to handle.
     * @returns ResultCode Whether the operation was successful or not.
     */
    virtual ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) = 0;

    /**
     * Handles the Applet start event, triggered from the application.
     * @param parameter Parameter data to handle.
     * @returns ResultCode Whether the operation was successful or not.
     */
    virtual ResultCode Start(Service::APT::AppletStartupParameter const& parameter) = 0;

    /**
     * Whether the applet is currently executing instead of the host application or not.
     */
    virtual bool IsRunning() = 0;

    /**
     * Handles an update tick for the Applet, lets it update the screen, send commands, etc.
     */
    virtual void Update() = 0;

    Service::APT::AppletId id; ///< Id of this Applet
};

/// Initializes the HLE applets
void Init();

/// Shuts down the HLE applets
void Shutdown();

extern std::shared_ptr<Applet> g_current_applet; ///< Applet that is currently executing
}
} // namespace