Implement a few HID Functions + Fix FAB handler

This commit is contained in:
◱ PixelyIon 2020-09-21 08:20:14 +05:30 committed by ◱ PixelyIon
parent 4970e58999
commit 157c54f918
3 changed files with 58 additions and 4 deletions

View File

@ -10,12 +10,15 @@ using namespace skyline::input;
namespace skyline::service::hid { namespace skyline::service::hid {
IHidServer::IHidServer(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, { IHidServer::IHidServer(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, {
{0x0, SFUNC(IHidServer::CreateAppletResource)}, {0x0, SFUNC(IHidServer::CreateAppletResource)},
{0x1, SFUNC(IHidServer::ActivateDebugPad)},
{0xB, SFUNC(IHidServer::ActivateTouchScreen)},
{0x64, SFUNC(IHidServer::SetSupportedNpadStyleSet)}, {0x64, SFUNC(IHidServer::SetSupportedNpadStyleSet)},
{0x64, SFUNC(IHidServer::GetSupportedNpadStyleSet)}, {0x65, SFUNC(IHidServer::GetSupportedNpadStyleSet)},
{0x66, SFUNC(IHidServer::SetSupportedNpadIdType)}, {0x66, SFUNC(IHidServer::SetSupportedNpadIdType)},
{0x67, SFUNC(IHidServer::ActivateNpad)}, {0x67, SFUNC(IHidServer::ActivateNpad)},
{0x68, SFUNC(IHidServer::DeactivateNpad)}, {0x68, SFUNC(IHidServer::DeactivateNpad)},
{0x6A, SFUNC(IHidServer::AcquireNpadStyleSetUpdateEventHandle)}, {0x6A, SFUNC(IHidServer::AcquireNpadStyleSetUpdateEventHandle)},
{0x6C, SFUNC(IHidServer::GetPlayerLedPattern)},
{0x6D, SFUNC(IHidServer::ActivateNpadWithRevision)}, {0x6D, SFUNC(IHidServer::ActivateNpadWithRevision)},
{0x78, SFUNC(IHidServer::SetNpadJoyHoldType)}, {0x78, SFUNC(IHidServer::SetNpadJoyHoldType)},
{0x79, SFUNC(IHidServer::GetNpadJoyHoldType)}, {0x79, SFUNC(IHidServer::GetNpadJoyHoldType)},
@ -31,6 +34,15 @@ namespace skyline::service::hid {
return {}; return {};
} }
Result IHidServer::ActivateDebugPad(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
return {};
}
Result IHidServer::ActivateTouchScreen(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
state.input->touch.Activate();
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);
@ -80,6 +92,33 @@ namespace skyline::service::hid {
return {}; return {};
} }
Result IHidServer::GetPlayerLedPattern(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto id = request.Pop<NpadId>();
response.Push<u64>([id] {
switch (id) {
case NpadId::Player1:
return 0b0001;
case NpadId::Player2:
return 0b0011;
case NpadId::Player3:
return 0b0111;
case NpadId::Player4:
return 0b1111;
case NpadId::Player5:
return 0b1001;
case NpadId::Player6:
return 0b0101;
case NpadId::Player7:
return 0b1101;
case NpadId::Player8:
return 0b0110;
default:
return 0b0000;
}
}());
return {};
}
Result IHidServer::ActivateNpadWithRevision(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IHidServer::ActivateNpadWithRevision(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
state.input->npad.Activate(); state.input->npad.Activate();
return {}; return {};

View File

@ -20,6 +20,16 @@ namespace skyline::service::hid {
*/ */
Result CreateAppletResource(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); Result CreateAppletResource(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief This would activate the debug pad (if hid:dbg was used) on a development device
*/
Result ActivateDebugPad(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief This activates the touch screen (if it's disabled, it is enabled by default)
*/
Result ActivateTouchScreen(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/** /**
* @brief This sets the style of controllers supported (https://switchbrew.org/wiki/HID_services#SetSupportedNpadStyleSet) * @brief This sets the style of controllers supported (https://switchbrew.org/wiki/HID_services#SetSupportedNpadStyleSet)
*/ */
@ -50,6 +60,11 @@ namespace skyline::service::hid {
*/ */
Result AcquireNpadStyleSetUpdateEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); Result AcquireNpadStyleSetUpdateEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief This requests the LED pattern which represents a particular Player
*/
Result GetPlayerLedPattern(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/** /**
* @brief This requests the activation of controllers with a specific HID revision (https://switchbrew.org/wiki/HID_services#ActivateNpadWithRevision) * @brief This requests the activation of controllers with a specific HID revision (https://switchbrew.org/wiki/HID_services#ActivateNpadWithRevision)
*/ */

View File

@ -173,15 +173,15 @@ class MainActivity : AppCompatActivity() {
settings_fab.setOnClickListener { startActivityForResult(Intent(this, SettingsActivity::class.java), 3) } settings_fab.setOnClickListener { startActivityForResult(Intent(this, SettingsActivity::class.java), 3) }
open_fab.setOnClickListener { startActivity(Intent(this, LogActivity::class.java)) } open_fab.setOnClickListener {
log_fab.setOnClickListener {
startActivityForResult(Intent(Intent.ACTION_OPEN_DOCUMENT).apply { startActivityForResult(Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE) addCategory(Intent.CATEGORY_OPENABLE)
type = "*/*" type = "*/*"
}, 2) }, 2)
} }
log_fab.setOnClickListener { startActivity(Intent(this, LogActivity::class.java)) }
setupAppList() setupAppList()
app_list.addOnScrollListener(object : RecyclerView.OnScrollListener() { app_list.addOnScrollListener(object : RecyclerView.OnScrollListener() {