Anonymous user
PS/2 Keyboard: Difference between revisions
Jump to navigation
Jump to search
Added a solution to read scancodes without interrupts, a few minor grammatical corrections.
[unchecked revision] | [unchecked revision] |
m (Link was 404, archive.org had nothing) |
(Added a solution to read scancodes without interrupts, a few minor grammatical corrections.) |
||
Line 227:
== Enough, give me code! ==
So, first read the scan code set table, and now start to code. If you too lazy,
(inb/outb can be found here: [[Inline Assembly/Examples#I.2FO access|Inline Assembly Examples - I/O Access]])
Line 251:
}
</source>
If you have not set up interrupts yet, the code for the function that reads scancodes will be slightly different:
<source lang="C">
char getScancode()
{
char flag = inb(0x64);
while(!(flag & 1)) {
flag = inb(0x64);
}
return inb(0x60);
}
</source>
The reason we are reading port 0x64 first is because in an environment without interrupts, one must first read the status port (0x64) and see if the first bit is set to one. If the first bit is set to one, the loop ends and we read port 0x60, returning a scancode. If it is not set to one, we do not read it and loop until it is set to one. This will assure that we are not infinitely releasing scancodes (since we do not have interrupts yet to make sure they are only pressed once).
== Scan Code Sets ==
|