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.