Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
eea87600
Commit
eea87600
authored
Nov 24, 2019
by
Chip Davis
Committed by
Alexandre Julliard
Nov 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Implement SystemBatteryState for Mac OS.
Signed-off-by:
Chip Davis
<
cdavis@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7026b59b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
nt.c
dlls/ntdll/nt.c
+70
-0
No files found.
dlls/ntdll/nt.c
View file @
eea87600
...
...
@@ -38,6 +38,9 @@
#endif
#ifdef HAVE_IOKIT_IOKITLIB_H
# include <IOKit/IOKitLib.h>
# include <IOKit/pwr_mgt/IOPM.h>
# include <IOKit/pwr_mgt/IOPMLib.h>
# include <IOKit/ps/IOPowerSources.h>
#endif
#include <ctype.h>
...
...
@@ -3291,6 +3294,73 @@ static NTSTATUS fill_battery_state(SYSTEM_BATTERY_STATE *bs)
return
STATUS_SUCCESS
;
}
#elif defined(HAVE_IOKIT_IOKITLIB_H)
static
NTSTATUS
fill_battery_state
(
SYSTEM_BATTERY_STATE
*
bs
)
{
CFArrayRef
batteries
;
CFDictionaryRef
battery
;
CFNumberRef
prop
;
uint32_t
value
,
voltage
;
CFTimeInterval
remain
;
if
(
IOPMCopyBatteryInfo
(
kIOMasterPortDefault
,
&
batteries
)
!=
kIOReturnSuccess
)
return
STATUS_ACCESS_DENIED
;
if
(
CFArrayGetCount
(
batteries
)
==
0
)
{
/* Just assume we're on AC with no battery. */
bs
->
AcOnLine
=
TRUE
;
return
STATUS_SUCCESS
;
}
/* Just use the first battery. */
battery
=
CFArrayGetValueAtIndex
(
batteries
,
0
);
prop
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOBatteryFlagsKey
)
);
CFNumberGetValue
(
prop
,
kCFNumberSInt32Type
,
&
value
);
if
(
value
&
kIOBatteryInstalled
)
bs
->
BatteryPresent
=
TRUE
;
else
/* Since we are executing code, we must have AC power. */
bs
->
AcOnLine
=
TRUE
;
if
(
value
&
kIOBatteryChargerConnect
)
{
bs
->
AcOnLine
=
TRUE
;
if
(
value
&
kIOBatteryCharge
)
bs
->
Charging
=
TRUE
;
}
else
bs
->
Discharging
=
TRUE
;
/* We'll need the voltage to be able to interpret the other values. */
prop
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOBatteryVoltageKey
)
);
CFNumberGetValue
(
prop
,
kCFNumberSInt32Type
,
&
voltage
);
prop
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOBatteryCapacityKey
)
);
CFNumberGetValue
(
prop
,
kCFNumberSInt32Type
,
&
value
);
bs
->
MaxCapacity
=
value
*
voltage
;
/* Apple uses "estimated time < 10:00" and "22%" for these, but we'll follow
* Windows for now (5% and 33%). */
bs
->
DefaultAlert1
=
bs
->
MaxCapacity
/
20
;
bs
->
DefaultAlert2
=
bs
->
MaxCapacity
/
3
;
prop
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOBatteryCurrentChargeKey
)
);
CFNumberGetValue
(
prop
,
kCFNumberSInt32Type
,
&
value
);
bs
->
RemainingCapacity
=
value
*
voltage
;
prop
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOBatteryAmperageKey
)
);
CFNumberGetValue
(
prop
,
kCFNumberSInt32Type
,
&
value
);
bs
->
Rate
=
value
*
voltage
;
remain
=
IOPSGetTimeRemainingEstimate
();
if
(
remain
!=
kIOPSTimeRemainingUnknown
&&
remain
!=
kIOPSTimeRemainingUnlimited
)
bs
->
EstimatedTime
=
(
ULONG
)
remain
;
CFRelease
(
batteries
);
return
STATUS_SUCCESS
;
}
#else
static
NTSTATUS
fill_battery_state
(
SYSTEM_BATTERY_STATE
*
bs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment