Changeset 236


Ignore:
Timestamp:
Jan 19, 2011, 9:33:02 PM (10 years ago)
Author:
sam
Message:

Mouse button support in Lol Engine.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/input.cpp

    r233 r236  
    3131public:
    3232    InputData()
    33     {
    34         mouse.x = mouse.y = -1;
    35     }
     33      : mouse(-1, -1),
     34        buttons(0, 0, 0)
     35    { }
    3636
    3737    Int2 mouse;
     38    Int3 buttons;
    3839}
    3940inputdata;
     
    7576}
    7677
     78void Input::SetMouseButton(int index)
     79{
     80    data->buttons[index] = 1;
     81}
     82
     83void Input::UnsetMouseButton(int index)
     84{
     85    data->buttons[index] = 0;
     86}
     87
     88Int3 Input::GetMouseButtons()
     89{
     90    return data->buttons;
     91}
     92
  • trunk/src/input.h

    r233 r236  
    2525    static void SetMousePos(Int2 coord);
    2626    static Int2 GetMousePos();
     27    static void SetMouseButton(int index);
     28    static void UnsetMouseButton(int index);
     29    static Int3 GetMouseButtons();
    2730};
    2831
  • trunk/src/sdlinput.cpp

    r233 r236  
    6666            Input::KeyPressed(event.key.keysym.sym, deltams);
    6767#endif
     68        else if (event.type == SDL_MOUSEBUTTONDOWN)
     69            Input::SetMouseButton(event.button.button - 1);
     70        else if (event.type == SDL_MOUSEBUTTONUP)
     71            Input::UnsetMouseButton(event.button.button - 1);
    6872    }
    6973
Note: See TracChangeset for help on using the changeset viewer.