Re: Reading at port 60h
Richard Cooper <peajay <at> funrestraints.com>
2005-09-04 02:56:30 GMT
> how i can have noticie that a key was pressed , but reading at port 60h,
You aren't doing that in Linux are you? Linux reads the keyboard via an
interrupt, if you're polling through port 0x60/0x64, you're not going to
get anything because the kernel will get to it first.
You can have the kernel give you the scancodes from the keyboard on your
stdin by using ioctls. You can get more information about that by typing
"man console_ioctl"
Basically, you call KDGKBMODE to get the current mode and save it, then
call KDSKBMODE to set "RAW" mode, and when your program exits, you set
the keyboard mode back like it was. However, before that, you have to
install signal handlers to catch if your program crashes or someone tries
to kill it, because if your program doesn't set the keyboard mode back,
the kernel isn't going to do it. Also, before calling KDSKBMODE, you need
to call TCSETSW to change the TTY settings, otherwise scancode 3 will be
interpreted as contol-c, and scancode 13 will be translated to 10, and 127
will be translated to 8, and probably some more. You also have to use
TCGETS to save those settings, so you can restore them too. Then you have
to watch for Alt-Fn and signal the kernel via VT_ACTIVATE to switch
consoles, because it doesn't watch for Alt-Fn when they keyboard is in RAW
mode. On the plus side, you don't have to switch back to non-raw mode
when you call VT_ACTIVATE, because the kernel keeps each console in it's
own mode.
It's a mess of work, but it's doable, and will certainly work better than
direct access.
> my problem is that i cant find a good documentation,
(Continue reading)