Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: test/testprotocol.c

Issue 6475005: Revert "Import files from .tar.gz that are missing from upstream git repo." (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/xf86-input-synaptics.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/test-pad.c ('k') | tools/.gitignore » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fcntl.h>
4 #include <stdio.h>
5 #include <unistd.h>
6
7 static int outputformat = 0;
8
9 void
10 SynapticsReadPacket(int fd)
11 {
12 int count = 0;
13 int inSync = 0;
14 unsigned char pBuf[7], u;
15
16 while (read(fd,&u, 1) == 1) {
17 pBuf[count++] = u;
18
19 /* check first byte */
20 if ((count == 1) && ((u & 0xC8) != 0x80)) {
21 inSync = 0;
22 count = 0;
23 printf("Synaptics driver lost sync at 1st byte\n");
24 continue;
25 }
26
27 /* check 4th byte */
28 if ((count == 4) && ((u & 0xc8) != 0xc0)) {
29 inSync = 0;
30 count = 0;
31 printf("Synaptics driver lost sync at 4th byte\n");
32 continue;
33 }
34
35 if (count >= 6) { /* Full packet received */
36 if (!inSync) {
37 inSync = 1;
38 printf("Synaptics driver resynced.\n");
39 }
40 count = 0;
41 switch (outputformat) {
42 case 1:
43 printf("Paket:%02X-%02X-%02X-%02X-%02X-%02X\n",
44 pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5]);
45 break;
46 case 2:
47 printf("x = %i, y = %i, z = %i, w = %i, l = %i, r = %i\n",
48 ((pBuf[3] & 0x10) << 8) | ((pBuf[1] & 0x0f) << 8) | pBuf[ 4],
49 ((pBuf[3] & 0x20) << 7) | ((pBuf[1] & 0xf0) << 4) | pBuf[ 5],
50 ((pBuf[0] & 0x30) >> 2) | ((pBuf[0] & 0x04) >> 1) | ((pBu f[3] & 0x04) >> 2),
51 ((pBuf[0] & 0x30) >> 2) | ((pBuf[0] & 0x04) >> 1) | ((pBu f[3] & 0x04) >> 2),
52 (pBuf[0] & 0x01) ? 1 : 0,
53 (pBuf[0] & 0x2) ? 1 : 0);
54 break;
55 default:
56 break;
57 }
58 }
59 }
60 }
61
62 int
63 main(int argc, char* argv[])
64 {
65 int fd;
66
67 if (argc > 1)
68 outputformat = atoi(argv[1]);
69
70
71 fd = open("/dev/psaux", O_RDONLY);
72 if (fd == -1) {
73 printf("Error opening /dev/psaux\n");
74 exit(1);
75 }
76
77 SynapticsReadPacket(fd);
78
79 close(fd);
80
81 exit(0);
82 }
OLDNEW
« no previous file with comments | « test/test-pad.c ('k') | tools/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698