Return to BSD News archive
Path: sserve!manuel.anu.edu.au!munnari.oz.au!hp9000.csc.cuhk.hk!saimiri.primate.wisc.edu!sdd.hp.com!cs.utexas.edu!uunet!mcsun!Germany.EU.net!unidui!du9ds3!veit From: veit@du9ds3 (Holger Veit) Newsgroups: comp.unix.bsd Subject: Re: [386BSD] Reading joystick port Date: 3 Dec 92 08:10:35 GMT Organization: Uni-Duisburg FB9 Datenverarbeitung Lines: 40 Message-ID: <veit.723370235@du9ds3> References: <jboyle.723341435@godzilla.cgl.citri.edu.au> Reply-To: veit@du9ds3.fb9dv.uni-duisburg.de NNTP-Posting-Host: du9ds3.fb9dv.uni-duisburg.de In <jboyle.723341435@godzilla.cgl.citri.edu.au> jboyle@cgl.citri.edu.au (James Boyle) writes: >Hi, >I am writing a simulation program that uses the PC to read in values from the >joystick port. These values then need to be sent over the network to an SGI >IRIS that will perform the dynamics and display the graphics. >So I can use the socket facility, I would like the PC to run BSD. >However, I don't know how to read joystick ports from a BSD process. >Is this possible? And if so how? >Any help would be appreciated. >Thanks in advance. >- James >jboyle@godzilla.cgl.citri.edu.au The dirty trick is, to drive a unix process into the "privileged" mode (protected mode, ring 0, for insiders) and then access the ports by outp and inp (routines as macros anywhere in /usr/include/machine/...). With a kernel with X11 support there is a backstage door for that. You are strongly discouraged to do these things. The clean solution is a device driver, say /dev/game. You have to write the necessary gameopen, gameclose, gameread, gameprobe, and gameattach routines. See the various lpt drivers for hints (and read some books, such as Bach, and Leiffler et al.) to understand the driver interface. The problem with the game port is that it has no interrupt, so you need some small code which periodically (internal kernel timer routines) wakes up the driver to sample the game port (once each some milliseconds). Life is not easy. Holger -- | | / Dr. Holger Veit | INTERNET: veit@du9ds3.fb9dv.uni-duisburg.de |__| / University of Duisburg | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | | / Dept. of Electr. Eng. | Sorry, the above really good fortune has | |/ Inst. f. Dataprocessing | been CENSORED because of obscenity"