Some tweaks to battery code for Linux if more than one battery is in the system.

This commit is contained in:
n-a-c-h
2005-10-08 22:55:21 +00:00
parent 31ce75d42d
commit 35b3225c4b

View File

@@ -1371,9 +1371,10 @@ int CheckBattery()
{ {
battery = 0; battery = 0;
} }
if (!strcmp(arg, "off-line")) else if (!strcmp(arg, "off-line"))
{ {
battery = 1; battery = 1;
break;
} }
} }
} }
@@ -1445,10 +1446,12 @@ static void update_battery_info()
else if (strcmp(key, "present rate") == 0 && sscanf(arg, "%g", &x) == 1) else if (strcmp(key, "present rate") == 0 && sscanf(arg, "%g", &x) == 1)
{ {
present_rate += charging * x; present_rate += charging * x;
charging = 0;
} }
else if (strcmp(key, "remaining capacity") == 0 && sscanf(arg, "%g:", &x) == 1) else if (strcmp(key, "remaining capacity") == 0 && sscanf(arg, "%g:", &x) == 1)
{ {
remaining_capacity += x; remaining_capacity += x;
charging = 0;
} }
} }
fclose(fp); fclose(fp);
@@ -1456,7 +1459,7 @@ static void update_battery_info()
} }
if (design_capacity > 0.0f) if (design_capacity > 0.0f)
{ {
BatteryLifePercent = (int)floorf((remaining_capacity / ((full_capacity > 0.0f) ? full_capacity : design_capacity) * 100.0) + 0.499); BatteryLifePercent = (int)floorf(remaining_capacity / ((full_capacity > 0.0f) ? full_capacity : design_capacity) * 100.0);
if (present_rate < 0.0f) if (present_rate < 0.0f)
{ {
// Linux specifies rates in mWh or mAh // Linux specifies rates in mWh or mAh