English Amiga Board


Go Back   English Amiga Board > Support > support.Hardware

 
 
Thread Tools
Old 10 August 2017, 17:34   #1
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
Scroll wheel with PS/2 mice

Hi,

I recently started playing around with some cool little Arduinos (Minis & Nanos) and was able to create a PS/2 Amiga mouse adapter.

It seems to work well but I would like to implement scroll wheel support.
The Amiga mouse port only has 2 quadrature encoders so this is not straightforward.

Some designs use the joystick port as well but this feels a bit hacky for me.

I notice that the Cocolino claims to support the scroll wheel. Does anyone know how they implement this?

The best idea I can think of is to pull all 3 mouse buttons high which signals to a custom mouse driver that the X/Y quadrature encoder is now the scroll wheel.

This is something a beginner in electronics can easily construct, it's literally just soldering a few wires to a £2 Arduino clone.
nogginthenog is offline  
Old 10 August 2017, 17:52   #2
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by nogginthenog View Post
I notice that the Cocolino claims to support the scroll wheel.
It does. Unfortunately the mouse pointer movement isn't as nice as a normal Amiga mouse. It's less accurate. Just leave the scroll wheel out. It's impossible to implement properly without hacks using only one port.

And yes, it's a thing. I have a Cocolino, and I think it sucks because of this hack.
Thorham is offline  
Old 10 August 2017, 18:12   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
This page shows the pinout of the Amiga's game port: http://old.pinouts.ru/Inputs/AmigaMouseJoy_pinout.shtml

If you could somehow utilise the PotX input to simulate an analogue signal, you could make a very accurate mouse wheel. With the PotY you could even read a second wheel.

Just keep in mind that PotX is shortened by the middle mouse button and PotY by the right button.
thomas is offline  
Old 10 August 2017, 18:39   #4
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
Quote:
Originally Posted by nogginthenog View Post
I notice that the Cocolino claims to support the scroll wheel. Does anyone know how they implement this?
I think the Cocolino is an evolution of Eyetech's EZMouse, which was originally my design. What I did was have the microcontroller use PotX as a select signal, similar to how a Megadrive joypad works. a VBlank interrupt runs on the Amiga which briefly pulls PotX low. This signals the adapter to put alternative data on the mouse button lines and two of the direction lines (whichever two are mapped to the least significant bits of the mouse counters - I forget now), then an input handler generates NewMouse-style mousewheel events from these signals.

If memory serves, the Punchinello Mk II did some kind of simulation of analogue signals. The problem with this method is that the analogue counters on the Amiga count at different rates depending on the current screenmode.
robinsonb5 is offline  
Old 10 August 2017, 18:54   #5
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
Thanks guys! Looks like the 3rd mouse button is the key. I wasn't aware the Amiga could write to the POT registers. This is very helpful!
nogginthenog is offline  
Old 10 August 2017, 19:00   #6
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Don't add support for a scroll wheel. Your adapter will end up being horrible like the Cocolino. I know, I have one. Wouldn't have bought it if I knew beforehand, and would have bought a normal Amiga mouse instead.

Really, DON'T.
Thorham is offline  
Old 10 August 2017, 20:38   #7
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by nogginthenog View Post
I notice that the Cocolino claims to support the scroll wheel. Does anyone know how they implement this?
IIRC they use the pin for the middle mouse button, to send digital signals.
Joysticks with more than 3 buttons send them this way ; middle button + wheel up + wheel down could simply do the same.
meynaf is offline  
Old 11 August 2017, 06:28   #8
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by meynaf View Post
IIRC they use the pin for the middle mouse button, to send digital signals.
Cocolino uses a nasty movement pins hack for the scroll wheel. Terrible design choice.

See here: http://www.amiga.org/forums/showpost...0&postcount=32

Last edited by Thorham; 11 August 2017 at 06:40.
Thorham is offline  
Old 11 August 2017, 08:11   #9
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by Thorham View Post
Cocolino uses a nasty movement pins hack for the scroll wheel. Terrible design choice.

See here: http://www.amiga.org/forums/showpost...0&postcount=32
Then this has to be better explained. Not only most people on this thread don't see it, but also if this were true, moving the wheel would trigger small mouse moves if the driver isn't run, and, sorry, it wasn't the case with any of my two cocolinos...
meynaf is offline  
Old 11 August 2017, 08:14   #10
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Quote:
Originally Posted by Thorham View Post
Cocolino uses a nasty movement pins hack for the scroll wheel. Terrible design choice.

See here: http://www.amiga.org/forums/showpost...0&postcount=32
Actually I think my explanation there is wrong. The effect where the mouse movement flattens out to a vertical or horizontal line is definitely there in some adapters, but there's a different reason behind it than what I suggest.
Leffmann is offline  
Old 11 August 2017, 10:12   #11
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
That flattening out on near-horizontal or vertical lines was something I always though was a "feature" of PC mice. To this day, you can easily draw a straight line of pixels in Paint or whatever on Windows by being careful with the movement, but the same thing is far more difficult using a native Amiga mouse. So perhaps it's part of the PS/2 protocol that has been replicated by some adaptors? Or maybe it's built into the controllers on some mice?

Anyway, using a PS/2 mouse on my Cocolino certainly feels different, but I haven't noticed a reduction in sensitivity or anything like that. And on the other hand, I'm totally lost on an Amiga when I *don't* have a scroll wheel, I've become that used to having it.

