mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 23:55:29 +03:00
Stub {Set,Get}NpadHandheldActivationMode in HID
This commit is contained in:
parent
2e197cead5
commit
0182fabc50
@ -48,6 +48,7 @@ namespace skyline::input {
|
|||||||
std::vector<NpadId> supportedIds; //!< The NPadId(s) that are supported by the application
|
std::vector<NpadId> supportedIds; //!< The NPadId(s) that are supported by the application
|
||||||
NpadStyleSet styles; //!< The styles that are supported by the application
|
NpadStyleSet styles; //!< The styles that are supported by the application
|
||||||
NpadJoyOrientation orientation{}; //!< The orientation all of Joy-Cons are in (This affects stick transformation for them)
|
NpadJoyOrientation orientation{}; //!< The orientation all of Joy-Cons are in (This affects stick transformation for them)
|
||||||
|
NpadHandheldActivationMode handheldActivationMode{NpadHandheldActivationMode::Dual}; //!< By default two controllers are required to activate handheld mode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param hid A pointer to HID Shared Memory on the host
|
* @param hid A pointer to HID Shared Memory on the host
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
#include "shared_mem.h"
|
#include "shared_mem.h"
|
||||||
|
|
||||||
namespace skyline::input {
|
namespace skyline::input {
|
||||||
|
/**
|
||||||
|
* @brief How many joycons must be attached for handheld mode to be triggered
|
||||||
|
*/
|
||||||
|
enum class NpadHandheldActivationMode : u64 {
|
||||||
|
Dual = 0,
|
||||||
|
Single = 1,
|
||||||
|
None = 2,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The orientations the Joy-Con(s) can be held in
|
* @brief The orientations the Joy-Con(s) can be held in
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,10 @@ namespace skyline::service::hid {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result IHidServer::StartSixAxisSensor(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
Result IHidServer::SetSupportedNpadStyleSet(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IHidServer::SetSupportedNpadStyleSet(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto styleSet{request.Pop<NpadStyleSet>()};
|
auto styleSet{request.Pop<NpadStyleSet>()};
|
||||||
std::lock_guard lock(state.input->npad.mutex);
|
std::lock_guard lock(state.input->npad.mutex);
|
||||||
@ -137,8 +141,45 @@ namespace skyline::service::hid {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IHidServer::CreateActiveVibrationDeviceList(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IHidServer::SetNpadHandheldActivationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
manager.RegisterService(SRVREG(IActiveVibrationDeviceList), session, response);
|
request.Skip<u64>();
|
||||||
|
auto activationMode{request.Pop<NpadHandheldActivationMode>()};
|
||||||
|
|
||||||
|
std::scoped_lock lock{state.input->npad.mutex};
|
||||||
|
state.input->npad.handheldActivationMode = activationMode;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IHidServer::GetNpadHandheldActivationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
std::scoped_lock lock{state.input->npad.mutex};
|
||||||
|
response.Push(state.input->npad.handheldActivationMode);
|
||||||
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +195,11 @@ namespace skyline::service::hid {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result IHidServer::CreateActiveVibrationDeviceList(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
|
manager.RegisterService(SRVREG(IActiveVibrationDeviceList), session, response);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
Result IHidServer::SendVibrationValues(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IHidServer::SendVibrationValues(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
request.Skip<u64>(); // appletResourceUserId
|
request.Skip<u64>(); // appletResourceUserId
|
||||||
|
|
||||||
@ -179,34 +225,4 @@ namespace skyline::service::hid {
|
|||||||
|
|
||||||
return {};
|
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 {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -119,10 +119,14 @@ namespace skyline::service::hid {
|
|||||||
Result SetNpadJoyAssignmentModeDual(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
Result SetNpadJoyAssignmentModeDual(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns an instance of #IActiveVibrationDeviceList
|
* @url https://switchbrew.org/wiki/HID_services#SetNpadHandheldActivationMode
|
||||||
* @url https://switchbrew.org/wiki/HID_services#CreateActiveVibrationDeviceList
|
|
||||||
*/
|
*/
|
||||||
Result CreateActiveVibrationDeviceList(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
Result SetNpadHandheldActivationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url https://switchbrew.org/wiki/HID_services#GetNpadHandheldActivationMode
|
||||||
|
*/
|
||||||
|
Result GetNpadHandheldActivationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the current vibration state of a device
|
* @brief Returns the current vibration state of a device
|
||||||
@ -136,6 +140,12 @@ namespace skyline::service::hid {
|
|||||||
*/
|
*/
|
||||||
Result SendVibrationValue(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
Result SendVibrationValue(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns an instance of #IActiveVibrationDeviceList
|
||||||
|
* @url https://switchbrew.org/wiki/HID_services#CreateActiveVibrationDeviceList
|
||||||
|
*/
|
||||||
|
Result CreateActiveVibrationDeviceList(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send vibration values to a HID device
|
* @brief Send vibration values to a HID device
|
||||||
* @url https://switchbrew.org/wiki/HID_services#SendVibrationValues
|
* @url https://switchbrew.org/wiki/HID_services#SendVibrationValues
|
||||||
@ -160,6 +170,8 @@ namespace skyline::service::hid {
|
|||||||
SFUNC(0x7A, IHidServer, SetNpadJoyAssignmentModeSingleByDefault),
|
SFUNC(0x7A, IHidServer, SetNpadJoyAssignmentModeSingleByDefault),
|
||||||
SFUNC(0x7B, IHidServer, SetNpadJoyAssignmentModeSingle),
|
SFUNC(0x7B, IHidServer, SetNpadJoyAssignmentModeSingle),
|
||||||
SFUNC(0x7C, IHidServer, SetNpadJoyAssignmentModeDual),
|
SFUNC(0x7C, IHidServer, SetNpadJoyAssignmentModeDual),
|
||||||
|
SFUNC(0x80, IHidServer, SetNpadHandheldActivationMode),
|
||||||
|
SFUNC(0x81, IHidServer, GetNpadHandheldActivationMode),
|
||||||
SFUNC(0xCB, IHidServer, CreateActiveVibrationDeviceList),
|
SFUNC(0xCB, IHidServer, CreateActiveVibrationDeviceList),
|
||||||
SFUNC(0xC8, IHidServer, GetVibrationDeviceInfo),
|
SFUNC(0xC8, IHidServer, GetVibrationDeviceInfo),
|
||||||
SFUNC(0xC9, IHidServer, SendVibrationValue),
|
SFUNC(0xC9, IHidServer, SendVibrationValue),
|
||||||
|
Loading…
Reference in New Issue
Block a user