Stub GyroscopeZeroDriftMode

Related service calls are called in a loop by SM3DW. A variable tracking zero drift mode has been added to `npad_device`, but it's unused at the moment.
This commit is contained in:
lynxnb 2022-11-28 09:12:57 +01:00 committed by Billy Laws
parent dcc3047ba8
commit 6599c1dccf
4 changed files with 57 additions and 1 deletions

View File

@ -10,7 +10,8 @@ namespace skyline::input {
: manager(manager), : manager(manager),
section(section), section(section),
id(id), id(id),
updateEvent(std::make_shared<kernel::type::KEvent>(manager.state, false)) { updateEvent(std::make_shared<kernel::type::KEvent>(manager.state, false)),
gyroZeroDriftMode(GyroscopeZeroDriftMode::Standard) {
constexpr std::size_t InitializeEntryCount{19}; //!< HW initializes the first 19 entries constexpr std::size_t InitializeEntryCount{19}; //!< HW initializes the first 19 entries
ResetDeviceProperties(); ResetDeviceProperties();

View File

@ -70,6 +70,8 @@ namespace skyline::input {
/** /**
* @brief A handle to a specific device addressed by its ID and type * @brief A handle to a specific device addressed by its ID and type
* @note This is used by both Six-Axis and Vibration * @note This is used by both Six-Axis and Vibration
* @url https://switchbrew.org/wiki/HID_services#SixAxisSensorHandle
* @url https://switchbrew.org/wiki/HID_services#VibrationDeviceHandle
*/ */
union __attribute__((__packed__)) NpadDeviceHandle { union __attribute__((__packed__)) NpadDeviceHandle {
u32 raw; u32 raw;
@ -125,6 +127,15 @@ namespace skyline::input {
}; };
static_assert(sizeof(NpadVibrationValue) == 0x10); static_assert(sizeof(NpadVibrationValue) == 0x10);
/**
* @url https://switchbrew.org/wiki/HID_services#GyroscopeZeroDriftMode
*/
enum class GyroscopeZeroDriftMode : u32 {
Loose = 0,
Standard = 1,
Tight = 2,
};
class NpadManager; class NpadManager;
/** /**
@ -170,6 +181,7 @@ namespace skyline::input {
NpadControllerType type{}; NpadControllerType type{};
NpadConnectionState connectionState{}; NpadConnectionState connectionState{};
std::shared_ptr<kernel::type::KEvent> updateEvent; //!< This event is triggered on the controller's style changing std::shared_ptr<kernel::type::KEvent> updateEvent; //!< This event is triggered on the controller's style changing
GyroscopeZeroDriftMode gyroZeroDriftMode;
NpadDevice(NpadManager &manager, NpadSection &section, NpadId id); NpadDevice(NpadManager &manager, NpadSection &section, NpadId id);

View File

@ -41,6 +41,28 @@ namespace skyline::service::hid {
return {}; return {};
} }
Result IHidServer::SetGyroscopeZeroDriftMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto npadHandle{request.Pop<NpadDeviceHandle>()};
auto mode{request.Pop<GyroscopeZeroDriftMode>()};
state.input->npad[npadHandle.id].gyroZeroDriftMode = mode;
return {};
}
Result IHidServer::GetGyroscopeZeroDriftMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto npadHandle{request.Pop<NpadDeviceHandle>()};
response.Push(state.input->npad[npadHandle.id].gyroZeroDriftMode);
return {};
}
Result IHidServer::ResetGyroscopeZeroDriftMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto npadHandle{request.Pop<NpadDeviceHandle>()};
state.input->npad[npadHandle.id].gyroZeroDriftMode = GyroscopeZeroDriftMode::Standard;
return {};
}
Result IHidServer::IsSixAxisSensorAtRest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IHidServer::IsSixAxisSensorAtRest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
response.Push<u8>(1); response.Push<u8>(1);
return {}; return {};

View File

@ -57,6 +57,24 @@ namespace skyline::service::hid {
*/ */
Result StopSixAxisSensor(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); Result StopSixAxisSensor(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief Sets the gyroscope zero drift mode
* @url https://switchbrew.org/wiki/HID_services#SetGyroscopeZeroDriftMode
*/
Result SetGyroscopeZeroDriftMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief Returns the gyroscope zero drift mode
* @url https://switchbrew.org/wiki/HID_services#GetGyroscopeZeroDriftMode
*/
Result GetGyroscopeZeroDriftMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief Rsets the gyroscope zero drift mode to Standard
* @url https://switchbrew.org/wiki/HID_services#ResetGyroscopeZeroDriftMode
*/
Result ResetGyroscopeZeroDriftMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/** /**
* @url https://switchbrew.org/wiki/HID_services#IsSixAxisSensorAtRest * @url https://switchbrew.org/wiki/HID_services#IsSixAxisSensorAtRest
*/ */
@ -202,6 +220,9 @@ namespace skyline::service::hid {
SFUNC(0x1F, IHidServer, ActivateKeyboard), SFUNC(0x1F, IHidServer, ActivateKeyboard),
SFUNC(0x42, IHidServer, StartSixAxisSensor), SFUNC(0x42, IHidServer, StartSixAxisSensor),
SFUNC(0x43, IHidServer, StopSixAxisSensor), SFUNC(0x43, IHidServer, StopSixAxisSensor),
SFUNC(0x4F, IHidServer, SetGyroscopeZeroDriftMode),
SFUNC(0x50, IHidServer, GetGyroscopeZeroDriftMode),
SFUNC(0x51, IHidServer, ResetGyroscopeZeroDriftMode),
SFUNC(0x52, IHidServer, IsSixAxisSensorAtRest), SFUNC(0x52, IHidServer, IsSixAxisSensorAtRest),
SFUNC(0x64, IHidServer, SetSupportedNpadStyleSet), SFUNC(0x64, IHidServer, SetSupportedNpadStyleSet),
SFUNC(0x65, IHidServer, GetSupportedNpadStyleSet), SFUNC(0x65, IHidServer, GetSupportedNpadStyleSet),