Mouse cursor position without clicking

So I’m trying the code I found in this topic…

But, MapWindowPoints hits an access violation somewhere. As far as I can tell in the locals, CCEGLView::sharedOpenGLView()->getHWnd(); returns an HWND with a variable ‘unused = 0’. Not sure I’m using it right.

…if I were to hack the engine…


… where would I even start?

The code…

LPPOINT p = {0};
HWND hWnd = CCEGLView::sharedOpenGLView()->getHWnd();
HWND hWndParent = GetParent(hWnd);

MapWindowPoints(hWnd, hWndParent, p, 1);
//MapWindowPoints(hWnd, NULL, p, 1);

mTargetPosition.x = p->x;
mTargetPosition.y = p->y;

Thanks guys!

See if this is what you need.

Awesome, thanks so much for the reply!

But I tried that.

In CCEGLView::WindowProc() (which is from where clickless, mouse movement seems to be hitting a barrier) there’s an if statement with “MK_LBUTTON == wParam”. Only clicking AND mouse movement gets through the if.

I tried ‘hacking’ it to exclude that if, but it doesn’t work and fills my output with “if the index doesn’t exist, it is an error
touchesMoved: count = 0” as long as the mouse moves. That error is inside “CCEGLViewProtocol::handleTouchesMove”. HandleTOUCHESMove.

Here’s the code. I marked the ‘hack time!’ section and put in the variations I tried. I put a breakpoint before the filter and saw that if the mouse moved anywhere in the window, the code hit the breakpoint. So I’m pretty sure this is where my prob my lie.

LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    BOOL bProcessed = FALSE;

	POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
    CCPoint pt(point.x, point.y);
    int id = 0;

    switch (message)
    {
    case WM_LBUTTONDOWN:
#if(_MSC_VER >= 1600)
        // Don't process message generated by Windows Touch
        if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

        if (m_pDelegate && MK_LBUTTON == wParam)
        {
            POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
            CCPoint pt(point.x, point.y);
            pt.x /= m_fFrameZoomFactor;
            pt.y /= m_fFrameZoomFactor;
            CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
            if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp))
            {
                m_bCaptured = true;
                SetCapture(m_hWnd);
                int id = 0;
                handleTouchesBegin(1, &id, &pt.x, &pt.y);
				m_pTouch->setTouchInfo(id, (float)pt.x, (float)(m_obScreenSize.height - pt.y));
            }
			
			_buildEvent(INPUT_MOUSEDOWN, 
							CCMouse::LeftButton, 
							0, 
							0, 
							m_pTouch->getLocationInView().x, 
							m_pTouch->getLocationInView().y);
        }
        break;

    case WM_MOUSEMOVE:
#if(_MSC_VER >= 1600)
        // Don't process message generated by Windows Touch
        if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		// ------------------------ hack time! ------------------------
        //if (MK_LBUTTON == wParam)
        //if (m_bCaptured)
        if (MK_LBUTTON == wParam && m_bCaptured)
		// ------------------------ hack time! ------------------------

        {
            pt.x /= m_fFrameZoomFactor;
            pt.y /= m_fFrameZoomFactor;
            handleTouchesMove(1, &id, &pt.x, &pt.y);
			m_pTouch->setTouchInfo(id, (float)pt.x, (float)(m_obScreenSize.height - pt.y));

			_buildEvent(INPUT_MOUSEMOVE, 
							CCMouse::LeftButton, 
							0, 
							0, 
							m_pTouch->getLocationInView().x, 
							m_pTouch->getLocationInView().y);
        }
        break;

Thanks for the help guys!

edit/update

So I found ‘GetCursorPos(LPPOINT)’ in WinUser.h, but the LPPOINT I send it isn’t being edited. It’s giving me an access violation when I try to get the coordinates.