From: Samuel Thibault <samuel.thibault@gnu.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCHv2] baum: Add support for typing ascii
Date: Mon, 31 Aug 2015 02:16:06 +0200 [thread overview]
Message-ID: <20150831001606.GE3238@var.home> (raw)
This adds support for typing ascii through the Baum Braille driver, by
translating it to braille with the NABCC table.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/backends/baum.c b/backends/baum.c
index a69aaff..50e6e86 100644
--- a/backends/baum.c
+++ b/backends/baum.c
@@ -1,7 +1,7 @@
/*
* QEMU Baum Braille Device
*
- * Copyright (c) 2008 Samuel Thibault
+ * Copyright (c) 2008, 2015 Samuel Thibault
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -468,12 +468,21 @@ static int baum_write(CharDriverState *chr, const uint8_t *buf, int len)
}
/* Send the key code to the other end */
-static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) {
+static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value)
+{
uint8_t packet[] = { type, value };
DPRINTF("writing key %x %x\n", type, value);
baum_write_packet(baum, packet, sizeof(packet));
}
+/* Send the 2-byte key code to the other end */
+static void baum_send_key2(BaumDriverState *baum, uint8_t type, uint16_t value)
+{
+ uint8_t packet[] = { type, value & 0xFF, value >> 8 };
+ DPRINTF("writing key %x %x\n", type, value);
+ baum_write_packet(baum, packet, sizeof(packet));
+}
+
/* We got some data on the BrlAPI socket */
static void baum_chr_read(void *opaque)
{
@@ -492,6 +501,14 @@ static void baum_chr_read(void *opaque)
baum_send_key(baum, BAUM_RSP_RoutingKey, (code & BRLAPI_KEY_CMD_ARG_MASK)+1);
baum_send_key(baum, BAUM_RSP_RoutingKey, 0);
break;
+ case BRLAPI_KEY_CMD_PASSDOTS:
+ {
+ unsigned char dots = code & BRLAPI_KEY_CMD_ARG_MASK;
+ DPRINTF("passdots %x\n", dots);
+ baum_send_key2(baum, BAUM_RSP_EntryKeys, dots << 8);
+ baum_send_key2(baum, BAUM_RSP_EntryKeys, 0);
+ break;
+ }
case 0:
switch (code & BRLAPI_KEY_CMD_ARG_MASK) {
case BRLAPI_KEY_CMD_FWINLT:
@@ -538,7 +555,30 @@ static void baum_chr_read(void *opaque)
}
break;
case BRLAPI_KEY_TYPE_SYM:
- break;
+ {
+ unsigned modifiers = ((code & BRLAPI_KEY_FLAGS_MASK)
+ >> BRLAPI_KEY_FLAGS_SHIFT) & 0xFF;
+ unsigned keysym = code & BRLAPI_KEY_CODE_MASK;
+ unsigned dots;
+ if (modifiers & ~1) {
+ /* Unsupported */
+ break;
+ }
+ if (keysym <= ' ' || keysym > '~') {
+ /* Unsupported */
+ break;
+ }
+ DPRINTF("keysym %x\n", keysym);
+ for (dots = 1; dots <= 0xFF; dots++) {
+ if (nabcc_translation[dots] == keysym) {
+ DPRINTF("dots %x\n", dots);
+ baum_send_key2(baum, BAUM_RSP_EntryKeys, dots << 8);
+ baum_send_key2(baum, BAUM_RSP_EntryKeys, 0);
+ break;
+ }
+ }
+ break;
+ }
}
}
if (ret == -1 && (brlapi_errno != BRLAPI_ERROR_LIBCERR || errno != EINTR)) {
reply other threads:[~2015-08-31 0:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150831001606.GE3238@var.home \
--to=samuel.thibault@gnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).