yuzu/src/core/hle/service/ptm/ts.cpp

89 lines
2.3 KiB
C++
Raw Normal View History

2022-06-26 23:48:12 +00:00
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#include <memory>
#include "core/core.h"
2023-02-19 19:42:12 +00:00
#include "core/hle/service/ipc_helpers.h"
2022-06-26 23:48:12 +00:00
#include "core/hle/service/ptm/ts.h"
namespace Service::PTM {
2023-10-20 17:29:15 +00:00
enum class Location : u8 {
Internal,
External,
};
class ISession : public ServiceFramework<ISession> {
public:
explicit ISession(Core::System& system_) : ServiceFramework{system_, "ISession"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "GetTemperatureRange"},
{2, nullptr, "SetMeasurementMode"},
{4, &ISession::GetTemperature, "GetTemperature"},
};
// clang-format on
RegisterHandlers(functions);
}
private:
void GetTemperature(HLERequestContext& ctx) {
constexpr f32 temperature = 35;
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(temperature);
}
};
2022-06-26 23:48:12 +00:00
TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "GetTemperatureRange"},
{1, &TS::GetTemperature, "GetTemperature"},
{2, nullptr, "SetMeasurementMode"},
2022-10-11 22:15:30 +00:00
{3, &TS::GetTemperatureMilliC, "GetTemperatureMilliC"},
2023-10-20 17:29:15 +00:00
{4, &TS::OpenSession, "OpenSession"},
2022-06-26 23:48:12 +00:00
};
// clang-format on
RegisterHandlers(functions);
}
TS::~TS() = default;
2023-02-19 19:42:12 +00:00
void TS::GetTemperature(HLERequestContext& ctx) {
2022-06-26 23:48:12 +00:00
IPC::RequestParser rp{ctx};
const auto location{rp.PopEnum<Location>()};
const s32 temperature = location == Location::Internal ? 35 : 20;
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(temperature);
}
2023-02-19 19:42:12 +00:00
void TS::GetTemperatureMilliC(HLERequestContext& ctx) {
2022-10-11 22:15:30 +00:00
IPC::RequestParser rp{ctx};
const auto location{rp.PopEnum<Location>()};
const s32 temperature = location == Location::Internal ? 35000 : 20000;
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(temperature);
}
2023-10-20 17:29:15 +00:00
void TS::OpenSession(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
[[maybe_unused]] const u32 device_code = rp.Pop<u32>();
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ISession>(system);
}
2022-06-26 23:48:12 +00:00
} // namespace Service::PTM