static int adb_kbd_probe(device_t dev) { uint8_t type; type = adb_get_device_type(dev); if (type != ADB_DEVICE_KEYBOARD) return (ENXIO); switch(adb_get_device_handler(dev)) { case 1: device_set_desc(dev,"Apple Standard Keyboard"); break; case 2: device_set_desc(dev,"Apple Extended Keyboard"); break; case 4: device_set_desc(dev,"Apple ISO Keyboard"); break; case 5: device_set_desc(dev,"Apple Extended ISO Keyboard"); break; case 8: device_set_desc(dev,"Apple Keyboard II"); break; case 9: device_set_desc(dev,"Apple ISO Keyboard II"); break; case 12: device_set_desc(dev,"PowerBook Keyboard"); break; case 13: device_set_desc(dev,"PowerBook ISO Keyboard"); break; case 24: device_set_desc(dev,"PowerBook Extended Keyboard"); break; case 27: device_set_desc(dev,"Apple Design Keyboard"); break; case 195: device_set_desc(dev,"PowerBook G3 Keyboard"); break; case 196: device_set_desc(dev,"iBook Keyboard"); break; default: device_set_desc(dev,"ADB Keyboard"); break; } return (0); }
static int abtn_attach(device_t dev) { struct abtn_softc *sc; sc = device_get_softc(dev); sc->sc_dev = dev; sc->handler_id = adb_get_device_handler(dev); return 0; }
static int adb_mouse_attach(device_t dev) { struct adb_mouse_softc *sc; char *description = "Unknown Pointing Device"; size_t r1_len; u_char r1[8]; sc = device_get_softc(dev); sc->sc_dev = dev; mtx_init(&sc->sc_mtx, "ams", NULL, MTX_DEF); cv_init(&sc->sc_cv,"ams"); sc->flags = 0; sc->hw.buttons = 2; sc->hw.iftype = MOUSE_IF_UNKNOWN; sc->hw.type = MOUSE_UNKNOWN; sc->hw.model = sc->hw.hwid = 0; sc->mode.protocol = MOUSE_PROTO_SYSMOUSE; sc->mode.rate = -1; sc->mode.resolution = 100; sc->mode.accelfactor = 0; sc->mode.level = 0; sc->mode.packetsize = 5; sc->buttons = 0; sc->sc_tapping = 0; sc->button_buf = 0; sc->last_buttons = 0; sc->packet_read_len = 0; /* Try to switch to extended protocol */ adb_set_device_handler(dev,4); switch(adb_get_device_handler(dev)) { case 1: sc->mode.resolution = 100; break; case 2: sc->mode.resolution = 200; break; case 4: r1_len = adb_read_register(dev,1,r1); if (r1_len < 8) break; sc->flags |= AMS_EXTENDED; memcpy(&sc->hw.hwid,r1,4); sc->mode.resolution = (r1[4] << 8) | r1[5]; switch (r1[6]) { case 0: sc->hw.type = MOUSE_PAD; description = "Tablet"; break; case 1: sc->hw.type = MOUSE_MOUSE; description = "Mouse"; break; case 2: sc->hw.type = MOUSE_TRACKBALL; description = "Trackball"; break; case 3: sc->flags |= AMS_TOUCHPAD; sc->hw.type = MOUSE_PAD; adb_init_trackpad(dev); description = "Touchpad"; break; } sc->hw.buttons = r1[7]; device_printf(dev,"%d-button %d-dpi %s\n", sc->hw.buttons, sc->mode.resolution,description); /* * Check for one of MacAlly's non-compliant 2-button mice. * These claim to speak the extended mouse protocol, but * instead speak the standard protocol and only when their * handler is set to 0x42. */ if (sc->hw.hwid == 0x4b4f4954) { adb_set_device_handler(dev,0x42); if (adb_get_device_handler(dev) == 0x42) { device_printf(dev, "MacAlly 2-Button Mouse\n"); sc->flags &= ~AMS_EXTENDED; } } break; } sc->cdev = make_dev(&ams_cdevsw, device_get_unit(dev), UID_ROOT, GID_OPERATOR, 0644, "ams%d", device_get_unit(dev)); sc->cdev->si_drv1 = sc; adb_set_autopoll(dev,1); return (0); }