During the game, you need to sell and buy things (a lot more buying than selling). The interface is as show in the picture. One click gets you 1 piece. 1000 clicks to get a thousand pieces. No left-press for continuesly counting up, no select 100 by right-clicking. And the two buttons on the right is "buy as much as I can afford" and "sell all".
Sometimes I did want to buy 1000 pieces of grain, but had the money to buy 10000. So I had to click the left mouse button 1000 times. No way!
Then I remembered autofire on the joysticks in the good old day. Flick a switch, and it would do the shooting for you. I wished my mouse could do that...
I then tried to short the two soldering pads through a diode (an 1N4148). It worked. There was a chance, that I could connect a transitor across the switch, and use the transitor to trigger a left-click.
Using a voltmeter, I confirmed that I could get 5V power from the circuit board. Ground was found at one end of the left mouse button switch. The other end was at 5V, probably through a pull-up resistor. I concluded this based on the observation, that both ends of the switch was at 0V when the switch was triggered.
As I was planing to use were little current, order of magnitudes less than the 500mA the USB port could supply, I did not bug myself looking at the power consumption.
The autofire would be implemented with a PIC10F200 driving a transitor put across the mouse button switch. A PIC10F200 was chosen for these reasons: I'm not very good at analoge electronics, so implementing the this without a PIC processor, was out of the question. The PIC10F200 is the smallest PIC I know of, and it would be nice to use it for something for once. The PIC10F200 does not have too many features that is not in use for this project.
I came up with this circuit:
| R1: | 470 Ohm |
| R2: | 4k7 Ohm |
| R3: | 22k Ohm |
| R4: | 100k Ohm |
| T1: | BC337-25 |
| C1: | 100nF ceramic |
| U1: | Microchip PIC10F200 |
The program of the PIC can be seen here.
The test circuit is shown here. It worked! The switch from diagram is not present. The autofire is enabled by connecting the right side pins of the two resistors on the left.
The circuit on a PCB.
I removed the mouse ball, anything mechanical associated with the mouse ball, and the scroll wheel from the mouse. My PCB fitted perfectly.
It is not perfect to look at, but it does it's job.
Thanks to Bertho Stultiens, for making a few suggestions.