hle: Remove a large amount of 3ds-specific service code.

This commit is contained in:
bunnei 2017-10-10 17:32:14 -04:00
commit dd4ffef0a2
200 changed files with 2 additions and 22393 deletions

View file

@ -134,21 +134,6 @@ void Config::ReadValues() {
Settings::values.region_value =
sdl2_config->GetInteger("System", "region_value", Settings::REGION_VALUE_AUTO_SELECT);
// Camera
using namespace Service::CAM;
Settings::values.camera_name[OuterRightCamera] =
sdl2_config->Get("Camera", "camera_outer_right_name", "blank");
Settings::values.camera_config[OuterRightCamera] =
sdl2_config->Get("Camera", "camera_outer_right_config", "");
Settings::values.camera_name[InnerCamera] =
sdl2_config->Get("Camera", "camera_inner_name", "blank");
Settings::values.camera_config[InnerCamera] =
sdl2_config->Get("Camera", "camera_inner_config", "");
Settings::values.camera_name[OuterLeftCamera] =
sdl2_config->Get("Camera", "camera_outer_left_name", "blank");
Settings::values.camera_config[OuterLeftCamera] =
sdl2_config->Get("Camera", "camera_outer_left_config", "");
// Miscellaneous
Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Info");

View file

@ -153,22 +153,6 @@ is_new_3ds =
# -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
region_value =
[Camera]
# Which camera engine to use for the right outer camera
# blank (default): a dummy camera that always returns black image
camera_outer_right_name =
# A config string for the right outer camera. Its meaning is defined by the camera engine
camera_outer_right_config =
# ... for the left outer camera
camera_outer_left_name =
camera_outer_left_config =
# ... for the inner camera
camera_inner_name =
camera_inner_config =
[Miscellaneous]
# A filter which removes logs below a certain logging level.
# Examples: *:Debug Kernel.SVC:Trace Service.*:Critical

View file

@ -105,22 +105,6 @@ void Config::ReadValues() {
qt_config->value("output_device", "auto").toString().toStdString();
qt_config->endGroup();
using namespace Service::CAM;
qt_config->beginGroup("Camera");
Settings::values.camera_name[OuterRightCamera] =
qt_config->value("camera_outer_right_name", "blank").toString().toStdString();
Settings::values.camera_config[OuterRightCamera] =
qt_config->value("camera_outer_right_config", "").toString().toStdString();
Settings::values.camera_name[InnerCamera] =
qt_config->value("camera_inner_name", "blank").toString().toStdString();
Settings::values.camera_config[InnerCamera] =
qt_config->value("camera_inner_config", "").toString().toStdString();
Settings::values.camera_name[OuterLeftCamera] =
qt_config->value("camera_outer_left_name", "blank").toString().toStdString();
Settings::values.camera_config[OuterLeftCamera] =
qt_config->value("camera_outer_left_config", "").toString().toStdString();
qt_config->endGroup();
qt_config->beginGroup("Data Storage");
Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool();
qt_config->endGroup();
@ -259,22 +243,6 @@ void Config::SaveValues() {
qt_config->setValue("output_device", QString::fromStdString(Settings::values.audio_device_id));
qt_config->endGroup();
using namespace Service::CAM;
qt_config->beginGroup("Camera");
qt_config->setValue("camera_outer_right_name",
QString::fromStdString(Settings::values.camera_name[OuterRightCamera]));
qt_config->setValue("camera_outer_right_config",
QString::fromStdString(Settings::values.camera_config[OuterRightCamera]));
qt_config->setValue("camera_inner_name",
QString::fromStdString(Settings::values.camera_name[InnerCamera]));
qt_config->setValue("camera_inner_config",
QString::fromStdString(Settings::values.camera_config[InnerCamera]));
qt_config->setValue("camera_outer_left_name",
QString::fromStdString(Settings::values.camera_name[OuterLeftCamera]));
qt_config->setValue("camera_outer_left_config",
QString::fromStdString(Settings::values.camera_config[OuterLeftCamera]));
qt_config->endGroup();
qt_config->beginGroup("Data Storage");
qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd);
qt_config->endGroup();

View file

@ -33,32 +33,11 @@ namespace Log {
SUB(Kernel, SVC) \
CLS(Service) \
SUB(Service, SRV) \
SUB(Service, FRD) \
SUB(Service, FS) \
SUB(Service, ERR) \
SUB(Service, APT) \
SUB(Service, BOSS) \
SUB(Service, GSP) \
SUB(Service, AC) \
SUB(Service, AM) \
SUB(Service, PTM) \
SUB(Service, LDR) \
SUB(Service, MIC) \
SUB(Service, NDM) \
SUB(Service, NFC) \
SUB(Service, NIM) \
SUB(Service, NWM) \
SUB(Service, CAM) \
SUB(Service, CECD) \
SUB(Service, CFG) \
SUB(Service, CSND) \
SUB(Service, DSP) \
SUB(Service, DLP) \
SUB(Service, HID) \
SUB(Service, HTTP) \
SUB(Service, SOC) \
SUB(Service, IR) \
SUB(Service, Y2R) \
CLS(HW) \
SUB(HW, Memory) \
SUB(HW, LCD) \

View file

@ -50,32 +50,11 @@ enum class Class : ClassType {
Service, ///< HLE implementation of system services. Each major service
/// should have its own subclass.
Service_SRV, ///< The SRV (Service Directory) implementation
Service_FRD, ///< The FRD (Friends) service
Service_FS, ///< The FS (Filesystem) service implementation
Service_ERR, ///< The ERR (Error) port implementation
Service_APT, ///< The APT (Applets) service
Service_BOSS, ///< The BOSS (SpotPass) service
Service_GSP, ///< The GSP (GPU control) service
Service_AC, ///< The AC (WiFi status) service
Service_AM, ///< The AM (Application manager) service
Service_PTM, ///< The PTM (Power status & misc.) service
Service_LDR, ///< The LDR (3ds dll loader) service
Service_MIC, ///< The MIC (Microphone) service
Service_NDM, ///< The NDM (Network daemon manager) service
Service_NFC, ///< The NFC service
Service_NIM, ///< The NIM (Network interface manager) service
Service_NWM, ///< The NWM (Network wlan manager) service
Service_CAM, ///< The CAM (Camera) service
Service_CECD, ///< The CECD (StreetPass) service
Service_CFG, ///< The CFG (Configuration) service
Service_CSND, ///< The CSND (CWAV format process) service
Service_DSP, ///< The DSP (DSP control) service
Service_DLP, ///< The DLP (Download Play) service
Service_HID, ///< The HID (Human interface device) service
Service_HTTP, ///< The HTTP service
Service_SOC, ///< The SOC (Socket) service
Service_IR, ///< The IR service
Service_Y2R, ///< The Y2R (YUV to RGB conversion) service
HW, ///< Low-level hardware emulation
HW_Memory, ///< Memory-map and address translation
HW_LCD, ///< LCD register emulation

View file

@ -32,18 +32,10 @@ set(SRCS
file_sys/path_parser.cpp
file_sys/savedata_archive.cpp
file_sys/title_metadata.cpp
frontend/camera/blank_camera.cpp
frontend/camera/factory.cpp
frontend/camera/interface.cpp
frontend/emu_window.cpp
frontend/framebuffer_layout.cpp
gdbstub/gdbstub.cpp
hle/config_mem.cpp
hle/applets/applet.cpp
hle/applets/erreula.cpp
hle/applets/mii_selector.cpp
hle/applets/mint.cpp
hle/applets/swkbd.cpp
hle/kernel/address_arbiter.cpp
hle/kernel/client_port.cpp
hle/kernel/client_session.cpp
@ -65,49 +57,12 @@ set(SRCS
hle/kernel/wait_object.cpp
hle/lock.cpp
hle/romfs.cpp
hle/service/ac/ac.cpp
hle/service/ac/ac_i.cpp
hle/service/ac/ac_u.cpp
hle/service/act/act.cpp
hle/service/act/act_a.cpp
hle/service/act/act_u.cpp
hle/service/am/am.cpp
hle/service/am/am_app.cpp
hle/service/am/am_net.cpp
hle/service/am/am_sys.cpp
hle/service/am/am_u.cpp
hle/service/apt/apt.cpp
hle/service/apt/apt_a.cpp
hle/service/apt/apt_s.cpp
hle/service/apt/apt_u.cpp
hle/service/apt/bcfnt/bcfnt.cpp
hle/service/boss/boss.cpp
hle/service/boss/boss_p.cpp
hle/service/boss/boss_u.cpp
hle/service/cam/cam.cpp
hle/service/cam/cam_c.cpp
hle/service/cam/cam_q.cpp
hle/service/cam/cam_s.cpp
hle/service/cam/cam_u.cpp
hle/service/cecd/cecd.cpp
hle/service/cecd/cecd_ndm.cpp
hle/service/cecd/cecd_s.cpp
hle/service/cecd/cecd_u.cpp
hle/service/cfg/cfg.cpp
hle/service/cfg/cfg_i.cpp
hle/service/cfg/cfg_nor.cpp
hle/service/cfg/cfg_s.cpp
hle/service/cfg/cfg_u.cpp
hle/service/csnd_snd.cpp
hle/service/dlp/dlp.cpp
hle/service/dlp/dlp_clnt.cpp
hle/service/dlp/dlp_fkcl.cpp
hle/service/dlp/dlp_srvr.cpp
hle/service/dsp_dsp.cpp
hle/service/err_f.cpp
hle/service/frd/frd.cpp
hle/service/frd/frd_a.cpp
hle/service/frd/frd_u.cpp
hle/service/fs/archive.cpp
hle/service/fs/fs_user.cpp
hle/service/gsp_gpu.cpp
@ -115,60 +70,11 @@ set(SRCS
hle/service/hid/hid.cpp
hle/service/hid/hid_spvr.cpp
hle/service/hid/hid_user.cpp
hle/service/http_c.cpp
hle/service/ir/extra_hid.cpp
hle/service/ir/ir.cpp
hle/service/ir/ir_rst.cpp
hle/service/ir/ir_u.cpp
hle/service/ir/ir_user.cpp
hle/service/ldr_ro/cro_helper.cpp
hle/service/ldr_ro/ldr_ro.cpp
hle/service/ldr_ro/memory_synchronizer.cpp
hle/service/mic_u.cpp
hle/service/mvd/mvd.cpp
hle/service/mvd/mvd_std.cpp
hle/service/ndm/ndm.cpp
hle/service/ndm/ndm_u.cpp
hle/service/nfc/nfc.cpp
hle/service/nfc/nfc_m.cpp
hle/service/nfc/nfc_u.cpp
hle/service/news/news.cpp
hle/service/news/news_s.cpp
hle/service/news/news_u.cpp
hle/service/nim/nim.cpp
hle/service/nim/nim_aoc.cpp
hle/service/nim/nim_s.cpp
hle/service/nim/nim_u.cpp
hle/service/ns/ns.cpp
hle/service/ns/ns_s.cpp
hle/service/nwm/nwm.cpp
hle/service/nwm/nwm_cec.cpp
hle/service/nwm/nwm_ext.cpp
hle/service/nwm/nwm_inf.cpp
hle/service/nwm/nwm_sap.cpp
hle/service/nwm/nwm_soc.cpp
hle/service/nwm/nwm_tst.cpp
hle/service/nwm/nwm_uds.cpp
hle/service/nwm/uds_beacon.cpp
hle/service/nwm/uds_connection.cpp
hle/service/nwm/uds_data.cpp
hle/service/pm_app.cpp
hle/service/ptm/ptm.cpp
hle/service/ptm/ptm_gets.cpp
hle/service/ptm/ptm_play.cpp
hle/service/ptm/ptm_sets.cpp
hle/service/ptm/ptm_sysm.cpp
hle/service/ptm/ptm_u.cpp
hle/service/qtm/qtm.cpp
hle/service/qtm/qtm_s.cpp
hle/service/qtm/qtm_sp.cpp
hle/service/qtm/qtm_u.cpp
hle/service/service.cpp
hle/service/sm/sm.cpp
hle/service/sm/srv.cpp
hle/service/soc_u.cpp
hle/service/ssl_c.cpp
hle/service/y2r_u.cpp
hle/shared_page.cpp
hle/svc.cpp
hw/aes/arithmetic128.cpp
@ -177,7 +83,6 @@ set(SRCS
hw/gpu.cpp
hw/hw.cpp
hw/lcd.cpp
hw/y2r.cpp
loader/3dsx.cpp
loader/elf.cpp
loader/linker.cpp
@ -231,9 +136,6 @@ set(HEADERS
file_sys/ivfc_archive.h
file_sys/path_parser.h
file_sys/savedata_archive.h
frontend/camera/blank_camera.h
frontend/camera/factory.h
frontend/camera/interface.h
frontend/emu_window.h
frontend/framebuffer_layout.h
frontend/input.h
@ -242,11 +144,6 @@ set(HEADERS
hle/function_wrappers.h
hle/ipc.h
hle/ipc_helpers.h
hle/applets/applet.h
hle/applets/erreula.h
hle/applets/mii_selector.h
hle/applets/mint.h
hle/applets/swkbd.h
hle/kernel/address_arbiter.h
hle/kernel/client_port.h
hle/kernel/client_session.h
@ -271,49 +168,12 @@ set(HEADERS
hle/lock.h
hle/result.h
hle/romfs.h
hle/service/ac/ac.h
hle/service/ac/ac_i.h
hle/service/ac/ac_u.h
hle/service/act/act.h
hle/service/act/act_a.h
hle/service/act/act_u.h
hle/service/am/am.h
hle/service/am/am_app.h
hle/service/am/am_net.h
hle/service/am/am_sys.h
hle/service/am/am_u.h
hle/service/apt/apt.h
hle/service/apt/apt_a.h
hle/service/apt/apt_s.h
hle/service/apt/apt_u.h
hle/service/apt/bcfnt/bcfnt.h
hle/service/boss/boss.h
hle/service/boss/boss_p.h
hle/service/boss/boss_u.h
hle/service/cam/cam.h
hle/service/cam/cam_c.h
hle/service/cam/cam_q.h
hle/service/cam/cam_s.h
hle/service/cam/cam_u.h
hle/service/cecd/cecd.h
hle/service/cecd/cecd_ndm.h
hle/service/cecd/cecd_s.h
hle/service/cecd/cecd_u.h
hle/service/cfg/cfg.h
hle/service/cfg/cfg_i.h
hle/service/cfg/cfg_nor.h
hle/service/cfg/cfg_s.h
hle/service/cfg/cfg_u.h
hle/service/csnd_snd.h
hle/service/dlp/dlp.h
hle/service/dlp/dlp_clnt.h
hle/service/dlp/dlp_fkcl.h
hle/service/dlp/dlp_srvr.h
hle/service/dsp_dsp.h
hle/service/err_f.h
hle/service/frd/frd.h
hle/service/frd/frd_a.h
hle/service/frd/frd_u.h
hle/service/fs/archive.h
hle/service/fs/fs_user.h
hle/service/gsp_gpu.h
@ -321,60 +181,11 @@ set(HEADERS
hle/service/hid/hid.h
hle/service/hid/hid_spvr.h
hle/service/hid/hid_user.h
hle/service/http_c.h
hle/service/ir/extra_hid.h
hle/service/ir/ir.h
hle/service/ir/ir_rst.h
hle/service/ir/ir_u.h
hle/service/ir/ir_user.h
hle/service/ldr_ro/cro_helper.h
hle/service/ldr_ro/ldr_ro.h
hle/service/ldr_ro/memory_synchronizer.h
hle/service/mic_u.h
hle/service/mvd/mvd.h
hle/service/mvd/mvd_std.h
hle/service/ndm/ndm.h
hle/service/ndm/ndm_u.h
hle/service/nfc/nfc.h
hle/service/nfc/nfc_m.h
hle/service/nfc/nfc_u.h
hle/service/news/news.h
hle/service/news/news_s.h
hle/service/news/news_u.h
hle/service/nim/nim.h
hle/service/nim/nim_aoc.h
hle/service/nim/nim_s.h
hle/service/nim/nim_u.h
hle/service/ns/ns.h
hle/service/ns/ns_s.h
hle/service/nwm/nwm.h
hle/service/nwm/nwm_cec.h
hle/service/nwm/nwm_ext.h
hle/service/nwm/nwm_inf.h
hle/service/nwm/nwm_sap.h
hle/service/nwm/nwm_soc.h
hle/service/nwm/nwm_tst.h
hle/service/nwm/nwm_uds.h
hle/service/nwm/uds_beacon.h
hle/service/nwm/uds_connection.h
hle/service/nwm/uds_data.h
hle/service/pm_app.h
hle/service/ptm/ptm.h
hle/service/ptm/ptm_gets.h
hle/service/ptm/ptm_play.h
hle/service/ptm/ptm_sets.h
hle/service/ptm/ptm_sysm.h
hle/service/ptm/ptm_u.h
hle/service/qtm/qtm.h
hle/service/qtm/qtm_s.h
hle/service/qtm/qtm_sp.h
hle/service/qtm/qtm_u.h
hle/service/service.h
hle/service/sm/sm.h
hle/service/sm/srv.h
hle/service/soc_u.h
hle/service/ssl_c.h
hle/service/y2r_u.h
hle/shared_page.h
hle/svc.h
hw/aes/arithmetic128.h
@ -383,7 +194,6 @@ set(HEADERS
hw/gpu.h
hw/hw.h
hw/lcd.h
hw/y2r.h
loader/3dsx.h
loader/elf.h
loader/linker.h

View file

@ -1,31 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/frontend/camera/blank_camera.h"
namespace Camera {
void BlankCamera::StartCapture() {}
void BlankCamera::StopCapture() {}
void BlankCamera::SetFormat(Service::CAM::OutputFormat output_format) {
output_rgb = output_format == Service::CAM::OutputFormat::RGB565;
}
void BlankCamera::SetResolution(const Service::CAM::Resolution& resolution) {
width = resolution.width;
height = resolution.height;
};
void BlankCamera::SetFlip(Service::CAM::Flip) {}
void BlankCamera::SetEffect(Service::CAM::Effect) {}
std::vector<u16> BlankCamera::ReceiveFrame() const {
// Note: 0x80008000 stands for two black pixels in YUV422
return std::vector<u16>(width * height, output_rgb ? 0 : 0x8000);
}
} // namespace Camera

View file

@ -1,28 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/frontend/camera/factory.h"
#include "core/frontend/camera/interface.h"
namespace Camera {
class BlankCamera final : public CameraInterface {
public:
void StartCapture() override;
void StopCapture() override;
void SetResolution(const Service::CAM::Resolution&) override;
void SetFlip(Service::CAM::Flip) override;
void SetEffect(Service::CAM::Effect) override;
void SetFormat(Service::CAM::OutputFormat) override;
std::vector<u16> ReceiveFrame() const override;
private:
int width = 0;
int height = 0;
bool output_rgb = false;
};
} // namespace Camera

View file

@ -1,32 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <unordered_map>
#include "common/logging/log.h"
#include "core/frontend/camera/blank_camera.h"
#include "core/frontend/camera/factory.h"
namespace Camera {
static std::unordered_map<std::string, std::unique_ptr<CameraFactory>> factories;
CameraFactory::~CameraFactory() = default;
void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory) {
factories[name] = std::move(factory);
}
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config) {
auto pair = factories.find(name);
if (pair != factories.end()) {
return pair->second->Create(config);
}
if (name != "blank") {
LOG_ERROR(Service_CAM, "Unknown camera \"%s\"", name.c_str());
}
return std::make_unique<BlankCamera>();
}
} // namespace Camera

View file

@ -1,41 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <string>
#include "core/frontend/camera/interface.h"
namespace Camera {
class CameraFactory {
public:
virtual ~CameraFactory();
/**
* Creates a camera object based on the configuration string.
* @param config Configuration string to create the camera. The implementation can decide the
* meaning of this string.
* @returns a unique_ptr to the created camera object.
*/
virtual std::unique_ptr<CameraInterface> Create(const std::string& config) const = 0;
};
/**
* Registers an external camera factory.
* @param name Identifier of the camera factory.
* @param factory Camera factory to register.
*/
void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory);
/**
* Creates a camera from the factory.
* @param name Identifier of the camera factory.
* @param config Configuration string to create the camera. The meaning of this string is
* defined by the factory.
*/
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config);
} // namespace Camera

View file

@ -1,11 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/frontend/camera/interface.h"
namespace Camera {
CameraInterface::~CameraInterface() = default;
} // namespace Camera

View file

@ -1,61 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <vector>
#include "common/common_types.h"
#include "core/hle/service/cam/cam.h"
namespace Camera {
/// An abstract class standing for a camera. All camera implementations should inherit from this.
class CameraInterface {
public:
virtual ~CameraInterface();
/// Starts the camera for video capturing.
virtual void StartCapture() = 0;
/// Stops the camera for video capturing.
virtual void StopCapture() = 0;
/**
* Sets the video resolution from raw CAM service parameters.
* For the meaning of the parameters, please refer to Service::CAM::Resolution. Note that the
* actual camera implementation doesn't need to respect all the parameters. However, the width
* and the height parameters must be respected and be used to determine the size of output
* frames.
* @param resolution The resolution parameters to set
*/
virtual void SetResolution(const Service::CAM::Resolution& resolution) = 0;
/**
* Configures how received frames should be flipped by the camera.
* @param flip Flip applying to the frame
*/
virtual void SetFlip(Service::CAM::Flip flip) = 0;
/**
* Configures what effect should be applied to received frames by the camera.
* @param effect Effect applying to the frame
*/
virtual void SetEffect(Service::CAM::Effect effect) = 0;
/**
* Sets the output format of the all frames received after this function is called.
* @param format Output format of the frame
*/
virtual void SetFormat(Service::CAM::OutputFormat format) = 0;
/**
* Receives a frame from the camera.
* This function should be only called between a StartCapture call and a StopCapture call.
* @returns A std::vector<u16> containing pixels. The total size of the vector is width * height
* where width and height are set by a call to SetResolution.
*/
virtual std::vector<u16> ReceiveFrame() const = 0;
};
} // namespace Camera

View file

@ -1,130 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <cstddef>
#include <memory>
#include <type_traits>
#include <unordered_map>
#include "common/assert.h"
#include "common/common_types.h"
#include "core/core_timing.h"
#include "core/hle/applets/applet.h"
#include "core/hle/applets/erreula.h"
#include "core/hle/applets/mii_selector.h"
#include "core/hle/applets/mint.h"
#include "core/hle/applets/swkbd.h"
#include "core/hle/result.h"
#include "core/hle/service/apt/apt.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Specializes std::hash for AppletId, so that we can use it in std::unordered_map.
// Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970
namespace std {
template <>
struct hash<Service::APT::AppletId> {
typedef Service::APT::AppletId argument_type;
typedef std::size_t result_type;
result_type operator()(const argument_type& id_code) const {
typedef std::underlying_type<argument_type>::type Type;
return std::hash<Type>()(static_cast<Type>(id_code));
}
};
}
namespace HLE {
namespace Applets {
static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets;
static u32 applet_update_event =
-1; ///< The CoreTiming event identifier for the Applet update callback.
/// The interval at which the Applet update callback will be called, 16.6ms
static const u64 applet_update_interval_us = 16666;
ResultCode Applet::Create(Service::APT::AppletId id) {
switch (id) {
case Service::APT::AppletId::SoftwareKeyboard1:
case Service::APT::AppletId::SoftwareKeyboard2:
applets[id] = std::make_shared<SoftwareKeyboard>(id);
break;
case Service::APT::AppletId::Ed1:
case Service::APT::AppletId::Ed2:
applets[id] = std::make_shared<MiiSelector>(id);
break;
case Service::APT::AppletId::Error:
case Service::APT::AppletId::Error2:
applets[id] = std::make_shared<ErrEula>(id);
break;
case Service::APT::AppletId::Mint:
case Service::APT::AppletId::Mint2:
applets[id] = std::make_shared<Mint>(id);
break;
default:
LOG_ERROR(Service_APT, "Could not create applet %u", id);
// TODO(Subv): Find the right error code
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
ErrorSummary::NotSupported, ErrorLevel::Permanent);
}
return RESULT_SUCCESS;
}
std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) {
auto itr = applets.find(id);
if (itr != applets.end())
return itr->second;
return nullptr;
}
/// Handles updating the current Applet every time it's called.
static void AppletUpdateEvent(u64 applet_id, int cycles_late) {
Service::APT::AppletId id = static_cast<Service::APT::AppletId>(applet_id);
std::shared_ptr<Applet> applet = Applet::Get(id);
ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id=%08X", id);
applet->Update();
// If the applet is still running after the last update, reschedule the event
if (applet->IsRunning()) {
CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us) - cycles_late,
applet_update_event, applet_id);
} else {
// Otherwise the applet has terminated, in which case we should clean it up
applets[id] = nullptr;
}
}
ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter) {
ResultCode result = StartImpl(parameter);
if (result.IsError())
return result;
// Schedule the update event
CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event,
static_cast<u64>(id));
return result;
}
bool Applet::IsRunning() const {
return is_running;
}
bool IsLibraryAppletRunning() {
// Check the applets map for instances of any applet
for (auto itr = applets.begin(); itr != applets.end(); ++itr)
if (itr->second != nullptr)
return true;
return false;
}
void Init() {
// Register the applet update callback
applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent);
}
void Shutdown() {
CoreTiming::RemoveEvent(applet_update_event);
}
}
} // namespace

View file

@ -1,83 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include "core/hle/result.h"
#include "core/hle/service/apt/apt.h"
namespace HLE {
namespace Applets {
class Applet {
public:
virtual ~Applet() = default;
/**
* Creates an instance of the Applet subclass identified by the parameter.
* and stores it in a global map.
* @param id Id of the applet to create.
* @returns ResultCode Whether the operation was successful or not.
*/
static ResultCode Create(Service::APT::AppletId id);
/**
* Retrieves the Applet instance identified by the specified id.
* @param id Id of the Applet to retrieve.
* @returns Requested Applet or nullptr if not found.
*/
static std::shared_ptr<Applet> Get(Service::APT::AppletId id);
/**
* Handles a parameter from the application.
* @param parameter Parameter data to handle.
* @returns ResultCode Whether the operation was successful or not.
*/
virtual ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) = 0;
/**
* Handles the Applet start event, triggered from the application.
* @param parameter Parameter data to handle.
* @returns ResultCode Whether the operation was successful or not.
*/
ResultCode Start(const Service::APT::AppletStartupParameter& parameter);
/**
* Whether the applet is currently executing instead of the host application or not.
*/
bool IsRunning() const;
/**
* Handles an update tick for the Applet, lets it update the screen, send commands, etc.
*/
virtual void Update() = 0;
protected:
explicit Applet(Service::APT::AppletId id) : id(id) {}
/**
* Handles the Applet start event, triggered from the application.
* @param parameter Parameter data to handle.
* @returns ResultCode Whether the operation was successful or not.
*/
virtual ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) = 0;
Service::APT::AppletId id; ///< Id of this Applet
std::shared_ptr<std::vector<u8>> heap_memory; ///< Heap memory for this Applet
/// Whether this applet is currently running instead of the host application or not.
bool is_running = false;
};
/// Returns whether a library applet is currently running
bool IsLibraryAppletRunning();
/// Initializes the HLE applets
void Init();
/// Shuts down the HLE applets
void Shutdown();
}
} // namespace