If you're doing the software side on the Amiga yourself, you can use whatever communication scheme you like. The CD32 approach might indeed be a nice way to do things, switching to serial input mode once a frame to receive a minimal few bits of information from the adaptor along pin 9 (RMB). I have to say that I thought the Cocolino sent its extra information over pin 5, but maybe I'm wrong there...
Daedalus is offline  
Old 11 August 2017, 10:28   #12
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
Quote:
Originally Posted by Leffmann View Post
Actually I think my explanation there is wrong.
Yeah, it doesn't discard the LSBs, it simply briefly re-uses them for wheel signals, during a vblank interrupt, and resets them again long before the system reads the mouse counters again during the next vblank. The LSBs are only changed in response to a signal from the wheeldriver, so if that's not running they're left alone. So whatever makes that particular adapter / mouse combination feel so horrible, it's something else, not the multiplexed wheel support.
[I'm assuming here that the Cocolino is indeed the same thing as the EZMouse - Amiga.resource.cx reckons it is.]
robinsonb5 is offline  
Old 15 August 2017, 15:40   #13
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
Thanks to everyone here. I have the scroll wheel mostly working.

Amiga VBlank interrupt server
Every frame pull the middle button low.
Delay a little by reading horiz changes in VHPOSR.
Read middle/right mouse ports.
Pull the middle button high.
Signal() the main Task which does the input injection.

Arduino
Middle mouse button generates an interrupt when pulled low.
The interrupt checks the status of the mouse wheel and writes to the middle/right mouse pins.
Delay a bit
Reset the pins.

I had to use my scope to get the timing right on both sides.
This gives me 4 commands. 0=Nothing 1=ScrollUp 2=ScrollDown 3=Unused. I could add another bit if I used the left button too.

To do:
  • I'm developing on a 68060 so I suspect the timing will need tweaking. My A4000/030 wasn't working last time I checked. Need to sort that.
  • The scroll wheel is much too fast!
  • See if I can add a middle mouse button event.
  • Build the final hardware. It's all on breadboard right now.
  • Code cleanup.
  • Document & publish.

I fried 1 Arduino in the process - magic smoke and all

Edit: forgot to add, the Amiga driver is optional. It's only used for scroll wheel support.

Last edited by nogginthenog; 15 August 2017 at 16:01.
nogginthenog is offline  
Old 15 August 2017, 15:51   #14
indigolemon
Bit Copying Bard
 
indigolemon's Avatar
 
Join Date: Jan 2017
Location: Kelty, Fife, Scotland
Age: 41
Posts: 1,293
Good work sir
indigolemon is offline  
Old 16 August 2017, 00:59   #15
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
Quote:
Originally Posted by nogginthenog View Post
Thanks to everyone here. I have the scroll wheel mostly working.
Nice going!

Quote:
Middle mouse button generates an interrupt when pulled low.
The interrupt checks the status of the mouse wheel and writes to the middle/right mouse pins.
Delay a bit
Reset the pins.
You're probably already doing this if you're using interrupts, but when you drive the middle mouse button pin high, do it by putting the arduino in input mode with pullup enabled - don't drive it high in output mode if you're going to have the Amiga drive the same pin low. The Arduino pin can source a fair bit of current - I don't know how much the Amiga will attempt to sink, but I'd be nervous about letting it try when the Arduino can source up to 40ma.
robinsonb5 is offline  
Old 16 August 2017, 11:23   #16
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
Quote:
Originally Posted by robinsonb5 View Post
Nice going!



You're probably already doing this if you're using interrupts, but when you drive the middle mouse button pin high, do it by putting the arduino in input mode with pullup enabled - don't drive it high in output mode if you're going to have the Amiga drive the same pin low. The Arduino pin can source a fair bit of current - I don't know how much the Amiga will attempt to sink, but I'd be nervous about letting it try when the Arduino can source up to 40ma.
I'm not. Will change thanks.
Edit: I was wrong, I am using the internal pullup for the input!

I also added the left mouse button to the VBL protocol. Now I can emulate the middle mouse button too. It's not using the real middle mouse button pin (tricky, but may be possible?) but an input event.

Last edited by nogginthenog; 16 August 2017 at 11:52.
nogginthenog is offline  
Old 15 October 2021, 23:25   #17
sq7bti
Registered User
 
Join Date: May 2019
Location: Eindhoven
Posts: 12
Hi all,

With help of noggingthenog and robinsonb5 I managed to make an old dell laser mouse work as bus mouse with a support of wheel, middle and two extra buttons. It uses ADNS-7550 SPI optical sensor, and MSP430G2553 microcontroler.

driver
MCU code

Simon
sq7bti is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scroll or Blockscroll with transparency? earok Coders. Blitz Basic 5 30 January 2017 17:40
Scroll with the mouse? BarrySWE support.Apps 14 29 May 2012 22:16
help me smooth scroll rusty71 support.WinUAE 7 21 November 2011 15:36
Hardware Scroll tutorial? Lonewolf10 Coders. Tutorials 14 24 January 2011 00:08
Using Mouse-Wheel Scroll in Workbench 3.1 vroom6sri New to Emulation or Amiga scene 4 31 May 2007 11:06

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:20.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.25245 seconds with 15 queries