diff options
Diffstat (limited to 'src/core/hle/applets/swkbd.cpp')
| -rw-r--r-- | src/core/hle/applets/swkbd.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 224aeb096..b800e0eb4 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp | |||
| @@ -6,13 +6,16 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | 7 | ||
| 8 | #include "core/hle/applets/swkbd.h" | 8 | #include "core/hle/applets/swkbd.h" |
| 9 | #include "core/hle/service/hid/hid.h" | ||
| 10 | #include "core/hle/service/gsp_gpu.h" | ||
| 11 | #include "video_core/video_core.h" | ||
| 9 | 12 | ||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | 14 | ||
| 12 | namespace HLE { | 15 | namespace HLE { |
| 13 | namespace Applets { | 16 | namespace Applets { |
| 14 | 17 | ||
| 15 | SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id) { | 18 | SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) { |
| 16 | // Create the SharedMemory that will hold the framebuffer data | 19 | // Create the SharedMemory that will hold the framebuffer data |
| 17 | // TODO(Subv): What size should we use here? | 20 | // TODO(Subv): What size should we use here? |
| 18 | using Kernel::MemoryPermission; | 21 | using Kernel::MemoryPermission; |
| @@ -47,17 +50,45 @@ ResultCode SoftwareKeyboard::Start(Service::APT::AppletStartupParameter const& p | |||
| 47 | // TODO(Subv): Verify if this is the correct behavior | 50 | // TODO(Subv): Verify if this is the correct behavior |
| 48 | memset(text_memory->GetPointer(), 0, text_memory->size); | 51 | memset(text_memory->GetPointer(), 0, text_memory->size); |
| 49 | 52 | ||
| 53 | DrawScreenKeyboard(); | ||
| 54 | |||
| 55 | // Update the current applet so we can get update events | ||
| 56 | started = true; | ||
| 57 | g_current_applet = shared_from_this(); | ||
| 58 | return RESULT_SUCCESS; | ||
| 59 | } | ||
| 60 | |||
| 61 | void SoftwareKeyboard::Update() { | ||
| 62 | // TODO(Subv): Handle input using the touch events from the HID module | ||
| 63 | |||
| 50 | // TODO(Subv): Remove this hardcoded text | 64 | // TODO(Subv): Remove this hardcoded text |
| 51 | const wchar_t str[] = L"Subv"; | 65 | std::u16string text = Common::UTF8ToUTF16("Citra"); |
| 52 | memcpy(text_memory->GetPointer(), str, 4 * sizeof(wchar_t)); | 66 | memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t)); |
| 53 | 67 | ||
| 54 | // TODO(Subv): Ask for input and write it to the shared memory | 68 | // 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, | 69 | // TODO(Subv): Find out what are the possible values for the return code, |
| 56 | // some games seem to check for a hardcoded 2 | 70 | // some games seem to check for a hardcoded 2 |
| 57 | config.return_code = 2; | 71 | config.return_code = 2; |
| 58 | config.text_length = 5; | 72 | config.text_length = 6; |
| 59 | config.text_offset = 0; | 73 | config.text_offset = 0; |
| 60 | 74 | ||
| 75 | // TODO(Subv): We're finalizing the applet immediately after it's started, | ||
| 76 | // but we should defer this call until after all the input has been collected. | ||
| 77 | Finalize(); | ||
| 78 | } | ||
| 79 | |||
| 80 | void SoftwareKeyboard::DrawScreenKeyboard() { | ||
| 81 | auto bottom_screen = GSP_GPU::GetFrameBufferInfo(0, 1); | ||
| 82 | auto info = bottom_screen->framebuffer_info[bottom_screen->index]; | ||
| 83 | |||
| 84 | // TODO(Subv): Draw the HLE keyboard, for now just zero-fill the framebuffer | ||
| 85 | memset(Memory::GetPointer(info.address_left), 0, info.stride * 320); | ||
| 86 | |||
| 87 | GSP_GPU::SetBufferSwap(1, info); | ||
| 88 | } | ||
| 89 | |||
| 90 | void SoftwareKeyboard::Finalize() { | ||
| 91 | // Let the application know that we're closing | ||
| 61 | Service::APT::MessageParameter message; | 92 | Service::APT::MessageParameter message; |
| 62 | message.buffer_size = sizeof(SoftwareKeyboardConfig); | 93 | message.buffer_size = sizeof(SoftwareKeyboardConfig); |
| 63 | message.data = reinterpret_cast<u8*>(&config); | 94 | message.data = reinterpret_cast<u8*>(&config); |
| @@ -66,7 +97,9 @@ ResultCode SoftwareKeyboard::Start(Service::APT::AppletStartupParameter const& p | |||
| 66 | message.sender_id = static_cast<u32>(id); | 97 | message.sender_id = static_cast<u32>(id); |
| 67 | Service::APT::SendParameter(message); | 98 | Service::APT::SendParameter(message); |
| 68 | 99 | ||
| 69 | return RESULT_SUCCESS; | 100 | started = false; |
| 101 | // Unset the current applet, we are not running anymore | ||
| 102 | g_current_applet = nullptr; | ||
| 70 | } | 103 | } |
| 71 | 104 | ||
| 72 | } | 105 | } |