2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-04-17 00:58:36 +00:00
|
|
|
|
|
|
|
#pragma once
|
2019-03-05 15:09:27 +00:00
|
|
|
|
2020-07-15 23:14:21 +00:00
|
|
|
#include <chrono>
|
2018-12-29 00:29:44 +00:00
|
|
|
|
2020-07-15 23:14:21 +00:00
|
|
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
2021-06-28 21:41:24 +00:00
|
|
|
#include "core/hle/service/kernel_helpers.h"
|
2018-12-24 21:19:16 +00:00
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
2019-02-12 17:32:15 +00:00
|
|
|
namespace Core::Timing {
|
2018-12-24 21:19:16 +00:00
|
|
|
struct EventType;
|
|
|
|
}
|
|
|
|
|
2019-02-27 16:36:46 +00:00
|
|
|
namespace Service::SM {
|
2018-10-05 14:23:21 +00:00
|
|
|
class ServiceManager;
|
|
|
|
}
|
2018-01-15 02:24:50 +00:00
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
namespace Service::HID {
|
2014-04-17 00:58:36 +00:00
|
|
|
|
2018-12-24 21:19:16 +00:00
|
|
|
enum class HidController : std::size_t {
|
|
|
|
DebugPad,
|
|
|
|
Touchscreen,
|
|
|
|
Mouse,
|
|
|
|
Keyboard,
|
|
|
|
XPad,
|
2021-01-10 17:37:19 +00:00
|
|
|
HomeButton,
|
|
|
|
SleepButton,
|
|
|
|
CaptureButton,
|
|
|
|
InputDetector,
|
|
|
|
UniquePad,
|
2018-12-24 21:19:16 +00:00
|
|
|
NPad,
|
|
|
|
Gesture,
|
2021-01-10 17:37:19 +00:00
|
|
|
ConsoleSixAxisSensor,
|
2023-02-24 18:52:32 +00:00
|
|
|
DebugMouse,
|
2022-01-19 02:08:56 +00:00
|
|
|
Palma,
|
2018-12-24 21:19:16 +00:00
|
|
|
|
|
|
|
MaxControllers,
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
|
|
|
public:
|
2021-06-28 21:41:24 +00:00
|
|
|
explicit IAppletResource(Core::System& system_,
|
|
|
|
KernelHelpers::ServiceContext& service_context_);
|
2018-12-24 21:19:16 +00:00
|
|
|
~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>
|
2022-04-19 20:30:32 +00:00
|
|
|
void MakeController(HidController controller, u8* shared_memory) {
|
2023-02-24 17:29:55 +00:00
|
|
|
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);
|
|
|
|
}
|
2018-12-24 21:19:16 +00:00
|
|
|
}
|
2023-02-24 17:29:55 +00:00
|
|
|
|
2021-06-28 21:41:24 +00:00
|
|
|
template <typename T>
|
2022-04-19 20:30:32 +00:00
|
|
|
void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) {
|
2021-06-28 21:41:24 +00:00
|
|
|
controllers[static_cast<std::size_t>(controller)] =
|
2022-04-19 20:30:32 +00:00
|
|
|
std::make_unique<T>(system.HIDCore(), shared_memory, service_context);
|
2021-06-28 21:41:24 +00:00
|
|
|
}
|
2018-12-24 21:19:16 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetSharedMemoryHandle(HLERequestContext& ctx);
|
2020-07-27 23:00:41 +00:00
|
|
|
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2022-11-05 17:40:19 +00:00
|
|
|
void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2021-11-15 03:28:38 +00:00
|
|
|
void UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2020-09-23 22:51:09 +00:00
|
|
|
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2018-12-24 21:19:16 +00:00
|
|
|
|
2021-06-28 21:41:24 +00:00
|
|
|
KernelHelpers::ServiceContext& service_context;
|
|
|
|
|
2022-11-05 17:40:19 +00:00
|
|
|
std::shared_ptr<Core::Timing::EventType> npad_update_event;
|
|
|
|
std::shared_ptr<Core::Timing::EventType> default_update_event;
|
2021-11-15 03:28:38 +00:00
|
|
|
std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event;
|
2020-09-23 22:51:09 +00:00
|
|
|
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
2018-12-24 21:19:16 +00:00
|
|
|
|
|
|
|
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
|
|
|
controllers{};
|
|
|
|
};
|
|
|
|
|
|
|
|
class Hid final : public ServiceFramework<Hid> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit Hid(Core::System& system_);
|
2018-12-24 21:19:16 +00:00
|
|
|
~Hid() override;
|
|
|
|
|
|
|
|
std::shared_ptr<IAppletResource> GetAppletResource();
|
|
|
|
|
|
|
|
private:
|
2023-02-19 19:42:12 +00:00
|
|
|
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);
|
2023-03-27 05:56:00 +00:00
|
|
|
void SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx);
|
2023-02-19 19:42:12 +00:00
|
|
|
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);
|
2018-12-24 21:19:16 +00:00
|
|
|
|
|
|
|
std::shared_ptr<IAppletResource> applet_resource;
|
2021-06-28 21:41:24 +00:00
|
|
|
|
|
|
|
KernelHelpers::ServiceContext service_context;
|
2018-12-24 21:19:16 +00:00
|
|
|
};
|
|
|
|
|
2023-02-18 21:26:48 +00:00
|
|
|
void LoopProcess(Core::System& system);
|
2018-01-15 02:24:50 +00:00
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
} // namespace Service::HID
|