mborjesson / USB-Mouse-to-Serial

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

Does not work in Windows 98 or OS/2 #4

Closed texneus closed 3 years ago

texneus commented 3 years ago

Hi, I found this project very useful! I have this working with an old "retro" Raspberry Pi 1 in DOS with CuteMouse in Microsoft mode (2 button mouse). My "real" serial mouse also emulates/detects the same way. However it goes unrecognised when I run OS/2. I was able to get it working though by changing your software to emulate Mouse Systems (but not Logitech or Wheel), but the cursor motion in this mode was pretty lagy. The real serial mouse however seems to detect and work just fine.

I have the same issue with Windows 98 (although I did not test Mouse Systems mode) so it seems like a bug or perhaps something peculiar with the old and slow Pi 1 that prevents detection, or perhaps it is related to when the CPU is in protected mode.

In both cases the web API reports the serial port is off (I'm writing this on the fly, I'd need to get everything working again if you need the exact message).

mborjesson commented 3 years ago

Hello! I'm happy you find it useful! :) Unfortunately I don't have a Pi1 to test with, but it sounds strange that it doesn't detect properly. Are you using an USB to serial-adapter or have you wired it up through the GPIO-pins?

I haven't tried it with OS/2 but I have not had any issues with Windows 98. I've only tested the Microsoft- and Logitech-mode in W98 though :)

texneus commented 3 years ago

I am using a USB to Serial cable (not sure of the brand, the box is long gone and there are no markings on the adapter), connected to a COM port on the PC via a null modem cable. I wasn't aware you could connect by GPIO. On Windows 98, what driver would this require in Microsoft mode? I wonder if I just need to "push" a driver into it to work.

We're having some power issues right now or I'd get you more information on the Pi, adapter, and some program data. Give me another day or so and I think this will pass and I'll follow-up with more info.

EDIT: I just read the closed issues and it looks like #2 refers to the same problem, but with Windows 3.11 (I have not noticed any issues with ctmouse). I haven't tried it with Windows 3.11 myself...

mborjesson commented 3 years ago

That's pretty much the same as my set up except I'm using a Pi2B. I mainly use Microsoft-mode and I've never had a problem where it wasn't detected, Windows 98 detects it and installs the drivers automatically. I wonder if there is something wrong with the adapter or the cable? Do you have another null modem cable to test with or maybe a regular cable with a null modem adapter at the end? Could you try the emulator on a laptop/workstation running Linux with the same adapter and cable?

I've seen that it's possible to add your own serial port through the GPIO-pins but I haven't tried it since I had a USB to serial adapter available :)

texneus commented 3 years ago

To make a long story short, it seems the adapter isn't answering the mouse interrogation. I can see Win98 toggle DCD 4 times waiting for an answer, your code is detecting and answering the challenge as it should, but as best I can tell the adapter doesn't pass any data along for ~1000mS once DCD is asserted, well beyond the allowed response window. To add insult to injury, it randomly does work perhaps 1 in 10 times.

Unlike what I mentioned above, ctmouse is also affected. What fooled me is from a fresh boot (everything powered off as the starting state) everything seems to work as it should. The only notable difference is that at power on all of CTS, DSR, and DSD are not asserted until the port is initialized. Once initialized all these signals are asserted and seem to stay that way. MAYBE it would work if these signals were all toggled, but of course that is a problem on the PC side, not the mouse side.

I did also try compiling/running your software on my laptop where it behaved no different, so I'm confident the issue is being caused by the adapter.

The USB to Serial adapter in question is a Prolific PL2303 device, which I read does not have the best reputation to begin with and many are actually counterfeit devices. I ordered a reputable branded FTDI based device and will resume looking at this later. It should be here later this week.

# dmesg | grep usb
...
[    5.390949] usb 1-1.3: new full-speed USB device number 5 using dwc_otg
[    5.524388] usb 1-1.3: New USB device found, idVendor=067b, idProduct=2303, bcdDevice= 3.00
[    5.531473] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    5.535189] usb 1-1.3: Product: USB 2.0 To COM Device
[    5.538788] usb 1-1.3: Manufacturer: Prolific Technology Inc.
...
[   20.045979] usbcore: registered new interface driver usbserial_generic
[   20.046136] usbserial: USB Serial support registered for generic
[   20.184750] usbcore: registered new interface driver pl2303
[   20.184926] usbserial: USB Serial support registered for pl2303
[   20.294687] usb 1-1.3: pl2303 converter now attached to ttyUSB0
...

# lsusb
...
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 004: ID 0000:0538 
...

# lsusb -v -d 067b:2303
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x067b Prolific Technology, Inc.
  idProduct          0x2303 PL2303 Serial Port
  bcdDevice            3.00
  iManufacturer           1 Prolific Technology Inc.
  iProduct                2 USB 2.0 To COM Device
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0027
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x000a  1x 10 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)
texneus commented 3 years ago

I am pleased to announce that it was the adapter. The new one is working perfectly in DOS, Windows 98, and OS/2. I am going to close this issue but I will open a new one to document what happened so others might be able to figure out how to check their adapters themselves. I'm not sure if you want to update your readme or point to the issue (or you can ignore me!).

mborjesson commented 3 years ago

Great to hear that you got it working! It's too bad that there are counterfeit adapters out there though :( Your write-up about the problem is excellent and I will link to it from the readme, thank you!