sarah-walker-pcem / pcem

PCem
http://pcem-emulator.co.uk
GNU General Public License v2.0
1.51k stars 207 forks source link

Mouse speed in the emulator is too high #150

Open andreyfedoseev opened 2 years ago

andreyfedoseev commented 2 years ago

Describe the bug When using the emulator with a mouse, for instance in Windows 98, the mouse pointer speed is too high, making it almost impossible to use. I set the mouse speed to the minimum value in Win 98 settings, but it's still to fast. My workaround is to switch mouse sensitivity on the mouse itself, I have a Logitech devices that allows that.

To Reproduce Steps to reproduce the behavior:

  1. Install Windows 98 on a PCEM machine
  2. Move the mouse cursor
  3. The cursor moves too fast

Expected behavior The mouse movement speed should be the same or close to the host OS

Emulator configuration

Host machine

Additional context Not sure if it's relevant, but I'm using 3x scale for video output.

unreal9010 commented 2 years ago

Are you sure that pointer speed isn't set to the highest level in your virtual machine's control panel? I'm running one Windows 95 and one Windows 98 SE installation and in both cases the mouse speed is just right. I'm using default settings.

andreyfedoseev commented 2 years ago

Are you sure that pointer speed isn't set to the highest level in your virtual machine's control panel?

I'm sure. Here's a demo:

https://youtu.be/Ivat2KyUnyA

The black cursor in the video is the cursor in my host OS. You can see how it's moving when I make little swings with my hand. The white cursor is in the guest OS - I'm making the same movements and it's moving much faster.

unreal9010 commented 2 years ago

Try another GPU driver version.

ruben-balea commented 2 years ago

What is your monitor resolution? I think in PCem the mouse moves the same percentage of screen (instead of the same number of pixels) on the host and guest machines, so if the physical screen is 1920 pixels wide and the emulated one is 800 pixels wide, the mouse pointer will move 2.4 times faster and farther on the emulated one than on the physical one, on a 4K monitor (3840x2160) it will move 4.8 times faster and farther... Maybe PCem needs another option to "downscale" the mouse movements for the monitors with resolutions, even at Full HD if the guest OS uses a low resolution, the difference in movement between the host and guest OS is already quite noticeable, although it is not as critical as in your case. Try setting the resolution in Windows 98 to 1280x1024 to see if it slows down the mouse. You may have to change the monitor type in Windows 98 settings to one that supports that resolution for Windows 98 to show that resolution, it seems to use by default a generic SVGA monitor with 800x600 max resolution.

andreyfedoseev commented 2 years ago

I'm using a 4K monitor.

This may be related to the video output scaling. If switch to 1x scaling (making the PCEM window really small), then the absolute amplitude of the mouse movements seems to be the same in host and guest OS seems. However, because the PCEM window is small compared to my host display, the relative amplitude (absolute distance compared to the screen dimensions on host or guest OS) is different.

I think what happens is:

When I move the mouse for 100px it's moved 100px on the Windows 98 desktop. But then the 100px are stretched 3x times, so they become 300px when rendered on my host OS.

unreal9010 commented 2 years ago

I'm using a 4K monitor as well and my video output scaling is set to 2.5x.

ruben-balea commented 2 years ago

I believe that the two things affect and also their effects add up, I have a Full HD monitor and if PCem at 1:1 scale runs Windows 98 at 800x600, the mouse moves a little more in Windows 98 than in Windows 10, which is the operating system I have on my computer. But if I put Windows 98 at 640x480 it moves even faster even though PCem still uses 1:1 scaling

Try temporarily changing the screen resolution in Ubuntu to 1920x1080, I guess the monitor will stretch the image so it still fills the screen, and then run PCem to see if the mouse moves slower in Windows 98

JosepMaJAZ commented 2 years ago

The mouse movement is one thing I've wanted to improve since I tried pcem 12 or so.(When it was still using the old allegro and Microsoft directinput instead of SDL.)

And indeed, there are two parts on making it work well: the dpi of the host (since the guest assumes 96) and the zoom applied to the guest (1x, 2x, window resizing, opengl3...).

Also, there is the acceleration, which can't be easily compensated ( the mouse acceleration is what makes the mouse move further when the movement is fast). Changing the guest acceleration to minimum makes it only have the acceleration of the host.

Finally, all this implies that in order to calculate the final guest mouse movement, pcem needs to know the host screen characteristics and take pcem window size in consideration.

Edit: And... how to do it in a platform independent way? I'm not sure if SDL itself can give all these details to us.

andreyfedoseev commented 2 years ago

@JosepMaJAZ

Is is possible to at least compensate for the zoom level? I think it's the most significant factor contributing to the insane mouse speed.

ruben-balea commented 2 years ago

I think that to compensate for the zoom level it would only be necessary to divide the mouse movement by the amount of zoom. It seems that in Windows since XP it is possible to get the mouse movement without acceleration: https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-rawmouse I guess Linux should have something equivalent.

Although I don't know how to implement any of those changes, for me c/c++ is something like Latin, I can read it although that doesn't imply that I understand everything and I have no idea how to write it 😥

nickkeane commented 2 years ago

Having the same issue on my Windows 3.1 PCem guest with Mouse Tracking Speed set to the lowest level. Having a slider or something in PCem settings to further reduce the pointer speed would be much appreciated. On 1080p monitor, PCem: Windowed Maximized OpenGL 3.0 Square Pixel Stretched, Guest: S3 Trio64 640x480 256, Microsoft 2-btn Serial Mouse.

ruben-balea commented 2 years ago

Having the same issue on my Windows 3.1 PCem guest with Mouse Tracking Speed set to the lowest level. Having a slider or something in PCem settings to further reduce the pointer speed would be much appreciated. On 1080p monitor, PCem: Windowed Maximized OpenGL 3.0 Square Pixel Stretched, Guest: S3 Trio64 640x480 256, Microsoft 2-btn Serial Mouse.

I have uploaded my latest patch to the PCem forum: https://www.pcem-emulator.co.uk/phpBB3/viewtopic.php?p=16148#p16148

I'll try to improve it a bit more when I have some free time but if anyone wants to improve it they're welcome, even if my code has to be discarded ;-) after all I don't have any experience programming in c and had to google a few times to write a few lines.