diff options
Diffstat (limited to 'ftnoir_protocol_mouse')
-rw-r--r-- | ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 43 | ||||
-rw-r--r-- | ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 13 | ||||
-rw-r--r-- | ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp | 4 |
3 files changed, 26 insertions, 34 deletions
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index ac543812..e26f6cbf 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -30,34 +30,33 @@ #include "opentrack/plugin-api.hpp" void FTNoIR_Protocol::pose(const double *headpose ) { - double fMouse_X = 0; - double fMouse_Y = 0; - - // XXX TODO remove axis selector, use mapping window's - // axis selection. Mention in UI axis used. -sh 20140920 - int Mouse_X = s.Mouse_X; - int Mouse_Y = s.Mouse_Y; - - if (Mouse_X > 0 && Mouse_X <= 6) - fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180); - - if (Mouse_Y > 0 && Mouse_Y <= 6) - fMouse_Y = headpose[Mouse_Y-1] / (Mouse_Y < 3 ? 100 : 180); - RECT desktop; const HWND hDesktop = GetDesktopWindow(); if (hDesktop != NULL && GetWindowRect(hDesktop, &desktop)) { - fMouse_X *= desktop.right; - fMouse_Y *= desktop.bottom; - SetCursorPos(fMouse_X + desktop.right/2, fMouse_Y + desktop.bottom/2); + // XXX TODO remove axis selector, use mapping window's + // axis selection. Mention in UI axis used. -sh 20140920 + int axis_x = s.Mouse_X; + int axis_y = s.Mouse_Y; + + int mouse_x, mouse_y; + + if (axis_x > 0 && axis_x <= 6) + mouse_x = headpose[axis_x-1] / (axis_x < 3 ? 100 : 180) * 10 * desktop.right/2; + + if (axis_y > 0 && axis_y <= 6) + mouse_y = headpose[axis_y-1] / (axis_y < 3 ? 100 : 180) * 10 * desktop.bottom/2; + + POINT pt; + + if (GetCursorPos(&pt)) + { + SetCursorPos(pt.x + mouse_x - last_x, pt.y + mouse_y - last_y); + last_x = mouse_x; + last_y = mouse_y; + } } } -void FTNoIR_Protocol::reload() -{ - s.b->reload(); -} - bool FTNoIR_Protocol::correct() { return true; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 3d04fa15..9f76571b 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -59,13 +59,13 @@ struct settings { class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol() {} + FTNoIR_Protocol() : last_x(0), last_y(0) {} bool correct(); void pose( const double *headpose); QString game_name() { return "Mouse tracker"; } - void reload(); + int last_x, last_y; private: struct settings s; }; @@ -75,16 +75,11 @@ class MOUSEControls: public IProtocolDialog Q_OBJECT public: MOUSEControls(); - void register_protocol(IProtocol *protocol) { - _proto = (FTNoIR_Protocol *) protocol; - } - void unregister_protocol() { - _proto = NULL; - } + void register_protocol(IProtocol *) {} + void unregister_protocol() {} private: Ui::UICMOUSEControls ui; settings s; - FTNoIR_Protocol* _proto; private slots: void doOK(); void doCancel(); diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index 3303e54c..f4ecaa48 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -25,7 +25,7 @@ #include "ftnoir_protocol_mouse.h" #include "opentrack/plugin-api.hpp" -MOUSEControls::MOUSEControls() : _proto(nullptr) +MOUSEControls::MOUSEControls() { ui.setupUi( this ); ui.cbxSelectMouse_X->addItem("None"); @@ -53,8 +53,6 @@ MOUSEControls::MOUSEControls() : _proto(nullptr) void MOUSEControls::doOK() { s.b->save(); - if (_proto) - _proto->reload(); this->close(); } |