switch: fix power interface

This commit is contained in:
cpasjuste 2021-06-24 14:32:27 +02:00
parent 8249883616
commit 84f61daaab
2 changed files with 14 additions and 8 deletions

View File

@ -28,12 +28,11 @@
#include "SDL_power.h"
SDL_bool
SDL_GetPowerInfo_SWITCH(SDL_PowerState * state, int *seconds,
int *percent)
{
SDL_GetPowerInfo_SWITCH(SDL_PowerState *state, int *seconds,
int *percent) {
PsmChargerType chargerType;
u32 charge;
double age;
//double age;
Result rc;
rc = psmGetChargerType(&chargerType);
@ -47,13 +46,16 @@ SDL_GetPowerInfo_SWITCH(SDL_PowerState * state, int *seconds,
psmGetBatteryChargePercentage(&charge);
*percent = (int) charge;
psmGetBatteryAgePercentage(&age);
*seconds = (int) age;
// TODO: use approximation for now, ~6h00 for a fully charged battery
*seconds = ((int) charge * 21600) / 100;
//psmGetBatteryAgePercentage(&age);
//*seconds = (int) age;
if(chargerType == PsmChargerType_EnoughPower) {
if (chargerType == PsmChargerType_Unconnected) {
*state = SDL_POWERSTATE_ON_BATTERY;
} else if (chargerType == PsmChargerType_EnoughPower) {
*state = SDL_POWERSTATE_CHARGED;
} else {
// TODO: check if device charging...
*state = SDL_POWERSTATE_CHARGING;
}

View File

@ -139,6 +139,8 @@ SWITCH_VideoInit(_THIS)
display.driverdata = NULL;
SDL_AddVideoDisplay(&display, SDL_FALSE);
// init psm service
psmInitialize();
// init touch
SWITCH_InitTouch();
// init keyboard
@ -169,6 +171,8 @@ SWITCH_VideoQuit(_THIS)
SWITCH_QuitMouse();
// exit software keyboard
SWITCH_QuitSwkb();
// exit psm service
psmExit();
}
void