// Step #2: translate Unicode code point to keystroke sequence // void usb_keyboard_class::write_unicode(uint16_t cpoint) { // Unicode code points beyond U+FFFF are not supported // technically this input should probably be called UCS-2 if (cpoint < 32) { if (cpoint == 10) write_key(KEY_ENTER); return; } if (cpoint < 128) { if (sizeof(KEYCODE_TYPE) == 1) { write_keycode(pgm_read_byte(keycodes_ascii + (cpoint - 0x20))); } else if (sizeof(KEYCODE_TYPE) == 2) { write_keycode(pgm_read_word(keycodes_ascii + (cpoint - 0x20))); } return; } #ifdef ISO_8859_1_A0 if (cpoint <= 0xA0) return; if (cpoint < 0x100) { if (sizeof(KEYCODE_TYPE) == 1) { write_keycode(pgm_read_byte(keycodes_iso_8859_1 + (cpoint - 0xA0))); } else if (sizeof(KEYCODE_TYPE) == 2) { write_keycode(pgm_read_word(keycodes_iso_8859_1 + (cpoint - 0xA0))); } return; } #endif #ifdef UNICODE_20AC if (cpoint == 0x20AC) write_keycode(UNICODE_20AC); #endif }
static int atkbd_read_packet(struct event_device *ed) { struct atkbd_backend *b = ed->priv_ptr; ssize_t ret = read(ed->fd, ed->packet_buf, 1); if (ret == -1 && errno == EAGAIN) { return 1; } else if (ret != 1) { return -1; } ed->packet_pos = 1; if (!write_keycode(b->vkbd_fd, ed->packet_buf[0])) return -1; return 0; }