Re: [AD] A few minor things

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]



First, I would like an API to get the battery level of the
device the game is running on.



#ifdef _WIN32

bool getRemainingBatteryPercentage(uint_t& percentage, bool& bHasBattery)
{    // returns true on failure, false on success

    bHasBattery = false;
    percentage = 0;

    SYSTEM_BATTERY_STATE batt_state;
if ( 0L == CallNtPowerInformation( SystemBatteryState, NULL, 0, &batt_state, sizeof(SYSTEM_BATTERY_STATE) ))
    {
        if ( batt_state.BatteryPresent )
            bHasBattery = true;
        if ( batt_state.MaxCapacity > 0 )
percentage = (uint32_t)((batt_state.RemainingCapacity*100)/batt_state.MaxCapacity);
        return false;    // success
    }

    return true;    // failure
}

#endif





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/