summaryrefslogtreecommitdiff
path: root/src/core/hle/applets/swkbd.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2017-10-10 17:32:14 -0400
committerGravatar bunnei2017-10-10 17:32:14 -0400
commit0906de9a14b735d1d409290ca050eb7d2c2d3d84 (patch)
tree79bb57d3a4dc4ca377e7a62744c3941de29e785b /src/core/hle/applets/swkbd.cpp
parentMerge remote-tracking branch 'upstream/master' into nx (diff)
downloadyuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.gz
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.xz
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.zip
hle: Remove a large amount of 3ds-specific service code.
Diffstat (limited to 'src/core/hle/applets/swkbd.cpp')
-rw-r--r--src/core/hle/applets/swkbd.cpp118
1 files changed, 0 insertions, 118 deletions
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
deleted file mode 100644
index 0bc471a3a..000000000
--- a/src/core/hle/applets/swkbd.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
1// Copyright 2015 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#include "common/assert.h"
8#include "common/logging/log.h"
9#include "common/string_util.h"
10#include "core/hle/applets/swkbd.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/gsp_gpu.h"
15#include "core/hle/service/hid/hid.h"
16#include "core/memory.h"
17
18////////////////////////////////////////////////////////////////////////////////////////////////////
19
20namespace HLE {
21namespace Applets {
22
23ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) {
24 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::Request)) {
25 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
26 UNIMPLEMENTED();
27 // TODO(Subv): Find the right error code
28 return ResultCode(-1);
29 }
30
31 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
32 // 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.buffer.data(), sizeof(capture_info));
38
39 using Kernel::MemoryPermission;
40 // Allocate a heap block of the required size for this applet.
41 heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
42 // Create a SharedMemory that directly points to this heap block.
43 framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
44 heap_memory, 0, capture_info.size, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
45 "SoftwareKeyboard Memory");
46
47 // Send the response message with the newly created SharedMemory
48 Service::APT::MessageParameter result;
49 result.signal = static_cast<u32>(Service::APT::SignalType::Response);
50 result.buffer.clear();
51 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
52 result.sender_id = static_cast<u32>(id);
53 result.object = framebuffer_memory;
54
55 Service::APT::SendParameter(result);
56 return RESULT_SUCCESS;
57}
58
59ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
60 ASSERT_MSG(parameter.buffer.size() == sizeof(config),
61 "The size of the parameter (SoftwareKeyboardConfig) is wrong");
62
63 memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
64 text_memory =
65 boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
66
67 // TODO(Subv): Verify if this is the correct behavior
68 memset(text_memory->GetPointer(), 0, text_memory->size);
69
70 DrawScreenKeyboard();
71
72 is_running = true;
73 return RESULT_SUCCESS;
74}
75
76void SoftwareKeyboard::Update() {
77 // TODO(Subv): Handle input using the touch events from the HID module
78
79 // TODO(Subv): Remove this hardcoded text
80 std::u16string text = Common::UTF8ToUTF16("Citra");
81 memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t));
82
83 // TODO(Subv): Ask for input and write it to the shared memory
84 // TODO(Subv): Find out what are the possible values for the return code,
85 // some games seem to check for a hardcoded 2
86 config.return_code = 2;
87 config.text_length = 6;
88 config.text_offset = 0;
89
90 // TODO(Subv): We're finalizing the applet immediately after it's started,
91 // but we should defer this call until after all the input has been collected.
92 Finalize();
93}
94
95void SoftwareKeyboard::DrawScreenKeyboard() {
96 auto bottom_screen = Service::GSP::GetFrameBufferInfo(0, 1);
97 auto info = bottom_screen->framebuffer_info[bottom_screen->index];
98
99 // TODO(Subv): Draw the HLE keyboard, for now just zero-fill the framebuffer
100 Memory::ZeroBlock(info.address_left, info.stride * 320);
101
102 Service::GSP::SetBufferSwap(1, info);
103}
104
105void SoftwareKeyboard::Finalize() {
106 // Let the application know that we're closing
107 Service::APT::MessageParameter message;
108 message.buffer.resize(sizeof(SoftwareKeyboardConfig));
109 std::memcpy(message.buffer.data(), &config, message.buffer.size());
110 message.signal = static_cast<u32>(Service::APT::SignalType::WakeupByExit);
111 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
112 message.sender_id = static_cast<u32>(id);
113 Service::APT::SendParameter(message);
114
115 is_running = false;
116}
117}
118} // namespace