summaryrefslogtreecommitdiff
path: root/Widgets/EventLoopSDL.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-11 01:48:09 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-11 01:48:09 +0200
commitf337616741b690feb36ed8e104df85ed5117daaa (patch)
treeddf346dd5c7f3871d56f8457e3a496e829ae51ae /Widgets/EventLoopSDL.cpp
parentaee66e011954b4a071edfca0e5ebf124da5f0ffb (diff)
downloadserenity-f337616741b690feb36ed8e104df85ed5117daaa.zip
More hacking on Widgets.
Diffstat (limited to 'Widgets/EventLoopSDL.cpp')
-rw-r--r--Widgets/EventLoopSDL.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Widgets/EventLoopSDL.cpp b/Widgets/EventLoopSDL.cpp
index 13eb047075..f607c3be15 100644
--- a/Widgets/EventLoopSDL.cpp
+++ b/Widgets/EventLoopSDL.cpp
@@ -12,6 +12,19 @@ EventLoopSDL::~EventLoopSDL()
{
}
+static inline MouseButton toMouseButton(byte sdlButton)
+{
+ printf("sdlbutton = %u\n", sdlButton);
+ if (sdlButton == 1)
+ return MouseButton::Left;
+ if (sdlButton == 2)
+ return MouseButton::Middle;
+ if (sdlButton == 3)
+ return MouseButton::Right;
+ ASSERT_NOT_REACHED();
+ return MouseButton::None;
+}
+
void EventLoopSDL::waitForEvent()
{
SDL_Event sdlEvent;
@@ -30,6 +43,9 @@ void EventLoopSDL::waitForEvent()
case SDL_MOUSEMOTION:
postEvent(&AbstractScreen::the(), make<MouseEvent>(Event::MouseMove, sdlEvent.motion.x, sdlEvent.motion.y));
return;
+ case SDL_MOUSEBUTTONDOWN:
+ postEvent(&AbstractScreen::the(), make<MouseEvent>(Event::MouseDown, sdlEvent.button.x, sdlEvent.button.y, toMouseButton(sdlEvent.button.button)));
+ return;
}
}
}