summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/hid_registration.cpp
blob: 8ed49bac12087576a3cdcaafb8bd04d790df342a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "core/core.h"
#include "core/hle/service/am/hid_registration.h"
#include "core/hle/service/am/process.h"
#include "core/hle/service/hid/hid_server.h"
#include "core/hle/service/sm/sm.h"
#include "hid_core/resource_manager.h"

namespace Service::AM {

HidRegistration::HidRegistration(Core::System& system, Process& process) : m_process(process) {
    m_hid_server = system.ServiceManager().GetService<HID::IHidServer>("hid");

    if (m_process.IsInitialized()) {
        m_hid_server->GetResourceManager()->RegisterAppletResourceUserId(m_process.GetProcessId(),
                                                                         true);
    }
}

HidRegistration::~HidRegistration() {
    if (m_process.IsInitialized()) {
        m_hid_server->GetResourceManager()->UnregisterAppletResourceUserId(
            m_process.GetProcessId());
    }
}

void HidRegistration::EnableAppletToGetInput(bool enable) {
    if (m_process.IsInitialized()) {
        m_hid_server->GetResourceManager()->EnableInput(m_process.GetProcessId(), enable);
    }
}

} // namespace Service::AM