Main page

How to build PS/2 Wheel Mouse Controller

For beginning: from version 1.4, there is new version of hardware - but you can still use your old hardware because of two new firmware versions. Detailed description of each of them with schemes and links to firmwares you can read here.

Part list

You will need at least following for building this controller: If you don't have PIC16F62x, or you want to modify existing PIC16F84-based controller and anyway don't want to use 2-wheel mice or joystick simulation in future, you can still use instead of PIC16F62x. Current and all next versions of firmware anyway will support both PICs.

If you want to reduce cost of controller by approx. 2 USD, you can replace flash PIC by OTP (One-Time-Programmable) PIC. It may be one of following PICs: PIC16C554, PIC16C558, PIC16C620, PIC16C621, PIC16C622 and some others. Them are cheaper, but you can't update firmware - you will need to replace PIC for that. Additionally, there is no OTP PIC programmers on Amiga now (June 2001), and you will need to program it elsewhere.

Optionally, you may use following parts:

PIC programming

You can program PIC on existing programmer, or build my simple devpic package.

Building of device

Finally select hardware version, and build it by schematic diagrams. Personally I don't use PCB, and I assemble it directly in DB-9 connector case (see photos on front page of manual). But if you want to do PCB - there is a reference PCB design, done by Marc SAVART []. It is designed for use on A4000T (also you can see photos archive of ready device). I can't give any warranty for this PCB design, but now I manually check every version for wrong connections :)


If assembled device doesn't work - there is a list of probable errors: If you have oscilloscope - see signal at OSC pins (not for PIC16F62x). Schematic diagram is already tested and doesn't contain bugs. There are tens of people that assembled and use it now.


Probably it is a most interesting part of this manual :-)  Because of open source you can modify source code for your needs. This source may be recompiled by picasm assembler (you can find it in devpic package). There is macros.i file, contains my favorite macro operators - it must be in current directory for picasm with source file. Usage of picasm is very simple:

picasm ps2m

Both firmware versions may be generated from one source because of conditional asseymbly usage. POWER variable (see line POWER equ...) defines it - 0 value is a 5-button version, and 1 value is a 4-button version. SPEED variable allows you to use different resonators, than 4MHz (see comment).

Some comments about several program parts destination:
intInterrupt handler - it is called every mouse clock (11 times per byte) and eats approximately a half of 4MHz PIC speed. After byte receiving, this routine stores received byte in recvdt and sets flag fbyte. These bytes are stored in packet buffer in «main loop».
Init code. Some details about mouse detection:
  • At first, there is Genius init sequence: 0xE8 0x03 0xE6 0xE6 0xE6 0xE9. After 0xE9 command mouse sends status bytes, or Genius NetScroll magic sequence 0x00 0x33 0x55. In last case (it means that it is Genius NetScroll with 5 buttons), controller uses Genius mode and skips next init sequences.
  • At second, there is Microsoft init sequence: 0xF3 0xC8 0xF3 0x64 0xF3 0x50. After this, controller reads mouse ID (0xF2) and checks it for equivalence with 3. If it is true - mouse is in Intellimouse mode now (wheel + 3 buttons).
  • At third, there is new Microsoft init sequence: 0xF3 0xC8 0xF3 0xC8 0xF3 0x50. After this, controller reads mouse ID again and checks it for equivalence with 4. If it is true - mouse is in Intellimouse Explorer mode now (wheel + 5 buttons). If mouse ID still is 3 - it means that it is only Intellimouse - not Explorer.
m_check It is a code, that will be executed after 2 seconds of mouse «silence». It reads mouse status and sees stream mode flag. If stream mode is disabled - this means that mouse was reconnected. In this case controller will reset it.
p_init Here is setting of initial values of «virtual sync serial port». It is used mainly for «re-sync» if sync was lost due to electric surge/noise (bit(s) was lost or unnecessary bit(s) was added).

Additionally, this routine contains check for «alien» signal on LMB pin (for example - second joystick «fire») and disable controller.

schk This routine receives bytes in packet buffer (byte1-byte4). After this it sets fpkt1 flag.
pchk1 This routine will be called after receiving of full packet. Because of controller is all time in «main loop» simulates mouse movement, packet processing is done by several parts. It is a first part - processing of horisontal movement. After processing this routine sets flag for next routine (fpkt2), and without own flag (fpkt1) it will not be processed again up to next packet receiving.

Processing of movement contains calculating of mouse speed - movement will be done with this speed.

pchk2 This routine is like previous, and it processes vertical movement.
pchk3 This routine processes all mouse buttons (at first - standard three buttons), and then it processes additional buttons and wheel (only if these were detected).
tchk It is a timer support. Controller updates mouse signals only approx. 6000 times per second. If next 1/6000 of second doesn't approach yet, controller will return to checking of next byte.
mchk It is a mouse checking - as described above.
It is realtime update of movement counters with needed speed.
zchk Wheel counter update.
xyout Movement counters and fourth button are simultaneously updated here.
cpoff This subroutine enables controller, if it is disabled. Additionally it sets counters in default state.
testms Check for Microsoft protocol(s). Both protocols are checked in one subroutine because of similarity (one byte difference).
send Sending byte to mouse. Because of rare nature of this action, it is not done by interrupt engine (that also unloads interrupt routine from rare instructions).
bwait It is a waiting for byte from mouse. Actually a byte receiving subroutine.
Delays by milliseconds and fourt microseconds (in W).