NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: detecting keyboard events (using wskbd?)



On Sun, Aug 06, 2023 at 08:09:10PM +0000, pouya+lists.netbsd%nohup.io@localhost wrote:
> Hi mighty netbsd-users,
> 
> For a personal project, I'm trying to find the right way to detect
> and act on raw (or raw-ish) keyboard events on a NetBSD system not
> running X11.
> 
> After spending more hours than I'd like to admit browsing the
> manpages and source code and doing some small experiments, I have
> formed a foggy notion that it can be done by issuing a WSKBDIO_GETMAP
> ioctl to get the key map and then using it to interpret what I'd
> read from a non-blocking /dev/wskbd.
> 
> But before I sank even more hours in confused attempts to figure
> out how to actually do this, I thought I'd ask if anyone here could
> perhaps provide some further guidance.
> 
> Many thanks,
> Pouya

Heya,

if you want raw keyboard events, you don't need to do
WSKBDIO_GETMAP.

You do need to do WSKBDIO_GTYPE, as the scan codes returned are
unfortunately different between PS/2 and USB. For some "retro"
protocols, the driver's author fortunately decided to pretend
to be a USB keyboard. However, currently, PS/2 needs to be handled
separately if you want good support for laptops.

Check out:
https://github.com/michaelforney/swc/blob/master/libswc/seat-ws.c

which converts wscons events to xkb events.


Home | Main Index | Thread Index | Old Index