2015-05-26 06:30:20 +02:00
|
|
|
// 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 {
|
|
|
|
|
2015-05-27 22:21:06 +02:00
|
|
|
class Applet {
|
2015-05-26 06:30:20 +02:00
|
|
|
public:
|
2015-05-27 22:21:06 +02:00
|
|
|
virtual ~Applet() { }
|
|
|
|
Applet(Service::APT::AppletId id) : id(id) { }
|
2015-05-26 06:30:20 +02:00
|
|
|
|
|
|
|
/**
|
2015-05-26 18:00:26 +02:00
|
|
|
* Creates an instance of the Applet subclass identified by the parameter.
|
2015-05-26 06:30:20 +02:00
|
|
|
* and stores it in a global map.
|
2015-05-26 18:00:26 +02:00
|
|
|
* @param id Id of the applet to create.
|
|
|
|
* @returns ResultCode Whether the operation was successful or not.
|
2015-05-26 06:30:20 +02:00
|
|
|
*/
|
|
|
|
static ResultCode Create(Service::APT::AppletId id);
|
|
|
|
|
|
|
|
/**
|
2015-05-26 18:00:26 +02:00
|
|
|
* 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.
|
2015-05-26 06:30:20 +02:00
|
|
|
*/
|
|
|
|
static std::shared_ptr<Applet> Get(Service::APT::AppletId id);
|
|
|
|
|
|
|
|
/**
|
2015-05-26 18:00:26 +02:00
|
|
|
* Handles a parameter from the application.
|
|
|
|
* @param parameter Parameter data to handle.
|
|
|
|
* @returns ResultCode Whether the operation was successful or not.
|
2015-05-26 06:30:20 +02:00
|
|
|
*/
|
2015-05-27 22:21:06 +02:00
|
|
|
virtual ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) = 0;
|
2015-05-26 06:30:20 +02:00
|
|
|
|
|
|
|
/**
|
2015-05-26 18:00:26 +02:00
|
|
|
* Handles the Applet start event, triggered from the application.
|
|
|
|
* @param parameter Parameter data to handle.
|
|
|
|
* @returns ResultCode Whether the operation was successful or not.
|
2015-05-26 06:30:20 +02:00
|
|
|
*/
|
2015-05-27 22:21:06 +02:00
|
|
|
ResultCode Start(const Service::APT::AppletStartupParameter& parameter);
|
2015-05-26 06:30:20 +02:00
|
|
|
|
2015-05-26 18:00:26 +02:00
|
|
|
/**
|
|
|
|
* Whether the applet is currently executing instead of the host application or not.
|
|
|
|
*/
|
2015-05-27 22:21:06 +02:00
|
|
|
virtual bool IsRunning() const = 0;
|
2015-05-26 18:00:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles an update tick for the Applet, lets it update the screen, send commands, etc.
|
|
|
|
*/
|
|
|
|
virtual void Update() = 0;
|
|
|
|
|
2015-05-27 22:21:06 +02:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* 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 StartImpl(const Service::APT::AppletStartupParameter& parameter) = 0;
|
|
|
|
|
2015-05-26 06:30:20 +02:00
|
|
|
Service::APT::AppletId id; ///< Id of this Applet
|
|
|
|
};
|
|
|
|
|
2015-05-26 18:00:26 +02:00
|
|
|
/// Initializes the HLE applets
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
/// Shuts down the HLE applets
|
|
|
|
void Shutdown();
|
|
|
|
|
2015-05-26 06:30:20 +02:00
|
|
|
}
|
|
|
|
} // namespace
|