News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Convert scancodes -> ASCII

Started by thomasantony, January 02, 2005, 05:02:13 AM

Previous topic - Next topic

thomasantony

Hi,
   Seems like I am back to OS programming. I am bored with everything else!! Now I am continuing the work on my 32-bit OS kernel. I finally got the Keyboard ISR to work so that it printed the letter K in different colors according to the scancode. It worked both in BOCHS and the actual system. Now I want soem way of converting the scancodes into ASCII codes. I have tried using a table and adding the scancode to it. This makes the letters appear when the key is pressed and another symbol when key is released. Can someone tell me how to distinguish b/w key press and releases. Also to dist. b/w ordinary presses and those with shift or control.

Thomas Antony
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

MichaelW

The key break code is the key make code (scan code) with bit7 set. AFAIK the translation of scan codes for the different shift states is a BIOS feature. Assuming you are bypassing the BIOS, I would think you could just do as the BIOS does and use the shift, alt, and ctrl key make/break codes to maintain a shift state, and refer to that state as necessary.
eschew obfuscation

thomasantony

Hi,
   I have done an and al,80h to igonre the key releases. Now I have to recognise the shift key. How do I do this?

Thomas Antony
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

MichaelW

Because the shift keys are used in combination with other keys, I think you would need to maintain a status variable for each one. Basically, you would set the status variable when you receive the key make code, and clear it when you receive the break code. Then while processing the codes for some other key of interest you could check the appropriate shift key status variable. AFAIK, the scan codes for the shift keys are:

L-SHIFT 2Ah
R-SHIFT 36h
L-CTRL 1Dh
R-CTRL E0h, 14h
L-ALT 38h
R-ALT E0h, 38h

These are the system scan codes delivered by the keyboard controller on the motherboard.

eschew obfuscation

Tedd

The usual way is to have a number of tables, and keep track of which 'selector' keys are currently down.

So you'd have one talble for 'normal' and another one for shift, and then possibly one for caps-lock (if you don't want to have to check characters) and yet another for ctrl and maybe even alt.
Which does seem a little overboard, but it's the fastest way of doing it; which is a good thing for an isr ;)

I'm playing around with a few things, and you can get by with just normal and shift. For ctrl and alt you could have flags, so you can do special things for those keys.

Definitely take a look at: http://my.execpc.com/~geezer/osd/kbd/index.htm
No snowflake in an avalanche feels responsible.