5 Replies Latest reply on Jul 12, 2010 11:44 PM by jackkirk

    Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's?

    joehecht@code4sale.com Enthusiast

       

      VM Workstation 6.5.1, XP (and probably other Windows guest), latest VM tools.

       

       

       

       

       

      In a VM, when my program calls the WinAPI Mouse_Event() and/or SetCursorPos() the mouse cursor is re-positioined correctly, however, if the user moves the mouse slightly  or the clicks the mouse, the mouse cursor poistion is set back to the original position before the before the call.

       

       

      Outside of a VM, everythng works is expected.

       

       

      I am guessing that VMWare is hooking the mouse, and it does not get updated?

       

       

      Workarounds?

       

       

      Joe

       

       

       

       

       

        • 1. Re: Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's?
          Expert
          joehecht@code4sale.com wrote:

           

          I am guessing that VMWare is hooking the mouse, and it does not get updated?

           

          Not quite. What's going on is that, in order to improve user experience and graphical responsiveness of the mouse cursor, we actually map the guest mouse cursor onto the host, so the cursor that you see is being drawn by your host operating system; in effect it's "offloaded" from the guest. A similar trick is used by e.g. Microsoft Terminal Services/Remote Desktop Connection, for the same reasons.

           

          In order for SetCursorPos() or Mouse_Event() to behave the way you would expect, you can disable the absolute mouse and host cursor offload, by adding the following to the VM's .vmx file and rebooting:

           

          vmmouse.present = FALSE

           

          You may notice that the mouse in your guest won't feel as smooth as before.

          • 2. Re: Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's?
            joehecht@code4sale.com Enthusiast

             

            Thank you very much for the swift and detailed reply!

             

             

            Joe

             

             

            • 3. Re: Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's?
              jackkirk Lurker

              Greetings,

               

              I have this exact issue with a WIndows XP SP3 guest OS in VMware Workstation 6.5.1.

               

              I have tried the fix described here, my detailed interpretation being:

               

              o Shutdown the VM guest.

              o In the host (also WIndows XP SP3) , use the Wordpad applet to open the appropriate *.vmx file.

              o Add the following line to the bottom of the *.vmx file:

               

              vmmouse.present = "FALSE"

               

              note blank either side of = and "'s around FALSE as per other entries in the *.vmx file.

               

              o Save modified *.vmx file.

              o Boot VM guest.

               

              This doesn't solve the problem.

               

              I have double checked I am using the right *.vmx file by tinkering with the sharedFolder0 entries, the changes to which appear as expected when the VM guest is booted.

               

              Any suggestions appreciated...

              • 4. Re: Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's?
                Master

                In View > Preferences > Input, does setting the "Optimize mouse for games" option to "Always" help?

                 

                If not, I think removing the VMware mouse driver in the guest would work (but is a bit heavy-handed).

                • 5. Re: Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's?
                  jackkirk Lurker

                  Thanks for the quick response.

                   

                  We must be on different versions of VMware - I am using VMware Workstation 6.5.1.

                   

                  I found an option "Never optimize mouse for games ..." under >[Preferences]>[Input]. This had been checked - I unchecked it and rebooted the guest OS but still have the problem.

                   

                  I had already tried uninstalling the VMware mouse driver - when rebooted, the guest installs  a "PS/2 Compatible Mouse" - I have mouse funstionality but still have the same problem.

                   

                  Any suggestions appreciated...