summaryrefslogtreecommitdiff
path: root/src/libtouch.h
blob: 50d3ed668661c7dc35932c58c7e7d2260c88c9ae (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _libtouch_H_
#define _libtouch_H_
#include <os.h>

#include "libconfig.h"

#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
#define HAVE_PROPERTIES 1
#endif

#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) */

#define LIBTOUCH_DEFAULT_TAP_TIMER          90
#define LIBTOUCH_DEFAULT_LONGTOUCH_TIMER    160
#define LIBTOUCH_DEFAULT_MOVE_LIMIT         180

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 libtouchSetMoveLimit(LibTouchRecPtr libtouch, int move_limit);

void libtouchInit(LibTouchRecPtr libtouch, LocalDevicePtr local);

#ifdef HAVE_PROPERTIES
void libtouchInitProperty(LibTouchRecPtr libtouch, DeviceIntPtr dev);
int libtouchSetProperty(LibTouchRecPtr libtouch, Atom atom, 
                        XIPropertyValuePtr val, BOOL checkonly);
void libtouchWriteHalConfig(LibTouchRecPtr libtouch, LibConfigRecPtr config);
#endif

void libtouchSetTime(LibTouchRecPtr libtouch, CARD32 now);
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