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
|
|
|
|
|
|
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
2018-12-22 21:27:44 -05:00
|
|
|
#include "core/hle/service/service.h"
|
2018-12-28 19:29:44 -05:00
|
|
|
|
|
|
|
#include "controllers/controller_base.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
class SharedMemory;
|
|
|
|
}
|
2014-04-16 20:58:36 -04:00
|
|
|
|
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,
|
|
|
|
Unknown1,
|
|
|
|
Unknown2,
|
|
|
|
Unknown3,
|
|
|
|
SixAxisSensor,
|
|
|
|
NPad,
|
|
|
|
Gesture,
|
|
|
|
|
|
|
|
MaxControllers,
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
|
|
|
public:
|
2019-09-22 02:41:34 -04:00
|
|
|
explicit IAppletResource(Core::System& system);
|
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) {
|
2019-09-22 02:41:34 -04:00
|
|
|
controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>(system);
|
2018-12-24 16:19:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
|
2019-03-24 18:11:32 -04:00
|
|
|
void UpdateControllers(u64 userdata, s64 cycles_late);
|
2018-12-24 16:19:16 -05:00
|
|
|
|
2019-11-24 20:15:51 -05:00
|
|
|
std::shared_ptr<Kernel::SharedMemory> shared_mem;
|
2018-12-24 16:19:16 -05:00
|
|
|
|
2019-11-26 21:48:56 -05:00
|
|
|
std::shared_ptr<Core::Timing::EventType> pad_update_event;
|
2019-09-21 04:43:43 -04:00
|
|
|
Core::System& system;
|
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:
|
2019-09-22 02:41:34 -04: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 ActivateXpad(Kernel::HLERequestContext& ctx);
|
2020-06-01 13:38:44 -04:00
|
|
|
void GetXpadIDs(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
void ActivateDebugPad(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateTouchScreen(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateMouse(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateKeyboard(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateGesture(Kernel::HLERequestContext& ctx);
|
|
|
|
void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
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);
|
2018-12-24 16:19:16 -05:00
|
|
|
void BeginPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
|
|
|
void SendVibrationValue(Kernel::HLERequestContext& ctx);
|
|
|
|
void SendVibrationValues(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetActualVibrationValue(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetVibrationDeviceInfo(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);
|
2018-12-24 16:19:16 -05:00
|
|
|
void ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void StopSixAxisSensor(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPalmaBoostMode(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-05-11 11:01:50 -04:00
|
|
|
void SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx);
|
2018-12-24 16:19:16 -05:00
|
|
|
|
|
|
|
std::shared_ptr<IAppletResource> applet_resource;
|
2019-09-21 04:43:43 -04:00
|
|
|
Core::System& system;
|
2018-12-24 16:19:16 -05:00
|
|
|
};
|
|
|
|
|
2017-01-20 15:46:39 -05:00
|
|
|
/// Reload input devices. Used when input configuration changed
|
|
|
|
void ReloadInputDevices();
|
2017-10-12 21:21:49 -04: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
|