-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make osc::Event virtual and start adding necessary infra for parsing …
…etc.
- Loading branch information
1 parent
969024c
commit 57fd286
Showing
5 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "Event.h" | ||
|
||
#include <memory> | ||
|
||
using namespace osc; | ||
|
||
std::unique_ptr<Event> osc::parse_into_event(const SDL_Event& e) | ||
{ | ||
return std::make_unique<RawEvent>(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
union SDL_Event; | ||
|
||
namespace osc | ||
{ | ||
// base class for application events | ||
class Event { | ||
public: | ||
protected: | ||
explicit Event(const SDL_Event& e) : inner_event_{&e} {} | ||
|
||
Event(const Event&) = default; | ||
Event(Event&&) noexcept = default; | ||
Event& operator=(const Event&) = default; | ||
Event& operator=(Event&&) noexcept = default; | ||
public: | ||
virtual ~Event() noexcept = default; | ||
|
||
operator const SDL_Event& () const { return *inner_event_; } | ||
private: | ||
const SDL_Event* inner_event_; | ||
}; | ||
|
||
// a "raw" uncategorized event from the underlying OS/OS abstraction layer | ||
class RawEvent : public Event { | ||
public: | ||
explicit RawEvent(const SDL_Event& e) : Event{e} {} | ||
}; | ||
|
||
std::unique_ptr<Event> parse_into_event(const SDL_Event&); | ||
} |