// Copyright 2016 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #include #include #include "common/assert.h" #include "common/logging/log.h" #include "common/string_util.h" #include "core/core.h" #include "core/hle/applets/mii_selector.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/result.h" //////////////////////////////////////////////////////////////////////////////////////////////////// namespace HLE { namespace Applets { // This data was obtained by writing the returned buffer in AppletManager::GlanceParameter of the // LLEd Mii picker of version system version 11.8.0 to a file static const std::array mii = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x10, 0x30, 0xd2, 0x85, 0xb6, 0xb3, 0x00, 0xc8, 0x85, 0x0a, 0x98, 0x39, 0x1e, 0xe4, 0x40, 0xf4, 0x07, 0xb7, 0x37, 0x10, 0x00, 0x00, 0xa6, 0x00, 0x43, 0x00, 0x69, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x21, 0x01, 0x02, 0x68, 0x44, 0x18, 0x26, 0x34, 0x46, 0x14, 0x81, 0x12, 0x17, 0x68, 0x0d, 0x00, 0x00, 0x29, 0x00, 0x52, 0x48, 0x50, 0x66, 0x00, 0x6c, 0x00, 0x54, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) { if (parameter.signal != Service::APT::SignalType::Request) { LOG_ERROR(Service_APT, "unsupported signal {}", static_cast(parameter.signal)); UNIMPLEMENTED(); // TODO(Subv): Find the right error code return ResultCode(-1); } // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared // memory. // Create the SharedMemory that will hold the framebuffer data Service::APT::CaptureBufferInfo capture_info; ASSERT(sizeof(capture_info) == parameter.buffer.size()); memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info)); using Kernel::MemoryPermission; // Allocate a heap block of the required size for this applet. heap_memory = std::make_shared>(capture_info.size); // Create a SharedMemory that directly points to this heap block. framebuffer_memory = Core::System::GetInstance().Kernel().CreateSharedMemoryForApplet( heap_memory, 0, capture_info.size, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite, "MiiSelector 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(result); return RESULT_SUCCESS; } ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) { is_running = true; // TODO(Subv): Reverse the parameter format for the Mii Selector memcpy(&config, parameter.buffer.data(), parameter.buffer.size()); // TODO(Subv): Find more about this structure MiiResult result; std::memcpy(&result, mii.data(), mii.size()); // Let the application know that we're closing Service::APT::MessageParameter message; message.buffer.resize(sizeof(MiiResult)); std::memcpy(message.buffer.data(), &result, 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; return RESULT_SUCCESS; } void MiiSelector::Update() {} } // namespace Applets } // namespace HLE