Autofire Mouse Button

I made a mouse with autofire on the left mouse button.

Background

I found Lords of the Realm a few day ago. I had not played it for many years, but remembered it as being a great game. It was. But it reminded me of a major flaw in the game.

no easy way to pick a lot of grain in this game

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...

Basic Preliminary Testing

I took apart a Logitech Pilot Wheel Mouse. It was easy to detemine that a simple on-off-switch got pressed, when the left mouse button was presses. The switch short circuited the wires (on the printed curcuit board) it was connected to. Putting a screwdriver across the soldering pads of the switch, confirmed that I could simulate a left mouse click.

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.

Looking at the Mouse PCB

The mouse was a USB-mouse. The USB cable from the computer had 5 wires to the Mouse PCB: Red, black, green, white, and a thick black wire. Red and black was Vcc and ground, where Vcc was 5V. Green and white was for the data. The Thick black wire was connected to the casing of the USB connector.

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.

Prototype

The first job was to solder some wires to the mouse PCB. Red for Vcc (5V), black for ground, and yellow for the signal, a wire connected to the signal part of the left mouse button switch.

I added three wires to the mouse PCB

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:

Simple circuit: 4 resistors, a capacitor, a transistor, and a PIC

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 prototype made on a breadboard

Putting it on a PCB

The circuit on a PCB

The circuit on a PCB.

My PCB fits into the mouse

I removed the mouse ball, anything mechanical associated with the mouse ball, and the scroll wheel from the mouse. My PCB fitted perfectly.

Switch placed int op cover of mouse

The mouse is finished

It is not perfect to look at, but it does it's job.

Behind the Scenes

The PIC program was assembled using gpasm, and written to the PIC using piklab-prog and a PicKit2.

Lessons Learned

The autofire rate, with the current program, is about 17Hz, based on observations of real use. I tried to double the rate, but then, the autofire was interpreted as mouse-drag, not a-lot-of-mouse-clicks. I could try to fine tune the rate, but I did not bother.

Conclusion

I played some Lords of the Realm 2 using the autofire mouse, along another mouse, for doing ordinary mouse things. The game improved a lot. I only wish the programmers, back in 1996, had seen the flaw. On the other hand, I enjoyed those 8 hours of work it took me to make the mouse.

Thanks to Bertho Stultiens, for making a few suggestions.


Written by Peter Skaarup. Copyleft 2010