summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar emmaus2017-05-17 21:12:59 +0000
committerGravatar emmaus2017-05-19 08:44:58 +0000
commitb2e82d16c80229261f55fbb25d84ac00a60cefac (patch)
treeb511154c8ba714958dcdff4653440ea38da25e7e
parentMerge pull request #2703 from wwylele/pica-reg-revise (diff)
downloadyuzu-b2e82d16c80229261f55fbb25d84ac00a60cefac.tar.gz
yuzu-b2e82d16c80229261f55fbb25d84ac00a60cefac.tar.xz
yuzu-b2e82d16c80229261f55fbb25d84ac00a60cefac.zip
use IPCHelper for PTM services
-rw-r--r--src/core/hle/service/ptm/ptm.cpp66
-rw-r--r--src/core/hle/service/ptm/ptm.h8
-rw-r--r--src/core/hle/service/ptm/ptm_u.cpp2
3 files changed, 45 insertions, 31 deletions
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
index e373ed47a..319e8c946 100644
--- a/src/core/hle/service/ptm/ptm.cpp
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -27,67 +27,72 @@ static bool shell_open;
27 27
28static bool battery_is_charging; 28static bool battery_is_charging;
29 29
30void GetAdapterState(Service::Interface* self) { 30static bool pedometer_is_counting;
31 u32* cmd_buff = Kernel::GetCommandBuffer();
32 31
33 // TODO(purpasmart96): This function is only a stub, 32void GetAdapterState(Service::Interface* self) {
34 // it returns a valid result without implementing full functionality. 33 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 0, 0);
35 34
36 cmd_buff[1] = RESULT_SUCCESS.raw; 35 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
37 cmd_buff[2] = battery_is_charging ? 1 : 0; 36 rb.Push(RESULT_SUCCESS);
37 rb.Push(battery_is_charging);
38 38
39 LOG_WARNING(Service_PTM, "(STUBBED) called"); 39 LOG_WARNING(Service_PTM, "(STUBBED) called");
40} 40}
41 41
42void GetShellState(Service::Interface* self) { 42void GetShellState(Service::Interface* self) {
43 u32* cmd_buff = Kernel::GetCommandBuffer(); 43 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x6, 0, 0);
44 44
45 cmd_buff[1] = RESULT_SUCCESS.raw; 45 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
46 cmd_buff[2] = shell_open ? 1 : 0; 46 rb.Push(RESULT_SUCCESS);
47 rb.Push(shell_open);
47} 48}
48 49
49void GetBatteryLevel(Service::Interface* self) { 50void GetBatteryLevel(Service::Interface* self) {
50 u32* cmd_buff = Kernel::GetCommandBuffer(); 51 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x7, 0, 0);
51 52
52 // TODO(purpasmart96): This function is only a stub, 53 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
53 // it returns a valid result without implementing full functionality. 54 rb.Push(RESULT_SUCCESS);
54 55 rb.Push(static_cast<u32>(ChargeLevels::CompletelyFull)); // Set to a completely full battery
55 cmd_buff[1] = RESULT_SUCCESS.raw;
56 cmd_buff[2] =
57 static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
58 56
59 LOG_WARNING(Service_PTM, "(STUBBED) called"); 57 LOG_WARNING(Service_PTM, "(STUBBED) called");
60} 58}
61 59
62void GetBatteryChargeState(Service::Interface* self) { 60void GetBatteryChargeState(Service::Interface* self) {
63 u32* cmd_buff = Kernel::GetCommandBuffer(); 61 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x8, 0, 0);
64 62
65 // TODO(purpasmart96): This function is only a stub, 63 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
66 // it returns a valid result without implementing full functionality. 64 rb.Push(RESULT_SUCCESS);
65 rb.Push(battery_is_charging);
67 66
68 cmd_buff[1] = RESULT_SUCCESS.raw; 67 LOG_WARNING(Service_PTM, "(STUBBED) called");
69 cmd_buff[2] = battery_is_charging ? 1 : 0; 68}
69
70void GetPedometerState(Service::Interface* self) {
71 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x9, 0, 0);
72
73 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
74 rb.Push(RESULT_SUCCESS);
75 rb.Push(pedometer_is_counting);
70 76
71 LOG_WARNING(Service_PTM, "(STUBBED) called"); 77 LOG_WARNING(Service_PTM, "(STUBBED) called");
72} 78}
73 79
74void GetTotalStepCount(Service::Interface* self) { 80void GetTotalStepCount(Service::Interface* self) {
75 u32* cmd_buff = Kernel::GetCommandBuffer(); 81 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xC, 0, 0);
76 82
77 // TODO: This function is only a stub, 83 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
78 // it returns 0 as the total step count 84 rb.Push(RESULT_SUCCESS);
79 85 rb.Push<u32>(0);
80 cmd_buff[1] = RESULT_SUCCESS.raw;
81 cmd_buff[2] = 0;
82 86
83 LOG_WARNING(Service_PTM, "(STUBBED) called"); 87 LOG_WARNING(Service_PTM, "(STUBBED) called");
84} 88}
85 89
86void GetSoftwareClosedFlag(Service::Interface* self) { 90void GetSoftwareClosedFlag(Service::Interface* self) {
87 u32* cmd_buff = Kernel::GetCommandBuffer(); 91 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x80F, 0, 0);
88 92
89 cmd_buff[1] = RESULT_SUCCESS.raw; 93 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
90 cmd_buff[2] = 0; 94 rb.Push(RESULT_SUCCESS);
95 rb.Push(false);
91 96
92 LOG_WARNING(Service_PTM, "(STUBBED) called"); 97 LOG_WARNING(Service_PTM, "(STUBBED) called");
93} 98}
@@ -121,6 +126,7 @@ void Init() {
121 126
122 shell_open = true; 127 shell_open = true;
123 battery_is_charging = true; 128 battery_is_charging = true;
129 pedometer_is_counting = false;
124 130
125 // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't 131 // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't
126 // exist 132 // exist
diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h
index 683fb445b..e17e59835 100644
--- a/src/core/hle/service/ptm/ptm.h
+++ b/src/core/hle/service/ptm/ptm.h
@@ -75,6 +75,14 @@ void GetBatteryLevel(Interface* self);
75void GetBatteryChargeState(Interface* self); 75void GetBatteryChargeState(Interface* self);
76 76
77/** 77/**
78 * PTM::GetPedometerState service function
79 * Outputs:
80 * 1 : Result of function, 0 on success, otherwise error code
81 * 2 : Output of function, 0 = not counting steps, 1 = counting steps.
82 */
83void GetPedometerState(Interface* self);
84
85/**
78 * PTM::GetTotalStepCount service function 86 * PTM::GetTotalStepCount service function
79 * Outputs: 87 * Outputs:
80 * 1 : Result of function, 0 on success, otherwise error code 88 * 1 : Result of function, 0 on success, otherwise error code
diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp
index e0b65ba89..696a58a36 100644
--- a/src/core/hle/service/ptm/ptm_u.cpp
+++ b/src/core/hle/service/ptm/ptm_u.cpp
@@ -17,7 +17,7 @@ const Interface::FunctionInfo FunctionTable[] = {
17 {0x00060000, GetShellState, "GetShellState"}, 17 {0x00060000, GetShellState, "GetShellState"},
18 {0x00070000, GetBatteryLevel, "GetBatteryLevel"}, 18 {0x00070000, GetBatteryLevel, "GetBatteryLevel"},
19 {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, 19 {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
20 {0x00090000, nullptr, "GetPedometerState"}, 20 {0x00090000, GetPedometerState, "GetPedometerState"},
21 {0x000A0042, nullptr, "GetStepHistoryEntry"}, 21 {0x000A0042, nullptr, "GetStepHistoryEntry"},
22 {0x000B00C2, nullptr, "GetStepHistory"}, 22 {0x000B00C2, nullptr, "GetStepHistory"},
23 {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, 23 {0x000C0000, GetTotalStepCount, "GetTotalStepCount"},