diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2012-11-03 13:43:58 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2012-11-03 13:43:58 +0000 |
commit | 08a75fff4755579e5093b2d09de0346293801d1d (patch) | |
tree | a6bb0127d11f374d7b4efbe6fbf847fbc0d771ad | |
parent | 4c28854100d25fdaf905ac8cd0d19b5036ebe8af (diff) |
Handle elantech touchpad buttons in a common code path for all
hardware variants. ok shadchin mikeb mpi
-rw-r--r-- | sys/dev/pckbc/pms.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/sys/dev/pckbc/pms.c b/sys/dev/pckbc/pms.c index da16e12c803..6f84bd88342 100644 --- a/sys/dev/pckbc/pms.c +++ b/sys/dev/pckbc/pms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pms.c,v 1.33 2012/11/02 12:07:57 stsp Exp $ */ +/* $OpenBSD: pms.c,v 1.34 2012/11/03 13:43:57 stsp Exp $ */ /* $NetBSD: psm.c,v 1.11 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -271,7 +271,7 @@ int alps_sec_proc(struct pms_softc *); int alps_get_hwinfo(struct pms_softc *); int elantech_knock(struct pms_softc *); -void elantech_send_input(struct pms_softc *, u_int, int, int, int, int); +void elantech_send_input(struct pms_softc *, int, int, int, int); int elantech_get_hwinfo_v1(struct pms_softc *); int elantech_get_hwinfo_v2(struct pms_softc *); int elantech_get_hwinfo_v3(struct pms_softc *); @@ -1955,7 +1955,6 @@ void pms_proc_elantech_v1(struct pms_softc *sc) { struct elantech_softc *elantech = sc->elantech; - u_int buttons = 0; int x, y, w, z; if (elantech->flags & ELANTECH_F_HW_V1_OLD) @@ -1975,18 +1974,7 @@ pms_proc_elantech_v1(struct pms_softc *sc) z = 0; } - if (sc->packet[0] & 0x01) - buttons |= WSMOUSE_BUTTON(1); - if (sc->packet[0] & 0x02) - buttons |= WSMOUSE_BUTTON(3); - if (elantech->flags & ELANTECH_F_HAS_ROCKER) { - if (sc->packet[0] & 0x40) /* up */ - buttons |= WSMOUSE_BUTTON(4); - if (sc->packet[0] & 0x80) /* down */ - buttons |= WSMOUSE_BUTTON(5); - } - - elantech_send_input(sc, buttons, x, y, z, w); + elantech_send_input(sc, x, y, z, w); } void @@ -1994,7 +1982,6 @@ pms_proc_elantech_v2(struct pms_softc *sc) { const u_char debounce_pkt[] = { 0x84, 0xff, 0xff, 0x02, 0xff, 0xff }; struct elantech_softc *elantech = sc->elantech; - u_int buttons; int x, y, w, z; /* @@ -2023,10 +2010,7 @@ pms_proc_elantech_v2(struct pms_softc *sc) z = 0; } - buttons = ((sc->packet[0] & 0x01 ? WSMOUSE_BUTTON(1) : 0) | - ((sc->packet[0] & 0x02) ? WSMOUSE_BUTTON(3): 0)); - - elantech_send_input(sc, buttons, x, y, z, w); + elantech_send_input(sc, x, y, z, w); } void @@ -2034,7 +2018,6 @@ 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. @@ -2042,8 +2025,6 @@ pms_proc_elantech_v3(struct pms_softc *sc) 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; @@ -2074,15 +2055,27 @@ pms_proc_elantech_v3(struct pms_softc *sc) else if (w) z = SYNAPTICS_PRESSURE; - elantech_send_input(sc, buttons, x, y, z, w); + elantech_send_input(sc, x, y, z, w); } void -elantech_send_input(struct pms_softc *sc, u_int buttons, int x, int y, int z, - int w) +elantech_send_input(struct pms_softc *sc, int x, int y, int z, int w) { struct elantech_softc *elantech = sc->elantech; int dx, dy; + u_int buttons = 0; + + if (sc->packet[0] & 0x01) + buttons |= WSMOUSE_BUTTON(1); + if (sc->packet[0] & 0x02) + buttons |= WSMOUSE_BUTTON(3); + + if (elantech->flags & ELANTECH_F_HAS_ROCKER) { + if (sc->packet[0] & 0x40) /* up */ + buttons |= WSMOUSE_BUTTON(4); + if (sc->packet[0] & 0x80) /* down */ + buttons |= WSMOUSE_BUTTON(5); + } if (elantech->wsmode == WSMOUSE_NATIVE) { wsmouse_input(sc->sc_wsmousedev, buttons, x, y, z, w, |