diff options
| author | 2014-11-28 16:56:44 -0800 | |
|---|---|---|
| committer | 2014-12-03 15:09:59 -0800 | |
| commit | 16fc98af644ba6a5a56b9aa804ed1bec5e064a8e (patch) | |
| tree | 47eff9b09813997516150e798c96ad516ec95e01 /src | |
| parent | Merge pull request #236 from rohit-n/sign-compare (diff) | |
| download | yuzu-16fc98af644ba6a5a56b9aa804ed1bec5e064a8e.tar.gz yuzu-16fc98af644ba6a5a56b9aa804ed1bec5e064a8e.tar.xz yuzu-16fc98af644ba6a5a56b9aa804ed1bec5e064a8e.zip | |
PTM_U: Added a stub for GetBatteryLevel & GetBatteryChargeState & GetAdapterState
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/ptm_u.cpp | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp index 1ce32ee4a..941df467b 100644 --- a/src/core/hle/service/ptm_u.cpp +++ b/src/core/hle/service/ptm_u.cpp | |||
| @@ -11,8 +11,40 @@ | |||
| 11 | 11 | ||
| 12 | namespace PTM_U { | 12 | namespace PTM_U { |
| 13 | 13 | ||
| 14 | /// Charge levels used by PTM functions | ||
| 15 | enum class ChargeLevels : u32 { | ||
| 16 | CriticalBattery = 1, | ||
| 17 | LowBattery = 2, | ||
| 18 | HalfFull = 3, | ||
| 19 | MostlyFull = 4, | ||
| 20 | CompletelyFull = 5, | ||
| 21 | }; | ||
| 22 | |||
| 14 | static bool shell_open = true; | 23 | static bool shell_open = true; |
| 15 | 24 | ||
| 25 | static bool battery_is_charging = true; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * It is unknown if GetAdapterState is the same as GetBatteryChargeState, | ||
| 29 | * it is likely to just be a duplicate function of GetBatteryChargeState | ||
| 30 | * that controls another part of the HW. | ||
| 31 | * PTM_U::GetAdapterState service function | ||
| 32 | * Outputs: | ||
| 33 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 34 | * 2 : Output of function, 0 = not charging, 1 = charging. | ||
| 35 | */ | ||
| 36 | static void GetAdapterState(Service::Interface* self) { | ||
| 37 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 38 | |||
| 39 | // TODO(purpasmart96): This function is only a stub, | ||
| 40 | // it returns a valid result without implementing full functionality. | ||
| 41 | |||
| 42 | cmd_buff[1] = 0; // No error | ||
| 43 | cmd_buff[2] = battery_is_charging ? 1 : 0; | ||
| 44 | |||
| 45 | WARN_LOG(KERNEL, "(STUBBED) called"); | ||
| 46 | } | ||
| 47 | |||
| 16 | /* | 48 | /* |
| 17 | * PTM_User::GetShellState service function. | 49 | * PTM_User::GetShellState service function. |
| 18 | * Outputs: | 50 | * Outputs: |
| @@ -28,15 +60,52 @@ static void GetShellState(Service::Interface* self) { | |||
| 28 | DEBUG_LOG(KERNEL, "PTM_U::GetShellState called"); | 60 | DEBUG_LOG(KERNEL, "PTM_U::GetShellState called"); |
| 29 | } | 61 | } |
| 30 | 62 | ||
| 63 | /** | ||
| 64 | * PTM_U::GetBatteryLevel service function | ||
| 65 | * Outputs: | ||
| 66 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 67 | * 2 : Battery level, 5 = completely full battery, 4 = mostly full battery, | ||
| 68 | * 3 = half full battery, 2 = low battery, 1 = critical battery. | ||
| 69 | */ | ||
| 70 | static void GetBatteryLevel(Service::Interface* self) { | ||
| 71 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 72 | |||
| 73 | // TODO(purpasmart96): This function is only a stub, | ||
| 74 | // it returns a valid result without implementing full functionality. | ||
| 75 | |||
| 76 | cmd_buff[1] = 0; // No error | ||
| 77 | cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery | ||
| 78 | |||
| 79 | WARN_LOG(KERNEL, "(STUBBED) called"); | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * PTM_U::GetBatteryChargeState service function | ||
| 84 | * Outputs: | ||
| 85 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 86 | * 2 : Output of function, 0 = not charging, 1 = charging. | ||
| 87 | */ | ||
| 88 | static void GetBatteryChargeState(Service::Interface* self) { | ||
| 89 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 90 | |||
| 91 | // TODO(purpasmart96): This function is only a stub, | ||
| 92 | // it returns a valid result without implementing full functionality. | ||
| 93 | |||
| 94 | cmd_buff[1] = 0; // No error | ||
| 95 | cmd_buff[2] = battery_is_charging ? 1 : 0; | ||
| 96 | |||
| 97 | WARN_LOG(KERNEL, "(STUBBED) called"); | ||
| 98 | } | ||
| 99 | |||
| 31 | const Interface::FunctionInfo FunctionTable[] = { | 100 | const Interface::FunctionInfo FunctionTable[] = { |
| 32 | {0x00010002, nullptr, "RegisterAlarmClient"}, | 101 | {0x00010002, nullptr, "RegisterAlarmClient"}, |
| 33 | {0x00020080, nullptr, "SetRtcAlarm"}, | 102 | {0x00020080, nullptr, "SetRtcAlarm"}, |
| 34 | {0x00030000, nullptr, "GetRtcAlarm"}, | 103 | {0x00030000, nullptr, "GetRtcAlarm"}, |
| 35 | {0x00040000, nullptr, "CancelRtcAlarm"}, | 104 | {0x00040000, nullptr, "CancelRtcAlarm"}, |
| 36 | {0x00050000, nullptr, "GetAdapterState"}, | 105 | {0x00050000, GetAdapterState, "GetAdapterState"}, |
| 37 | {0x00060000, GetShellState, "GetShellState"}, | 106 | {0x00060000, GetShellState, "GetShellState"}, |
| 38 | {0x00070000, nullptr, "GetBatteryLevel"}, | 107 | {0x00070000, GetBatteryLevel, "GetBatteryLevel"}, |
| 39 | {0x00080000, nullptr, "GetBatteryChargeState"}, | 108 | {0x00080000, GetBatteryChargeState, "GetBatteryChargeState"}, |
| 40 | {0x00090000, nullptr, "GetPedometerState"}, | 109 | {0x00090000, nullptr, "GetPedometerState"}, |
| 41 | {0x000A0042, nullptr, "GetStepHistoryEntry"}, | 110 | {0x000A0042, nullptr, "GetStepHistoryEntry"}, |
| 42 | {0x000B00C2, nullptr, "GetStepHistory"}, | 111 | {0x000B00C2, nullptr, "GetStepHistory"}, |