gpt4 book ai didi

c - Mac 多点触控代码

转载 作者:行者123 更新时间:2023-11-30 20:31:32 25 4
gpt4 key购买 nike

您好,我不熟悉 Java 之外的任何内容,并且对我所包含的源代码有一些困难。我认为是C++。我已经安装了 Xcode,但它不只是即插即用。那么这实际上是C++吗? Xcode 目前值得投入精力吗?最终目标是集成到 Touch Designer,那么这是否是正确的方向?

“#include

“#include

“#include

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

最佳答案

实际上是Objective-C 。 Objective-C 是一种类 C 语言,主要由 Apple 使用,但最近已被 Swift 取代。

关于c - Mac 多点触控代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50399080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com