aboutsummaryrefslogtreecommitdiff
path: root/src/mtouch.c
blob: 5c71a3bdcc2343f5c5ecd2b24f56f23a98cef33a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "mtouch.h"

struct cached_finger_data *cached_finger_data[256];

void process_cached_finger_data(int identifier)
{
    printf("-- begin processing finger (%d) --\n", identifier);
    int frame_count = buf_len(cached_finger_data[identifier]);
    for (int i = 0; i < frame_count; ++i) {
        struct cached_finger_data cached_data = cached_finger_data[identifier][i];
        printf("finger: %d, pos: (%.5f, %.5f), pressure: %.5f\n",
                cached_data.id,
                cached_data.pos.x, cached_data.pos.y,
                cached_data.pressure);
    }
    printf("-- end processing (%d frames) --\n", frame_count);
}

void multitouch_begin(struct multitouch *multitouch, multitouch_callback *callback)
{
    multitouch->dev = MTDeviceCreateDefault();
    MTRegisterContactFrameCallback(multitouch->dev, callback);
    MTDeviceStart(multitouch->dev, 0);
}