diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-29 20:16:26 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-29 20:16:26 +0200 |
commit | dbb5ab72d1f16ce864567dad84a7bf2a586fd0ff (patch) | |
tree | ec5aeca433f6fab2619834dd0c1edc1c8c46ff13 /ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | |
parent | c05fc771558a62ebdcd16dfb2f8459ae2a12fb88 (diff) |
VJoy protocol
Diffstat (limited to 'ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp')
-rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp new file mode 100644 index 00000000..6fea845c --- /dev/null +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -0,0 +1,37 @@ +#include "ftnoir_protocol_vjoy.h" +#include "facetracknoir/global-settings.h" +#include <ftnoir_tracker_base/ftnoir_tracker_types.h> + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + VJoy_Initialize("", ""); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + VJoy_Shutdown(); +} + +void FTNoIR_Protocol::Initialize() +{ +} + +void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { + JOYSTICK_STATE state[2] = { 0 }; + + state[0].XAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[RX] * VJOY_AXIS_MAX / 180.0)); + state[0].YAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[RY] * VJOY_AXIS_MAX / 180.0)); + state[0].ZAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[RZ] * VJOY_AXIS_MAX / 180.0)); + state[0].XRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TX] * VJOY_AXIS_MAX / 100.0)); + state[0].YRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TY] * VJOY_AXIS_MAX / 100.0)); + state[0].ZRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TZ] * VJOY_AXIS_MAX / 100.0)); + + VJoy_UpdateJoyState(0, state); +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} |