mouse_event, windows xp lagginess

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dtzWill
    New Member
    • Feb 2008
    • 2

    mouse_event, windows xp lagginess

    Hey all--I'm trying to implement the server-side code for some software I'm writing for the iPhone.

    Basically it's a wireless touchpad... so I have a client that sends events (runs on the phone) to the server which generates them.. simple enough.

    My problem is that in developing the windows version of this server, I'm having difficulty making the mouse move smoothly.

    Code is available here: http://code.google.com/p/itouchpad/source/browse/trunk/windows/itp-server-win/itp-server-win/itp-server-win.cpp (it's not long, don't worry :)).

    The problem seems to be that the mouse isn't 'updated'. As you can see in the code, I've commented out "XFlush( dpy )", which in X11 was the programmatic way of flushing the input events I've generated.

    Is there a windows equivalent to XFlush? (I've looked and kind find such a method. I've been unable to do so, and tried the following:

    Code:
    MSG msg;
    while( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
    {
    	if( ::GetMessage( &msg, NULL, 0, 0 ) )
    	{
    		::TranslateMessage( &msg );
    		::DispatchMessage( &msg );
    	}
    	else
    	{
    		break;
    	}
    }
    
    Sleep( 0 );//ouch, kludge
    But this doesn't seem to have any effect as far as I can tell.
    This is code I found elsewhere--I don't understand how windows works well enough to understand exactly what that's doing--but my current understanding is that it's trying to empty the pending events on the queue so that the system has a chance to process them. Seems to me there should be a conditional there to do this event processing until the WM_MOUSEMOVE event I generate is processed... but I don't even know if that's the right tree to be barking up, so to speak.

    I've found examples all over the place for moving the mouse--and read through the tightvnc and synergy source for ideas on what I'm doing wrong (both are related projects that don't seem to have this issue at all)--it seems they're doing the same I am, which unfortunately makes me wonder what I'm doing wrong?? :-/.

    To be clear--the code linked works, it just makes the mouse 'jumpy'.
    It's hard to describe exactly--but mostly it just seems like the mouse refresh rate is 1fps.

    Adding a "Sleep(2)" call after the switch statement makes things 'work' but then the events stack up and the result is a cumulative/building lag effect. Sleep(1) wasn't sufficient to flush it, and both are hacks as far as I'm concerned anyway.

    Can someone provide some insight as to what I'm doing wrong? This seems like it should be simple but I've been unable to figure this out. :-/.

    I'll be happy to provide more information if it's needed.

    Thanks in advance for your input.

    ~Will

    PS If anyone sees anything unrelated to my question in that code or the code in general, I encourage you to comment... I open-sourced it for a reason. :)
  • dtzWill
    New Member
    • Feb 2008
    • 2

    #2
    Turns out disabling nagle on the client sided fixed this.

    Sigh.

    Comment

    Working...