diff options
author | Peter Osterlund <petero2@telia.com> | 2003-09-15 21:26:08 +0200 |
---|---|---|
committer | Peter Osterlund <petero2@telia.com> | 2006-04-09 04:01:10 +0200 |
commit | 1e01005291b312b9cc229701832991b77dbc7f79 (patch) | |
tree | 054c192d215ab91b40680d8e70087c611cd08b42 | |
parent | 738003e9f6154b7b1bde845b030916c03080d56e (diff) |
Forgot to run emacs indent before last check in.
-rw-r--r-- | ps2comm.c | 34 | ||||
-rw-r--r-- | testprotokoll.c | 107 |
2 files changed, 72 insertions, 69 deletions
@@ -137,7 +137,7 @@ ps2_special_cmd(int fd, byte cmd) /* send 4x 2-bits with set resolution command */ for (i=0; i<4; i++) { if (((ps2_putbyte(fd, PS2_CMD_SET_RESOLUTION)) != Success) || - ((ps2_putbyte(fd, (cmd>>6)&0x3) != Success))) + ((ps2_putbyte(fd, (cmd>>6)&0x3) != Success))) return !Success; cmd<<=2; } @@ -188,7 +188,7 @@ synaptics_reset(int fd) } xf86WaitForInput(fd, 4000000); if ((ps2_getbyte(fd, &r[0]) == Success) && - (ps2_getbyte(fd, &r[1]) == Success)) { + (ps2_getbyte(fd, &r[1]) == Success)) { if (r[0] == 0xAA && r[1] == 0x00) { DBG(ErrorF("...done\n")); return Success; @@ -213,9 +213,9 @@ synaptics_model_id(int fd, unsigned long int *model_id) DBG(ErrorF("Read mode id...\n")); if ((ps2_send_cmd(fd, SYN_QUE_MODEL) == Success) && - (ps2_getbyte(fd, &mi[0]) == Success) && - (ps2_getbyte(fd, &mi[1]) == Success) && - (ps2_getbyte(fd, &mi[2]) == Success)) { + (ps2_getbyte(fd, &mi[0]) == Success) && + (ps2_getbyte(fd, &mi[1]) == Success) && + (ps2_getbyte(fd, &mi[2]) == Success)) { *model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2]; DBG(ErrorF("mode-id %06X\n", *model_id)); DBG(ErrorF("...done.\n")); @@ -238,17 +238,17 @@ synaptics_capability(int fd, unsigned long int *capability, unsigned long int *e *ext_capab = 0; if ((ps2_send_cmd(fd, SYN_QUE_CAPABILITIES) == Success) && - (ps2_getbyte(fd, &cap[0]) == Success) && - (ps2_getbyte(fd, &cap[1]) == Success) && - (ps2_getbyte(fd, &cap[2]) == Success)) { + (ps2_getbyte(fd, &cap[0]) == Success) && + (ps2_getbyte(fd, &cap[1]) == Success) && + (ps2_getbyte(fd, &cap[2]) == Success)) { *capability = (cap[0]<<16) | (cap[1]<<8) | cap[2]; DBG(ErrorF("capability %06X\n", *capability)); if (SYN_CAP_VALID(*capability)) { if (SYN_EXT_CAP_REQUESTS(*capability)) { if ((ps2_send_cmd(fd, SYN_QUE_EXT_CAPAB) == Success) && - (ps2_getbyte(fd, &cap[0]) == Success) && - (ps2_getbyte(fd, &cap[1]) == Success) && - (ps2_getbyte(fd, &cap[2]) == Success)) { + (ps2_getbyte(fd, &cap[0]) == Success) && + (ps2_getbyte(fd, &cap[1]) == Success) && + (ps2_getbyte(fd, &cap[2]) == Success)) { *ext_capab = (cap[0]<<16) | (cap[1]<<8) | cap[2]; DBG(ErrorF("ext-capability %06X\n", *ext_capab)); } else { @@ -276,9 +276,9 @@ synaptics_identify(int fd, unsigned long int *ident) DBG(ErrorF("Identify Touchpad...\n")); if ((ps2_send_cmd(fd, SYN_QUE_IDENTIFY) == Success) && - (ps2_getbyte(fd, &id[0]) == Success) && - (ps2_getbyte(fd, &id[1]) == Success) && - (ps2_getbyte(fd, &id[2]) == Success)) { + (ps2_getbyte(fd, &id[0]) == Success) && + (ps2_getbyte(fd, &id[1]) == Success) && + (ps2_getbyte(fd, &id[2]) == Success)) { *ident = (id[0]<<16) | (id[1]<<8) | id[2]; DBG(ErrorF("ident %06X\n", *ident)); if (SYN_ID_IS_SYNAPTICS(*ident)) { @@ -301,9 +301,9 @@ synaptics_read_mode(int fd, unsigned char *mode) DBG(ErrorF("Read mode byte...\n")); if ((ps2_send_cmd(fd, SYN_QUE_MODES) == Success) && - (ps2_getbyte(fd, &modes[0]) == Success) && - (ps2_getbyte(fd, &modes[1]) == Success) && - (ps2_getbyte(fd, &modes[2]) == Success)) { + (ps2_getbyte(fd, &modes[0]) == Success) && + (ps2_getbyte(fd, &modes[1]) == Success) && + (ps2_getbyte(fd, &modes[2]) == Success)) { *mode = modes[2]; DBG(ErrorF("modes byte %02X%02X%02X\n", modes[0], modes[1], modes[2])); diff --git a/testprotokoll.c b/testprotokoll.c index 7cd0483..51758be 100644 --- a/testprotokoll.c +++ b/testprotokoll.c @@ -4,75 +4,78 @@ #include <stdio.h> #include <unistd.h> -int outputformat = 0; +static int outputformat = 0; void SynapticsReadPacket(int fd) { - int count = 0; - int inSync = 0; - unsigned char pBuf[7], u; + int count = 0; + int inSync = 0; + unsigned char pBuf[7], u; - while (read(fd,&u, 1) == 1) { - pBuf[count++] = u; + while (read(fd,&u, 1) == 1) { + pBuf[count++] = u; - /* check first byte */ - if ((count == 1) && ((u & 0xC8) != 0x80)) { - inSync = 0; - count = 0; - printf("Synaptics driver lost sync at 1st byte\n"); - continue; - } + /* check first byte */ + if ((count == 1) && ((u & 0xC8) != 0x80)) { + inSync = 0; + count = 0; + printf("Synaptics driver lost sync at 1st byte\n"); + continue; + } - /* check 4th byte */ - if ((count == 4) && ((u & 0xc8) != 0xc0)) { - inSync = 0; - count = 0; - printf("Synaptics driver lost sync at 4th byte\n"); - continue; - } + /* check 4th byte */ + if ((count == 4) && ((u & 0xc8) != 0xc0)) { + inSync = 0; + count = 0; + printf("Synaptics driver lost sync at 4th byte\n"); + continue; + } - if (count >= 6) { /* Full packet received */ - if (!inSync) { - inSync = 1; - printf("Synaptics driver resynced.\n"); - } - count = 0; - switch (outputformat) { - case 1: printf("Paket:%02X-%02X-%02X-%02X-%02X-%02X\n", - pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5]); - break; - case 2: printf("x = %i, y = %i, z = %i, w = %i, l = %i, r = %i\n", - ((pBuf[3] & 0x10) << 8) | ((pBuf[1] & 0x0f) << 8) | pBuf[4], - ((pBuf[3] & 0x20) << 7) | ((pBuf[1] & 0xf0) << 4) | pBuf[5], - ((pBuf[0] & 0x30) >> 2) | ((pBuf[0] & 0x04) >> 1) | ((pBuf[3] & 0x04) >> 2), - ((pBuf[0] & 0x30) >> 2) | ((pBuf[0] & 0x04) >> 1) | ((pBuf[3] & 0x04) >> 2), - (pBuf[0] & 0x01) ? 1 : 0, - (pBuf[0] & 0x2) ? 1 : 0); - break; - default: break; - } - } + if (count >= 6) { /* Full packet received */ + if (!inSync) { + inSync = 1; + printf("Synaptics driver resynced.\n"); + } + count = 0; + switch (outputformat) { + case 1: + printf("Paket:%02X-%02X-%02X-%02X-%02X-%02X\n", + pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5]); + break; + case 2: + printf("x = %i, y = %i, z = %i, w = %i, l = %i, r = %i\n", + ((pBuf[3] & 0x10) << 8) | ((pBuf[1] & 0x0f) << 8) | pBuf[4], + ((pBuf[3] & 0x20) << 7) | ((pBuf[1] & 0xf0) << 4) | pBuf[5], + ((pBuf[0] & 0x30) >> 2) | ((pBuf[0] & 0x04) >> 1) | ((pBuf[3] & 0x04) >> 2), + ((pBuf[0] & 0x30) >> 2) | ((pBuf[0] & 0x04) >> 1) | ((pBuf[3] & 0x04) >> 2), + (pBuf[0] & 0x01) ? 1 : 0, + (pBuf[0] & 0x2) ? 1 : 0); + break; + default: + break; + } } + } } int main(int argc, char* argv[]) { - int fd; + int fd; - if (argc > 1) - outputformat = atoi(argv[1]); + if (argc > 1) + outputformat = atoi(argv[1]); - fd=open("/dev/psaux", O_RDONLY); - if (fd == -1) { - printf("Error opening /dev/psaux\n"); - exit(1); - } + fd = open("/dev/psaux", O_RDONLY); + if (fd == -1) { + printf("Error opening /dev/psaux\n"); + exit(1); + } - SynapticsReadPacket(fd); + SynapticsReadPacket(fd); - close(fd); + close(fd); - exit(0); + exit(0); } |