From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: joystick reading (gameport) Date: Mon, 10 Mar 1997 15:18:45 +0000 Organization: None Distribution: world Message-ID: References: <199703101327 DOT OAA01724 AT gilberto DOT physik DOT rwth-aachen DOT de> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 40 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Christoph Kukulies writes: >I found that the inport for the joystick - I want to use it to >position my XYZ-stepper motor assembly - is 0x201 and reading >using inportb(0x201) gives me the fire button statii but where >is the data for the stick itself? It's a mess :-) The position is read by status bits in 0x201: bit 0 is the X axis, bit 1 is the Y axis, and bits 2 and 3 are for the second joystick. You write a byte to 0x201 (any value), which sets these bits to 1, and then time how long they take to fall back to 0. How to interpret the results depends on the type of joystick, so you need to calibrate it before use, by measuring the time with the joystick in some known positions. Allegro has some code that does all this: look in joystick.c and misc.s. >Sorry, I'm a nono on DOS game programming. Are there int13/21 >calls for reading the joystick information and should I use them >better over direct I/O statements? There are (I can't remember the details offhand: look in Ralph Brown's Interrupt List), but they are only supported by a few BIOS's. You might be lucky, which is fine if you only care about your program running on your machine, but they haven't been implemented on the last couple of systems I tried. >Should I take care for contact bouncing, when reading the data? Depends on the stick. Some (the more expensive ones) are ok, but on most the buttons will bounce a few times. And the position can wobble quite a bit, and doesn't always centre itself to the same place. The things are a real pain... Check out the PCGPE (on x2ftp.oulu.fi) for more info. /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Beauty is a French phonetic corruption of a short cloth neck ornament. */