mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-14 09:14:58 +00:00
Merge pull request #12038 from german77/no_implement
service: hid: Split hid.cpp into individual interfaces
This commit is contained in:
commit
7eac28e410
17 changed files with 3276 additions and 3070 deletions
|
@ -521,11 +521,19 @@ add_library(core STATIC
|
||||||
hle/service/grc/grc.h
|
hle/service/grc/grc.h
|
||||||
hle/service/hid/hid.cpp
|
hle/service/hid/hid.cpp
|
||||||
hle/service/hid/hid.h
|
hle/service/hid/hid.h
|
||||||
|
hle/service/hid/hid_debug_server.cpp
|
||||||
|
hle/service/hid/hid_debug_server.h
|
||||||
|
hle/service/hid/hid_server.cpp
|
||||||
|
hle/service/hid/hid_server.h
|
||||||
|
hle/service/hid/hid_system_server.cpp
|
||||||
|
hle/service/hid/hid_system_server.h
|
||||||
hle/service/hid/hidbus.cpp
|
hle/service/hid/hidbus.cpp
|
||||||
hle/service/hid/hidbus.h
|
hle/service/hid/hidbus.h
|
||||||
hle/service/hid/irs.cpp
|
hle/service/hid/irs.cpp
|
||||||
hle/service/hid/irs.h
|
hle/service/hid/irs.h
|
||||||
hle/service/hid/irs_ring_lifo.h
|
hle/service/hid/irs_ring_lifo.h
|
||||||
|
hle/service/hid/resource_manager.cpp
|
||||||
|
hle/service/hid/resource_manager.h
|
||||||
hle/service/hid/ring_lifo.h
|
hle/service/hid/ring_lifo.h
|
||||||
hle/service/hid/xcd.cpp
|
hle/service/hid/xcd.cpp
|
||||||
hle/service/hid/xcd.h
|
hle/service/hid/xcd.h
|
||||||
|
|
|
@ -38,14 +38,6 @@ using TouchParams = std::array<Common::ParamPackage, MaxTouchDevices>;
|
||||||
using ConsoleMotionValues = ConsoleMotionInfo;
|
using ConsoleMotionValues = ConsoleMotionInfo;
|
||||||
using TouchValues = std::array<Common::Input::TouchStatus, MaxTouchDevices>;
|
using TouchValues = std::array<Common::Input::TouchStatus, MaxTouchDevices>;
|
||||||
|
|
||||||
struct TouchFinger {
|
|
||||||
u64 last_touch{};
|
|
||||||
Common::Point<float> position{};
|
|
||||||
u32 id{};
|
|
||||||
TouchAttribute attribute{};
|
|
||||||
bool pressed{};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Contains all motion related data that is used on the services
|
// Contains all motion related data that is used on the services
|
||||||
struct ConsoleMotion {
|
struct ConsoleMotion {
|
||||||
Common::Vec3f accel{};
|
Common::Vec3f accel{};
|
||||||
|
|
|
@ -356,6 +356,14 @@ struct TouchState {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
|
static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
|
||||||
|
|
||||||
|
struct TouchFinger {
|
||||||
|
u64 last_touch{};
|
||||||
|
Common::Point<float> position{};
|
||||||
|
u32 id{};
|
||||||
|
TouchAttribute attribute{};
|
||||||
|
bool pressed{};
|
||||||
|
};
|
||||||
|
|
||||||
// This is nn::hid::TouchScreenConfigurationForNx
|
// This is nn::hid::TouchScreenConfigurationForNx
|
||||||
struct TouchScreenConfigurationForNx {
|
struct TouchScreenConfigurationForNx {
|
||||||
TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting};
|
TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting};
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#include "core/hid/hid_types.h"
|
#include "core/hid/hid_types.h"
|
||||||
#include "core/hid/input_interpreter.h"
|
#include "core/hid/input_interpreter.h"
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid_server.h"
|
||||||
|
#include "core/hle/service/hid/resource_manager.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
|
||||||
InputInterpreter::InputInterpreter(Core::System& system)
|
InputInterpreter::InputInterpreter(Core::System& system)
|
||||||
: npad{system.ServiceManager()
|
: npad{system.ServiceManager()
|
||||||
.GetService<Service::HID::Hid>("hid")
|
.GetService<Service::HID::IHidServer>("hid")
|
||||||
->GetAppletResource()
|
->GetResourceManager()
|
||||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)} {
|
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)} {
|
||||||
ResetButtonStates();
|
ResetButtonStates();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,220 +3,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
namespace Core {
|
||||||
|
class System;
|
||||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
|
||||||
#include "core/hle/service/kernel_helpers.h"
|
|
||||||
#include "core/hle/service/service.h"
|
|
||||||
|
|
||||||
namespace Core::Timing {
|
|
||||||
struct EventType;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Service::SM {
|
|
||||||
class ServiceManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
|
|
||||||
enum class HidController : std::size_t {
|
|
||||||
DebugPad,
|
|
||||||
Touchscreen,
|
|
||||||
Mouse,
|
|
||||||
Keyboard,
|
|
||||||
XPad,
|
|
||||||
HomeButton,
|
|
||||||
SleepButton,
|
|
||||||
CaptureButton,
|
|
||||||
InputDetector,
|
|
||||||
UniquePad,
|
|
||||||
NPad,
|
|
||||||
Gesture,
|
|
||||||
ConsoleSixAxisSensor,
|
|
||||||
DebugMouse,
|
|
||||||
Palma,
|
|
||||||
|
|
||||||
MaxControllers,
|
|
||||||
};
|
|
||||||
|
|
||||||
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
|
||||||
public:
|
|
||||||
explicit IAppletResource(Core::System& system_,
|
|
||||||
KernelHelpers::ServiceContext& service_context_);
|
|
||||||
~IAppletResource() override;
|
|
||||||
|
|
||||||
void ActivateController(HidController controller);
|
|
||||||
void DeactivateController(HidController controller);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T& GetController(HidController controller) {
|
|
||||||
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
const T& GetController(HidController controller) const {
|
|
||||||
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename T>
|
|
||||||
void MakeController(HidController controller, u8* shared_memory) {
|
|
||||||
if constexpr (std::is_constructible_v<T, Core::System&, u8*>) {
|
|
||||||
controllers[static_cast<std::size_t>(controller)] =
|
|
||||||
std::make_unique<T>(system, shared_memory);
|
|
||||||
} else {
|
|
||||||
controllers[static_cast<std::size_t>(controller)] =
|
|
||||||
std::make_unique<T>(system.HIDCore(), shared_memory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) {
|
|
||||||
controllers[static_cast<std::size_t>(controller)] =
|
|
||||||
std::make_unique<T>(system.HIDCore(), shared_memory, service_context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetSharedMemoryHandle(HLERequestContext& ctx);
|
|
||||||
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
|
||||||
void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
|
||||||
void UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
|
||||||
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
|
||||||
|
|
||||||
KernelHelpers::ServiceContext& service_context;
|
|
||||||
|
|
||||||
std::shared_ptr<Core::Timing::EventType> npad_update_event;
|
|
||||||
std::shared_ptr<Core::Timing::EventType> default_update_event;
|
|
||||||
std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event;
|
|
||||||
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
|
||||||
|
|
||||||
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
|
||||||
controllers{};
|
|
||||||
};
|
|
||||||
|
|
||||||
class Hid final : public ServiceFramework<Hid> {
|
|
||||||
public:
|
|
||||||
explicit Hid(Core::System& system_, std::shared_ptr<IAppletResource> applet_resource_);
|
|
||||||
~Hid() override;
|
|
||||||
|
|
||||||
std::shared_ptr<IAppletResource> GetAppletResource();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void CreateAppletResource(HLERequestContext& ctx);
|
|
||||||
void ActivateDebugPad(HLERequestContext& ctx);
|
|
||||||
void ActivateTouchScreen(HLERequestContext& ctx);
|
|
||||||
void ActivateMouse(HLERequestContext& ctx);
|
|
||||||
void ActivateKeyboard(HLERequestContext& ctx);
|
|
||||||
void SendKeyboardLockKeyEvent(HLERequestContext& ctx);
|
|
||||||
void ActivateXpad(HLERequestContext& ctx);
|
|
||||||
void GetXpadIDs(HLERequestContext& ctx);
|
|
||||||
void ActivateSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void DeactivateSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void StartSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void StopSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void IsSixAxisSensorFusionEnabled(HLERequestContext& ctx);
|
|
||||||
void EnableSixAxisSensorFusion(HLERequestContext& ctx);
|
|
||||||
void SetSixAxisSensorFusionParameters(HLERequestContext& ctx);
|
|
||||||
void GetSixAxisSensorFusionParameters(HLERequestContext& ctx);
|
|
||||||
void ResetSixAxisSensorFusionParameters(HLERequestContext& ctx);
|
|
||||||
void SetGyroscopeZeroDriftMode(HLERequestContext& ctx);
|
|
||||||
void GetGyroscopeZeroDriftMode(HLERequestContext& ctx);
|
|
||||||
void ResetGyroscopeZeroDriftMode(HLERequestContext& ctx);
|
|
||||||
void IsSixAxisSensorAtRest(HLERequestContext& ctx);
|
|
||||||
void IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx);
|
|
||||||
void IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx);
|
|
||||||
void LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx);
|
|
||||||
void GetSixAxisSensorIcInformation(HLERequestContext& ctx);
|
|
||||||
void ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx);
|
|
||||||
void ActivateGesture(HLERequestContext& ctx);
|
|
||||||
void SetSupportedNpadStyleSet(HLERequestContext& ctx);
|
|
||||||
void GetSupportedNpadStyleSet(HLERequestContext& ctx);
|
|
||||||
void SetSupportedNpadIdType(HLERequestContext& ctx);
|
|
||||||
void ActivateNpad(HLERequestContext& ctx);
|
|
||||||
void DeactivateNpad(HLERequestContext& ctx);
|
|
||||||
void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx);
|
|
||||||
void DisconnectNpad(HLERequestContext& ctx);
|
|
||||||
void GetPlayerLedPattern(HLERequestContext& ctx);
|
|
||||||
void ActivateNpadWithRevision(HLERequestContext& ctx);
|
|
||||||
void SetNpadJoyHoldType(HLERequestContext& ctx);
|
|
||||||
void GetNpadJoyHoldType(HLERequestContext& ctx);
|
|
||||||
void SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx);
|
|
||||||
void SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx);
|
|
||||||
void SetNpadJoyAssignmentModeDual(HLERequestContext& ctx);
|
|
||||||
void MergeSingleJoyAsDualJoy(HLERequestContext& ctx);
|
|
||||||
void StartLrAssignmentMode(HLERequestContext& ctx);
|
|
||||||
void StopLrAssignmentMode(HLERequestContext& ctx);
|
|
||||||
void SetNpadHandheldActivationMode(HLERequestContext& ctx);
|
|
||||||
void GetNpadHandheldActivationMode(HLERequestContext& ctx);
|
|
||||||
void SwapNpadAssignment(HLERequestContext& ctx);
|
|
||||||
void IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx);
|
|
||||||
void EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx);
|
|
||||||
void SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx);
|
|
||||||
void SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx);
|
|
||||||
void SetNpadCaptureButtonAssignment(HLERequestContext& ctx);
|
|
||||||
void ClearNpadCaptureButtonAssignment(HLERequestContext& ctx);
|
|
||||||
void GetVibrationDeviceInfo(HLERequestContext& ctx);
|
|
||||||
void SendVibrationValue(HLERequestContext& ctx);
|
|
||||||
void GetActualVibrationValue(HLERequestContext& ctx);
|
|
||||||
void CreateActiveVibrationDeviceList(HLERequestContext& ctx);
|
|
||||||
void PermitVibration(HLERequestContext& ctx);
|
|
||||||
void IsVibrationPermitted(HLERequestContext& ctx);
|
|
||||||
void SendVibrationValues(HLERequestContext& ctx);
|
|
||||||
void SendVibrationGcErmCommand(HLERequestContext& ctx);
|
|
||||||
void GetActualVibrationGcErmCommand(HLERequestContext& ctx);
|
|
||||||
void BeginPermitVibrationSession(HLERequestContext& ctx);
|
|
||||||
void EndPermitVibrationSession(HLERequestContext& ctx);
|
|
||||||
void IsVibrationDeviceMounted(HLERequestContext& ctx);
|
|
||||||
void ActivateConsoleSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void StartConsoleSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void StopConsoleSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void ActivateSevenSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void StartSevenSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void StopSevenSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void InitializeSevenSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void FinalizeSevenSixAxisSensor(HLERequestContext& ctx);
|
|
||||||
void ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx);
|
|
||||||
void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
|
|
||||||
void GetPalmaConnectionHandle(HLERequestContext& ctx);
|
|
||||||
void InitializePalma(HLERequestContext& ctx);
|
|
||||||
void AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx);
|
|
||||||
void GetPalmaOperationInfo(HLERequestContext& ctx);
|
|
||||||
void PlayPalmaActivity(HLERequestContext& ctx);
|
|
||||||
void SetPalmaFrModeType(HLERequestContext& ctx);
|
|
||||||
void ReadPalmaStep(HLERequestContext& ctx);
|
|
||||||
void EnablePalmaStep(HLERequestContext& ctx);
|
|
||||||
void ResetPalmaStep(HLERequestContext& ctx);
|
|
||||||
void ReadPalmaApplicationSection(HLERequestContext& ctx);
|
|
||||||
void WritePalmaApplicationSection(HLERequestContext& ctx);
|
|
||||||
void ReadPalmaUniqueCode(HLERequestContext& ctx);
|
|
||||||
void SetPalmaUniqueCodeInvalid(HLERequestContext& ctx);
|
|
||||||
void WritePalmaActivityEntry(HLERequestContext& ctx);
|
|
||||||
void WritePalmaRgbLedPatternEntry(HLERequestContext& ctx);
|
|
||||||
void WritePalmaWaveEntry(HLERequestContext& ctx);
|
|
||||||
void SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx);
|
|
||||||
void GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx);
|
|
||||||
void SuspendPalmaFeature(HLERequestContext& ctx);
|
|
||||||
void GetPalmaOperationResult(HLERequestContext& ctx);
|
|
||||||
void ReadPalmaPlayLog(HLERequestContext& ctx);
|
|
||||||
void ResetPalmaPlayLog(HLERequestContext& ctx);
|
|
||||||
void SetIsPalmaAllConnectable(HLERequestContext& ctx);
|
|
||||||
void SetIsPalmaPairedConnectable(HLERequestContext& ctx);
|
|
||||||
void PairPalma(HLERequestContext& ctx);
|
|
||||||
void SetPalmaBoostMode(HLERequestContext& ctx);
|
|
||||||
void CancelWritePalmaWaveEntry(HLERequestContext& ctx);
|
|
||||||
void EnablePalmaBoostMode(HLERequestContext& ctx);
|
|
||||||
void GetPalmaBluetoothAddress(HLERequestContext& ctx);
|
|
||||||
void SetDisallowedPalmaConnection(HLERequestContext& ctx);
|
|
||||||
void SetNpadCommunicationMode(HLERequestContext& ctx);
|
|
||||||
void GetNpadCommunicationMode(HLERequestContext& ctx);
|
|
||||||
void SetTouchScreenConfiguration(HLERequestContext& ctx);
|
|
||||||
void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx);
|
|
||||||
|
|
||||||
std::shared_ptr<IAppletResource> applet_resource;
|
|
||||||
|
|
||||||
KernelHelpers::ServiceContext service_context;
|
|
||||||
};
|
|
||||||
|
|
||||||
void LoopProcess(Core::System& system);
|
void LoopProcess(Core::System& system);
|
||||||
|
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
159
src/core/hle/service/hid/hid_debug_server.cpp
Normal file
159
src/core/hle/service/hid/hid_debug_server.cpp
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include "core/hle/service/hid/hid_debug_server.h"
|
||||||
|
#include "core/hle/service/hid/resource_manager.h"
|
||||||
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
|
||||||
|
IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource)
|
||||||
|
: ServiceFramework{system_, "hid:dbg"}, resource_manager{resource} {
|
||||||
|
// clang-format off
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, nullptr, "DeactivateDebugPad"},
|
||||||
|
{1, nullptr, "SetDebugPadAutoPilotState"},
|
||||||
|
{2, nullptr, "UnsetDebugPadAutoPilotState"},
|
||||||
|
{10, nullptr, "DeactivateTouchScreen"},
|
||||||
|
{11, nullptr, "SetTouchScreenAutoPilotState"},
|
||||||
|
{12, nullptr, "UnsetTouchScreenAutoPilotState"},
|
||||||
|
{13, nullptr, "GetTouchScreenConfiguration"},
|
||||||
|
{14, nullptr, "ProcessTouchScreenAutoTune"},
|
||||||
|
{15, nullptr, "ForceStopTouchScreenManagement"},
|
||||||
|
{16, nullptr, "ForceRestartTouchScreenManagement"},
|
||||||
|
{17, nullptr, "IsTouchScreenManaged"},
|
||||||
|
{20, nullptr, "DeactivateMouse"},
|
||||||
|
{21, nullptr, "SetMouseAutoPilotState"},
|
||||||
|
{22, nullptr, "UnsetMouseAutoPilotState"},
|
||||||
|
{25, nullptr, "SetDebugMouseAutoPilotState"},
|
||||||
|
{26, nullptr, "UnsetDebugMouseAutoPilotState"},
|
||||||
|
{30, nullptr, "DeactivateKeyboard"},
|
||||||
|
{31, nullptr, "SetKeyboardAutoPilotState"},
|
||||||
|
{32, nullptr, "UnsetKeyboardAutoPilotState"},
|
||||||
|
{50, nullptr, "DeactivateXpad"},
|
||||||
|
{51, nullptr, "SetXpadAutoPilotState"},
|
||||||
|
{52, nullptr, "UnsetXpadAutoPilotState"},
|
||||||
|
{53, nullptr, "DeactivateJoyXpad"},
|
||||||
|
{60, nullptr, "ClearNpadSystemCommonPolicy"},
|
||||||
|
{61, nullptr, "DeactivateNpad"},
|
||||||
|
{62, nullptr, "ForceDisconnectNpad"},
|
||||||
|
{91, nullptr, "DeactivateGesture"},
|
||||||
|
{110, nullptr, "DeactivateHomeButton"},
|
||||||
|
{111, nullptr, "SetHomeButtonAutoPilotState"},
|
||||||
|
{112, nullptr, "UnsetHomeButtonAutoPilotState"},
|
||||||
|
{120, nullptr, "DeactivateSleepButton"},
|
||||||
|
{121, nullptr, "SetSleepButtonAutoPilotState"},
|
||||||
|
{122, nullptr, "UnsetSleepButtonAutoPilotState"},
|
||||||
|
{123, nullptr, "DeactivateInputDetector"},
|
||||||
|
{130, nullptr, "DeactivateCaptureButton"},
|
||||||
|
{131, nullptr, "SetCaptureButtonAutoPilotState"},
|
||||||
|
{132, nullptr, "UnsetCaptureButtonAutoPilotState"},
|
||||||
|
{133, nullptr, "SetShiftAccelerometerCalibrationValue"},
|
||||||
|
{134, nullptr, "GetShiftAccelerometerCalibrationValue"},
|
||||||
|
{135, nullptr, "SetShiftGyroscopeCalibrationValue"},
|
||||||
|
{136, nullptr, "GetShiftGyroscopeCalibrationValue"},
|
||||||
|
{140, nullptr, "DeactivateConsoleSixAxisSensor"},
|
||||||
|
{141, nullptr, "GetConsoleSixAxisSensorSamplingFrequency"},
|
||||||
|
{142, nullptr, "DeactivateSevenSixAxisSensor"},
|
||||||
|
{143, nullptr, "GetConsoleSixAxisSensorCountStates"},
|
||||||
|
{144, nullptr, "GetAccelerometerFsr"},
|
||||||
|
{145, nullptr, "SetAccelerometerFsr"},
|
||||||
|
{146, nullptr, "GetAccelerometerOdr"},
|
||||||
|
{147, nullptr, "SetAccelerometerOdr"},
|
||||||
|
{148, nullptr, "GetGyroscopeFsr"},
|
||||||
|
{149, nullptr, "SetGyroscopeFsr"},
|
||||||
|
{150, nullptr, "GetGyroscopeOdr"},
|
||||||
|
{151, nullptr, "SetGyroscopeOdr"},
|
||||||
|
{152, nullptr, "GetWhoAmI"},
|
||||||
|
{201, nullptr, "ActivateFirmwareUpdate"},
|
||||||
|
{202, nullptr, "DeactivateFirmwareUpdate"},
|
||||||
|
{203, nullptr, "StartFirmwareUpdate"},
|
||||||
|
{204, nullptr, "GetFirmwareUpdateStage"},
|
||||||
|
{205, nullptr, "GetFirmwareVersion"},
|
||||||
|
{206, nullptr, "GetDestinationFirmwareVersion"},
|
||||||
|
{207, nullptr, "DiscardFirmwareInfoCacheForRevert"},
|
||||||
|
{208, nullptr, "StartFirmwareUpdateForRevert"},
|
||||||
|
{209, nullptr, "GetAvailableFirmwareVersionForRevert"},
|
||||||
|
{210, nullptr, "IsFirmwareUpdatingDevice"},
|
||||||
|
{211, nullptr, "StartFirmwareUpdateIndividual"},
|
||||||
|
{215, nullptr, "SetUsbFirmwareForceUpdateEnabled"},
|
||||||
|
{216, nullptr, "SetAllKuinaDevicesToFirmwareUpdateMode"},
|
||||||
|
{221, nullptr, "UpdateControllerColor"},
|
||||||
|
{222, nullptr, "ConnectUsbPadsAsync"},
|
||||||
|
{223, nullptr, "DisconnectUsbPadsAsync"},
|
||||||
|
{224, nullptr, "UpdateDesignInfo"},
|
||||||
|
{225, nullptr, "GetUniquePadDriverState"},
|
||||||
|
{226, nullptr, "GetSixAxisSensorDriverStates"},
|
||||||
|
{227, nullptr, "GetRxPacketHistory"},
|
||||||
|
{228, nullptr, "AcquireOperationEventHandle"},
|
||||||
|
{229, nullptr, "ReadSerialFlash"},
|
||||||
|
{230, nullptr, "WriteSerialFlash"},
|
||||||
|
{231, nullptr, "GetOperationResult"},
|
||||||
|
{232, nullptr, "EnableShipmentMode"},
|
||||||
|
{233, nullptr, "ClearPairingInfo"},
|
||||||
|
{234, nullptr, "GetUniquePadDeviceTypeSetInternal"},
|
||||||
|
{235, nullptr, "EnableAnalogStickPower"},
|
||||||
|
{236, nullptr, "RequestKuinaUartClockCal"},
|
||||||
|
{237, nullptr, "GetKuinaUartClockCal"},
|
||||||
|
{238, nullptr, "SetKuinaUartClockTrim"},
|
||||||
|
{239, nullptr, "KuinaLoopbackTest"},
|
||||||
|
{240, nullptr, "RequestBatteryVoltage"},
|
||||||
|
{241, nullptr, "GetBatteryVoltage"},
|
||||||
|
{242, nullptr, "GetUniquePadPowerInfo"},
|
||||||
|
{243, nullptr, "RebootUniquePad"},
|
||||||
|
{244, nullptr, "RequestKuinaFirmwareVersion"},
|
||||||
|
{245, nullptr, "GetKuinaFirmwareVersion"},
|
||||||
|
{246, nullptr, "GetVidPid"},
|
||||||
|
{247, nullptr, "GetAnalogStickCalibrationValue"},
|
||||||
|
{248, nullptr, "GetUniquePadIdsFull"},
|
||||||
|
{249, nullptr, "ConnectUniquePad"},
|
||||||
|
{250, nullptr, "IsVirtual"},
|
||||||
|
{251, nullptr, "GetAnalogStickModuleParam"},
|
||||||
|
{301, nullptr, "GetAbstractedPadHandles"},
|
||||||
|
{302, nullptr, "GetAbstractedPadState"},
|
||||||
|
{303, nullptr, "GetAbstractedPadsState"},
|
||||||
|
{321, nullptr, "SetAutoPilotVirtualPadState"},
|
||||||
|
{322, nullptr, "UnsetAutoPilotVirtualPadState"},
|
||||||
|
{323, nullptr, "UnsetAllAutoPilotVirtualPadState"},
|
||||||
|
{324, nullptr, "AttachHdlsWorkBuffer"},
|
||||||
|
{325, nullptr, "ReleaseHdlsWorkBuffer"},
|
||||||
|
{326, nullptr, "DumpHdlsNpadAssignmentState"},
|
||||||
|
{327, nullptr, "DumpHdlsStates"},
|
||||||
|
{328, nullptr, "ApplyHdlsNpadAssignmentState"},
|
||||||
|
{329, nullptr, "ApplyHdlsStateList"},
|
||||||
|
{330, nullptr, "AttachHdlsVirtualDevice"},
|
||||||
|
{331, nullptr, "DetachHdlsVirtualDevice"},
|
||||||
|
{332, nullptr, "SetHdlsState"},
|
||||||
|
{350, nullptr, "AddRegisteredDevice"},
|
||||||
|
{400, nullptr, "DisableExternalMcuOnNxDevice"},
|
||||||
|
{401, nullptr, "DisableRailDeviceFiltering"},
|
||||||
|
{402, nullptr, "EnableWiredPairing"},
|
||||||
|
{403, nullptr, "EnableShipmentModeAutoClear"},
|
||||||
|
{404, nullptr, "SetRailEnabled"},
|
||||||
|
{500, nullptr, "SetFactoryInt"},
|
||||||
|
{501, nullptr, "IsFactoryBootEnabled"},
|
||||||
|
{550, nullptr, "SetAnalogStickModelDataTemporarily"},
|
||||||
|
{551, nullptr, "GetAnalogStickModelData"},
|
||||||
|
{552, nullptr, "ResetAnalogStickModelData"},
|
||||||
|
{600, nullptr, "ConvertPadState"},
|
||||||
|
{650, nullptr, "AddButtonPlayData"},
|
||||||
|
{651, nullptr, "StartButtonPlayData"},
|
||||||
|
{652, nullptr, "StopButtonPlayData"},
|
||||||
|
{2000, nullptr, "DeactivateDigitizer"},
|
||||||
|
{2001, nullptr, "SetDigitizerAutoPilotState"},
|
||||||
|
{2002, nullptr, "UnsetDigitizerAutoPilotState"},
|
||||||
|
{2002, nullptr, "ReloadFirmwareDebugSettings"},
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
IHidDebugServer::~IHidDebugServer() = default;
|
||||||
|
|
||||||
|
std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() {
|
||||||
|
resource_manager->Initialize();
|
||||||
|
return resource_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
26
src/core/hle/service/hid/hid_debug_server.h
Normal file
26
src/core/hle/service/hid/hid_debug_server.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
class ResourceManager;
|
||||||
|
|
||||||
|
class IHidDebugServer final : public ServiceFramework<IHidDebugServer> {
|
||||||
|
public:
|
||||||
|
explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource);
|
||||||
|
~IHidDebugServer() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<ResourceManager> GetResourceManager();
|
||||||
|
|
||||||
|
std::shared_ptr<ResourceManager> resource_manager;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
2269
src/core/hle/service/hid/hid_server.cpp
Normal file
2269
src/core/hle/service/hid/hid_server.cpp
Normal file
File diff suppressed because it is too large
Load diff
138
src/core/hle/service/hid/hid_server.h
Normal file
138
src/core/hle/service/hid/hid_server.h
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
class ResourceManager;
|
||||||
|
|
||||||
|
class IHidServer final : public ServiceFramework<IHidServer> {
|
||||||
|
public:
|
||||||
|
explicit IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> resource);
|
||||||
|
~IHidServer() override;
|
||||||
|
|
||||||
|
std::shared_ptr<ResourceManager> GetResourceManager();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CreateAppletResource(HLERequestContext& ctx);
|
||||||
|
void ActivateDebugPad(HLERequestContext& ctx);
|
||||||
|
void ActivateTouchScreen(HLERequestContext& ctx);
|
||||||
|
void ActivateMouse(HLERequestContext& ctx);
|
||||||
|
void ActivateKeyboard(HLERequestContext& ctx);
|
||||||
|
void SendKeyboardLockKeyEvent(HLERequestContext& ctx);
|
||||||
|
void ActivateXpad(HLERequestContext& ctx);
|
||||||
|
void GetXpadIds(HLERequestContext& ctx);
|
||||||
|
void GetJoyXpadIds(HLERequestContext& ctx);
|
||||||
|
void ActivateSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void DeactivateSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void StartSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void StopSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void IsSixAxisSensorFusionEnabled(HLERequestContext& ctx);
|
||||||
|
void EnableSixAxisSensorFusion(HLERequestContext& ctx);
|
||||||
|
void SetSixAxisSensorFusionParameters(HLERequestContext& ctx);
|
||||||
|
void GetSixAxisSensorFusionParameters(HLERequestContext& ctx);
|
||||||
|
void ResetSixAxisSensorFusionParameters(HLERequestContext& ctx);
|
||||||
|
void SetGyroscopeZeroDriftMode(HLERequestContext& ctx);
|
||||||
|
void GetGyroscopeZeroDriftMode(HLERequestContext& ctx);
|
||||||
|
void ResetGyroscopeZeroDriftMode(HLERequestContext& ctx);
|
||||||
|
void IsSixAxisSensorAtRest(HLERequestContext& ctx);
|
||||||
|
void IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx);
|
||||||
|
void IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx);
|
||||||
|
void LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx);
|
||||||
|
void GetSixAxisSensorIcInformation(HLERequestContext& ctx);
|
||||||
|
void ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx);
|
||||||
|
void ActivateGesture(HLERequestContext& ctx);
|
||||||
|
void SetSupportedNpadStyleSet(HLERequestContext& ctx);
|
||||||
|
void GetSupportedNpadStyleSet(HLERequestContext& ctx);
|
||||||
|
void SetSupportedNpadIdType(HLERequestContext& ctx);
|
||||||
|
void ActivateNpad(HLERequestContext& ctx);
|
||||||
|
void DeactivateNpad(HLERequestContext& ctx);
|
||||||
|
void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx);
|
||||||
|
void DisconnectNpad(HLERequestContext& ctx);
|
||||||
|
void GetPlayerLedPattern(HLERequestContext& ctx);
|
||||||
|
void ActivateNpadWithRevision(HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyHoldType(HLERequestContext& ctx);
|
||||||
|
void GetNpadJoyHoldType(HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyAssignmentModeDual(HLERequestContext& ctx);
|
||||||
|
void MergeSingleJoyAsDualJoy(HLERequestContext& ctx);
|
||||||
|
void StartLrAssignmentMode(HLERequestContext& ctx);
|
||||||
|
void StopLrAssignmentMode(HLERequestContext& ctx);
|
||||||
|
void SetNpadHandheldActivationMode(HLERequestContext& ctx);
|
||||||
|
void GetNpadHandheldActivationMode(HLERequestContext& ctx);
|
||||||
|
void SwapNpadAssignment(HLERequestContext& ctx);
|
||||||
|
void IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx);
|
||||||
|
void EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx);
|
||||||
|
void SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx);
|
||||||
|
void SetNpadCaptureButtonAssignment(HLERequestContext& ctx);
|
||||||
|
void ClearNpadCaptureButtonAssignment(HLERequestContext& ctx);
|
||||||
|
void GetVibrationDeviceInfo(HLERequestContext& ctx);
|
||||||
|
void SendVibrationValue(HLERequestContext& ctx);
|
||||||
|
void GetActualVibrationValue(HLERequestContext& ctx);
|
||||||
|
void CreateActiveVibrationDeviceList(HLERequestContext& ctx);
|
||||||
|
void PermitVibration(HLERequestContext& ctx);
|
||||||
|
void IsVibrationPermitted(HLERequestContext& ctx);
|
||||||
|
void SendVibrationValues(HLERequestContext& ctx);
|
||||||
|
void SendVibrationGcErmCommand(HLERequestContext& ctx);
|
||||||
|
void GetActualVibrationGcErmCommand(HLERequestContext& ctx);
|
||||||
|
void BeginPermitVibrationSession(HLERequestContext& ctx);
|
||||||
|
void EndPermitVibrationSession(HLERequestContext& ctx);
|
||||||
|
void IsVibrationDeviceMounted(HLERequestContext& ctx);
|
||||||
|
void ActivateConsoleSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void StartConsoleSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void StopConsoleSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void ActivateSevenSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void StartSevenSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void StopSevenSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void InitializeSevenSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void FinalizeSevenSixAxisSensor(HLERequestContext& ctx);
|
||||||
|
void ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx);
|
||||||
|
void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
|
||||||
|
void GetPalmaConnectionHandle(HLERequestContext& ctx);
|
||||||
|
void InitializePalma(HLERequestContext& ctx);
|
||||||
|
void AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx);
|
||||||
|
void GetPalmaOperationInfo(HLERequestContext& ctx);
|
||||||
|
void PlayPalmaActivity(HLERequestContext& ctx);
|
||||||
|
void SetPalmaFrModeType(HLERequestContext& ctx);
|
||||||
|
void ReadPalmaStep(HLERequestContext& ctx);
|
||||||
|
void EnablePalmaStep(HLERequestContext& ctx);
|
||||||
|
void ResetPalmaStep(HLERequestContext& ctx);
|
||||||
|
void ReadPalmaApplicationSection(HLERequestContext& ctx);
|
||||||
|
void WritePalmaApplicationSection(HLERequestContext& ctx);
|
||||||
|
void ReadPalmaUniqueCode(HLERequestContext& ctx);
|
||||||
|
void SetPalmaUniqueCodeInvalid(HLERequestContext& ctx);
|
||||||
|
void WritePalmaActivityEntry(HLERequestContext& ctx);
|
||||||
|
void WritePalmaRgbLedPatternEntry(HLERequestContext& ctx);
|
||||||
|
void WritePalmaWaveEntry(HLERequestContext& ctx);
|
||||||
|
void SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx);
|
||||||
|
void GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx);
|
||||||
|
void SuspendPalmaFeature(HLERequestContext& ctx);
|
||||||
|
void GetPalmaOperationResult(HLERequestContext& ctx);
|
||||||
|
void ReadPalmaPlayLog(HLERequestContext& ctx);
|
||||||
|
void ResetPalmaPlayLog(HLERequestContext& ctx);
|
||||||
|
void SetIsPalmaAllConnectable(HLERequestContext& ctx);
|
||||||
|
void SetIsPalmaPairedConnectable(HLERequestContext& ctx);
|
||||||
|
void PairPalma(HLERequestContext& ctx);
|
||||||
|
void SetPalmaBoostMode(HLERequestContext& ctx);
|
||||||
|
void CancelWritePalmaWaveEntry(HLERequestContext& ctx);
|
||||||
|
void EnablePalmaBoostMode(HLERequestContext& ctx);
|
||||||
|
void GetPalmaBluetoothAddress(HLERequestContext& ctx);
|
||||||
|
void SetDisallowedPalmaConnection(HLERequestContext& ctx);
|
||||||
|
void SetNpadCommunicationMode(HLERequestContext& ctx);
|
||||||
|
void GetNpadCommunicationMode(HLERequestContext& ctx);
|
||||||
|
void SetTouchScreenConfiguration(HLERequestContext& ctx);
|
||||||
|
void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx);
|
||||||
|
|
||||||
|
std::shared_ptr<ResourceManager> resource_manager;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
304
src/core/hle/service/hid/hid_system_server.cpp
Normal file
304
src/core/hle/service/hid/hid_system_server.cpp
Normal file
|
@ -0,0 +1,304 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include "core/hid/hid_core.h"
|
||||||
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
|
#include "core/hle/service/hid/controllers/touchscreen.h"
|
||||||
|
#include "core/hle/service/hid/errors.h"
|
||||||
|
#include "core/hle/service/hid/hid_system_server.h"
|
||||||
|
#include "core/hle/service/hid/resource_manager.h"
|
||||||
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
|
||||||
|
IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource)
|
||||||
|
: ServiceFramework{system_, "hid:sys"}, service_context{system_, service_name},
|
||||||
|
resource_manager{resource} {
|
||||||
|
// clang-format off
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{31, nullptr, "SendKeyboardLockKeyEvent"},
|
||||||
|
{101, nullptr, "AcquireHomeButtonEventHandle"},
|
||||||
|
{111, nullptr, "ActivateHomeButton"},
|
||||||
|
{121, nullptr, "AcquireSleepButtonEventHandle"},
|
||||||
|
{131, nullptr, "ActivateSleepButton"},
|
||||||
|
{141, nullptr, "AcquireCaptureButtonEventHandle"},
|
||||||
|
{151, nullptr, "ActivateCaptureButton"},
|
||||||
|
{161, nullptr, "GetPlatformConfig"},
|
||||||
|
{210, nullptr, "AcquireNfcDeviceUpdateEventHandle"},
|
||||||
|
{211, nullptr, "GetNpadsWithNfc"},
|
||||||
|
{212, nullptr, "AcquireNfcActivateEventHandle"},
|
||||||
|
{213, nullptr, "ActivateNfc"},
|
||||||
|
{214, nullptr, "GetXcdHandleForNpadWithNfc"},
|
||||||
|
{215, nullptr, "IsNfcActivated"},
|
||||||
|
{230, nullptr, "AcquireIrSensorEventHandle"},
|
||||||
|
{231, nullptr, "ActivateIrSensor"},
|
||||||
|
{232, nullptr, "GetIrSensorState"},
|
||||||
|
{233, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||||
|
{301, nullptr, "ActivateNpadSystem"},
|
||||||
|
{303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
|
||||||
|
{304, nullptr, "EnableAssigningSingleOnSlSrPress"},
|
||||||
|
{305, nullptr, "DisableAssigningSingleOnSlSrPress"},
|
||||||
|
{306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"},
|
||||||
|
{307, nullptr, "GetNpadSystemExtStyle"},
|
||||||
|
{308, nullptr, "ApplyNpadSystemCommonPolicyFull"},
|
||||||
|
{309, nullptr, "GetNpadFullKeyGripColor"},
|
||||||
|
{310, nullptr, "GetMaskedSupportedNpadStyleSet"},
|
||||||
|
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
|
||||||
|
{312, nullptr, "SetSupportedNpadStyleSetAll"},
|
||||||
|
{313, nullptr, "GetNpadCaptureButtonAssignment"},
|
||||||
|
{314, nullptr, "GetAppletFooterUiType"},
|
||||||
|
{315, nullptr, "GetAppletDetailedUiType"},
|
||||||
|
{316, nullptr, "GetNpadInterfaceType"},
|
||||||
|
{317, nullptr, "GetNpadLeftRightInterfaceType"},
|
||||||
|
{318, nullptr, "HasBattery"},
|
||||||
|
{319, nullptr, "HasLeftRightBattery"},
|
||||||
|
{321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
|
||||||
|
{322, nullptr, "GetIrSensorState"},
|
||||||
|
{323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
|
||||||
|
{324, nullptr, "GetUniquePadButtonSet"},
|
||||||
|
{325, nullptr, "GetUniquePadColor"},
|
||||||
|
{326, nullptr, "GetUniquePadAppletDetailedUiType"},
|
||||||
|
{327, nullptr, "GetAbstractedPadIdDataFromNpad"},
|
||||||
|
{328, nullptr, "AttachAbstractedPadToNpad"},
|
||||||
|
{329, nullptr, "DetachAbstractedPadAll"},
|
||||||
|
{330, nullptr, "CheckAbstractedPadConnection"},
|
||||||
|
{500, nullptr, "SetAppletResourceUserId"},
|
||||||
|
{501, nullptr, "RegisterAppletResourceUserId"},
|
||||||
|
{502, nullptr, "UnregisterAppletResourceUserId"},
|
||||||
|
{503, nullptr, "EnableAppletToGetInput"},
|
||||||
|
{504, nullptr, "SetAruidValidForVibration"},
|
||||||
|
{505, nullptr, "EnableAppletToGetSixAxisSensor"},
|
||||||
|
{506, nullptr, "EnableAppletToGetPadInput"},
|
||||||
|
{507, nullptr, "EnableAppletToGetTouchScreen"},
|
||||||
|
{510, nullptr, "SetVibrationMasterVolume"},
|
||||||
|
{511, nullptr, "GetVibrationMasterVolume"},
|
||||||
|
{512, nullptr, "BeginPermitVibrationSession"},
|
||||||
|
{513, nullptr, "EndPermitVibrationSession"},
|
||||||
|
{514, nullptr, "Unknown514"},
|
||||||
|
{520, nullptr, "EnableHandheldHids"},
|
||||||
|
{521, nullptr, "DisableHandheldHids"},
|
||||||
|
{522, nullptr, "SetJoyConRailEnabled"},
|
||||||
|
{523, nullptr, "IsJoyConRailEnabled"},
|
||||||
|
{524, nullptr, "IsHandheldHidsEnabled"},
|
||||||
|
{525, nullptr, "IsJoyConAttachedOnAllRail"},
|
||||||
|
{540, nullptr, "AcquirePlayReportControllerUsageUpdateEvent"},
|
||||||
|
{541, nullptr, "GetPlayReportControllerUsages"},
|
||||||
|
{542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"},
|
||||||
|
{543, nullptr, "GetRegisteredDevicesOld"},
|
||||||
|
{544, nullptr, "AcquireConnectionTriggerTimeoutEvent"},
|
||||||
|
{545, nullptr, "SendConnectionTrigger"},
|
||||||
|
{546, nullptr, "AcquireDeviceRegisteredEventForControllerSupport"},
|
||||||
|
{547, nullptr, "GetAllowedBluetoothLinksCount"},
|
||||||
|
{548, nullptr, "GetRegisteredDevices"},
|
||||||
|
{549, nullptr, "GetConnectableRegisteredDevices"},
|
||||||
|
{700, nullptr, "ActivateUniquePad"},
|
||||||
|
{702, nullptr, "AcquireUniquePadConnectionEventHandle"},
|
||||||
|
{703, nullptr, "GetUniquePadIds"},
|
||||||
|
{751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"},
|
||||||
|
{800, nullptr, "ListSixAxisSensorHandles"},
|
||||||
|
{801, nullptr, "IsSixAxisSensorUserCalibrationSupported"},
|
||||||
|
{802, nullptr, "ResetSixAxisSensorCalibrationValues"},
|
||||||
|
{803, nullptr, "StartSixAxisSensorUserCalibration"},
|
||||||
|
{804, nullptr, "CancelSixAxisSensorUserCalibration"},
|
||||||
|
{805, nullptr, "GetUniquePadBluetoothAddress"},
|
||||||
|
{806, nullptr, "DisconnectUniquePad"},
|
||||||
|
{807, nullptr, "GetUniquePadType"},
|
||||||
|
{808, nullptr, "GetUniquePadInterface"},
|
||||||
|
{809, nullptr, "GetUniquePadSerialNumber"},
|
||||||
|
{810, nullptr, "GetUniquePadControllerNumber"},
|
||||||
|
{811, nullptr, "GetSixAxisSensorUserCalibrationStage"},
|
||||||
|
{812, nullptr, "GetConsoleUniqueSixAxisSensorHandle"},
|
||||||
|
{821, nullptr, "StartAnalogStickManualCalibration"},
|
||||||
|
{822, nullptr, "RetryCurrentAnalogStickManualCalibrationStage"},
|
||||||
|
{823, nullptr, "CancelAnalogStickManualCalibration"},
|
||||||
|
{824, nullptr, "ResetAnalogStickManualCalibration"},
|
||||||
|
{825, nullptr, "GetAnalogStickState"},
|
||||||
|
{826, nullptr, "GetAnalogStickManualCalibrationStage"},
|
||||||
|
{827, nullptr, "IsAnalogStickButtonPressed"},
|
||||||
|
{828, nullptr, "IsAnalogStickInReleasePosition"},
|
||||||
|
{829, nullptr, "IsAnalogStickInCircumference"},
|
||||||
|
{830, nullptr, "SetNotificationLedPattern"},
|
||||||
|
{831, nullptr, "SetNotificationLedPatternWithTimeout"},
|
||||||
|
{832, nullptr, "PrepareHidsForNotificationWake"},
|
||||||
|
{850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
|
||||||
|
{851, nullptr, "EnableUsbFullKeyController"},
|
||||||
|
{852, nullptr, "IsUsbConnected"},
|
||||||
|
{870, nullptr, "IsHandheldButtonPressedOnConsoleMode"},
|
||||||
|
{900, nullptr, "ActivateInputDetector"},
|
||||||
|
{901, nullptr, "NotifyInputDetector"},
|
||||||
|
{1000, nullptr, "InitializeFirmwareUpdate"},
|
||||||
|
{1001, nullptr, "GetFirmwareVersion"},
|
||||||
|
{1002, nullptr, "GetAvailableFirmwareVersion"},
|
||||||
|
{1003, nullptr, "IsFirmwareUpdateAvailable"},
|
||||||
|
{1004, nullptr, "CheckFirmwareUpdateRequired"},
|
||||||
|
{1005, nullptr, "StartFirmwareUpdate"},
|
||||||
|
{1006, nullptr, "AbortFirmwareUpdate"},
|
||||||
|
{1007, nullptr, "GetFirmwareUpdateState"},
|
||||||
|
{1008, nullptr, "ActivateAudioControl"},
|
||||||
|
{1009, nullptr, "AcquireAudioControlEventHandle"},
|
||||||
|
{1010, nullptr, "GetAudioControlStates"},
|
||||||
|
{1011, nullptr, "DeactivateAudioControl"},
|
||||||
|
{1050, nullptr, "IsSixAxisSensorAccurateUserCalibrationSupported"},
|
||||||
|
{1051, nullptr, "StartSixAxisSensorAccurateUserCalibration"},
|
||||||
|
{1052, nullptr, "CancelSixAxisSensorAccurateUserCalibration"},
|
||||||
|
{1053, nullptr, "GetSixAxisSensorAccurateUserCalibrationState"},
|
||||||
|
{1100, nullptr, "GetHidbusSystemServiceObject"},
|
||||||
|
{1120, nullptr, "SetFirmwareHotfixUpdateSkipEnabled"},
|
||||||
|
{1130, nullptr, "InitializeUsbFirmwareUpdate"},
|
||||||
|
{1131, nullptr, "FinalizeUsbFirmwareUpdate"},
|
||||||
|
{1132, nullptr, "CheckUsbFirmwareUpdateRequired"},
|
||||||
|
{1133, nullptr, "StartUsbFirmwareUpdate"},
|
||||||
|
{1134, nullptr, "GetUsbFirmwareUpdateState"},
|
||||||
|
{1150, nullptr, "SetTouchScreenMagnification"},
|
||||||
|
{1151, nullptr, "GetTouchScreenFirmwareVersion"},
|
||||||
|
{1152, nullptr, "SetTouchScreenDefaultConfiguration"},
|
||||||
|
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
|
||||||
|
{1154, nullptr, "IsFirmwareAvailableForNotification"},
|
||||||
|
{1155, nullptr, "SetForceHandheldStyleVibration"},
|
||||||
|
{1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"},
|
||||||
|
{1157, nullptr, "CancelConnectionTrigger"},
|
||||||
|
{1200, nullptr, "IsButtonConfigSupported"},
|
||||||
|
{1201, nullptr, "IsButtonConfigEmbeddedSupported"},
|
||||||
|
{1202, nullptr, "DeleteButtonConfig"},
|
||||||
|
{1203, nullptr, "DeleteButtonConfigEmbedded"},
|
||||||
|
{1204, nullptr, "SetButtonConfigEnabled"},
|
||||||
|
{1205, nullptr, "SetButtonConfigEmbeddedEnabled"},
|
||||||
|
{1206, nullptr, "IsButtonConfigEnabled"},
|
||||||
|
{1207, nullptr, "IsButtonConfigEmbeddedEnabled"},
|
||||||
|
{1208, nullptr, "SetButtonConfigEmbedded"},
|
||||||
|
{1209, nullptr, "SetButtonConfigFull"},
|
||||||
|
{1210, nullptr, "SetButtonConfigLeft"},
|
||||||
|
{1211, nullptr, "SetButtonConfigRight"},
|
||||||
|
{1212, nullptr, "GetButtonConfigEmbedded"},
|
||||||
|
{1213, nullptr, "GetButtonConfigFull"},
|
||||||
|
{1214, nullptr, "GetButtonConfigLeft"},
|
||||||
|
{1215, nullptr, "GetButtonConfigRight"},
|
||||||
|
{1250, nullptr, "IsCustomButtonConfigSupported"},
|
||||||
|
{1251, nullptr, "IsDefaultButtonConfigEmbedded"},
|
||||||
|
{1252, nullptr, "IsDefaultButtonConfigFull"},
|
||||||
|
{1253, nullptr, "IsDefaultButtonConfigLeft"},
|
||||||
|
{1254, nullptr, "IsDefaultButtonConfigRight"},
|
||||||
|
{1255, nullptr, "IsButtonConfigStorageEmbeddedEmpty"},
|
||||||
|
{1256, nullptr, "IsButtonConfigStorageFullEmpty"},
|
||||||
|
{1257, nullptr, "IsButtonConfigStorageLeftEmpty"},
|
||||||
|
{1258, nullptr, "IsButtonConfigStorageRightEmpty"},
|
||||||
|
{1259, nullptr, "GetButtonConfigStorageEmbeddedDeprecated"},
|
||||||
|
{1260, nullptr, "GetButtonConfigStorageFullDeprecated"},
|
||||||
|
{1261, nullptr, "GetButtonConfigStorageLeftDeprecated"},
|
||||||
|
{1262, nullptr, "GetButtonConfigStorageRightDeprecated"},
|
||||||
|
{1263, nullptr, "SetButtonConfigStorageEmbeddedDeprecated"},
|
||||||
|
{1264, nullptr, "SetButtonConfigStorageFullDeprecated"},
|
||||||
|
{1265, nullptr, "SetButtonConfigStorageLeftDeprecated"},
|
||||||
|
{1266, nullptr, "SetButtonConfigStorageRightDeprecated"},
|
||||||
|
{1267, nullptr, "DeleteButtonConfigStorageEmbedded"},
|
||||||
|
{1268, nullptr, "DeleteButtonConfigStorageFull"},
|
||||||
|
{1269, nullptr, "DeleteButtonConfigStorageLeft"},
|
||||||
|
{1270, nullptr, "DeleteButtonConfigStorageRight"},
|
||||||
|
{1271, nullptr, "IsUsingCustomButtonConfig"},
|
||||||
|
{1272, nullptr, "IsAnyCustomButtonConfigEnabled"},
|
||||||
|
{1273, nullptr, "SetAllCustomButtonConfigEnabled"},
|
||||||
|
{1274, nullptr, "SetDefaultButtonConfig"},
|
||||||
|
{1275, nullptr, "SetAllDefaultButtonConfig"},
|
||||||
|
{1276, nullptr, "SetHidButtonConfigEmbedded"},
|
||||||
|
{1277, nullptr, "SetHidButtonConfigFull"},
|
||||||
|
{1278, nullptr, "SetHidButtonConfigLeft"},
|
||||||
|
{1279, nullptr, "SetHidButtonConfigRight"},
|
||||||
|
{1280, nullptr, "GetHidButtonConfigEmbedded"},
|
||||||
|
{1281, nullptr, "GetHidButtonConfigFull"},
|
||||||
|
{1282, nullptr, "GetHidButtonConfigLeft"},
|
||||||
|
{1283, nullptr, "GetHidButtonConfigRight"},
|
||||||
|
{1284, nullptr, "GetButtonConfigStorageEmbedded"},
|
||||||
|
{1285, nullptr, "GetButtonConfigStorageFull"},
|
||||||
|
{1286, nullptr, "GetButtonConfigStorageLeft"},
|
||||||
|
{1287, nullptr, "GetButtonConfigStorageRight"},
|
||||||
|
{1288, nullptr, "SetButtonConfigStorageEmbedded"},
|
||||||
|
{1289, nullptr, "SetButtonConfigStorageFull"},
|
||||||
|
{1290, nullptr, "DeleteButtonConfigStorageRight"},
|
||||||
|
{1291, nullptr, "DeleteButtonConfigStorageRight"},
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
|
joy_detach_event = service_context.CreateEvent("HidSys::JoyDetachEvent");
|
||||||
|
}
|
||||||
|
|
||||||
|
IHidSystemServer::~IHidSystemServer() {
|
||||||
|
service_context.CloseEvent(joy_detach_event);
|
||||||
|
};
|
||||||
|
|
||||||
|
void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
|
||||||
|
LOG_WARNING(Service_HID, "called");
|
||||||
|
|
||||||
|
GetResourceManager()
|
||||||
|
->GetController<Controller_NPad>(HidController::NPad)
|
||||||
|
.ApplyNpadSystemCommonPolicy();
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_HID, "(STUBBED) called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushEnum(system.HIDCore().GetLastActiveController());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHidSystemServer::GetUniquePadsFromNpad(HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||||
|
|
||||||
|
LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type);
|
||||||
|
|
||||||
|
const std::vector<Core::HID::UniquePadId> unique_pads{};
|
||||||
|
|
||||||
|
ctx.WriteBuffer(unique_pads);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.Push(static_cast<u32>(unique_pads.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) {
|
||||||
|
LOG_INFO(Service_AM, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushCopyObjects(joy_detach_event->GetReadableEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHidSystemServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
|
||||||
|
const bool is_enabled = false;
|
||||||
|
|
||||||
|
LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.Push(is_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
|
||||||
|
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||||
|
|
||||||
|
Core::HID::TouchScreenConfigurationForNx touchscreen_config{
|
||||||
|
.mode = Core::HID::TouchScreenModeForNx::Finger,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
|
||||||
|
touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
|
||||||
|
touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 6};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushRaw(touchscreen_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() {
|
||||||
|
resource_manager->Initialize();
|
||||||
|
return resource_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
40
src/core/hle/service/hid/hid_system_server.h
Normal file
40
src/core/hle/service/hid/hid_system_server.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class KEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
class ResourceManager;
|
||||||
|
|
||||||
|
class IHidSystemServer final : public ServiceFramework<IHidSystemServer> {
|
||||||
|
public:
|
||||||
|
explicit IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource);
|
||||||
|
~IHidSystemServer() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx);
|
||||||
|
void GetLastActiveNpad(HLERequestContext& ctx);
|
||||||
|
void GetUniquePadsFromNpad(HLERequestContext& ctx);
|
||||||
|
void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx);
|
||||||
|
void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
|
||||||
|
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
|
||||||
|
|
||||||
|
std::shared_ptr<ResourceManager> GetResourceManager();
|
||||||
|
|
||||||
|
Kernel::KEvent* joy_detach_event;
|
||||||
|
KernelHelpers::ServiceContext service_context;
|
||||||
|
std::shared_ptr<ResourceManager> resource_manager;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
|
@ -3,15 +3,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
#include "core/hid/hid_types.h"
|
#include "core/hid/hid_types.h"
|
||||||
#include "core/hid/irs_types.h"
|
#include "core/hid/irs_types.h"
|
||||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class System;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core::HID {
|
namespace Core::HID {
|
||||||
class EmulatedController;
|
class EmulatedController;
|
||||||
} // namespace Core::HID
|
} // namespace Core::HID
|
||||||
|
|
192
src/core/hle/service/hid/resource_manager.cpp
Normal file
192
src/core/hle/service/hid/resource_manager.cpp
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/core_timing.h"
|
||||||
|
#include "core/hid/hid_core.h"
|
||||||
|
#include "core/hle/kernel/k_shared_memory.h"
|
||||||
|
#include "core/hle/service/hid/resource_manager.h"
|
||||||
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
|
||||||
|
#include "core/hle/service/hid/controllers/console_sixaxis.h"
|
||||||
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||||
|
#include "core/hle/service/hid/controllers/debug_pad.h"
|
||||||
|
#include "core/hle/service/hid/controllers/gesture.h"
|
||||||
|
#include "core/hle/service/hid/controllers/keyboard.h"
|
||||||
|
#include "core/hle/service/hid/controllers/mouse.h"
|
||||||
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
|
#include "core/hle/service/hid/controllers/palma.h"
|
||||||
|
#include "core/hle/service/hid/controllers/stubbed.h"
|
||||||
|
#include "core/hle/service/hid/controllers/touchscreen.h"
|
||||||
|
#include "core/hle/service/hid/controllers/xpad.h"
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
|
||||||
|
// Updating period for each HID device.
|
||||||
|
// Period time is obtained by measuring the number of samples in a second on HW using a homebrew
|
||||||
|
// Correct npad_update_ns is 4ms this is overclocked to lower input lag
|
||||||
|
constexpr auto npad_update_ns = std::chrono::nanoseconds{1 * 1000 * 1000}; // (1ms, 1000Hz)
|
||||||
|
constexpr auto default_update_ns = std::chrono::nanoseconds{4 * 1000 * 1000}; // (4ms, 1000Hz)
|
||||||
|
constexpr auto mouse_keyboard_update_ns = std::chrono::nanoseconds{8 * 1000 * 1000}; // (8ms, 125Hz)
|
||||||
|
constexpr auto motion_update_ns = std::chrono::nanoseconds{5 * 1000 * 1000}; // (5ms, 200Hz)
|
||||||
|
|
||||||
|
ResourceManager::ResourceManager(Core::System& system_)
|
||||||
|
: system{system_}, service_context{system_, "hid"} {}
|
||||||
|
|
||||||
|
ResourceManager::~ResourceManager() = default;
|
||||||
|
|
||||||
|
void ResourceManager::Initialize() {
|
||||||
|
if (is_initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8* shared_memory = system.Kernel().GetHidSharedMem().GetPointer();
|
||||||
|
MakeController<Controller_DebugPad>(HidController::DebugPad, shared_memory);
|
||||||
|
MakeController<Controller_Touchscreen>(HidController::Touchscreen, shared_memory);
|
||||||
|
MakeController<Controller_Mouse>(HidController::Mouse, shared_memory);
|
||||||
|
MakeController<Controller_Keyboard>(HidController::Keyboard, shared_memory);
|
||||||
|
MakeController<Controller_XPad>(HidController::XPad, shared_memory);
|
||||||
|
MakeController<Controller_Stubbed>(HidController::HomeButton, shared_memory);
|
||||||
|
MakeController<Controller_Stubbed>(HidController::SleepButton, shared_memory);
|
||||||
|
MakeController<Controller_Stubbed>(HidController::CaptureButton, shared_memory);
|
||||||
|
MakeController<Controller_Stubbed>(HidController::InputDetector, shared_memory);
|
||||||
|
MakeController<Controller_Stubbed>(HidController::UniquePad, shared_memory);
|
||||||
|
MakeControllerWithServiceContext<Controller_NPad>(HidController::NPad, shared_memory);
|
||||||
|
MakeController<Controller_Gesture>(HidController::Gesture, shared_memory);
|
||||||
|
MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor, shared_memory);
|
||||||
|
MakeController<Controller_Stubbed>(HidController::DebugMouse, shared_memory);
|
||||||
|
MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory);
|
||||||
|
|
||||||
|
// Homebrew doesn't try to activate some controllers, so we activate them by default
|
||||||
|
GetController<Controller_NPad>(HidController::NPad).ActivateController();
|
||||||
|
GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController();
|
||||||
|
|
||||||
|
GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00);
|
||||||
|
GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00);
|
||||||
|
GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000);
|
||||||
|
GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200);
|
||||||
|
GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00);
|
||||||
|
GetController<Controller_Stubbed>(HidController::DebugMouse).SetCommonHeaderOffset(0x3DC00);
|
||||||
|
|
||||||
|
system.HIDCore().ReloadInputDevices();
|
||||||
|
is_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::ActivateController(HidController controller) {
|
||||||
|
controllers[static_cast<size_t>(controller)]->ActivateController();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::DeactivateController(HidController controller) {
|
||||||
|
controllers[static_cast<size_t>(controller)]->DeactivateController();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::UpdateControllers(std::uintptr_t user_data,
|
||||||
|
std::chrono::nanoseconds ns_late) {
|
||||||
|
auto& core_timing = system.CoreTiming();
|
||||||
|
|
||||||
|
for (const auto& controller : controllers) {
|
||||||
|
// Keyboard has it's own update event
|
||||||
|
if (controller == controllers[static_cast<size_t>(HidController::Keyboard)]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Mouse has it's own update event
|
||||||
|
if (controller == controllers[static_cast<size_t>(HidController::Mouse)]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Npad has it's own update event
|
||||||
|
if (controller == controllers[static_cast<size_t>(HidController::NPad)]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
controller->OnUpdate(core_timing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) {
|
||||||
|
auto& core_timing = system.CoreTiming();
|
||||||
|
|
||||||
|
controllers[static_cast<size_t>(HidController::NPad)]->OnUpdate(core_timing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::UpdateMouseKeyboard(std::uintptr_t user_data,
|
||||||
|
std::chrono::nanoseconds ns_late) {
|
||||||
|
auto& core_timing = system.CoreTiming();
|
||||||
|
|
||||||
|
controllers[static_cast<size_t>(HidController::Mouse)]->OnUpdate(core_timing);
|
||||||
|
controllers[static_cast<size_t>(HidController::Keyboard)]->OnUpdate(core_timing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) {
|
||||||
|
auto& core_timing = system.CoreTiming();
|
||||||
|
|
||||||
|
controllers[static_cast<size_t>(HidController::NPad)]->OnMotionUpdate(core_timing);
|
||||||
|
}
|
||||||
|
|
||||||
|
IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource)
|
||||||
|
: ServiceFramework{system_, "IAppletResource"} {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
|
resource->Initialize();
|
||||||
|
|
||||||
|
// Register update callbacks
|
||||||
|
npad_update_event = Core::Timing::CreateEvent(
|
||||||
|
"HID::UpdatePadCallback",
|
||||||
|
[this, resource](std::uintptr_t user_data, s64 time, std::chrono::nanoseconds ns_late)
|
||||||
|
-> std::optional<std::chrono::nanoseconds> {
|
||||||
|
const auto guard = LockService();
|
||||||
|
resource->UpdateNpad(user_data, ns_late);
|
||||||
|
return std::nullopt;
|
||||||
|
});
|
||||||
|
default_update_event = Core::Timing::CreateEvent(
|
||||||
|
"HID::UpdateDefaultCallback",
|
||||||
|
[this, resource](std::uintptr_t user_data, s64 time, std::chrono::nanoseconds ns_late)
|
||||||
|
-> std::optional<std::chrono::nanoseconds> {
|
||||||
|
const auto guard = LockService();
|
||||||
|
resource->UpdateControllers(user_data, ns_late);
|
||||||
|
return std::nullopt;
|
||||||
|
});
|
||||||
|
mouse_keyboard_update_event = Core::Timing::CreateEvent(
|
||||||
|
"HID::UpdateMouseKeyboardCallback",
|
||||||
|
[this, resource](std::uintptr_t user_data, s64 time, std::chrono::nanoseconds ns_late)
|
||||||
|
-> std::optional<std::chrono::nanoseconds> {
|
||||||
|
const auto guard = LockService();
|
||||||
|
resource->UpdateMouseKeyboard(user_data, ns_late);
|
||||||
|
return std::nullopt;
|
||||||
|
});
|
||||||
|
motion_update_event = Core::Timing::CreateEvent(
|
||||||
|
"HID::UpdateMotionCallback",
|
||||||
|
[this, resource](std::uintptr_t user_data, s64 time, std::chrono::nanoseconds ns_late)
|
||||||
|
-> std::optional<std::chrono::nanoseconds> {
|
||||||
|
const auto guard = LockService();
|
||||||
|
resource->UpdateMotion(user_data, ns_late);
|
||||||
|
return std::nullopt;
|
||||||
|
});
|
||||||
|
|
||||||
|
system.CoreTiming().ScheduleLoopingEvent(npad_update_ns, npad_update_ns, npad_update_event);
|
||||||
|
system.CoreTiming().ScheduleLoopingEvent(default_update_ns, default_update_ns,
|
||||||
|
default_update_event);
|
||||||
|
system.CoreTiming().ScheduleLoopingEvent(mouse_keyboard_update_ns, mouse_keyboard_update_ns,
|
||||||
|
mouse_keyboard_update_event);
|
||||||
|
system.CoreTiming().ScheduleLoopingEvent(motion_update_ns, motion_update_ns,
|
||||||
|
motion_update_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
IAppletResource::~IAppletResource() {
|
||||||
|
system.CoreTiming().UnscheduleEvent(npad_update_event, 0);
|
||||||
|
system.CoreTiming().UnscheduleEvent(default_update_event, 0);
|
||||||
|
system.CoreTiming().UnscheduleEvent(mouse_keyboard_update_event, 0);
|
||||||
|
system.CoreTiming().UnscheduleEvent(motion_update_event, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_HID, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushCopyObjects(&system.Kernel().GetHidSharedMem());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
106
src/core/hle/service/hid/resource_manager.h
Normal file
106
src/core/hle/service/hid/resource_manager.h
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||||
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Core::Timing {
|
||||||
|
struct EventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Core::HID {
|
||||||
|
class HIDCore;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::HID {
|
||||||
|
|
||||||
|
enum class HidController : std::size_t {
|
||||||
|
DebugPad,
|
||||||
|
Touchscreen,
|
||||||
|
Mouse,
|
||||||
|
Keyboard,
|
||||||
|
XPad,
|
||||||
|
HomeButton,
|
||||||
|
SleepButton,
|
||||||
|
CaptureButton,
|
||||||
|
InputDetector,
|
||||||
|
UniquePad,
|
||||||
|
NPad,
|
||||||
|
Gesture,
|
||||||
|
ConsoleSixAxisSensor,
|
||||||
|
DebugMouse,
|
||||||
|
Palma,
|
||||||
|
|
||||||
|
MaxControllers,
|
||||||
|
};
|
||||||
|
class ResourceManager {
|
||||||
|
public:
|
||||||
|
explicit ResourceManager(Core::System& system_);
|
||||||
|
~ResourceManager();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T& GetController(HidController controller) {
|
||||||
|
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
const T& GetController(HidController controller) const {
|
||||||
|
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Initialize();
|
||||||
|
void ActivateController(HidController controller);
|
||||||
|
void DeactivateController(HidController controller);
|
||||||
|
|
||||||
|
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||||
|
void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||||
|
void UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||||
|
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T>
|
||||||
|
void MakeController(HidController controller, u8* shared_memory) {
|
||||||
|
if constexpr (std::is_constructible_v<T, Core::System&, u8*>) {
|
||||||
|
controllers[static_cast<std::size_t>(controller)] =
|
||||||
|
std::make_unique<T>(system, shared_memory);
|
||||||
|
} else {
|
||||||
|
controllers[static_cast<std::size_t>(controller)] =
|
||||||
|
std::make_unique<T>(system.HIDCore(), shared_memory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) {
|
||||||
|
controllers[static_cast<std::size_t>(controller)] =
|
||||||
|
std::make_unique<T>(system.HIDCore(), shared_memory, service_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_initialized{false};
|
||||||
|
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
||||||
|
controllers{};
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
|
KernelHelpers::ServiceContext service_context;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
||||||
|
public:
|
||||||
|
explicit IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource);
|
||||||
|
~IAppletResource() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetSharedMemoryHandle(HLERequestContext& ctx);
|
||||||
|
|
||||||
|
std::shared_ptr<Core::Timing::EventType> npad_update_event;
|
||||||
|
std::shared_ptr<Core::Timing::EventType> default_update_event;
|
||||||
|
std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event;
|
||||||
|
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Service::HID
|
|
@ -10,7 +10,8 @@
|
||||||
#include "core/hle/kernel/k_page_table.h"
|
#include "core/hle/kernel/k_page_table.h"
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid_server.h"
|
||||||
|
#include "core/hle/service/hid/resource_manager.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/memory/cheat_engine.h"
|
#include "core/memory/cheat_engine.h"
|
||||||
|
@ -54,13 +55,13 @@ void StandardVmCallbacks::MemoryWrite(VAddr address, const void* data, u64 size)
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 StandardVmCallbacks::HidKeysDown() {
|
u64 StandardVmCallbacks::HidKeysDown() {
|
||||||
const auto hid = system.ServiceManager().GetService<Service::HID::Hid>("hid");
|
const auto hid = system.ServiceManager().GetService<Service::HID::IHidServer>("hid");
|
||||||
if (hid == nullptr) {
|
if (hid == nullptr) {
|
||||||
LOG_WARNING(CheatEngine, "Attempted to read input state, but hid is not initialized!");
|
LOG_WARNING(CheatEngine, "Attempted to read input state, but hid is not initialized!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto applet_resource = hid->GetAppletResource();
|
const auto applet_resource = hid->GetResourceManager();
|
||||||
if (applet_resource == nullptr) {
|
if (applet_resource == nullptr) {
|
||||||
LOG_WARNING(CheatEngine,
|
LOG_WARNING(CheatEngine,
|
||||||
"Attempted to read input state, but applet resource is not initialized!");
|
"Attempted to read input state, but applet resource is not initialized!");
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "core/hid/hid_core.h"
|
#include "core/hid/hid_core.h"
|
||||||
#include "core/hid/hid_types.h"
|
#include "core/hid/hid_types.h"
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
#include "ui_qt_controller.h"
|
#include "ui_qt_controller.h"
|
||||||
#include "yuzu/applets/qt_controller.h"
|
#include "yuzu/applets/qt_controller.h"
|
||||||
|
|
Loading…
Reference in a new issue