mirror of
https://github.com/encounter/SDL.git
synced 2025-06-16 11:33:39 +00:00
switch: fix power interface
This commit is contained in:
parent
8249883616
commit
84f61daaab
@ -28,12 +28,11 @@
|
|||||||
#include "SDL_power.h"
|
#include "SDL_power.h"
|
||||||
|
|
||||||
SDL_bool
|
SDL_bool
|
||||||
SDL_GetPowerInfo_SWITCH(SDL_PowerState * state, int *seconds,
|
SDL_GetPowerInfo_SWITCH(SDL_PowerState *state, int *seconds,
|
||||||
int *percent)
|
int *percent) {
|
||||||
{
|
|
||||||
PsmChargerType chargerType;
|
PsmChargerType chargerType;
|
||||||
u32 charge;
|
u32 charge;
|
||||||
double age;
|
//double age;
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
rc = psmGetChargerType(&chargerType);
|
rc = psmGetChargerType(&chargerType);
|
||||||
@ -47,13 +46,16 @@ SDL_GetPowerInfo_SWITCH(SDL_PowerState * state, int *seconds,
|
|||||||
psmGetBatteryChargePercentage(&charge);
|
psmGetBatteryChargePercentage(&charge);
|
||||||
*percent = (int) charge;
|
*percent = (int) charge;
|
||||||
|
|
||||||
psmGetBatteryAgePercentage(&age);
|
// TODO: use approximation for now, ~6h00 for a fully charged battery
|
||||||
*seconds = (int) age;
|
*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;
|
*state = SDL_POWERSTATE_CHARGED;
|
||||||
} else {
|
} else {
|
||||||
// TODO: check if device charging...
|
|
||||||
*state = SDL_POWERSTATE_CHARGING;
|
*state = SDL_POWERSTATE_CHARGING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +139,8 @@ SWITCH_VideoInit(_THIS)
|
|||||||
display.driverdata = NULL;
|
display.driverdata = NULL;
|
||||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||||
|
|
||||||
|
// init psm service
|
||||||
|
psmInitialize();
|
||||||
// init touch
|
// init touch
|
||||||
SWITCH_InitTouch();
|
SWITCH_InitTouch();
|
||||||
// init keyboard
|
// init keyboard
|
||||||
@ -169,6 +171,8 @@ SWITCH_VideoQuit(_THIS)
|
|||||||
SWITCH_QuitMouse();
|
SWITCH_QuitMouse();
|
||||||
// exit software keyboard
|
// exit software keyboard
|
||||||
SWITCH_QuitSwkb();
|
SWITCH_QuitSwkb();
|
||||||
|
// exit psm service
|
||||||
|
psmExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user