Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rypyr

Old school keyboard handling

This topic is 5191 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A friend of mine had a couple games written many year ago in DOS using Borland's Turbo C++. I started toying with the idea of writing a replacement library for Borland's BGI (graphics.h), conio.h and bios.h by writing a wrapper around SDL. So far, things are going great, but I'm rewriting getch() and bioskey() and I can't remember how they are supposed to work exactly. Documentation on the web seems to be pretty sparse, all I could find was this and this. Anybody remember how bioskey(0), bioskey(1) and getch() are supposed to work exactly? Thanks a lot! Jeff
[ CodeDread ] [edited by - rypyr on March 6, 2004 10:50:03 AM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by rypyr
Anybody remember how bioskey(0), bioskey(1) and getch() are supposed to work exactly?
Urf, that brings back some unpleasant memories.

Bioskey(0) waits for a key press, and returns its code. I don''t remember the format of the code, though IIRC, it''s 16 bits. The right arrow was ~19232 IIRC.

Bioskey(1) does the same thing, but doesn''t wait, so it''s generally the one you want to use in a "real-time" game.

Getch(), you should get some documentation for it on the web. It returns the character pressed. I don''t think that it can distinguish between keys that don''t return a character. It returns a char, IIRC again.

But bioskey() was too weak; you can''t tell if two keys are pressed at the same time (unless it''s a combination with shift/control/alt --- which is why they were popular "jump" keys). The real manly way is to get the keyboard data straight from the keyboard port

Cédric

Share this post


Link to post
Share on other sites
quote:
Urf, that brings back some unpleasant memories.


unpleasant or pleasant?

quote:

Bioskey(0) waits for a key press, and returns its code. I don''t remember the format of the code, though IIRC, it''s 16 bits. The right arrow was ~19232 IIRC.

Bioskey(1) does the same thing, but doesn''t wait, so it''s generally the one you want to use in a "real-time" game.



Does bioskey(0) awit for an actual key to transition from up to down or does it return if any key happens to already be down?

Thanks,
Jeff


[ CodeDread ]

Share this post


Link to post
Share on other sites
Bioskey, IIRC, doesn''t work with the "state", but rather with key presses.

If you hold the right arrow down, but then start holding the up arrow, you will receive the code associated to the up arrow. There will then be no way to tell if the right arrow is still being held down.

Now that I think about it, I remember the need to call bioskey(0) when there is a key being pressed, otherwise the buffer would get full (and you would get the familiar PC speaker BEEP). Bioskey(1) doesn''t affect the buffer. I don''t really remember the specifics, unfortunately.

Cédric

Share this post


Link to post
Share on other sites
Ok, I''ve got it working to some degree now. However, I still need a good description of how bioskey is supposed to work.

I believe if you hold down a key, it should generate multiple events which means I need to implement a key repeat mechanism.

But what happpens if you hold down key 1, then hold down key 2. Do you only get multiple key 2 events?

Thanks,
Jeff


[ CodeDread ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!