reverse engineer a ps2 mouse... need halp

Hello i made a mouse that listens to a wii nunchuck and just sends it serially to a program that grabs mouse position and adds mouse events.

obviously i want to make this more of hardware and make the pc think it's an actual mouse, and not a serial device... I found an old mouse with a chip specifically made to connect to a computer's ps2.
here is the chip SPCP05A
datasheet:
http://www.datasheet4u.com/html/S/P/C/SPCP05A_SunplusTechnology.pdf.html

very simple circuit on the mouse...


those optical encoders have 3 wires... does anyone know how they work? like i know how to use a 2 pinned phototransistor, but not 3.... how can it tell direction if gaps are all evenly spaced, and optical encoder only has one sensor per wheel?

how can it tell direction if gaps are all evenly spaced, and optical encoder only has one sensor per wheel

You can't that's why there are two sensors, you probably haven't seen the other one yet.

Have you seen this:-
http://www.arduino.cc/playground/ComponentLib/Ps2mouse

I have a couple of tips for you.

First, look up "quadrature" encoding. The mouse can tell direction because it uses two sensors per encoder wheel.

The phototransistor is two in one, with a common pin. The middle pin is common to both, and is probably +5. There is one pin per sensor, and it's in an "open" mode, so that it only needs one pin. That means you have to put a pull-down resistor on it if you want to read the value directly.

HTH,

[Added]
You were very lucky to find such a complete data sheet for the chip. Most of the time it's just an anonymous blob, or no data sheet exists. Unfortunately, it's really just a microcontroller, so all the mouse smarts are in the program. However, as you pointed out the circuit is fairly simple and you should be able to see what connects where.

If you want to keep the mouse guts and just fiddle the photodetector inputs, then you'll need to analyze the signals. There should be four pins on the chip connected to the sensors. Some mouse controllers will pulse the LED, and only read the inputs when the LEDs are on. You'll also have to output quadrature signals for direction. Be careful because some mice will be setup to do scaling, acceleration and sampling rates, all of which can skew the output.

If you want to emulate the whole mouse (which should be possible), then take a close look at the PS2 mouse protocol:
http://www.computer-engineering.org/ps2mouse/

Have fun,

ok i wasn't sure how the 3 pinned phototransistors worked, but makes sense now.
thank you very much. Now if i wanted to buy more of these chips, would they come pre-programmed?

for ease of use i'll try getting this chip working and rebuilding the circuit.. Yes it would just take software, but the arduino ps2 mouse is for reading the mouse. not emulating one.