diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index a0b9597973..931623df86 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -30,7 +30,7 @@ static bool battery_is_charging; static bool pedometer_is_counting; -void GetAdapterState(Service::Interface* self) { +void GetAdapterState(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -40,7 +40,7 @@ void GetAdapterState(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } -void GetShellState(Service::Interface* self) { +void GetShellState(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x6, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -48,7 +48,7 @@ void GetShellState(Service::Interface* self) { rb.Push(shell_open); } -void GetBatteryLevel(Service::Interface* self) { +void GetBatteryLevel(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x7, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -58,7 +58,7 @@ void GetBatteryLevel(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } -void GetBatteryChargeState(Service::Interface* self) { +void GetBatteryChargeState(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x8, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -68,7 +68,7 @@ void GetBatteryChargeState(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } -void GetPedometerState(Service::Interface* self) { +void GetPedometerState(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x9, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -78,7 +78,29 @@ void GetPedometerState(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } -void GetTotalStepCount(Service::Interface* self) { +void GetStepHistory(Interface* self) { + IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xB, 3, 2); + + u32 hours = rp.Pop(); + u64 start_time = rp.Pop(); + size_t steps_buff_size; + const VAddr steps_buff_addr = rp.PopMappedBuffer(&steps_buff_size); + ASSERT_MSG(sizeof(u16) * hours == steps_buff_size, "Buffer for steps count has incorrect size"); + + // Stub: set zero steps count for every hour + for (u32 i = 0; i < hours; ++i) { + const u16 steps_per_hour = 0; + Memory::Write16(steps_buff_addr + i * sizeof(u16), steps_per_hour); + } + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service_PTM, "(STUBBED) called, from time(raw): 0x%llx, for %d hours", start_time, + hours); +} + +void GetTotalStepCount(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xC, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -88,7 +110,7 @@ void GetTotalStepCount(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } -void GetSoftwareClosedFlag(Service::Interface* self) { +void GetSoftwareClosedFlag(Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x80F, 0, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); @@ -112,7 +134,7 @@ void CheckNew3DS(IPC::RequestBuilder& rb) { LOG_WARNING(Service_PTM, "(STUBBED) called isNew3DS = 0x%08x", static_cast(is_new_3ds)); } -void CheckNew3DS(Service::Interface* self) { +void CheckNew3DS(Interface* self) { IPC::RequestBuilder rb(Kernel::GetCommandBuffer(), 0x40A, 0, 0); // 0x040A0000 CheckNew3DS(rb); } diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index e17e598359..7a5cd3bdd7 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h @@ -82,6 +82,18 @@ void GetBatteryChargeState(Interface* self); */ void GetPedometerState(Interface* self); +/** + * PTM::GetStepHistory service function + * Inputs: + * 1 : Number of hours + * 2-3 : Start time + * 4 : Buffer mapping descriptor + * 5 : (short*) Buffer for step counts + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +void GetStepHistory(Interface* self); + /** * PTM::GetTotalStepCount service function * Outputs: diff --git a/src/core/hle/service/ptm/ptm_gets.cpp b/src/core/hle/service/ptm/ptm_gets.cpp index b23e508d6e..eeaeeba33d 100644 --- a/src/core/hle/service/ptm/ptm_gets.cpp +++ b/src/core/hle/service/ptm/ptm_gets.cpp @@ -20,7 +20,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, {0x00090000, nullptr, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, - {0x000B00C2, nullptr, "GetStepHistory"}, + {0x000B00C2, GetStepHistory, "GetStepHistory"}, {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, {0x000D0040, nullptr, "SetPedometerRecordingMode"}, {0x000E0000, nullptr, "GetPedometerRecordingMode"}, diff --git a/src/core/hle/service/ptm/ptm_play.cpp b/src/core/hle/service/ptm/ptm_play.cpp index bcb00e0d43..a04ef18990 100644 --- a/src/core/hle/service/ptm/ptm_play.cpp +++ b/src/core/hle/service/ptm/ptm_play.cpp @@ -20,7 +20,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, {0x00090000, nullptr, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, - {0x000B00C2, nullptr, "GetStepHistory"}, + {0x000B00C2, GetStepHistory, "GetStepHistory"}, {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, {0x000D0040, nullptr, "SetPedometerRecordingMode"}, {0x000E0000, nullptr, "GetPedometerRecordingMode"}, diff --git a/src/core/hle/service/ptm/ptm_sysm.cpp b/src/core/hle/service/ptm/ptm_sysm.cpp index f95dfdbb10..ee73aff1ad 100644 --- a/src/core/hle/service/ptm/ptm_sysm.cpp +++ b/src/core/hle/service/ptm/ptm_sysm.cpp @@ -20,7 +20,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, {0x00090000, nullptr, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, - {0x000B00C2, nullptr, "GetStepHistory"}, + {0x000B00C2, GetStepHistory, "GetStepHistory"}, {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, {0x000D0040, nullptr, "SetPedometerRecordingMode"}, {0x000E0000, nullptr, "GetPedometerRecordingMode"}, diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp index 696a58a365..b815c1bae9 100644 --- a/src/core/hle/service/ptm/ptm_u.cpp +++ b/src/core/hle/service/ptm/ptm_u.cpp @@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, {0x00090000, GetPedometerState, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, - {0x000B00C2, nullptr, "GetStepHistory"}, + {0x000B00C2, GetStepHistory, "GetStepHistory"}, {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, {0x000D0040, nullptr, "SetPedometerRecordingMode"}, {0x000E0000, nullptr, "GetPedometerRecordingMode"},