summaryrefslogtreecommitdiffhomepage
path: root/protocol-mouse
diff options
context:
space:
mode:
Diffstat (limited to 'protocol-mouse')
-rw-r--r--protocol-mouse/CMakeLists.txt3
-rw-r--r--protocol-mouse/ftnoir_mousecontrols.ui188
-rw-r--r--protocol-mouse/ftnoir_protocol_mouse.cpp54
-rw-r--r--protocol-mouse/ftnoir_protocol_mouse.h59
-rw-r--r--protocol-mouse/ftnoir_protocol_mouse_dialog.cpp24
-rw-r--r--protocol-mouse/images/mouse.pngbin0 -> 1169 bytes
-rw-r--r--protocol-mouse/win32-mouse-protocol.qrc5
7 files changed, 333 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UICMOUSEControls</class>
+ <widget class="QWidget" name="UICMOUSEControls">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>280</width>
+ <height>106</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Mouse protocol settings</string>
+ </property>
+ <property name="windowIcon">
+ <iconset resource="win32-mouse-protocol.qrc">
+ <normaloff>:/images/mouse.png</normaloff>:/images/mouse.png</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel2_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Map mouse X to:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QComboBox" name="cbxSelectMouse_X">
+ <property name="maximumSize">
+ <size>
+ <width>80</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Select Number</string>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::InsertAlphabetically</enum>
+ </property>
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Z</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Yaw</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Roll</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2">
+ <widget class="QComboBox" name="cbxSelectMouse_Y">
+ <property name="maximumSize">
+ <size>
+ <width>80</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Select Number</string>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::InsertAlphabetically</enum>
+ </property>
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Z</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Yaw</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Roll</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel2_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Map mouse Y to:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="win32-mouse-protocol.qrc"/>
+ </resources>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
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 <sthalik@misaki.pl>
+ *
+ * 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 <windows.h>
+
+#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 <sthalik@misaki.pl>
+ *
+ * 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 <QDebug>
+#include "opentrack/plugin-api.hpp"
+#include "opentrack/options.hpp"
+using namespace options;
+
+struct settings : opts {
+ value<int> 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
--- /dev/null
+++ b/protocol-mouse/images/mouse.png
Binary files 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 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/mouse.png</file>
+ </qresource>
+</RCC>