mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-15 11:29:58 +01:00
* apt: Implement additional library applet state management. * kernel: Clear process handle table on exit. * apt: Implement system applet commands. * apt: Pop MediaType from command buffers with correct size. * apt: Improve accuracy of parameters and HLE applet lifecycle. * apt: General cleanup. * file_sys: Make system save data open error code more correct. Not sure if this is the exact right error code, but it's at least more correct than before as Game Notes will now create its system save data instead of throwing a fatal error. * apt: Fix launching New 3DS Internet Browser. * frd: Correct fix to GetMyScreenName response.
98 lines
3.4 KiB
C++
98 lines
3.4 KiB
C++
// Copyright 2015 Citra Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include "core/hle/result.h"
|
|
#include "core/hle/service/apt/applet_manager.h"
|
|
|
|
namespace HLE::Applets {
|
|
|
|
class Applet {
|
|
public:
|
|
virtual ~Applet() = default;
|
|
|
|
/**
|
|
* 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.
|
|
* @param parent Id of the applet's parent.
|
|
* @param preload Whether the applet is being preloaded.
|
|
* @returns ResultCode Whether the operation was successful or not.
|
|
*/
|
|
static ResultCode Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
|
|
const std::shared_ptr<Service::APT::AppletManager>& manager);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter);
|
|
|
|
/**
|
|
* Whether the applet is currently executing instead of the host application or not.
|
|
*/
|
|
[[nodiscard]] bool IsRunning() const;
|
|
|
|
/**
|
|
* Handles an update tick for the Applet, lets it update the screen, send commands, etc.
|
|
*/
|
|
virtual void Update() = 0;
|
|
|
|
protected:
|
|
Applet(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
|
|
std::weak_ptr<Service::APT::AppletManager> manager)
|
|
: id(id), parent(parent), preload(preload), manager(std::move(manager)) {}
|
|
|
|
/**
|
|
* Handles a parameter from the application.
|
|
* @param parameter Parameter data to handle.
|
|
* @returns ResultCode Whether the operation was successful or not.
|
|
*/
|
|
virtual ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& 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(const Service::APT::MessageParameter& parameter) = 0;
|
|
|
|
/**
|
|
* Sends the LibAppletClosing signal to the application,
|
|
* along with the relevant data buffers.
|
|
*/
|
|
virtual ResultCode Finalize() = 0;
|
|
|
|
Service::APT::AppletId id; ///< Id of this Applet
|
|
Service::APT::AppletId parent; ///< Id of this Applet's parent
|
|
bool preload; ///< Whether the Applet is being preloaded.
|
|
std::shared_ptr<std::vector<u8>> heap_memory; ///< Heap memory for this Applet
|
|
|
|
/// Whether this applet is currently running instead of the host application or not.
|
|
bool is_running = false;
|
|
|
|
void SendParameter(const Service::APT::MessageParameter& parameter);
|
|
void CloseApplet(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
|
|
|
|
private:
|
|
std::weak_ptr<Service::APT::AppletManager> manager;
|
|
};
|
|
|
|
/// Initializes the HLE applets
|
|
void Init();
|
|
|
|
/// Shuts down the HLE applets
|
|
void Shutdown();
|
|
} // namespace HLE::Applets
|