Commit 0434d777 authored by Peter Hutterer's avatar Peter Hutterer

Indent consistently

x-indent-all.sh from xorg/util/modular as of
c2d630fab65dbe3409af3947f6f442782ddb026f
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarChase Douglas <chase.douglas@canonical.com>
parent a1162f80
......@@ -164,4 +164,4 @@
/* 32 Bit Integer, 2 values, horizontal hysteresis, vertical hysteresis */
#define SYNAPTICS_PROP_NOISE_CANCELLATION "Synaptics Noise Cancellation"
#endif /* _SYNAPTICS_PROPERTIES_H_ */
#endif /* _SYNAPTICS_PROPERTIES_H_ */
......@@ -29,36 +29,35 @@
* Used by driver and the shared memory configurator
*****************************************************************************/
typedef enum {
RT_TAP = 0, /* Right top corner */
RB_TAP, /* Right bottom corner */
LT_TAP, /* Left top corner */
LB_TAP, /* Left bottom corner */
F1_TAP, /* Non-corner tap, one finger */
F2_TAP, /* Non-corner tap, two fingers */
F3_TAP, /* Non-corner tap, three fingers */
RT_TAP = 0, /* Right top corner */
RB_TAP, /* Right bottom corner */
LT_TAP, /* Left top corner */
LB_TAP, /* Left bottom corner */
F1_TAP, /* Non-corner tap, one finger */
F2_TAP, /* Non-corner tap, two fingers */
F3_TAP, /* Non-corner tap, three fingers */
MAX_TAP
} TapEvent;
typedef enum {
F1_CLICK1 = 0, /* Click left, one finger */
F2_CLICK1, /* Click left, two fingers */
F3_CLICK1, /* Click left, three fingers */
F1_CLICK1 = 0, /* Click left, one finger */
F2_CLICK1, /* Click left, two fingers */
F3_CLICK1, /* Click left, three fingers */
MAX_CLICK
} ClickFingerEvent;
#define SYN_MAX_BUTTONS 12 /* Max number of mouse buttons */
#define SYN_MAX_BUTTONS 12 /* Max number of mouse buttons */
#define SHM_SYNAPTICS 23947
typedef struct _SynapticsSHM
{
int version; /* Driver version */
typedef struct _SynapticsSHM {
int version; /* Driver version */
/* Current device state */
int x, y; /* actual x, y coordinates */
int z; /* pressure value */
int numFingers; /* number of fingers */
int fingerWidth; /* finger width value */
int left, right, up, down; /* left/right/up/down buttons */
int x, y; /* actual x, y coordinates */
int z; /* pressure value */
int numFingers; /* number of fingers */
int fingerWidth; /* finger width value */
int left, right, up, down; /* left/right/up/down buttons */
Bool multi[8];
Bool middle;
} SynapticsSHM;
......@@ -69,4 +68,4 @@ typedef struct _SynapticsSHM
#define SBR_MIN 10
#define SBR_MAX 1000
#endif /* _SYNAPTICS_H_ */
#endif /* _SYNAPTICS_H_ */
......@@ -39,14 +39,14 @@
#include "ps2comm.h"
#include <xf86.h>
/* Wait for the channel to go silent, which means we're in sync */
static void
ALPS_sync(int fd)
{
byte buffer[64];
while (xf86WaitForInput(fd, 250000) > 0) {
xf86ReadSerial(fd, &buffer, 64);
xf86ReadSerial(fd, &buffer, 64);
}
}
......@@ -98,7 +98,7 @@ ALPS_packet_ok(struct CommData *comm)
{
/* ALPS absolute mode packets start with 0b11111mrl */
if ((comm->protoBuf[0] & 0xf8) == 0xf8)
return TRUE;
return TRUE;
return FALSE;
}
......@@ -108,24 +108,23 @@ ALPS_get_packet(struct CommData *comm, InputInfoPtr pInfo)
int c;
while ((c = XisbRead(comm->buffer)) >= 0) {
unsigned char u = (unsigned char)c;
comm->protoBuf[comm->protoBufTail++] = u;
if (comm->protoBufTail == 3) { /* PS/2 packet received? */
if ((comm->protoBuf[0] & 0xc8) == 0x08) {
comm->protoBufTail = 0;
return TRUE;
}
}
if (comm->protoBufTail >= 6) { /* Full packet received */
comm->protoBufTail = 0;
if (ALPS_packet_ok(comm))
return TRUE;
while ((c = XisbRead(comm->buffer)) >= 0)
; /* If packet is invalid, re-sync */
}
unsigned char u = (unsigned char) c;
comm->protoBuf[comm->protoBufTail++] = u;
if (comm->protoBufTail == 3) { /* PS/2 packet received? */
if ((comm->protoBuf[0] & 0xc8) == 0x08) {
comm->protoBufTail = 0;
return TRUE;
}
}
if (comm->protoBufTail >= 6) { /* Full packet received */
comm->protoBufTail = 0;
if (ALPS_packet_ok(comm))
return TRUE;
while ((c = XisbRead(comm->buffer)) >= 0); /* If packet is invalid, re-sync */
}
}
return FALSE;
......@@ -157,48 +156,50 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw)
hw->millis = GetTimeInMillis();
x = (packet[1] & 0x7f) | ((packet[2] & 0x78) << (7-3));
y = (packet[4] & 0x7f) | ((packet[3] & 0x70) << (7-4));
x = (packet[1] & 0x7f) | ((packet[2] & 0x78) << (7 - 3));
y = (packet[4] & 0x7f) | ((packet[3] & 0x70) << (7 - 4));
z = packet[5];
if (z == 127) { /* DualPoint stick is relative, not absolute */
hw->left = packet[3] & 1;
hw->right = (packet[3] >> 1) & 1;
return;
if (z == 127) { /* DualPoint stick is relative, not absolute */
hw->left = packet[3] & 1;
hw->right = (packet[3] >> 1) & 1;
return;
}
/* Handle normal packets */
hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = 0;
hw->left = hw->right = hw->up = hw->down = hw->middle = FALSE;
for (i = 0; i < 8; i++)
hw->multi[i] = FALSE;
hw->multi[i] = FALSE;
if (z > 0) {
hw->x = x;
hw->y = y;
hw->x = x;
hw->y = y;
}
hw->z = z;
hw->numFingers = (z > 0) ? 1 : 0;
hw->fingerWidth = 5;
left |= (packet[2] ) & 1;
left |= (packet[3] ) & 1;
left |= (packet[2]) & 1;
left |= (packet[3]) & 1;
right |= (packet[3] >> 1) & 1;
if (packet[0] == 0xff) {
int back = (packet[3] >> 2) & 1;
int forward = (packet[2] >> 2) & 1;
if (back && forward) {
middle = 1;
back = 0;
forward = 0;
}
hw->down = back;
hw->up = forward;
} else {
left |= (packet[0] ) & 1;
right |= (packet[0] >> 1) & 1;
middle |= (packet[0] >> 2) & 1;
middle |= (packet[3] >> 2) & 1;
int back = (packet[3] >> 2) & 1;
int forward = (packet[2] >> 2) & 1;
if (back && forward) {
middle = 1;
back = 0;
forward = 0;
}
hw->down = back;
hw->up = forward;
}
else {
left |= (packet[0]) & 1;
right |= (packet[0] >> 1) & 1;
middle |= (packet[0] >> 2) & 1;
middle |= (packet[3] >> 2) & 1;
}
hw->left = left;
......@@ -208,13 +209,13 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw)
static Bool
ALPSReadHwState(InputInfoPtr pInfo,
struct CommData *comm, struct SynapticsHwState *hwRet)
struct CommData *comm, struct SynapticsHwState *hwRet)
{
unsigned char *buf = comm->protoBuf;
struct SynapticsHwState *hw = comm->hwState;
if (!ALPS_get_packet(comm, pInfo))
return FALSE;
return FALSE;
ALPS_process_packet(buf, hw);
......
This diff is collapsed.
......@@ -38,11 +38,11 @@
struct eventcomm_proto_data;
extern struct eventcomm_proto_data *
EventProtoDataAlloc(void);
extern struct eventcomm_proto_data *EventProtoDataAlloc(void);
extern Bool
EventReadHwState(InputInfoPtr pInfo,
struct CommData *comm, struct SynapticsHwState *hwRet);
struct CommData *comm, struct SynapticsHwState *hwRet);
#endif /* _EVENTCOMM_H_ */
#endif /* _EVENTCOMM_H_ */
This diff is collapsed.
This diff is collapsed.
......@@ -95,16 +95,17 @@
typedef unsigned char byte;
struct PS2SynapticsHwInfo {
unsigned int model_id; /* Model-ID */
unsigned int capabilities; /* Capabilities */
unsigned int ext_cap; /* Extended Capabilities */
unsigned int identity; /* Identification */
unsigned int model_id; /* Model-ID */
unsigned int capabilities; /* Capabilities */
unsigned int ext_cap; /* Extended Capabilities */
unsigned int identity; /* Identification */
};
Bool ps2_putbyte(int fd, byte b);
void ps2_print_ident(InputInfoPtr pInfo, const struct PS2SynapticsHwInfo *synhw);
void ps2_print_ident(InputInfoPtr pInfo,
const struct PS2SynapticsHwInfo *synhw);
Bool PS2ReadHwStateProto(InputInfoPtr pInfo,
struct SynapticsProtocolOperations *proto_ops,
struct CommData *comm, struct SynapticsHwState *hwRet);
struct SynapticsProtocolOperations *proto_ops,
struct CommData *comm, struct SynapticsHwState *hwRet);
#endif /* _PS2COMM_H_ */
#endif /* _PS2COMM_H_ */
......@@ -47,7 +47,7 @@
#include "synproto.h"
#include "synaptics.h"
#include "synapticsstr.h"
#include "ps2comm.h" /* ps2_print_ident() */
#include "ps2comm.h" /* ps2_print_ident() */
#include <xf86.h>
#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
......@@ -57,15 +57,15 @@
* See also the SYN_ID_* macros
*/
static Bool
psm_synaptics_identify(int fd, synapticshw_t *ident)
psm_synaptics_identify(int fd, synapticshw_t * ident)
{
int ret;
SYSCALL(ret = ioctl(fd, MOUSE_SYN_GETHWINFO, ident));
if (ret == 0)
return TRUE;
return TRUE;
else
return FALSE;
return FALSE;
}
/* This define is used in a ioctl but not in mouse.h :/ */
......@@ -84,46 +84,49 @@ PSMQueryIsSynaptics(InputInfoPtr pInfo)
*/
SYSCALL(ret = ioctl(pInfo->fd, MOUSE_SETLEVEL, &level));
if (ret != 0) {
xf86IDrvMsg(pInfo, X_ERROR, "%s Can't set native mode\n", pInfo->name);
return FALSE;
xf86IDrvMsg(pInfo, X_ERROR, "%s Can't set native mode\n", pInfo->name);
return FALSE;
}
SYSCALL(ret = ioctl(pInfo->fd, MOUSE_GETHWINFO, &mhw));
if (ret != 0) {
xf86IDrvMsg(pInfo, X_ERROR, "%s Can't get hardware info\n", pInfo->name);
return FALSE;
xf86IDrvMsg(pInfo, X_ERROR, "%s Can't get hardware info\n",
pInfo->name);
return FALSE;
}
if (mhw.model == MOUSE_MODEL_SYNAPTICS) {
return TRUE;
} else {
xf86IDrvMsg(pInfo, X_ERROR, "%s Found no Synaptics, found Mouse model %d instead\n",
pInfo->name, mhw.model);
return FALSE;
return TRUE;
}
else {
xf86IDrvMsg(pInfo, X_ERROR,
"%s Found no Synaptics, found Mouse model %d instead\n",
pInfo->name, mhw.model);
return FALSE;
}
}
static void
convert_hw_info(const synapticshw_t *psm_ident, struct PS2SynapticsHwInfo *synhw)
convert_hw_info(const synapticshw_t * psm_ident,
struct PS2SynapticsHwInfo *synhw)
{
memset(synhw, 0, sizeof(*synhw));
synhw->model_id = ((psm_ident->infoRot180 << 23) |
(psm_ident->infoPortrait << 22) |
(psm_ident->infoSensor << 16) |
(psm_ident->infoHardware << 9) |
(psm_ident->infoNewAbs << 7) |
(psm_ident->capPen << 6) |
(psm_ident->infoSimplC << 5) |
(psm_ident->infoGeometry));
(psm_ident->infoPortrait << 22) |
(psm_ident->infoSensor << 16) |
(psm_ident->infoHardware << 9) |
(psm_ident->infoNewAbs << 7) |
(psm_ident->capPen << 6) |
(psm_ident->infoSimplC << 5) |
(psm_ident->infoGeometry));
synhw->capabilities = ((psm_ident->capExtended << 23) |
(psm_ident->capPassthrough << 7) |
(psm_ident->capSleep << 4) |
(psm_ident->capFourButtons << 3) |
(psm_ident->capMultiFinger << 1) |
(psm_ident->capPalmDetect));
(psm_ident->capPassthrough << 7) |
(psm_ident->capSleep << 4) |
(psm_ident->capFourButtons << 3) |
(psm_ident->capMultiFinger << 1) |
(psm_ident->capPalmDetect));
synhw->ext_cap = 0;
synhw->identity = ((psm_ident->infoMajor) |
(0x47 << 8) |
(psm_ident->infoMinor << 16));
(0x47 << 8) | (psm_ident->infoMinor << 16));
}
static Bool
......@@ -133,20 +136,20 @@ PSMQueryHardware(InputInfoPtr pInfo)
struct PS2SynapticsHwInfo *synhw;
SynapticsPrivate *priv;
priv = (SynapticsPrivate *)pInfo->private;
priv = (SynapticsPrivate *) pInfo->private;
if(!priv->proto_data)
if (!priv->proto_data)
priv->proto_data = calloc(1, sizeof(struct PS2SynapticsHwInfo));
synhw = (struct PS2SynapticsHwInfo*)priv->proto_data;
synhw = (struct PS2SynapticsHwInfo *) priv->proto_data;
/* is the synaptics touchpad active? */
if (!PSMQueryIsSynaptics(pInfo))
return FALSE;
return FALSE;
xf86IDrvMsg(pInfo, X_PROBED, "synaptics touchpad found\n");
if (!psm_synaptics_identify(pInfo->fd, &psm_ident))
return FALSE;
return FALSE;
convert_hw_info(&psm_ident, synhw);
......@@ -157,7 +160,7 @@ PSMQueryHardware(InputInfoPtr pInfo)
static Bool
PSMReadHwState(InputInfoPtr pInfo,
struct CommData *comm, struct SynapticsHwState *hwRet)
struct CommData *comm, struct SynapticsHwState *hwRet)
{
return PS2ReadHwStateProto(pInfo, &psm_proto_operations, comm, hwRet);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -21,14 +21,13 @@
* DEALINGS IN THE SOFTWARE.
*/
#include "synproto.h"
#include "synaptics.h"
#include "synapticsstr.h"
#ifdef HAVE_MULTITOUCH
static int
HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv)
HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate * priv)
{
int num_vals;
int i = 0;
......@@ -38,12 +37,11 @@ HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv)
if (!hw->mt_mask)
goto fail;
num_vals = 2; /* x and y */
num_vals += 2; /* scroll axes */
num_vals = 2; /* x and y */
num_vals += 2; /* scroll axes */
num_vals += priv->num_mt_axes;
for (; i < hw->num_mt_mask; i++)
{
for (; i < hw->num_mt_mask; i++) {
hw->mt_mask[i] = valuator_mask_new(num_vals);
if (!hw->mt_mask[i])
goto fail;
......@@ -55,7 +53,7 @@ HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv)
return Success;
fail:
fail:
for (i--; i >= 0; i--)
valuator_mask_free(&hw->mt_mask[i]);
free(hw->mt_mask);
......@@ -65,7 +63,7 @@ fail:
#endif
struct SynapticsHwState *
SynapticsHwStateAlloc(SynapticsPrivate *priv)
SynapticsHwStateAlloc(SynapticsPrivate * priv)
{
struct SynapticsHwState *hw;
......@@ -74,8 +72,7 @@ SynapticsHwStateAlloc(SynapticsPrivate *priv)
return NULL;
#ifdef HAVE_MULTITOUCH
if (HwStateAllocTouch(hw, priv) != Success)
{
if (HwStateAllocTouch(hw, priv) != Success) {
free(hw);
return NULL;
}
......@@ -162,25 +159,24 @@ SynapticsResetTouchHwState(struct SynapticsHwState *hw, Bool set_slot_empty)
#ifdef HAVE_MULTITOUCH
int i;
for (i = 0; i < hw->num_mt_mask; i++)
{
for (i = 0; i < hw->num_mt_mask; i++) {
int j;
/* Leave x and y valuators in case we need to restart touch */
for (j = 2; j < valuator_mask_num_valuators(hw->mt_mask[i]); j++)
valuator_mask_unset(hw->mt_mask[i], j);
switch (hw->slot_state[i])
{
case SLOTSTATE_OPEN:
case SLOTSTATE_OPEN_EMPTY:
case SLOTSTATE_UPDATE:
hw->slot_state[i] = set_slot_empty ? SLOTSTATE_EMPTY : SLOTSTATE_OPEN_EMPTY;
break;
default:
hw->slot_state[i] = SLOTSTATE_EMPTY;
break;
switch (hw->slot_state[i]) {
case SLOTSTATE_OPEN:
case SLOTSTATE_OPEN_EMPTY:
case SLOTSTATE_UPDATE:
hw->slot_state[i] =
set_slot_empty ? SLOTSTATE_EMPTY : SLOTSTATE_OPEN_EMPTY;
break;
default:
hw->slot_state[i] = SLOTSTATE_EMPTY;
break;
}
}
#endif
......
......@@ -37,8 +37,7 @@
struct _SynapticsPrivateRec;
typedef struct _SynapticsPrivateRec SynapticsPrivate;
enum SynapticsSlotState
{
enum SynapticsSlotState {
SLOTSTATE_EMPTY = 0,
SLOTSTATE_OPEN,
SLOTSTATE_CLOSE,
......@@ -53,12 +52,12 @@ enum SynapticsSlotState
* A structure to describe the state of the touchpad hardware (buttons and pad)
*/
struct SynapticsHwState {
CARD32 millis; /* Timestamp in milliseconds */
int x; /* X position of finger */
int y; /* Y position of finger */
int z; /* Finger pressure */
int cumulative_dx; /* Cumulative delta X for clickpad dragging */
int cumulative_dy; /* Cumulative delta Y for clickpad dragging */
CARD32 millis; /* Timestamp in milliseconds */
int x; /* X position of finger */
int y; /* Y position of finger */
int z; /* Finger pressure */
int cumulative_dx; /* Cumulative delta X for clickpad dragging */
int cumulative_dy; /* Cumulative delta Y for clickpad dragging */
int numFingers;
int fingerWidth;
......@@ -68,7 +67,7 @@ struct SynapticsHwState {
Bool down;
Bool multi[8];
Bool middle; /* Some ALPS touchpads have a middle button */
Bool middle; /* Some ALPS touchpads have a middle button */
#ifdef HAVE_MULTITOUCH
int num_mt_mask;
......@@ -79,10 +78,10 @@ struct SynapticsHwState {
struct CommData {
XISBuffer *buffer;
unsigned char protoBuf[6]; /* Buffer for Packet */
unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */
int outOfSync; /* How many consecutive incorrect packets we
have received */
unsigned char protoBuf[6]; /* Buffer for Packet */
unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */
int outOfSync; /* How many consecutive incorrect packets we
have received */
int protoBufTail;
/* Used for keeping track of partial HwState updates. */
......@@ -95,33 +94,36 @@ struct CommData {
struct _SynapticsParameters;
struct SynapticsProtocolOperations {
Bool (*DeviceOnHook)(InputInfoPtr pInfo, struct _SynapticsParameters *para);
Bool (*DeviceOffHook)(InputInfoPtr pInfo);
Bool (*QueryHardware)(InputInfoPtr pInfo);
Bool (*ReadHwState)(InputInfoPtr pInfo,
struct CommData *comm, struct SynapticsHwState *hwRet);
Bool (*AutoDevProbe)(InputInfoPtr pInfo, const char *device);
void (*ReadDevDimensions)(InputInfoPtr pInfo);
Bool (*DeviceOnHook) (InputInfoPtr pInfo,
struct _SynapticsParameters * para);
Bool (*DeviceOffHook) (InputInfoPtr pInfo);
Bool (*QueryHardware) (InputInfoPtr pInfo);
Bool (*ReadHwState) (InputInfoPtr pInfo,
struct CommData * comm,
struct SynapticsHwState * hwRet);
Bool (*AutoDevProbe) (InputInfoPtr pInfo, const char *device);
void (*ReadDevDimensions) (InputInfoPtr pInfo);
};
#ifdef BUILD_PS2COMM
extern struct SynapticsProtocolOperations psaux_proto_operations;
extern struct SynapticsProtocolOperations alps_proto_operations;
#endif /* BUILD_PS2COMM */
#endif /* BUILD_PS2COMM */
#ifdef BUILD_EVENTCOMM
extern struct SynapticsProtocolOperations event_proto_operations;
#endif /* BUILD_EVENTCOMM */
#endif /* BUILD_EVENTCOMM */
#ifdef BUILD_PSMCOMM
extern struct SynapticsProtocolOperations psm_proto_operations;
#endif /* BUILD_PSMCOMM */
#endif /* BUILD_PSMCOMM */
extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate *priv);
extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate * priv);
extern void SynapticsHwStateFree(struct SynapticsHwState **hw);
extern void SynapticsCopyHwState(struct SynapticsHwState *dst,
const struct SynapticsHwState *src);
extern void SynapticsResetHwState(struct SynapticsHwState *hw);
extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw, Bool force_empty);
extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw,
Bool force_empty);
extern Bool SynapticsIsSoftButtonAreasValid(int *values);
#endif /* _SYNPROTO_H_ */
#endif /* _SYNPROTO_H_ */
......@@ -55,7 +55,7 @@ create_pipe_fd(void)
static void
reset_data(struct SynapticsHwState **hw, struct CommData *comm,
SynapticsPrivate *priv)