2018-01-14 21:24:50 -05:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2014-12-17 00:38:14 -05:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-04-16 20:58:36 -04:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
2019-03-05 10:09:27 -05:00
|
|
|
|
2020-07-15 19:14:21 -04:00
|
|
|
#include <chrono>
|
2018-12-28 19:29:44 -05:00
|
|
|
|
2020-07-15 19:14:21 -04:00
|
|
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
2021-06-28 17:41:24 -04:00
|
|
|
#include "core/hle/service/kernel_helpers.h"
|
2018-12-24 16:19:16 -05:00
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
2019-02-12 12:32:15 -05:00
|
|
|
namespace Core::Timing {
|
2018-12-24 16:19:16 -05:00
|
|
|
struct EventType;
|
|
|
|
}
|
|
|
|
|
2019-02-27 11:36:46 -05:00
|
|
|
namespace Service::SM {
|
2018-10-05 10:23:21 -04:00
|
|
|
class ServiceManager;
|
|
|
|
}
|
2018-01-14 21:24:50 -05:00
|
|
|
|
2018-04-19 21:41:44 -04:00
|
|
|
namespace Service::HID {
|
2014-04-16 20:58:36 -04:00
|
|
|
|
2018-12-24 16:19:16 -05:00
|
|
|
enum class HidController : std::size_t {
|
|
|
|
DebugPad,
|
|
|
|
Touchscreen,
|
|
|
|
Mouse,
|
|
|
|
Keyboard,
|
|
|
|
XPad,
|
2021-01-10 12:37:19 -05:00
|
|
|
HomeButton,
|
|
|
|
SleepButton,
|
|
|
|
CaptureButton,
|
|
|
|
InputDetector,
|
|
|
|
UniquePad,
|
2018-12-24 16:19:16 -05:00
|
|
|
NPad,
|
|
|
|
Gesture,
|
2021-01-10 12:37:19 -05:00
|
|
|
ConsoleSixAxisSensor,
|
2018-12-24 16:19:16 -05:00
|
|
|
|
|
|
|
MaxControllers,
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
|
|
|
public:
|
2021-06-28 17:41:24 -04:00
|
|
|
explicit IAppletResource(Core::System& system_,
|
|
|
|
KernelHelpers::ServiceContext& service_context_);
|
2018-12-24 16:19:16 -05: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>
|
|
|
|
void MakeController(HidController controller) {
|
2021-11-04 21:05:58 -04:00
|
|
|
controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>(system.HIDCore());
|
2018-12-24 16:19:16 -05:00
|
|
|
}
|
2021-06-28 17:41:24 -04:00
|
|
|
template <typename T>
|
|
|
|
void MakeControllerWithServiceContext(HidController controller) {
|
|
|
|
controllers[static_cast<std::size_t>(controller)] =
|
2021-11-04 21:05:58 -04:00
|
|
|
std::make_unique<T>(system.HIDCore(), service_context);
|
2021-06-28 17:41:24 -04:00
|
|
|
}
|
2018-12-24 16:19:16 -05:00
|
|
|
|
|
|
|
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
|
2020-07-27 19:00:41 -04:00
|
|
|
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2020-09-23 18:51:09 -04:00
|
|
|
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
|
2018-12-24 16:19:16 -05:00
|
|
|
|
2021-06-28 17:41:24 -04:00
|
|
|
KernelHelpers::ServiceContext& service_context;
|
|
|
|
|
2019-11-26 21:48:56 -05:00
|
|
|
std::shared_ptr<Core::Timing::EventType> pad_update_event;
|
2020-09-23 18:51:09 -04:00
|
|
|
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
2018-12-24 16:19:16 -05:00
|
|
|
|
|
|
|
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
|
|
|
controllers{};
|
|
|
|
};
|
|
|
|
|
|
|
|
class Hid final : public ServiceFramework<Hid> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit Hid(Core::System& system_);
|
2018-12-24 16:19:16 -05: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 05:37:46 -04:00
|
|
|
void SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx);
|
2020-10-06 07:00:18 -04:00
|
|
|
void ActivateXpad(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetXpadIDs(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-06-22 05:37:46 -04:00
|
|
|
void StopSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-09-29 20:37:22 -04:00
|
|
|
void EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx);
|
2021-01-24 11:27:04 -05:00
|
|
|
void SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
2020-06-21 15:48:02 -04:00
|
|
|
void GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx);
|
2021-06-11 15:35:35 -04:00
|
|
|
void IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-10-06 07:00:18 -04:00
|
|
|
void ActivateGesture(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateNpad(Kernel::HLERequestContext& ctx);
|
2019-09-21 18:17:46 -04:00
|
|
|
void DeactivateNpad(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx);
|
|
|
|
void DisconnectNpad(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPlayerLedPattern(Kernel::HLERequestContext& ctx);
|
2020-10-06 07:00:18 -04:00
|
|
|
void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx);
|
2019-09-14 17:09:14 -04: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 06:34:08 -04:00
|
|
|
void IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& ctx);
|
2021-04-08 03:41:06 -04:00
|
|
|
void SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx);
|
2020-10-06 07:00:18 -04:00
|
|
|
void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void SendVibrationValue(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetActualVibrationValue(Kernel::HLERequestContext& ctx);
|
|
|
|
void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx);
|
2019-09-04 02:42:42 -04:00
|
|
|
void PermitVibration(Kernel::HLERequestContext& ctx);
|
|
|
|
void IsVibrationPermitted(Kernel::HLERequestContext& ctx);
|
2020-10-06 07:00:18 -04:00
|
|
|
void SendVibrationValues(Kernel::HLERequestContext& ctx);
|
2021-02-16 04:46:56 -05:00
|
|
|
void SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx);
|
2020-10-06 07:00:18 -04:00
|
|
|
void BeginPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
2020-10-11 08:35:40 -04:00
|
|
|
void IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-06-22 05:37:46 -04:00
|
|
|
void StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-04-25 18:30:52 -04:00
|
|
|
void StopSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-03-27 10:48:01 -04:00
|
|
|
void InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
2020-06-22 05:37:46 -04:00
|
|
|
void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPalmaBoostMode(Kernel::HLERequestContext& ctx);
|
2020-11-26 22:15:48 -05:00
|
|
|
void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetNpadCommunicationMode(Kernel::HLERequestContext& ctx);
|
2021-09-10 11:09:22 -04:00
|
|
|
void SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
|
|
|
|
std::shared_ptr<IAppletResource> applet_resource;
|
2021-06-28 17:41:24 -04:00
|
|
|
|
|
|
|
KernelHelpers::ServiceContext service_context;
|
2018-12-24 16:19:16 -05:00
|
|
|
};
|
|
|
|
|
2018-01-14 21:24:50 -05:00
|
|
|
/// Registers all HID services with the specified service manager.
|
2019-09-21 04:43:43 -04:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
2018-01-14 21:24:50 -05:00
|
|
|
|
2018-04-19 21:41:44 -04:00
|
|
|
} // namespace Service::HID
|