Browse Source

Mouse button support in Lol Engine.

legacy
Sam Hocevar sam 14 years ago
parent
commit
2d93e03c45
3 changed files with 26 additions and 3 deletions
  1. +19
    -3
      src/input.cpp
  2. +3
    -0
      src/input.h
  3. +4
    -0
      src/sdlinput.cpp

+ 19
- 3
src/input.cpp View File

@@ -30,11 +30,12 @@ static class InputData

public:
InputData()
{
mouse.x = mouse.y = -1;
}
: mouse(-1, -1),
buttons(0, 0, 0)
{ }

Int2 mouse;
Int3 buttons;
}
inputdata;

@@ -74,3 +75,18 @@ Int2 Input::GetMousePos()
return data->mouse;
}

void Input::SetMouseButton(int index)
{
data->buttons[index] = 1;
}

void Input::UnsetMouseButton(int index)
{
data->buttons[index] = 0;
}

Int3 Input::GetMouseButtons()
{
return data->buttons;
}


+ 3
- 0
src/input.h View File

@@ -24,6 +24,9 @@ public:
static Float2 GetAxis(int axis);
static void SetMousePos(Int2 coord);
static Int2 GetMousePos();
static void SetMouseButton(int index);
static void UnsetMouseButton(int index);
static Int3 GetMouseButtons();
};

#endif // __DH_INPUT_H__


+ 4
- 0
src/sdlinput.cpp View File

@@ -65,6 +65,10 @@ void SdlInput::TickGame(float deltams)
else if (event.type == SDL_KEYDOWN)
Input::KeyPressed(event.key.keysym.sym, deltams);
#endif
else if (event.type == SDL_MOUSEBUTTONDOWN)
Input::SetMouseButton(event.button.button - 1);
else if (event.type == SDL_MOUSEBUTTONUP)
Input::UnsetMouseButton(event.button.button - 1);
}

/* Send the whole keyboard state to the input system */


Loading…
Cancel
Save