this should be simple
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Jan 18 20:06:18 UTC 2005
On Tue, Jan 18, 2005 at 01:32:53PM -0500, bob wrote:
> Suppose I want to write a very simple Linux C program to detect that the user
> has pressed CTRL (or ALT) and PGUP.
>
> How do I do this?
>
> I remember back to my QNX days that there were term functions which could
> detect this but for the life of me I can't find the Linux equivalent.
Get char returns characters, not modifier key events. You will have to
use one of the lower level console access libraries. Under X you would
use the X event libraries of course. For a portable application, use
SDL if possible since it will abstract away all the yucky stuff. It
esentially involves using ioctl to switch the console to raw keyboard
mode, and then doing your own parsing of the scancodes you read and then
restoring the keyboard mode on exit again. The SDL libs know how to do
that for you no matter if you are in X or on console, so it may be a
simpler method or it could be overkill. The source code to dumpkeys
from the console-tools might also be a helpful place to look.
What it comes down to is: No it shouldn't be simple, because it isn't
simple.
Lennart Sorensen
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list