mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Implement IHidServer Functions
Add GetVibrationDeviceInfo and StartSixAxisSensor
This commit is contained in:
parent
9f51664b1d
commit
e8cc760b10
@ -134,7 +134,7 @@ namespace skyline::input {
|
||||
section.header.singleColorStatus = NpadColorReadStatus::Success; // Single color is also written for dual controllers
|
||||
section.header.singleColor = section.header.leftColor; // and is set to the color of the left JC
|
||||
break;
|
||||
|
||||
case NpadControllerType::Gamecube:
|
||||
case NpadControllerType::None:
|
||||
break;
|
||||
}
|
||||
|
@ -83,12 +83,23 @@ namespace skyline::input {
|
||||
return NpadControllerType::JoyconLeft;
|
||||
case 7:
|
||||
return NpadControllerType::JoyconRight;
|
||||
case 8:
|
||||
return NpadControllerType::Gamecube;
|
||||
default:
|
||||
return NpadControllerType::None;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @url https://switchbrew.org/wiki/HID_services#VibrationDeviceInfo
|
||||
*/
|
||||
struct NpadVibrationDeviceInfo {
|
||||
NpadVibrationDeviceType deviceType;
|
||||
NpadVibrationDevicePosition position;
|
||||
};
|
||||
static_assert(sizeof(NpadVibrationDeviceInfo) == 0x8);
|
||||
|
||||
/**
|
||||
* @brief The parameters to produce a vibration using an LRA
|
||||
* @note The vibration is broken into a frequency band with the lower and high range supplied
|
||||
|
@ -14,6 +14,7 @@ namespace skyline::input {
|
||||
JoyconDual = 0b100,
|
||||
JoyconLeft = 0b1000,
|
||||
JoyconRight = 0b10000,
|
||||
Gamecube = 0b100000,
|
||||
};
|
||||
// @fmt:on
|
||||
|
||||
@ -187,6 +188,26 @@ namespace skyline::input {
|
||||
};
|
||||
static_assert(sizeof(NpadDeviceType) == 0x4);
|
||||
|
||||
/**
|
||||
* @url https://switchbrew.org/wiki/HID_services#VibrationDeviceType
|
||||
*/
|
||||
enum class NpadVibrationDeviceType : u32 {
|
||||
Unknown,
|
||||
LinearResonantActuator, //!< LRAs are used on devices that support HD Rumble functionality such as Joy-Cons and the Pro Controller
|
||||
EccentricRotatingMass, //!< ERMs are mainly used in the old GameCube controllers and offer more crude rumble
|
||||
};
|
||||
static_assert(sizeof(NpadVibrationDeviceType) == 0x4);
|
||||
|
||||
/**
|
||||
* @url https://switchbrew.org/wiki/HID_services#VibrationDevicePosition
|
||||
*/
|
||||
enum class NpadVibrationDevicePosition : u32 {
|
||||
None,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
static_assert(sizeof(NpadVibrationDevicePosition) == 0x4);
|
||||
|
||||
/**
|
||||
* @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadSystemProperties
|
||||
*/
|
||||
|
@ -179,4 +179,34 @@ namespace skyline::service::hid {
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Result IHidServer::StartSixAxisSensor(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Result IHidServer::GetVibrationDeviceInfo(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
auto deviceHandle{request.Pop<NpadDeviceHandle>()};
|
||||
auto id{deviceHandle.id};
|
||||
|
||||
if (id > NpadId::Player8 && id != NpadId::Handheld && id != NpadId::Unknown)
|
||||
return result::InvalidNpadId;
|
||||
|
||||
auto vibrationDeviceType{NpadVibrationDeviceType::Unknown};
|
||||
auto vibrationDevicePosition{NpadVibrationDevicePosition::None};
|
||||
|
||||
if (deviceHandle.GetType() == NpadControllerType::Gamecube)
|
||||
vibrationDeviceType = NpadVibrationDeviceType::EccentricRotatingMass;
|
||||
else
|
||||
vibrationDeviceType = NpadVibrationDeviceType::LinearResonantActuator;
|
||||
|
||||
if (vibrationDeviceType == NpadVibrationDeviceType::LinearResonantActuator)
|
||||
if (deviceHandle.isRight)
|
||||
vibrationDevicePosition = NpadVibrationDevicePosition::Right;
|
||||
else
|
||||
vibrationDevicePosition = NpadVibrationDevicePosition::Left;
|
||||
|
||||
response.Push(NpadVibrationDeviceInfo{vibrationDeviceType, vibrationDevicePosition});
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include "IAppletResource.h"
|
||||
|
||||
namespace skyline::service::hid {
|
||||
namespace result {
|
||||
constexpr Result InvalidNpadId(202, 709);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IHidServer or hid service is used to access input devices
|
||||
* @url https://switchbrew.org/wiki/HID_services#hid
|
||||
@ -31,6 +35,12 @@ namespace skyline::service::hid {
|
||||
*/
|
||||
Result ActivateTouchScreen(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||
|
||||
/**
|
||||
* @brief Starts the Six Axis Sensor given an PID
|
||||
* @url https://switchbrew.org/wiki/HID_services#CreateAppletResource
|
||||
*/
|
||||
Result StartSixAxisSensor(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||
|
||||
/**
|
||||
* @brief Sets the style of controllers supported
|
||||
* @url https://switchbrew.org/wiki/HID_services#SetSupportedNpadStyleSet
|
||||
@ -114,6 +124,12 @@ namespace skyline::service::hid {
|
||||
*/
|
||||
Result CreateActiveVibrationDeviceList(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||
|
||||
/**
|
||||
* @brief Returns the current vibration state of a device
|
||||
* @url https://switchbrew.org/wiki/HID_services#GetVibrationDeviceInfo
|
||||
*/
|
||||
Result GetVibrationDeviceInfo(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||
|
||||
/**
|
||||
* @brief Send a single vibration value to a HID device
|
||||
* @url https://switchbrew.org/wiki/HID_services#SendVibrationValue
|
||||
@ -130,6 +146,7 @@ namespace skyline::service::hid {
|
||||
SFUNC(0x0, IHidServer, CreateAppletResource),
|
||||
SFUNC(0x1, IHidServer, ActivateDebugPad),
|
||||
SFUNC(0xB, IHidServer, ActivateTouchScreen),
|
||||
SFUNC(0x42, IHidServer, StartSixAxisSensor),
|
||||
SFUNC(0x64, IHidServer, SetSupportedNpadStyleSet),
|
||||
SFUNC(0x65, IHidServer, GetSupportedNpadStyleSet),
|
||||
SFUNC(0x66, IHidServer, SetSupportedNpadIdType),
|
||||
@ -144,6 +161,7 @@ namespace skyline::service::hid {
|
||||
SFUNC(0x7B, IHidServer, SetNpadJoyAssignmentModeSingle),
|
||||
SFUNC(0x7C, IHidServer, SetNpadJoyAssignmentModeDual),
|
||||
SFUNC(0xCB, IHidServer, CreateActiveVibrationDeviceList),
|
||||
SFUNC(0xC8, IHidServer, GetVibrationDeviceInfo),
|
||||
SFUNC(0xC9, IHidServer, SendVibrationValue),
|
||||
SFUNC(0xCE, IHidServer, SendVibrationValues)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user