static int brl_writeWindow(BrailleDisplay *brl, const wchar_t *text) { if(text) { char bytes[brl->textColumns]; int i; for(i = 0; i < brl->textColumns; ++i) { wchar_t character = text[i]; bytes[i] = iswLatin1(character)? character: '?'; } braille_write(bytes, brl->textColumns); if(brl->cursor >= 0) { braille_filter(translateOutputCell(cursorDots()), brl->cursor); } braille_render(); } return 1; }
/* Show portion of VC at vc_x, vc_y */ static void vc_refresh(struct vc_data *vc) { u16 buf[WIDTH]; int i; for (i = 0; i < WIDTH; i++) { u16 glyph = screen_glyph(vc, 2 * (vc_x + i) + vc_y * vc->vc_size_row); buf[i] = inverse_translate(vc, glyph, 1); } braille_write(buf); }
static int vt_notifier_call(struct notifier_block *blk, unsigned long code, void *_param) { struct vt_notifier_param *param = _param; struct vc_data *vc = param->vc; switch (code) { case VT_ALLOCATE: break; case VT_DEALLOCATE: break; case VT_WRITE: { unsigned char c = param->c; if (vc->vc_num != fg_console) break; switch (c) { case '\b': case 127: if (console_cursor > 0) { console_cursor--; console_buf[console_cursor] = ' '; } break; case '\n': case '\v': case '\f': case '\r': console_newline = 1; break; case '\t': c = ' '; /* Fallthrough */ default: if (c < 32) /* Ignore other control sequences */ break; if (console_newline) { memset(console_buf, 0, sizeof(console_buf)); console_cursor = 0; console_newline = 0; } if (console_cursor == WIDTH) memmove(console_buf, &console_buf[1], (WIDTH-1) * sizeof(*console_buf)); else console_cursor++; console_buf[console_cursor-1] = c; break; } if (console_show) braille_write(console_buf); else { vc_maybe_cursor_moved(vc); vc_refresh(vc); } break; } case VT_UPDATE: /* Maybe a VT switch, flush */ if (console_show) { if (vc->vc_num != lastVC) { lastVC = vc->vc_num; memset(console_buf, 0, sizeof(console_buf)); console_cursor = 0; braille_write(console_buf); } } else { vc_maybe_cursor_moved(vc); vc_refresh(vc); } break; } return NOTIFY_OK; }
static int keyboard_notifier_call(struct notifier_block *blk, unsigned long code, void *_param) { struct keyboard_notifier_param *param = _param; struct vc_data *vc = param->vc; int ret = NOTIFY_OK; if (!param->down) return ret; switch (code) { case KBD_KEYCODE: if (console_show) { if (param->value == BRAILLE_KEY) { console_show = 0; beep(880); vc_maybe_cursor_moved(vc); vc_refresh(vc); ret = NOTIFY_STOP; } } else { ret = NOTIFY_STOP; switch (param->value) { case KEY_INSERT: beep(440); console_show = 1; lastVC = -1; braille_write(console_buf); break; case KEY_LEFT: if (vc_x > 0) { vc_x -= WIDTH; if (vc_x < 0) vc_x = 0; } else if (vc_y >= 1) { beep(880); vc_y--; vc_x = vc->vc_cols-WIDTH; } else beep(220); break; case KEY_RIGHT: if (vc_x + WIDTH < vc->vc_cols) { vc_x += WIDTH; } else if (vc_y + 1 < vc->vc_rows) { beep(880); vc_y++; vc_x = 0; } else beep(220); break; case KEY_DOWN: if (vc_y + 1 < vc->vc_rows) vc_y++; else beep(220); break; case KEY_UP: if (vc_y >= 1) vc_y--; else beep(220); break; case KEY_HOME: vc_follow_cursor(vc); break; case KEY_PAGEUP: vc_x = 0; vc_y = 0; break; case KEY_PAGEDOWN: vc_x = 0; vc_y = vc->vc_rows-1; break; default: ret = NOTIFY_OK; break; } if (ret == NOTIFY_STOP) vc_refresh(vc); } break; case KBD_POST_KEYSYM: { unsigned char type = KTYP(param->value) - 0xf0; if (type == KT_SPEC) { unsigned char val = KVAL(param->value); int on_off = -1; switch (val) { case KVAL(K_CAPS): on_off = vc_kbd_led(kbd_table + fg_console, VC_CAPSLOCK); break; case KVAL(K_NUM): on_off = vc_kbd_led(kbd_table + fg_console, VC_NUMLOCK); break; case KVAL(K_HOLD): on_off = vc_kbd_led(kbd_table + fg_console, VC_SCROLLOCK); break; } if (on_off == 1) beep(880); else if (on_off == 0) beep(440); } } case KBD_UNBOUND_KEYCODE: case KBD_UNICODE: case KBD_KEYSYM: /* Unused */ break; } return ret; }