-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.cpp
79 lines (62 loc) · 2.08 KB
/
input.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "input.h"
///////////////////////////////////////////////////////////////////////////////////
Input::Input()
{
enableOpenGL1 = true;
noWindow = false;
exitStatus = false;
inputLibraryPath = L"D:/PROG/HydraAPI/main/tests_f/test_201";
inputRenderName = L"opengl1";
camMoveSpeed = 7.5f;
mouseSensitivity = 0.1f;
// dynamic data
//
pathTracingEnabled = false;
cameraFreeze = false;
}
///////////////////////////////////////////////////////////////////////////////////
/**
\brief Read bool from hash map. if no value was found (by key), don't overwrite 'pParam'
\param a_params - hash map to read from
\param a_name - key
\param pParam - output parameter. if no value was found (by key), it does not touched.
\return found value or false if nothing was found
*/
static bool ReadBoolCmd(const std::unordered_map<std::string, std::string>& a_params, const std::string& a_name, bool* pParam = nullptr)
{
const auto p = a_params.find(a_name);
if (p != a_params.end())
{
const int val = atoi(p->second.c_str());
const bool result = (val > 0);
if (pParam != nullptr)
(*pParam) = result;
return result;
}
else
return false;
}
/**
\brief Read string from hash map. if no value was found (by key), don't overwrite 'pParam'
\param a_params - hash map to read from
\param a_name - key
\param pParam - output parameter. if no value was found (by key), it does not touched.
\return found value or "" if nothing was found
*/
static std::string ReadStringCmd(const std::unordered_map<std::string, std::string>& a_params, const std::string& a_name, std::string* pParam = nullptr)
{
const auto p = a_params.find(a_name);
if (p != a_params.end())
{
if (pParam != nullptr)
(*pParam) = p->second;
return p->second;
}
else
return std::string("");
}
///////////////////////////////////////////////////////////////////////////////////
void Input::ParseCommandLineParams(const std::unordered_map<std::string, std::string>& a_params)
{
ReadBoolCmd(a_params, "-nowindow", &noWindow);
}