-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.cpp
More file actions
36 lines (33 loc) · 1.07 KB
/
Input.cpp
File metadata and controls
36 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "Input.h"
void Input::MouseButtonDown(SDL_MouseButtonEvent &b) {
if (b.button == SDL_BUTTON_LEFT) {
mouseButtonDown_Left = true;
}
else if (b.button == SDL_BUTTON_RIGHT) {
mouseButtonDown_Right = true;
}
else if (b.button == SDL_BUTTON_MIDDLE) {
mouseButtonDown_Middle = true;
}
SDL_GetMouseState(&prevMousePosition.first, &prevMousePosition.second);
}
void Input::MouseButtonUp(SDL_MouseButtonEvent &b) {
if (b.button == SDL_BUTTON_LEFT) {
mouseButtonDown_Left = false;
}
else if (b.button == SDL_BUTTON_RIGHT) {
mouseButtonDown_Right = false;
}
else if (b.button == SDL_BUTTON_MIDDLE) {
mouseButtonDown_Middle = false;
}
}
bool Input::GetMouseButtonDown(std::string button) {
if (button == "Left" || button == "left") {
return mouseButtonDown_Left;
} else if (button == "Right" || button == "right") {
return mouseButtonDown_Right;
} else if (button == "Middle" || button == "middle") {
return mouseButtonDown_Middle;
} else return false;
}