[BRLTTY] BrlAPI Raw key code mode?
Mario Lang
mlang at delysid.org
Fri Jul 28 03:03:58 EDT 2017
Dave Mielke <dave at mielke.cc> writes:
> [quoted lines by Mario Lang on 2017/07/27 at 21:17 +0200]
>
>>This did the trick:
>>
>> brlapi_range_t Ranges[1];
>> Ranges[0].first = 0;
>> Ranges[0].last = 0Xffffffffffffffff;
>> brlapi__acceptKeyRanges(BrlAPI->handle(), Ranges, 1);
>
> Here's what I think is a btter way to code the initialization:
>
> brlapi_range_t ranges[] = {
> { .first = 0, .last = UINT64_MAX }
> };
In C, yes. C++ does not support the .field syntax.
But UINT64_MAX is a good hint, although C++ also does that a bit
differently (std::numeric_limits<brlapi_keyCode_t>::max()).
Quite a mouthful, but more flexible and less error prone.
The way I code it now is:
brlapi_range_t Ranges[] = {
{ std::numeric_limits<brlapi_keyCode_t>::min()
, std::numeric_limits<brlapi_keyCode_t>::max()
}
};
brlapi__acceptKeyRanges(
BrlAPI->handle(),
Ranges, std::distance(std::begin(Ranges), std::end(Ranges))
);
"Look ma, no magic numbers and no macros either!" :-)
But I'd prefer to not do this at all (see below)
>>Either the documentation or the code needs to be fixed.
>>I would vote for making the code do what the documentation claims.
>
> So do I. Having to accept specific ranges makes no sense (to me) in raw mode.
I agree. I would even go as far as dropping the exception
for BRL_SWITCHVT and similar. After all, the client has just
requested raw keycodes, they should know what they are doing in that
particular situation.
--
CYa,
⡍⠁⠗⠊⠕ | Blog: <https://blind.guru/> GitHub: <https://github.com/mlang/>
.''`. | Twitter: @blindbird23 FaceBook: disyled
: :' : | SoundCloud: <soundcloud.com/mario-lang>
`. `' | YouTube: <youtube.com/user/mlang23>
`-
More information about the BRLTTY
mailing list