mnewnam@eos.ncsu.edu (MARK NEWNAM) (10/04/90)
Keywords: I am writing a game using TP5.5 and need to be able to tell which keys were pressed if more than one key was pressed at the same time. Example 8: is jump 6: move left space: fire if a person is holding down the 6 key to move left and hits the 8 key to jump at the same time, then the keyboard buffer willl change from telling you that 6 is pressed and tell you that 8 is pressed. Now the problem is that as long as you continue to hold down the 6 key, it will continue to tell you that the 8 key is being pressed. Any ideas out there???? Mark Newnam
eli@smectos.gang.umass.edu (Eli Brandt) (10/06/90)
In article <1990Oct3.232145.18021@ncsuvx.ncsu.edu> mnewnam@eos.ncsu.edu (MARK NEWNAM) writes: >Keywords: >I am writing a game using TP5.5 and need to >be able to tell which keys were pressed if >more than one key was pressed at the same time. > >Example > >8: is jump >6: move left >space: fire > >if a person is holding down the 6 key to move left >and hits the 8 key to jump at the same time, then >the keyboard buffer willl change from telling you >that 6 is pressed and tell you that 8 is pressed. > >Now the problem is that as long as you continue to >hold down the 6 key, it will continue to tell you >that the 8 key is being pressed. > > Any ideas out there???? > > > Mark > Newnam The BIOS keyboard handler isn't set up to handle multiple keypresses. What you can do is hook into the INT 9, look at each scan code as it comes in, and then pass control on to the normal BIOS handler. For instance, if you get a keyboard scan code of 2, you know that the "1" key (on the *top*) has been pressed, and you set some bit in a public data strcture accordingly. If you get an 81h, you know that somebody took their finger off the Escape key, and so forth. Unfortunately, things get unpleasant for keys on the IBM "Enhanced" (cough wheeze) Keyboard, which sends bizarre six-byte make and break codes for PgUp, for instance. Please note that specific details, such as scan codes, are probably wrong. The general scheme, however, should work.