mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-30 13:24:16 +01:00
applet: Fix HLE applet pre-start lifecycle. (#6362)
This commit is contained in:
parent
44097c2a8d
commit
d9d0fc63ec
@ -80,6 +80,9 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
|
|||||||
manager->FinishPreloadingLibraryApplet(id);
|
manager->FinishPreloadingLibraryApplet(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Schedule the update event
|
||||||
|
Core::System::GetInstance().CoreTiming().ScheduleEvent(
|
||||||
|
usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +99,9 @@ static void AppletUpdateEvent(u64 applet_id, s64 cycles_late) {
|
|||||||
const auto applet = Applet::Get(id);
|
const auto applet = Applet::Get(id);
|
||||||
ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:08X}", id);
|
ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:08X}", id);
|
||||||
|
|
||||||
|
if (applet->IsActive()) {
|
||||||
applet->Update();
|
applet->Update();
|
||||||
|
}
|
||||||
|
|
||||||
// If the applet is still running after the last update, reschedule the event
|
// If the applet is still running after the last update, reschedule the event
|
||||||
if (applet->IsRunning()) {
|
if (applet->IsRunning()) {
|
||||||
@ -112,14 +117,16 @@ bool Applet::IsRunning() const {
|
|||||||
return is_running;
|
return is_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Applet::IsActive() const {
|
||||||
|
return is_active;
|
||||||
|
}
|
||||||
|
|
||||||
ResultCode Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
|
ResultCode Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
|
||||||
switch (parameter.signal) {
|
switch (parameter.signal) {
|
||||||
case Service::APT::SignalType::Wakeup: {
|
case Service::APT::SignalType::Wakeup: {
|
||||||
ResultCode result = Start(parameter);
|
ResultCode result = Start(parameter);
|
||||||
if (!result.IsError()) {
|
if (!result.IsError()) {
|
||||||
// Schedule the update event
|
is_active = true;
|
||||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(
|
|
||||||
usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -146,6 +153,7 @@ void Applet::CloseApplet(std::shared_ptr<Kernel::Object> object, const std::vect
|
|||||||
LOG_ERROR(Service_APT, "called after destructing applet manager");
|
LOG_ERROR(Service_APT, "called after destructing applet manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_active = false;
|
||||||
is_running = false;
|
is_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,15 @@ public:
|
|||||||
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter);
|
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the applet is currently executing instead of the host application or not.
|
* Whether the applet is currently running.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] bool IsRunning() const;
|
[[nodiscard]] bool IsRunning() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the applet is currently active instead of the host application or not.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] bool IsActive() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an update tick for the Applet, lets it update the screen, send commands, etc.
|
* Handles an update tick for the Applet, lets it update the screen, send commands, etc.
|
||||||
*/
|
*/
|
||||||
@ -79,8 +84,11 @@ protected:
|
|||||||
bool preload; ///< Whether the Applet is being preloaded.
|
bool preload; ///< Whether the Applet is being preloaded.
|
||||||
std::shared_ptr<std::vector<u8>> heap_memory; ///< Heap memory for this Applet
|
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.
|
/// Whether this applet is running.
|
||||||
bool is_running = false;
|
bool is_running = true;
|
||||||
|
|
||||||
|
/// Whether this applet is currently active instead of the host application or not.
|
||||||
|
bool is_active = false;
|
||||||
|
|
||||||
void SendParameter(const Service::APT::MessageParameter& parameter);
|
void SendParameter(const Service::APT::MessageParameter& parameter);
|
||||||
void CloseApplet(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
|
void CloseApplet(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
|
||||||
|
@ -44,7 +44,6 @@ ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& p
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
|
ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
|
||||||
is_running = true;
|
|
||||||
startup_param = parameter.buffer;
|
startup_param = parameter.buffer;
|
||||||
|
|
||||||
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
||||||
|
@ -65,7 +65,6 @@ ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
|
|||||||
MiiSelectorConfig frontend_config = ToFrontendConfig(config);
|
MiiSelectorConfig frontend_config = ToFrontendConfig(config);
|
||||||
frontend_applet->Setup(frontend_config);
|
frontend_applet->Setup(frontend_config);
|
||||||
|
|
||||||
is_running = true;
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& para
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
|
ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
|
||||||
is_running = true;
|
|
||||||
startup_param = parameter.buffer;
|
startup_param = parameter.buffer;
|
||||||
|
|
||||||
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
||||||
|
@ -106,7 +106,6 @@ ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& paramet
|
|||||||
|
|
||||||
frontend_applet->Execute(ToFrontendConfig(config));
|
frontend_applet->Execute(ToFrontendConfig(config));
|
||||||
|
|
||||||
is_running = true;
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user