summaryrefslogtreecommitdiff
path: root/libtouch.h
blob: e7e2c739377c55a153db2b105b11acd39b51aff9 (plain)
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
#ifndef _libtouch_H_
#define _libtouch_H_
#include <os.h>

#define TOUCHED 0x01
#define X_COORD 0x02
#define Y_COORD 0x04
#define LB_STAT 0x08  /* LB up / down */
#define RB_STAT 0x10  /* RB up / down (both needed for 3-btn emu) */

typedef enum touchState {
        PEN_TOUCHED   = 1,
        PEN_UNTOUCHED = 2,
        PEN_UNKNOWN   = 3
} LibTouchState_t;

typedef struct _libtouch {
        int cur_x;
        int cur_y;
        int ypos_changed;
	int xpos_changed;
        int old_x;
        int old_y;

        LibTouchState_t pen;

        OsTimerPtr tap_timer;
        int        tap_timeo;
        Bool       tap_timer_expired;

        OsTimerPtr longtouch_timer;
        int        longtouch_timeo;
        Bool       longtouch_timer_expired;

        int drag_timer;
        unsigned char pressed_btn_stat;

        int move_limit;

        int untouch_time;
        int touch_time;
        int touch_x;
        int touch_y;
        int last_touch_x;
        int last_touch_y;
        unsigned char touch_flags; /* 1 - touched, 2 - x-coord received
                                      4 - y-coord received */

        CARD32 past;
        CARD32 now;
        LocalDevicePtr local;
} LibTouchRec, *LibTouchRecPtr;

void libtouchSetDebugLevel(int level);
void libtouchSetTapTimeo(LibTouchRecPtr libtouch, int timeo);
void libtouchSetLongtouchTimeo(LibTouchRecPtr libtouch, int timeo);
void libtouchSetOneandahalftapTimeo(LibTouchRecPtr libtouch, int timeo);
void libtouchSetTime(LibTouchRecPtr libtouch, CARD32 now);
void libtouchSetMoveLimit(LibTouchRecPtr libtouch, int move_limit);

void libtouchInit(LibTouchRecPtr libtouch, LocalDevicePtr local);

void libtouchSetPos(LibTouchRecPtr libtouch, int x, int y);
void libtouchTriggerSM(LibTouchRecPtr libtouch, LibTouchState_t touch);
void libtouchSetXPos(LibTouchRecPtr libtouch, int x);
void libtouchSetYPos(LibTouchRecPtr libtouch, int y);

#endif