diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/controller_base.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/controller_base.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/palma.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_firmware_settings.cpp | 99 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_firmware_settings.h | 54 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.cpp | 146 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/hid/resource_manager.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/hid/resource_manager.h | 2 |
12 files changed, 295 insertions, 54 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 3aa2e4340..555807e19 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -523,6 +523,8 @@ add_library(core STATIC | |||
| 523 | hle/service/hid/hid.h | 523 | hle/service/hid/hid.h |
| 524 | hle/service/hid/hid_debug_server.cpp | 524 | hle/service/hid/hid_debug_server.cpp |
| 525 | hle/service/hid/hid_debug_server.h | 525 | hle/service/hid/hid_debug_server.h |
| 526 | hle/service/hid/hid_firmware_settings.cpp | ||
| 527 | hle/service/hid/hid_firmware_settings.h | ||
| 526 | hle/service/hid/hid_server.cpp | 528 | hle/service/hid/hid_server.cpp |
| 527 | hle/service/hid/hid_server.h | 529 | hle/service/hid/hid_server.h |
| 528 | hle/service/hid/hid_system_server.cpp | 530 | hle/service/hid/hid_system_server.cpp |
diff --git a/src/core/hle/service/hid/controllers/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp index c58d67d7d..0bcd87062 100644 --- a/src/core/hle/service/hid/controllers/controller_base.cpp +++ b/src/core/hle/service/hid/controllers/controller_base.cpp | |||
| @@ -8,12 +8,17 @@ namespace Service::HID { | |||
| 8 | ControllerBase::ControllerBase(Core::HID::HIDCore& hid_core_) : hid_core(hid_core_) {} | 8 | ControllerBase::ControllerBase(Core::HID::HIDCore& hid_core_) : hid_core(hid_core_) {} |
| 9 | ControllerBase::~ControllerBase() = default; | 9 | ControllerBase::~ControllerBase() = default; |
| 10 | 10 | ||
| 11 | void ControllerBase::ActivateController() { | 11 | Result ControllerBase::Activate() { |
| 12 | if (is_activated) { | 12 | if (is_activated) { |
| 13 | return; | 13 | return ResultSuccess; |
| 14 | } | 14 | } |
| 15 | is_activated = true; | 15 | is_activated = true; |
| 16 | OnInit(); | 16 | OnInit(); |
| 17 | return ResultSuccess; | ||
| 18 | } | ||
| 19 | |||
| 20 | Result ControllerBase::Activate(u64 aruid) { | ||
| 21 | return Activate(); | ||
| 17 | } | 22 | } |
| 18 | 23 | ||
| 19 | void ControllerBase::DeactivateController() { | 24 | void ControllerBase::DeactivateController() { |
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h index d6f7a5073..9a44ee41e 100644 --- a/src/core/hle/service/hid/controllers/controller_base.h +++ b/src/core/hle/service/hid/controllers/controller_base.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_types.h" | 6 | #include "common/common_types.h" |
| 7 | #include "core/hle/result.h" | ||
| 7 | 8 | ||
| 8 | namespace Core::Timing { | 9 | namespace Core::Timing { |
| 9 | class CoreTiming; | 10 | class CoreTiming; |
| @@ -31,7 +32,8 @@ public: | |||
| 31 | // When the controller is requesting a motion update for the shared memory | 32 | // When the controller is requesting a motion update for the shared memory |
| 32 | virtual void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) {} | 33 | virtual void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) {} |
| 33 | 34 | ||
| 34 | void ActivateController(); | 35 | Result Activate(); |
| 36 | Result Activate(u64 aruid); | ||
| 35 | 37 | ||
| 36 | void DeactivateController(); | 38 | void DeactivateController(); |
| 37 | 39 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 949e58a4c..e23b4986c 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -86,6 +86,13 @@ public: | |||
| 86 | Default = 3, | 86 | Default = 3, |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | enum class NpadRevision : u32 { | ||
| 90 | Revision0 = 0, | ||
| 91 | Revision1 = 1, | ||
| 92 | Revision2 = 2, | ||
| 93 | Revision3 = 3, | ||
| 94 | }; | ||
| 95 | |||
| 89 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); | 96 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); |
| 90 | Core::HID::NpadStyleTag GetSupportedStyleSet() const; | 97 | Core::HID::NpadStyleTag GetSupportedStyleSet() const; |
| 91 | 98 | ||
diff --git a/src/core/hle/service/hid/controllers/palma.cpp b/src/core/hle/service/hid/controllers/palma.cpp index 73a2a2b91..51a18335f 100644 --- a/src/core/hle/service/hid/controllers/palma.cpp +++ b/src/core/hle/service/hid/controllers/palma.cpp | |||
| @@ -44,7 +44,7 @@ Result Controller_Palma::InitializePalma(const PalmaConnectionHandle& handle) { | |||
| 44 | if (handle.npad_id != active_handle.npad_id) { | 44 | if (handle.npad_id != active_handle.npad_id) { |
| 45 | return InvalidPalmaHandle; | 45 | return InvalidPalmaHandle; |
| 46 | } | 46 | } |
| 47 | ActivateController(); | 47 | Activate(); |
| 48 | return ResultSuccess; | 48 | return ResultSuccess; |
| 49 | } | 49 | } |
| 50 | 50 | ||
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 801a4d08f..1b7381d8d 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "core/hle/service/hid/hid.h" | 4 | #include "core/hle/service/hid/hid.h" |
| 5 | #include "core/hle/service/hid/hid_debug_server.h" | 5 | #include "core/hle/service/hid/hid_debug_server.h" |
| 6 | #include "core/hle/service/hid/hid_firmware_settings.h" | ||
| 6 | #include "core/hle/service/hid/hid_server.h" | 7 | #include "core/hle/service/hid/hid_server.h" |
| 7 | #include "core/hle/service/hid/hid_system_server.h" | 8 | #include "core/hle/service/hid/hid_system_server.h" |
| 8 | #include "core/hle/service/hid/hidbus.h" | 9 | #include "core/hle/service/hid/hidbus.h" |
| @@ -16,9 +17,11 @@ namespace Service::HID { | |||
| 16 | void LoopProcess(Core::System& system) { | 17 | void LoopProcess(Core::System& system) { |
| 17 | auto server_manager = std::make_unique<ServerManager>(system); | 18 | auto server_manager = std::make_unique<ServerManager>(system); |
| 18 | std::shared_ptr<ResourceManager> resouce_manager = std::make_shared<ResourceManager>(system); | 19 | std::shared_ptr<ResourceManager> resouce_manager = std::make_shared<ResourceManager>(system); |
| 20 | std::shared_ptr<HidFirmwareSettings> firmware_settings = | ||
| 21 | std::make_shared<HidFirmwareSettings>(); | ||
| 19 | 22 | ||
| 20 | server_manager->RegisterNamedService("hid", | 23 | server_manager->RegisterNamedService( |
| 21 | std::make_shared<IHidServer>(system, resouce_manager)); | 24 | "hid", std::make_shared<IHidServer>(system, resouce_manager, firmware_settings)); |
| 22 | server_manager->RegisterNamedService( | 25 | server_manager->RegisterNamedService( |
| 23 | "hid:dbg", std::make_shared<IHidDebugServer>(system, resouce_manager)); | 26 | "hid:dbg", std::make_shared<IHidDebugServer>(system, resouce_manager)); |
| 24 | server_manager->RegisterNamedService( | 27 | server_manager->RegisterNamedService( |
diff --git a/src/core/hle/service/hid/hid_firmware_settings.cpp b/src/core/hle/service/hid/hid_firmware_settings.cpp new file mode 100644 index 000000000..59bd6825c --- /dev/null +++ b/src/core/hle/service/hid/hid_firmware_settings.cpp | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/hid/hid_firmware_settings.h" | ||
| 5 | |||
| 6 | namespace Service::HID { | ||
| 7 | |||
| 8 | HidFirmwareSettings::HidFirmwareSettings() { | ||
| 9 | LoadSettings(true); | ||
| 10 | } | ||
| 11 | |||
| 12 | void HidFirmwareSettings::Reload() { | ||
| 13 | LoadSettings(true); | ||
| 14 | } | ||
| 15 | |||
| 16 | void HidFirmwareSettings::LoadSettings(bool reload_config) { | ||
| 17 | if (is_initalized && !reload_config) { | ||
| 18 | return; | ||
| 19 | } | ||
| 20 | |||
| 21 | // TODO: Use nn::settings::fwdbg::GetSettingsItemValue to load config values | ||
| 22 | |||
| 23 | is_debug_pad_enabled = true; | ||
| 24 | is_device_managed = true; | ||
| 25 | is_touch_i2c_managed = is_device_managed; | ||
| 26 | is_future_devices_emulated = false; | ||
| 27 | is_mcu_hardware_error_emulated = false; | ||
| 28 | is_rail_enabled = true; | ||
| 29 | is_firmware_update_failure_emulated = false; | ||
| 30 | is_firmware_update_failure = {}; | ||
| 31 | is_ble_disabled = false; | ||
| 32 | is_dscale_disabled = false; | ||
| 33 | is_handheld_forced = true; | ||
| 34 | features_per_id_disabled = {}; | ||
| 35 | is_touch_firmware_auto_update_disabled = false; | ||
| 36 | is_initalized = true; | ||
| 37 | } | ||
| 38 | |||
| 39 | bool HidFirmwareSettings::IsDebugPadEnabled() { | ||
| 40 | LoadSettings(false); | ||
| 41 | return is_debug_pad_enabled; | ||
| 42 | } | ||
| 43 | |||
| 44 | bool HidFirmwareSettings::IsDeviceManaged() { | ||
| 45 | LoadSettings(false); | ||
| 46 | return is_device_managed; | ||
| 47 | } | ||
| 48 | |||
| 49 | bool HidFirmwareSettings::IsEmulateFutureDevice() { | ||
| 50 | LoadSettings(false); | ||
| 51 | return is_future_devices_emulated; | ||
| 52 | } | ||
| 53 | |||
| 54 | bool HidFirmwareSettings::IsTouchI2cManaged() { | ||
| 55 | LoadSettings(false); | ||
| 56 | return is_touch_i2c_managed; | ||
| 57 | } | ||
| 58 | |||
| 59 | bool HidFirmwareSettings::IsHandheldForced() { | ||
| 60 | LoadSettings(false); | ||
| 61 | return is_handheld_forced; | ||
| 62 | } | ||
| 63 | |||
| 64 | bool HidFirmwareSettings::IsRailEnabled() { | ||
| 65 | LoadSettings(false); | ||
| 66 | return is_rail_enabled; | ||
| 67 | } | ||
| 68 | |||
| 69 | bool HidFirmwareSettings::IsHardwareErrorEmulated() { | ||
| 70 | LoadSettings(false); | ||
| 71 | return is_mcu_hardware_error_emulated; | ||
| 72 | } | ||
| 73 | |||
| 74 | bool HidFirmwareSettings::IsBleDisabled() { | ||
| 75 | LoadSettings(false); | ||
| 76 | return is_ble_disabled; | ||
| 77 | } | ||
| 78 | |||
| 79 | bool HidFirmwareSettings::IsDscaleDisabled() { | ||
| 80 | LoadSettings(false); | ||
| 81 | return is_dscale_disabled; | ||
| 82 | } | ||
| 83 | |||
| 84 | bool HidFirmwareSettings::IsTouchAutoUpdateDisabled() { | ||
| 85 | LoadSettings(false); | ||
| 86 | return is_touch_firmware_auto_update_disabled; | ||
| 87 | } | ||
| 88 | |||
| 89 | HidFirmwareSettings::FirmwareSetting HidFirmwareSettings::GetFirmwareUpdateFailure() { | ||
| 90 | LoadSettings(false); | ||
| 91 | return is_firmware_update_failure; | ||
| 92 | } | ||
| 93 | |||
| 94 | HidFirmwareSettings::FeaturesPerId HidFirmwareSettings::FeaturesDisabledPerId() { | ||
| 95 | LoadSettings(false); | ||
| 96 | return features_per_id_disabled; | ||
| 97 | } | ||
| 98 | |||
| 99 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/hid_firmware_settings.h b/src/core/hle/service/hid/hid_firmware_settings.h new file mode 100644 index 000000000..6c10c440b --- /dev/null +++ b/src/core/hle/service/hid/hid_firmware_settings.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_types.h" | ||
| 7 | |||
| 8 | namespace Service::HID { | ||
| 9 | |||
| 10 | /// Loads firmware config from nn::settings::fwdbg | ||
| 11 | class HidFirmwareSettings { | ||
| 12 | public: | ||
| 13 | using FirmwareSetting = std::array<u8, 4>; | ||
| 14 | using FeaturesPerId = std::array<bool, 0xA8>; | ||
| 15 | |||
| 16 | HidFirmwareSettings(); | ||
| 17 | |||
| 18 | void Reload(); | ||
| 19 | void LoadSettings(bool reload_config); | ||
| 20 | |||
| 21 | bool IsDebugPadEnabled(); | ||
| 22 | bool IsDeviceManaged(); | ||
| 23 | bool IsEmulateFutureDevice(); | ||
| 24 | bool IsTouchI2cManaged(); | ||
| 25 | bool IsHandheldForced(); | ||
| 26 | bool IsRailEnabled(); | ||
| 27 | bool IsHardwareErrorEmulated(); | ||
| 28 | bool IsBleDisabled(); | ||
| 29 | bool IsDscaleDisabled(); | ||
| 30 | bool IsTouchAutoUpdateDisabled(); | ||
| 31 | |||
| 32 | FirmwareSetting GetFirmwareUpdateFailure(); | ||
| 33 | FeaturesPerId FeaturesDisabledPerId(); | ||
| 34 | |||
| 35 | private: | ||
| 36 | bool is_initalized{}; | ||
| 37 | |||
| 38 | // Debug settings | ||
| 39 | bool is_debug_pad_enabled{}; | ||
| 40 | bool is_device_managed{}; | ||
| 41 | bool is_touch_i2c_managed{}; | ||
| 42 | bool is_future_devices_emulated{}; | ||
| 43 | bool is_mcu_hardware_error_emulated{}; | ||
| 44 | bool is_rail_enabled{}; | ||
| 45 | bool is_firmware_update_failure_emulated{}; | ||
| 46 | bool is_ble_disabled{}; | ||
| 47 | bool is_dscale_disabled{}; | ||
| 48 | bool is_handheld_forced{}; | ||
| 49 | bool is_touch_firmware_auto_update_disabled{}; | ||
| 50 | FirmwareSetting is_firmware_update_failure{}; | ||
| 51 | FeaturesPerId features_per_id_disabled{}; | ||
| 52 | }; | ||
| 53 | |||
| 54 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index 2fb31cf47..0be6a7186 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "core/hle/kernel/k_transfer_memory.h" | 10 | #include "core/hle/kernel/k_transfer_memory.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/service/hid/errors.h" | 12 | #include "core/hle/service/hid/errors.h" |
| 13 | #include "core/hle/service/hid/hid_firmware_settings.h" | ||
| 13 | #include "core/hle/service/hid/hid_server.h" | 14 | #include "core/hle/service/hid/hid_server.h" |
| 14 | #include "core/hle/service/hid/resource_manager.h" | 15 | #include "core/hle/service/hid/resource_manager.h" |
| 15 | #include "core/hle/service/ipc_helpers.h" | 16 | #include "core/hle/service/ipc_helpers.h" |
| @@ -64,8 +65,9 @@ private: | |||
| 64 | std::shared_ptr<ResourceManager> resource_manager; | 65 | std::shared_ptr<ResourceManager> resource_manager; |
| 65 | }; | 66 | }; |
| 66 | 67 | ||
| 67 | IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource) | 68 | IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource, |
| 68 | : ServiceFramework{system_, "hid"}, resource_manager{resource} { | 69 | std::shared_ptr<HidFirmwareSettings> settings) |
| 70 | : ServiceFramework{system_, "hid"}, resource_manager{resource}, firmware_settings{settings} { | ||
| 69 | // clang-format off | 71 | // clang-format off |
| 70 | static const FunctionInfo functions[] = { | 72 | static const FunctionInfo functions[] = { |
| 71 | {0, &IHidServer::CreateAppletResource, "CreateAppletResource"}, | 73 | {0, &IHidServer::CreateAppletResource, "CreateAppletResource"}, |
| @@ -230,48 +232,87 @@ void IHidServer::ActivateDebugPad(HLERequestContext& ctx) { | |||
| 230 | IPC::RequestParser rp{ctx}; | 232 | IPC::RequestParser rp{ctx}; |
| 231 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 233 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 232 | 234 | ||
| 233 | GetResourceManager()->ActivateController(HidController::DebugPad); | ||
| 234 | |||
| 235 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 235 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 236 | 236 | ||
| 237 | Result result = ResultSuccess; | ||
| 238 | auto& debug_pad = | ||
| 239 | GetResourceManager()->GetController<Controller_DebugPad>(HidController::DebugPad); | ||
| 240 | |||
| 241 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 242 | result = debug_pad.Activate(); | ||
| 243 | } | ||
| 244 | |||
| 245 | if (result.IsSuccess()) { | ||
| 246 | result = debug_pad.Activate(applet_resource_user_id); | ||
| 247 | } | ||
| 248 | |||
| 237 | IPC::ResponseBuilder rb{ctx, 2}; | 249 | IPC::ResponseBuilder rb{ctx, 2}; |
| 238 | rb.Push(ResultSuccess); | 250 | rb.Push(result); |
| 239 | } | 251 | } |
| 240 | 252 | ||
| 241 | void IHidServer::ActivateTouchScreen(HLERequestContext& ctx) { | 253 | void IHidServer::ActivateTouchScreen(HLERequestContext& ctx) { |
| 242 | IPC::RequestParser rp{ctx}; | 254 | IPC::RequestParser rp{ctx}; |
| 243 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 255 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 244 | 256 | ||
| 245 | GetResourceManager()->ActivateController(HidController::Touchscreen); | ||
| 246 | |||
| 247 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 257 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 248 | 258 | ||
| 259 | Result result = ResultSuccess; | ||
| 260 | auto& touch_screen = | ||
| 261 | GetResourceManager()->GetController<Controller_Touchscreen>(HidController::Touchscreen); | ||
| 262 | |||
| 263 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 264 | result = touch_screen.Activate(); | ||
| 265 | } | ||
| 266 | |||
| 267 | if (result.IsSuccess()) { | ||
| 268 | result = touch_screen.Activate(applet_resource_user_id); | ||
| 269 | } | ||
| 270 | |||
| 249 | IPC::ResponseBuilder rb{ctx, 2}; | 271 | IPC::ResponseBuilder rb{ctx, 2}; |
| 250 | rb.Push(ResultSuccess); | 272 | rb.Push(result); |
| 251 | } | 273 | } |
| 252 | 274 | ||
| 253 | void IHidServer::ActivateMouse(HLERequestContext& ctx) { | 275 | void IHidServer::ActivateMouse(HLERequestContext& ctx) { |
| 254 | IPC::RequestParser rp{ctx}; | 276 | IPC::RequestParser rp{ctx}; |
| 255 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 277 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 256 | 278 | ||
| 257 | GetResourceManager()->ActivateController(HidController::Mouse); | ||
| 258 | |||
| 259 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 279 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 260 | 280 | ||
| 281 | Result result = ResultSuccess; | ||
| 282 | auto& mouse = GetResourceManager()->GetController<Controller_Mouse>(HidController::Mouse); | ||
| 283 | |||
| 284 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 285 | result = mouse.Activate(); | ||
| 286 | } | ||
| 287 | |||
| 288 | if (result.IsSuccess()) { | ||
| 289 | result = mouse.Activate(applet_resource_user_id); | ||
| 290 | } | ||
| 291 | |||
| 261 | IPC::ResponseBuilder rb{ctx, 2}; | 292 | IPC::ResponseBuilder rb{ctx, 2}; |
| 262 | rb.Push(ResultSuccess); | 293 | rb.Push(result); |
| 263 | } | 294 | } |
| 264 | 295 | ||
| 265 | void IHidServer::ActivateKeyboard(HLERequestContext& ctx) { | 296 | void IHidServer::ActivateKeyboard(HLERequestContext& ctx) { |
| 266 | IPC::RequestParser rp{ctx}; | 297 | IPC::RequestParser rp{ctx}; |
| 267 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 298 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 268 | 299 | ||
| 269 | GetResourceManager()->ActivateController(HidController::Keyboard); | ||
| 270 | |||
| 271 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 300 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 272 | 301 | ||
| 302 | Result result = ResultSuccess; | ||
| 303 | auto& keyboard = | ||
| 304 | GetResourceManager()->GetController<Controller_Keyboard>(HidController::Keyboard); | ||
| 305 | |||
| 306 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 307 | result = keyboard.Activate(); | ||
| 308 | } | ||
| 309 | |||
| 310 | if (result.IsSuccess()) { | ||
| 311 | result = keyboard.Activate(applet_resource_user_id); | ||
| 312 | } | ||
| 313 | |||
| 273 | IPC::ResponseBuilder rb{ctx, 2}; | 314 | IPC::ResponseBuilder rb{ctx, 2}; |
| 274 | rb.Push(ResultSuccess); | 315 | rb.Push(result); |
| 275 | } | 316 | } |
| 276 | 317 | ||
| 277 | void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) { | 318 | void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) { |
| @@ -898,7 +939,7 @@ void IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx) | |||
| 898 | void IHidServer::ActivateGesture(HLERequestContext& ctx) { | 939 | void IHidServer::ActivateGesture(HLERequestContext& ctx) { |
| 899 | IPC::RequestParser rp{ctx}; | 940 | IPC::RequestParser rp{ctx}; |
| 900 | struct Parameters { | 941 | struct Parameters { |
| 901 | u32 unknown; | 942 | u32 basic_gesture_id; |
| 902 | INSERT_PADDING_WORDS_NOINIT(1); | 943 | INSERT_PADDING_WORDS_NOINIT(1); |
| 903 | u64 applet_resource_user_id; | 944 | u64 applet_resource_user_id; |
| 904 | }; | 945 | }; |
| @@ -906,13 +947,23 @@ void IHidServer::ActivateGesture(HLERequestContext& ctx) { | |||
| 906 | 947 | ||
| 907 | const auto parameters{rp.PopRaw<Parameters>()}; | 948 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 908 | 949 | ||
| 909 | GetResourceManager()->ActivateController(HidController::Gesture); | 950 | LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}", |
| 951 | parameters.basic_gesture_id, parameters.applet_resource_user_id); | ||
| 910 | 952 | ||
| 911 | LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}", | 953 | Result result = ResultSuccess; |
| 912 | parameters.unknown, parameters.applet_resource_user_id); | 954 | auto& gesture = GetResourceManager()->GetController<Controller_Gesture>(HidController::Gesture); |
| 955 | |||
| 956 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 957 | result = gesture.Activate(); | ||
| 958 | } | ||
| 959 | |||
| 960 | if (result.IsSuccess()) { | ||
| 961 | // TODO: Use gesture id here | ||
| 962 | result = gesture.Activate(parameters.applet_resource_user_id); | ||
| 963 | } | ||
| 913 | 964 | ||
| 914 | IPC::ResponseBuilder rb{ctx, 2}; | 965 | IPC::ResponseBuilder rb{ctx, 2}; |
| 915 | rb.Push(ResultSuccess); | 966 | rb.Push(result); |
| 916 | } | 967 | } |
| 917 | 968 | ||
| 918 | void IHidServer::SetSupportedNpadStyleSet(HLERequestContext& ctx) { | 969 | void IHidServer::SetSupportedNpadStyleSet(HLERequestContext& ctx) { |
| @@ -969,22 +1020,25 @@ void IHidServer::ActivateNpad(HLERequestContext& ctx) { | |||
| 969 | IPC::RequestParser rp{ctx}; | 1020 | IPC::RequestParser rp{ctx}; |
| 970 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1021 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 971 | 1022 | ||
| 972 | GetResourceManager()->ActivateController(HidController::NPad); | ||
| 973 | |||
| 974 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 1023 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 975 | 1024 | ||
| 1025 | auto& npad = GetResourceManager()->GetController<Controller_NPad>(HidController::NPad); | ||
| 1026 | |||
| 1027 | // TODO: npad->SetRevision(applet_resource_user_id, NpadRevision::Revision0); | ||
| 1028 | const Result result = npad.Activate(applet_resource_user_id); | ||
| 1029 | |||
| 976 | IPC::ResponseBuilder rb{ctx, 2}; | 1030 | IPC::ResponseBuilder rb{ctx, 2}; |
| 977 | rb.Push(ResultSuccess); | 1031 | rb.Push(result); |
| 978 | } | 1032 | } |
| 979 | 1033 | ||
| 980 | void IHidServer::DeactivateNpad(HLERequestContext& ctx) { | 1034 | void IHidServer::DeactivateNpad(HLERequestContext& ctx) { |
| 981 | IPC::RequestParser rp{ctx}; | 1035 | IPC::RequestParser rp{ctx}; |
| 982 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1036 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 983 | 1037 | ||
| 984 | GetResourceManager()->DeactivateController(HidController::NPad); | ||
| 985 | |||
| 986 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 1038 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 987 | 1039 | ||
| 1040 | // This function does nothing since 10.0.0+ | ||
| 1041 | |||
| 988 | IPC::ResponseBuilder rb{ctx, 2}; | 1042 | IPC::ResponseBuilder rb{ctx, 2}; |
| 989 | rb.Push(ResultSuccess); | 1043 | rb.Push(ResultSuccess); |
| 990 | } | 1044 | } |
| @@ -1053,10 +1107,9 @@ void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) { | |||
| 1053 | } | 1107 | } |
| 1054 | 1108 | ||
| 1055 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { | 1109 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { |
| 1056 | // Should have no effect with how our npad sets up the data | ||
| 1057 | IPC::RequestParser rp{ctx}; | 1110 | IPC::RequestParser rp{ctx}; |
| 1058 | struct Parameters { | 1111 | struct Parameters { |
| 1059 | s32 revision; | 1112 | Controller_NPad::NpadRevision revision; |
| 1060 | INSERT_PADDING_WORDS_NOINIT(1); | 1113 | INSERT_PADDING_WORDS_NOINIT(1); |
| 1061 | u64 applet_resource_user_id; | 1114 | u64 applet_resource_user_id; |
| 1062 | }; | 1115 | }; |
| @@ -1064,13 +1117,16 @@ void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { | |||
| 1064 | 1117 | ||
| 1065 | const auto parameters{rp.PopRaw<Parameters>()}; | 1118 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 1066 | 1119 | ||
| 1067 | GetResourceManager()->ActivateController(HidController::NPad); | ||
| 1068 | |||
| 1069 | LOG_DEBUG(Service_HID, "called, revision={}, applet_resource_user_id={}", parameters.revision, | 1120 | LOG_DEBUG(Service_HID, "called, revision={}, applet_resource_user_id={}", parameters.revision, |
| 1070 | parameters.applet_resource_user_id); | 1121 | parameters.applet_resource_user_id); |
| 1071 | 1122 | ||
| 1123 | auto& npad = GetResourceManager()->GetController<Controller_NPad>(HidController::NPad); | ||
| 1124 | |||
| 1125 | // TODO: npad->SetRevision(applet_resource_user_id, revision); | ||
| 1126 | const auto result = npad.Activate(parameters.applet_resource_user_id); | ||
| 1127 | |||
| 1072 | IPC::ResponseBuilder rb{ctx, 2}; | 1128 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1073 | rb.Push(ResultSuccess); | 1129 | rb.Push(result); |
| 1074 | } | 1130 | } |
| 1075 | 1131 | ||
| 1076 | void IHidServer::SetNpadJoyHoldType(HLERequestContext& ctx) { | 1132 | void IHidServer::SetNpadJoyHoldType(HLERequestContext& ctx) { |
| @@ -1718,12 +1774,22 @@ void IHidServer::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) { | |||
| 1718 | IPC::RequestParser rp{ctx}; | 1774 | IPC::RequestParser rp{ctx}; |
| 1719 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1775 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1720 | 1776 | ||
| 1721 | GetResourceManager()->ActivateController(HidController::ConsoleSixAxisSensor); | 1777 | LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 1722 | 1778 | ||
| 1723 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 1779 | Result result = ResultSuccess; |
| 1780 | auto console_sixaxis = GetResourceManager()->GetController<Controller_ConsoleSixAxis>( | ||
| 1781 | HidController::ConsoleSixAxisSensor); | ||
| 1782 | |||
| 1783 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 1784 | result = console_sixaxis.Activate(); | ||
| 1785 | } | ||
| 1786 | |||
| 1787 | if (result.IsSuccess()) { | ||
| 1788 | result = console_sixaxis.Activate(applet_resource_user_id); | ||
| 1789 | } | ||
| 1724 | 1790 | ||
| 1725 | IPC::ResponseBuilder rb{ctx, 2}; | 1791 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1726 | rb.Push(ResultSuccess); | 1792 | rb.Push(result); |
| 1727 | } | 1793 | } |
| 1728 | 1794 | ||
| 1729 | void IHidServer::StartConsoleSixAxisSensor(HLERequestContext& ctx) { | 1795 | void IHidServer::StartConsoleSixAxisSensor(HLERequestContext& ctx) { |
| @@ -1770,9 +1836,19 @@ void IHidServer::ActivateSevenSixAxisSensor(HLERequestContext& ctx) { | |||
| 1770 | IPC::RequestParser rp{ctx}; | 1836 | IPC::RequestParser rp{ctx}; |
| 1771 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1837 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1772 | 1838 | ||
| 1773 | GetResourceManager()->ActivateController(HidController::ConsoleSixAxisSensor); | 1839 | LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); |
| 1774 | 1840 | ||
| 1775 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 1841 | Result result = ResultSuccess; |
| 1842 | auto console_sixaxis = GetResourceManager()->GetController<Controller_ConsoleSixAxis>( | ||
| 1843 | HidController::ConsoleSixAxisSensor); | ||
| 1844 | |||
| 1845 | if (!firmware_settings->IsDeviceManaged()) { | ||
| 1846 | result = console_sixaxis.Activate(); | ||
| 1847 | } | ||
| 1848 | |||
| 1849 | if (result.IsSuccess()) { | ||
| 1850 | console_sixaxis.Activate(applet_resource_user_id); | ||
| 1851 | } | ||
| 1776 | 1852 | ||
| 1777 | IPC::ResponseBuilder rb{ctx, 2}; | 1853 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1778 | rb.Push(ResultSuccess); | 1854 | rb.Push(ResultSuccess); |
| @@ -1837,7 +1913,7 @@ void IHidServer::InitializeSevenSixAxisSensor(HLERequestContext& ctx) { | |||
| 1837 | // Activate console six axis controller | 1913 | // Activate console six axis controller |
| 1838 | GetResourceManager() | 1914 | GetResourceManager() |
| 1839 | ->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | 1915 | ->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) |
| 1840 | .ActivateController(); | 1916 | .Activate(); |
| 1841 | 1917 | ||
| 1842 | GetResourceManager() | 1918 | GetResourceManager() |
| 1843 | ->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | 1919 | ->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) |
diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index 98353b0db..eb2e8e7f4 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h | |||
| @@ -11,10 +11,12 @@ class System; | |||
| 11 | 11 | ||
| 12 | namespace Service::HID { | 12 | namespace Service::HID { |
| 13 | class ResourceManager; | 13 | class ResourceManager; |
| 14 | class HidFirmwareSettings; | ||
| 14 | 15 | ||
| 15 | class IHidServer final : public ServiceFramework<IHidServer> { | 16 | class IHidServer final : public ServiceFramework<IHidServer> { |
| 16 | public: | 17 | public: |
| 17 | explicit IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource); | 18 | explicit IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource, |
| 19 | std::shared_ptr<HidFirmwareSettings> settings); | ||
| 18 | ~IHidServer() override; | 20 | ~IHidServer() override; |
| 19 | 21 | ||
| 20 | std::shared_ptr<ResourceManager> GetResourceManager(); | 22 | std::shared_ptr<ResourceManager> GetResourceManager(); |
| @@ -141,6 +143,7 @@ private: | |||
| 141 | void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx); | 143 | void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx); |
| 142 | 144 | ||
| 143 | std::shared_ptr<ResourceManager> resource_manager; | 145 | std::shared_ptr<ResourceManager> resource_manager; |
| 146 | std::shared_ptr<HidFirmwareSettings> firmware_settings; | ||
| 144 | }; | 147 | }; |
| 145 | 148 | ||
| 146 | } // namespace Service::HID | 149 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/resource_manager.cpp b/src/core/hle/service/hid/resource_manager.cpp index 4e462f3b3..d6f42c646 100644 --- a/src/core/hle/service/hid/resource_manager.cpp +++ b/src/core/hle/service/hid/resource_manager.cpp | |||
| @@ -59,8 +59,8 @@ void ResourceManager::Initialize() { | |||
| 59 | MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory); | 59 | MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory); |
| 60 | 60 | ||
| 61 | // Homebrew doesn't try to activate some controllers, so we activate them by default | 61 | // Homebrew doesn't try to activate some controllers, so we activate them by default |
| 62 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); | 62 | GetController<Controller_NPad>(HidController::NPad).Activate(); |
| 63 | GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController(); | 63 | GetController<Controller_Touchscreen>(HidController::Touchscreen).Activate(); |
| 64 | 64 | ||
| 65 | GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00); | 65 | GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00); |
| 66 | GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00); | 66 | GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00); |
| @@ -73,14 +73,6 @@ void ResourceManager::Initialize() { | |||
| 73 | is_initialized = true; | 73 | is_initialized = true; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | void ResourceManager::ActivateController(HidController controller) { | ||
| 77 | controllers[static_cast<size_t>(controller)]->ActivateController(); | ||
| 78 | } | ||
| 79 | |||
| 80 | void ResourceManager::DeactivateController(HidController controller) { | ||
| 81 | controllers[static_cast<size_t>(controller)]->DeactivateController(); | ||
| 82 | } | ||
| 83 | |||
| 84 | void ResourceManager::UpdateControllers(std::uintptr_t user_data, | 76 | void ResourceManager::UpdateControllers(std::uintptr_t user_data, |
| 85 | std::chrono::nanoseconds ns_late) { | 77 | std::chrono::nanoseconds ns_late) { |
| 86 | auto& core_timing = system.CoreTiming(); | 78 | auto& core_timing = system.CoreTiming(); |
diff --git a/src/core/hle/service/hid/resource_manager.h b/src/core/hle/service/hid/resource_manager.h index 81b17f9a9..34dbf36bc 100644 --- a/src/core/hle/service/hid/resource_manager.h +++ b/src/core/hle/service/hid/resource_manager.h | |||
| @@ -55,8 +55,6 @@ public: | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | void Initialize(); | 57 | void Initialize(); |
| 58 | void ActivateController(HidController controller); | ||
| 59 | void DeactivateController(HidController controller); | ||
| 60 | 58 | ||
| 61 | void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); | 59 | void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); |
| 62 | void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); | 60 | void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); |