View file

@ -1,72 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/string_util.h"
#include "core/hle/applets/erreula.h"
#include "core/hle/service/apt/apt.h"
namespace HLE {
namespace Applets {
ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != static_cast<u32>(Service::APT::SignalType::Request)) {
LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
}
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
// memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer.size());
memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
// TODO: allocated memory never released
using Kernel::MemoryPermission;
// Allocate a heap block of the required size for this applet.
heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
// Create a SharedMemory that directly points to this heap block.
framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
heap_memory, 0, capture_info.size, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
"ErrEula Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
result.signal = static_cast<u32>(Service::APT::SignalType::Response);
result.buffer.clear();
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
result.sender_id = static_cast<u32>(id);
result.object = framebuffer_memory;
Service::APT::SendParameter(result);
return RESULT_SUCCESS;
}
ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
is_running = true;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
// application.
// TODO(Subv): Reverse the parameter format for the ErrEula applet
// Let the application know that we're closing
Service::APT::MessageParameter message;
message.buffer.resize(parameter.buffer.size());
std::fill(message.buffer.begin(), message.buffer.end(), 0);
message.signal = static_cast<u32>(Service::APT::SignalType::WakeupByExit);
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
message.sender_id = static_cast<u32>(id);
Service::APT::SendParameter(message);
is_running = false;
return RESULT_SUCCESS;
}
void ErrEula::Update() {}
} // namespace Applets
} // namespace HLE

