Can I read the keyboard in two modes simultaneously?

  • Follow



Hi.  I'm wondering if there's any way in a C program on
linux to use ioctl() or similar to get both the raw
keypresses (keydown and keyup indicating which physical
keyboard button was pressed) and the translated characters
generated.

My application is a "roguelike" game interface with
a lot of keys mapped to various commands. I want
keypress messages so I can tell the difference between
the number pad, the arrow keys, and the number row
above the keyboard, and translated characters so I can
respond appropriately when the user pushes a "letter key"
or composes a letter using their altgr or whatever, no
matter where that letter is mapped on his/her particular
keyboard.

Any help would be appreciated.

Thanks,


Bear

0
Reply bear (1215) 8/4/2007 1:06:12 AM

> Hi.  I'm wondering if there's any way in a C program on
> linux to use ioctl() or similar to get both the raw
> keypresses (keydown and keyup indicating which physical
> keyboard button was pressed) and the translated characters
> generated.

<snip>

Off the cuff, I would say it should indeed be possible, but it would
probably require a bit of work on your part. You either need a key-
mapping function that translates keypresses without removing them from
the input buffer, or you need a function that pulls the keypresses,
then passes them to a translator.

0
Reply wild.halcyon (2) 8/4/2007 5:13:51 PM


Ray Dillinger <bear@sonic.net> wrote:
> My application is a "roguelike" game interface with
> a lot of keys mapped to various commands. I want
> keypress messages so I can tell the difference between
> the number pad, the arrow keys, and the number row
> above the keyboard [...]

Drop the numberpad into application mode and then use terminfo(5) to
read the key sequences. No need for the complexity of handling key-downs.

Chris
0
Reply chris-usenet (1110) 8/5/2007 11:51:22 PM

2 Replies
44 Views

(page loaded in 0.086 seconds)

Similiar Articles:













7/24/2012 1:49:39 AM


Reply: