summaryrefslogtreecommitdiff
path: root/src/core/hle/applets/swkbd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/applets/swkbd.cpp')
-rw-r--r--src/core/hle/applets/swkbd.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
new file mode 100644
index 000000000..224aeb096
--- /dev/null
+++ b/src/core/hle/applets/swkbd.cpp
@@ -0,0 +1,73 @@
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 "common/assert.h"
6#include "common/logging/log.h"
7
8#include "core/hle/applets/swkbd.h"
9
10////////////////////////////////////////////////////////////////////////////////////////////////////
11
12namespace HLE {
13namespace Applets {
14
15SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id) {
16 // Create the SharedMemory that will hold the framebuffer data
17 // TODO(Subv): What size should we use here?
18 using Kernel::MemoryPermission;
19 framebuffer_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite, "SoftwareKeyboard Memory");
20}
21
22ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) {
23 if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) {
24 LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
25 UNIMPLEMENTED();
26 // TODO(Subv): Find the right error code
27 return ResultCode(-1);
28 }
29
30 Service::APT::MessageParameter result;
31 // The buffer passed in parameter contains the data returned by GSPGPU::ImportDisplayCaptureInfo
32 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
33 result.data = nullptr;
34 result.buffer_size = 0;
35 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
36 result.sender_id = static_cast<u32>(id);
37 result.object = framebuffer_memory;
38
39 Service::APT::SendParameter(result);
40 return RESULT_SUCCESS;
41}
42
43ResultCode SoftwareKeyboard::Start(Service::APT::AppletStartupParameter const& parameter) {
44 memcpy(&config, parameter.data, parameter.buffer_size);
45 text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
46
47 // TODO(Subv): Verify if this is the correct behavior
48 memset(text_memory->GetPointer(), 0, text_memory->size);
49
50 // TODO(Subv): Remove this hardcoded text
51 const wchar_t str[] = L"Subv";
52 memcpy(text_memory->GetPointer(), str, 4 * sizeof(wchar_t));
53
54 // TODO(Subv): Ask for input and write it to the shared memory
55 // TODO(Subv): Find out what are the possible values for the return code,
56 // some games seem to check for a hardcoded 2
57 config.return_code = 2;
58 config.text_length = 5;
59 config.text_offset = 0;
60
61 Service::APT::MessageParameter message;
62 message.buffer_size = sizeof(SoftwareKeyboardConfig);
63 message.data = reinterpret_cast<u8*>(&config);
64 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
65 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
66 message.sender_id = static_cast<u32>(id);
67 Service::APT::SendParameter(message);
68
69 return RESULT_SUCCESS;
70}
71
72}
73} // namespace