summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/applets/applet.cpp6
-rw-r--r--src/core/hle/applets/mii_selector.cpp75
-rw-r--r--src/core/hle/applets/mii_selector.h37
-rw-r--r--src/core/hle/service/apt/apt.cpp19
-rw-r--r--src/core/hle/service/apt/apt.h17
-rw-r--r--src/core/hle/service/apt/apt_u.cpp2
7 files changed, 156 insertions, 2 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index edf5fcc44..35b61dada 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -26,6 +26,7 @@ set(SRCS
26 hle/config_mem.cpp 26 hle/config_mem.cpp
27 hle/hle.cpp 27 hle/hle.cpp
28 hle/applets/applet.cpp 28 hle/applets/applet.cpp
29 hle/applets/mii_selector.cpp
29 hle/applets/swkbd.cpp 30 hle/applets/swkbd.cpp
30 hle/kernel/address_arbiter.cpp 31 hle/kernel/address_arbiter.cpp
31 hle/kernel/event.cpp 32 hle/kernel/event.cpp
@@ -155,6 +156,7 @@ set(HEADERS
155 hle/function_wrappers.h 156 hle/function_wrappers.h
156 hle/hle.h 157 hle/hle.h
157 hle/applets/applet.h 158 hle/applets/applet.h
159 hle/applets/mii_selector.h
158 hle/applets/swkbd.h 160 hle/applets/swkbd.h
159 hle/kernel/address_arbiter.h 161 hle/kernel/address_arbiter.h
160 hle/kernel/event.h 162 hle/kernel/event.h
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp
index bc2a1829e..90e134437 100644
--- a/src/core/hle/applets/applet.cpp
+++ b/src/core/hle/applets/applet.cpp
@@ -12,6 +12,7 @@
12 12
13#include "core/core_timing.h" 13#include "core/core_timing.h"
14#include "core/hle/applets/applet.h" 14#include "core/hle/applets/applet.h"
15#include "core/hle/applets/mii_selector.h"
15#include "core/hle/applets/swkbd.h" 16#include "core/hle/applets/swkbd.h"
16#include "core/hle/result.h" 17#include "core/hle/result.h"
17#include "core/hle/service/apt/apt.h" 18#include "core/hle/service/apt/apt.h"
@@ -47,7 +48,12 @@ ResultCode Applet::Create(Service::APT::AppletId id) {
47 case Service::APT::AppletId::SoftwareKeyboard2: 48 case Service::APT::AppletId::SoftwareKeyboard2:
48 applets[id] = std::make_shared<SoftwareKeyboard>(id); 49 applets[id] = std::make_shared<SoftwareKeyboard>(id);
49 break; 50 break;
51 case Service::APT::AppletId::Ed1:
52 case Service::APT::AppletId::Ed2:
53 applets[id] = std::make_shared<MiiSelector>(id);
54 break;
50 default: 55 default:
56 LOG_ERROR(Service_APT, "Could not create applet %u", id);
51 // TODO(Subv): Find the right error code 57 // TODO(Subv): Find the right error code
52 return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported, ErrorLevel::Permanent); 58 return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported, ErrorLevel::Permanent);
53 } 59 }
diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp
new file mode 100644
index 000000000..708d2f630
--- /dev/null
+++ b/src/core/hle/applets/mii_selector.cpp
@@ -0,0 +1,75 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <cstring>
6#include <string>
7
8#include "common/assert.h"
9#include "common/logging/log.h"
10#include "common/string_util.h"
11
12#include "core/hle/applets/mii_selector.h"
13#include "core/hle/kernel/kernel.h"
14#include "core/hle/kernel/shared_memory.h"
15#include "core/hle/result.h"
16
17#include "video_core/video_core.h"
18
19////////////////////////////////////////////////////////////////////////////////////////////////////
20
21namespace HLE {
22namespace Applets {
23
24MiiSelector::MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) {
25 // Create the SharedMemory that will hold the framebuffer data
26 // TODO(Subv): What size should we use here?
27 using Kernel::MemoryPermission;
28 framebuffer_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite, "MiiSelector Memory");
29}
30
31ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
32 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) {
33 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
34 UNIMPLEMENTED();
35 // TODO(Subv): Find the right error code
36 return ResultCode(-1);
37 }
38
39 Service::APT::MessageParameter result;
40 // The buffer passed in parameter contains the data returned by GSPGPU::ImportDisplayCaptureInfo
41 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
42 result.data = nullptr;
43 result.buffer_size = 0;
44 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
45 result.sender_id = static_cast<u32>(id);
46 result.object = framebuffer_memory;
47
48 Service::APT::SendParameter(result);
49 return RESULT_SUCCESS;
50}
51
52ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
53 started = true;
54
55 // TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
56 // TODO(Subv): Reverse the parameter format for the Mii Selector
57
58 // Let the application know that we're closing
59 Service::APT::MessageParameter message;
60 message.buffer_size = parameter.buffer_size;
61 message.data = parameter.data;
62 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
63 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
64 message.sender_id = static_cast<u32>(id);
65 Service::APT::SendParameter(message);
66
67 started = false;
68 return RESULT_SUCCESS;
69}
70
71void MiiSelector::Update() {
72}
73
74}
75} // namespace
diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h
new file mode 100644
index 000000000..6a3e7c8eb
--- /dev/null
+++ b/src/core/hle/applets/mii_selector.h
@@ -0,0 +1,37 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8#include "common/common_funcs.h"
9
10#include "core/hle/applets/applet.h"
11#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/shared_memory.h"
13#include "core/hle/result.h"
14#include "core/hle/service/apt/apt.h"
15
16namespace HLE {
17namespace Applets {
18
19class MiiSelector final : public Applet {
20public:
21 MiiSelector(Service::APT::AppletId id);
22
23 ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
24 ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
25 void Update() override;
26 bool IsRunning() const override { return started; }
27
28 /// TODO(Subv): Find out what this is actually used for.
29 /// It is believed that the application stores the current screen image here.
30 Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
31
32 /// Whether this applet is currently running instead of the host application or not.
33 bool started;
34};
35
36}
37} // namespace
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 69255e2ef..98c72fc32 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -12,6 +12,7 @@
12#include "core/hle/service/apt/apt_a.h" 12#include "core/hle/service/apt/apt_a.h"
13#include "core/hle/service/apt/apt_s.h" 13#include "core/hle/service/apt/apt_s.h"
14#include "core/hle/service/apt/apt_u.h" 14#include "core/hle/service/apt/apt_u.h"
15#include "core/hle/service/fs/archive.h"
15 16
16#include "core/hle/kernel/event.h" 17#include "core/hle/kernel/event.h"
17#include "core/hle/kernel/mutex.h" 18#include "core/hle/kernel/mutex.h"
@@ -378,6 +379,24 @@ void StartLibraryApplet(Service::Interface* self) {
378 cmd_buff[1] = applet->Start(parameter).raw; 379 cmd_buff[1] = applet->Start(parameter).raw;
379} 380}
380 381
382void GetAppletInfo(Service::Interface* self) {
383 u32* cmd_buff = Kernel::GetCommandBuffer();
384 auto app_id = static_cast<AppletId>(cmd_buff[1]);
385
386 if (auto applet = HLE::Applets::Applet::Get(app_id)) {
387 // TODO(Subv): Get the title id for the current applet and write it in the response[2-3]
388 cmd_buff[1] = RESULT_SUCCESS.raw;
389 cmd_buff[4] = static_cast<u32>(Service::FS::MediaType::NAND);
390 cmd_buff[5] = 1; // Registered
391 cmd_buff[6] = 1; // Loaded
392 cmd_buff[7] = 0; // Applet Attributes
393 } else {
394 cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
395 ErrorSummary::NotFound, ErrorLevel::Status).raw;
396 }
397 LOG_WARNING(Service_APT, "(stubbed) called appid=%u", app_id);
398}
399
381void Init() { 400void Init() {
382 AddService(new APT_A_Interface); 401 AddService(new APT_A_Interface);
383 AddService(new APT_S_Interface); 402 AddService(new APT_S_Interface);
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 4a72b6b5c..47a97c1a1 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -54,7 +54,7 @@ enum class AppletId : u32 {
54 Notifications = 0x116, 54 Notifications = 0x116,
55 Miiverse = 0x117, 55 Miiverse = 0x117,
56 SoftwareKeyboard1 = 0x201, 56 SoftwareKeyboard1 = 0x201,
57 Ed = 0x202, 57 Ed1 = 0x202,
58 PnoteApp = 0x204, 58 PnoteApp = 0x204,
59 SnoteApp = 0x205, 59 SnoteApp = 0x205,
60 Error = 0x206, 60 Error = 0x206,
@@ -64,6 +64,7 @@ enum class AppletId : u32 {
64 Application = 0x300, 64 Application = 0x300,
65 AnyLibraryApplet = 0x400, 65 AnyLibraryApplet = 0x400,
66 SoftwareKeyboard2 = 0x401, 66 SoftwareKeyboard2 = 0x401,
67 Ed2 = 0x402,
67}; 68};
68 69
69/// Send a parameter to the currently-running application, which will read it via ReceiveParameter 70/// Send a parameter to the currently-running application, which will read it via ReceiveParameter
@@ -133,6 +134,20 @@ void Enable(Service::Interface* self);
133void GetAppletManInfo(Service::Interface* self); 134void GetAppletManInfo(Service::Interface* self);
134 135
135/** 136/**
137 * APT::GetAppletInfo service function.
138 * Inputs:
139 * 1 : AppId
140 * Outputs:
141 * 1 : Result of function, 0 on success, otherwise error code
142 * 2-3 : Title ID
143 * 4 : Media Type
144 * 5 : Registered
145 * 6 : Loaded
146 * 7 : Attributes
147 */
148void GetAppletInfo(Service::Interface* self);
149
150/**
136 * APT::IsRegistered service function. This returns whether the specified AppID is registered with NS yet. 151 * APT::IsRegistered service function. This returns whether the specified AppID is registered with NS yet.
137 * An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home Menu uses this 152 * An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home Menu uses this
138 * command to determine when the launched process is running and to determine when to stop using GSP etc, 153 * command to determine when the launched process is running and to determine when to stop using GSP etc,
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp
index 209a0055b..b13b51549 100644
--- a/src/core/hle/service/apt/apt_u.cpp
+++ b/src/core/hle/service/apt/apt_u.cpp
@@ -14,7 +14,7 @@ const Interface::FunctionInfo FunctionTable[] = {
14 {0x00030040, Enable, "Enable"}, 14 {0x00030040, Enable, "Enable"},
15 {0x00040040, nullptr, "Finalize"}, 15 {0x00040040, nullptr, "Finalize"},
16 {0x00050040, GetAppletManInfo, "GetAppletManInfo"}, 16 {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
17 {0x00060040, nullptr, "GetAppletInfo"}, 17 {0x00060040, GetAppletInfo, "GetAppletInfo"},
18 {0x00070000, nullptr, "GetLastSignaledAppletId"}, 18 {0x00070000, nullptr, "GetLastSignaledAppletId"},
19 {0x00080000, nullptr, "CountRegisteredApplet"}, 19 {0x00080000, nullptr, "CountRegisteredApplet"},
20 {0x00090040, IsRegistered, "IsRegistered"}, 20 {0x00090040, IsRegistered, "IsRegistered"},