2018-01-15 02:24:50 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2015-01-18 23:07:48 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
#include "common/logging/log.h"
|
2018-01-15 02:24:50 +00:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
|
#include "core/hle/kernel/client_port.h"
|
|
|
|
#include "core/hle/kernel/client_session.h"
|
|
|
|
#include "core/hle/kernel/shared_memory.h"
|
2016-09-21 06:52:38 +00:00
|
|
|
#include "core/hle/service/hid/hid.h"
|
2016-09-20 15:21:23 +00:00
|
|
|
#include "core/hle/service/service.h"
|
2015-03-09 04:14:59 +00:00
|
|
|
|
2015-01-18 23:07:48 +00:00
|
|
|
namespace Service {
|
|
|
|
namespace HID {
|
|
|
|
|
2018-01-15 02:24:50 +00:00
|
|
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
|
|
|
public:
|
|
|
|
IAppletResource() : ServiceFramework("IAppletResource") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
2015-01-18 23:07:48 +00:00
|
|
|
|
2018-01-15 02:24:50 +00:00
|
|
|
shared_mem = Kernel::SharedMemory::Create(
|
|
|
|
nullptr, 0x40000, Kernel::MemoryPermission::ReadWrite, Kernel::MemoryPermission::Read,
|
|
|
|
0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(shared_mem);
|
|
|
|
LOG_DEBUG(Service, "called");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle to shared memory region designated to HID service
|
|
|
|
Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Hid final : public ServiceFramework<Hid> {
|
|
|
|
public:
|
|
|
|
Hid() : ServiceFramework("hid") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0x00000000, &Hid::CreateAppletResource, "CreateAppletResource"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
~Hid() = default;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateAppletResource(Kernel::HLERequestContext& ctx) {
|
|
|
|
auto client_port = std::make_shared<IAppletResource>()->CreatePort();
|
|
|
|
auto session = client_port->Connect();
|
|
|
|
if (session.Succeeded()) {
|
|
|
|
LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u",
|
|
|
|
(*session)->GetObjectId());
|
|
|
|
IPC::RequestBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushMoveObjects(std::move(session).Unwrap());
|
|
|
|
} else {
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-01-18 23:07:48 +00:00
|
|
|
|
2017-10-13 01:21:49 +00:00
|
|
|
void ReloadInputDevices() {}
|
2015-01-18 23:07:48 +00:00
|
|
|
|
2018-01-15 02:24:50 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
|
|
|
std::make_shared<Hid>()->InstallAsService(service_manager);
|
|
|
|
}
|
|
|
|
|
2015-03-09 04:14:59 +00:00
|
|
|
} // namespace HID
|
|
|
|
} // namespace Service
|