diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-05-21 11:56:48 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-05-31 14:56:47 +1000 |
commit | bbf82ff5c9685ced637778de93fe119935b604e5 (patch) | |
tree | aa4b9f384eacbf910d987982090a5382a9d68f1d | |
parent | a844197d18ea9f3849974d5e8bb4cf235fde3cf7 (diff) |
Pass the fd down into ReadInput
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/alpscomm.c | 2 | ||||
-rw-r--r-- | src/eventcomm.c | 10 | ||||
-rw-r--r-- | src/eventcomm.h | 2 | ||||
-rw-r--r-- | src/ps2comm.c | 17 | ||||
-rw-r--r-- | src/ps2comm.h | 2 | ||||
-rw-r--r-- | src/synaptics-x11.c | 2 | ||||
-rw-r--r-- | src/synaptics.c | 8 | ||||
-rw-r--r-- | src/synaptics.h | 2 | ||||
-rw-r--r-- | src/synproto.h | 1 | ||||
-rw-r--r-- | test/eventcomm-test.c | 28 |
10 files changed, 38 insertions, 36 deletions
diff --git a/src/alpscomm.c b/src/alpscomm.c index 9a9b18d..52d74e7 100644 --- a/src/alpscomm.c +++ b/src/alpscomm.c @@ -210,7 +210,7 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw) } static Bool -ALPSReadHwState(SynapticsPrivate *priv, +ALPSReadHwState(SynapticsPrivate *priv, int fd, struct CommData *comm, struct SynapticsHwState *hwRet) { struct SynapticsHwState *hw = comm->hwState; diff --git a/src/eventcomm.c b/src/eventcomm.c index 470f712..b1042ac 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -472,17 +472,17 @@ event_query_axis_ranges(SynapticsPrivate * priv, int fd) } static Bool -SynapticsReadEvent(SynapticsPrivate *priv, struct input_event *ev) +SynapticsReadEvent(SynapticsPrivate *priv, int fd, struct input_event *ev) { struct eventcomm_proto_data *proto_data = priv->proto_data; int rc = TRUE; ssize_t len; if (proto_data->mtdev) - len = mtdev_get(proto_data->mtdev, priv->fd, ev, 1) * + len = mtdev_get(proto_data->mtdev, fd, ev, 1) * sizeof(struct input_event); else - len = read(priv->fd, ev, sizeof(*ev)); + len = read(fd, ev, sizeof(*ev)); if (len <= 0) { /* We use X_NONE here because it doesn't alloc */ if (errno != EAGAIN) @@ -602,7 +602,7 @@ apply_st_scaling(struct eventcomm_proto_data *proto_data, int value, int axis) } Bool -EventReadHwState(SynapticsPrivate * priv, +EventReadHwState(SynapticsPrivate * priv, int fd, struct CommData *comm, struct SynapticsHwState *hwRet) { struct input_event ev; @@ -619,7 +619,7 @@ EventReadHwState(SynapticsPrivate * priv, hw->cumulative_dy = hw->y; } - while (SynapticsReadEvent(priv, &ev)) { + while (SynapticsReadEvent(priv, fd, &ev)) { switch (ev.type) { case EV_SYN: switch (ev.code) { diff --git a/src/eventcomm.h b/src/eventcomm.h index c8db0e8..ef234fe 100644 --- a/src/eventcomm.h +++ b/src/eventcomm.h @@ -40,7 +40,7 @@ struct eventcomm_proto_data; extern struct eventcomm_proto_data *EventProtoDataAlloc(void); extern Bool -EventReadHwState(SynapticsPrivate *priv, +EventReadHwState(SynapticsPrivate *priv, int fd, struct CommData *comm, struct SynapticsHwState *hwRet); #endif /* _EVENTCOMM_H_ */ diff --git a/src/ps2comm.c b/src/ps2comm.c index cb22414..887a012 100644 --- a/src/ps2comm.c +++ b/src/ps2comm.c @@ -458,7 +458,8 @@ ps2_packet_ok(struct PS2SynapticsHwInfo *synhw, struct PS2CommData *comm) } static Bool -ps2_synaptics_get_packet(SynapticsPrivate *priv, struct PS2SynapticsHwInfo *synhw, +ps2_synaptics_get_packet(SynapticsPrivate *priv, int fd, + struct PS2SynapticsHwInfo *synhw, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm) { @@ -472,9 +473,9 @@ ps2_synaptics_get_packet(SynapticsPrivate *priv, struct PS2SynapticsHwInfo *synh /* test if there is a reset sequence received */ if ((c == 0x00) && (ps2_comm_data->lastByte == 0xAA)) { - if (xf86WaitForInput(priv->fd, 50000) == 0) { + if (xf86WaitForInput(fd, 50000) == 0) { PS2DBG("Reset received\n"); - proto_ops->QueryHardware(priv, priv->fd); + proto_ops->QueryHardware(priv, fd); } else PS2DBG("faked reset received\n"); @@ -503,7 +504,7 @@ ps2_synaptics_get_packet(SynapticsPrivate *priv, struct PS2SynapticsHwInfo *synh if (ps2_comm_data->outOfSync > MAX_UNSYNC_PACKETS) { ps2_comm_data->outOfSync = 0; PS2DBG("Synaptics synchronization lost too long -> reset touchpad.\n"); - proto_ops->QueryHardware(priv, priv->fd); /* including a reset */ + proto_ops->QueryHardware(priv, fd); /* including a reset */ continue; } } @@ -523,7 +524,7 @@ ps2_synaptics_get_packet(SynapticsPrivate *priv, struct PS2SynapticsHwInfo *synh } Bool -PS2ReadHwStateProto(SynapticsPrivate *priv, +PS2ReadHwStateProto(SynapticsPrivate *priv, int fd, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet) { @@ -544,7 +545,7 @@ PS2ReadHwStateProto(SynapticsPrivate *priv, newabs = SYN_MODEL_NEWABS(synhw); - if (!ps2_synaptics_get_packet(priv, synhw, proto_ops, comm)) + if (!ps2_synaptics_get_packet(priv, fd, synhw, proto_ops, comm)) return FALSE; /* Handle normal packets */ @@ -656,10 +657,10 @@ PS2ReadHwStateProto(SynapticsPrivate *priv, } static Bool -PS2ReadHwState(SynapticsPrivate *priv, +PS2ReadHwState(SynapticsPrivate *priv, int fd, struct CommData *comm, struct SynapticsHwState *hwRet) { - return PS2ReadHwStateProto(priv, &psaux_proto_operations, comm, hwRet); + return PS2ReadHwStateProto(priv, fd, &psaux_proto_operations, comm, hwRet); } Bool diff --git a/src/ps2comm.h b/src/ps2comm.h index e0c1808..87f8696 100644 --- a/src/ps2comm.h +++ b/src/ps2comm.h @@ -114,7 +114,7 @@ struct PS2CommData { int ps2_putbyte(int fd, byte b); void ps2_print_ident(SynapticsPrivate *priv, const struct PS2SynapticsHwInfo *synhw); -Bool PS2ReadHwStateProto(SynapticsPrivate *priv, +Bool PS2ReadHwStateProto(SynapticsPrivate *priv, int fd, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet); Bool PS2ProtoDataInit(SynapticsPrivate *priv); diff --git a/src/synaptics-x11.c b/src/synaptics-x11.c index 3110ef0..a8a87f9 100644 --- a/src/synaptics-x11.c +++ b/src/synaptics-x11.c @@ -669,7 +669,7 @@ SwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) static void ReadInput(InputInfoPtr pInfo) { - SynapticsReadInput(pInfo->private); + SynapticsReadInput(pInfo->private, pInfo->fd); } static void FreeX11Private(struct SynapticsX11 **x11) diff --git a/src/synaptics.c b/src/synaptics.c index d7719d7..02f53ce 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -772,16 +772,16 @@ clamp(int val, int min, int max) } static Bool -SynapticsGetHwState(SynapticsPrivate * priv, struct SynapticsHwState *hw) +SynapticsGetHwState(SynapticsPrivate * priv, int fd, struct SynapticsHwState *hw) { - return priv->proto_ops->ReadHwState(priv, &priv->comm, hw); + return priv->proto_ops->ReadHwState(priv, fd, &priv->comm, hw); } /* * called for each full received packet from the touchpad */ void -SynapticsReadInput(SynapticsPrivate *priv) +SynapticsReadInput(SynapticsPrivate *priv, int fd) { struct SynapticsHwState *hw = priv->local_hw_state; int delay = 0; @@ -789,7 +789,7 @@ SynapticsReadInput(SynapticsPrivate *priv) SynapticsResetTouchHwState(hw, FALSE); - while (SynapticsGetHwState(priv, hw)) { + while (SynapticsGetHwState(priv, fd, hw)) { /* Semi-mt device touch slots do not track touches. When there is a * change in the number of touches, we must disregard the temporary * motion changes. */ diff --git a/src/synaptics.h b/src/synaptics.h index d7fa94d..e637e1a 100644 --- a/src/synaptics.h +++ b/src/synaptics.h @@ -51,7 +51,7 @@ void SynapticsReset(SynapticsPrivate * priv); * posts events to the frontend. * Implemented by: core */ -void SynapticsReadInput(SynapticsPrivate *priv); +void SynapticsReadInput(SynapticsPrivate *priv, int fd); /** * Initialise device-internal structs and get the device ready for sending * events. diff --git a/src/synproto.h b/src/synproto.h index f8b7f01..c8b87bd 100644 --- a/src/synproto.h +++ b/src/synproto.h @@ -100,6 +100,7 @@ struct SynapticsProtocolOperations { Bool (*DeviceOffHook) (SynapticsPrivate *priv); Bool (*QueryHardware) (SynapticsPrivate * priv, int fd); Bool (*ReadHwState) (SynapticsPrivate * priv, + int fd, struct CommData * comm, struct SynapticsHwState * hwRet); Bool (*AutoDevProbe) (SynapticsPrivate * priv, const char *device, char **device_out); diff --git a/test/eventcomm-test.c b/test/eventcomm-test.c index 5cf2639..eb16011 100644 --- a/test/eventcomm-test.c +++ b/test/eventcomm-test.c @@ -76,7 +76,7 @@ write_event(int fd, struct input_event *ev, int n) } static void -test_buttons(int fd, SynapticsPrivate *priv, struct CommData *comm) +test_buttons(int write_fd, int read_fd, SynapticsPrivate *priv, struct CommData *comm) { struct SynapticsHwState *hw = NULL; struct input_event ev = { {0, 0}, EV_KEY, 0, 0 }; @@ -86,12 +86,12 @@ test_buttons(int fd, SynapticsPrivate *priv, struct CommData *comm) #define _test_press_release(_code, field) \ ev.code = (_code); \ ev.value = 1; \ - write_event(fd, &ev, 1); \ - EventReadHwState(priv, comm, hw); \ + write_event(write_fd, &ev, 1); \ + EventReadHwState(priv, read_fd, comm, hw); \ assert(hw->field == 1); \ ev.value = 0; /* button release */ \ - write_event(fd_write, &ev, 1); \ - EventReadHwState(priv, comm, hw); \ + write_event(write_fd, &ev, 1); \ + EventReadHwState(priv, read_fd, comm, hw); \ assert(hw->field == 0); _test_press_release(BTN_LEFT, left); @@ -142,48 +142,48 @@ test_read_hw_state(void) /* just the syn event */ reset_data(&hw, &comm, &private); write(fd_write, &syn, sizeof(syn)); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->numFingers == 0); /* one finger */ reset_data(&hw, &comm, &private); write_event(fd_write, &ev[0], 1); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->numFingers == 1); /* two fingers */ reset_data(&hw, &comm, &private); write_event(fd_write, &ev[1], 1); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->numFingers == 2); /* three fingers */ reset_data(&hw, &comm, &private); write_event(fd_write, &ev[2], 1); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->numFingers == 3); /* x/y data */ reset_data(&hw, &comm, &private); write_event(fd_write, &ev[3], 2); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->x == ev[3].value); assert(hw->y == ev[4].value); /* pressure */ reset_data(&hw, &comm, &private); write_event(fd_write, &ev[5], 1); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->z == ev[5].value); /* finger width */ reset_data(&hw, &comm, &private); write_event(fd_write, &ev[6], 1); - EventReadHwState(&private, &comm, hw); + EventReadHwState(&private, fd_read, &comm, hw); assert(hw->fingerWidth == ev[6].value); /* the various buttons */ - test_buttons(fd_write, &private, &comm); + test_buttons(fd_write, fd_read, &private, &comm); free(private.proto_data); SynapticsHwStateFree(&hw); @@ -271,7 +271,7 @@ test_ignore_hw_state(void) ev.code = _code; \ ev.value = 1; \ write_event(fd_write, &ev, 1); \ - EventReadHwState(&private, &comm, hw); \ + EventReadHwState(&private, fd_read, &comm, hw); \ assert(compare_hw_state(hw, hw_zero) == 0); for (i = ABS_X; i < ABS_MAX; i++) { |