您好我不熟悉Java之外的任何内容,并且对我已包含的源代码有些困难。我认为这是C ++。我已经安装了Xcode,但它不仅仅是即插即用。这实际上是C ++吗? Xcode目前值得投入吗?最终目标是集成到Touch Designer中,这是否也是正确的轨道?
" #include<文件math.h>"
" #include< unistd.h中>"
" #include<的CoreFoundation / CoreFoundation.h>"
typedef struct { float x,y; } mtPoint;
typedef struct { mtPoint pos,vel; } mtReadout;
typedef struct {
int frame;
double timestamp;
int identifier, state, foo3, foo4;
mtReadout normalized;
float size;
int zero1;
float angle, majorAxis, minorAxis; // ellipsoid
mtReadout mm;
int zero2[2];
float unk2;
} Finger;
typedef void *MTDeviceRef;
typedef int (*MTContactCallbackFunction)(int,Finger*,int,double,int);
MTDeviceRef MTDeviceCreateDefault();
void MTRegisterContactFrameCallback(MTDeviceRef, MTContactCallbackFunction);
void MTDeviceStart(MTDeviceRef, int); // thanks comex
int callback(int device, Finger *data, int nFingers, double timestamp, int
frame) {
for (int i=0; i<nFingers; i++) {
Finger *f = &data[i];
printf("Frame %7d: Angle %6.2f, ellipse %6.3f x%6.3f; "
"position (%6.3f,%6.3f) vel (%6.3f,%6.3f) "
"ID %d, state %d [%d %d?] size %6.3f, %6.3f?\n",
f->frame,
f->angle * 90 / atan2(1,0),
f->majorAxis,
f->minorAxis,
f->normalized.pos.x,
f->normalized.pos.y,
f->normalized.vel.x,
f->normalized.vel.y,
f->identifier, f->state, f->foo3, f->foo4,
f->size, f->unk2);
}
printf("\n");
return 0;
}
int main() {
MTDeviceRef dev = MTDeviceCreateDefault();
MTRegisterContactFrameCallback(dev, callback);
MTDeviceStart(dev, 0);
printf("Ctrl-C to abort\n");
sleep(-1);
return 0;
}
run: test
./test
test: test.m
gcc -F/System/Library/PrivateFrameworks -framework MultitouchSupport $^ -o $@ -std=c99