From e696ed1f4d20f28f8b26c637498962938df7d96f Mon Sep 17 00:00:00 2001
From: Zach Hilman <zachhilman@gmail.com>
Date: Sun, 11 Nov 2018 16:39:25 -0500
Subject: am: Deglobalize software keyboard applet

---
 src/core/core.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

(limited to 'src/core/core.cpp')

diff --git a/src/core/core.cpp b/src/core/core.cpp
index 6d5b5a2d01..6c72fdf4a0 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -23,12 +23,14 @@
 #include "core/hle/kernel/process.h"
 #include "core/hle/kernel/scheduler.h"
 #include "core/hle/kernel/thread.h"
+#include "core/hle/service/am/applets/software_keyboard.h"
 #include "core/hle/service/service.h"
 #include "core/hle/service/sm/sm.h"
 #include "core/loader/loader.h"
 #include "core/perf_stats.h"
 #include "core/settings.h"
 #include "core/telemetry_session.h"
+#include "frontend/applets/software_keyboard.h"
 #include "video_core/debug_utils/debug_utils.h"
 #include "video_core/gpu.h"
 #include "video_core/renderer_base.h"
@@ -136,6 +138,10 @@ struct System::Impl {
         if (virtual_filesystem == nullptr)
             virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
 
+        /// Create default implementations of applets if one is not provided.
+        if (software_keyboard == nullptr)
+            software_keyboard = std::make_unique<Core::Frontend::DefaultSoftwareKeyboardApplet>();
+
         auto main_process = Kernel::Process::Create(kernel, "main");
         kernel.MakeCurrentProcess(main_process.get());
 
@@ -289,6 +295,9 @@ struct System::Impl {
     std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads;
     std::size_t active_core{}; ///< Active core, only used in single thread mode
 
+    /// Frontend applets
+    std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> software_keyboard;
+
     /// Service manager
     std::shared_ptr<Service::SM::ServiceManager> service_manager;
 
@@ -488,6 +497,14 @@ std::shared_ptr<FileSys::VfsFilesystem> System::GetFilesystem() const {
     return impl->virtual_filesystem;
 }
 
+void System::SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet) {
+    impl->software_keyboard = std::move(applet);
+}
+
+const Core::Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const {
+    return *impl->software_keyboard;
+}
+
 System::ResultStatus System::Init(Frontend::EmuWindow& emu_window) {
     return impl->Init(emu_window);
 }
-- 
cgit v1.2.3-70-g09d2