View file

@ -1,29 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/applets/applet.h"
#include "core/hle/kernel/shared_memory.h"
namespace HLE {
namespace Applets {
class ErrEula final : public Applet {
public:
explicit ErrEula(Service::APT::AppletId id) : Applet(id) {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override;
private:
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
/// It holds the framebuffer info retrieved by the application with
/// GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
};
} // namespace Applets
} // namespace HLE

View file

@ -1,86 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <cstring>
#include <string>
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/string_util.h"
#include "core/hle/applets/mii_selector.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/result.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace HLE {
namespace Applets {
ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != static_cast<u32>(Service::APT::SignalType::Request)) {
LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
}
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
// memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer.size());
memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
using Kernel::MemoryPermission;
// Allocate a heap block of the required size for this applet.
heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
// Create a SharedMemory that directly points to this heap block.
framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
heap_memory, 0, capture_info.size, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
"MiiSelector Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
result.signal = static_cast<u32>(Service::APT::SignalType::Response);
result.buffer.clear();
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
result.sender_id = static_cast<u32>(id);
result.object = framebuffer_memory;
Service::APT::SendParameter(result);
return RESULT_SUCCESS;
}
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
is_running = true;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
// application.
// TODO(Subv): Reverse the parameter format for the Mii Selector
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
// TODO(Subv): Find more about this structure, result code 0 is enough to let most games
// continue.
MiiResult result;
memset(&result, 0, sizeof(result));
result.return_code = 0;
// Let the application know that we're closing
Service::APT::MessageParameter message;
message.buffer.resize(sizeof(MiiResult));
std::memcpy(message.buffer.data(), &result, message.buffer.size());
message.signal = static_cast<u32>(Service::APT::SignalType::WakeupByExit);
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
message.sender_id = static_cast<u32>(id);
Service::APT::SendParameter(message);
is_running = false;
return RESULT_SUCCESS;
}
void MiiSelector::Update() {}
} // namespace Applets
} // namespace HLE

