Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
FreeTrack.cpp
Go to the documentation of this file.
1
#include "
FreeTrack.h
"
2
3
#include "
Viewscreen.h
"
4
5
FreeTrack::FreeTrack
(
Viewscreen
* prmViewscreen)
6
:
viewscreen
(prmViewscreen),
logger
(prmViewscreen->
logger
),
7
hinstLib
(nullptr),
getData
(nullptr),
getDllVersion
(nullptr),
reportID
(nullptr),
provider
(nullptr)
8
{
9
// Loading metadata is safe while unselected; FTGetData is strictly opt-in.
10
hinstLib
= LoadLibrary(L
"FreeTrackClient.dll"
);
11
if
(!
hinstLib
)
12
{
13
logger
->
Log
(
"FreeTrack: Unable to load DLL"
,
Logger::Level::Warn
);
14
return
;
15
}
16
getData
=
reinterpret_cast<
importGetData
>
(GetProcAddress(
hinstLib
,
"FTGetData"
));
17
getDllVersion
=
reinterpret_cast<
importGetDllVersion
>
(GetProcAddress(
hinstLib
,
"FTGetDllVersion"
));
18
reportID
=
reinterpret_cast<
importReportID
>
(GetProcAddress(
hinstLib
,
"FTReportName"
));
19
provider
=
reinterpret_cast<
importProvider
>
(GetProcAddress(
hinstLib
,
"FTProvider"
));
20
if
(!
getData
)
21
logger
->
Log
(
"FreeTrack: Unable to find 'FTGetData' function"
,
Logger::Level::Warn
);
22
if
(
getDllVersion
)
23
{
24
if
(
const
char
* version =
getDllVersion
())
dllVersion
= version;
25
logger
->
Log
((
"FreeTrack: DLL Version: "
+
dllVersion
).c_str());
26
}
27
}
28
29
void
FreeTrack::Reset
()
30
{
31
input
.
Reset
();
32
viewscreen
->
rolltilt
= 0;
33
}
34
35
void
FreeTrack::Poll
()
36
{
37
const
auto
& lateral =
viewscreen
->
gameclass
->
config
.
inputConfigLookLateral
;
38
const
auto
& vertical =
viewscreen
->
gameclass
->
config
.
inputConfigLookVertical
;
39
try
40
{
41
const
bool
fresh =
input
.
Poll
(lateral.IsFreeTrack(), vertical.IsFreeTrack(), GetTickCount64(),
42
[
this
](
FreeTrackData
* data) {
return
getData
&&
getData
(data); });
43
if
(fresh)
44
input
.
Apply
(lateral.IsFreeTrack() &&
viewscreen
->
camera
->
allowPan
,
45
vertical.IsFreeTrack() &&
viewscreen
->
camera
->
allowTilt
,
46
lateral.invert, vertical.invert,
viewscreen
->
targetLeftright
,
viewscreen
->
targetUpdown
);
47
viewscreen
->
rolltilt
=
input
.
roll
;
48
}
49
catch
(...)
50
{
51
Reset
();
52
getData
=
nullptr
;
// A faulty client must not keep failing every frame.
53
logger
->
Log
(
"FreeTrack::Poll unhandled exception!"
,
Logger::Level::Error
);
54
}
55
}
56
57
FreeTrack::~FreeTrack
()
58
{
59
if
(
hinstLib
) FreeLibrary(
hinstLib
);
60
}
FreeTrack.h
Viewscreen.h
Config::inputConfigLookLateral
InputConfig inputConfigLookLateral
Definition
config.h:43
Config::inputConfigLookVertical
InputConfig inputConfigLookVertical
Definition
config.h:44
FreeTrack::~FreeTrack
~FreeTrack()
Definition
FreeTrack.cpp:57
FreeTrack::Poll
void Poll()
Definition
FreeTrack.cpp:35
FreeTrack::hinstLib
HINSTANCE hinstLib
Definition
FreeTrack.h:30
FreeTrack::reportID
importReportID reportID
Definition
FreeTrack.h:43
FreeTrack::dllVersion
std::string dllVersion
Definition
FreeTrack.h:46
FreeTrack::importProvider
const char *(WINAPI *) importProvider()
Definition
FreeTrack.h:38
FreeTrack::provider
importProvider provider
Definition
FreeTrack.h:44
FreeTrack::input
FreeTrackInput input
Definition
FreeTrack.h:49
FreeTrack::FreeTrack
FreeTrack(Viewscreen *prmViewscreen)
Definition
FreeTrack.cpp:5
FreeTrack::getDllVersion
importGetDllVersion getDllVersion
Definition
FreeTrack.h:42
FreeTrack::importGetData
BOOL(WINAPI *) importGetData(FreeTrackData *data)
Definition
FreeTrack.h:35
FreeTrack::importGetDllVersion
const char *(WINAPI *) importGetDllVersion()
Definition
FreeTrack.h:36
FreeTrack::logger
Logger * logger
Definition
FreeTrack.h:28
FreeTrack::viewscreen
Viewscreen * viewscreen
Definition
FreeTrack.h:27
FreeTrack::importReportID
void(WINAPI *) importReportID(int name)
Definition
FreeTrack.h:37
FreeTrack::Reset
void Reset()
Definition
FreeTrack.cpp:29
FreeTrack::getData
importGetData getData
Definition
FreeTrack.h:41
FreeTrackInput::Apply
void Apply(bool lateral, bool vertical, bool invertLateral, bool invertVertical, float &targetLateral, float &targetVertical) const
Definition
FreeTrackInput.h:98
FreeTrackInput::roll
float roll
Definition
FreeTrackInput.h:28
FreeTrackInput::Poll
bool Poll(bool lateral, bool vertical, std::uint64_t now, Reader read)
Definition
FreeTrackInput.h:36
FreeTrackInput::Reset
void Reset()
Definition
FreeTrackInput.h:33
GameClass::config
Config config
Definition
GameClass.h:100
Logger::Log
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition
Logger.cpp:283
Logger::Warn
@ Warn
Definition
Logger.h:26
Logger::Error
@ Error
Definition
Logger.h:28
SCamera::allowPan
bool allowPan
Definition
Camera.h:18
SCamera::allowTilt
bool allowTilt
Definition
Camera.h:19
Viewscreen
Definition
Viewscreen.h:48
Viewscreen::gameclass
GameClass * gameclass
Definition
Viewscreen.h:439
Viewscreen::rolltilt
float rolltilt
Definition
Viewscreen.h:447
Viewscreen::targetUpdown
float targetUpdown
Definition
Viewscreen.h:445
Viewscreen::targetLeftright
float targetLeftright
Definition
Viewscreen.h:444
Viewscreen::camera
SCamera * camera
Definition
Viewscreen.h:137
FreeTrackData
Definition
FreeTrackInput.h:8
Viewscreen
FreeTrack.cpp
Generated on
for Rise by
1.18.0