Setting AT Scancode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
simply_the_guest

Setting AT Scancode

Post by simply_the_guest »

hello all,

i'm writing the keyboard interrupt. i've heard that scan code set 2 (AT) should be chosen, because it is the mostly supported scancode set. but, when i print the make code and break code of my keyboard when i press a key, i receive only the scan code set 1 (XT). i've tried to set the scan code to 2 by the following code :

   xor   ax, ax
waitt:
   in   al, 60h
   bt   ax, 1
   jc   wait

   mov   al, 0F0h
   out   60h, al
   mov   al, 03h
   out   60h, al

but, still the interrupt prints only the scancode set 1(XT). any help will be appreciated.

thank you,
gaffi

Re:Setting AT Scancode

Post by gaffi »

Hi
You have to disable the scancode translation in the command-byte. If you don't do so your kbd sents AT codes, but the controller translates them back to XT.

; Command Byte
call waitt
mov al,0x60
out 64h,al
call waitt
mov al,00000011b <- no translation, mouse + kbd ints
out 60h,al

More info:
http://panda.cs.ndsu.nodak.edu
/~achapwes/PICmicro/keyboard/atkeyboard.html

bye,
gaffi
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Setting AT Scancode

Post by Pype.Clicker »

very honestly, i have seen nothing but XT scancodes getting out of the 8042 in about 8 years of low-level programming ... Is it wise to force the second set of scancodes to be reported if the controller is able to translate things ?

There doesn't look like having any distinction in the features offered by both scancodes and set 1 looks easier to deal with (break and make code for a single key are of the same length, and you have a single prefix code insead of "E0" and "F0" prefixes for set 2...)
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Setting AT Scancode

Post by Neo »

do ya mean to say that the XT scancode is what should be translated? and since we're at it how the hell do we determine if the system where the OS is being installed has an XT or AT keyboard. Any help appreciated here?
Only Human
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Setting AT Scancode

Post by Pype.Clicker »

well, if your OS is not running on a XT computer (remember those had only 8088 or 8086 processors ;] ), it means the computer does *not* have an XT keyboard. However, for the sake of downwards compatibility, the chipset will still offer XT scancodes, whatever your keyboard actually sends on its code (even if it's an USB keyboard).

Switching the scancode set is, imho, irrelevant unless you are programming a microcontroller and you wish it to get input from a PC-AT (or PC-XT) keyboard.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Setting AT Scancode

Post by Neo »

are you saying that i can just leave it as such and try translating the XT codes to ascii instead of trying to convert them to AT scancodes?
Only Human
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Setting AT Scancode

Post by Pype.Clicker »

yes, i am.
tom1000000

Re:Setting AT Scancode

Post by tom1000000 »

Hi,

Leaving the keyboard with the default XT scancodes seems like a good idea.

I just wanted to know if the default XT scancodes support ALL keys such as the new Windows keys, F12 etc.

I vaguely remember the old XT keyboards had only 86 keys. Do you need the AT scancodes to access all the newer keys?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Setting AT Scancode

Post by Pype.Clicker »

true, but by looking at http://panda.cs.ndsu.nodak.edu/%7Eachap ... odes1.html, you'll see that everything is in the XT scancode set ...
however, some codes are made of an 'extended' prefix (E0) followed by another number ... most of the 'grey keys' that were not on the initial XT keyboard (yes, the one that had function keys in 2 columns on the left of the keyboard and no other arrow keys than the numberic keyboard ;) use that E0 extended code.
Post Reply