DIY SERIAL MOUSE

Nagging hardware related question? Post here!
tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: DIY SERIAL MOUSE

Post by tcat »

Hi All,

First of all thank you for continued support.

Having read documents I was referred to plus some other on the net, I can say that sometimes MS mouse protocol is described as 8 data bit and sometimes as 7 data bit.
Indeed there exists mice supporting both yet being in compliance with MS standard.

Afx kindly sent me a dump of his Genius xx06 type of mouse, in this particular model MS mode really is 8 data bits, while my model "MyMouse" of Genius mouse is 7 data bits.

This is the difference.

8 databit stream, leftmost MSB is "1" Xmitted by mouse, syncing bit is #6
76543210
11001100 - 1st byte
10000001 - 2nd byte
10111111 - 3rd byte
and so on ...

7 databit stream no parity, syncing bit is #6
6543210
1001100 - 1st byte
0000001 - 2nd byte
0111111 - 3rd byte
and so on ...

The actual data is taken from bits #5 to #0.
QL is designed to receive 8 data bits, it will not work with 7 unless a parity bit is transmitted as well.

Unfortunately to know that a particular mouse is serial type supporting MS mode is not enough to judge if it will work with the QL.

It seems that from a certain year of release, manufactures decided to switch to 7 bit data stream in MS mode.

While PC Mouse System mode remained apparently always at 8 data bit stream with support for three buttons. This PC mode I believe is ideal for the QL.

Some mice have a switch at the bottom, this could mean switching between PC and MS mode, but could also mean switching between 2 or 3 button function of the MS protocol later extended by Logitech to add support for the 3rd button in MS mode.

D25 connector could also give a clue, that it may be 8 bit in either mode.

I wish there were a list of supported models and makes of suitable mice for the QL.

Tom
Last edited by tcat on Wed Jun 04, 2014 7:49 am, edited 1 time in total.


afx
Trump Card
Posts: 171
Joined: Tue Dec 28, 2010 10:23 pm

Re: DIY SERIAL MOUSE

Post by afx »

tcat wrote:I wish there were a list of supported models and makes of suitable mice for the QL.
Two models supported are these:

Commodore Mouse (year 91 ??), it has a switch on the bottom, "PC" <-> "MS". The QL only works with the switch on "PC".
Commodore Mouse
Commodore Mouse
afxQLR1x.JPG (20.23 KiB) Viewed 7415 times
Genius Mouse (year 88?). By default the mouse starts in "PC mode", but when the left button is pressed while turn on the computer then the mouse starts in "MS mode". The QL also works only in "PC mode".
Genius Mouse
Genius Mouse
afxQLR2x.JPG (22.71 KiB) Viewed 7415 times
(In MS mode, Sermouse not work with QL).


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: DIY SERIAL MOUSE

Post by tcat »

Dear All,

I had a second thought and took the mouse appart. On the PCB I found a vacant placeholder for a switch marked S4, with three connection pins 3 x 2. There was a permanent truck between 2 and x, that I tripped. I have soldered in a three pin switch, and bridged 3 and x.

Please see picture.
3 pin switch
3 pin switch
I remembered your earlier suggestion, and kept the left mouse button depressed at power on.
I am now getting PC mode 8bit data packets.

So it seems Genius late models with 2-3 switch, EasyMouse, MyMouse, Mouse-3, etc, are good with QL, after all. There are two flavours, with or without a mechanical switch, but the switch can be soldered in.

This site might be usefull when looking for old serial mice as you can see mouse internals here.

http://www.tcocd.de/Pictures/Peripheral/in_mice.shtml

Tom


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: DIY SERIAL MOUSE

Post by tcat »

Hi,

I found this definition of mouse protocols usefull, it defines plain MS (M*Soft) and PC (Mouse Systems) protocols. Neither MS extension of Logitech with a third button, nor weeler in the middle.
mouse protocols
mouse protocols
This is my understanding of Mouse Systems protocol. I coded this little program in S*BASIC. It doodles on the chanel #2. It should plot by clicking,

left button - red dots
right button - green dots
both - black dots
none- white dots
middle button - quits

I was not sure how to sync the first byte in sequence, so I used this mask
11111000 binary, 248 decimal

Code: Select all

