From 4cd9bbb4ed8e3e01a48dcc341b9350bfc397a9ea Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Sat, 14 Jan 2017 01:16:03 -0800 Subject: [PATCH] Did a lot of boilerplate on the Event wrapper --- {src => assets/fonts}/unifont.ttf | Bin include/Event.hpp | 74 ++++++++++++++++++++++++++++++ include/Pub_Sub.hpp | 6 +++ 3 files changed, 80 insertions(+) rename {src => assets/fonts}/unifont.ttf (100%) create mode 100644 include/Event.hpp diff --git a/src/unifont.ttf b/assets/fonts/unifont.ttf similarity index 100% rename from src/unifont.ttf rename to assets/fonts/unifont.ttf diff --git a/include/Event.hpp b/include/Event.hpp new file mode 100644 index 0000000..537d6e2 --- /dev/null +++ b/include/Event.hpp @@ -0,0 +1,74 @@ +#pragma once + + +namespace vr { + + + class Event { + public: + enum EventType + { + Closed, + Resized, + LostFocus, + GainedFocus, + TextEntered, + KeyPressed, + KeyReleased, + MouseWheelMoved, + MouseWheelScrolled, + MouseButtonPressed, + MouseButtonReleased, + MouseMoved, + MouseEntered, + MouseLeft, + JoystickButtonPressed, + JoystickButtonReleased, + JoystickMoved, + JoystickConnected, + JoystickDisconnected, + TouchBegan, + TouchMoved, + TouchEnded, + SensorChanged, + Count + }; + + EventType type; + + }; + + Closed, + Resized, + LostFocus, + GainedFocus, + TextEntered, + KeyPressed, + KeyReleased, + MouseWheelMoved, + MouseWheelScrolled, + MouseButtonPressed, + MouseButtonReleased, + MouseMoved, + MouseEntered, + MouseLeft, + JoystickButtonPressed, + JoystickButtonReleased, + JoystickMoved, + JoystickConnected, + JoystickDisconnected, + TouchBegan, + TouchMoved, + TouchEnded, + SensorChanged, + Count + + + + + + + + + +} \ No newline at end of file diff --git a/include/Pub_Sub.hpp b/include/Pub_Sub.hpp index 205551b..654a076 100644 --- a/include/Pub_Sub.hpp +++ b/include/Pub_Sub.hpp @@ -119,9 +119,15 @@ public: event_class = Event_Class::SensorEvent; } + else { + std::cout << "Unable to classify sf::Event into Event_Class"; + abort(); + } + // get the bucket containing subscribers to that Event_Class std::vector *event_type_bucket = &subscribers[event_class]; + // Send them the event for (auto s : *event_type_bucket) { s->update(this, e); }