Is there a good way to detect keypresses without BIOS ? Found out that
after CLI the thing no longer reacts to CTL-ALT-DEL ... but reboots as soon
as STI occurs

How to detect keypresses after CLI ? And is there a good way to deactivate
the collecting/buffering of keypresses ? I am interested only in a keypress
at the moment of detection, not all the garbage that might have
been typed before ...

_________________Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug

28 Jan 2007, 20:42

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

Most probably all the information you need may be found in Ralph Brown's interrupt list (PORTS.LST for ports 60h-64h description, INTERRUPT.LST for list of scan codes in Table 00006).

Is the keypress buffering (+mouse buffering and messing it into same
buffer ) hard-wired in the hardware, with no possibility to deactivate ?

What are the limitations of this method ? Down to pre-PS/2 80386 PC's ?
USB keyboards ?

_________________Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug

01 Feb 2007, 19:47

Japheth

Joined: 26 Oct 2004
Posts: 151

Japheth

> Is the keypress buffering (+mouse buffering and messing it into same
> buffer Sad ) hard-wired in the hardware, with no possibility to deactivate ?

both keyboard and ps/2 mouse can be deactivated (RBIL, ports.A).

But why polling the keyboard anyway? Disabling interrupts while waiting for a keystroke will almost certainly loose timer interrupts, which is rather bad.

The two devices use different IRQs (kbd IRQ 1, mouse IRQ 12), so if you want to poll the keyboard only, you can selectively disable IRQ 1 (PIC port 21h, bit 1). I'm not sure, however, if this works reliably, should be tried out first.

01 Feb 2007, 20:38

MCD

Joined: 21 Aug 2004
Posts: 604
Location: Germany

MCD

if you have USB mouse/keyboard, things get much more complecated. I'm not so into USB programming, but how much USB databases/lists does one need to access simple mouse/keyboard?

01 Feb 2007, 20:42

DOS386

Joined: 08 Dec 2006
Posts: 1901

DOS386

Thanks.

Quote:

both keyboard and ps/2 mouse can be deactivated (RBIL, ports.A).

OK, it is sort of documented ... but not really obvious how to use, and
maybe even dangerous:

Code:

Note: Attention: Never write anything other than 99h to this port
(better: never write anything to this port, only during BIOS
init), as other values may connect multiple output drivers
and will cause hardware damage in PC/XTs! By setting command
word to 99h, PPI will be set in input/output modes as it is
necessary to support the commonly known IO-ports 60,61,62
as desired.

But now seems I have not really the need to deactivate the buffering or
the kbd or mouse completely

Remains the USB issue: I had a look at source of DKRNL32.DLL and did
not understand really much but it seems that DKRNL32 picks keypresses
from port $60 in IRQ1 - does this mean that DKRNL32 does NOT
work with USB kbd's either ? I now have no USB kbd's to test

BIOS will (mostly) copy keypresses from USB somewhere - to INT $16
maybe, rather than into port $60 ?

Quote:

But why polling the keyboard anyway? Disabling interrupts while waiting for a keystroke

Tomasz's example was waiting, my issue is not waiting, but possibility to
abort a running process: exit if <ESC>, otherwise continue.

Quote:

will almost certainly loose timer interrupts, which is rather bad.

What is the damage ? Anyway, timers was an issue I wanted to ask next:
can I use the timers (OK, they hang on ports $40...$5F as "documented"
in the same text ) without interrupts (after CLI) to generate a delay
of cca 50us - start the timer, execute some code (should take <50us),
and then wait for "completing" the 50us ?

OK, I retested the "loose timer" problem: the CLOCK is FROZEN while
CLI and it remains delayed Unreproductable: if the PC is off, the
clock runs also, although no interrupts occur either Any good way
to prevent this problem, except not to use CLI ?

_________________Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug

01 Feb 2007, 21:52

Japheth

Joined: 26 Oct 2004
Posts: 151

Japheth

> if the PC is off, the clock runs also, although no interrupts occur either

yes, the RTC runs always. But the RTC and the PIT are 2 different devices, and DOS synchronizes with the RTC "not very often".

Simplest way to detect a keypress (not one of the status keys, however) without calling the BIOS is to check variables [41Ah] and [41Ch]. If they are equal, the keyboard buffer is "empty".

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum