[BRLTTY] screen driver in brlapi

Dave Mielke Dave at mielke.cc
Sat Nov 3 19:28:45 EDT 2018


[quoted lines by Samuel Thibault on 2018/11/03 at 23:44 +0100]

>>    uint8_t header[4];
>>    read(vcsa, header, sizeof(header));
>>    off_t offset = ((header[3] * header[1]) + header[2]) * sizeof(character);
>>    wchar_t character;
>>    read(vcsu, offset, sizeof(character));

First, I'd better fix this sample code. That's what I get for not having
proof-read it and/or tested it first. I've also made it a little clearer.

   int vcsa = open("/dev/vcsa", O_RDONLY);
   uint8_t header[4];
   pread(vcsa, header, sizeof(header), 0);

   const uint8_t *byte = header;
   uint8_t rowCount = *byte++;
   uint8_t columnCount = *byte++;
   uint8_t cursorColumn = *byte++;
   uint8_t cursorRow = *byte++;

   int vcsu = open("/dev/vcsu", O_RDONLY);
   wchar_t character;
   off_t offset = ((cursorRow * columnCount) + cursorColumn) * sizeof(character);
   pread(vcsu, &character, sizeof(character), offset);

Of course, you should also be checking for errors everywhere. :-( I left all
that out in order to make the example clearer.

>> You should use poll() to wait for changes to the screen content.
>
>I'm however wondering, how do make sure not to miss updates?

Yes. Readable means a change since the last read. This means that one needs to
read everything that one cares about in a single operation. Brltty actually
reads in the whole screen each time as this enables it to present stable
content for functions that search, e.g. for the start of the previous/next
paragraph.

>I guess poll will immediately return, because something happened since
>the last read?

Yes. We can get into trouble, though, if, say, two changes occur and we only
read in one of them and then expect to be able to wait for the second.

-- 
I believe the Bible to be the very Word of God: http://Mielke.cc/bible/
Dave Mielke            | 2213 Fox Crescent | WebHome: http://Mielke.cc/
EMail: Dave at Mielke.cc  | Ottawa, Ontario   | Twitter: @Dave_Mielke
Phone: +1 613 726 0014 | Canada  K2A 1H7   |


More information about the BRLTTY mailing list