aboutsummaryrefslogtreecommitdiff
path: root/mwe/events/src/inputSystem.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-16 15:26:54 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-16 15:26:54 +0100
commit6b3feac981ce78144fb69e490640a4b07dd29f1d (patch)
tree88c9a7b1b03ada97a8152591deb035681f99b7c8 /mwe/events/src/inputSystem.cpp
parent8209678e20605936b2ce58331c1a65d8f23fee91 (diff)
parent9f6475e7b0698c414138e2a8140b47f01ce9c5d1 (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/events
Diffstat (limited to 'mwe/events/src/inputSystem.cpp')
-rw-r--r--mwe/events/src/inputSystem.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/mwe/events/src/inputSystem.cpp b/mwe/events/src/inputSystem.cpp
index b87b12e..d740c9e 100644
--- a/mwe/events/src/inputSystem.cpp
+++ b/mwe/events/src/inputSystem.cpp
@@ -3,9 +3,7 @@
InputSystem::InputSystem() {}
void InputSystem::registerButton(Button * button) { buttons.push_back(button); }
-void InputSystem::registerTextInput(TextInput * input) {
- textInputs.push_back(input);
-}
+void InputSystem::registerTextInput(TextInput * input) { textInputs.push_back(input); }
void InputSystem::registerText(Text * label) { texts.push_back(label); }
void InputSystem::processInput() {
@@ -16,8 +14,7 @@ void InputSystem::processInput() {
triggerEvent(ShutDownEvent());
break;
case SDL_KEYDOWN:
- triggerEvent(
- KeyPressedEvent(getCustomKey(event.key.keysym.sym)));
+ triggerEvent(KeyPressedEvent(getCustomKey(event.key.keysym.sym)));
processKeyPress(event.key.keysym.sym);
break;
case SDL_TEXTINPUT:
@@ -37,15 +34,14 @@ void InputSystem::processInput() {
void InputSystem::processMouseClick(int mouseX, int mouseY) {
for (auto * button : buttons) {
- if (mouseX >= button->x && mouseX <= (button->x + button->width)
- && mouseY >= button->y && mouseY <= (button->y + button->height)) {
+ if (mouseX >= button->x && mouseX <= (button->x + button->width) && mouseY >= button->y
+ && mouseY <= (button->y + button->height)) {
button->onClick();
}
}
for (auto * textInput : textInputs) {
if (mouseX >= textInput->x && mouseX <= textInput->x + textInput->width
- && mouseY >= textInput->y
- && mouseY <= textInput->y + textInput->height) {
+ && mouseY >= textInput->y && mouseY <= textInput->y + textInput->height) {
textInput->isActive = true;
} else {
textInput->isActive = false;