Lines Matching +full:high +full:- +full:resolution

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
51 #define CDEV_GET_SOFTC(x) (x)->si_drv1
153 sc->sc_dev = dev; in adb_mouse_attach()
155 mtx_init(&sc->sc_mtx, "ams", NULL, MTX_DEF); in adb_mouse_attach()
156 cv_init(&sc->sc_cv,"ams"); in adb_mouse_attach()
158 sc->flags = 0; in adb_mouse_attach()
160 sc->hw.buttons = 2; in adb_mouse_attach()
161 sc->hw.iftype = MOUSE_IF_UNKNOWN; in adb_mouse_attach()
162 sc->hw.type = MOUSE_UNKNOWN; in adb_mouse_attach()
163 sc->hw.model = sc->hw.hwid = 0; in adb_mouse_attach()
165 sc->mode.protocol = MOUSE_PROTO_SYSMOUSE; in adb_mouse_attach()
166 sc->mode.rate = -1; in adb_mouse_attach()
167 sc->mode.resolution = 100; in adb_mouse_attach()
168 sc->mode.accelfactor = 0; in adb_mouse_attach()
169 sc->mode.level = 0; in adb_mouse_attach()
170 sc->mode.packetsize = 5; in adb_mouse_attach()
172 sc->buttons = 0; in adb_mouse_attach()
173 sc->sc_tapping = 0; in adb_mouse_attach()
174 sc->button_buf = 0; in adb_mouse_attach()
175 sc->last_buttons = 0; in adb_mouse_attach()
176 sc->packet_read_len = 0; in adb_mouse_attach()
183 sc->mode.resolution = 100; in adb_mouse_attach()
186 sc->mode.resolution = 200; in adb_mouse_attach()
193 sc->flags |= AMS_EXTENDED; in adb_mouse_attach()
194 memcpy(&sc->hw.hwid,r1,4); in adb_mouse_attach()
195 sc->mode.resolution = (r1[4] << 8) | r1[5]; in adb_mouse_attach()
199 sc->hw.type = MOUSE_PAD; in adb_mouse_attach()
203 sc->hw.type = MOUSE_MOUSE; in adb_mouse_attach()
207 sc->hw.type = MOUSE_TRACKBALL; in adb_mouse_attach()
211 sc->flags |= AMS_TOUCHPAD; in adb_mouse_attach()
212 sc->hw.type = MOUSE_PAD; in adb_mouse_attach()
218 sc->hw.buttons = r1[7]; in adb_mouse_attach()
220 device_printf(dev,"%d-button %d-dpi %s\n", in adb_mouse_attach()
221 sc->hw.buttons, sc->mode.resolution,description); in adb_mouse_attach()
224 * Check for one of MacAlly's non-compliant 2-button mice. in adb_mouse_attach()
230 if (sc->hw.hwid == 0x4b4f4954) { in adb_mouse_attach()
234 device_printf(dev, "MacAlly 2-Button Mouse\n"); in adb_mouse_attach()
235 sc->flags &= ~AMS_EXTENDED; in adb_mouse_attach()
242 sc->cdev = make_dev(&ams_cdevsw, device_get_unit(dev), in adb_mouse_attach()
245 sc->cdev->si_drv1 = sc; in adb_mouse_attach()
260 destroy_dev(sc->cdev); in adb_mouse_detach()
262 mtx_destroy(&sc->sc_mtx); in adb_mouse_detach()
263 cv_destroy(&sc->sc_cv); in adb_mouse_detach()
298 "(non-Extended Mode)\n", r1[6]); in adb_init_trackpad()
353 if (sc->flags & AMS_EXTENDED) { in adb_mouse_receive_packet()
356 ydelta |= (data[i] & 0x70) << (3*i - 3); in adb_mouse_receive_packet()
358 buttons |= !(data[i] & 0x08) << (2*i - 2); in adb_mouse_receive_packet()
359 buttons |= !(data[i] & 0x80) << (2*i - 1); in adb_mouse_receive_packet()
366 if (xdelta & (0x40 << 3*(len-2))) in adb_mouse_receive_packet()
367 xdelta |= 0xffffffc0 << 3*(len - 2); in adb_mouse_receive_packet()
368 if (ydelta & (0x40 << 3*(len-2))) in adb_mouse_receive_packet()
369 ydelta |= 0xffffffc0 << 3*(len - 2); in adb_mouse_receive_packet()
371 if ((sc->flags & AMS_TOUCHPAD) && (sc->sc_tapping == 1)) { in adb_mouse_receive_packet()
380 sc->button_buf = tmp_buttons; in adb_mouse_receive_packet()
385 if (sc->button_buf != 0x3) in adb_mouse_receive_packet()
390 sc->button_buf = 0; in adb_mouse_receive_packet()
396 * Some mice report high-numbered buttons on the wrong button number, in adb_mouse_receive_packet()
397 * so set the highest-numbered real button as pressed if there are in adb_mouse_receive_packet()
398 * mysterious high-numbered ones set. in adb_mouse_receive_packet()
401 * high button events when they are touched. in adb_mouse_receive_packet()
404 if (rounddown2(buttons, 1 << sc->hw.buttons) in adb_mouse_receive_packet()
405 && !(sc->flags & AMS_TOUCHPAD)) { in adb_mouse_receive_packet()
406 buttons |= 1 << (sc->hw.buttons - 1); in adb_mouse_receive_packet()
408 buttons &= (1 << sc->hw.buttons) - 1; in adb_mouse_receive_packet()
410 mtx_lock(&sc->sc_mtx); in adb_mouse_receive_packet()
415 sc->xdelta += xdelta; in adb_mouse_receive_packet()
416 sc->ydelta -= ydelta; in adb_mouse_receive_packet()
418 sc->buttons = buttons; in adb_mouse_receive_packet()
420 mtx_unlock(&sc->sc_mtx); in adb_mouse_receive_packet()
422 cv_broadcast(&sc->sc_cv); in adb_mouse_receive_packet()
423 selwakeuppri(&sc->rsel, PZERO); in adb_mouse_receive_packet()
437 mtx_lock(&sc->sc_mtx); in ams_open()
438 sc->packet_read_len = 0; in ams_open()
439 sc->xdelta = 0; in ams_open()
440 sc->ydelta = 0; in ams_open()
441 sc->buttons = 0; in ams_open()
442 mtx_unlock(&sc->sc_mtx); in ams_open()
454 cv_broadcast(&sc->sc_cv); in ams_close()
455 selwakeuppri(&sc->rsel, PZERO); in ams_close()
469 mtx_lock(&sc->sc_mtx); in ams_poll()
471 if (sc->xdelta == 0 && sc->ydelta == 0 && in ams_poll()
472 sc->buttons == sc->last_buttons && in ams_poll()
473 sc->packet_read_len == 0) { in ams_poll()
474 selrecord(p, &sc->rsel); in ams_poll()
480 mtx_unlock(&sc->sc_mtx); in ams_poll()
498 if (uio->uio_resid <= 0) in ams_read()
501 mtx_lock(&sc->sc_mtx); in ams_read()
503 if (!sc->packet_read_len) { in ams_read()
504 if (sc->xdelta == 0 && sc->ydelta == 0 && in ams_read()
505 sc->buttons == sc->last_buttons) { in ams_read()
507 mtx_unlock(&sc->sc_mtx); in ams_read()
512 error = cv_wait_sig(&sc->sc_cv, &sc->sc_mtx); in ams_read()
514 mtx_unlock(&sc->sc_mtx); in ams_read()
519 sc->packet[0] = 1U << 7; in ams_read()
520 sc->packet[0] |= (!(sc->buttons & 1)) << 2; in ams_read()
521 sc->packet[0] |= (!(sc->buttons & 4)) << 1; in ams_read()
522 sc->packet[0] |= (!(sc->buttons & 2)); in ams_read()
524 if (sc->xdelta > 127) { in ams_read()
525 sc->packet[1] = 127; in ams_read()
526 sc->packet[3] = sc->xdelta - 127; in ams_read()
527 } else if (sc->xdelta < -127) { in ams_read()
528 sc->packet[1] = -127; in ams_read()
529 sc->packet[3] = sc->xdelta + 127; in ams_read()
531 sc->packet[1] = sc->xdelta; in ams_read()
532 sc->packet[3] = 0; in ams_read()
535 if (sc->ydelta > 127) { in ams_read()
536 sc->packet[2] = 127; in ams_read()
537 sc->packet[4] = sc->ydelta - 127; in ams_read()
538 } else if (sc->ydelta < -127) { in ams_read()
539 sc->packet[2] = -127; in ams_read()
540 sc->packet[4] = sc->ydelta + 127; in ams_read()
542 sc->packet[2] = sc->ydelta; in ams_read()
543 sc->packet[4] = 0; in ams_read()
547 sc->packet[5] = 0; in ams_read()
548 sc->packet[6] = 0; in ams_read()
550 sc->packet[7] = ~((uint8_t)(sc->buttons >> 3)) & 0x7f; in ams_read()
552 sc->last_buttons = sc->buttons; in ams_read()
553 sc->xdelta = 0; in ams_read()
554 sc->ydelta = 0; in ams_read()
556 sc->packet_read_len = sc->mode.packetsize; in ams_read()
559 len = (sc->packet_read_len > uio->uio_resid) ? in ams_read()
560 uio->uio_resid : sc->packet_read_len; in ams_read()
562 memcpy(outpacket,sc->packet + in ams_read()
563 (sc->mode.packetsize - sc->packet_read_len),len); in ams_read()
564 sc->packet_read_len -= len; in ams_read()
566 mtx_unlock(&sc->sc_mtx); in ams_read()
586 *(mousehw_t *)addr = sc->hw; in ams_ioctl()
589 *(mousemode_t *)addr = sc->mode; in ams_ioctl()
598 if (*(int *)addr == -1) in ams_ioctl()
601 sc->mode.level = 1; in ams_ioctl()
602 sc->mode.packetsize = 8; in ams_ioctl()
605 sc->mode.level = 0; in ams_ioctl()
606 sc->mode.packetsize = 5; in ams_ioctl()
612 *(int *)addr = sc->mode.level; in ams_ioctl()
618 mtx_lock(&sc->sc_mtx); in ams_ioctl()
620 status->button = sc->buttons; in ams_ioctl()
621 status->obutton = sc->last_buttons; in ams_ioctl()
623 status->flags = status->button ^ status->obutton; in ams_ioctl()
625 if (sc->xdelta != 0 || sc->ydelta) in ams_ioctl()
626 status->flags |= MOUSE_POSCHANGED; in ams_ioctl()
627 if (status->button != status->obutton) in ams_ioctl()
628 status->flags |= MOUSE_BUTTONSCHANGED; in ams_ioctl()
630 status->dx = sc->xdelta; in ams_ioctl()
631 status->dy = sc->ydelta; in ams_ioctl()
632 status->dz = 0; in ams_ioctl()
634 sc->xdelta = 0; in ams_ioctl()
635 sc->ydelta = 0; in ams_ioctl()
636 sc->last_buttons = sc->buttons; in ams_ioctl()
638 mtx_unlock(&sc->sc_mtx); in ams_ioctl()
656 dev = sc->sc_dev; in adb_tapping_sysctl()
657 tapping = sc->sc_tapping; in adb_tapping_sysctl()
661 if (error || !req->newptr) in adb_tapping_sysctl()
668 sc->sc_tapping = 1; in adb_tapping_sysctl()
673 sc->sc_tapping = 0; in adb_tapping_sysctl()