From a280373f8e72ffab531e15267bfe4dc7353d4cbb Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 21 May 2026 21:30:41 +0000 Subject: [PATCH] extra battery states --- src/core/hle/service/btm/btm_system_core.h | 3 ++ src/core/hle/service/ptm/psm.cpp | 32 +++++++++++++++++----- src/core/hle/service/ptm/psm.h | 2 ++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/core/hle/service/btm/btm_system_core.h b/src/core/hle/service/btm/btm_system_core.h index c390627f28..3fc4c0d56c 100644 --- a/src/core/hle/service/btm/btm_system_core.h +++ b/src/core/hle/service/btm/btm_system_core.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index ace11dd501..06396bbb4c 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp @@ -136,10 +136,10 @@ PSM::PSM(Core::System& system_) : ServiceFramework{system_, "psm"} { {9, nullptr, "DisableEnoughPowerChargeEmulation"}, {10, nullptr, "EnableFastBatteryCharging"}, {11, nullptr, "DisableFastBatteryCharging"}, - {12, nullptr, "GetBatteryVoltageState"}, + {12, &PSM::GetBatteryVoltageState, "GetBatteryVoltageState"}, {13, nullptr, "GetRawBatteryChargePercentage"}, {14, nullptr, "IsEnoughPowerSupplied"}, - {15, nullptr, "GetBatteryAgePercentage"}, + {15, &PSM::GetBatteryAgePercentage, "GetBatteryAgePercentage"}, {16, nullptr, "GetBatteryChargeInfoEvent"}, {17, &PSM::GetBatteryChargeInfoFields, "GetBatteryChargeInfoFields"}, {18, nullptr, "GetBatteryChargeCalibratedEvent"}, @@ -189,6 +189,20 @@ void PSM::OpenSession(HLERequestContext& ctx) { rb.PushIpcInterface(system); } +void PSM::GetBatteryVoltageState(HLERequestContext& ctx) { + LOG_DEBUG(Service_PTM, "(stubbed)"); + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.PushRaw(0); // +} + +void PSM::GetBatteryAgePercentage(HLERequestContext& ctx) { + LOG_DEBUG(Service_PTM, "(stubbed)"); + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.PushRaw(1.f); +} + struct BatteryChargeInfoFields { u32 input_current_limit; //mA u32 boost_mode_current_limit; @@ -200,9 +214,9 @@ struct BatteryChargeInfoFields { INSERT_PADDING_BYTES_NOINIT(2); u32 vdd50_state; u32 temperature_celcius; - u32 battery_charge_percentage; + f32 battery_charge_percentage; u32 battery_charge_milli_voltage; - u32 battery_age_percentage; + f32 battery_age_percentage; u32 usb_power_role; u32 usb_charger_type; u32 charger_input_voltage_limit; @@ -214,17 +228,21 @@ struct BatteryChargeInfoFields { INSERT_PADDING_BYTES_NOINIT(0x14); //[+17.0.0] }; static_assert(sizeof(struct BatteryChargeInfoFields) == 0x54); - void PSM::GetBatteryChargeInfoFields(HLERequestContext& ctx) { LOG_DEBUG(Service_PTM, "called"); Common::PowerStatus power_status = Common::GetPowerStatus(); BatteryChargeInfoFields r{}; - r.battery_charge_percentage = power_status.percentage; //100% - r.battery_age_percentage = power_status.percentage; //100% + r.battery_charge_percentage = f32(power_status.percentage); //100% + r.battery_age_percentage = f32(power_status.percentage); //100% r.battery_charging = power_status.charging ? 1 : 0; r.charger_type = u32(power_status.has_battery && power_status.charging ? ChargerType::RegularCharger : ChargerType::Unplugged); + r.charger_input_voltage_limit = 100; + r.charger_input_voltage_limit = 100; + r.input_current_limit = 100; + r.boost_mode_current_limit = 100; + r.fast_charge_current_limit = 100; IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/ptm/psm.h b/src/core/hle/service/ptm/psm.h index 1e4aa72dee..77c38d1f9b 100644 --- a/src/core/hle/service/ptm/psm.h +++ b/src/core/hle/service/ptm/psm.h @@ -25,6 +25,8 @@ private: void GetBatteryChargePercentage(HLERequestContext& ctx); void GetChargerType(HLERequestContext& ctx); void OpenSession(HLERequestContext& ctx); + void GetBatteryVoltageState(HLERequestContext& ctx); + void GetBatteryAgePercentage(HLERequestContext& ctx); void GetBatteryChargeInfoFields(HLERequestContext& ctx); };