summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/applet_resource.cpp
blob: 4814d7ad511b7b0aca12f7b57f0212071e2149fe (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
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#include "common/logging/log.h"
#include "core/hle/kernel/k_shared_memory.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/hid/applet_resource.h"
#include "hid_core/resource_manager.h"

namespace Service::HID {

IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource,
                                 u64 applet_resource_user_id)
    : ServiceFramework{system_, "IAppletResource"}, aruid{applet_resource_user_id},
      resource_manager{resource} {
    static const FunctionInfo functions[] = {
        {0, C<&IAppletResource::GetSharedMemoryHandle>, "GetSharedMemoryHandle"},
    };
    RegisterHandlers(functions);
}

IAppletResource::~IAppletResource() {
    resource_manager->FreeAppletResourceId(aruid);
}

Result IAppletResource::GetSharedMemoryHandle(
    OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle) {
    const auto result = resource_manager->GetSharedMemoryHandle(out_shared_memory_handle, aruid);

    LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, result=0x{:X}", aruid, result.raw);
    R_RETURN(result);
}

} // namespace Service::HID