summaryrefslogtreecommitdiff
path: root/synclient.c
blob: ec45b88889f773b69a99a1e00000f9a8e30a853f (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
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>

#define SHM_SYNAPTICS 23947
typedef struct _SynapticsSHM {
	int x, y;
	int z;								/* pressure value */
	int w;								/* finger width value */
	int left, right, up, down;			/* left/right/up/down buttons */
} SynapticsSHM;

static int is_equal(SynapticsSHM* s1, SynapticsSHM* s2)
{
	return ((s1->x     == s2->x) &&
			(s1->y     == s2->y) &&
			(s1->z     == s2->z) &&
			(s1->w     == s2->w) &&
			(s1->left  == s2->left) &&
			(s1->right == s2->right) &&
			(s1->up    == s2->up) &&
			(s1->down  == s2->down));
}

int main() {
	SynapticsSHM *synshm;
	int shmid;
	SynapticsSHM old;

	if((shmid = shmget(SHM_SYNAPTICS, 0, 0)) == -1) 
		printf("shmget Fehler\n");
	if((synshm = (SynapticsSHM*) shmat(shmid, NULL, 0)) == NULL)
		printf("shmat Fehler\n");

	while(1) {
		SynapticsSHM cur = *synshm;
		if (!is_equal(&old, &cur)) {
			printf("x:%4d y:%4d z:%3d w:%2d left:%d right:%d up:%d down:%d\n",
				   cur.x, cur.y, cur.z, cur.w, cur.left, cur.right, cur.up, cur.down);
			old = cur;
		}
		usleep(100000);
	}

	exit(0);
}

/* Local Variables: */
/* tab-width: 4 */
/* End: */