Mouse input

why am i getting theses numbers from my mouse
http://img393.imageshack.us/img393/4944/untitled5tb.jpg

please help thanks


private ACEIDev ACEMouse;

public int ACEMouseX=0;

public int ACEMouseY = 0;

public int ACEMouseZ = 0;

public ACEMou(Control ff)

{

ACEMouse = new ACEIDev(SystemGuid.Mouse);

ACEMouse.Properties.AxisModeAbsolute = true;

ACEMouse.SetCooperativeLevel(ff, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.Exclusive);

ACEMouse.Acquire();

}

public Vector3 ACEMouseGetPos()

{

MouseState ACEState = ACEMouse.CurrentMouseState;

ACEMouseX=ACEState.X;

ACEMouseY = ACEState.Y;

ACEMouseZ = ACEState.Z;

return new Vector3(ACEState.X,ACEState.Y,ACEState.Z);

}


 




Answer this question

Mouse input

  • FredP

    p.s ... this code doesnt return absolute mouse position ...

    if mouse aint moving x and y will be zero

    X = left / right movement
    Y = up / down movement
    Z = scroll (returns 120 / -120 when scrolling)

    ...

    this code shows the mouse coordinates in the titlebar
    i added the sleep method, cause when running this test i dint render ... so mouse value changes were not visible.



    long __stdcall CTestApp::ProcessInput(ICREKeyboard *pKeyboard, ICREMouse *pMouse, ICREJoystick *pJoystick)
    {

    WCHAR lpMouse[MAX_PATH];
    wsprintf(lpMouse, L
    "X: %d | Y: %d | Z: %d", pMouse->GetAxis(CREMA_X), pMouse->GetAxis(CREMA_Y), pMouse->GetAxis(CREMA_SCROLL));
    SetWindowText(g_pState->GetWindow(), lpMouse);

    Sleep(100);

    return
    S_OK;

    }



     

  • Gurpreet GIll

    For better or ill, the absolute axis system does not use screen coordinates based on 0,0 in the upper left of the screen.  Some offset (apparently a couple of states over) is added to the numbers.  They will be absolute, but not based on the coordinate system that you may have expected.  Moving the mouse will still add the expected deltas to those large numbers.
  • AlchemistMatt

    Have you checked the following:
    1) You're definitely getting mouse coordinates
    2) Your formatting matches the type of the input



  • GatorBait58

    I am not 100% sure but I think those values are stored up in the device. So over the life time of that device you have moved (-723952105x, 471007952y,0z). Everytime you move the mouse the change is added to this value.

    I personally use Relative Axis Mode. This gives the change in mouse position since last check. I build a class on top that originally places the mouse at center screen, the just add the change to my stored mouse position and voila you have on screen coordinates for you mouse. 

    Andrew


  • Archimedez

     NerdAndy wrote:
    thts all my code above


    If this is all your code, then the problem might be in the ACEIDev class
    u might wanna put some breaklines on following lines ...



    ACEMouseX=ACEState.X;
    ACEMouseY = ACEState.Y;
    ACEMouseZ = ACEState.Z;


     



    and see the ACEState.X returns the same value to ACEMouseX like u have in your output ...

    I have done direct mouse few days ago for my project and just ran some test ... it works fine on both win32 and win64.



    // Store the cooperative level
    m_lCooperativeLevel = 0L;
    if(bForeground) { m_lCooperativeLevel = DISCL_FOREGROUND; } else { m_lCooperativeLevel = DISCL_BACKGROUND; }
    if(bExclusive) { m_lCooperativeLevel |= DISCL_EXCLUSIVE; } else { m_lCooperativeLevel |= DISCL_NONEXCLUSIVE; }

    // Initialize the microsoft direct input device interface
    V_RETURN(pDirectInput->CreateDevice(GUID_SysMouse, &m_pDirectInputDevice, NULL));
    V_RETURN(m_pDirectInputDevice->SetDataFormat(&c_dfDIMouse2));
    V_RETURN(m_pDirectInputDevice->SetCooperativeLevel(hWnd, m_lCooperativeLevel));

    // Acquire the microsoft direct input device
    V_RETURN(m_pDirectInputDevice->Acquire());

    ...

    DIMOUSESTATE2 pMouseState;
    ZeroMemory(&pMouseState,
    sizeof(DIMOUSESTATE2));
    if(FAILED(hr = m_pDirectInputDevice->GetDeviceState(sizeof(DIMOUSESTATE2), &pMouseState)))
    { ... reacquire }

    m_lAxis[CREMA_X] = pMouseState.lX;
    m_lAxis[CREMA_Y] = pMouseState.lY;
    m_lAxis[CREMA_SCROLL] = pMouseState.lZ;




     


  • BahKoo51

    sorry that did not help
    could you break that down
    thts all my code above

  • Mouse input