mborjesson / USB-Mouse-to-Serial

Connect a USB mouse to your retro computer using a Raspberry Pi
GNU General Public License v2.0
45 stars 3 forks source link

Mouse Detection Issues #7

Open texneus opened 3 years ago

texneus commented 3 years ago

There have been reported issues using USB-Mouse-to-Serial in various scenarios, for example see #2 and #4. Although the number of incidents are too few to know for certain, it appears certain USB to RS232 adapters are at fault. Unfortunately there was a period of time when many of these devices were counterfeited which may be a factor in this problem. At the end of this issue is a list of adapters that are known to work properly. Please help build this list by reporting both compatible and incompatible adapters.

Symptoms:

The mouse is not reliably detected in Windows, OS/2, and possibly other operating systems. DOS seems the least effected (at least with the latest available version of the Cute Mouse "CTMOUSE.EXE" driver) but it will almost never work in Windows 98 or OS/2.

The Cause:

To detect the presence of a serial mouse, the computer toggles one or both of "Clear To Send" (CTS) and "Data Carrier Detect" (DCD) (As seen by the Raspberry Pi at it's end of the null modem cable). The mouse responds to this challenge within 200mS by sending a one or two byte response to indicate what type of mouse is installed. The USB-Mouse-to-Serial software detects this challenge and responds appropriately, but certain adapters appear to block communications until it feels CTS and/or DTS are stable. From the computer's perspective, the challenge goes unanswered and therefore believes that no mouse is present.

How To Verify This Is The Problem?

1) In a console window as root, start USB-Mouse-to-Serial software in Microsoft Mouse mode and a verbose (-v) flag. ex:

# usb_mouse_to_serial -v
Protocol: Microsoft 2-button mouse
Default output rate.
Verbose level: 1
Opening serial device /dev/ttyUSB0...
Found mouse:  USB OPTICAL MOUSE (vendor: 0, product: 538)
Exclusive mouse access: yes

2) Boot Windows 98. As Windows boots, you will see multiple "Mouse connected." messages. This means USB-Mouse-to-Serial has detected the mouse "challenge" and responded, but Windows is not seeing the response. Windows 98 (and possibly other versions) will attempt to discover a mouse four times before displaying a warning dialog, then another four times after the warning is acknowledged.

Mouse connected.     (Serial port is initialized)
     (Delay as Windows continues to load)
Mouse connected.
Mouse connected.
Mouse connected.
Mouse connected.
     (Dialog box is displayed in Windows warning the user to plug in a mouse)
Mouse connected.
Mouse connected.
Mouse connected.
Mouse connected.

3) If you see this it is most likely the adapter blocking the response. If you do not see any messages at all then something is blocking the challenge itself.

Known NOT Working Adapters

NOTE: Links given are provided reference only. Insten PCABUSBX0049 - The culprit in #4. Note: May be counterfeit, but it has worked in other applications.

Known Working Adapters

Aten UC232A - Used by the program's author as noted in #3. Startech.com ICUSB232FTN - Resolved #4. Note this adapter IS a null modem cable itself, omitting the need for a second cable.

ArnoldUK commented 1 year ago

I've been looking into the serial mouse detection issue and some mouse drivers do not detect the attached serial mouse unless the initialization string is sent multiple times. i.e modify your code as shown here:

if (next_protocol != PROTOCOL_MOUSE_SYSTEMS) {
bytes = write_char(serial_fd, 'M');
bytes += write_char(serial_fd, 'M');
bytes += write_char(serial_fd, 'M');
bytes += write_char(serial_fd, 'M');
bytes += write_char(serial_fd, 'M');
bytes += write_char(serial_fd, 'M');

I'm not sure why this is required but it allows the use of some mouse drivers to detect the mouse in windows.