PS/2 Keyboard: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
Added full code. |
|||
Line 226: | Line 226: | ||
* Various "toggle" states (CapsLock, ScrollLock, NumberLock, etc) |
* Various "toggle" states (CapsLock, ScrollLock, NumberLock, etc) |
||
== Enough, give me code! == |
|||
So, first read the scan code set table, and now start to code. If you too lazy, there's a full code: |
|||
<source lang="c"> |
|||
/* |
|||
PS/2 keyboard code. |
|||
Dependencies: |
|||
inb function and scancode table. |
|||
*/ |
|||
char getScancode() |
|||
{ |
|||
char c=0; |
|||
do { |
|||
if(inb(0x60)!=c) |
|||
{ |
|||
c=inb(0x60); |
|||
if(c>0) |
|||
return c; |
|||
} |
|||
}while(1); |
|||
} |
|||
char getchar() |
|||
{ |
|||
return scancode[getScancode()+1]; |
|||
} |
|||
</source> |
|||
== Scan Code Sets == |
== Scan Code Sets == |
||