Cosmetic changes.

This commit is contained in:
Peter Osterlund
2005-01-06 00:08:10 +01:00
parent ad7c167063
commit 996d47af57
5 changed files with 167 additions and 145 deletions

View File

@@ -209,7 +209,8 @@ SetDeviceAndProtocol(LocalDevicePtr local)
* The function will allocate shared memory if priv->shm_config is TRUE.
* The allocated data is initialized from priv->synpara_default.
*/
static Bool alloc_param_data(LocalDevicePtr local)
static Bool
alloc_param_data(LocalDevicePtr local)
{
int shmid;
SynapticsPrivate *priv = local->private;
@@ -242,7 +243,8 @@ static Bool alloc_param_data(LocalDevicePtr local)
/*
* Free SynapticsSHM data previously allocated by alloc_param_data().
*/
static void free_param_data(SynapticsPrivate *priv)
static void
free_param_data(SynapticsPrivate *priv)
{
int shmid;
@@ -621,8 +623,9 @@ move_distance(int dx, int dy)
* -1 corresponds to the left/upper edge and +1 corresponds to the
* right/lower edge.
*/
static void relative_coords(SynapticsPrivate *priv, int x, int y,
double *relX, double *relY)
static void
relative_coords(SynapticsPrivate *priv, int x, int y,
double *relX, double *relY)
{
int minX = priv->synpara->left_edge;
int maxX = priv->synpara->right_edge;
@@ -741,7 +744,8 @@ timerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
return 0;
}
static int clamp(int val, int min, int max)
static int
clamp(int val, int min, int max)
{
if (val < min)
return min;
@@ -1130,7 +1134,8 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
#define HIST(a) (priv->move_hist[((priv->hist_index - (a) + SYNAPTICS_MOVE_HISTORY) % SYNAPTICS_MOVE_HISTORY)])
static void store_history(SynapticsPrivate *priv, int x, int y, unsigned int millis)
static void
store_history(SynapticsPrivate *priv, int x, int y, unsigned int millis)
{
int idx = (priv->hist_index + 1) % SYNAPTICS_MOVE_HISTORY;
priv->move_hist[idx].x = x;
@@ -1144,13 +1149,15 @@ static void store_history(SynapticsPrivate *priv, int x, int y, unsigned int mil
* linear regression to fit a line to the data and use the slope of the
* line.
*/
static double estimate_delta(double x0, double x1, double x2, double x3)
static double
estimate_delta(double x0, double x1, double x2, double x3)
{
return x0 * 0.3 + x1 * 0.1 - x2 * 0.1 - x3 * 0.3;
}
static long ComputeDeltas(SynapticsPrivate *priv, struct SynapticsHwState *hw,
edge_type edge, int *dxP, int *dyP)
static long
ComputeDeltas(SynapticsPrivate *priv, struct SynapticsHwState *hw,
edge_type edge, int *dxP, int *dyP)
{
SynapticsSHM *para = priv->synpara;
Bool moving_state;

View File

@@ -31,22 +31,6 @@
#include <X11/Xdefs.h>
#include "synaptics.h"
static void show_hw_info(SynapticsSHM* synshm)
{
printf("Hardware properties:\n");
if (synshm->synhw.model_id) {
printf(" Model Id = %08x\n", synshm->synhw.model_id);
printf(" Capabilities = %08x\n", synshm->synhw.capabilities);
printf(" Identity = %08x\n", synshm->synhw.identity);
} else {
printf(" No touchpad found\n");
printf(" Do you use a newer kernel than 2.4?\n");
printf(" Then browse the messages or boot.msg for the hardware info\n");
}
}
/* ---------------------------------------------------------------------- */
enum ParaType {
PT_INT,
PT_BOOL,
@@ -54,7 +38,7 @@ enum ParaType {
};
struct Parameter {
char* name; /* Name of parameter */
char *name; /* Name of parameter */
int offset; /* Offset in shared memory area */
enum ParaType type; /* Type of parameter */
double min_val; /* Minimum allowed value */
@@ -108,7 +92,23 @@ static struct Parameter params[] = {
{ 0, 0, 0, 0, 0 }
};
static void show_settings(SynapticsSHM* synshm)
static void
show_hw_info(SynapticsSHM *synshm)
{
printf("Hardware properties:\n");
if (synshm->synhw.model_id) {
printf(" Model Id = %08x\n", synshm->synhw.model_id);
printf(" Capabilities = %08x\n", synshm->synhw.capabilities);
printf(" Identity = %08x\n", synshm->synhw.identity);
} else {
printf(" No touchpad found\n");
printf(" Do you use a newer kernel than 2.4?\n");
printf(" Then browse the messages or boot.msg for the hardware info\n");
}
}
static void
show_settings(SynapticsSHM *synshm)
{
int i;
@@ -129,12 +129,13 @@ static void show_settings(SynapticsSHM* synshm)
}
}
static void set_variables(SynapticsSHM* synshm, int argc, char* argv[], int first_cmd)
static void
set_variables(SynapticsSHM *synshm, int argc, char *argv[], int first_cmd)
{
int i;
for (i = first_cmd; i < argc; i++) {
char* cmd = argv[i];
char* eqp = index(cmd, '=');
char *cmd = argv[i];
char *eqp = index(cmd, '=');
if (eqp) {
int j;
int found = 0;
@@ -174,7 +175,8 @@ static void set_variables(SynapticsSHM* synshm, int argc, char* argv[], int firs
}
}
static int is_equal(SynapticsSHM* s1, SynapticsSHM* s2)
static int
is_equal(SynapticsSHM *s1, SynapticsSHM *s2)
{
int i;
@@ -202,14 +204,16 @@ static int is_equal(SynapticsSHM* s1, SynapticsSHM* s2)
return 1;
}
static double get_time()
static double
get_time()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
static void monitor(SynapticsSHM* synshm, int delay)
static void
monitor(SynapticsSHM *synshm, int delay)
{
int header = 0;
SynapticsSHM old;
@@ -245,7 +249,8 @@ static void monitor(SynapticsSHM* synshm, int delay)
}
}
static void usage()
static void
usage()
{
fprintf(stderr, "Usage: synclient [-m interval] [-h] [-l] [-V] [-?] [var1=value1 [var2=value2] ...]\n");
fprintf(stderr, " -m monitor changes to the touchpad state.\n"
@@ -258,7 +263,8 @@ static void usage()
exit(1);
}
int main(int argc, char* argv[])
int
main(int argc, char *argv[])
{
SynapticsSHM *synshm;
int shmid;

View File

@@ -36,7 +36,8 @@ static int disable_taps_only;
static int background = 0;
static void usage()
static void
usage()
{
fprintf(stderr, "Usage: syndaemon [-i idle-time] [-d]\n");
fprintf(stderr, " -i How many seconds to wait after the last key press before\n");
@@ -46,7 +47,8 @@ static void usage()
exit(1);
}
static void signal_handler(int signum)
static void
signal_handler(int signum)
{
if (pad_disabled) {
synshm->touchpad_off = 0;
@@ -55,7 +57,8 @@ static void signal_handler(int signum)
kill(getpid(), signum);
}
static void install_signal_handler()
static void
install_signal_handler()
{
static int signals[] = {
SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
@@ -82,7 +85,8 @@ static void install_signal_handler()
/**
* Return non-zero if the keyboard state has changed since the last call.
*/
static int keyboard_activity(Display *display)
static int
keyboard_activity(Display *display)
{
#define KEYMAP_SIZE 32
static char old_key_state[KEYMAP_SIZE];
@@ -104,7 +108,8 @@ static int keyboard_activity(Display *display)
/**
* Return non-zero if any physical touchpad button is currently pressed.
*/
static int touchpad_buttons_active()
static int
touchpad_buttons_active()
{
int i;
@@ -118,14 +123,16 @@ static int touchpad_buttons_active()
return 0;
}
static double get_time()
static double
get_time()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
static void main_loop(Display *display, double idle_time)
static void
main_loop(Display *display, double idle_time)
{
const int poll_delay = 20000; /* 20 ms */
double last_activity = 0.0;
@@ -164,7 +171,8 @@ static void main_loop(Display *display, double idle_time)
}
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
double idle_time = 2.0;
Display *display;

View File

@@ -6,116 +6,116 @@
#include <string.h>
#include <errno.h>
int getbyte(int fd, unsigned char *b)
int
getbyte(int fd, unsigned char *b)
{
return(read(fd, b, 1) == 1);
return(read(fd, b, 1) == 1);
}
int putbyte(int fd, unsigned char b)
int
putbyte(int fd, unsigned char b)
{
unsigned char ack;
unsigned char ack;
printf("write %02X\n", b);
if(write(fd, &b, 1) != 1)
{
fprintf(stderr, "error write: %s\n", strerror(errno));
return 0;
}
if(!getbyte(fd, &ack))
{
fprintf(stderr, "error read: %s\n", strerror(errno));
return 0;
}
printf("read %02X\n", ack);
if(ack != 0xFA)
{
fprintf(stderr, "error ack\n");
return 0;
}
return 1;
}
int special_cmd(int fd, unsigned char cmd)
{
int i;
if(putbyte(fd, 0xE6))
for(i=0; i<4; i++)
{
printf("special_cmd %i\n", i);
if((!putbyte(fd, 0xE8)) || (!putbyte(fd, (cmd>>6)&0x3)))
return 0;
cmd<<=2;
}
else
return 0;
return 1;
}
int send_cmd(int fd, unsigned char cmd)
{
return(special_cmd(fd, cmd) && putbyte(fd, 0xE9));
}
int identify(int fd, unsigned long int *ident)
{
unsigned char id[3];
if(send_cmd(fd, 0x00) && getbyte(fd, &id[0]) && getbyte(fd, &id[1]) && getbyte(fd, &id[2]))
{
*ident = (id[0]<<16)|(id[1]<<8)|id[2];
printf("ident %06X\n", *ident);
return 1;
} else {
fprintf(stderr, "error identify\n");
return 0;
}
}
int reset(int fd)
{
unsigned char r[2];
if(!putbyte(fd, 0xFF))
{
fprintf(stderr, "error reset\n");
return 0;
}
sleep(5);
if(getbyte(fd, &r[0]) && getbyte(fd, &r[1]))
if(r[0] == 0xAA && r[1] == 0x00)
{
fprintf(stderr, "reset done\n");
return 1;
}
fprintf(stderr, "error reset ack\n");
printf("write %02X\n", b);
if (write(fd, &b, 1) != 1) {
fprintf(stderr, "error write: %s\n", strerror(errno));
return 0;
}
if (!getbyte(fd, &ack)) {
fprintf(stderr, "error read: %s\n", strerror(errno));
return 0;
}
printf("read %02X\n", ack);
if (ack != 0xFA) {
fprintf(stderr, "error ack\n");
return 0;
}
return 1;
}
int main(int argc, char* argv[])
int
special_cmd(int fd, unsigned char cmd)
{
int fd;
unsigned long int ident;
int i;
fd = open("/dev/psaux", O_RDWR);
if(fd == -1)
{
fprintf(stderr, "error open: %s\n", strerror(errno));
exit(0);
if (putbyte(fd, 0xE6))
for (i = 0; i < 4; i++) {
printf("special_cmd %i\n", i);
if ((!putbyte(fd, 0xE8)) || (!putbyte(fd, (cmd>>6)&0x3)))
return 0;
cmd<<=2;
}
reset(fd);
identify(fd, &ident);
close(fd);
exit(0);
else
return 0;
return 1;
}
int
send_cmd(int fd, unsigned char cmd)
{
return (special_cmd(fd, cmd) &&
putbyte(fd, 0xE9));
}
int
identify(int fd, unsigned long int *ident)
{
unsigned char id[3];
if (send_cmd(fd, 0x00) &&
getbyte(fd, &id[0]) &&
getbyte(fd, &id[1]) &&
getbyte(fd, &id[2])) {
*ident = (id[0]<<16)|(id[1]<<8)|id[2];
printf("ident %06X\n", *ident);
return 1;
} else {
fprintf(stderr, "error identify\n");
return 0;
}
}
int
reset(int fd)
{
unsigned char r[2];
if (!putbyte(fd, 0xFF)) {
fprintf(stderr, "error reset\n");
return 0;
}
sleep(5);
if (getbyte(fd, &r[0]) && getbyte(fd, &r[1]))
if (r[0] == 0xAA && r[1] == 0x00) {
fprintf(stderr, "reset done\n");
return 1;
}
fprintf(stderr, "error reset ack\n");
return 0;
}
int
main(int argc, char* argv[])
{
int fd;
unsigned long int ident;
fd = open("/dev/psaux", O_RDWR);
if (fd == -1) {
fprintf(stderr, "error open: %s\n", strerror(errno));
exit(0);
}
reset(fd);
identify(fd, &ident);
close(fd);
exit(0);
}

View File

@@ -59,7 +59,8 @@ SynapticsReadPacket(int fd)
}
}
int main(int argc, char* argv[])
int
main(int argc, char* argv[])
{
int fd;