2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-04-17 02:58:36 +02:00
|
|
|
|
|
|
|
#pragma once
|
2019-03-05 16:09:27 +01:00
|
|
|
|
2020-07-16 01:14:21 +02:00
|
|
|
#include <chrono>
|
2018-12-29 01:29:44 +01:00
|
|
|
|
2020-07-16 01:14:21 +02:00
|
|
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
2021-06-28 23:41:24 +02:00
|
|
|
#include "core/hle/service/kernel_helpers.h"
|
2018-12-24 22:19:16 +01:00
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
2019-02-12 18:32:15 +01:00
|
|
|
namespace Core::Timing {
|
2018-12-24 22:19:16 +01:00
|
|
|
struct EventType;
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:36:46 +01:00
|
|
|
namespace Service::SM {
|
2018-10-05 16:23:21 +02:00
|
|
|
class ServiceManager;
|
|
|
|
}
|
2018-01-15 03:24:50 +01:00
|
|
|
|
2018-04-20 03:41:44 +02:00
|
|
|
namespace Service::HID {
|
2014-04-17 02:58:36 +02:00
|
|
|
|
2018-12-24 22:19:16 +01:00
|
|
|
enum class HidController : std::size_t {
|
|
|
|
DebugPad,
|
|
|
|
Touchscreen,
|
|
|
|
Mouse,
|
|
|
|
Keyboard,
|
|
|
|
XPad,
|
2021-01-10 18:37:19 +01:00
|
|
|
HomeButton,
|
|
|
|
SleepButton,
|
|
|
|
CaptureButton,
|
|
|
|
InputDetector,
|
|
|
|
UniquePad,
|
2018-12-24 22:19:16 +01:00
|
|
|
NPad,
|
|
|
|
Gesture,
|
2021-01-10 18:37:19 +01:00
|
|
|
ConsoleSixAxisSensor,
|
2022-01-19 03:08:56 +01:00
|
|
|
Palma,
|
2018-12-24 22:19:16 +01:00
|
|
|
|
|
|
|
MaxControllers,
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
|
|
|
public:
|
2021-06-28 23:41:24 +02:00
|
|
|
explicit IAppletResource(Core::System& system_,
|
|
|
|
KernelHelpers::ServiceContext& service_context_);
|
2018-12-24 22:19:16 +01: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 22:30:32 +02:00
|
|
|
void MakeController(HidController controller, u8* shared_memory) {
|
|
|
|
controllers[static_cast<std::size_t>(controller)] =
|
|
|
|
std::make_unique<T>(system.HIDCore(), shared_memory);
|
2018-12-24 22:19:16 +01:00
|
|
|
}
|
2021-06-28 23:41:24 +02:00
|
|
|
template <typename T>
|
2022-04-19 22:30:32 +02:00
|
|
|
void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) {
|
2021-06-28 23:41:24 +02:00
|
|
|
controllers[static_cast<std::size_t>(controller)] =
|
2022-04-19 22:30:32 +02:00
|
|
|
std::make_unique<T>(system.HIDCore(), shared_memory, service_context);
|
2021-06-28 23:41:24 +02:00
|
|
|
}
|
2018-12-24 22:19:16 +01:00
|
|
|
|
|
|
|
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
|
2020-07-28 01:00:41 +02:00
|
|
|
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2021-11-15 04:28:38 +01:00
|
|
|
void UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2020-09-24 00:51:09 +02:00
|
|
|
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2018-12-24 22:19:16 +01:00
|
|
|
|
2021-06-28 23:41:24 +02:00
|
|
|
KernelHelpers::ServiceContext& service_context;
|
|
|
|
|
2019-11-27 03:48:56 +01:00
|
|
|
std::shared_ptr<Core::Timing::EventType> pad_update_event;
|
2021-11-15 04:28:38 +01:00
|
|
|
std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event;
|
2020-09-24 00:51:09 +02:00
|
|
|
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
2018-12-24 22:19:16 +01:00
|
|
|
|
|
|
|
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
|
|
|
controllers{};
|
|
|
|
};
|
|
|
|
|
|
|
|
class Hid final : public ServiceFramework<Hid> {
|
|
|
|
public:
|
2020-11-26 21:19:08 +01:00
|
|
|
explicit Hid(Core::System& system_);
|
2018-12-24 22:19:16 +01:00
|
|
|
~Hid() override;
|
|
|
|
|
|
|
|
std::shared_ptr<IAppletResource> GetAppletResource();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateAppletResource(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateDebugPad(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateTouchScreen(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateMouse(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateKeyboard(Kernel::HLERequestContext& ctx);
|
2020-06-22 11:37:46 +02:00
|
|
|
void SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx);
|
2020-10-06 13:00:18 +02:00
|
|
|
void ActivateXpad(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetXpadIDs(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-06-22 11:37:46 +02:00
|
|
|
void StopSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2022-04-13 19:52:29 +02:00
|
|
|
void IsSixAxisSensorFusionEnabled(Kernel::HLERequestContext& ctx);
|
2020-09-30 02:37:22 +02:00
|
|
|
void EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx);
|
2021-01-24 17:27:04 +01:00
|
|
|
void SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
2020-06-21 21:48:02 +02:00
|
|
|
void GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx);
|
2021-06-11 21:35:35 +02:00
|
|
|
void IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2022-05-22 00:03:08 +02:00
|
|
|
void EnableSixAxisSensorUnalteredPassthrough(Kernel::HLERequestContext& ctx);
|
|
|
|
void IsSixAxisSensorUnalteredPassthroughEnabled(Kernel::HLERequestContext& ctx);
|
2022-05-22 00:10:20 +02:00
|
|
|
void LoadSixAxisSensorCalibrationParameter(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSixAxisSensorIcInformation(Kernel::HLERequestContext& ctx);
|
2022-05-22 00:21:45 +02:00
|
|
|
void ResetIsSixAxisSensorDeviceNewlyAssigned(Kernel::HLERequestContext& ctx);
|
2020-10-06 13:00:18 +02:00
|
|
|
void ActivateGesture(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateNpad(Kernel::HLERequestContext& ctx);
|
2019-09-22 00:17:46 +02:00
|
|
|
void DeactivateNpad(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx);
|
|
|
|
void DisconnectNpad(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPlayerLedPattern(Kernel::HLERequestContext& ctx);
|
2020-10-06 13:00:18 +02:00
|
|
|
void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx);
|
2019-09-14 23:09:14 +02:00
|
|
|
void SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx);
|
|
|
|
void MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartLrAssignmentMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void StopLrAssignmentMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void SwapNpadAssignment(Kernel::HLERequestContext& ctx);
|
2020-09-30 12:34:08 +02:00
|
|
|
void IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& ctx);
|
2021-04-08 09:41:06 +02:00
|
|
|
void SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx);
|
2021-12-06 05:41:21 +01:00
|
|
|
void SetNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx);
|
|
|
|
void ClearNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx);
|
2020-10-06 13:00:18 +02:00
|
|
|
void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void SendVibrationValue(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetActualVibrationValue(Kernel::HLERequestContext& ctx);
|
|
|
|
void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx);
|
2019-09-04 08:42:42 +02:00
|
|
|
void PermitVibration(Kernel::HLERequestContext& ctx);
|
|
|
|
void IsVibrationPermitted(Kernel::HLERequestContext& ctx);
|
2020-10-06 13:00:18 +02:00
|
|
|
void SendVibrationValues(Kernel::HLERequestContext& ctx);
|
2021-02-16 10:46:56 +01:00
|
|
|
void SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx);
|
2020-10-06 13:00:18 +02:00
|
|
|
void BeginPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
2020-10-11 14:35:40 +02:00
|
|
|
void IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
void ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-06-22 11:37:46 +02:00
|
|
|
void StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-04-26 00:30:52 +02:00
|
|
|
void StopSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-03-27 15:48:01 +01:00
|
|
|
void InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-06-22 11:37:46 +02:00
|
|
|
void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx);
|
2022-02-12 21:32:11 +01:00
|
|
|
void IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx);
|
2022-01-19 03:08:56 +01:00
|
|
|
void GetPalmaConnectionHandle(Kernel::HLERequestContext& ctx);
|
|
|
|
void InitializePalma(Kernel::HLERequestContext& ctx);
|
|
|
|
void AcquirePalmaOperationCompleteEvent(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPalmaOperationInfo(Kernel::HLERequestContext& ctx);
|
|
|
|
void PlayPalmaActivity(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPalmaFrModeType(Kernel::HLERequestContext& ctx);
|
|
|
|
void ReadPalmaStep(Kernel::HLERequestContext& ctx);
|
|
|
|
void EnablePalmaStep(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetPalmaStep(Kernel::HLERequestContext& ctx);
|
|
|
|
void ReadPalmaApplicationSection(Kernel::HLERequestContext& ctx);
|
|
|
|
void WritePalmaApplicationSection(Kernel::HLERequestContext& ctx);
|
|
|
|
void ReadPalmaUniqueCode(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPalmaUniqueCodeInvalid(Kernel::HLERequestContext& ctx);
|
|
|
|
void WritePalmaActivityEntry(Kernel::HLERequestContext& ctx);
|
|
|
|
void WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx);
|
|
|
|
void WritePalmaWaveEntry(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx);
|
|
|
|
void SuspendPalmaFeature(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPalmaOperationResult(Kernel::HLERequestContext& ctx);
|
|
|
|
void ReadPalmaPlayLog(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetPalmaPlayLog(Kernel::HLERequestContext& ctx);
|
2020-06-22 11:37:46 +02:00
|
|
|
void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
|
2022-01-19 03:08:56 +01:00
|
|
|
void SetIsPalmaPairedConnectable(Kernel::HLERequestContext& ctx);
|
|
|
|
void PairPalma(Kernel::HLERequestContext& ctx);
|
2020-06-22 11:37:46 +02:00
|
|
|
void SetPalmaBoostMode(Kernel::HLERequestContext& ctx);
|
2022-01-19 03:08:56 +01:00
|
|
|
void CancelWritePalmaWaveEntry(Kernel::HLERequestContext& ctx);
|
|
|
|
void EnablePalmaBoostMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPalmaBluetoothAddress(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetDisallowedPalmaConnection(Kernel::HLERequestContext& ctx);
|
2020-11-27 04:15:48 +01:00
|
|
|
void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetNpadCommunicationMode(Kernel::HLERequestContext& ctx);
|
2021-09-10 17:09:22 +02:00
|
|
|
void SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx);
|
2022-04-27 05:22:27 +02:00
|
|
|
void IsFirmwareUpdateNeededForNotification(Kernel::HLERequestContext& ctx);
|
2018-12-24 22:19:16 +01:00
|
|
|
|
|
|
|
std::shared_ptr<IAppletResource> applet_resource;
|
2021-06-28 23:41:24 +02:00
|
|
|
|
|
|
|
KernelHelpers::ServiceContext service_context;
|
2018-12-24 22:19:16 +01:00
|
|
|
};
|
|
|
|
|
2018-01-15 03:24:50 +01:00
|
|
|
/// Registers all HID services with the specified service manager.
|
2019-09-21 10:43:43 +02:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
2018-01-15 03:24:50 +01:00
|
|
|
|
2018-04-20 03:41:44 +02:00
|
|
|
} // namespace Service::HID
|