mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Merge pull request #2281 from lioncash/applet
applet: minor interface changes
This commit is contained in:
commit
bc48e2bda6
|
@ -101,6 +101,10 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Applet::IsRunning() const {
|
||||||
|
return is_running;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsLibraryAppletRunning() {
|
bool IsLibraryAppletRunning() {
|
||||||
// Check the applets map for instances of any applet
|
// Check the applets map for instances of any applet
|
||||||
for (auto itr = applets.begin(); itr != applets.end(); ++itr)
|
for (auto itr = applets.begin(); itr != applets.end(); ++itr)
|
||||||
|
|
|
@ -13,8 +13,7 @@ namespace Applets {
|
||||||
|
|
||||||
class Applet {
|
class Applet {
|
||||||
public:
|
public:
|
||||||
virtual ~Applet() {}
|
virtual ~Applet() = default;
|
||||||
Applet(Service::APT::AppletId id) : id(id) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of the Applet subclass identified by the parameter.
|
* Creates an instance of the Applet subclass identified by the parameter.
|
||||||
|
@ -48,7 +47,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Whether the applet is currently executing instead of the host application or not.
|
* Whether the applet is currently executing instead of the host application or not.
|
||||||
*/
|
*/
|
||||||
virtual bool IsRunning() const = 0;
|
bool IsRunning() 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.
|
||||||
|
@ -56,6 +55,8 @@ public:
|
||||||
virtual void Update() = 0;
|
virtual void Update() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
explicit Applet(Service::APT::AppletId id) : id(id) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the Applet start event, triggered from the application.
|
* Handles the Applet start event, triggered from the application.
|
||||||
* @param parameter Parameter data to handle.
|
* @param parameter Parameter data to handle.
|
||||||
|
@ -65,6 +66,9 @@ protected:
|
||||||
|
|
||||||
Service::APT::AppletId id; ///< Id of this Applet
|
Service::APT::AppletId id; ///< Id of this Applet
|
||||||
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.
|
||||||
|
bool is_running = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns whether a library applet is currently running
|
/// Returns whether a library applet is currently running
|
||||||
|
|
|
@ -47,7 +47,7 @@ ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& param
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
|
ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
|
||||||
started = true;
|
is_running = true;
|
||||||
|
|
||||||
// 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
|
||||||
// application.
|
// application.
|
||||||
|
@ -62,7 +62,7 @@ ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parame
|
||||||
message.sender_id = static_cast<u32>(id);
|
message.sender_id = static_cast<u32>(id);
|
||||||
Service::APT::SendParameter(message);
|
Service::APT::SendParameter(message);
|
||||||
|
|
||||||
started = false;
|
is_running = false;
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,18 +17,12 @@ public:
|
||||||
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
|
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
|
||||||
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
bool IsRunning() const override {
|
|
||||||
return started;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private:
|
||||||
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
||||||
/// It holds the framebuffer info retrieved by the application with
|
/// It holds the framebuffer info retrieved by the application with
|
||||||
/// GSPGPU::ImportDisplayCaptureInfo
|
/// GSPGPU::ImportDisplayCaptureInfo
|
||||||
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
|
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
|
||||||
|
|
||||||
private:
|
|
||||||
/// Whether this applet is currently running instead of the host application or not.
|
|
||||||
bool started = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Applets
|
} // namespace Applets
|
||||||
|
|
|
@ -55,7 +55,7 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
|
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
|
||||||
started = true;
|
is_running = true;
|
||||||
|
|
||||||
// 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
|
||||||
// application.
|
// application.
|
||||||
|
@ -78,7 +78,7 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
|
||||||
message.sender_id = static_cast<u32>(id);
|
message.sender_id = static_cast<u32>(id);
|
||||||
Service::APT::SendParameter(message);
|
Service::APT::SendParameter(message);
|
||||||
|
|
||||||
started = false;
|
is_running = false;
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,23 +65,18 @@ ASSERT_REG_POSITION(unk_6C, 0x6C);
|
||||||
|
|
||||||
class MiiSelector final : public Applet {
|
class MiiSelector final : public Applet {
|
||||||
public:
|
public:
|
||||||
MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) {}
|
MiiSelector(Service::APT::AppletId id) : Applet(id) {}
|
||||||
|
|
||||||
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
|
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
|
||||||
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
bool IsRunning() const override {
|
|
||||||
return started;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private:
|
||||||
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
||||||
/// It holds the framebuffer info retrieved by the application with
|
/// It holds the framebuffer info retrieved by the application with
|
||||||
/// GSPGPU::ImportDisplayCaptureInfo
|
/// GSPGPU::ImportDisplayCaptureInfo
|
||||||
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
|
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
|
||||||
|
|
||||||
/// Whether this applet is currently running instead of the host application or not.
|
|
||||||
bool started;
|
|
||||||
|
|
||||||
MiiConfig config;
|
MiiConfig config;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons
|
||||||
|
|
||||||
DrawScreenKeyboard();
|
DrawScreenKeyboard();
|
||||||
|
|
||||||
started = true;
|
is_running = true;
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ void SoftwareKeyboard::Finalize() {
|
||||||
message.sender_id = static_cast<u32>(id);
|
message.sender_id = static_cast<u32>(id);
|
||||||
Service::APT::SendParameter(message);
|
Service::APT::SendParameter(message);
|
||||||
|
|
||||||
started = false;
|
is_running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -52,14 +52,11 @@ static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config
|
||||||
|
|
||||||
class SoftwareKeyboard final : public Applet {
|
class SoftwareKeyboard final : public Applet {
|
||||||
public:
|
public:
|
||||||
SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) {}
|
SoftwareKeyboard(Service::APT::AppletId id) : Applet(id) {}
|
||||||
|
|
||||||
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
|
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
|
||||||
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
bool IsRunning() const override {
|
|
||||||
return started;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a keyboard to the current bottom screen framebuffer.
|
* Draws a keyboard to the current bottom screen framebuffer.
|
||||||
|
@ -72,6 +69,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
|
private:
|
||||||
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
|
||||||
/// It holds the framebuffer info retrieved by the application with
|
/// It holds the framebuffer info retrieved by the application with
|
||||||
/// GSPGPU::ImportDisplayCaptureInfo
|
/// GSPGPU::ImportDisplayCaptureInfo
|
||||||
|
@ -82,9 +80,6 @@ public:
|
||||||
|
|
||||||
/// Configuration of this instance of the SoftwareKeyboard, as received from the application
|
/// Configuration of this instance of the SoftwareKeyboard, as received from the application
|
||||||
SoftwareKeyboardConfig config;
|
SoftwareKeyboardConfig config;
|
||||||
|
|
||||||
/// Whether this applet is currently running instead of the host application or not.
|
|
||||||
bool started;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in a new issue