From aa066bdd4622d4f6824fee864f6be6806813f04d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 07:37:41 +0100 Subject: move to subdirectory-based build system Closes #224 --- protocol-mouse/CMakeLists.txt | 3 + protocol-mouse/ftnoir_mousecontrols.ui | 188 ++++++++++++++++++++++++ protocol-mouse/ftnoir_protocol_mouse.cpp | 54 +++++++ protocol-mouse/ftnoir_protocol_mouse.h | 59 ++++++++ protocol-mouse/ftnoir_protocol_mouse_dialog.cpp | 24 +++ protocol-mouse/images/mouse.png | Bin 0 -> 1169 bytes protocol-mouse/win32-mouse-protocol.qrc | 5 + 7 files changed, 333 insertions(+) create mode 100644 protocol-mouse/CMakeLists.txt create mode 100644 protocol-mouse/ftnoir_mousecontrols.ui create mode 100644 protocol-mouse/ftnoir_protocol_mouse.cpp create mode 100644 protocol-mouse/ftnoir_protocol_mouse.h create mode 100644 protocol-mouse/ftnoir_protocol_mouse_dialog.cpp create mode 100644 protocol-mouse/images/mouse.png create mode 100644 protocol-mouse/win32-mouse-protocol.qrc (limited to 'protocol-mouse') diff --git a/protocol-mouse/CMakeLists.txt b/protocol-mouse/CMakeLists.txt new file mode 100644 index 00000000..b221c79c --- /dev/null +++ b/protocol-mouse/CMakeLists.txt @@ -0,0 +1,3 @@ +if(WIN32) + opentrack_boilerplate(opentrack-proto-win32-mouse) +endif() diff --git a/protocol-mouse/ftnoir_mousecontrols.ui b/protocol-mouse/ftnoir_mousecontrols.ui new file mode 100644 index 00000000..b1f4bcf8 --- /dev/null +++ b/protocol-mouse/ftnoir_mousecontrols.ui @@ -0,0 +1,188 @@ + + + UICMOUSEControls + + + Qt::NonModal + + + + 0 + 0 + 280 + 106 + + + + Mouse protocol settings + + + + :/images/mouse.png:/images/mouse.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + Map mouse X to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + None + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + None + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 0 + 0 + + + + Map mouse Y to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/protocol-mouse/ftnoir_protocol_mouse.cpp b/protocol-mouse/ftnoir_protocol_mouse.cpp new file mode 100644 index 00000000..c0a0a868 --- /dev/null +++ b/protocol-mouse/ftnoir_protocol_mouse.cpp @@ -0,0 +1,54 @@ +/* Copyright (c) 2015 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ +#include "ftnoir_protocol_mouse.h" +#include "opentrack/plugin-api.hpp" +#include + +#ifndef MOUSEEVENTF_MOVE_NOCOALESCE +# define MOUSEEVENTF_MOVE_NOCOALESCE 0x2000 +#endif + +void FTNoIR_Protocol::pose(const double *headpose ) { + RECT desktop; + const HWND hDesktop = GetDesktopWindow(); + if (hDesktop != NULL && GetWindowRect(hDesktop, &desktop)) { + // 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 = 0, mouse_y = 0; + + 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; + + MOUSEINPUT mi; + mi.dx = mouse_x - last_x; + mi.dy = mouse_y - last_y; + mi.mouseData = 0; + mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE; + mi.time = 0; + mi.dwExtraInfo = 0; + INPUT input; + input.type = INPUT_MOUSE; + input.mi = mi; + (void) SendInput(1, &input, sizeof(INPUT)); + + last_x = mouse_x; + last_y = mouse_y; + } +} + +bool FTNoIR_Protocol::correct() +{ + return true; +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, MOUSEControls, FTNoIR_ProtocolDll) diff --git a/protocol-mouse/ftnoir_protocol_mouse.h b/protocol-mouse/ftnoir_protocol_mouse.h new file mode 100644 index 00000000..595be393 --- /dev/null +++ b/protocol-mouse/ftnoir_protocol_mouse.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2015 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include "ui_ftnoir_mousecontrols.h" +#include +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value Mouse_X, Mouse_Y; + settings() : + opts("mouse-proto"), + Mouse_X(b, "mouse-x", 0), + Mouse_Y(b, "mouse-y", 0) + {} +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol() : last_x(0), last_y(0) {} + bool correct(); + void pose( const double *headpose); + QString game_name() { + return "Mouse tracker"; + } + int last_x, last_y; +private: + struct settings s; +}; + +class MOUSEControls: public IProtocolDialog +{ + Q_OBJECT +public: + MOUSEControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICMOUSEControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("mouse emulation"); } + QIcon icon() { return QIcon(":/images/mouse.png"); } +}; diff --git a/protocol-mouse/ftnoir_protocol_mouse_dialog.cpp b/protocol-mouse/ftnoir_protocol_mouse_dialog.cpp new file mode 100644 index 00000000..bb5fe3b8 --- /dev/null +++ b/protocol-mouse/ftnoir_protocol_mouse_dialog.cpp @@ -0,0 +1,24 @@ +#include "ftnoir_protocol_mouse.h" +#include "opentrack/plugin-api.hpp" + +MOUSEControls::MOUSEControls() +{ + ui.setupUi( this ); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.Mouse_X, ui.cbxSelectMouse_X); + tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y); +} + +void MOUSEControls::doOK() { + s.b->save(); + this->close(); +} + +void MOUSEControls::doCancel() { + s.b->reload(); + this->close(); +} + diff --git a/protocol-mouse/images/mouse.png b/protocol-mouse/images/mouse.png new file mode 100644 index 00000000..c6f9ea26 Binary files /dev/null and b/protocol-mouse/images/mouse.png differ diff --git a/protocol-mouse/win32-mouse-protocol.qrc b/protocol-mouse/win32-mouse-protocol.qrc new file mode 100644 index 00000000..ed6a71be --- /dev/null +++ b/protocol-mouse/win32-mouse-protocol.qrc @@ -0,0 +1,5 @@ + + + images/mouse.png + + -- cgit v1.2.3