VMware Communities
zwalker1
Contributor
Contributor

SetCursorPos() not working (Win32/Direct3D 10)

Hi, I have a win32 app which utilizes direct3d 10 for graphics. I am running this within windows 10 from within vmware workstation 12 pro.

I have noticed that SetCursorPos() doesn't alter the mouse cursor position. This method should fire when I right click my mouse button, but the cursor just stays where it is. I have tried a number of solutions:

1) Add the following line to the bottom of the *.vmx file: vmmouse.present = "FALSE"

2) preferences > input > optimize mouse for games = Never

3) uninstall "VMware Pointing device" from device manager

Nothing works. Would anyone know what else I can try? Thanks.

0 Kudos
2 Replies
joserfonseca
VMware Employee
VMware Employee

I believe the behavior you see is to be expected and not specific to virtualization.  See for example:

  http://forums.codeguru.com/showthread.php?379647-An-alternative-way-to-SetCursorPos

If you believe otherwise, please confirm that behavior is different on a physical Windows machine.

0 Kudos
zwalker1
Contributor
Contributor

I don't see how that should be the default behavior for SetCursorPos(). I have minimalistic win32 code that upon right mouse button click, the mouse cursor moves diagonally:

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

{

     switch (msg)

     {

     case WM_RBUTTONDOWN:

        rbutton();

        break;

     ...

    }

    return 0;

}

void rbutton() {

    POINT pos;

    GetCursorPos(&pos);

    int x = pos.x;

    int y = pos.y;

    int step = 20;

    SetCursorPos(x + step, y + step);

}

I have my full bare minimum code here: cursor/main.cpp at master · zwalker1/cursor · GitHub which can be compiled and tested under virtualization, and on a physical machine. On a physical machine, the cursor moves diagonally on right mouse click, under virtualization, it doesn't move at all.

I cannot explain the post you refer to, but my guess is that the original poster has issues elsewhere in their code. Previous users on this forum have had similar issues to what I am experiencing: Bug: WinAPI Mouse_Event() and SetCursorPos() broken in VM's? however the solutions they posed do not work under workstation 12 pro.

Any help much appreciated.

0 Kudos