扫描键盘获取扫描codeS [英] Scan the keyboard to obtain scan codes

查看:161
本文介绍了扫描键盘获取扫描codeS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在学习如何使一个操作系统。
的问题是,每一个网站说扫描键盘,以获得在扫描codeS中,为了检测输入。
我如何扫描键盘?
我知道这个问题似乎很可笑,但我真的不知道该怎么做了,我需要帮助。我也有提到,我GOOGLE了很多。

So I'm learning how to make an OS. The problem is that every website says to scan the keyboard to obtain the scancodes in order to detect input. How do I 'scan' the keyboard? I know this question seems very ridiculous, but I really don't know how to do that, and I need help. I also have to mention that I googled it a lot.

推荐答案

举例投票,而无需使用ISR(x86的CPU)的键盘口:

Example for polling the keyboard port without using an ISR (x86-CPU):

cli
mov  al, 2               ; dissable IRQ 1
out  21h, al
sti
;---------------------------------------------
AGAIN:
in   al, 64h             ; get status byte 
test al, 1               ; check outputbuffer
jz  short NOKEY
test al, 20h             ; PS2-Mouse byte?
jnz short NOKEY
in   al, 60h             ; get scancode (makecode or breakcode)

; place your code here for comparing.....

NOKEY:
jmp AGAIN
;---------------------------------------------
QUIT:
cli
xor  al, al              ; enable IRQ 1
out  21h, al
sti
;---------------------------------------------
; DATA 
TASTTAB DB 02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh
        DB 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Eh,1Fh
        DB 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Bh,2Ch,2Dh,2Eh,2Fh
        DB 30h,31h,32h,33h,34h,35h,39h
        DB 56h
tablen =  ($-TASTTAB)

TEXTTAB DB "1234567890ß'"      ; (using german letters)
        DB "qwertzuiopü+as"
        DB "dfghjklöä^#yxcv"
        DB "bnm,.- "
        DB "<"
textablen  =  ($-TEXTTAB)

在一个ISR简单的使用的人,60H的 的为获得扫描code。

Within an ISR simple use "in al, 60h" for to get the scancode.

这篇关于扫描键盘获取扫描codeS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