CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2013
    Posts
    20

    Moving mouse position

    I am writing a program to map keyboard and mouse to an xbox 360 controller with win32 and xinput. I have everything going fine but when im trying to control the mouse with the thumbsticks I get problems with the movement if my program has the focus it moves fine but when I put another window in focus the movement is over sensitive here is the code I am using


    Code:
    if(_controllerState.Gamepad.sThumbRX >= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
    	{
    		GetCursorPos(&mousepos);
    		
    		
    		profile->Buttons[6]->input.type = INPUT_MOUSE;
    		profile->Buttons[6]->input.mi.dwExtraInfo = GetMessageExtraInfo();
    		profile->Buttons[6]->input.mi.time = 0;
    		profile->Buttons[6]->input.mi.dwFlags =  MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;
    		profile->Buttons[6]->input.mi.mouseData = 0;
    		
    		profile->Buttons[6]->input.mi.dx = mousepos.x * (65535.0f / GetSystemMetrics(SM_CXSCREEN));
    		profile->Buttons[6]->input.mi.dy = mousepos.y * (65535.0f / GetSystemMetrics(SM_CYSCREEN));
    		
    		SendInput(1, &profile->Buttons[6]->input, sizeof(INPUT)); 
    		
    	}
    I have tried everything to fix it any advice.

  2. #2
    Join Date
    Jan 2009
    Posts
    399

    Re: Moving mouse position

    Quote Originally Posted by william3711 View Post
    I am writing a program to map keyboard and mouse to an xbox 360 controller with win32 and xinput. I have everything going fine but when im trying to control the mouse with the thumbsticks I get problems with the movement if my program has the focus it moves fine but when I put another window in focus the movement is over sensitive here is the code I am using


    Code:
    if(_controllerState.Gamepad.sThumbRX >= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
    	{
    		GetCursorPos(&mousepos);
    		
    		
    		profile->Buttons[6]->input.type = INPUT_MOUSE;
    		profile->Buttons[6]->input.mi.dwExtraInfo = GetMessageExtraInfo();
    		profile->Buttons[6]->input.mi.time = 0;
    		profile->Buttons[6]->input.mi.dwFlags =  MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;
    		profile->Buttons[6]->input.mi.mouseData = 0;
    		
    		profile->Buttons[6]->input.mi.dx = mousepos.x * (65535.0f / GetSystemMetrics(SM_CXSCREEN));
    		profile->Buttons[6]->input.mi.dy = mousepos.y * (65535.0f / GetSystemMetrics(SM_CYSCREEN));
    		
    		SendInput(1, &profile->Buttons[6]->input, sizeof(INPUT)); 
    		
    	}
    I have tried everything to fix it any advice.

    In principle, you could move the mouse position with SetCursorPos ... you should can move it, or else you have another issue ..

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured