On 28/10/12(Sun) 15:47, Stefan Sperling wrote:
> On Mon, Oct 08, 2012 at 06:16:22PM +0200, Martin Pieuchot wrote:
> > I don't have any Elantech hardware to test but I can tell you that this
> > version doesn't introduce any regression with my ALPS touchpad. It could
> > be nice to hear from other touchpad owners too ;)
>
> I haven't received test reports from anyone else. I suspect many don't
> realise that their laptop contains an elantech touchpad.
> [...]
>
> Good idea but it doesn't work.
> We need to switch the pad into absolute mode first. Else it reports
> bogus width/height values which causes the mouse cursor to behave
> erratically and breaks edge scrolling.
>
> Thanks for the review! Is this good for commit now?
Yep, ok mpi@ with on more style(9) tweak regarding the multilines
comments:
> +void
> +pms_proc_elantech_v3(struct pms_softc *sc)
> +{
> + const u_char debounce_pkt[] = { 0xc4, 0xff, 0xff, 0x02, 0xff, 0xff };
> + struct elantech_softc *elantech = sc->elantech;
> + u_int buttons;
> + int x, y, w, z;
> +
> + /* The hardware sends this packet when in debounce state.
> + * The packet should be ignored. */
Here:
/*
* The hardware sends this packet when in debounce state.
* The packet should be ignored.
*/
> + if (!memcmp(sc->packet, debounce_pkt, sizeof(debounce_pkt)))
> + return;
> +
> + buttons = ((sc->packet[0] & 0x01 ? WSMOUSE_BUTTON(1) : 0) |
> + ((sc->packet[0] & 0x02) ? WSMOUSE_BUTTON(3): 0));
> + x = ((sc->packet[1] & 0x0f) << 8 | sc->packet[2]);
> + y = ((sc->packet[4] & 0x0f) << 8 | sc->packet[5]);
> + z = 0;
> + w = (sc->packet[0] & 0xc0) >> 6;
> + if (w == 2) {
> + /* Two-finger touch causes two packets -- a head packet
> + * and a tail packet. We report a single event and ignore
> + * the tail packet. */
And:
/*
* Two-finger touch causes two packets -- a head packet
* and a tail packet. We report a single event and ignore
* the tail packet.
*/
> + if ((sc->packet[0] & 0x0c) != 0x04 &&
> + (sc->packet[3] & 0xfc) != 0x02) {
> + /* not the head packet -- ignore */
> + return;
> + }
> + }
> +
> + /* Prevent juming cursor if pad isn't touched or reports garbage. */
> + if (w == 0 ||
> + ((x == 0 || y == 0 || x == elantech->max_x || y == elantech->max_y)
> + && (x != elantech->old_x || y != elantech->old_y))) {
> + x = elantech->old_x;
> + y = elantech->old_y;
> + }
> +
> + if (elantech->flags & ELANTECH_F_REPORTS_PRESSURE)
> + z = (sc->packet[1] & 0xf0) | ((sc->packet[4] & 0xf0) >> 4);
> + else if (w)
> + z = SYNAPTICS_PRESSURE;
> +
> + elantech_send_input(sc, buttons, x, y, z, w);
> +}
M.