On Fri, 3 Dec 2004, Alexandre Quessy wrote:
Pd is quite amazing, and we can do just about anything. It's interesting to offer something else than keyboards to interact with electronic art. What about a Nintendo or SEGA gun ?
AFAIK, the way the Nintendo gun works is that it is a simple photosensor that is made very directional by usage of both a lens and a thin cannon. Therefore, for using it, when a click is detected, the program usually blanks the screen except for a few targets, and then figures out whether the gun detects a target.
I don't know how it differentiates between two targets; maybe it uses a sequence of black frames containing one white region each, and then does some tight realtime figuring out the exact frame that the gun detected. It's also possible to figure out in one frame the vertical position on the screen using sub-millisecond timings and a lot of sync; but to differentiate two regions at the same height you'd need two frames (unless i'm missing some trick)
I found this:
http://www.epanorama.net/documents/pc/lightpen.html http://en.wikipedia.org/wiki/Zapper_Light_Gun http://nesdev.parodius.com/zapper_to_famicom.txt
And from what i can guess,
__
/ o| 1 5 |o o| 2 6 |o o| 3 7 |o o| 4 `---'
1 is ground, 2,3,4 is a serial port for the 8 buttons not in the gun, 5 is +5 volts 6 is a bit (not an analog signal) for the lightgun value 7 is a bit (inverted) for the trigger of the gun
You could use one of the three available parallel port externals as a way to connect to pd. Then you plug nintendo pins 5,6,7 into, say, pins 2,10,13 of the parport. Then you send the 255 byte so that pins 2-9 provide +5V. I hope there is enough amperage in pin 2 for the gun to work, but if you need more, try several pins at once (or maybe it doesn't do anything).
Note: If using linux lp driver, you have to ground pins 12,13 (onto, say, pin 25) to be able to send anything, else it blocks. Marc Lavallée's parport external avoids this issue but requires root access to run.
It would also be possible to use the db15 joystick port for that, if that's easier. See http://www.epanorama.net/documents/joystick/pc_joystick.html
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju