Index: sys/dev/hid/bcm5974.c =================================================================== --- sys/dev/hid/bcm5974.c +++ sys/dev/hid/bcm5974.c @@ -154,22 +154,24 @@ /* trackpad finger structure - little endian */ struct tp_finger { - int16_t origin; /* zero when switching track finger */ - int16_t abs_x; /* absolute x coodinate */ - int16_t abs_y; /* absolute y coodinate */ - int16_t rel_x; /* relative x coodinate */ - int16_t rel_y; /* relative y coodinate */ - int16_t tool_major; /* tool area, major axis */ - int16_t tool_minor; /* tool area, minor axis */ - int16_t orientation; /* 16384 when point, else 15 bit angle */ - int16_t touch_major; /* touch area, major axis */ - int16_t touch_minor; /* touch area, minor axis */ - int16_t unused[2]; /* zeros */ - int16_t pressure; /* pressure on forcetouch touchpad */ - int16_t multi; /* one finger: varies, more fingers: - * constant */ + uint16_t origin; /* zero when switching track finger */ + uint16_t abs_x; /* absolute x coodinate */ + uint16_t abs_y; /* absolute y coodinate */ + uint16_t rel_x; /* relative x coodinate */ + uint16_t rel_y; /* relative y coodinate */ + uint16_t tool_major; /* tool area, major axis */ + uint16_t tool_minor; /* tool area, minor axis */ + uint16_t orientation; /* 16384 when point, else 15 bit angle */ + uint16_t touch_major; /* touch area, major axis */ + uint16_t touch_minor; /* touch area, minor axis */ + uint16_t unused[2]; /* zeros */ + uint16_t pressure; /* pressure on forcetouch touchpad */ + uint16_t multi; /* one finger: varies, more fingers: + * constant */ } __packed; +#define WSP_LE2H(x) ((int32_t)(int16_t)le16toh(x)) + /* trackpad finger data size, empirically at least ten fingers */ #define MAX_FINGERS MAX_MT_SLOTS @@ -694,26 +696,26 @@ DPRINTFN(BCM5974_LLEVEL_INFO, "[%d]ibt=%d, taps=%d, o=%4d, ax=%5d, ay=%5d, " "rx=%5d, ry=%5d, tlmaj=%4d, tlmin=%4d, ot=%4x, " - "tchmaj=%4d, tchmin=%4d, presure=%4d, m=%4x\n", - i, ibt, ntouch, le16toh(f->origin), le16toh(f->abs_x), - le16toh(f->abs_y), le16toh(f->rel_x), le16toh(f->rel_y), - le16toh(f->tool_major), le16toh(f->tool_minor), - le16toh(f->orientation), le16toh(f->touch_major), - le16toh(f->touch_minor), le16toh(f->pressure), - le16toh(f->multi)); + "tchmaj=%4d, tchmin=%4d, pressure=%4d, m=%4x\n", + i, ibt, ntouch, WSP_LE2H(f->origin), WSP_LE2H(f->abs_x), + WSP_LE2H(f->abs_y), WSP_LE2H(f->rel_x), WSP_LE2H(f->rel_y), + WSP_LE2H(f->tool_major), WSP_LE2H(f->tool_minor), + WSP_LE2H(f->orientation), WSP_LE2H(f->touch_major), + WSP_LE2H(f->touch_minor), WSP_LE2H(f->pressure), + WSP_LE2H(f->multi)); - if (f->touch_major == 0) + if (WSP_LE2H(f->touch_major) == 0) continue; slot_data = (union evdev_mt_slot) { .id = slot, - .x = le16toh(f->abs_x), - .y = params->y.min + params->y.max - le16toh(f->abs_y), - .p = le16toh(f->pressure), - .maj = le16toh(f->touch_major) << 1, - .min = le16toh(f->touch_minor) << 1, - .w_maj = le16toh(f->tool_major) << 1, - .w_min = le16toh(f->tool_minor) << 1, - .ori = params->o.max - le16toh(f->orientation), + .x = WSP_LE2H(f->abs_x), + .y = params->y.min + params->y.max - WSP_LE2H(f->abs_y), + .p = WSP_LE2H(f->pressure), + .maj = WSP_LE2H(f->touch_major) << 1, + .min = WSP_LE2H(f->touch_minor) << 1, + .w_maj = WSP_LE2H(f->tool_major) << 1, + .w_min = WSP_LE2H(f->tool_minor) << 1, + .ori = params->o.max - WSP_LE2H(f->orientation), }; evdev_mt_push_slot(sc->sc_evdev, slot, &slot_data); slot++;