View file

@ -1,78 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "core/hle/applets/applet.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/result.h"
#include "core/hle/service/apt/apt.h"
namespace HLE {
namespace Applets {
struct MiiConfig {
u8 enable_cancel_button;
u8 enable_guest_mii;
u8 show_on_top_screen;
INSERT_PADDING_BYTES(5);
u16 title[0x40];
INSERT_PADDING_BYTES(4);
u8 show_guest_miis;
INSERT_PADDING_BYTES(3);
u32 initially_selected_mii_index;
u8 guest_mii_whitelist[6];
u8 user_mii_whitelist[0x64];
INSERT_PADDING_BYTES(2);
u32 magic_value;
};
static_assert(sizeof(MiiConfig) == 0x104, "MiiConfig structure has incorrect size");
#define ASSERT_REG_POSITION(field_name, position) \
static_assert(offsetof(MiiConfig, field_name) == position, \
"Field " #field_name " has invalid position")
ASSERT_REG_POSITION(title, 0x08);
ASSERT_REG_POSITION(show_guest_miis, 0x8C);
ASSERT_REG_POSITION(initially_selected_mii_index, 0x90);
ASSERT_REG_POSITION(guest_mii_whitelist, 0x94);
#undef ASSERT_REG_POSITION
struct MiiResult {
u32 return_code;
u32 is_guest_mii_selected;
u32 selected_guest_mii_index;
// TODO(mailwl): expand to Mii Format structure: https://www.3dbrew.org/wiki/Mii
u8 selected_mii_data[0x5C];
INSERT_PADDING_BYTES(2);
u16 mii_data_checksum;
u16 guest_mii_name[0xC];
};
static_assert(sizeof(MiiResult) == 0x84, "MiiResult structure has incorrect size");
#define ASSERT_REG_POSITION(field_name, position) \
static_assert(offsetof(MiiResult, field_name) == position, \
"Field " #field_name " has invalid position")
ASSERT_REG_POSITION(selected_mii_data, 0x0C);
ASSERT_REG_POSITION(guest_mii_name, 0x6C);
#undef ASSERT_REG_POSITION
class MiiSelector final : public Applet {
public:
MiiSelector(Service::APT::AppletId id) : Applet(id) {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override;
private:
/// This SharedMemory will be created when we receive the LibAppJustStarted message.
/// It holds the framebuffer info retrieved by the application with
/// GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
MiiConfig config;
};
} // namespace Applets
} // namespace HLE

View file

@ -1,72 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/string_util.h"
#include "core/hle/applets/mint.h"
#include "core/hle/service/apt/apt.h"
namespace HLE {
namespace Applets {
ResultCode Mint::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != static_cast<u32>(Service::APT::SignalType::Request)) {
LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
}
// The Request message contains a buffer with the size of the framebuffer shared
// memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer.size());
memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
// TODO: allocated memory never released
using Kernel::MemoryPermission;
// Allocate a heap block of the required size for this applet.
heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
// Create a SharedMemory that directly points to this heap block.
framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
heap_memory, 0, capture_info.size, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
"Mint Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result;
result.signal = static_cast<u32>(Service::APT::SignalType::Response);
result.buffer.clear();
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
result.sender_id = static_cast<u32>(id);
result.object = framebuffer_memory;
Service::APT::SendParameter(result);
return RESULT_SUCCESS;
}
ResultCode Mint::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
is_running = true;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
// application.
// TODO(Subv): Reverse the parameter format for the Mint applet
// Let the application know that we're closing
Service::APT::MessageParameter message;
message.buffer.resize(parameter.buffer.size());
std::fill(message.buffer.begin(), message.buffer.end(), 0);
message.signal = static_cast<u32>(Service::APT::SignalType::WakeupByExit);
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
message.sender_id = static_cast<u32>(id);
Service::APT::SendParameter(message);
is_running = false;
return RESULT_SUCCESS;
}
void Mint::Update() {}
} // namespace Applets
} // namespace HLE

View file

@ -1,29 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/applets/applet.h"
#include "core/hle/kernel/shared_memory.h"
namespace HLE {
namespace Applets {
class Mint final : public Applet {
public:
explicit Mint(Service::APT::AppletId id) : Applet(id) {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override;
private:
/// This SharedMemory will be created when we receive the Request message.
/// It holds the framebuffer info retrieved by the application with
/// GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
};
} // namespace Applets
} // namespace HLE

Some files were not shown because too many files have changed in this diff Show more