Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse has erratic movement #85

Open
kezax94 opened this issue Dec 30, 2021 · 11 comments
Open

Mouse has erratic movement #85

kezax94 opened this issue Dec 30, 2021 · 11 comments

Comments

@kezax94
Copy link

kezax94 commented Dec 30, 2021

Well, I lost about one hour this evening trying to setup Windows 3.1 on ao486. The mouse was moving like accelerated like crazy and generating random clicks when I moved it. So I tried multiple configurations, in Windows, in the mister.ini, etc.
I finally found the root cause: I had changed the default CPU clock value from 90MHz to 30MHz.
When I set it back to 90MHz, the mouse behaved again like normal.
I had set my clock to 30MHz for nostalgic reasons (it was the exact spec of my first PC, +/- 3MHz...), but now I hate it :)

@birdybro
Copy link
Member

@kezax94
Copy link
Author

kezax94 commented Jan 27, 2022

I tried it, but it did not work. If I moved the mouse very very slow, it was even slower with the setting, but if I moved the mouse normally, it was going mayhem directly. No, really, it works only with CPU clock 90MHz.

@ChrisDeadman
Copy link
Contributor

ChrisDeadman commented Jan 31, 2022

This sounds like a similar issue I had with windows when coding my usb to ps2 converter (https://github.com/ChrisDeadman/usb-to-ps2-gameport-hat/tree/master/Software/usb-to-ps2-gameport-hat).
It worked in DOS but windows initializes the mouse differently - and if a command or response is expected to contain one more data byte which is not expected by mouse or the OS because of incorrect implementation then the PS/2 protocol gets out of sync and causes this erratic behavior.

Now I am not good at all at verilog unfortunately but maybe I find the time to look at it sometime if nobody else does it.
As a hint for now I can tell you that I fixed my issue by properly handling the sample rate setting (see here: https://github.com/ChrisDeadman/usb-to-ps2-gameport-hat/blob/master/Software/usb-to-ps2-gameport-hat/lib/PS2Device/src/PS2Mouse.cpp#L151)

EDIT: But if it works depending on the CPU clock I guess the issue maybe is that the emulated mouse is sending too fast for windows to handle? (for PS/2 clock is generated by the peripherals). really interesting issue :)

@ChrisDeadman
Copy link
Contributor

ChrisDeadman commented Jan 31, 2022

I just installed Windows 3.11 and could reproduce it - altho I had to set CPU clock to 15Mhz to reliably reproduce it. Once it happened I had to restart, increasing the clock again did not fix it for me...so somehow windows is getting out of sync with PS/2 mouse protocol at low CPU clock speeds...I will try to build a version with PS2DIV set to 8000 instead of 4000 and test again with that :-)

EDIT:
PS2DIV 8000 made the problem appear even slightly faster so I tried the opposite direction and made the PS/2 clock faster by setting PS2DIV to 2000...with that the issue is gone 😮

At the moment I have no explanation for this except that maybe a timeout is happening inside windows PS/2 driver...
But given that sys_clk is 30Mhz and PS2DIV is now 2000 it should be within spec now (PS/2 cock should be between ~10Khz and ~16Khz)

@c0d3h4x0r
Copy link

I've had this happen plenty of times now while only using MS-DOS 6.22 or MS-DOS 7.10. It seems to just happen randomly, unrelated to changing clock speed. Sometimes the mouse just freaks out and jumps all over the place, and the only solution is to reset the core.

@ChrisDeadman
Copy link
Contributor

ChrisDeadman commented Mar 4, 2022

If you want you can try if this build fixes it for you, it did for me: https://github.com/ChrisDeadman/ao486_MiSTer/releases/download/fix-ps2div/ao486.rbf in official release now

@c0d3h4x0r
Copy link

I'll give it a try this weekend.

@ChrisDeadman
Copy link
Contributor

ChrisDeadman commented May 28, 2022

@kezax94 @c0d3h4x0r did you get around to test it? for me the issue is resolved with the latest release.

@c0d3h4x0r
Copy link

Sorry for not following up. I haven't experienced any mouse problems with more recent ao486 releases, so I think we're probably safe to close this.

@ioev
Copy link

ioev commented Feb 1, 2024

I believe I've just experienced this today. My mouse seems to be normally on the fast side, but at one point after loading Worms it seemed so fast it was just jumping around the edges of the screen. I was using the 486 33/DX preset when it happened, and tried switching the CPU to 90mhz (not sure if this takes effect right away) and nothing changed. I was able to quit the game, and it seems like it froze up after trying to load it again, but performing a reboot (just the 486 core) seemed to resolve it.

I also tried the "mouse_throttle" option, but it seems like any amount I use causes the mouse to crawl. Started at 50 and went up to 85, then tried 25 and they all seemed to be so slow it was unusable. For this value, would a lower value = faster mouse speed?

@sorgelig
Copy link
Member

sorgelig commented Feb 1, 2024

@ioev looks like problem in mouse driver in your PC setup. Try other mouse driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants