Mail Archives: djgpp/1997/03/11/04:09:01
> 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
Hmm. bits 2 and 3 ?
With the following test program
#include <stdio.h>
main()
{
int i;
while(1){
outportb(0x201,0xff);
i=inportb(0x201);
printf("%02x\r",i);fflush(stdout);
}
}
I'm getting 0xff when no button is pressed or no stick action is made.
When I press one fire button I'm getting 0xef, the other 0xdf.
This joystick has two fire buttons (Saitek MEGASTICK III, MX-130)
(e.g.: http://www.dbline.it/shtm/jmx-130.htm)
Are the two fire buttons equivalent to the second joystick?
Why do I see no data in the first nibble?
> 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.
> */
>
--
Chris Christoph P. U. Kukulies kuku AT gil DOT physik DOT rwth-aachen DOT de
- Raw text -