-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
62 lines (50 loc) · 1.59 KB
/
main.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 "cemuhookserver.h"
#include "config.h"
#include <csignal>
#include <iostream>
#include <string>
#include <sys/types.h>
#include <yaml-cpp/yaml.h>
using std::cout;
Server *serverPointer;
void signalHandler(int signal) {
if (signal == SIGINT) {
cout << "\nCtrl + C Received, Stopping...\n";
serverPointer->Stop();
}
}
Config *readConfig() {
Config *configStruct = new Config();
#ifdef __unix__
std::string homeDir = getenv("HOME");
std::string configPath = homeDir + "/.config/CemuShake.yml";
#endif
#ifdef _WIN32
std::string configPath = "CemuShake.yml";
#endif
try {
YAML::Node configFile = YAML::LoadFile(configPath);
configStruct->port = configFile["port"].as<uint>();
for (std::size_t i = 0; i < configFile["buttons"].size(); i++) {
configStruct->buttons.emplace_back(
configFile["buttons"][i]["id"].as<int>(),
false,
configFile["buttons"][i]["accX"].as<float>(),
configFile["buttons"][i]["accY"].as<float>(),
configFile["buttons"][i]["accZ"].as<float>(),
configFile["buttons"][i]["pitch"].as<float>(),
configFile["buttons"][i]["yaw"].as<float>(),
configFile["buttons"][i]["roll"].as<float>());
}
} catch (YAML::BadFile) {
cout << "Could not load config file\n";
}
return configStruct;
}
int main() {
std::signal(SIGINT, signalHandler);
Config *configStruct = readConfig();
Server server(configStruct);
serverPointer = &server;
server.Start();
}