2 * QEMU Baum Braille Device
4 * Copyright (c) 2008 Samuel Thibault
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #include "qemu/osdep.h"
25 #include "qapi/error.h"
26 #include "qemu-common.h"
27 #include "sysemu/char.h"
28 #include "qemu/timer.h"
31 #include <brlapi_constants.h>
32 #include <brlapi_keycodes.h>
34 #include <SDL_syswm.h>
38 #define DPRINTF(fmt, ...) \
39 printf(fmt, ## __VA_ARGS__)
41 #define DPRINTF(fmt, ...)
46 #define BAUM_REQ_DisplayData 0x01
47 #define BAUM_REQ_GetVersionNumber 0x05
48 #define BAUM_REQ_GetKeys 0x08
49 #define BAUM_REQ_SetMode 0x12
50 #define BAUM_REQ_SetProtocol 0x15
51 #define BAUM_REQ_GetDeviceIdentity 0x84
52 #define BAUM_REQ_GetSerialNumber 0x8A
54 #define BAUM_RSP_CellCount 0x01
55 #define BAUM_RSP_VersionNumber 0x05
56 #define BAUM_RSP_ModeSetting 0x11
57 #define BAUM_RSP_CommunicationChannel 0x16
58 #define BAUM_RSP_PowerdownSignal 0x17
59 #define BAUM_RSP_HorizontalSensors 0x20
60 #define BAUM_RSP_VerticalSensors 0x21
61 #define BAUM_RSP_RoutingKeys 0x22
62 #define BAUM_RSP_Switches 0x23
63 #define BAUM_RSP_TopKeys 0x24
64 #define BAUM_RSP_HorizontalSensor 0x25
65 #define BAUM_RSP_VerticalSensor 0x26
66 #define BAUM_RSP_RoutingKey 0x27
67 #define BAUM_RSP_FrontKeys6 0x28
68 #define BAUM_RSP_BackKeys6 0x29
69 #define BAUM_RSP_CommandKeys 0x2B
70 #define BAUM_RSP_FrontKeys10 0x2C
71 #define BAUM_RSP_BackKeys10 0x2D
72 #define BAUM_RSP_EntryKeys 0x33
73 #define BAUM_RSP_JoyStick 0x34
74 #define BAUM_RSP_ErrorCode 0x40
75 #define BAUM_RSP_InfoBlock 0x42
76 #define BAUM_RSP_DeviceIdentity 0x84
77 #define BAUM_RSP_SerialNumber 0x8A
78 #define BAUM_RSP_BluetoothName 0x8C
92 brlapi_handle_t *brlapi;
96 uint8_t in_buf[BUF_SIZE];
98 uint8_t out_buf[BUF_SIZE];
99 uint8_t out_buf_used, out_buf_ptr;
101 QEMUTimer *cellCount_timer;
104 /* Let's assume NABCC by default */
105 static const uint8_t nabcc_translation[256] = {
108 #define BRLAPI_DOTS(d1,d2,d3,d4,d5,d6,d7,d8) \
109 ((d1?BRLAPI_DOT1:0)|\
118 [BRLAPI_DOTS(1,0,0,0,0,0,0,0)] = 'a',
119 [BRLAPI_DOTS(1,1,0,0,0,0,0,0)] = 'b',
120 [BRLAPI_DOTS(1,0,0,1,0,0,0,0)] = 'c',
121 [BRLAPI_DOTS(1,0,0,1,1,0,0,0)] = 'd',
122 [BRLAPI_DOTS(1,0,0,0,1,0,0,0)] = 'e',
123 [BRLAPI_DOTS(1,1,0,1,0,0,0,0)] = 'f',
124 [BRLAPI_DOTS(1,1,0,1,1,0,0,0)] = 'g',
125 [BRLAPI_DOTS(1,1,0,0,1,0,0,0)] = 'h',
126 [BRLAPI_DOTS(0,1,0,1,0,0,0,0)] = 'i',
127 [BRLAPI_DOTS(0,1,0,1,1,0,0,0)] = 'j',
128 [BRLAPI_DOTS(1,0,1,0,0,0,0,0)] = 'k',
129 [BRLAPI_DOTS(1,1,1,0,0,0,0,0)] = 'l',
130 [BRLAPI_DOTS(1,0,1,1,0,0,0,0)] = 'm',
131 [BRLAPI_DOTS(1,0,1,1,1,0,0,0)] = 'n',
132 [BRLAPI_DOTS(1,0,1,0,1,0,0,0)] = 'o',
133 [BRLAPI_DOTS(1,1,1,1,0,0,0,0)] = 'p',
134 [BRLAPI_DOTS(1,1,1,1,1,0,0,0)] = 'q',
135 [BRLAPI_DOTS(1,1,1,0,1,0,0,0)] = 'r',
136 [BRLAPI_DOTS(0,1,1,1,0,0,0,0)] = 's',
137 [BRLAPI_DOTS(0,1,1,1,1,0,0,0)] = 't',
138 [BRLAPI_DOTS(1,0,1,0,0,1,0,0)] = 'u',
139 [BRLAPI_DOTS(1,1,1,0,0,1,0,0)] = 'v',
140 [BRLAPI_DOTS(0,1,0,1,1,1,0,0)] = 'w',
141 [BRLAPI_DOTS(1,0,1,1,0,1,0,0)] = 'x',
142 [BRLAPI_DOTS(1,0,1,1,1,1,0,0)] = 'y',
143 [BRLAPI_DOTS(1,0,1,0,1,1,0,0)] = 'z',
145 [BRLAPI_DOTS(1,0,0,0,0,0,1,0)] = 'A',
146 [BRLAPI_DOTS(1,1,0,0,0,0,1,0)] = 'B',
147 [BRLAPI_DOTS(1,0,0,1,0,0,1,0)] = 'C',
148 [BRLAPI_DOTS(1,0,0,1,1,0,1,0)] = 'D',
149 [BRLAPI_DOTS(1,0,0,0,1,0,1,0)] = 'E',
150 [BRLAPI_DOTS(1,1,0,1,0,0,1,0)] = 'F',
151 [BRLAPI_DOTS(1,1,0,1,1,0,1,0)] = 'G',
152 [BRLAPI_DOTS(1,1,0,0,1,0,1,0)] = 'H',
153 [BRLAPI_DOTS(0,1,0,1,0,0,1,0)] = 'I',
154 [BRLAPI_DOTS(0,1,0,1,1,0,1,0)] = 'J',
155 [BRLAPI_DOTS(1,0,1,0,0,0,1,0)] = 'K',
156 [BRLAPI_DOTS(1,1,1,0,0,0,1,0)] = 'L',
157 [BRLAPI_DOTS(1,0,1,1,0,0,1,0)] = 'M',
158 [BRLAPI_DOTS(1,0,1,1,1,0,1,0)] = 'N',
159 [BRLAPI_DOTS(1,0,1,0,1,0,1,0)] = 'O',
160 [BRLAPI_DOTS(1,1,1,1,0,0,1,0)] = 'P',
161 [BRLAPI_DOTS(1,1,1,1,1,0,1,0)] = 'Q',
162 [BRLAPI_DOTS(1,1,1,0,1,0,1,0)] = 'R',
163 [BRLAPI_DOTS(0,1,1,1,0,0,1,0)] = 'S',
164 [BRLAPI_DOTS(0,1,1,1,1,0,1,0)] = 'T',
165 [BRLAPI_DOTS(1,0,1,0,0,1,1,0)] = 'U',
166 [BRLAPI_DOTS(1,1,1,0,0,1,1,0)] = 'V',
167 [BRLAPI_DOTS(0,1,0,1,1,1,1,0)] = 'W',
168 [BRLAPI_DOTS(1,0,1,1,0,1,1,0)] = 'X',
169 [BRLAPI_DOTS(1,0,1,1,1,1,1,0)] = 'Y',
170 [BRLAPI_DOTS(1,0,1,0,1,1,1,0)] = 'Z',
172 [BRLAPI_DOTS(0,0,1,0,1,1,0,0)] = '0',
173 [BRLAPI_DOTS(0,1,0,0,0,0,0,0)] = '1',
174 [BRLAPI_DOTS(0,1,1,0,0,0,0,0)] = '2',
175 [BRLAPI_DOTS(0,1,0,0,1,0,0,0)] = '3',
176 [BRLAPI_DOTS(0,1,0,0,1,1,0,0)] = '4',
177 [BRLAPI_DOTS(0,1,0,0,0,1,0,0)] = '5',
178 [BRLAPI_DOTS(0,1,1,0,1,0,0,0)] = '6',
179 [BRLAPI_DOTS(0,1,1,0,1,1,0,0)] = '7',
180 [BRLAPI_DOTS(0,1,1,0,0,1,0,0)] = '8',
181 [BRLAPI_DOTS(0,0,1,0,1,0,0,0)] = '9',
183 [BRLAPI_DOTS(0,0,0,1,0,1,0,0)] = '.',
184 [BRLAPI_DOTS(0,0,1,1,0,1,0,0)] = '+',
185 [BRLAPI_DOTS(0,0,1,0,0,1,0,0)] = '-',
186 [BRLAPI_DOTS(1,0,0,0,0,1,0,0)] = '*',
187 [BRLAPI_DOTS(0,0,1,1,0,0,0,0)] = '/',
188 [BRLAPI_DOTS(1,1,1,0,1,1,0,0)] = '(',
189 [BRLAPI_DOTS(0,1,1,1,1,1,0,0)] = ')',
191 [BRLAPI_DOTS(1,1,1,1,0,1,0,0)] = '&',
192 [BRLAPI_DOTS(0,0,1,1,1,1,0,0)] = '#',
194 [BRLAPI_DOTS(0,0,0,0,0,1,0,0)] = ',',
195 [BRLAPI_DOTS(0,0,0,0,1,1,0,0)] = ';',
196 [BRLAPI_DOTS(1,0,0,0,1,1,0,0)] = ':',
197 [BRLAPI_DOTS(0,1,1,1,0,1,0,0)] = '!',
198 [BRLAPI_DOTS(1,0,0,1,1,1,0,0)] = '?',
199 [BRLAPI_DOTS(0,0,0,0,1,0,0,0)] = '"',
200 [BRLAPI_DOTS(0,0,1,0,0,0,0,0)] ='\'',
201 [BRLAPI_DOTS(0,0,0,1,0,0,0,0)] = '`',
202 [BRLAPI_DOTS(0,0,0,1,1,0,1,0)] = '^',
203 [BRLAPI_DOTS(0,0,0,1,1,0,0,0)] = '~',
204 [BRLAPI_DOTS(0,1,0,1,0,1,1,0)] = '[',
205 [BRLAPI_DOTS(1,1,0,1,1,1,1,0)] = ']',
206 [BRLAPI_DOTS(0,1,0,1,0,1,0,0)] = '{',
207 [BRLAPI_DOTS(1,1,0,1,1,1,0,0)] = '}',
208 [BRLAPI_DOTS(1,1,1,1,1,1,0,0)] = '=',
209 [BRLAPI_DOTS(1,1,0,0,0,1,0,0)] = '<',
210 [BRLAPI_DOTS(0,0,1,1,1,0,0,0)] = '>',
211 [BRLAPI_DOTS(1,1,0,1,0,1,0,0)] = '$',
212 [BRLAPI_DOTS(1,0,0,1,0,1,0,0)] = '%',
213 [BRLAPI_DOTS(0,0,0,1,0,0,1,0)] = '@',
214 [BRLAPI_DOTS(1,1,0,0,1,1,0,0)] = '|',
215 [BRLAPI_DOTS(1,1,0,0,1,1,1,0)] ='\\',
216 [BRLAPI_DOTS(0,0,0,1,1,1,0,0)] = '_',
219 /* The serial port can receive more of our data */
220 static void baum_accept_input(struct CharDriverState *chr)
222 BaumDriverState *baum = chr->opaque;
225 if (!baum->out_buf_used)
227 room = qemu_chr_be_can_write(chr);
230 if (room > baum->out_buf_used)
231 room = baum->out_buf_used;
233 first = BUF_SIZE - baum->out_buf_ptr;
235 qemu_chr_be_write(chr, baum->out_buf + baum->out_buf_ptr, first);
236 baum->out_buf_ptr = 0;
237 baum->out_buf_used -= first;
240 qemu_chr_be_write(chr, baum->out_buf + baum->out_buf_ptr, room);
241 baum->out_buf_ptr += room;
242 baum->out_buf_used -= room;
245 /* We want to send a packet */
246 static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len)
248 uint8_t io_buf[1 + 2 * len], *cur = io_buf;
252 if ((*cur++ = *buf++) == ESC)
254 room = qemu_chr_be_can_write(baum->chr);
258 qemu_chr_be_write(baum->chr, io_buf, len);
262 /* Can't fit all, send what can be, and store the rest. */
263 qemu_chr_be_write(baum->chr, io_buf, room);
266 if (len > BUF_SIZE - baum->out_buf_used) {
267 /* Can't even store it, drop the previous data... */
268 assert(len <= BUF_SIZE);
269 baum->out_buf_used = 0;
270 baum->out_buf_ptr = 0;
272 out = baum->out_buf_ptr;
273 baum->out_buf_used += len;
274 first = BUF_SIZE - baum->out_buf_ptr;
276 memcpy(baum->out_buf + out, cur, first);
281 memcpy(baum->out_buf + out, cur, len);
285 /* Called when the other end seems to have a wrong idea of our display size */
286 static void baum_cellCount_timer_cb(void *opaque)
288 BaumDriverState *baum = opaque;
289 uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
290 DPRINTF("Timeout waiting for DisplayData, sending cell count\n");
291 baum_write_packet(baum, cell_count, sizeof(cell_count));
294 /* Try to interpret a whole incoming packet */
295 static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
297 const uint8_t *cur = buf;
303 while (*cur != ESC) {
308 DPRINTF("Dropped %td bytes!\n", cur - buf);
314 if ((c = *cur++) == ESC) { \
317 if (*cur++ != ESC) { \
318 DPRINTF("Broken packet %#2x, tossing\n", req); \
319 if (timer_pending(baum->cellCount_timer)) { \
320 timer_del(baum->cellCount_timer); \
321 baum_cellCount_timer_cb(baum); \
323 return (cur - 2 - buf); \
330 case BAUM_REQ_DisplayData:
332 uint8_t cells[baum->x * baum->y], c;
333 uint8_t text[baum->x * baum->y];
334 uint8_t zero[baum->x * baum->y];
335 int cursor = BRLAPI_CURSOR_OFF;
338 /* Allow 100ms to complete the DisplayData packet */
339 timer_mod(baum->cellCount_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
340 NANOSECONDS_PER_SECOND / 10);
341 for (i = 0; i < baum->x * baum->y ; i++) {
344 if ((c & (BRLAPI_DOT7|BRLAPI_DOT8))
345 == (BRLAPI_DOT7|BRLAPI_DOT8)) {
347 c &= ~(BRLAPI_DOT7|BRLAPI_DOT8);
349 if (!(c = nabcc_translation[c]))
353 timer_del(baum->cellCount_timer);
355 memset(zero, 0, sizeof(zero));
357 brlapi_writeArguments_t wa = {
358 .displayNumber = BRLAPI_DISPLAY_DEFAULT,
360 .regionSize = baum->x * baum->y,
361 .text = (char *)text,
362 .textSize = baum->x * baum->y,
366 .charset = (char *)"ISO-8859-1",
369 if (brlapi__write(baum->brlapi, &wa) == -1)
370 brlapi_perror("baum brlapi_write");
373 case BAUM_REQ_SetMode:
375 uint8_t mode, setting;
376 DPRINTF("SetMode\n");
382 case BAUM_REQ_SetProtocol:
385 DPRINTF("SetProtocol\n");
390 case BAUM_REQ_GetDeviceIdentity:
392 uint8_t identity[17] = { BAUM_RSP_DeviceIdentity,
393 'B','a','u','m',' ','V','a','r','i','o' };
394 DPRINTF("GetDeviceIdentity\n");
395 identity[11] = '0' + baum->x / 10;
396 identity[12] = '0' + baum->x % 10;
397 baum_write_packet(baum, identity, sizeof(identity));
400 case BAUM_REQ_GetVersionNumber:
402 uint8_t version[] = { BAUM_RSP_VersionNumber, 1 }; /* ? */
403 DPRINTF("GetVersionNumber\n");
404 baum_write_packet(baum, version, sizeof(version));
407 case BAUM_REQ_GetSerialNumber:
409 uint8_t serial[] = { BAUM_RSP_SerialNumber,
410 '0','0','0','0','0','0','0','0' };
411 DPRINTF("GetSerialNumber\n");
412 baum_write_packet(baum, serial, sizeof(serial));
415 case BAUM_REQ_GetKeys:
417 DPRINTF("Get%0#2x\n", req);
422 DPRINTF("unrecognized request %0#2x\n", req);
426 while (*cur++ != ESC);
433 /* The other end is writing some data. Store it and try to interpret */
434 static int baum_write(CharDriverState *chr, const uint8_t *buf, int len)
436 BaumDriverState *baum = chr->opaque;
437 int tocopy, cur, eaten, orig_len = len;
445 /* Complete our buffer as much as possible */
447 if (tocopy > BUF_SIZE - baum->in_buf_used)
448 tocopy = BUF_SIZE - baum->in_buf_used;
450 memcpy(baum->in_buf + baum->in_buf_used, buf, tocopy);
451 baum->in_buf_used += tocopy;
455 /* Interpret it as much as possible */
457 while (cur < baum->in_buf_used &&
458 (eaten = baum_eat_packet(baum, baum->in_buf + cur, baum->in_buf_used - cur)))
461 /* Shift the remainder */
463 memmove(baum->in_buf, baum->in_buf + cur, baum->in_buf_used - cur);
464 baum->in_buf_used -= cur;
467 /* And continue if any data left */
472 /* Send the key code to the other end */
473 static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) {
474 uint8_t packet[] = { type, value };
475 DPRINTF("writing key %x %x\n", type, value);
476 baum_write_packet(baum, packet, sizeof(packet));
479 /* We got some data on the BrlAPI socket */
480 static void baum_chr_read(void *opaque)
482 BaumDriverState *baum = opaque;
483 brlapi_keyCode_t code;
487 while ((ret = brlapi__readKey(baum->brlapi, 0, &code)) == 1) {
488 DPRINTF("got key %"BRLAPI_PRIxKEYCODE"\n", code);
490 switch (code & BRLAPI_KEY_TYPE_MASK) {
491 case BRLAPI_KEY_TYPE_CMD:
492 switch (code & BRLAPI_KEY_CMD_BLK_MASK) {
493 case BRLAPI_KEY_CMD_ROUTE:
494 baum_send_key(baum, BAUM_RSP_RoutingKey, (code & BRLAPI_KEY_CMD_ARG_MASK)+1);
495 baum_send_key(baum, BAUM_RSP_RoutingKey, 0);
498 switch (code & BRLAPI_KEY_CMD_ARG_MASK) {
499 case BRLAPI_KEY_CMD_FWINLT:
500 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2);
501 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
503 case BRLAPI_KEY_CMD_FWINRT:
504 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TR2);
505 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
507 case BRLAPI_KEY_CMD_LNUP:
508 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TR1);
509 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
511 case BRLAPI_KEY_CMD_LNDN:
512 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TR3);
513 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
515 case BRLAPI_KEY_CMD_TOP:
516 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL1|BAUM_TR1);
517 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
519 case BRLAPI_KEY_CMD_BOT:
520 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL3|BAUM_TR3);
521 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
523 case BRLAPI_KEY_CMD_TOP_LEFT:
524 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2|BAUM_TR1);
525 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
527 case BRLAPI_KEY_CMD_BOT_LEFT:
528 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2|BAUM_TR3);
529 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
531 case BRLAPI_KEY_CMD_HOME:
532 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2|BAUM_TR1|BAUM_TR3);
533 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
535 case BRLAPI_KEY_CMD_PREFMENU:
536 baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL1|BAUM_TL3|BAUM_TR1);
537 baum_send_key(baum, BAUM_RSP_TopKeys, 0);
542 case BRLAPI_KEY_TYPE_SYM:
546 if (ret == -1 && (brlapi_errno != BRLAPI_ERROR_LIBCERR || errno != EINTR)) {
547 brlapi_perror("baum: brlapi_readKey");
548 brlapi__closeConnection(baum->brlapi);
549 g_free(baum->brlapi);
554 static void baum_close(struct CharDriverState *chr)
556 BaumDriverState *baum = chr->opaque;
558 timer_free(baum->cellCount_timer);
560 brlapi__closeConnection(baum->brlapi);
561 g_free(baum->brlapi);
566 static CharDriverState *chr_baum_init(const char *id,
567 ChardevBackend *backend,
571 ChardevCommon *common = backend->u.braille.data;
572 BaumDriverState *baum;
573 CharDriverState *chr;
574 brlapi_handle_t *handle;
575 #if defined(CONFIG_SDL)
576 #if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0)
582 chr = qemu_chr_alloc(common, errp);
586 baum = g_malloc0(sizeof(BaumDriverState));
590 chr->chr_write = baum_write;
591 chr->chr_accept_input = baum_accept_input;
592 chr->chr_close = baum_close;
594 handle = g_malloc0(brlapi_getHandleSize());
595 baum->brlapi = handle;
597 baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
598 if (baum->brlapi_fd == -1) {
599 error_setg(errp, "brlapi__openConnection: %s",
600 brlapi_strerror(brlapi_error_location()));
604 baum->cellCount_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, baum_cellCount_timer_cb, baum);
606 if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {
607 error_setg(errp, "brlapi__getDisplaySize: %s",
608 brlapi_strerror(brlapi_error_location()));
612 #if defined(CONFIG_SDL)
613 #if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0)
614 memset(&info, 0, sizeof(info));
615 SDL_VERSION(&info.version);
616 if (SDL_GetWMInfo(&info))
617 tty = info.info.x11.wmwindow;
621 tty = BRLAPI_TTY_DEFAULT;
623 if (brlapi__enterTtyMode(handle, tty, NULL) == -1) {
624 error_setg(errp, "brlapi__enterTtyMode: %s",
625 brlapi_strerror(brlapi_error_location()));
629 qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);
634 timer_free(baum->cellCount_timer);
635 brlapi__closeConnection(handle);
643 static void register_types(void)
645 register_char_driver("braille", CHARDEV_BACKEND_KIND_BRAILLE, NULL,
649 type_init(register_types);