100 BAUD 1200
110 OPEN #5, ser1ir
120 LET xx = 60 : yy = 50
130 :
140 REPeat poll
150 LET b = CODE( INKEY$(#5,-1) )
160 :
170 IF (b && 248) = 128 THEN 
180   LET lb = b && 4
190   LET mb = b && 2
200   LET rb = b && 1
210 :
220   FOR n = 1 TO 2
230     LET b = CODE( INKEY$(#5,0) )
240     IF (b && 248) = 128 : EXIT n
250     LET x = b
260     IF x > 127 : LET x = x-256
270     LET xx = xx + x
280 :
290     LET b = CODE( INKEY$(#5,0) )
300     IF (b && 248) = 128 : EXIT n
310     LET y = b
320     IF y > 127 : LET y = y-256
330     LET yy = yy + y
340 :
350     IF mb = 0 THEN EXIT poll
360   END FOR n
370 :
380   IF xx < 0 : LET xx = 0
390   IF yy < 0 : LET yy = 0
400   IF xx > 210 : LET xx = 210
410   IF yy > 190 : LET yy = 190
420   BLOCK #2,4,4, xx, 190-yy, lb || rb*2
430 :
440 END IF 
450 END REPeat poll
460 CLOSE #5
It needs some patience and requires slow moves to draw a line. I would like to try compiling the code, perhaps I can make it faster, but have no experience with that.

Many thanks so far
TOM


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: DIY SERIAL MOUSE

Post by dilwyn »

tcat wrote:Hi,

I found this definition of mouse protocols usefull, it defines plain MS (M*Soft) and PC (Mouse Systems) protocols. Neither MS extension of Logitech with a third button, nor weeler in the middle.
<snip>
TOM
Thank you for posting this, it looks very useful.

I wonder if it would be possible to improve straight line drawing by ignoring small or short duration movements in the opposite direction? (must admit I haven't looked at the code to see how possible it would be).


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: DIY SERIAL MOUSE

Post by tcat »

Dilwyn,

Thank you for your encouragement.
These are my first steps with mice, I am not even sure my understanding of it is good, but it does something for me.

I believe it can be improved, perhaps it should be more correct to say it is putting out dots the distance mouse travells, when slow dots are next to each other.

I am looking into a possibility to compile the code, as I hope it can be run as job afterwards. My next goal would be to mimic cursor keys to see if it could be good with non PTR driven text editors.

Interfacing to PTR environment seems difficult challenge so far.

TOM


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: DIY SERIAL MOUSE

Post by tcat »

Hi All,

I have coded another program, this time for polling a Microsoft mouse. Again as earlier example it may put some dots as mouse moves, and coloured stippled dots when buttons are depressed, Polling may be quit by pressing 'q'.

Having no Microsoft serial two button mouse, I cannot really try the code myself.
These lines may be changed to adjust mouse sensitivity.

340 LET xx = xx + x / 5
350 LET yy = yy + y / 5

Code: Select all

100 BAUD 1200
110 OPEN #5, ser1ir
120 LET xx = 60 : yy = 50
130 :
140 REPeat poll
150 LET b = CODE( INKEY$(#5,-1) )
160 IF INKEY$(0) = 'q' THEN EXIT poll
170 :
180 IF (b && 64) = 64 THEN 
190   LET lb = b && 32
200   LET rb = b && 16
210   LET x = (b && 3) * 64
220   LET y = (b && 12) * 16
230 :
240   LET b = CODE( INKEY$(#5,0) )
250   IF (b && 64) = 64 THEN NEXT poll
260   LET x = x || b && 63
270   IF x > 127 : LET x = x-256
280 :
290   LET b = CODE( INKEY$(#5,0) )
300   IF (b && 64) = 64 THEN NEXT poll
310   LET y = y || b && 63
320   IF y >127 : LET y = y-256
330 :
340   LET xx = xx + x
350   LET yy = yy + y
360   IF xx < 0 : LET xx = 0
370   IF yy < 0 : LET yy = 0
380   IF xx > 210 : LET xx = 210
390   IF yy > 190 : LET yy = 190
400   BLOCK #2,4,4, xx, yy, lb || rb
410 :
420 END IF 
430 END REPeat poll
440 CLOSE #5
Tom


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: DIY SERIAL MOUSE

Post by tcat »

Hi All,

I have made some further progress with my QL mouse. I have reassembled Simon G, DIY mouse driver in QMAC assembler Quanta version 1.06. I needed to change some conditional assembly directives. I also changed the server to be linked as a scheduled task, as this performs better on my QL.

It works nicely for me.

It is loaded as S*BASIC extension and it updates mouse coordinate variables, that can be used directly in S*BASIC programs. It can also emulate arrow keys, so the cursor can be moved by the mouse, e.g. on S*BASIC command line, in text editors, including built-in ED as part of TK2 and also in standard suite of QL applications, such as Quill and the like.

Example1 --- reports coordinates and the state of mouse buttons

100 baud 1200 : ptr_on
110 print ptr_x%, ptr_y%, button%(0)
120 goto 110

Example2 --- puts out coloured dots on default channel, combination of mouse buttons changes the colour

100 baud 1200 : ptr_on
110 block 4,4, ptr_x%, ptr_y%, button%(0)
120 goto 110

Example3 --- starts arrow key emulation

100 baud 1200 : ptr_on : ptr_key 1,0

Example4 --- switches the driver off

100 ptr_off

Tom


Post Reply