Mail Archives: djgpp/1997/03/11/16:04:19
Christoph Kukulies writes:
>#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.
Ok, sorry: I lied :-) The button bits are usually 1, and zero when the
button is pressed. But my comments about the timing still stands. When
you do the outportb(), you reset the low four bits to 1. You should then
go into a loop, calling inportb() but not writing anything to the port,
and measure how long it takes the low bits to fall back from 1 to 0. The
time delay for bits 0 and 1 gives you the X and Y position of the stick.
btw. such PC hardware issues are really off-topic for this group: I
suggest you get a copy of the PCGPE which covers all this in some
detail...
/*
* 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.
*/
- Raw text -