Lines Matching +full:y +full:- +full:axis
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
89 &wsp_debug, WSP_LLEVEL_ERROR, "WSP debug level (0-3)");
133 WSP_CLAMP(ptun->scale_factor, 1, 63); in wsp_running_rangecheck()
134 WSP_CLAMP(ptun->scroll_finger_count, 0, 3); in wsp_running_rangecheck()
135 WSP_CLAMP(ptun->horizontal_swipe_finger_count, 0, 3); in wsp_running_rangecheck()
136 WSP_CLAMP(ptun->z_factor, 0, 63); in wsp_running_rangecheck()
137 WSP_CLAMP(ptun->z_invert, 0, 1); in wsp_running_rangecheck()
138 WSP_CLAMP(ptun->t_factor, 0, 63); in wsp_running_rangecheck()
139 WSP_CLAMP(ptun->t_invert, 0, 1); in wsp_running_rangecheck()
140 WSP_CLAMP(ptun->pressure_touch_threshold, 1, 255); in wsp_running_rangecheck()
141 WSP_CLAMP(ptun->pressure_untouch_threshold, 1, 255); in wsp_running_rangecheck()
142 WSP_CLAMP(ptun->pressure_tap_threshold, 1, 255); in wsp_running_rangecheck()
143 WSP_CLAMP(ptun->max_finger_diameter, 1, 2400); in wsp_running_rangecheck()
144 WSP_CLAMP(ptun->max_scroll_finger_distance, 1, 16384); in wsp_running_rangecheck()
145 WSP_CLAMP(ptun->max_double_tap_distance, 1, 16384); in wsp_running_rangecheck()
146 WSP_CLAMP(ptun->scr_threshold, 1, 255); in wsp_running_rangecheck()
147 WSP_CLAMP(ptun->enable_single_tap_clicks, 0, 1); in wsp_running_rangecheck()
148 WSP_CLAMP(ptun->enable_single_tap_movement, 0, 1); in wsp_running_rangecheck()
158 &wsp_tuning.z_factor, 0, "Z-axis (vertical) scale factor");
160 &wsp_tuning.z_invert, 0, "enable (vertical) Z-axis inversion");
162 &wsp_tuning.t_factor, 0, "T-axis (horizontal) scale factor");
164 &wsp_tuning.t_invert, 0, "enable T-axis (horizontal) inversion");
176 &wsp_tuning.max_double_tap_distance, 0, "maximum double-finger click distance");
195 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
198 * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
200 * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
209 uint8_t rel_y; /* relative y coordinate */
221 /* trackpad finger data offsets, le16-aligned */
302 /* trackpad finger header - little endian */
317 /* trackpad finger structure - little endian */
321 int16_t abs_y; /* absolute y coodinate */
323 int16_t rel_y; /* relative y coodinate */
324 int16_t tool_major; /* tool area, major axis */
325 int16_t tool_minor; /* tool area, minor axis */
327 int16_t touch_major; /* touch area, major axis */
328 int16_t touch_minor; /* touch area, minor axis */
366 /* device-specific parameters */
368 int snratio; /* signal-to-noise ratio */
374 /* device-specific configuration */
380 struct wsp_param y; /* vertical limits */ member
385 #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */
386 #define SN_WIDTH 25 /* width signal-to-noise ratio */
387 #define SN_COORD 250 /* coordinate signal-to-noise ratio */
388 #define SN_ORIENT 10 /* orientation signal-to-noise ratio */
395 .x = { SN_COORD, -4824, 5342, 105 },
396 .y = { SN_COORD, -172, 5820, 75 },
398 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
404 .x = { SN_COORD, -4824, 4824, 105 },
405 .y = { SN_COORD, -172, 4290, 75 },
407 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
413 .x = { SN_COORD, -4460, 5166, 105 },
414 .y = { SN_COORD, -75, 6700, 75 },
416 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
422 .x = { SN_COORD, -4620, 5140, 105 },
423 .y = { SN_COORD, -150, 6600, 75 },
425 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
431 .x = { SN_COORD, -4616, 5112, 105 },
432 .y = { SN_COORD, -142, 5234, 75 },
434 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
440 .x = { SN_COORD, -4415, 5050, 105 },
441 .y = { SN_COORD, -55, 6680, 75 },
443 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
449 .x = { SN_COORD, -4620, 5140, 105 },
450 .y = { SN_COORD, -150, 6600, 75 },
452 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
458 .x = { SN_COORD, -4750, 5280, 105 },
459 .y = { SN_COORD, -150, 6730, 75 },
461 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
467 .x = { SN_COORD, -4620, 5140, 105 },
468 .y = { SN_COORD, -150, 6600, 75 },
470 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
476 .x = { SN_COORD, -4750, 5280, 105 },
477 .y = { SN_COORD, -150, 6730, 75 },
479 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
485 .x = { SN_COORD, -4750, 5280, 105 },
486 .y = { SN_COORD, -150, 6730, 75 },
488 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
494 .x = { SN_COORD, -4620, 5140, 105 },
495 .y = { SN_COORD, -150, 6600, 75 },
497 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
503 .x = { SN_COORD, -4828, 5345, 105 },
504 .y = { SN_COORD, -203, 6803, 75 },
506 -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 },
558 /* MacbookPro11,1-3 (unibody, June 2013) */
617 int dx_sum; /* x axis cumulative movement */
618 int dy_sum; /* y axis cumulative movement */
619 int dz_sum; /* z axis cumulative movement */
622 int dt_sum; /* T-axis cumulative movement */
623 int rdx; /* x axis remainder of divide by scale_factor */
624 int rdy; /* y axis remainder of divide by scale_factor */
625 int rdz; /* z axis remainder of divide by scale_factor */
700 const struct wsp_dev_params *params = sc->sc_params; in wsp_set_device_mode()
705 if (params->tp == wsp_tp + TYPE3) in wsp_set_device_mode()
708 err = usbd_req_get_report(sc->sc_usb_device, NULL, in wsp_set_device_mode()
709 mode_bytes, params->tp->um_size, params->tp->iface_index, in wsp_set_device_mode()
710 UHID_FEATURE_REPORT, params->tp->um_req_idx); in wsp_set_device_mode()
725 mode_bytes[params->tp->um_switch_idx] = in wsp_set_device_mode()
726 on ? params->tp->um_switch_on : params->tp->um_switch_off; in wsp_set_device_mode()
728 return (usbd_req_set_report(sc->sc_usb_device, NULL, in wsp_set_device_mode()
729 mode_bytes, params->tp->um_size, params->tp->iface_index, in wsp_set_device_mode()
730 UHID_FEATURE_REPORT, params->tp->um_req_idx)); in wsp_set_device_mode()
737 memset(&sc->sc_status, 0, sizeof(sc->sc_status)); in wsp_enable()
738 sc->sc_state |= WSP_ENABLED; in wsp_enable()
747 sc->sc_state &= ~WSP_ENABLED; in wsp_disable()
759 if (uaa->usb_mode != USB_MODE_HOST) in wsp_probe()
764 iface = usbd_get_iface(uaa->device, i); in wsp_probe()
767 id = iface->idesc; in wsp_probe()
769 (id->bInterfaceClass != UICLASS_HID) || in wsp_probe()
770 (id->bInterfaceProtocol != 0 && in wsp_probe()
771 id->bInterfaceProtocol != UIPROTO_MOUSE)) in wsp_probe()
776 if (uaa->info.bIfaceIndex != i) in wsp_probe()
796 err = usbd_req_get_hid_desc(uaa->device, NULL, &d_ptr, in wsp_attach()
797 &d_len, M_TEMP, uaa->info.bIfaceIndex); in wsp_attach()
801 sc->tp_datalen = hid_report_size_max(d_ptr, d_len, hid_input, in wsp_attach()
805 if (sc->tp_datalen <= 0 || sc->tp_datalen > WSP_BUFFER_MAX) { in wsp_attach()
807 "datalength: %d\n", sc->tp_datalen); in wsp_attach()
814 sc->sc_usb_device = uaa->device; in wsp_attach()
817 sc->sc_params = wsp_dev_params + USB_GET_DRIVER_INFO(uaa); in wsp_attach()
825 * reports to raw sensor data using vendor-specific USB in wsp_attach()
830 * During re-enumeration of the device we need to force the in wsp_attach()
846 mtx_init(&sc->sc_mutex, "wspmtx", NULL, MTX_DEF | MTX_RECURSE); in wsp_attach()
848 err = usbd_transfer_setup(uaa->device, in wsp_attach()
849 &uaa->info.bIfaceIndex, sc->sc_xfer, wsp_config, in wsp_attach()
850 WSP_N_TRANSFER, sc, &sc->sc_mutex); in wsp_attach()
855 if (usb_fifo_attach(sc->sc_usb_device, sc, &sc->sc_mutex, in wsp_attach()
856 &wsp_fifo_methods, &sc->sc_fifo, in wsp_attach()
857 device_get_unit(dev), -1, uaa->info.bIfaceIndex, in wsp_attach()
863 sc->sc_hw.buttons = 3; in wsp_attach()
864 sc->sc_hw.iftype = MOUSE_IF_USB; in wsp_attach()
865 sc->sc_hw.type = MOUSE_PAD; in wsp_attach()
866 sc->sc_hw.model = MOUSE_MODEL_GENERIC; in wsp_attach()
867 sc->sc_mode.protocol = MOUSE_PROTO_MSC; in wsp_attach()
868 sc->sc_mode.rate = -1; in wsp_attach()
869 sc->sc_mode.resolution = MOUSE_RES_UNKNOWN; in wsp_attach()
870 sc->sc_mode.packetsize = MOUSE_MSC_PACKETSIZE; in wsp_attach()
871 sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK; in wsp_attach()
872 sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC; in wsp_attach()
874 sc->sc_touch = WSP_UNTOUCH; in wsp_attach()
875 sc->scr_mode = WSP_SCR_NONE; in wsp_attach()
878 sc->sc_evdev = evdev_alloc(); in wsp_attach()
879 evdev_set_name(sc->sc_evdev, device_get_desc(dev)); in wsp_attach()
880 evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); in wsp_attach()
881 evdev_set_id(sc->sc_evdev, BUS_USB, uaa->info.idVendor, in wsp_attach()
882 uaa->info.idProduct, 0); in wsp_attach()
883 evdev_set_serial(sc->sc_evdev, usb_get_serial(uaa->device)); in wsp_attach()
884 evdev_set_methods(sc->sc_evdev, sc, &wsp_evdev_methods); in wsp_attach()
885 evdev_support_prop(sc->sc_evdev, INPUT_PROP_POINTER); in wsp_attach()
886 evdev_support_event(sc->sc_evdev, EV_SYN); in wsp_attach()
887 evdev_support_event(sc->sc_evdev, EV_ABS); in wsp_attach()
888 evdev_support_event(sc->sc_evdev, EV_KEY); in wsp_attach()
892 ((param).max - (param).min) / (param).snratio, 0, \ in wsp_attach()
893 (param).size != 0 ? ((param).max - (param).min) / (param).size : 0); in wsp_attach()
896 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_POSITION_X, sc->sc_params->x); in wsp_attach()
897 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_POSITION_Y, sc->sc_params->y); in wsp_attach()
899 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_PRESSURE, sc->sc_params->p); in wsp_attach()
900 /* finger major/minor axis */ in wsp_attach()
901 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_TOUCH_MAJOR, sc->sc_params->w); in wsp_attach()
902 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_TOUCH_MINOR, sc->sc_params->w); in wsp_attach()
904 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_WIDTH_MAJOR, sc->sc_params->w); in wsp_attach()
905 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_WIDTH_MINOR, sc->sc_params->w); in wsp_attach()
907 WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_ORIENTATION, sc->sc_params->o); in wsp_attach()
909 evdev_support_key(sc->sc_evdev, BTN_LEFT); in wsp_attach()
910 if ((sc->sc_params->tp->caps & HAS_INTEGRATED_BUTTON) != 0) in wsp_attach()
911 evdev_support_prop(sc->sc_evdev, INPUT_PROP_BUTTONPAD); in wsp_attach()
913 evdev_support_abs(sc->sc_evdev, ABS_MT_SLOT, in wsp_attach()
914 0, MAX_FINGERS - 1, 0, 0, 0); in wsp_attach()
915 evdev_support_abs(sc->sc_evdev, ABS_MT_TRACKING_ID, in wsp_attach()
916 -1, MAX_FINGERS - 1, 0, 0, 0); in wsp_attach()
917 evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_TRACK); in wsp_attach()
918 evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_AUTOREL); in wsp_attach()
920 evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_STCOMPAT); in wsp_attach()
922 err = evdev_register(sc->sc_evdev); in wsp_attach()
941 mtx_lock(&sc->sc_mutex); in wsp_detach()
942 if (sc->sc_state & WSP_ENABLED) in wsp_detach()
944 mtx_unlock(&sc->sc_mutex); in wsp_detach()
946 usb_fifo_detach(&sc->sc_fifo); in wsp_detach()
949 evdev_free(sc->sc_evdev); in wsp_detach()
952 usbd_transfer_unsetup(sc->sc_xfer, WSP_N_TRANSFER); in wsp_detach()
954 mtx_destroy(&sc->sc_mutex); in wsp_detach()
963 const struct wsp_dev_params *params = sc->sc_params; in wsp_intr_callback()
983 if (sc->dz_count == 0) in wsp_intr_callback()
984 sc->dz_count = WSP_DZ_MAX_COUNT; in wsp_intr_callback()
993 usbd_copy_out(pc, 0, sc->tp_data, len); in wsp_intr_callback()
995 if ((len < params->tp->offset + params->tp->fsize) || in wsp_intr_callback()
996 ((len - params->tp->offset) % params->tp->fsize) != 0) { in wsp_intr_callback()
998 len, sc->tp_data[0], sc->tp_data[1]); in wsp_intr_callback()
1002 if (len < sc->tp_datalen) { in wsp_intr_callback()
1004 memset(sc->tp_data + len, 0, sc->tp_datalen - len); in wsp_intr_callback()
1007 if (params->tp != wsp_tp + TYPE1) { in wsp_intr_callback()
1008 ibt = sc->tp_data[params->tp->button]; in wsp_intr_callback()
1009 ntouch = sc->tp_data[params->tp->button - 1]; in wsp_intr_callback()
1011 ntouch = (len - params->tp->offset) / params->tp->fsize; in wsp_intr_callback()
1020 …f = (struct tp_finger *)(sc->tp_data + params->tp->offset + params->tp->delta + i * params->tp->fs… in wsp_intr_callback()
1023 f->origin = le16toh((uint16_t)f->origin); in wsp_intr_callback()
1024 f->abs_x = le16toh((uint16_t)f->abs_x); in wsp_intr_callback()
1025 f->abs_y = le16toh((uint16_t)f->abs_y); in wsp_intr_callback()
1026 f->rel_x = le16toh((uint16_t)f->rel_x); in wsp_intr_callback()
1027 f->rel_y = le16toh((uint16_t)f->rel_y); in wsp_intr_callback()
1028 f->tool_major = le16toh((uint16_t)f->tool_major); in wsp_intr_callback()
1029 f->tool_minor = le16toh((uint16_t)f->tool_minor); in wsp_intr_callback()
1030 f->orientation = le16toh((uint16_t)f->orientation); in wsp_intr_callback()
1031 f->touch_major = le16toh((uint16_t)f->touch_major); in wsp_intr_callback()
1032 f->touch_minor = le16toh((uint16_t)f->touch_minor); in wsp_intr_callback()
1033 f->pressure = le16toh((uint16_t)f->pressure); in wsp_intr_callback()
1034 f->multi = le16toh((uint16_t)f->multi); in wsp_intr_callback()
1040 i, ibt, ntouch, f->origin, f->abs_x, f->abs_y, in wsp_intr_callback()
1041 f->rel_x, f->rel_y, f->tool_major, f->tool_minor, f->orientation, in wsp_intr_callback()
1042 f->touch_major, f->touch_minor, f->pressure, f->multi); in wsp_intr_callback()
1043 sc->pos_x[i] = f->abs_x; in wsp_intr_callback()
1044 sc->pos_y[i] = -f->abs_y; in wsp_intr_callback()
1045 sc->index[i] = f; in wsp_intr_callback()
1047 if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE && f->touch_major != 0) { in wsp_intr_callback()
1050 .x = f->abs_x, in wsp_intr_callback()
1051 .y = params->y.min + params->y.max - f->abs_y, in wsp_intr_callback()
1052 .p = f->pressure, in wsp_intr_callback()
1053 .maj = f->touch_major << 1, in wsp_intr_callback()
1054 .min = f->touch_minor << 1, in wsp_intr_callback()
1055 .w_maj = f->tool_major << 1, in wsp_intr_callback()
1056 .w_min = f->tool_minor << 1, in wsp_intr_callback()
1057 .ori = params->o.max - f->orientation, in wsp_intr_callback()
1059 evdev_mt_push_slot(sc->sc_evdev, slot, &slot_data); in wsp_intr_callback()
1067 evdev_push_key(sc->sc_evdev, BTN_LEFT, ibt); in wsp_intr_callback()
1068 evdev_sync(sc->sc_evdev); in wsp_intr_callback()
1071 sc->sc_status.flags &= ~MOUSE_POSCHANGED; in wsp_intr_callback()
1072 sc->sc_status.flags &= ~MOUSE_STDBUTTONSCHANGED; in wsp_intr_callback()
1073 sc->sc_status.obutton = sc->sc_status.button; in wsp_intr_callback()
1074 sc->sc_status.button = 0; in wsp_intr_callback()
1077 sc->distance = max(sc->distance, max( in wsp_intr_callback()
1078 abs(sc->pos_x[0] - sc->pos_x[1]), in wsp_intr_callback()
1079 abs(sc->pos_y[0] - sc->pos_y[1]))); in wsp_intr_callback()
1083 if (params->tp->caps & HAS_INTEGRATED_BUTTON) { in wsp_intr_callback()
1086 sc->sc_status.button |= MOUSE_BUTTON1DOWN; in wsp_intr_callback()
1089 if (sc->distance < tun.max_double_tap_distance && abs(sc->dx_sum) < 5 && in wsp_intr_callback()
1090 abs(sc->dy_sum) < 5) in wsp_intr_callback()
1091 sc->sc_status.button |= MOUSE_BUTTON3DOWN; in wsp_intr_callback()
1093 sc->sc_status.button |= MOUSE_BUTTON1DOWN; in wsp_intr_callback()
1096 sc->sc_status.button |= MOUSE_BUTTON2DOWN; in wsp_intr_callback()
1102 sc->sc_status.button |= MOUSE_BUTTON1DOWN; in wsp_intr_callback()
1105 sc->ibtn = 1; in wsp_intr_callback()
1107 sc->intr_count++; in wsp_intr_callback()
1109 if (sc->ntaps < ntouch) { in wsp_intr_callback()
1112 if (sc->index[0]->touch_major > tun.pressure_tap_threshold && in wsp_intr_callback()
1113 sc->index[0]->tool_major <= tun.max_finger_diameter) in wsp_intr_callback()
1114 sc->ntaps = 1; in wsp_intr_callback()
1117 if (sc->index[0]->touch_major > tun.pressure_tap_threshold-30 && in wsp_intr_callback()
1118 sc->index[1]->touch_major > tun.pressure_tap_threshold-30) in wsp_intr_callback()
1119 sc->ntaps = 2; in wsp_intr_callback()
1122 if (sc->index[0]->touch_major > tun.pressure_tap_threshold-40 && in wsp_intr_callback()
1123 sc->index[1]->touch_major > tun.pressure_tap_threshold-40 && in wsp_intr_callback()
1124 sc->index[2]->touch_major > tun.pressure_tap_threshold-40) in wsp_intr_callback()
1125 sc->ntaps = 3; in wsp_intr_callback()
1132 if (sc->index[0]->touch_major < tun.pressure_untouch_threshold && in wsp_intr_callback()
1133 sc->sc_status.button == 0) { in wsp_intr_callback()
1134 sc->sc_touch = WSP_UNTOUCH; in wsp_intr_callback()
1135 if (sc->intr_count < WSP_TAP_MAX_COUNT && in wsp_intr_callback()
1136 sc->intr_count > WSP_TAP_THRESHOLD && in wsp_intr_callback()
1137 sc->ntaps && sc->ibtn == 0) { in wsp_intr_callback()
1139 * Add a pair of events (button-down and in wsp_intr_callback()
1140 * button-up). in wsp_intr_callback()
1142 switch (sc->ntaps) { in wsp_intr_callback()
1144 if (!(params->tp->caps & HAS_INTEGRATED_BUTTON) || tun.enable_single_tap_clicks) { in wsp_intr_callback()
1151 sc->dx_sum, sc->dy_sum); in wsp_intr_callback()
1152 if (sc->distance < tun.max_double_tap_distance && abs(sc->dx_sum) < 5 && in wsp_intr_callback()
1153 abs(sc->dy_sum) < 5) { in wsp_intr_callback()
1168 if (sc->scr_mode == WSP_SCR_HOR && sc->ntaps == tun.horizontal_swipe_finger_count in wsp_intr_callback()
1169 && tun.horizontal_swipe_finger_count > 0 && (sc->dt_sum / tun.scr_threshold) != 0) { in wsp_intr_callback()
1171 * translate T-axis swipe into button in wsp_intr_callback()
1174 if (sc->dt_sum > 0) in wsp_intr_callback()
1176 else if (sc->dt_sum < 0) in wsp_intr_callback()
1180 sc->dz_count = WSP_DZ_MAX_COUNT; in wsp_intr_callback()
1181 sc->dz_sum = 0; in wsp_intr_callback()
1182 sc->intr_count = 0; in wsp_intr_callback()
1183 sc->ibtn = 0; in wsp_intr_callback()
1184 sc->ntaps = 0; in wsp_intr_callback()
1185 sc->finger = 0; in wsp_intr_callback()
1186 sc->distance = 0; in wsp_intr_callback()
1187 sc->dt_sum = 0; in wsp_intr_callback()
1188 sc->dx_sum = 0; in wsp_intr_callback()
1189 sc->dy_sum = 0; in wsp_intr_callback()
1190 sc->rdx = 0; in wsp_intr_callback()
1191 sc->rdy = 0; in wsp_intr_callback()
1192 sc->rdz = 0; in wsp_intr_callback()
1193 sc->scr_mode = WSP_SCR_NONE; in wsp_intr_callback()
1194 } else if (sc->index[0]->touch_major >= tun.pressure_touch_threshold && in wsp_intr_callback()
1195 sc->sc_touch == WSP_UNTOUCH) { /* ignore first touch */ in wsp_intr_callback()
1196 sc->sc_touch = WSP_FIRST_TOUCH; in wsp_intr_callback()
1197 } else if (sc->index[0]->touch_major >= tun.pressure_touch_threshold && in wsp_intr_callback()
1198 sc->sc_touch == WSP_FIRST_TOUCH) { /* ignore second touch */ in wsp_intr_callback()
1199 sc->sc_touch = WSP_SECOND_TOUCH; in wsp_intr_callback()
1201 sc->pre_pos_x[0], sc->pre_pos_y[0]); in wsp_intr_callback()
1203 if (sc->sc_touch == WSP_SECOND_TOUCH) in wsp_intr_callback()
1204 sc->sc_touch = WSP_TOUCHING; in wsp_intr_callback()
1207 sc->index[0]->touch_major >= tun.pressure_touch_threshold) { in wsp_intr_callback()
1208 dx = sc->pos_x[0] - sc->pre_pos_x[0]; in wsp_intr_callback()
1209 dy = sc->pos_y[0] - sc->pre_pos_y[0]; in wsp_intr_callback()
1212 if (tun.enable_single_tap_movement != 1 && sc->ibtn != 0 && sc->sc_status.button == 0) in wsp_intr_callback()
1216 if (sc->o_ntouch != ntouch) in wsp_intr_callback()
1220 if (ntouch == 1 && sc->index[0]->tool_major > tun.max_finger_diameter) in wsp_intr_callback()
1223 if (sc->ibtn != 0 && ntouch == 1 && in wsp_intr_callback()
1224 sc->intr_count < WSP_TAP_MAX_COUNT && in wsp_intr_callback()
1225 abs(sc->dx_sum) < 1 && abs(sc->dy_sum) < 1 ) in wsp_intr_callback()
1228 if (ntouch == 2 && sc->sc_status.button != 0) { in wsp_intr_callback()
1229 dx = sc->pos_x[sc->finger] - sc->pre_pos_x[sc->finger]; in wsp_intr_callback()
1230 dy = sc->pos_y[sc->finger] - sc->pre_pos_y[sc->finger]; in wsp_intr_callback()
1236 if (sc->index[0]->origin == 0 || sc->index[1]->origin == 0 || in wsp_intr_callback()
1237 sc->sc_status.obutton != sc->sc_status.button) { in wsp_intr_callback()
1239 sc->finger = 0; in wsp_intr_callback()
1241 if ((abs(sc->index[0]->rel_x) + abs(sc->index[0]->rel_y)) < in wsp_intr_callback()
1242 (abs(sc->index[1]->rel_x) + abs(sc->index[1]->rel_y)) && in wsp_intr_callback()
1243 sc->finger == 0) { in wsp_intr_callback()
1244 sc->sc_touch = WSP_SECOND_TOUCH; in wsp_intr_callback()
1246 sc->finger = 1; in wsp_intr_callback()
1248 if ((abs(sc->index[0]->rel_x) + abs(sc->index[0]->rel_y)) >= in wsp_intr_callback()
1249 (abs(sc->index[1]->rel_x) + abs(sc->index[1]->rel_y)) && in wsp_intr_callback()
1250 sc->finger == 1) { in wsp_intr_callback()
1251 sc->sc_touch = WSP_SECOND_TOUCH; in wsp_intr_callback()
1253 sc->finger = 0; in wsp_intr_callback()
1256 dx, dy, sc->finger); in wsp_intr_callback()
1258 if (sc->dz_count--) { in wsp_intr_callback()
1259 if (sc->scr_mode == WSP_SCR_HOR) { in wsp_intr_callback()
1260 rdz = (dx + sc->rdz) % tun.scale_factor; in wsp_intr_callback()
1261 sc->dz_sum -= (dx + sc->rdz) / tun.scale_factor; in wsp_intr_callback()
1262 } else if (sc->scr_mode == WSP_SCR_VER) { in wsp_intr_callback()
1263 rdz = (dy + sc->rdz) % tun.scale_factor; in wsp_intr_callback()
1264 sc->dz_sum -= (dy + sc->rdz) / tun.scale_factor; in wsp_intr_callback()
1266 sc->rdz = rdz; in wsp_intr_callback()
1268 if (sc->scr_mode == WSP_SCR_VER && (tun.z_factor == 0 || (sc->dz_sum / tun.z_factor) != 0)) in wsp_intr_callback()
1269 sc->dz_count = 0; in wsp_intr_callback()
1270 else if (sc->scr_mode == WSP_SCR_HOR && (tun.t_factor == 0 || (sc->dz_sum / tun.t_factor) != 0)) in wsp_intr_callback()
1271 sc->dz_count = 0; in wsp_intr_callback()
1273 rdx = (dx + sc->rdx) % tun.scale_factor; in wsp_intr_callback()
1274 dx = (dx + sc->rdx) / tun.scale_factor; in wsp_intr_callback()
1275 sc->rdx = rdx; in wsp_intr_callback()
1277 rdy = (dy + sc->rdy) % tun.scale_factor; in wsp_intr_callback()
1278 dy = (dy + sc->rdy) / tun.scale_factor; in wsp_intr_callback()
1279 sc->rdy = rdy; in wsp_intr_callback()
1281 sc->dx_sum += dx; in wsp_intr_callback()
1282 sc->dy_sum += dy; in wsp_intr_callback()
1284 if (sc->sc_status.button == 0 && ntouch > 0) { in wsp_intr_callback()
1286 if (sc->scr_mode == WSP_SCR_NONE && abs(sc->dx_sum) + abs(sc->dy_sum) > tun.scr_threshold) in wsp_intr_callback()
1287 sc->scr_mode = abs(sc->dx_sum) > abs(sc->dy_sum) * 2 ? WSP_SCR_HOR : WSP_SCR_VER; in wsp_intr_callback()
1289 …O, "scr_mode=%5d, count=%d, dx_sum=%d, dy_sum=%d\n", sc->scr_mode, sc->intr_count, sc->dx_sum, sc-… in wsp_intr_callback()
1293 if (sc->scr_mode == WSP_SCR_HOR) { in wsp_intr_callback()
1294 sc->sc_status.button = 1 << 5; in wsp_intr_callback()
1298 sc->dt_sum = 0; in wsp_intr_callback()
1299 if (sc->distance <= tun.max_scroll_finger_distance && sc->dz_count == 0) { in wsp_intr_callback()
1300 if (sc->scr_mode == WSP_SCR_VER) { in wsp_intr_callback()
1302 dz = (sc->dz_sum / tun.z_factor) * (tun.z_invert ? -1 : 1); in wsp_intr_callback()
1303 } else if (sc->scr_mode == WSP_SCR_HOR) { in wsp_intr_callback()
1305 dz = (sc->dz_sum / tun.t_factor) * (tun.t_invert ? -1 : 1); in wsp_intr_callback()
1309 if (sc->scr_mode == WSP_SCR_HOR) { in wsp_intr_callback()
1310 sc->dt_sum += dx * (tun.t_invert ? -1 : 1); in wsp_intr_callback()
1312 sc->dt_sum = 0; in wsp_intr_callback()
1322 sc->dt_sum = 0; in wsp_intr_callback()
1325 sc->scr_mode = WSP_SCR_NONE; in wsp_intr_callback()
1327 if (sc->intr_count < WSP_TAP_MAX_COUNT && in wsp_intr_callback()
1331 sc->intr_count = WSP_TAP_MAX_COUNT; in wsp_intr_callback()
1333 sc->sc_status.flags |= MOUSE_POSCHANGED; in wsp_intr_callback()
1335 dx, dy, dz, sc->sc_touch, sc->sc_status.button); in wsp_intr_callback()
1336 sc->sc_status.dx += dx; in wsp_intr_callback()
1337 sc->sc_status.dy += dy; in wsp_intr_callback()
1338 sc->sc_status.dz += dz; in wsp_intr_callback()
1340 wsp_add_to_queue(sc, dx, -dy, dz, sc->sc_status.button); in wsp_intr_callback()
1341 if (sc->dz_count == 0) { in wsp_intr_callback()
1342 sc->dz_sum = 0; in wsp_intr_callback()
1343 sc->rdz = 0; in wsp_intr_callback()
1346 sc->pre_pos_x[0] = sc->pos_x[0]; in wsp_intr_callback()
1347 sc->pre_pos_y[0] = sc->pos_y[0]; in wsp_intr_callback()
1349 if (ntouch == 2 && sc->sc_status.button != 0) { in wsp_intr_callback()
1350 sc->pre_pos_x[sc->finger] = sc->pos_x[sc->finger]; in wsp_intr_callback()
1351 sc->pre_pos_y[sc->finger] = sc->pos_y[sc->finger]; in wsp_intr_callback()
1353 sc->o_ntouch = ntouch; in wsp_intr_callback()
1359 sc->sc_fifo.fp[USB_FIFO_RX]) != 0) { in wsp_intr_callback()
1361 sc->tp_datalen); in wsp_intr_callback()
1384 dx = imax(dx, -256); in wsp_add_to_queue()
1386 dy = imax(dy, -256); in wsp_add_to_queue()
1388 dz = imax(dz, -128); in wsp_add_to_queue()
1399 buf[0] = sc->sc_mode.syncmask[1]; in wsp_add_to_queue()
1403 buf[3] = dx - (dx >> 1); in wsp_add_to_queue()
1404 buf[4] = dy - (dy >> 1); in wsp_add_to_queue()
1406 if (sc->sc_mode.level == 1) { in wsp_add_to_queue()
1408 buf[6] = dz - (dz >> 1);/* dz - (dz / 2) */ in wsp_add_to_queue()
1412 usb_fifo_put_data_linear(sc->sc_fifo.fp[USB_FIFO_RX], buf, in wsp_add_to_queue()
1413 sc->sc_mode.packetsize, 1); in wsp_add_to_queue()
1420 usb_fifo_reset(sc->sc_fifo.fp[USB_FIFO_RX]); in wsp_reset_buf()
1429 rate = sc->sc_pollrate; in wsp_start_read()
1434 if ((rate > 0) && (sc->sc_xfer[WSP_INTR_DT] != NULL)) { in wsp_start_read()
1436 usbd_transfer_stop(sc->sc_xfer[WSP_INTR_DT]); in wsp_start_read()
1438 usbd_xfer_set_interval(sc->sc_xfer[WSP_INTR_DT], 1000 / rate); in wsp_start_read()
1440 sc->sc_pollrate = 0; in wsp_start_read()
1442 usbd_transfer_start(sc->sc_xfer[WSP_INTR_DT]); in wsp_start_read()
1448 usbd_transfer_stop(sc->sc_xfer[WSP_INTR_DT]); in wsp_stop_read()
1459 if (sc->sc_fflags & fflags) in wsp_open()
1468 if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) in wsp_open()
1476 sc->sc_fflags |= fflags & (FREAD | FWRITE); in wsp_open()
1487 if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) in wsp_close()
1493 sc->sc_fflags &= ~(fflags & (FREAD | FWRITE)); in wsp_close()
1510 if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) in wsp_fifo_stop_read()
1522 mtx_lock(&sc->sc_mutex); in wsp_ev_open()
1523 if (sc->sc_fflags == 0) in wsp_ev_open()
1527 sc->sc_state |= WSP_EVDEV_OPENED; in wsp_ev_open()
1529 mtx_unlock(&sc->sc_mutex); in wsp_ev_open()
1539 mtx_lock(&sc->sc_mutex); in wsp_ev_close()
1540 sc->sc_state &= ~WSP_EVDEV_OPENED; in wsp_ev_close()
1541 if (sc->sc_fflags == 0) in wsp_ev_close()
1543 mtx_unlock(&sc->sc_mutex); in wsp_ev_close()
1556 mtx_lock(&sc->sc_mutex); in wsp_ioctl()
1560 *(mousehw_t *)addr = sc->sc_hw; in wsp_ioctl()
1563 *(mousemode_t *)addr = sc->sc_mode; in wsp_ioctl()
1568 if (mode.level == -1) in wsp_ioctl()
1575 sc->sc_mode.level = mode.level; in wsp_ioctl()
1576 sc->sc_pollrate = mode.rate; in wsp_ioctl()
1577 sc->sc_hw.buttons = 3; in wsp_ioctl()
1579 if (sc->sc_mode.level == 0) { in wsp_ioctl()
1580 sc->sc_mode.protocol = MOUSE_PROTO_MSC; in wsp_ioctl()
1581 sc->sc_mode.packetsize = MOUSE_MSC_PACKETSIZE; in wsp_ioctl()
1582 sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK; in wsp_ioctl()
1583 sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC; in wsp_ioctl()
1584 } else if (sc->sc_mode.level == 1) { in wsp_ioctl()
1585 sc->sc_mode.protocol = MOUSE_PROTO_SYSMOUSE; in wsp_ioctl()
1586 sc->sc_mode.packetsize = MOUSE_SYS_PACKETSIZE; in wsp_ioctl()
1587 sc->sc_mode.syncmask[0] = MOUSE_SYS_SYNCMASK; in wsp_ioctl()
1588 sc->sc_mode.syncmask[1] = MOUSE_SYS_SYNC; in wsp_ioctl()
1593 *(int *)addr = sc->sc_mode.level; in wsp_ioctl()
1600 sc->sc_mode.level = *(int *)addr; in wsp_ioctl()
1601 sc->sc_hw.buttons = 3; in wsp_ioctl()
1603 if (sc->sc_mode.level == 0) { in wsp_ioctl()
1604 sc->sc_mode.protocol = MOUSE_PROTO_MSC; in wsp_ioctl()
1605 sc->sc_mode.packetsize = MOUSE_MSC_PACKETSIZE; in wsp_ioctl()
1606 sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK; in wsp_ioctl()
1607 sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC; in wsp_ioctl()
1608 } else if (sc->sc_mode.level == 1) { in wsp_ioctl()
1609 sc->sc_mode.protocol = MOUSE_PROTO_SYSMOUSE; in wsp_ioctl()
1610 sc->sc_mode.packetsize = MOUSE_SYS_PACKETSIZE; in wsp_ioctl()
1611 sc->sc_mode.syncmask[0] = MOUSE_SYS_SYNCMASK; in wsp_ioctl()
1612 sc->sc_mode.syncmask[1] = MOUSE_SYS_SYNC; in wsp_ioctl()
1619 *status = sc->sc_status; in wsp_ioctl()
1620 sc->sc_status.obutton = sc->sc_status.button; in wsp_ioctl()
1621 sc->sc_status.button = 0; in wsp_ioctl()
1622 sc->sc_status.dx = 0; in wsp_ioctl()
1623 sc->sc_status.dy = 0; in wsp_ioctl()
1624 sc->sc_status.dz = 0; in wsp_ioctl()
1626 if (status->dx || status->dy || status->dz) in wsp_ioctl()
1627 status->flags |= MOUSE_POSCHANGED; in wsp_ioctl()
1628 if (status->button != status->obutton) in wsp_ioctl()
1629 status->flags |= MOUSE_BUTTONSCHANGED; in wsp_ioctl()
1637 mtx_unlock(&sc->sc_mutex); in wsp_ioctl()