Merge pull request #756 from purpasmart96/ptm_service_changes
PTM: Changed the ptm services to be like the IR, HID, and APT services.
This commit is contained in:
commit
7d21b0663b
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
|
||||||
#include "core/file_sys/file_backend.h"
|
#include "core/file_sys/file_backend.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
#include "core/hle/service/ptm/ptm.h"
|
#include "core/hle/service/ptm/ptm.h"
|
||||||
|
@ -23,20 +25,56 @@ static bool shell_open;
|
||||||
|
|
||||||
static bool battery_is_charging;
|
static bool battery_is_charging;
|
||||||
|
|
||||||
u32 GetAdapterState() {
|
void GetAdapterState(Service::Interface* self) {
|
||||||
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||||
|
|
||||||
// TODO(purpasmart96): This function is only a stub,
|
// TODO(purpasmart96): This function is only a stub,
|
||||||
// it returns a valid result without implementing full functionality.
|
// it returns a valid result without implementing full functionality.
|
||||||
return battery_is_charging ? 1 : 0;
|
|
||||||
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||||
|
cmd_buff[2] = battery_is_charging ? 1 : 0;
|
||||||
|
|
||||||
|
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetShellState() {
|
void GetShellState(Service::Interface* self) {
|
||||||
return shell_open ? 1 : 0;
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||||
|
|
||||||
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||||
|
cmd_buff[2] = shell_open ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChargeLevels GetBatteryLevel() {
|
void GetBatteryLevel(Service::Interface* self) {
|
||||||
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||||
|
|
||||||
// TODO(purpasmart96): This function is only a stub,
|
// TODO(purpasmart96): This function is only a stub,
|
||||||
// it returns a valid result without implementing full functionality.
|
// it returns a valid result without implementing full functionality.
|
||||||
return ChargeLevels::CompletelyFull; // Set to a completely full battery
|
|
||||||
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||||
|
cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
|
||||||
|
|
||||||
|
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetBatteryChargeState(Service::Interface* self) {
|
||||||
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||||
|
|
||||||
|
// TODO(purpasmart96): This function is only a stub,
|
||||||
|
// it returns a valid result without implementing full functionality.
|
||||||
|
|
||||||
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||||
|
cmd_buff[2] = battery_is_charging ? 1 : 0;
|
||||||
|
|
||||||
|
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void IsLegacyPowerOff(Service::Interface* self) {
|
||||||
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||||
|
|
||||||
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||||
|
cmd_buff[2] = 0;
|
||||||
|
|
||||||
|
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
|
@ -35,25 +36,48 @@ struct GameCoin {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the battery is charging or not.
|
|
||||||
* It is unknown if GetAdapterState is the same as GetBatteryChargeState,
|
* It is unknown if GetAdapterState is the same as GetBatteryChargeState,
|
||||||
* it is likely to just be a duplicate function of GetBatteryChargeState
|
* it is likely to just be a duplicate function of GetBatteryChargeState
|
||||||
* that controls another part of the HW.
|
* that controls another part of the HW.
|
||||||
* @returns 1 if the battery is charging, and 0 otherwise.
|
* PTM::GetAdapterState service function
|
||||||
|
* Outputs:
|
||||||
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
|
* 2 : Output of function, 0 = not charging, 1 = charging.
|
||||||
*/
|
*/
|
||||||
u32 GetAdapterState();
|
void GetAdapterState(Interface* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the 3DS's physical shell casing is open or closed
|
* PTM::GetShellState service function.
|
||||||
* @returns 1 if the shell is open, and 0 if otherwise
|
* Outputs:
|
||||||
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
|
* 2 : Whether the 3DS's physical shell casing is open (1) or closed (0)
|
||||||
*/
|
*/
|
||||||
u32 GetShellState();
|
void GetShellState(Interface* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current battery's charge level.
|
* PTM::GetBatteryLevel service function
|
||||||
* @returns The battery's charge level.
|
* Outputs:
|
||||||
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
|
* 2 : Battery level, 5 = completely full battery, 4 = mostly full battery,
|
||||||
|
* 3 = half full battery, 2 = low battery, 1 = critical battery.
|
||||||
*/
|
*/
|
||||||
ChargeLevels GetBatteryLevel();
|
void GetBatteryLevel(Interface* self);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTM::GetBatteryChargeState service function
|
||||||
|
* Outputs:
|
||||||
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
|
* 2 : Output of function, 0 = not charging, 1 = charging.
|
||||||
|
*/
|
||||||
|
void GetBatteryChargeState(Interface* self);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTM::IsLegacyPowerOff service function
|
||||||
|
* Outputs:
|
||||||
|
* 1: Result code, 0 on success, otherwise error code
|
||||||
|
* 2: Whether the system is going through a power off
|
||||||
|
*/
|
||||||
|
void IsLegacyPowerOff(Interface* self);
|
||||||
|
|
||||||
/// Initialize the PTM service
|
/// Initialize the PTM service
|
||||||
void Init();
|
void Init();
|
||||||
|
|
|
@ -9,10 +9,10 @@ namespace Service {
|
||||||
namespace PTM {
|
namespace PTM {
|
||||||
|
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
const Interface::FunctionInfo FunctionTable[] = {
|
||||||
{ 0x08070082, nullptr, "GetPlayHistory" },
|
{0x08070082, nullptr, "GetPlayHistory"},
|
||||||
{ 0x08080000, nullptr, "GetPlayHistoryStart" },
|
{0x08080000, nullptr, "GetPlayHistoryStart"},
|
||||||
{ 0x08090000, nullptr, "GetPlayHistoryLength" },
|
{0x08090000, nullptr, "GetPlayHistoryLength"},
|
||||||
{ 0x080B0080, nullptr, "CalcPlayHistoryStart" },
|
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
|
||||||
};
|
};
|
||||||
|
|
||||||
PTM_Play_Interface::PTM_Play_Interface() {
|
PTM_Play_Interface::PTM_Play_Interface() {
|
||||||
|
|
|
@ -2,57 +2,44 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
|
||||||
#include "core/file_sys/archive_extsavedata.h"
|
|
||||||
#include "core/hle/hle.h"
|
#include "core/hle/hle.h"
|
||||||
|
#include "core/hle/service/ptm/ptm.h"
|
||||||
#include "core/hle/service/ptm/ptm_sysm.h"
|
#include "core/hle/service/ptm/ptm_sysm.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
namespace PTM {
|
namespace PTM {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the system is powering off (?)
|
|
||||||
* Outputs:
|
|
||||||
* 1: Result code, 0 on success, otherwise error code
|
|
||||||
* 2: Whether the system is going through a power off
|
|
||||||
*/
|
|
||||||
static void IsLegacyPowerOff(Service::Interface* self) {
|
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
||||||
cmd_buff[2] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
const Interface::FunctionInfo FunctionTable[] = {
|
||||||
{0x040100C0, nullptr, "SetRtcAlarmEx"},
|
{0x040100C0, nullptr, "SetRtcAlarmEx"},
|
||||||
{0x04020042, nullptr, "ReplySleepQuery"},
|
{0x04020042, nullptr, "ReplySleepQuery"},
|
||||||
{0x04030042, nullptr, "NotifySleepPreparationComplete"},
|
{0x04030042, nullptr, "NotifySleepPreparationComplete"},
|
||||||
{0x04040102, nullptr, "SetWakeupTrigger"},
|
{0x04040102, nullptr, "SetWakeupTrigger"},
|
||||||
{0x04050000, nullptr, "GetAwakeReason"},
|
{0x04050000, nullptr, "GetAwakeReason"},
|
||||||
{0x04060000, nullptr, "RequestSleep"},
|
{0x04060000, nullptr, "RequestSleep"},
|
||||||
{0x040700C0, nullptr, "ShutdownAsync"},
|
{0x040700C0, nullptr, "ShutdownAsync"},
|
||||||
{0x04080000, nullptr, "Awake"},
|
{0x04080000, nullptr, "Awake"},
|
||||||
{0x04090080, nullptr, "RebootAsync"},
|
{0x04090080, nullptr, "RebootAsync"},
|
||||||
{0x040A0000, nullptr, "CheckNew3DS"},
|
{0x040A0000, nullptr, "CheckNew3DS"},
|
||||||
{0x08010640, nullptr, "SetInfoLEDPattern"},
|
{0x08010640, nullptr, "SetInfoLEDPattern"},
|
||||||
{0x08020040, nullptr, "SetInfoLEDPatternHeader"},
|
{0x08020040, nullptr, "SetInfoLEDPatternHeader"},
|
||||||
{0x08030000, nullptr, "GetInfoLEDStatus"},
|
{0x08030000, nullptr, "GetInfoLEDStatus"},
|
||||||
{0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
|
{0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
|
||||||
{0x08050000, nullptr, "ClearStepHistory"},
|
{0x08050000, nullptr, "ClearStepHistory"},
|
||||||
{0x080600C2, nullptr, "SetStepHistory"},
|
{0x080600C2, nullptr, "SetStepHistory"},
|
||||||
{0x08070082, nullptr, "GetPlayHistory"},
|
{0x08070082, nullptr, "GetPlayHistory"},
|
||||||
{0x08080000, nullptr, "GetPlayHistoryStart"},
|
{0x08080000, nullptr, "GetPlayHistoryStart"},
|
||||||
{0x08090000, nullptr, "GetPlayHistoryLength"},
|
{0x08090000, nullptr, "GetPlayHistoryLength"},
|
||||||
{0x080A0000, nullptr, "ClearPlayHistory"},
|
{0x080A0000, nullptr, "ClearPlayHistory"},
|
||||||
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
|
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
|
||||||
{0x080C0080, nullptr, "SetUserTime"},
|
{0x080C0080, nullptr, "SetUserTime"},
|
||||||
{0x080D0000, nullptr, "InvalidateSystemTime"},
|
{0x080D0000, nullptr, "InvalidateSystemTime"},
|
||||||
{0x080E0140, nullptr, "NotifyPlayEvent"},
|
{0x080E0140, nullptr, "NotifyPlayEvent"},
|
||||||
{0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
|
{0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
|
||||||
{0x08100000, nullptr, "ClearLegacyPowerOff"},
|
{0x08100000, nullptr, "ClearLegacyPowerOff"},
|
||||||
{0x08110000, nullptr, "GetShellStatus"},
|
{0x08110000, nullptr, "GetShellStatus"},
|
||||||
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
|
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
|
||||||
{0x08130000, nullptr, "FormatSavedata"},
|
{0x08130000, nullptr, "FormatSavedata"},
|
||||||
{0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"}
|
{0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"}
|
||||||
};
|
};
|
||||||
|
|
||||||
PTM_Sysm_Interface::PTM_Sysm_Interface() {
|
PTM_Sysm_Interface::PTM_Sysm_Interface() {
|
||||||
|
|
|
@ -11,68 +11,6 @@
|
||||||
namespace Service {
|
namespace Service {
|
||||||
namespace PTM {
|
namespace PTM {
|
||||||
|
|
||||||
/**
|
|
||||||
* PTM_U::GetAdapterState service function
|
|
||||||
* Outputs:
|
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
|
||||||
* 2 : Output of function, 0 = not charging, 1 = charging.
|
|
||||||
*/
|
|
||||||
static void GetAdapterState(Service::Interface* self) {
|
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
||||||
|
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
||||||
cmd_buff[2] = GetAdapterState();
|
|
||||||
|
|
||||||
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PTM_User::GetShellState service function.
|
|
||||||
* Outputs:
|
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
|
||||||
* 2 : Whether the 3DS's physical shell casing is open (1) or closed (0)
|
|
||||||
*/
|
|
||||||
static void GetShellState(Service::Interface* self) {
|
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
||||||
|
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
||||||
cmd_buff[2] = GetShellState();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PTM_U::GetBatteryLevel service function
|
|
||||||
* Outputs:
|
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
|
||||||
* 2 : Battery level, 5 = completely full battery, 4 = mostly full battery,
|
|
||||||
* 3 = half full battery, 2 = low battery, 1 = critical battery.
|
|
||||||
*/
|
|
||||||
static void GetBatteryLevel(Service::Interface* self) {
|
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
||||||
|
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
||||||
cmd_buff[2] = static_cast<u32>(GetBatteryLevel());
|
|
||||||
|
|
||||||
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PTM_U::GetBatteryChargeState service function
|
|
||||||
* Outputs:
|
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
|
||||||
* 2 : Output of function, 0 = not charging, 1 = charging.
|
|
||||||
*/
|
|
||||||
static void GetBatteryChargeState(Service::Interface* self) {
|
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
||||||
|
|
||||||
// TODO(purpasmart96): This function is only a stub,
|
|
||||||
// it returns a valid result without implementing full functionality.
|
|
||||||
|
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
||||||
cmd_buff[2] = GetAdapterState();
|
|
||||||
|
|
||||||
LOG_WARNING(Service_PTM, "(STUBBED) called");
|
|
||||||
}
|
|
||||||
|
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
const Interface::FunctionInfo FunctionTable[] = {
|
||||||
{0x00010002, nullptr, "RegisterAlarmClient"},
|
{0x00010002, nullptr, "RegisterAlarmClient"},
|
||||||
{0x00020080, nullptr, "SetRtcAlarm"},
|
{0x00020080, nullptr, "SetRtcAlarm"},
|
||||||
|
|
Reference in New Issue