sota@tc.fluke.COM (Bruce White) (12/06/88)
I am interested in seeing some code fragments showing how to read the postion of the joystick, and the state of the buttons. This assumes that the joystick is connected to a clone via the Game Port Card. Code in any language will do, but 'c' is preferred. Are there any good references on this subject? Thanks. -- Bruce T. White John Fluke Mfg. Co., Inc. {uw-beaver,decvax!microsof,ucbvax!lbl-csam,allegra,ssc-vax}!fluke!sota
everett@hpcvlx.HP.COM (Everett Kaser) (12/08/88)
I don't have any code fragments available, but here's the text of a note I posted about a year ago in response to a similar question: The IBM Game Control Adapter (adapted from the IBM PC XT Tech Ref Manual). The game port is controlled/accessed through a single I/O location located at hex 0x201. The hardware, simplified, consists of four 555-type timers set up in one-shot mode, with the length, or duration, of the one-shot pulse controll- ed by the current value/position of the potentiometers in the joysticks (one timer is controlled by each of four potentiometers, two potentiometers per joystick, one each for x and y directions). Additionally, there are four "digital" inputs, pulled high (+5) by pull-up resistors on the game card, that are usually connected to normally-open switches that, when pressed or closed, ground those input lines. The normal way these are hooked up is two joysticks with two buttons per joystick, thus accounting for all of the inputs. The program should do an output to 0x201 (of any value, doesn't matter), which will trigger the one-shots, causing the inputs from them (reading 0x201, the four least significant bits) to go high for a varying amount of time (the amount of time is controlled, of course, by the current setting of the potentiometers). When reading 0x201, the bits are: Bit 0 joystick A x-coordinate timer 1 joystick A y-coordinate timer 2 joystick B x-coordinate timer 3 joystick B y-coordinate timer 4 joystick A button 1 5 joystick A button 2 6 joystick B button 1 7 joystick B button 2 "The user must first begin the conversation by an Out to address hex 201. An In from address hex 201 will show the digital pulse go high and remain high for the duration according to the resistance value. All four bits (3-0) function in the same manner; their digital pulse will all go high simultan- eously and will reset independently according to the input resistance value." "These buttons default to an open state and are read as 1. When a button is pressed, it is read as 0. Software should be aware that these buttons are not debounced in hardware." Everett Kaser !hplabs!hp-pcd!everett
noren@dinl.uucp (Charles Noren) (12/09/88)
An excellent article covering the issues in reading a joystick: Magazine article: Firmware Furnace: Using the IBM PC Joystick Port, Circuit Cellar Ink, Vol 1, No. 4 (July/August 1988) (ISSN 0896-8985) ...subscriptions and orders: Circuit Cellar INK 12 Depot Square Peterborough, NH 03458-9909 (203) 875-2751 Also Keith Peterson (maintainer of the CP/M and MSDOS archives) has a good C program on joysticks he sent me when I had a similar question. -- Chuck Noren NET: ncar!dinl!noren US-MAIL: Martin Marietta I&CS, MS XL8058, P.O. Box 1260, Denver, CO 80201-1260 Phone: (303) 971-7930