1. Holding Buttons in DOS

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01BDF236.ADE63846
        charset="iso-8859-1"

I'm trying to emulate Win32-style key events in DOS. I need a *different*
way of reading the keyboard.

Here's a typical problem with the way the keyboard is currently handled. I'm
trying to emulate Win32 button behavior in DOS. Pressing down the spacebar
when the focus is on the button toggles the button, and it is held down
until the space bar is released. You can tab off the button, even if it is
pressed, and not have it selected.

When I try to duplicate this in DOS, holding down a button triggers the auto
repeat on the key, and I end up getting a stream of keys. Even if I wait for
-1 event on get_key() to emulate a key up/down type behavior, the auto
repeat clicks away - very irritating.

Win32 splits a button press into three seperate events: key down, key up,
and key press. For example, if you hold down the Space bar, you might get
the following events queued:

        Space key down
        Space key pressed
        Space key pressed
        Space key pressed
        Space key pressed
        Space key up

How do I query the keyboard to get this information? I've seen this done in
Allegro, but they replace the DOS interrupt with one of their own, and I'm
not big on writing interrupts myself...

Thanks!

-- David Cuny

------_=_NextPart_001_01BDF236.ADE63846
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2232.0">
<TITLE>Holding Buttons in DOS</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>I'm trying to emulate Win32-style key events in DOS. =
I need a *different* way of reading the keyboard. </FONT>
</P>

<P><FONT SIZE=3D2>Here's a typical problem with the way the keyboard is =
currently handled. I'm trying to emulate Win32 button behavior in DOS. =
Pressing down the spacebar when the focus is on the button toggles the =
button, and it is held down until the space bar is released. You can =
tab off the button, even if it is pressed, and not have it =
selected.</FONT></P>

<P><FONT SIZE=3D2>When I try to duplicate this in DOS, holding down a =
button triggers the auto repeat on the key, and I end up getting a =
stream of keys. Even if I wait for -1 event on get_key() to emulate a =
key up/down type behavior, the auto repeat clicks away - very =
irritating.</FONT></P>

<P><FONT SIZE=3D2>Win32 splits a button press into three seperate =
events: key down, key up, and key press. For example, if you hold down =
the Space bar, you might get the following events queued:</FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>Space key =
down</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>Space key =
pressed</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>Space key =
pressed</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>Space key =
pressed</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>Space key =
pressed</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>Space key =
up</FONT>
</P>

<P><FONT SIZE=3D2>How do I query the keyboard to get this information? =
I've seen this done in Allegro, but they replace the DOS interrupt with =
one of their own, and I'm not big on writing interrupts =
myself...</FONT></P>

<P><FONT SIZE=3D2>Thanks!</FONT>
</P>

<P><FONT SIZE=3D2>-- David Cuny</FONT>
</P>

</HTML>
------_=_NextPart_001_01BDF236.ADE63846--

new topic     » topic index » view message » categorize

2. Re: Holding Buttons in DOS

>    I'm trying to emulate Win32-style key events in DOS. I need a
> *different* way of reading the keyboard.

Getting Micheal Bolin's excellent key-board handler.
It will not generate effects, however, it will at request give you a status
report of the current keys pressed.
However, any type of event scheme is possible using this approuch.

A simple get_keys () call return a list of all keys currently pressed.
You can find it at the archives.

It has been used in a number of programs and games. (including mine)
Ralf

new topic     » goto parent     » topic index » view message » categorize

3. Re: Holding Buttons in DOS

------=_NextPart_000_004C_01BDF230.491E0CA0
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

David Cuny wrote
(regarding key up/down status)
> How do I query the keyboard to get this information?

If Michael Bolin's interrupt handler seems like overkill,
you could also look at Marcel Kollenaar's "Keyboard Status Function"
in the Archive. However it only works on special keys like
shift, control, Alt etc. and I think maybe you know how to do this
already.
=20
Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/=20
=20

------=_NextPart_000_004C_01BDF230.491E0CA0
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 =
HTML//EN"><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000><FONT size=3D3>David Cuny =
wrote</FONT></FONT></DIV>
<DIV><FONT color=3D#000000><FONT size=3D3></FONT></FONT><FONT =
size=3D3>(<FONT=20
color=3D#000000>regarding key up/down status)</FONT></FONT></DIV>
<DIV>&gt; How do I query the keyboard to get this information?</DIV>
<DIV>&nbsp;</DIV>
<DIV>If Michael Bolin's interrupt handler seems like overkill,</DIV>
<DIV>you could also look at Marcel Kollenaar's &quot;Keyboard Status=20
Function&quot;</DIV>
<DIV>in the Archive. However it only works on special keys like</DIV>
<DIV>shift, control, Alt etc. and I think maybe you know how to do =
this</DIV>
<DIV>already.</DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000><FONT =
size=3D3>Regards,<BR>&nbsp;&nbsp;&nbsp;&nbsp; Rob=20
Craig<BR>&nbsp;&nbsp;&nbsp;&nbsp; Rapid Deployment=20
Software<BR>&nbsp;&nbsp;&nbsp;&nbsp; <A=20
/A></FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>

------=_NextPart_000_004C_01BDF230.491E0CA0--

new topic     » goto parent     » topic index » view message » categorize

4. Re: Holding Buttons in DOS

Ralf suggested:

>Getting Micheal Bolin's excellent key-board handler.
>It will not generate effects, however, it will at request give you a status
>report of the current keys pressed.

Using Michael's library is pretty simple (once the keycode->ascii table has
been built. Unfortunately, the keys still click on my HP Vectra. Grrr...

Thanks.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

5. Re: Holding Buttons in DOS

>Ralf suggested:
>>Getting Micheal Bolin's excellent key-board handler.
>>It will not generate effects, however, it will at request give you a
>>status report of the current keys pressed.

David replied:
>Using Michael's library is pretty simple (once the keycode->ascii
>table has been built. Unfortunately, the keys still click on my HP
>Vectra. Grrr...

You just need to try to call get_keys() more often. (To flush the
keyboard buffer.)

If you hold down a key and have it held down long enough for the delay to
go off, and to repeat 13 or so times (keyboard buffer limit) without
calling get_keys(), you'll get the beeps.

If you get the beeps, it means your code is too slow or you're not
calling it enough. (Try some dummy calls in a few places--It claims to be
a very fast routine.)


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu