1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

settimer() speed

Discussion in 'Win32' started by rodolphe, Feb 3, 2008.

  1. rodolphe

    rodolphe New Member

    Hi! First, a bit of background on what I'm doing. I'm currently working on a project to correlate eye-gaze position with cursor position on a computer screen. I could not find any free software that did want I wanted it to do (for free ~.~) so I decided to write my own.

    Apparently, there is no easy way to do this from a console application, so I had to write a win32 application, for the first time ever.

    What this program basically has to do is get the cursor position's x and y coordinates and the current time, and write them to a file every 4milliseconds.

    The problem is that for some reason, it only does this every 15.5 ms.

    I was just wondering how to fix this, if my code was for some reason slowing down application or something. Here's the snippets of code:

    Code:
    UINT myTimer = SetTimer( hwnd, 9000, 1, TimerProc );
    
    Code:
    VOID CALLBACK TimerProc ( HWND hParent, UINT uMsg, UINT uEventID, DWORD dwTimer)
    {         
         POINT p;
         SYSTEMTIME curTime;
    
         GetCursorPos(&p);
         GetLocalTime(&curTime);
                            
         fprintf(data,"(%d %d)\t%d:%d:%d:%d\n", p.x, p.y, curTime.wHour, curTime.wMinute, curTime.wSecond, curTime.wMilliseconds);
    }
    
     
  2. oogabooga

    oogabooga New Member

    The timer has a resolution of about 10ms (if that).
    It used to be about 50ms on Windows 95/98, so it's an improvement.
    I'll think about how to get better resolution, but it won't be by using SetTimer().
     

Share This Page