-
Notifications
You must be signed in to change notification settings - Fork 3
/
CtrlEPMCallback.cpp
62 lines (52 loc) · 1.44 KB
/
CtrlEPMCallback.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "CtrlEPMCallback.h"
#define NTDDI_VERSION NTDDI_WIN10_RS5 //0x0A000006 1809
#define _WIN32_WINNT _WIN32_WINNT_WIN10 //Windows 10 (0x0A00)
#include <Windows.h>
#include <PowrProf.h>
#pragma comment(lib, "PowrProf.lib")
CtrlEPMCallback *epmCallbackMainClass;
void epmCallback(EFFECTIVE_POWER_MODE EPM, void *Context) {
epmMode epm = epmNone;
switch(int(EPM)){
case 0:
epm = BatterySaver;
break;
case 1:
epm = BetterBattery;
break;
case 2:
epm = Balanced;
break;
case 3:
epm = MaxPerformance;
break;
case 4:
epm = MaxPerformance;
break;
case 5:
epm = GameMode;
break;
case 6:
epm = MixedReality;
break;
}
epmCallbackMainClass->emitEpmIdChanged(epm);
}
CtrlEPMCallback::CtrlEPMCallback() {
epmHandle = new void*;
PowerRegisterForEffectivePowerModeNotifications(EFFECTIVE_POWER_MODE_V2, epmCallback,
nullptr, epmHandle);
// USE EFFECTIVE_POWER_MODE_V2 For Game and AR Modes
epmCallbackMainClass = this;
}
CtrlEPMCallback::~CtrlEPMCallback() {
PowerUnregisterFromEffectivePowerModeNotifications(epmHandle);
}
void CtrlEPMCallback::emitEpmIdChanged(epmMode epm){
currentEpm = epm;
emit epmIdChanged(epm);
}
void CtrlEPMCallback::emitCurrentEPMState(){
if(currentEpm != epmNone)
emit epmIdChanged(currentEpm);
}