summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2016-05-07 17:21:48 -0400
committerGravatar bunnei2016-05-07 17:21:48 -0400
commit8e9b33a34aab3f585d4855c2b69dbd76f1751be1 (patch)
treeef54db38e7727d403651a2857afb6e4f9c4f2872
parentMerge pull request #1736 from MerryMage/sdl2-sink (diff)
parentHLE/Applets: Use the correct size for the framebuffer SharedMemory in the swk... (diff)
downloadyuzu-8e9b33a34aab3f585d4855c2b69dbd76f1751be1.tar.gz
yuzu-8e9b33a34aab3f585d4855c2b69dbd76f1751be1.tar.xz
yuzu-8e9b33a34aab3f585d4855c2b69dbd76f1751be1.zip
Merge pull request #1761 from Subv/applets_fb
HLE/Applets: Use the correct size for the framebuffer SharedMemory
-rw-r--r--src/core/hle/applets/mii_selector.cpp19
-rw-r--r--src/core/hle/applets/mii_selector.h6
-rw-r--r--src/core/hle/applets/swkbd.cpp20
-rw-r--r--src/core/hle/applets/swkbd.h7
-rw-r--r--src/core/hle/service/apt/apt.h15
5 files changed, 44 insertions, 23 deletions
diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp
index 5191c821d..b4456ca90 100644
--- a/src/core/hle/applets/mii_selector.cpp
+++ b/src/core/hle/applets/mii_selector.cpp
@@ -21,13 +21,6 @@
21namespace HLE { 21namespace HLE {
22namespace Applets { 22namespace Applets {
23 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) { 24ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
32 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) { 25 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) {
33 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal); 26 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
@@ -36,8 +29,18 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
36 return ResultCode(-1); 29 return ResultCode(-1);
37 } 30 }
38 31
32 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
33 // Create the SharedMemory that will hold the framebuffer data
34 Service::APT::CaptureBufferInfo capture_info;
35 ASSERT(sizeof(capture_info) == parameter.buffer_size);
36
37 memcpy(&capture_info, parameter.data, sizeof(capture_info));
38 using Kernel::MemoryPermission;
39 framebuffer_memory = Kernel::SharedMemory::Create(capture_info.size, MemoryPermission::ReadWrite,
40 MemoryPermission::ReadWrite, "MiiSelector Memory");
41
42 // Send the response message with the newly created SharedMemory
39 Service::APT::MessageParameter result; 43 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); 44 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
42 result.data = nullptr; 45 result.data = nullptr;
43 result.buffer_size = 0; 46 result.buffer_size = 0;
diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h
index c02dded4a..be6b04642 100644
--- a/src/core/hle/applets/mii_selector.h
+++ b/src/core/hle/applets/mii_selector.h
@@ -62,15 +62,15 @@ ASSERT_REG_POSITION(unk_6C, 0x6C);
62 62
63class MiiSelector final : public Applet { 63class MiiSelector final : public Applet {
64public: 64public:
65 MiiSelector(Service::APT::AppletId id); 65 MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) { }
66 66
67 ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; 67 ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
68 ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; 68 ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
69 void Update() override; 69 void Update() override;
70 bool IsRunning() const override { return started; } 70 bool IsRunning() const override { return started; }
71 71
72 /// TODO(Subv): Find out what this is actually used for. 72 /// This SharedMemory will be created when we receive the LibAppJustStarted message.
73 /// It is believed that the application stores the current screen image here. 73 /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
74 Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory; 74 Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
75 75
76 /// Whether this applet is currently running instead of the host application or not. 76 /// Whether this applet is currently running instead of the host application or not.
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
index 1db6b5a17..87238aa1c 100644
--- a/src/core/hle/applets/swkbd.cpp
+++ b/src/core/hle/applets/swkbd.cpp
@@ -24,13 +24,6 @@
24namespace HLE { 24namespace HLE {
25namespace Applets { 25namespace Applets {
26 26
27SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) {
28 // Create the SharedMemory that will hold the framebuffer data
29 // TODO(Subv): What size should we use here?
30 using Kernel::MemoryPermission;
31 framebuffer_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite, "SoftwareKeyboard Memory");
32}
33
34ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) { 27ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) {
35 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) { 28 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) {
36 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal); 29 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
@@ -39,8 +32,19 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
39 return ResultCode(-1); 32 return ResultCode(-1);
40 } 33 }
41 34
35 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
36 // Create the SharedMemory that will hold the framebuffer data
37 Service::APT::CaptureBufferInfo capture_info;
38 ASSERT(sizeof(capture_info) == parameter.buffer_size);
39
40 memcpy(&capture_info, parameter.data, sizeof(capture_info));
41
42 using Kernel::MemoryPermission;
43 framebuffer_memory = Kernel::SharedMemory::Create(capture_info.size, MemoryPermission::ReadWrite,
44 MemoryPermission::ReadWrite, "SoftwareKeyboard Memory");
45
46 // Send the response message with the newly created SharedMemory
42 Service::APT::MessageParameter result; 47 Service::APT::MessageParameter result;
43 // The buffer passed in parameter contains the data returned by GSPGPU::ImportDisplayCaptureInfo
44 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); 48 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
45 result.data = nullptr; 49 result.data = nullptr;
46 result.buffer_size = 0; 50 result.buffer_size = 0;
diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h
index cb95b8d90..cf26a8fb7 100644
--- a/src/core/hle/applets/swkbd.h
+++ b/src/core/hle/applets/swkbd.h
@@ -53,8 +53,7 @@ static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config
53 53
54class SoftwareKeyboard final : public Applet { 54class SoftwareKeyboard final : public Applet {
55public: 55public:
56 SoftwareKeyboard(Service::APT::AppletId id); 56 SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) { }
57 ~SoftwareKeyboard() {}
58 57
59 ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; 58 ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
60 ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; 59 ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
@@ -72,8 +71,8 @@ public:
72 */ 71 */
73 void Finalize(); 72 void Finalize();
74 73
75 /// TODO(Subv): Find out what this is actually used for. 74 /// This SharedMemory will be created when we receive the LibAppJustStarted message.
76 /// It is believed that the application stores the current screen image here. 75 /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
77 Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory; 76 Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
78 77
79 /// SharedMemory where the output text will be stored 78 /// SharedMemory where the output text will be stored
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 668b4a66f..1a1034fcc 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/swap.h"
8 9
9#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
10 11
@@ -31,6 +32,20 @@ struct AppletStartupParameter {
31 u8* data = nullptr; 32 u8* data = nullptr;
32}; 33};
33 34
35/// Used by the application to pass information about the current framebuffer to applets.
36struct CaptureBufferInfo {
37 u32_le size;
38 u8 is_3d;
39 INSERT_PADDING_BYTES(0x3); // Padding for alignment
40 u32_le top_screen_left_offset;
41 u32_le top_screen_right_offset;
42 u32_le top_screen_format;
43 u32_le bottom_screen_left_offset;
44 u32_le bottom_screen_right_offset;
45 u32_le bottom_screen_format;
46};
47static_assert(sizeof(CaptureBufferInfo) == 0x20, "CaptureBufferInfo struct has incorrect size");
48
34/// Signals used by APT functions 49/// Signals used by APT functions
35enum class SignalType : u32 { 50enum class SignalType : u32 {
36 None = 0x0, 51 None = 0x0,