Changeset 233


Ignore:
Timestamp:
Jan 19, 2011, 1:34:23 PM (10 years ago)
Author:
sam
Message:

Make SdlInput regularly inject the mouse position into the Input singleton.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/input.cpp

    r221 r233  
    3030
    3131public:
    32     int dummy;
     32    InputData()
     33    {
     34        mouse.x = mouse.y = -1;
     35    }
     36
     37    Int2 mouse;
    3338}
    3439inputdata;
     
    6065}
    6166
     67void Input::SetMousePos(Int2 coord)
     68{
     69    data->mouse = coord;
     70}
     71
     72Int2 Input::GetMousePos()
     73{
     74    return data->mouse;
     75}
     76
  • trunk/src/input.h

    r221 r233  
    2323public:
    2424    static Float2 GetAxis(int axis);
     25    static void SetMousePos(Int2 coord);
     26    static Int2 GetMousePos();
    2527};
    2628
  • trunk/src/sdlinput.cpp

    r221 r233  
    4949
    5050    /* Handle mouse input */
    51     SDL_GetMouseState(&data->mx, &data->my);
     51    Int2 mouse;
     52    if (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
     53        SDL_GetMouseState(&mouse.x, &mouse.y);
     54    else
     55        mouse.x = mouse.y = -1;
     56    Input::SetMousePos(mouse);
    5257
    5358    /* Handle keyboard and WM events */
Note: See TracChangeset for help on using the changeset viewer.