summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-11-11 22:39:25 +0100
committerZach Hilman <zachhilman@gmail.com>2018-11-18 16:53:47 +0100
commite696ed1f4d20f28f8b26c637498962938df7d96f (patch)
tree79222d795725ba7b19f0aa9326041e236f9a22d8 /src/core/hle/service
parentqt/main: Register Qt Software Keyboard frontend with AM (diff)
downloadyuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.tar
yuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.tar.gz
yuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.tar.bz2
yuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.tar.lz
yuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.tar.xz
yuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.tar.zst
yuzu-e696ed1f4d20f28f8b26c637498962938df7d96f.zip
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/am/am.cpp14
-rw-r--r--src/core/hle/service/am/am.h10
-rw-r--r--src/core/hle/service/am/applets/applets.cpp16
-rw-r--r--src/core/hle/service/am/applets/applets.h10
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp12
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.h9
6 files changed, 44 insertions, 27 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 53580d673..fc464270e 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -501,6 +501,8 @@ IStorage::IStorage(std::vector<u8> buffer)
RegisterHandlers(functions);
}
+IStorage::~IStorage() = default;
+
const std::vector<u8>& IStorage::GetData() const {
return buffer;
}
@@ -670,6 +672,8 @@ IStorageAccessor::IStorageAccessor(IStorage& storage)
RegisterHandlers(functions);
}
+IStorageAccessor::~IStorageAccessor() = default;
+
void IStorageAccessor::GetSize(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 4};
@@ -685,7 +689,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
const u64 offset{rp.Pop<u64>()};
const std::vector<u8> data{ctx.ReadBuffer()};
- const auto size = std::min<std::size_t>(data.size(), backing.buffer.size() - offset);
+ const auto size = std::min(data.size(), backing.buffer.size() - offset);
std::memcpy(&backing.buffer[offset], data.data(), size);
@@ -701,7 +705,7 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
const u64 offset{rp.Pop<u64>()};
std::size_t size{ctx.GetWriteBufferSize()};
- size = std::min<std::size_t>(size, backing.buffer.size() - offset);
+ size = std::min(size, backing.buffer.size() - offset);
ctx.WriteBuffer(backing.buffer.data() + offset, size);
@@ -787,9 +791,9 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
return;
}
- std::vector<u8> memory(shared_mem->size);
- std::memcpy(memory.data(), shared_mem->backing_block->data() + shared_mem->backing_block_offset,
- memory.size());
+ const auto mem_begin = shared_mem->backing_block->begin() + shared_mem->backing_block_offset;
+ const auto mem_end = mem_begin + shared_mem->size;
+ std::vector<u8> memory{mem_begin, mem_end};
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index 640901e4a..44c1bcde5 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -158,27 +158,29 @@ private:
class IStorage final : public ServiceFramework<IStorage> {
public:
explicit IStorage(std::vector<u8> buffer);
+ ~IStorage() override;
const std::vector<u8>& GetData() const;
private:
- std::vector<u8> buffer;
-
void Open(Kernel::HLERequestContext& ctx);
+ std::vector<u8> buffer;
+
friend class IStorageAccessor;
};
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
public:
explicit IStorageAccessor(IStorage& backing);
+ ~IStorageAccessor() override;
private:
- IStorage& backing;
-
void GetSize(Kernel::HLERequestContext& ctx);
void Write(Kernel::HLERequestContext& ctx);
void Read(Kernel::HLERequestContext& ctx);
+
+ IStorage& backing;
};
class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> {
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp
index 8cc4b0f1a..03b9d83e7 100644
--- a/src/core/hle/service/am/applets/applets.cpp
+++ b/src/core/hle/service/am/applets/applets.cpp
@@ -7,23 +7,13 @@
namespace Service::AM::Applets {
-std::shared_ptr<Frontend::SoftwareKeyboardApplet> software_keyboard =
- std::make_shared<Frontend::DefaultSoftwareKeyboardApplet>();
+Applet::Applet() = default;
+
+Applet::~Applet() = default;
void Applet::Initialize(std::vector<std::shared_ptr<IStorage>> storage) {
storage_stack = std::move(storage);
initialized = true;
}
-void RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboardApplet> applet) {
- if (applet == nullptr)
- return;
-
- software_keyboard = std::move(applet);
-}
-
-std::shared_ptr<Frontend::SoftwareKeyboardApplet> GetSoftwareKeyboard() {
- return software_keyboard;
-}
-
} // namespace Service::AM::Applets
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h
index 1f91392b4..47db22fb4 100644
--- a/src/core/hle/service/am/applets/applets.h
+++ b/src/core/hle/service/am/applets/applets.h
@@ -20,10 +20,17 @@ namespace Applets {
class Applet {
public:
+ Applet();
+ virtual ~Applet();
+
virtual void Initialize(std::vector<std::shared_ptr<IStorage>> storage);
virtual IStorage Execute() = 0;
+ bool IsInitialized() const {
+ return initialized;
+ }
+
protected:
struct CommonArguments {
u32_le arguments_version;
@@ -39,8 +46,5 @@ protected:
bool initialized = false;
};
-void RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboardApplet> applet);
-std::shared_ptr<Frontend::SoftwareKeyboardApplet> GetSoftwareKeyboard();
-
} // namespace Applets
} // namespace Service::AM
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp
index ad1797ef1..556dea3e4 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -2,8 +2,10 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <cstring>
#include "common/assert.h"
#include "common/string_util.h"
+#include "core/core.h"
#include "core/frontend/applets/software_keyboard.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applets/software_keyboard.h"
@@ -11,11 +13,13 @@
namespace Service::AM::Applets {
constexpr std::size_t SWKBD_OUTPUT_BUFFER_SIZE = 0x7D8;
+constexpr std::size_t SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE = 0x7D4;
constexpr std::size_t DEFAULT_MAX_LENGTH = 500;
+constexpr bool INTERACTIVE_STATUS_OK = false;
-static Frontend::SoftwareKeyboardApplet::Parameters ConvertToFrontendParameters(
+static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters(
KeyboardConfig config, std::u16string initial_text) {
- Frontend::SoftwareKeyboardApplet::Parameters params{};
+ Core::Frontend::SoftwareKeyboardParameters params{};
params.submit_text = Common::UTF16StringFromFixedZeroTerminatedBuffer(
config.submit_text.data(), config.submit_text.size());
@@ -34,6 +38,10 @@ static Frontend::SoftwareKeyboardApplet::Parameters ConvertToFrontendParameters(
return params;
}
+SoftwareKeyboard::SoftwareKeyboard() = default;
+
+SoftwareKeyboard::~SoftwareKeyboard() = default;
+
void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage_) {
Applet::Initialize(std::move(storage_));
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h
index 9a37ba45f..9d77f5802 100644
--- a/src/core/hle/service/am/applets/software_keyboard.h
+++ b/src/core/hle/service/am/applets/software_keyboard.h
@@ -5,6 +5,7 @@
#pragma once
#include "common/common_funcs.h"
+#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applets/applets.h"
namespace Service::AM::Applets {
@@ -45,13 +46,21 @@ static_assert(sizeof(KeyboardConfig) == 0x3E0, "KeyboardConfig has incorrect siz
class SoftwareKeyboard final : public Applet {
public:
+ SoftwareKeyboard();
+ ~SoftwareKeyboard() override;
+
void Initialize(std::vector<std::shared_ptr<IStorage>> storage) override;
+ bool TransactionComplete() const override;
+ ResultCode GetStatus() const override;
+ void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) override;
IStorage Execute() override;
private:
KeyboardConfig config;
std::u16string initial_text;
+ bool complete = false;
+ std::vector<u8> final_data;
};
} // namespace Service::AM::Applets