-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
pointeraction.h
executable file
·186 lines (158 loc) · 5.68 KB
/
pointeraction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/////////////////////////////////////////////////////////////////////////////
// Name: pointeraction.h
// Purpose:
// Author: Cesar Mauri Loba (cesar at crea-si dot com)
// Modified by:
// Created:
// Copyright: (C) 2008-11 Cesar Mauri Loba - CREA Software Systems
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////
#ifndef POINTERACTION_H
#define POINTERACTION_H
#include "mousecontrol.h"
#include "configbase.h"
#include <math.h>
class wxSound;
class wxWindow;
class CMouseControl;
class CDwellClick;
class CGestureClick;
class CPointerAction : public CConfigBase
{
public:
CPointerAction ();
~CPointerAction ();
// Call from machine vision tracker
void ProcessMotion (float dxSensor, float dySensor);
// Enable/disable processing motion and generating actions
bool GetEnabled() const { return m_enabled; }
void SetEnabled(bool value);
// Choose among diferent types of click generation modes
enum EClickMode { NONE, DWELL, GESTURE };
EClickMode GetClickMode() const { return m_clickMode; }
bool SetClickMode(EClickMode mode, bool silent= true, wxWindow* parent= NULL);
unsigned int GetXSpeed() const { return m_xSpeed; }
void SetXSpeed(unsigned int value) {
if (value >= 0 && value <= 30)
{
m_xSpeed= value;
m_pMouseControl->SetRelFactorX (GetSpeedFactor(m_xSpeed));
}
}
unsigned int GetYSpeed() const { return m_ySpeed; }
void SetYSpeed(unsigned int value) {
if (value >= 0 && value <= 30)
{
m_ySpeed= value;
m_pMouseControl->SetRelFactorY (GetSpeedFactor(m_ySpeed));
}
}
unsigned int GetAcceleration() const {
return m_acceleration;
}
void SetAcceleration(unsigned int acceleration);
unsigned int GetSmoothness() const {
return (unsigned int) (powf (10.0f, m_pMouseControl->GetLowPassFilterWeight ()) + 0.5f) - 1;
}
void SetSmoothness (unsigned int smoothness) {
if (smoothness> 8) smoothness= 8;
m_pMouseControl->SetLowPassFilterWeight (log10f((float) smoothness + 1));
}
unsigned int GetEasyStopValue() const {
return (unsigned int) m_pMouseControl->GetRelDeltaThreshold ();
}
void SetEasyStopValue (unsigned int value) {
if (value> 10) value= 10;
m_pMouseControl->SetRelDeltaThreshold ( (float) value);
}
bool GetBeepOnClick() const { return m_beepOnClick; }
void SetBeepOnClick(bool value) { m_beepOnClick = value; }
// Common for dwell and gesture click
bool GetVisualAlerts() const;
void SetVisualAlerts(bool value);
// Common for dwell and gesture click
unsigned int GetDwellTime() const;
void SetDwellTime (unsigned int ds);
// Common for dwell and gesture click
unsigned int GetDwellToleranceArea() const;
void SetDwellToleranceArea(unsigned int value);
void SetRestrictedWorkingArea (bool value) {
m_pMouseControl->SetRestrictedWorkingArea(value);
}
bool GetRestrictedWorkingArea() const {
return m_pMouseControl->GetRestrictedWorkingArea();
}
unsigned int GetTopWorkspace() const {
return (unsigned int) ((1.0f - m_pMouseControl->GetTopPercent()) * 50.0f + 0.5f);
}
void SetTopWorkspace(unsigned int value) {
if (value > 50) value = 50;
m_pMouseControl->SetTopPercent((float) (50 - value) / 50.0f);
}
unsigned int GetLeftWorkspace() const {
return (unsigned int) ((1.0f - m_pMouseControl->GetLeftPercent()) * 50.0f + 0.5f);
}
void SetLeftWorkspace(unsigned int value) {
if (value > 50) value = 50;
m_pMouseControl->SetLeftPercent((float) (50 - value) / 50.0f);
}
unsigned int GetRightWorkspace() const {
return (unsigned int) ((1.0f - m_pMouseControl->GetRightPercent()) * 50.0f + 0.5f);
}
void SetRightWorkspace(unsigned int value) {
if (value > 50) value = 50;
m_pMouseControl->SetRightPercent((float) (50 - value) / 50.0f);
}
unsigned int GetBottomWorkspace() {
return (unsigned int) ((1.0f - m_pMouseControl->GetBottomPercent()) * 50.0f + 0.5f);
}
void SetBottomWorkspace(unsigned int value) {
if (value > 50) value = 50;
m_pMouseControl->SetBottomPercent((float) (50 - value) / 50.0f);
}
void SetWrapPointer (bool value) {
m_pMouseControl->SetWrapPointer(value);
}
bool GetWrapPointer() const {
return m_pMouseControl->GetWrapPointer();
}
void SetSendActionWait(unsigned int ms) {
if (ms> 50) ms= 50;
m_pMouseControl->SetSendActionWait(ms);
}
unsigned int GetSendActionWait() const { return m_pMouseControl->GetSendActionWait(); }
void ResetCounters();
//
void CenterPointer () { m_pMouseControl->CenterPointer(); };
CDwellClick& GetDwellClick() { assert (m_pDwellClick); return *m_pDwellClick; }
CGestureClick& GetGestureClick() { assert (m_pGestureClick); return *m_pGestureClick; }
// Configuration methods
virtual void InitDefaults();
virtual void WriteProfileData(wxConfigBase* pConfObj);
virtual void ReadProfileData(wxConfigBase* pConfObj);
private:
float GetSpeedFactor(unsigned int speed) const;
bool m_enabled;
unsigned int m_xSpeed, m_ySpeed;
unsigned int m_acceleration;
EClickMode m_clickMode;
bool m_beepOnClick;
wxSound* m_pClickSound;
wxSound* m_pLeftUpClickSound;
CMouseControl* m_pMouseControl;
CDwellClick* m_pDwellClick;
CGestureClick* m_pGestureClick;
};
#endif