-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalibratorbuilder.hh
155 lines (111 loc) · 3.52 KB
/
calibratorbuilder.hh
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
#ifndef _calibratorbuilder_hh
#define _calibratorbuilder_hh
#include <X11/Xlib.h>
#include <memory>
#include "lang.hh"
int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
float scaleAxis(float Cx, int to_max, int to_min, int from_max, int from_min);
struct AxisInfo
{
int min, max;
bool invert;
AxisInfo() : min(-1), max(-1), invert(false) { }
AxisInfo(int mi, int ma, bool inv = false) :
min(mi), max(ma), invert(inv) { }
AxisInfo(const AxisInfo& old) :
min(old.min), max(old.max), invert(old.invert) { }
void do_invert()
{
invert = !invert;
}
};
/// struct to hold min/max info of the X and Y axis
struct XYinfo {
/// Axis swapped
bool swap_xy;
/// X, Y axis
AxisInfo x, y;
XYinfo() : swap_xy(false) {}
XYinfo(int xmi, int xma, int ymi, int yma, bool swap_xy_ = false,
bool inv_x = false, bool inv_y = false) :
swap_xy(swap_xy_), x(xmi, xma, inv_x), y(ymi, yma, inv_y) {}
XYinfo(const XYinfo& old) :
swap_xy(old.swap_xy), x(old.x), y(old.y) {}
void do_xf86ScaleAxis(const XYinfo& to, const XYinfo& from) {
x.min = xf86ScaleAxis(x.min, to.x.max, to.x.min, from.x.max, from.x.min);
x.max = xf86ScaleAxis(x.max, to.x.max, to.x.min, from.x.max, from.x.min);
y.min = xf86ScaleAxis(y.min, to.y.max, to.y.min, from.y.max, from.y.min);
y.max = xf86ScaleAxis(y.max, to.y.max, to.y.min, from.y.max, from.y.min);
}
void print(const char* xtra="\n") {
printf("XYinfo: x.min=%i, x.max=%i, y.min=%i, y.max=%i, swap_xy=%i, invert_x=%i, invert_y=%i%s",
x.min, x.max, y.min, y.max, swap_xy, x.invert, y.invert, xtra);
}
};
/// Output types
enum OutputType
{
OUTYPE_AUTO,
OUTYPE_XORGCONFD,
OUTYPE_HAL,
OUTYPE_XINPUT
};
class CalibratorBuilder;
using PtrCalibratorBuilder = std::shared_ptr<CalibratorBuilder>;
class CalibratorBuilder
{
public:
CalibratorBuilder();
CalibratorBuilder(const CalibratorBuilder& builder);
CalibratorBuilder* setThrMisclick(int value);
int getThrMisclick() const;
CalibratorBuilder* setThrDoubleclick(int value);
int getThrDoubleclick() const;
XYinfo getAxys() const;
CalibratorBuilder*setAxys(const XYinfo&value);
const char *getDevice_name() const;
OutputType getOutput_type() const;
void setOutput_type(const OutputType&value);
char* getGeometry() const;
void setGeometry(char*value);
bool getUse_timeout() const;
CalibratorBuilder* setUse_timeout(bool value);
char*getOutput_filename() const;
void setOutput_filename(char*value);
bool getTestMode() const;
void setTestMode(bool value);
Lang getLang() const;
void setLang(const Lang&value);
bool getSmall() const;
void setSmall(bool value);
void setDevice_name(const char*value);
XID getDevice_id() const;
void setDevice_id(const XID&value);
bool getTouchID() const;
void setTouchID(bool value);
int getTimeout() const;
void setTimeout(int value);
bool getTouchEmpty() const;
void setTouchEmpty(bool value);
std::string getCrtc() const;
void setCrtc(const std::string&value);
private:
/// Name of the device (driver)
const char* device_name;
XYinfo axys;
int thr_misclick;
int thr_doubleclick;
OutputType output_type;
char* geometry;
bool use_timeout;
char* output_filename;
bool testMode;
Lang lang;
bool small;
XID device_id;// != (XID)-1)
bool touchID;
bool touchEmpty;
int timeout; //sec
std::string crtc; //sec
};
#endif