apt: Implement additional applet state management. (#6303)

* 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.
This commit is contained in:
Steveice10 2023-02-28 04:09:54 -08:00 committed by GitHub
parent 8b116aaa04
commit 3c15398f9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 966 additions and 705 deletions

View file

@ -21,7 +21,7 @@
namespace HLE::Applets {
ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) {
ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) {
switch (parameter.signal) {
case Service::APT::SignalType::Request: {
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -39,14 +39,13 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
"SoftwareKeyboard Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
result.signal = Service::APT::SignalType::Response;
result.buffer.clear();
result.destination_id = Service::APT::AppletId::Application;
result.sender_id = id;
result.object = framebuffer_memory;
SendParameter({
.sender_id = id,
.destination_id = parent,
.signal = Service::APT::SignalType::Response,
.object = framebuffer_memory,
});
SendParameter(result);
return RESULT_SUCCESS;
}
@ -92,7 +91,7 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
}
}
ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) {
ASSERT_MSG(parameter.buffer.size() == sizeof(config),
"The size of the parameter (SoftwareKeyboardConfig) is wrong");
@ -151,14 +150,16 @@ void SoftwareKeyboard::Update() {
config.text_offset = 0;
if (config.filter_flags & HLE::Applets::SoftwareKeyboardFilter::Callback) {
std::vector<u8> buffer(sizeof(SoftwareKeyboardConfig));
std::memcpy(buffer.data(), &config, buffer.size());
// Send the message to invoke callback
Service::APT::MessageParameter message;
message.buffer.resize(sizeof(SoftwareKeyboardConfig));
std::memcpy(message.buffer.data(), &config, message.buffer.size());
message.signal = Service::APT::SignalType::Message;
message.destination_id = Service::APT::AppletId::Application;
message.sender_id = id;
SendParameter(message);
SendParameter({
.sender_id = id,
.destination_id = parent,
.signal = Service::APT::SignalType::Message,
.buffer = buffer,
});
} else {
Finalize();
}
@ -168,18 +169,12 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
// TODO(Subv): Draw the HLE keyboard, for now just do nothing
}
void SoftwareKeyboard::Finalize() {
// Let the application know that we're closing
Service::APT::MessageParameter message;
message.buffer.resize(sizeof(SoftwareKeyboardConfig));
std::memcpy(message.buffer.data(), &config, message.buffer.size());
message.signal = Service::APT::SignalType::WakeupByExit;
message.destination_id = Service::APT::AppletId::Application;
message.sender_id = id;
SendParameter(message);
is_running = false;
ResultCode SoftwareKeyboard::Finalize() {
std::vector<u8> buffer(sizeof(SoftwareKeyboardConfig));
std::memcpy(buffer.data(), &config, buffer.size());
CloseApplet(nullptr, buffer);
text_memory = nullptr;
return RESULT_SUCCESS;
}
Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(