Merge pull request #12734 from german77/enable-applet

service: hid: Implement EnableAppletForInput
This commit is contained in:
liamwhite 2024-01-21 19:15:53 -05:00 committed by GitHub
commit 57ff934f0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -533,7 +533,7 @@ void IHidSystemServer::EnableAppletToGetInput(HLERequestContext& ctx) {
parameters.is_enabled, parameters.applet_resource_user_id); parameters.is_enabled, parameters.applet_resource_user_id);
GetResourceManager()->EnableInput(parameters.applet_resource_user_id, parameters.is_enabled); GetResourceManager()->EnableInput(parameters.applet_resource_user_id, parameters.is_enabled);
// GetResourceManager()->GetNpad()->EnableInput(parameters.applet_resource_user_id); GetResourceManager()->GetNpad()->EnableAppletToGetInput(parameters.applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -596,7 +596,7 @@ void IHidSystemServer::EnableAppletToGetPadInput(HLERequestContext& ctx) {
parameters.is_enabled, parameters.applet_resource_user_id); parameters.is_enabled, parameters.applet_resource_user_id);
GetResourceManager()->EnablePadInput(parameters.applet_resource_user_id, parameters.is_enabled); GetResourceManager()->EnablePadInput(parameters.applet_resource_user_id, parameters.is_enabled);
// GetResourceManager()->GetNpad()->EnableInput(parameters.applet_resource_user_id); GetResourceManager()->GetNpad()->EnableAppletToGetInput(parameters.applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View File

@ -480,6 +480,10 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
continue; continue;
} }
if (!data->flag.enable_pad_input) {
continue;
}
RequestPadStateUpdate(aruid, controller.device->GetNpadIdType()); RequestPadStateUpdate(aruid, controller.device->GetNpadIdType());
auto& pad_state = controller.npad_pad_state; auto& pad_state = controller.npad_pad_state;
auto& libnx_state = controller.npad_libnx_state; auto& libnx_state = controller.npad_libnx_state;
@ -1316,4 +1320,13 @@ void NPad::UpdateHandheldAbstractState() {
abstracted_pads[NpadIdTypeToIndex(Core::HID::NpadIdType::Handheld)].Update(); abstracted_pads[NpadIdTypeToIndex(Core::HID::NpadIdType::Handheld)].Update();
} }
void NPad::EnableAppletToGetInput(u64 aruid) {
std::scoped_lock lock{mutex};
std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex};
for (auto& abstract_pad : abstracted_pads) {
abstract_pad.EnableAppletToGetInput(aruid);
}
}
} // namespace Service::HID } // namespace Service::HID

View File

@ -153,6 +153,8 @@ public:
void UpdateHandheldAbstractState(); void UpdateHandheldAbstractState();
void EnableAppletToGetInput(u64 aruid);
private: private:
struct NpadControllerData { struct NpadControllerData {
NpadInternalState* shared_memory = nullptr; NpadInternalState* shared_memory = nullptr;