-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
43 lines (32 loc) · 866 Bytes
/
timer.h
File metadata and controls
43 lines (32 loc) · 866 Bytes
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
#pragma once
#include "framework.h"
#include "monitor.h"
#define IDT_TIMER1 1001
// How long to wait between the screens changing and changing rotations
constexpr int MONITOR_TIMER_INTERVAL = 2000;
HANDLE monitorTimerMutex;
bool paused = false;
void executeMonitorTimer(HWND hwnd, UINT, UINT_PTR, DWORD)
{
KillTimer(hwnd, IDT_TIMER1);
auto res = WaitForSingleObject(monitorTimerMutex, INFINITE);
nassert(res == WAIT_OBJECT_0);
if (!paused)
{
fixMonitorRotations();
}
nassert(ReleaseMutex(monitorTimerMutex));
}
void setMonitorTimer(HWND hwnd)
{
KillTimer(hwnd, IDT_TIMER1);
SetTimer(hwnd, IDT_TIMER1, MONITOR_TIMER_INTERVAL, executeMonitorTimer);
}
void initMonitorTimer()
{
monitorTimerMutex = CreateMutex(
NULL, // default security attributes
FALSE, // initially not owned
NULL); // unnamed mutex
nassert(monitorTimerMutex != NULL);
}