summaryrefslogtreecommitdiffhomepage
path: root/proto-mouse/ftnoir_protocol_mouse.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-14 11:47:30 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-14 18:14:46 +0200
commit1d8b1da9a68a47e6b222e8d80dc8e546e52e4dcc (patch)
tree2bbcf25de732bd8a81363f452e08520087b024b5 /proto-mouse/ftnoir_protocol_mouse.h
parenta8da0d997048007d3feb2e3814ba93bbfd4d4ef8 (diff)
proto/mouse: guard against +181 -> -179 wraparound
Always use the shorter way around. This also adds a sensitivity param. Issue: #370
Diffstat (limited to 'proto-mouse/ftnoir_protocol_mouse.h')
-rw-r--r--proto-mouse/ftnoir_protocol_mouse.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/proto-mouse/ftnoir_protocol_mouse.h b/proto-mouse/ftnoir_protocol_mouse.h
index f1730777..2d96915e 100644
--- a/proto-mouse/ftnoir_protocol_mouse.h
+++ b/proto-mouse/ftnoir_protocol_mouse.h
@@ -15,24 +15,30 @@ using namespace options;
struct settings : opts {
value<int> Mouse_X, Mouse_Y;
+ value<slider_value> sensitivity_x, sensitivity_y;
settings() :
opts("mouse-proto"),
Mouse_X(b, "mouse-x", 0),
- Mouse_Y(b, "mouse-y", 0)
+ Mouse_Y(b, "mouse-y", 0),
+ sensitivity_x(b, "mouse-sensitivity-x", slider_value(200, 100, 500)),
+ sensitivity_y(b, "mouse-sensitivity-y", slider_value(200, 100, 500))
{}
};
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";
- }
+ FTNoIR_Protocol() : last_pos_x(0), last_pos_y(0), last_x(0), last_y(0) {}
+ bool correct() override;
+ void pose( const double *headpose) override;
+ QString game_name() override;
+
+ double last_pos_x, last_pos_y;
int last_x, last_y;
private:
+ static double get_rotation(double val, double last_val);
+ static int get_value(double val, double& last_pos, int& last_px, bool is_rotation, double sensitivity);
+
struct settings s;
};