X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Tim Nicholson Newsgroups: comp.os.msdos.djgpp Subject: Re: Handling multiple keys in video game Date: Sun, 29 Feb 2004 08:37:27 +0000 (UTC) Organization: BT Openworld Lines: 38 Message-ID: References: NNTP-Posting-Host: host81-128-153-22.in-addr.btopenworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sparta.btinternet.com 1078043847 20555 81.128.153.22 (29 Feb 2004 08:37:27 GMT) X-Complaints-To: news-complaints AT lists DOT btinternet DOT com NNTP-Posting-Date: Sun, 29 Feb 2004 08:37:27 +0000 (UTC) In-Reply-To: X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031210 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Mike H wrote: > How do I tell which keys are being held down (W, A, S, and D for > example) either alone or simultaneously? If I try to use inportb(0x60) > and press A, then S, then release A, I get something like > > 30 > > 31 > > 158 for a split second > 31. > > This is bad if the game doesn't recognize that split second. What > technique do you use? To do it yourself you would need to write an Interrupt service routine for the keyboard interrupt line IRQ01. Although this is not too difficult under DJGPP, it does involve a good understanding of both DJGPP and the PC hardware. A better solution would be to download the Allegro games programming library for DJGPP (and others) from http://www.talula.demon.co.uk/allegro/ this will give you all the keyboard control you need and a lot of additional useful games stuff as well. Allegro provides you with a Boolean array called key[] which contains an entry for each key with a true value if the key is down and a false if it is up, this means that if you which to test if both A and S are pressed you just need a statement like if (key[KEY_A] && key[KEY_S]) { .. } Hope this is some help Tim Nicholson