@@ -43,6 +43,7 @@ static std::string host("localhost");
43
43
static int port = 3333 ;
44
44
static int protocol = TUIO_UDP;
45
45
static int dev_id = 0 ;
46
+ static float y_scale;
46
47
47
48
// Sensitivity
48
49
#define MIN_DISTANCE 0 .00001f
@@ -156,6 +157,11 @@ typedef void (*MTPathCallbackFunction)(MTDeviceRef device, long pathID, long sta
156
157
// Process incoming events
157
158
static void callback (MTDeviceRef device, MTTouch touches[], size_t numTouches, double timestamp, size_t frame) {
158
159
160
+
161
+ /* int width,height;
162
+ MTDeviceGetSensorSurfaceDimensions(device, &width, &height);
163
+ std::cout << width << " " << height << std::endl;*/
164
+
159
165
if (!running || !sampling_interval_passed ()) {
160
166
return ;
161
167
}
@@ -170,8 +176,9 @@ static void callback(MTDeviceRef device, MTTouch touches[], size_t numTouches, d
170
176
MTTouch *f = &touches[i];
171
177
int id = f->pathIndex ;
172
178
179
+ if (f->normalizedVector .position .y >y_scale) y_scale = f->normalizedVector .position .y ;
173
180
float x = f->normalizedVector .position .x ;
174
- float y = 1 .0f - f->normalizedVector .position .y /1 . 15f ; // reverse y axis, work around scaling
181
+ float y = 1 .0f - f->normalizedVector .position .y /y_scale ; // reverse y axis, work around scaling
175
182
176
183
if (x<0 ) x=0 ; else if (x>1 ) x=1 ;
177
184
if (y<0 ) y=0 ; else if (y>1 ) y=1 ;
@@ -251,6 +258,8 @@ static void mt_start()
251
258
dev = (MTDeviceRef)CFArrayGetValueAtIndex (devList, dev_id);
252
259
MTRegisterContactFrameCallback (dev, callback);
253
260
MTDeviceStart (dev, 0 );
261
+
262
+ y_scale = 1 ;
254
263
}
255
264
256
265
// Stop handling multitouch events
0 commit comments