-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
63 lines (58 loc) · 1.74 KB
/
main.cpp
File metadata and controls
63 lines (58 loc) · 1.74 KB
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
63
// Last edit: 30.04.24 10:16 by Mateusz Chojnowski mateusz.chojnowski@inseye.com
//
// Copyright (c) Inseye Inc. 2024.
//
// This file is part of Inseye Software Development Kit subject to Inseye SDK License
// See https://github.com/Inseye/Licenses/blob/master/SDKLicense.txt.
// All other rights reserved.
#include <iostream>
#include <chrono>
#include <thread>
#include "windows.h"
#include "remote_connector.h"
static bool run = true;
BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
{
switch (fdwCtrlType)
{
case CTRL_C_EVENT:
case CTRL_CLOSE_EVENT:
case CTRL_BREAK_EVENT:
run = false;
return TRUE;
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
default:
return FALSE;
}
}
template<typename T>
void print_data(T & eye_tracker_data) {
std::cout << "Successfully read data\n";
std::cout << "Time: " << eye_tracker_data.time << "\n";
std::cout << "Left X: " << eye_tracker_data.left_eye_x << "\n";
std::cout << "Left Y: " << eye_tracker_data.left_eye_y << "\n";
std::cout << "Right X: " << eye_tracker_data.right_eye_x << "\n";
std::cout << "Right Y: " << eye_tracker_data.right_eye_y << "\n";
std::cout << "Event: " << eye_tracker_data.gaze_event;
}
int main(int argc, char *argv[]) {
using namespace std::chrono_literals;
try {
inseye::EyeTracker reader(-1);
inseye::EyeTrackerDataStruct eyeTrackerData;
SetConsoleCtrlHandler(CtrlHandler, TRUE);
while (run) {
if (reader.TryReadNextEyeTrackerData(eyeTrackerData)) {
print_data(eyeTrackerData);
} else {
std::cout << "Failed to read data";
std::this_thread::sleep_for(5s);
}
std::cout << std::endl;
}
}
catch (std::runtime_error& ref){
std::cout << ref.what() << std::endl;
}
}