int qsckbd_cnattach(u_int line) { qsckbd_console_internal.dzi_ks.attmt.sendchar = qsckbd_sendchar; qsckbd_console_internal.dzi_ks.attmt.cookie = (void *)line; lk201_init(&qsckbd_console_internal.dzi_ks); qsckbd_console_internal.dzi_line = line; wskbd_cnattach(&qsckbd_consops, &qsckbd_console_internal, &qsckbd_keymapdata); return 0; }
int dzkbd_cnattach(struct dz_linestate *ls) { dzkbd_console_internal.dzi_ks.attmt.sendchar = dzkbd_sendchar; dzkbd_console_internal.dzi_ks.attmt.cookie = ls; lk201_init(&dzkbd_console_internal.dzi_ks); dzkbd_console_internal.dzi_ls = ls; wskbd_cnattach(&dzkbd_consops, &dzkbd_console_internal, &dzkbd_keymapdata); return 0; }
static void dzkbd_attach(struct device *parent, struct device *self, void *aux) { struct dz_softc *dz = device_private(parent); struct dzkbd_softc *dzkbd = device_private(self); struct dzkm_attach_args *daa = aux; struct dz_linestate *ls; struct dzkbd_internal *dzi; struct wskbddev_attach_args a; int isconsole; dz->sc_dz[daa->daa_line].dz_catch = dzkbd_input; dz->sc_dz[daa->daa_line].dz_private = dzkbd; ls = &dz->sc_dz[daa->daa_line]; isconsole = (daa->daa_flags & DZKBD_CONSOLE); if (isconsole) { dzi = &dzkbd_console_internal; } else { dzi = malloc(sizeof(struct dzkbd_internal), M_DEVBUF, M_NOWAIT); dzi->dzi_ks.attmt.sendchar = dzkbd_sendchar; dzi->dzi_ks.attmt.cookie = ls; } dzi->dzi_ls = ls; dzkbd->sc_itl = dzi; printf("\n"); if (!isconsole) { DELAY(100000); lk201_init(&dzi->dzi_ks); } /* XXX should identify keyboard ID here XXX */ /* XXX layout and the number of LED is varying XXX */ dzkbd->kbd_type = WSKBD_TYPE_LK201; dzkbd->sc_enabled = 1; a.console = isconsole; a.keymap = &dzkbd_keymapdata; a.accessops = &dzkbd_accessops; a.accesscookie = dzkbd; dzkbd->sc_wskbddev = config_found(self, &a, wskbddevprint); }
void dzkbd_attach(struct device *parent, struct device *self, void *aux) { struct dz_softc *dz = (void *)parent; struct dzkbd_softc *dzkbd = (void *)self; struct dzkm_attach_args *daa = aux; struct dz_linestate *ls; struct dzkbd_internal *dzi; struct wskbddev_attach_args a; int isconsole; dz->sc_dz[daa->daa_line].dz_catch = dzkbd_input; dz->sc_dz[daa->daa_line].dz_private = dzkbd; ls = &dz->sc_dz[daa->daa_line]; isconsole = (daa->daa_flags & DZKBD_CONSOLE); if (isconsole) { dzi = &dzkbd_console_internal; dzkbd->sc_enabled = 1; } else { dzi = malloc(sizeof(struct dzkbd_internal), M_DEVBUF, M_NOWAIT); if (dzi == NULL) { printf(": out of memory\n"); return; } dzi->dzi_ks.attmt.sendchar = dzkbd_sendchar; dzi->dzi_ks.attmt.cookie = ls; } dzi->dzi_ks.device = self; dzi->dzi_ls = ls; dzkbd->sc_itl = dzi; printf("\n"); if (!isconsole) lk201_init(&dzi->dzi_ks); a.console = dzi == &dzkbd_console_internal; a.keymap = &dzkbd_keymapdata; a.accessops = &dzkbd_accessops; a.accesscookie = dzkbd; dzkbd->sc_wskbddev = config_found(self, &a, wskbddevprint); }
void qsckbd_attach(struct device *parent, struct device *self, void *aux) { struct qsckbd_softc *sc = (void *)self; struct qsc_attach_args *qa = aux; struct qsckbd_internal *dzi; struct wskbddev_attach_args a; int isconsole; qa->qa_hook->fn = qsckbd_input; qa->qa_hook->arg = self; isconsole = qa->qa_console; if (isconsole) { dzi = &qsckbd_console_internal; sc->sc_enabled = 1; } else { dzi = malloc(sizeof(struct qsckbd_internal), M_DEVBUF, M_NOWAIT); if (dzi == NULL) { printf(": out of memory\n"); return; } dzi->dzi_ks.attmt.sendchar = qsckbd_sendchar; dzi->dzi_ks.attmt.cookie = (void *)qa->qa_line; } dzi->dzi_ks.device = self; dzi->dzi_line = qa->qa_line; sc->sc_itl = dzi; printf("\n"); if (!isconsole) lk201_init(&dzi->dzi_ks); a.console = dzi == &qsckbd_console_internal; a.keymap = &qsckbd_keymapdata; a.accessops = &qsckbd_accessops; a.accesscookie = sc; sc->sc_wskbddev = config_found(self, &a, wskbddevprint); }
int dzkbd_cnattach() { /* * Early operation (especially keyboard initialization) * requires the help of the serial console routines, which * need to be initialized to work with the keyboard line. */ dzcninit_internal(0, 1); dzkbd_console_internal.dzi_ks.attmt.sendchar = dzkbd_sendchar; dzkbd_console_internal.dzi_ks.attmt.cookie = NULL; lk201_init(&dzkbd_console_internal.dzi_ks); dzkbd_console_internal.dzi_ls = NULL; wskbd_cnattach(&dzkbd_consops, &dzkbd_console_internal, &dzkbd_keymapdata); return 0; }
int lk201_decode(struct lk201_state *lks, int wantmulti, int datain, u_int *type, int *dataout) { int i, freeslot; if (lks->waitack != 0) { lks->ackdata = datain; lks->waitack = 0; return LKD_NODATA; } switch (datain) { #if 0 case LK_KEY_UP: for (i = 0; i < LK_KLL; i++) lks->down_keys_list[i] = -1; *type = WSCONS_EVENT_ALL_KEYS_UP; return (1); #endif case LK_POWER_UP: printf("lk201_decode: powerup detected\n"); lk201_init(lks); return (0); case LK_KDOWN_ERROR: case LK_POWER_ERROR: case LK_OUTPUT_ERROR: case LK_INPUT_ERROR: printf("lk201_decode: error %x\n", datain); /* FALLTHRU */ case LK_KEY_REPEAT: /* autorepeat handled by wskbd */ case LK_MODE_CHANGE: /* ignore silently */ return (0); } if (datain == LK_KEY_UP) { if (wantmulti) { for (i = 0; i < LK_KLL; i++) if (lks->down_keys_list[i] != -1) { *type = WSCONS_EVENT_KEY_UP; *dataout = lks->down_keys_list[i] - MIN_LK201_KEY; lks->down_keys_list[i] = -1; return (LKD_MORE); } return (LKD_NODATA); } else { for (i = 0; i < LK_KLL; i++) lks->down_keys_list[i] = -1; *type = WSCONS_EVENT_ALL_KEYS_UP; return (LKD_COMPLETE); } } else if (datain < MIN_LK201_KEY || datain > MAX_LK201_KEY) { printf("lk201_decode: %x\n", datain); return (0); } *dataout = datain - MIN_LK201_KEY; freeslot = -1; for (i = 0; i < LK_KLL; i++) { if (lks->down_keys_list[i] == datain) { *type = WSCONS_EVENT_KEY_UP; lks->down_keys_list[i] = -1; return (1); } if (lks->down_keys_list[i] == -1 && freeslot == -1) freeslot = i; } if (freeslot == -1) { printf("lk201_decode: down(%d) no free slot\n", datain); return (0); } *type = WSCONS_EVENT_KEY_DOWN; lks->down_keys_list[freeslot] = datain; return (1); }
int lk201_decode(struct lk201_state *lks, int active, int wantmulti, int datain, u_int *type, int *dataout) { int i, freeslot; if (lks->waitack != 0) { lks->ackdata = datain; lks->waitack = 0; return (LKD_NODATA); } switch (datain) { case LK_POWER_UP: #ifdef DEBUG printf("lk201_decode: powerup detected\n"); #endif lk201_init(lks); return (LKD_NODATA); case LK_KDOWN_ERROR: case LK_POWER_ERROR: case LK_OUTPUT_ERROR: case LK_INPUT_ERROR: printf("lk201_decode: error %x\n", datain); /* FALLTHROUGH */ case LK_KEY_REPEAT: /* autorepeat handled by wskbd */ case LK_MODE_CHANGE: /* ignore silently */ return (LKD_NODATA); } if (active == 0) return (LKD_NODATA); /* no need to decode */ if (datain == LK_KEY_UP) { if (wantmulti) { for (i = 0; i < LK_KLL; i++) if (lks->down_keys_list[i] != -1) { *type = WSCONS_EVENT_KEY_UP; *dataout = lks->down_keys_list[i] - MIN_LK201_KEY; lks->down_keys_list[i] = -1; return (LKD_MORE); } return (LKD_NODATA); } else { for (i = 0; i < LK_KLL; i++) lks->down_keys_list[i] = -1; *type = WSCONS_EVENT_ALL_KEYS_UP; return (LKD_COMPLETE); } } else if (datain < MIN_LK201_KEY || datain > MAX_LK201_KEY) { #ifdef DEBUG /* this can happen while hotplugging the keyboard */ printf("lk201_decode: %x\n", datain); #endif return (LKD_NODATA); } /* * The LK-201 keyboard has a compose key (to the left of the spacebar), * but no alt/meta key at all. The LK-401 keyboard fixes this and has * two compose keys and two alt keys. * * If the keyboard is an LK-201, translate the left compose key * scancode to a specific key code, which will map as a left alt key, * and compose key when shifted), so that the user can have both * an alt and a compose key available. */ if (lks->kbdtype == KBD_LK201 && datain == 177) datain = 252; *dataout = datain - MIN_LK201_KEY; freeslot = -1; for (i = 0; i < LK_KLL; i++) { if (lks->down_keys_list[i] == datain) { *type = WSCONS_EVENT_KEY_UP; lks->down_keys_list[i] = -1; return (LKD_COMPLETE); } if (lks->down_keys_list[i] == -1 && freeslot == -1) freeslot = i; } if (freeslot == -1) { printf("lk201_decode: down(%d) no free slot\n", datain); return (LKD_NODATA); } *type = WSCONS_EVENT_KEY_DOWN; lks->down_keys_list[freeslot] = datain; return (LKD_COMPLETE); }