This commit is contained in:
Narr the Reg 2023-10-13 09:58:10 -06:00
parent 7843915b71
commit 971f0a395b
15 changed files with 365 additions and 175 deletions

View File

@ -513,6 +513,8 @@ add_library(core STATIC
hle/service/hid/hid.h
hle/service/hid/hid_debug_server.cpp
hle/service/hid/hid_debug_server.h
hle/service/hid/hid_firmware_settings.cpp
hle/service/hid/hid_firmware_settings.h
hle/service/hid/hid_result.h
hle/service/hid/hid_server.cpp
hle/service/hid/hid_server.h

View File

@ -11,15 +11,18 @@
#include "core/hle/service/hid/resource_manager.h"
#include "core/hle/service/hid/xcd.h"
#include "core/hle/service/server_manager.h"
#include "core/hle/service/hid/hid_firmware_settings.h"
namespace Service::HID {
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
std::shared_ptr<ResourceManager> resouce_manager = std::make_shared<ResourceManager>(system);
std::shared_ptr<HidFirmwareSettings> firmware_settings =
std::make_shared<HidFirmwareSettings>();
server_manager->RegisterNamedService("hid",
std::make_shared<IHidServer>(system, resouce_manager));
server_manager->RegisterNamedService(
"hid", std::make_shared<IHidServer>(system, resouce_manager, firmware_settings));
server_manager->RegisterNamedService(
"hid:dbg", std::make_shared<IHidDebugServer>(system, resouce_manager));
server_manager->RegisterNamedService(

View File

@ -326,11 +326,7 @@ void IHidDebugServer::GetGyroscopeOdr(HLERequestContext& ctx) {}
void IHidDebugServer::SetGyroscopeOdr(HLERequestContext& ctx) {}
std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() {
if (!is_resource_manager_initialized) {
resource_manager->Initialize();
is_resource_manager_initialized = true;
}
resource_manager->VerifiyInitalization();
return resource_manager;
}

View File

@ -36,8 +36,6 @@ private:
std::shared_ptr<ResourceManager> GetResourceManager();
bool is_resource_manager_initialized{};
std::shared_ptr<ResourceManager> resource_manager = nullptr;
};

View File

@ -0,0 +1,148 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/hid/hid_firmware_settings.h"
namespace Service::HID {
HidFirmwareSettings::HidFirmwareSettings() {
LoadSettings(true);
}
void HidFirmwareSettings::Reload() {
LoadSettings(true);
}
void HidFirmwareSettings::LoadSettings(bool should_initialize) {
// TODO: uncomment this code when we can talk between services
if (is_debug_settings_initalized && !should_initialize) {
return;
}
is_debugpad_enabled = true;
// nn::settings::fwdbg::GetSettingsItemValue(&is_debugpad_enabled, 1, "hid_debug",
// "enables_debugpad")
is_device_managed = true;
// nn::settings::fwdbg::GetSettingsItemValue(&is_device_managed, 1, "hid_debug",
// "manages_devices");
is_touch_i2c_managed = is_device_managed;
if (is_device_managed) {
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_manages_touch_ic_i2c, 1,
// "hid_debug", "manages_touch_ic_i2c");
}
is_future_devices_emulated = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_emulate_future_device, 1,
// "hid_debug", "emulate_future_device");
is_mcu_hardware_error_emulated = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_emulate_mcu_hardware_error, 1,
// "hid_debug", "emulate_mcu_hardware_error");
is_rail_enabled = true;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_enables_rail, 1, "hid_debug",
// "enables_rail");
is_firmware_update_failure_emulated = false;
// nn::settings::fwdbg::GetSettingsItemValue(setting_hid_debug_emulate_firmware_update_failure,
// 1, "hid_debug", "emulate_firmware_update_failure");
is_firmware_update_failure = {};
if (is_firmware_update_failure_emulated) {
const std::size_t size = 0; // GetSettingsItemValueSize("hid_debug",
// "firmware_update_failure"); if (size != 0) {
[[maybe_unused]] const std::size_t setting_size =
std::min(size, is_firmware_update_failure.size());
// nn::settings::fwdbg::GetSettingsItemValue(&is_firmware_update_failure, setting_size,
// "hid_debug", "firmware_update_failure");
//}
}
is_ble_disabled = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_ble_disabled, 1, "hid_debug",
// "ble_disabled");
is_dscale_disabled = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_dscale_disabled, 1, "hid_debug",
// "dscale_disabled");
is_handheld_forced = true;
// nn::settings::fwdbg::GetSettingsItemValue(&force_handheld, 1, "hid_debug", "force_handheld");
features_per_id_disabled = {};
// nn::settings::fwdbg::GetSettingsItemValue(&disabled_features_per_id,
// is_features_per_id_disabled.size(), "hid_debug",
// "disabled_features_per_id");
is_touch_firmware_auto_update_disabled = false;
// nn::settings::fwdbg::GetSettingsItemValue(
// &setting_hid_debug_touch_firmware_auto_update_disabled, 1, "hid_debug",
// "touch_firmware_auto_update_disabled");
is_debug_settings_initalized = true;
}
bool HidFirmwareSettings::IsDebugPadEnabled() {
LoadSettings(false);
return is_debugpad_enabled;
}
bool HidFirmwareSettings::IsDeviceManaged() {
LoadSettings(false);
return is_device_managed;
}
bool HidFirmwareSettings::IsEmulateFutureDevice() {
LoadSettings(false);
return is_future_devices_emulated;
}
bool HidFirmwareSettings::IsTouchI2cManaged() {
LoadSettings(false);
return is_touch_i2c_managed;
}
bool HidFirmwareSettings::IsHandheldForced() {
LoadSettings(false);
return is_handheld_forced;
}
bool HidFirmwareSettings::IsRailEnabled() {
LoadSettings(false);
return is_rail_enabled;
}
bool HidFirmwareSettings::IsHardwareErrorEmulated() {
LoadSettings(false);
return is_mcu_hardware_error_emulated;
}
bool HidFirmwareSettings::IsBleDisabled() {
LoadSettings(false);
return is_ble_disabled;
}
bool HidFirmwareSettings::IsDscaleDisabled() {
LoadSettings(false);
return is_dscale_disabled;
}
bool HidFirmwareSettings::IsTouchAutoUpdateDisabled() {
LoadSettings(false);
return is_touch_firmware_auto_update_disabled;
}
HidFirmwareSettings::FirmwareSetting HidFirmwareSettings::GetFirmwareUpdateFailure() {
LoadSettings(false);
return is_firmware_update_failure;
}
HidFirmwareSettings::FeaturesPerId HidFirmwareSettings::FeaturesDisabledPerId() {
LoadSettings(false);
return features_per_id_disabled;
}
} // namespace Service::HID

View File

@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_types.h"
namespace Service::HID {
/// Loads firmware config from nn::settings::fwdbg
class HidFirmwareSettings {
public:
using FirmwareSetting = std::array<u8, 4>;
using FeaturesPerId = std::array<bool, 0xA8>;
HidFirmwareSettings();
void Reload();
void LoadSettings(bool should_initialize);
bool IsDebugPadEnabled();
bool IsDeviceManaged();
bool IsEmulateFutureDevice();
bool IsTouchI2cManaged();
bool IsHandheldForced();
bool IsRailEnabled();
bool IsHardwareErrorEmulated();
bool IsBleDisabled();
bool IsDscaleDisabled();
bool IsTouchAutoUpdateDisabled();
FirmwareSetting GetFirmwareUpdateFailure();
FeaturesPerId FeaturesDisabledPerId();
private:
bool is_debug_settings_initalized{};
// Debug settings
bool is_debugpad_enabled{};
bool is_device_managed{};
bool is_touch_i2c_managed{};
bool is_future_devices_emulated{};
bool is_mcu_hardware_error_emulated{};
bool is_rail_enabled{};
bool is_firmware_update_failure_emulated{};
bool is_ble_disabled{};
bool is_dscale_disabled{};
bool is_handheld_forced{};
bool is_touch_firmware_auto_update_disabled{};
FirmwareSetting is_firmware_update_failure{};
FeaturesPerId features_per_id_disabled{};
};
} // namespace Service::HID

View File

@ -19,6 +19,7 @@
#include "core/hle/service/hid/resource_manager/palma.h"
#include "core/hle/service/hid/resource_manager/sixaxis.h"
#include "core/hle/service/hid/resource_manager/touch_screen.h"
#include "core/hle/service/hid/hid_firmware_settings.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::HID {
@ -70,15 +71,16 @@ void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) {
rb.PushCopyObjects(&system.Kernel().GetHidSharedMem());
}
IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource)
: ServiceFramework{system_, "hid"}, resource_manager{resource} {
IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
std::shared_ptr<HidFirmwareSettings> settings)
: ServiceFramework{system_, "hid"}, resource_manager{resource}, firmware_settings{settings} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IHidServer::CreateAppletResource, "CreateAppletResource"},
{1, &IHidServer::ActivateDebugPad, "ActivateDebugPad"},
{11, &IHidServer::ActivateTouchScreen, "ActivateTouchScreen"},
{21, &IHidServer::ActivateMouse, "ActivateMouse"},
{26, nullptr, "ActivateDebugMouse"},
{26, &IHidServer::ActivateDebugMouse, "ActivateDebugMouse"},
{31, &IHidServer::ActivateKeyboard, "ActivateKeyboard"},
{32, &IHidServer::SendKeyboardLockKeyEvent, "SendKeyboardLockKeyEvent"},
{40, &IHidServer::AcquireXpadIdEventHandle, "AcquireXpadIdEventHandle"},
@ -258,7 +260,7 @@ void IHidServer::ActivateDebugPad(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto debug_pad = GetResourceManager()->GetDebugPad();
if (IsDeviceManaged()) {
if (firmware_settings->IsDeviceManaged()) {
result = debug_pad->Activate(applet_resource_user_id);
} else {
result = debug_pad->Activate();
@ -277,7 +279,7 @@ void IHidServer::ActivateTouchScreen(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto touch_screen = GetResourceManager()->GetTouchScreen();
if (IsDeviceManaged()) {
if (firmware_settings->IsDeviceManaged()) {
result = touch_screen->Activate(applet_resource_user_id);
} else {
result = touch_screen->Activate();
@ -296,7 +298,26 @@ void IHidServer::ActivateMouse(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto mouse = GetResourceManager()->GetMouse();
if (IsDeviceManaged()) {
if (firmware_settings->IsDeviceManaged()) {
result = mouse->Activate(applet_resource_user_id);
} else {
result = mouse->Activate();
}
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::ActivateDebugMouse(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
Result result = ResultSuccess;
auto mouse = GetResourceManager()->GetDebugMouse();
if (firmware_settings->IsDeviceManaged()) {
result = mouse->Activate(applet_resource_user_id);
} else {
result = mouse->Activate();
@ -315,7 +336,7 @@ void IHidServer::ActivateKeyboard(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto keyboard = GetResourceManager()->GetKeyboard();
if (IsDeviceManaged()) {
if (firmware_settings->IsDeviceManaged()) {
result = keyboard->Activate(applet_resource_user_id);
} else {
result = keyboard->Activate();
@ -325,7 +346,20 @@ void IHidServer::ActivateKeyboard(HLERequestContext& ctx) {
rb.Push(result);
}
void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) {}
void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto keyboard_lock_key_event{rp.Pop<u32>()};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, keyboard_lock_key_event={}, applet_resource_user_id={}",
keyboard_lock_key_event, applet_resource_user_id);
const Result result =
GetResourceManager()->GetKeyboard()->SendKeyboardLockKeyEvent(keyboard_lock_key_event);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::AcquireXpadIdEventHandle(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
@ -978,13 +1012,13 @@ void IHidServer::IsSixAxisSensorAtRest(HLERequestContext& ctx) {
parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
// const auto npad = GetResourceManager()->GetNpad();
// const auto sixaxis = npad()->GetNpadSharedMemory(parameters.sixaxis_handle);
// const bool is_at_rest = sixaxis->IsAtRest();
const auto sixaxis_sensor_state =
GetResourceManager()->GetNpad()->GetSixAxisSensorState(parameters.sixaxis_handle);
const bool is_at_rest = sixaxis_sensor_state.IsAtRest();
// IPC::ResponseBuilder rb{ctx, 3};
// rb.Push(ResultSuccess);
// rb.Push<u8>(is_at_rest);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u8>(is_at_rest);
}
void IHidServer::IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx) {
@ -1094,20 +1128,21 @@ void IHidServer::StoreSixAxisSensorCalibrationParameter(HLERequestContext& ctx)
parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
// SixAxisSensorCalibrationParameter calibration{};
// const auto npad = GetResourceManager()->GetNpad();
// const auto sixaxis = npad()->GetNpadSharedMemory(parameters.sixaxis_handle);
const auto sixaxis_config =
GetResourceManager()->GetNpad()->GetSixAxisSensorConfig(parameters.sixaxis_handle);
// if (sixaxis == nullptr) {
// IPC::ResponseBuilder rb{ctx, 2};
// rb.Push(ResultUnknown108);
// }
if (sixaxis_config == nullptr) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown108);
return;
}
// memcpy(&calibration, buffer.data(), sizeof(SixAxisSensorCalibrationParameter));
// const auto result = sixaxis.StoreSixAxisSensorCalibrationParameter(calibration);
SixAxisSensorCalibrationParameter calibration{};
memcpy(&calibration, buffer.data(), sizeof(SixAxisSensorCalibrationParameter));
const auto result = ResultSuccess; // sixaxis_config.StoreSixAxisSensorCalibrationParameter(calibration);
// IPC::ResponseBuilder rb{ctx, 2};
// rb.Push(result);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx) {
@ -1127,23 +1162,25 @@ void IHidServer::LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx) {
parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
// SixAxisSensorCalibrationParameter calibration{};
// const auto npad = GetResourceManager()->GetNpad();
// const auto sixaxis = npad()->GetNpadSharedMemory(parameters.sixaxis_handle);
const auto sixaxis_config =
GetResourceManager()->GetNpad()->GetSixAxisSensorConfig(parameters.sixaxis_handle);
// if (sixaxis == nullptr) {
// IPC::ResponseBuilder rb{ctx, 2};
// rb.Push(ResultUnknown108);
// }
if (sixaxis_config == nullptr) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown108);
return;
}
// const auto result = sixaxis.LoadSixAxisSensorCalibrationParameter(calibration);
SixAxisSensorCalibrationParameter calibration{};
const auto result =
ResultSuccess; // sixaxis_config.LoadSixAxisSensorCalibrationParameter(calibration);
// if (result.IsSuccess()) {
// ctx.WriteBuffer(calibration);
// }
if (result.IsSuccess()) {
ctx.WriteBuffer(calibration);
}
// IPC::ResponseBuilder rb{ctx, 2};
// rb.Push(result);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::GetSixAxisSensorIcInformation(HLERequestContext& ctx) {
@ -1163,23 +1200,24 @@ void IHidServer::GetSixAxisSensorIcInformation(HLERequestContext& ctx) {
parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
// SixAxisSensorIcInformation ic_information{};
// const auto npad = GetResourceManager()->GetNpad();
// const auto sixaxis = npad()->GetNpadSharedMemory(parameters.sixaxis_handle);
const auto sixaxis_config =
GetResourceManager()->GetNpad()->GetSixAxisSensorConfig(parameters.sixaxis_handle);
// if (sixaxis == nullptr) {
// IPC::ResponseBuilder rb{ctx, 2};
// rb.Push(ResultUnknown108);
// }
if (sixaxis_config == nullptr) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultUnknown108);
return;
}
// const auto result = sixaxis.GetSixAxisSensorIcInformation(ic_information);
SixAxisSensorIcInformation ic_information{};
const auto result = ResultSuccess; // sixaxis.GetSixAxisSensorIcInformation(ic_information);
// if (result.IsSuccess()) {
// ctx.WriteBuffer(ic_information);
// }
if (result.IsSuccess()) {
ctx.WriteBuffer(ic_information);
}
// IPC::ResponseBuilder rb{ctx, 2};
// rb.Push(result);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx) {
@ -1224,7 +1262,7 @@ void IHidServer::ActivateGesture(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto gesture = GetResourceManager()->GetGesture();
if (IsDeviceManaged()) {
if (firmware_settings->IsDeviceManaged()) {
result = gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
} else {
result = gesture->Activate();
@ -2128,7 +2166,7 @@ void IHidServer::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto sixaxis = GetResourceManager()->GetConsoleSixAxis();
// if (IsDeviceManaged()) {
// if (firmware_settings->IsDeviceManaged()) {
// result = sixaxis->Activate(applet_resource_user_id);
// } else {
// result = sixaxis->Activate();
@ -2177,7 +2215,7 @@ void IHidServer::ActivateSevenSixAxisSensor(HLERequestContext& ctx) {
Result result = ResultSuccess;
auto sixaxis = GetResourceManager()->GetConsoleSixAxis();
// if (IsDeviceManaged()) {
// if (firmware_settings->IsDeviceManaged()) {
// result = sixaxis->Activate(applet_resource_user_id);
// } else {
// result = sixaxis->Activate();
@ -2854,89 +2892,8 @@ void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {
void IHidServer::ActivateDigitizer(HLERequestContext& ctx) {}
bool IHidServer::IsDeviceManaged() {
InitializeDebugSettings();
return is_device_managed;
}
void IHidServer::InitializeDebugSettings() {
if (is_debug_settings_initalized) {
return;
}
// TODO: uncomment this code when we can talk between services
is_debugpad_enabled = true;
// nn::settings::fwdbg::GetSettingsItemValue(&is_debugpad_enabled, 1, "hid_debug",
// "enables_debugpad")
is_device_managed = true;
// nn::settings::fwdbg::GetSettingsItemValue(&is_device_managed, 1, "hid_debug",
// "manages_devices");
is_touch_i2c_managed = is_device_managed;
if (is_device_managed) {
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_manages_touch_ic_i2c, 1,
// "hid_debug", "manages_touch_ic_i2c");
}
is_future_devices_emulated = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_emulate_future_device, 1,
// "hid_debug", "emulate_future_device");
is_mcu_hardware_error_emulated = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_emulate_mcu_hardware_error, 1,
// "hid_debug", "emulate_mcu_hardware_error");
is_rail_enabled = true;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_enables_rail, 1, "hid_debug",
// "enables_rail");
is_firmware_update_failure_emulated = false;
// nn::settings::fwdbg::GetSettingsItemValue(setting_hid_debug_emulate_firmware_update_failure,
// 1, "hid_debug", "emulate_firmware_update_failure");
is_firmware_update_failure = {};
if (is_firmware_update_failure_emulated) {
const std::size_t size = 0; // GetSettingsItemValueSize("hid_debug",
// "firmware_update_failure"); if (size != 0) {
[[maybe_unused]] const std::size_t setting_size =
std::min(size, is_firmware_update_failure.size());
// nn::settings::fwdbg::GetSettingsItemValue(&is_firmware_update_failure, setting_size,
// "hid_debug", "firmware_update_failure");
//}
}
is_ble_disabled = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_ble_disabled, 1, "hid_debug",
// "ble_disabled");
is_dscale_disabled = false;
// nn::settings::fwdbg::GetSettingsItemValue(&setting_hid_debug_dscale_disabled, 1, "hid_debug",
// "dscale_disabled");
is_handheld_forced = true;
// nn::settings::fwdbg::GetSettingsItemValue(&force_handheld, 1, "hid_debug", "force_handheld");
is_features_per_id_disabled = {};
// nn::settings::fwdbg::GetSettingsItemValue(&disabled_features_per_id,
// is_features_per_id_disabled.size(), "hid_debug",
// "disabled_features_per_id");
is_touch_firmware_auto_update_disabled = false;
// nn::settings::fwdbg::GetSettingsItemValue(
// &setting_hid_debug_touch_firmware_auto_update_disabled, 1, "hid_debug",
// "touch_firmware_auto_update_disabled");
is_debug_settings_initalized = true;
}
std::shared_ptr<ResourceManager> IHidServer::GetResourceManager() {
if (!is_resource_manager_initialized) {
resource_manager->Initialize();
is_resource_manager_initialized = true;
}
resource_manager->VerifiyInitalization();
return resource_manager;
}

View File

@ -14,6 +14,7 @@ struct VibrationDeviceHandle;
struct VibrationValue;
class ResourceManager;
class HidFirmwareSettings;
} // namespace Service::HID
namespace Service::HID {
@ -41,15 +42,16 @@ private:
class IHidServer final : public ServiceFramework<IHidServer> {
public:
explicit IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource);
explicit IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
std::shared_ptr<HidFirmwareSettings> settings);
~IHidServer() override;
private:
// Service calls
void CreateAppletResource(HLERequestContext& ctx);
void ActivateDebugPad(HLERequestContext& ctx);
void ActivateTouchScreen(HLERequestContext& ctx);
void ActivateMouse(HLERequestContext& ctx);
void ActivateDebugMouse(HLERequestContext& ctx);
void ActivateKeyboard(HLERequestContext& ctx);
void SendKeyboardLockKeyEvent(HLERequestContext& ctx);
void AcquireXpadIdEventHandle(HLERequestContext& ctx);
@ -189,31 +191,11 @@ private:
Result SendVibrationValueImpl(const u64 aruid, const VibrationDeviceHandle& handle,
const VibrationValue& value);
bool IsDeviceManaged();
void InitializeDebugSettings();
std::shared_ptr<ResourceManager> GetResourceManager();
// Server state
bool is_debug_settings_initalized{};
bool is_resource_manager_initialized{};
// Debug settings
bool is_debugpad_enabled{};
bool is_device_managed{};
bool is_touch_i2c_managed{};
bool is_future_devices_emulated{};
bool is_mcu_hardware_error_emulated{};
bool is_rail_enabled{};
bool is_firmware_update_failure_emulated{};
std::array<u8, 4> is_firmware_update_failure{};
bool is_ble_disabled{};
bool is_dscale_disabled{};
bool is_handheld_forced{};
std::array<bool, 0xA8> is_features_per_id_disabled{};
bool is_touch_firmware_auto_update_disabled{};
std::shared_ptr<ResourceManager> resource_manager = nullptr;
std::shared_ptr<IAppletResource> applet_resource = nullptr;
std::shared_ptr<HidFirmwareSettings> firmware_settings = nullptr;
};
} // namespace Service::HID

View File

@ -396,11 +396,7 @@ void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx
}
std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() {
if (!is_resource_manager_initialized) {
resource_manager->Initialize();
is_resource_manager_initialized = true;
}
resource_manager->VerifiyInitalization();
return resource_manager;
}

View File

@ -33,8 +33,6 @@ private:
std::shared_ptr<ResourceManager> GetResourceManager();
bool is_resource_manager_initialized{};
std::shared_ptr<ResourceManager> resource_manager = nullptr;
};

View File

@ -83,6 +83,14 @@ void ResourceManager::Initialize() {
palma = std::make_shared<Palma>();
sixaxis = std::make_shared<SixAxis>();
touch_screen = std::make_shared<TouchScreen>();
is_initialized = true;
}
void ResourceManager::VerifiyInitalization() {
if (!is_initialized) {
Initialize();
}
}
Result ResourceManager::GetVibrationDeviceInfo(VibrationDeviceInfo& out_device_info,
@ -182,6 +190,10 @@ std::shared_ptr<Mouse> ResourceManager::GetMouse() {
return mouse;
}
std::shared_ptr<Mouse> ResourceManager::GetDebugMouse() {
return debug_mouse;
}
std::shared_ptr<Npad> ResourceManager::GetNpad() {
return npad;
}

View File

@ -33,6 +33,7 @@ public:
~ResourceManager();
void Initialize();
void VerifiyInitalization();
Result GetVibrationDeviceInfo(VibrationDeviceInfo& out_device_info,
const VibrationDeviceHandle& handle) const;
@ -42,6 +43,7 @@ public:
std::shared_ptr<Gesture> GetGesture();
std::shared_ptr<Keyboard> GetKeyboard();
std::shared_ptr<Mouse> GetMouse();
std::shared_ptr<Mouse> GetDebugMouse();
std::shared_ptr<Npad> GetNpad();
std::shared_ptr<Palma> GetPalma();
std::shared_ptr<SixAxis> GetSixAxis();
@ -52,10 +54,13 @@ public:
std::shared_ptr<Vibration> GetGCVibration(const VibrationDeviceHandle& handle);
std::shared_ptr<Vibration> GetN64Vibration(const VibrationDeviceHandle& handle);
bool is_initialized;
std::shared_ptr<DebugPad> debug_pad = nullptr;
std::shared_ptr<Gesture> gesture = nullptr;
std::shared_ptr<Keyboard> keyboard = nullptr;
std::shared_ptr<Mouse> mouse = nullptr;
std::shared_ptr<Mouse> debug_mouse = nullptr;
std::shared_ptr<Npad> npad = nullptr;
std::shared_ptr<Palma> palma = nullptr;
std::shared_ptr<SixAxis> sixaxis = nullptr;

View File

@ -23,6 +23,8 @@ public:
Result Activate(const u64 aruid);
Result Activate();
Result SendKeyboardLockKeyEvent(const u32 keyboard_lock_key_event);
private:
bool is_activated;
};

View File

@ -281,6 +281,34 @@ Result Npad::ResetIsSixAxisSensorDeviceNewlyAssigned(const u64 aruid,
return ResultSuccess;
}
SixAxisSensorSharedState Npad::GetSixAxisSensorState(const SixAxisSensorHandle& handle) {
auto npad_index = NpadIdTypeToIndex(static_cast<NpadIdType>(handle.device_index));
if (!IsNpadIdValid(static_cast<NpadIdType>(handle.npad_id))) {
return;
}
auto& abtract = abstract_npad_state[npad_index];
if (handle.npad_type == NpadStyleIndex::FullKey) {
}
// TODO: Implement this part
}
std::shared_ptr<SixAxisSensorSharedConfig> Npad::GetSixAxisSensorConfig(const SixAxisSensorHandle& handle) {
auto npad_index = NpadIdTypeToIndex(static_cast<NpadIdType>(handle.device_index));
if (!IsNpadIdValid(static_cast<NpadIdType>(handle.npad_id))) {
return;
}
auto& abtract = abstract_npad_state[npad_index];
if (handle.npad_type == NpadStyleIndex::FullKey) {
}
return
}
void Npad::SetNpadJoyAssignmentModeSingleByDefault(const u64 aruid, const NpadIdType npad_id) {
if (aruid != GetNpadActiveAruid()) {
return;

View File

@ -40,6 +40,12 @@ class NpadState;
namespace Service::HID {
class SixAxisSensorSharedState {
public:
bool IsAtRest() const;
};
class SixAxisSensorSharedConfig {};
class AbstractNpadState {
public:
explicit AbstractNpadState();
@ -108,6 +114,9 @@ public:
bool IsFirmwareUpdateAvailableForSixAxisSensor(const SixAxisSensorHandle& handle) const;
Result ResetIsSixAxisSensorDeviceNewlyAssigned(const u64 aruid,
const SixAxisSensorHandle& handle);
SixAxisSensorSharedState GetSixAxisSensorState(const SixAxisSensorHandle& handle);
std::shared_ptr <
SixAxisSensorSharedConfig> GetSixAxisSensorConfig(const SixAxisSensorHandle& handle);
// Assignment, merge, swap or split npad
void SetNpadJoyAssignmentModeSingleByDefault(const u64 aruid, const NpadIdType npad_id);