Lines Matching full:input

20  * touchpad input processing
365 magnitude(struct wsmouseinput *input, int dx, int dy) in magnitude() argument
369 h = abs(dx) * input->filter.h.mag_scale; in magnitude()
370 v = abs(dy) * input->filter.v.mag_scale; in magnitude()
381 wstpad_is_stable(struct wsmouseinput *input, struct tpad_touch *t) in wstpad_is_stable() argument
386 if (magnitude(input, t->pos->dx, t->pos->dy) > MAG_MEDIUM) in wstpad_is_stable()
390 timespecsub(&input->tp->time, &t->start, &ts); in wstpad_is_stable()
418 get_2nd_touch(struct wsmouseinput *input) in get_2nd_touch() argument
420 struct wstpad *tp = input->tp; in get_2nd_touch()
424 slot = ffs(input->mt.touches & ~(input->mt.ptr | tp->ignore)); in get_2nd_touch()
443 wstpad_scroll_coords(struct wsmouseinput *input, int *dx, int *dy) in wstpad_scroll_coords() argument
445 struct wstpad *tp = input->tp; in wstpad_scroll_coords()
452 if ((input->motion.sync & SYNC_POSITION) == 0) in wstpad_scroll_coords()
460 if (tp->scroll.dz || tp->scroll.dw || wstpad_is_stable(input, tp->t)) { in wstpad_scroll_coords()
461 *dx = normalize_rel(&input->filter.h, input->motion.pos.dx); in wstpad_scroll_coords()
462 *dy = normalize_rel(&input->filter.v, input->motion.pos.dy); in wstpad_scroll_coords()
475 * The function applies strong deceleration, but only to input with in wstpad_scroll()
523 wstpad_f2scroll(struct wsmouseinput *input, u_int *cmds) in wstpad_f2scroll() argument
525 struct wstpad *tp = input->tp; in wstpad_f2scroll()
532 } else if (tp->contacts != 3 || (tp->ignore == input->mt.ptr)) { in wstpad_f2scroll()
536 if (!wstpad_scroll_coords(input, &dx, &dy)) in wstpad_f2scroll()
548 t2 = get_2nd_touch(input); in wstpad_f2scroll()
556 if (!wstpad_is_stable(input, t2) && in wstpad_f2scroll()
563 magnitude(input, dx, dy), cmds); in wstpad_f2scroll()
570 wstpad_edgescroll(struct wsmouseinput *input, u_int *cmds) in wstpad_edgescroll() argument
572 struct wstpad *tp = input->tp; in wstpad_edgescroll()
577 if (!wstpad_scroll_coords(input, &dx, &dy) || tp->contacts != 1) in wstpad_edgescroll()
589 wstpad_scroll(tp, dx, dy, magnitude(input, dx, dy), cmds); in wstpad_edgescroll()
616 wstpad_get_sbtn(struct wsmouseinput *input, int top) in wstpad_get_sbtn() argument
618 struct wstpad *tp = input->tp; in wstpad_get_sbtn()
631 if ((t = get_2nd_touch(input)) != NULL) in wstpad_get_sbtn()
641 wstpad_mtbtn_contacts(struct wsmouseinput *input) in wstpad_mtbtn_contacts() argument
643 struct wstpad *tp = input->tp; in wstpad_mtbtn_contacts()
650 if (tp->contacts == 2 && (t = get_2nd_touch(input)) != NULL) { in wstpad_mtbtn_contacts()
655 if (input->mt.ptr_mask != 0) in wstpad_mtbtn_contacts()
664 wstpad_get_mtbtn(struct wsmouseinput *input) in wstpad_get_mtbtn() argument
666 int contacts = wstpad_mtbtn_contacts(input); in wstpad_get_mtbtn()
672 wstpad_softbuttons(struct wsmouseinput *input, u_int *cmds, int hdlr) in wstpad_softbuttons() argument
674 struct wstpad *tp = input->tp; in wstpad_softbuttons()
684 ? wstpad_get_mtbtn(input) : wstpad_get_sbtn(input, top)); in wstpad_softbuttons()
723 wstpad_tap_touch(struct wsmouseinput *input) in wstpad_tap_touch() argument
725 struct wstpad *tp = input->tp; in wstpad_tap_touch()
731 lifted = (input->mt.sync[MTS_TOUCH] & ~input->mt.touches); in wstpad_tap_touch()
780 wstpad_tap(struct wsmouseinput *input, u_int *cmds) in wstpad_tap() argument
782 struct wstpad *tp = input->tp; in wstpad_tap()
787 if (input->btn.sync) in wstpad_tap()
799 (input->mt.touches & input->mt.sync[MTS_TOUCH]))) { in wstpad_tap()
809 if ((slot = ffs(input->mt.ptr_mask) - 1) >= 0 in wstpad_tap()
818 t = wstpad_tap_touch(input); in wstpad_tap()
870 t = wstpad_tap_touch(input); in wstpad_tap()
885 input->sbtn.buttons &= ~tp->tap.button; in wstpad_tap()
886 input->sbtn.sync |= tp->tap.button; in wstpad_tap()
894 wstpad_tap_sync(struct wsmouseinput *input) { in wstpad_tap_sync() argument
895 struct wstpad *tp = input->tp; in wstpad_tap_sync()
897 return ((tp->tap.button & (input->btn.buttons | tp->softbutton)) == 0 in wstpad_tap_sync()
904 struct wsmouseinput *input = p; in wstpad_tap_timeout() local
905 struct wstpad *tp = input->tp; in wstpad_tap_timeout()
911 evq.evar = *input->evar; in wstpad_tap_timeout()
917 input->sbtn.buttons |= tp->tap.button; in wstpad_tap_timeout()
919 if (wstpad_tap_sync(input)) { in wstpad_tap_timeout()
924 if (wstpad_tap_sync(input)) { in wstpad_tap_timeout()
929 input->sbtn.buttons &= ~tp->tap.button; in wstpad_tap_timeout()
940 if (input->flags & LOG_EVENTS) { in wstpad_tap_timeout()
941 wsmouse_log_events(input, &evq); in wstpad_tap_timeout()
946 input->sbtn.sync |= tp->tap.button; in wstpad_tap_timeout()
957 wstpad_click(struct wsmouseinput *input) in wstpad_click() argument
959 struct wstpad *tp = input->tp; in wstpad_click()
968 wstpad_cmds(struct wsmouseinput *input, u_int cmds) in wstpad_cmds() argument
970 struct wstpad *tp = input->tp; in wstpad_cmds()
976 input->motion.dx = input->motion.dy = 0; in wstpad_cmds()
977 if (input->motion.dz == 0 && input->motion.dw == 0) in wstpad_cmds()
978 input->motion.sync &= ~SYNC_DELTAS; in wstpad_cmds()
981 input->btn.sync &= ~PRIMARYBTN; in wstpad_cmds()
982 input->sbtn.buttons |= tp->softbutton; in wstpad_cmds()
984 input->sbtn.sync |= tp->softbutton; in wstpad_cmds()
987 input->btn.sync &= ~PRIMARYBTN; in wstpad_cmds()
989 input->sbtn.buttons &= ~tp->softbutton; in wstpad_cmds()
990 input->sbtn.sync |= tp->softbutton; in wstpad_cmds()
996 input->btn.sync &= ~tp->tap.button; in wstpad_cmds()
1001 input->sbtn.buttons |= tp->tap.button; in wstpad_cmds()
1002 if (wstpad_tap_sync(input)) in wstpad_cmds()
1003 input->sbtn.sync |= tp->tap.button; in wstpad_cmds()
1007 input->sbtn.buttons &= ~tp->tap.button; in wstpad_cmds()
1008 if (wstpad_tap_sync(input)) in wstpad_cmds()
1009 input->sbtn.sync |= tp->tap.button; in wstpad_cmds()
1013 input->motion.dw = tp->scroll.dw; in wstpad_cmds()
1014 input->motion.sync |= SYNC_DELTAS; in wstpad_cmds()
1017 input->motion.dz = tp->scroll.dz; in wstpad_cmds()
1018 input->motion.sync |= SYNC_DELTAS; in wstpad_cmds()
1033 clear_touchstates(struct wsmouseinput *input, enum touchstates state) in clear_touchstates() argument
1038 touches = input->mt.sync[MTS_TOUCH] & ~input->mt.touches; in clear_touchstates()
1040 input->tp->tpad_touches[slot].state = state; in clear_touchstates()
1044 wstpad_mt_inputs(struct wsmouseinput *input) in wstpad_mt_inputs() argument
1046 struct wstpad *tp = input->tp; in wstpad_mt_inputs()
1052 touches = input->mt.touches & input->mt.sync[MTS_TOUCH]; in wstpad_mt_inputs()
1056 t->x = normalize_abs(&input->filter.h, t->pos->x); in wstpad_mt_inputs()
1057 t->y = normalize_abs(&input->filter.v, t->pos->y); in wstpad_mt_inputs()
1066 touches = input->mt.touches & input->mt.frame; in wstpad_mt_inputs()
1073 inactive = input->mt.touches & ~tp->mtcycle; in wstpad_mt_inputs()
1079 touches = input->mt.touches & ~input->mt.sync[MTS_TOUCH]; in wstpad_mt_inputs()
1083 if ((1 << slot) & input->mt.frame) { in wstpad_mt_inputs()
1084 dx = normalize_abs(&input->filter.h, t->pos->x) - t->x; in wstpad_mt_inputs()
1086 dy = normalize_abs(&input->filter.v, t->pos->y) - t->y; in wstpad_mt_inputs()
1089 if (wsmouse_hysteresis(input, t->pos)) in wstpad_mt_inputs()
1097 clear_touchstates(input, TOUCH_END); in wstpad_mt_inputs()
1122 wstpad_mt_masks(struct wsmouseinput *input) in wstpad_mt_masks() argument
1124 struct wstpad *tp = input->tp; in wstpad_mt_masks()
1130 tp->ignore &= input->mt.touches; in wstpad_mt_masks()
1140 if (t->dir < 0 && wstpad_is_stable(input, t)) { in wstpad_mt_masks()
1146 magnitude(input, t->pos->dx, t->pos->dy) >= MAG_MEDIUM)) in wstpad_mt_masks()
1151 if (input->mt.ptr_mask == 0) { in wstpad_mt_masks()
1153 FOREACHBIT(input->mt.touches, slot) { in wstpad_mt_masks()
1157 input->mt.ptr_mask = mask; in wstpad_mt_masks()
1162 if ((input->mt.ptr_mask & ~input->mt.ptr) in wstpad_mt_masks()
1165 && wstpad_is_stable(input, tp->t)) { in wstpad_mt_masks()
1167 slot = ffs(input->mt.ptr_mask) - 1; in wstpad_mt_masks()
1173 if (!wstpad_is_stable(input, t)) in wstpad_mt_masks()
1178 if (abs(pos->acc_dx) < 3 * input->filter.h.hysteresis in wstpad_mt_masks()
1179 && abs(pos->acc_dy) < 3 * input->filter.v.hysteresis) in wstpad_mt_masks()
1184 if (magnitude(input, t->pos->dx, t->pos->dy) > MAG_LOW in wstpad_mt_masks()
1185 || magnitude(input, pos->dx, pos->dy) < MAG_MEDIUM) in wstpad_mt_masks()
1189 tp->ignore = input->mt.ptr_mask; in wstpad_mt_masks()
1194 wstpad_touch_inputs(struct wsmouseinput *input) in wstpad_touch_inputs() argument
1196 struct wstpad *tp = input->tp; in wstpad_touch_inputs()
1200 tp->btns = input->btn.buttons; in wstpad_touch_inputs()
1201 tp->btns_sync = input->btn.sync; in wstpad_touch_inputs()
1204 tp->contacts = input->touch.contacts; in wstpad_touch_inputs()
1208 input->touch.width >= tp->params.f2width) in wstpad_touch_inputs()
1210 input->touch.pressure >= tp->params.f2pressure))) in wstpad_touch_inputs()
1214 wstpad_mt_inputs(input); in wstpad_touch_inputs()
1215 if (input->mt.ptr) { in wstpad_touch_inputs()
1216 slot = ffs(input->mt.ptr) - 1; in wstpad_touch_inputs()
1219 wstpad_mt_masks(input); in wstpad_touch_inputs()
1230 x = normalize_abs(&input->filter.h, t->pos->x); in wstpad_touch_inputs()
1231 y = normalize_abs(&input->filter.v, t->pos->y); in wstpad_touch_inputs()
1238 } else if (input->motion.sync & SYNC_POSITION) { in wstpad_touch_inputs()
1239 if (!wsmouse_hysteresis(input, t->pos)) { in wstpad_touch_inputs()
1252 t2_ignore(struct wsmouseinput *input) in t2_ignore() argument
1259 return (input->tp->contacts == 2 && ((input->tp->btns & PRIMARYBTN) in t2_ignore()
1260 || (input->tp->ignore & ~input->mt.ptr))); in t2_ignore()
1264 wstpad_process_input(struct wsmouseinput *input, struct evq_access *evq) in wstpad_process_input() argument
1266 struct wstpad *tp = input->tp; in wstpad_process_input()
1270 wstpad_touch_inputs(input); in wstpad_process_input()
1281 wstpad_softbuttons(input, &cmds, hdlr); in wstpad_process_input()
1284 wstpad_tap(input, &cmds); in wstpad_process_input()
1287 wstpad_f2scroll(input, &cmds); in wstpad_process_input()
1290 wstpad_edgescroll(input, &cmds); in wstpad_process_input()
1293 wstpad_click(input); in wstpad_process_input()
1299 if (input->motion.dx || input->motion.dy) { in wstpad_process_input()
1303 || (tp->contacts > 1 && !t2_ignore(input))) { in wstpad_process_input()
1309 wstpad_cmds(input, cmds); in wstpad_process_input()
1312 clear_touchstates(input, TOUCH_NONE); in wstpad_process_input()
1324 wstpad_track_interval(struct wsmouseinput *input, struct timespec *time) in wstpad_track_interval() argument
1330 if (input->motion.sync == 0 in wstpad_track_interval()
1331 || (input->touch.sync & SYNC_CONTACTS) in wstpad_track_interval()
1332 || (input->touch.contacts > 1)) { in wstpad_track_interval()
1333 input->intv.track = 0; in wstpad_track_interval()
1336 if (input->intv.track) { in wstpad_track_interval()
1337 timespecsub(time, &input->intv.ts, &ts); in wstpad_track_interval()
1340 input->intv.sum += ts.tv_nsec >> 12; in wstpad_track_interval()
1341 samples = ++input->intv.samples; in wstpad_track_interval()
1347 input->intv.avg = input->intv.sum << 9; in wstpad_track_interval()
1348 wstpad_init_deceleration(input); in wstpad_track_interval()
1350 input->intv.avg = input->intv.sum << 5; in wstpad_track_interval()
1351 wstpad_init_deceleration(input); in wstpad_track_interval()
1352 input->intv.samples = 0; in wstpad_track_interval()
1353 input->intv.sum = 0; in wstpad_track_interval()
1354 input->flags &= ~TRACK_INTERVAL; in wstpad_track_interval()
1358 memcpy(&input->intv.ts, time, sizeof(struct timespec)); in wstpad_track_interval()
1359 input->intv.track = 1; in wstpad_track_interval()
1376 wstpad_decelerate(struct wsmouseinput *input, int *dx, int *dy) in wstpad_decelerate() argument
1380 mag = magnitude(input, *dx, *dy); in wstpad_decelerate()
1383 mag = (mag + 7 * input->filter.mag) / 8; in wstpad_decelerate()
1385 input->filter.mag = imin(mag, 24 << 12); in wstpad_decelerate()
1390 h = *dx * n + input->filter.h.dclr_rmdr; in wstpad_decelerate()
1391 v = *dy * n + input->filter.v.dclr_rmdr; in wstpad_decelerate()
1392 input->filter.h.dclr_rmdr = (h >= 0 ? h & 7 : -(-h & 7)); in wstpad_decelerate()
1393 input->filter.v.dclr_rmdr = (v >= 0 ? v & 7 : -(-v & 7)); in wstpad_decelerate()
1402 wstpad_filter(struct wsmouseinput *input) in wstpad_filter() argument
1404 struct axis_filter *h = &input->filter.h; in wstpad_filter()
1405 struct axis_filter *v = &input->filter.v; in wstpad_filter()
1406 struct position *pos = &input->motion.pos; in wstpad_filter()
1407 int strength = input->filter.mode & 7; in wstpad_filter()
1410 if (!(input->motion.sync & SYNC_POSITION) in wstpad_filter()
1419 if (wsmouse_hysteresis(input, pos)) in wstpad_filter()
1422 if (input->filter.dclr && wstpad_decelerate(input, &dx, &dy)) in wstpad_filter()
1427 if ((input->touch.sync & SYNC_CONTACTS) in wstpad_filter()
1428 || input->mt.ptr != input->mt.prev_ptr) { in wstpad_filter()
1440 input->motion.dx = dx; in wstpad_filter()
1441 input->motion.dy = dy; in wstpad_filter()
1451 wstpad_compat_convert(struct wsmouseinput *input, struct evq_access *evq) in wstpad_compat_convert() argument
1453 if (input->flags & TRACK_INTERVAL) in wstpad_compat_convert()
1454 wstpad_track_interval(input, &evq->ts); in wstpad_compat_convert()
1456 wstpad_filter(input); in wstpad_compat_convert()
1458 if ((input->motion.dx || input->motion.dy) in wstpad_compat_convert()
1459 && !(input->motion.sync & SYNC_DELTAS)) { in wstpad_compat_convert()
1460 input->motion.dz = input->motion.dw = 0; in wstpad_compat_convert()
1461 input->motion.sync |= SYNC_DELTAS; in wstpad_compat_convert()
1464 if (input->tp != NULL) in wstpad_compat_convert()
1465 wstpad_process_input(input, evq); in wstpad_compat_convert()
1467 input->motion.sync &= ~SYNC_POSITION; in wstpad_compat_convert()
1468 input->touch.sync = 0; in wstpad_compat_convert()
1472 wstpad_init(struct wsmouseinput *input) in wstpad_init() argument
1474 struct wstpad *tp = input->tp; in wstpad_init()
1480 input->tp = tp = malloc(sizeof(struct wstpad), in wstpad_init()
1485 slots = imax(input->mt.num_slots, 1); in wstpad_init()
1494 if (input->mt.num_slots) { in wstpad_init()
1496 for (i = 0; i < input->mt.num_slots; i++) in wstpad_init()
1497 tp->tpad_touches[i].pos = &input->mt.slots[i].pos; in wstpad_init()
1499 tp->t->pos = &input->motion.pos; in wstpad_init()
1502 timeout_set(&tp->tap.to, wstpad_tap_timeout, input); in wstpad_init()
1504 tp->ratio = input->filter.ratio; in wstpad_init()
1538 wstpad_init_deceleration(struct wsmouseinput *input) in wstpad_init_deceleration() argument
1542 if ((dclr = input->filter.dclr) == 0) in wstpad_init_deceleration()
1553 if (input->intv.avg == 0) { in wstpad_init_deceleration()
1556 n = 8 * 13000000 / input->intv.avg; in wstpad_init_deceleration()
1559 input->filter.h.mag_scale = (n << 12) / dclr; in wstpad_init_deceleration()
1560 input->filter.v.mag_scale = (input->filter.ratio ? in wstpad_init_deceleration()
1561 n * input->filter.ratio : n << 12) / dclr; in wstpad_init_deceleration()
1562 input->filter.h.dclr_rmdr = 0; in wstpad_init_deceleration()
1563 input->filter.v.dclr_rmdr = 0; in wstpad_init_deceleration()
1564 input->flags |= TRACK_INTERVAL; in wstpad_init_deceleration()
1568 wstpad_configure(struct wsmouseinput *input) in wstpad_configure() argument
1573 width = abs(input->hw.x_max - input->hw.x_min); in wstpad_configure()
1574 height = abs(input->hw.y_max - input->hw.y_min); in wstpad_configure()
1578 if (input->tp == NULL && wstpad_init(input)) in wstpad_configure()
1580 tp = input->tp; in wstpad_configure()
1582 if (!(input->flags & CONFIGURED)) { in wstpad_configure()
1591 h_res = input->hw.h_res; in wstpad_configure()
1592 v_res = input->hw.v_res; in wstpad_configure()
1596 input->filter.h.scale = (imin(920, diag) << 12) / diag; in wstpad_configure()
1597 input->filter.v.scale = input->filter.h.scale * h_res / v_res; in wstpad_configure()
1600 input->filter.h.hysteresis = h_unit; in wstpad_configure()
1601 input->filter.v.hysteresis = v_unit; in wstpad_configure()
1602 input->filter.mode = FILTER_MODE_DEFAULT; in wstpad_configure()
1603 input->filter.dclr = h_unit - h_unit / 5; in wstpad_configure()
1604 wstpad_init_deceleration(input); in wstpad_configure()
1608 if (input->hw.contacts_max != 1) in wstpad_configure()
1613 if (input->hw.hw_type == WSMOUSEHW_CLICKPAD) { in wstpad_configure()
1614 if (input->hw.type == WSMOUSE_TYPE_SYNAP_SBTN) { in wstpad_configure()
1639 input->hw.hw_type == WSMOUSEHW_CLICKPAD && in wstpad_configure()
1652 tp->edge.left = (offset ? input->hw.x_min + offset : INT_MIN); in wstpad_configure()
1654 tp->edge.right = (offset ? input->hw.x_max - offset : INT_MAX); in wstpad_configure()
1656 tp->edge.bottom = (offset ? input->hw.y_min + offset : INT_MIN); in wstpad_configure()
1659 tp->edge.top = (offset ? input->hw.y_max - offset : INT_MAX); in wstpad_configure()
1662 tp->edge.center = input->hw.x_min + width / 2; in wstpad_configure()
1701 if (input->hw.hw_type == WSMOUSEHW_CLICKPAD) in wstpad_configure()
1711 wstpad_reset(struct wsmouseinput *input) in wstpad_reset() argument
1713 struct wstpad *tp = input->tp; in wstpad_reset()
1720 if (input->sbtn.buttons) { in wstpad_reset()
1721 input->sbtn.sync = input->sbtn.buttons; in wstpad_reset()
1722 input->sbtn.buttons = 0; in wstpad_reset()
1727 wstpad_cleanup(struct wsmouseinput *input) in wstpad_cleanup() argument
1729 struct wstpad *tp = input->tp; in wstpad_cleanup()
1733 slots = imax(input->mt.num_slots, 1); in wstpad_cleanup()
1736 input->tp = NULL; in wstpad_cleanup()
1740 wstpad_set_param(struct wsmouseinput *input, int key, int val) in wstpad_set_param() argument
1742 struct wstpad *tp = input->tp; in wstpad_set_param()
1841 wstpad_get_param(struct wsmouseinput *input, int key, int *pval) in wstpad_get_param() argument
1843 struct wstpad *tp = input->tp; in wstpad_get_param()