News:

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

keyboard input

Started by xxxx, March 27, 2005, 09:06:27 AM

Previous topic - Next topic

xxxx


this is what i understand about what happens when a key is pressed in the IBM PC

when a key is pressed,it's scan code is sent to the motherboard and decoded to get and 8-bit scan code to send to port A.then int9h
is activated.and the key is stored in the keyboard buffer in the BIOS data area.

so how and when is the key displayed on the screen?

assume that the OS of the PC is DOS.
is there a difference when the OS is Windows or any other multitasking OS?

thanks

MichaelW

I think you are describing the keyboard handling mechanism that started with the IBM PC-AT. Although the keyboards have always had an internal controller, it was not until the PC-AT that the motherboard controller was added. IIRC everything up through the interrupt takes place in hardware. Beyond that point, keystrokes are handled by the BIOS, under DOS, or by Windows. To display a key on the screen, an application would typically get the key from the OS, but under DOS, it wasn't unusual for applications to bypass the OS and access the BIOS directly. PM operating systems, including Windows, do not generally use the BIOS (except during startup, and neglecting OS/2 running on the IBM systems that included a PM BIOS) so the OS must handle everything above the hardware level. AFAIK Windows even goes so far as to reprogram significant portions of the hardware.
eschew obfuscation

xxxx

yes i am describing the IBM PC-AT.

1.so an application would directly read the BIOS keyboard data area in DOS.when does this occur?is there an interupt that signals that paricular app to read the keyboard data buffer?

2.", an application would typically get the key from the OS"
so the OS would get the key from the BIOS keyboard buffer,correct?

3.i understand that widows uses messages to communicate with apps.so when a key on the keyboard is press,is a message sent to the OS to the app in focus or does the app send a message to the OS?what happens if the key pressed was intended for a app that is not in focus?


thanks

MichaelW

Under DOS, the normal method of getting keystroke data was by polling, and the BIOS keyboard buffer and the keyboard functions (Interrupt 16h) were designed to support this. Although a DOS application can directly access and manipulate the BIOS keyboard buffer, or set up and manage its own buffer, most applications that bypass the OS just call the BIOS keyboard functions directly. Windows provides methods of polling for keystroke data, and AFAIK for a console app this is the normal method of obtaining keyboard input, but most input is handled through the messaging system.

MSDN: Messages and Message Queues

eschew obfuscation

xxxx