diff --git a/FlippR-Driver/src/Input/Detector.cpp b/FlippR-Driver/src/Input/Detector.cpp new file mode 100644 index 0000000..87ae5f8 --- /dev/null +++ b/FlippR-Driver/src/Input/Detector.cpp @@ -0,0 +1,54 @@ +/* + * Detector.cpp + * + * Created on: Apr 5, 2018 + * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht + */ + +#include "Detector.h" + +#include + +namespace Input +{ + +Detector::Detector(std::vector events) : + input_events(events), is_running(true) +{ + detect_thread = std::thread(&Detector::detect, this); +} + + +Detector::~Detector() +{ + is_running = false; + detect_thread.join(); +} + +void Detector::register_input_event_handler(InputEventHandler* handler) +{ + event_handler.insert(handler); +} + +void Detector::unregister_input_event_handler(InputEventHandler* handler) +{ + event_handler.erase(handler); +} + +void Detector::detect() +{ + while(is_running) + { + std::cout << "hallo_thread\n"; + } +} + +void Detector::notify_handlers(InputEvent& event) +{ + for(auto* handler : event_handler) + { + handler->handle(event); + } +} + +} diff --git a/FlippR-Driver/src/Input/Detector.h b/FlippR-Driver/src/Input/Detector.h new file mode 100644 index 0000000..dd51e68 --- /dev/null +++ b/FlippR-Driver/src/Input/Detector.h @@ -0,0 +1,45 @@ +/* + * Detector.h + * + * Created on: Apr 5, 2018 + * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht + */ + +#ifndef DETECTOR_H_ +#define DETECTOR_H_ + +#include +#include + +#include "InputEvent.h" + +namespace Input +{ + +class Detector +{ +public: + Detector(std::vector events); + ~Detector(); + + void register_input_event_handler(InputEventHandler* handler); + void unregister_input_event_handler(InputEventHandler* handler); + +private: + void detect(); + + void notify_handlers(InputEvent& event); + +private: + std::vector input_events; + std::set event_handler; + + std::thread detect_thread; + bool is_running; +}; + +} + + + +#endif /* DETECTOR_H_ */ diff --git a/FlippR-Driver/src/Input/InputEvent.h b/FlippR-Driver/src/Input/InputEvent.h new file mode 100644 index 0000000..f495bca --- /dev/null +++ b/FlippR-Driver/src/Input/InputEvent.h @@ -0,0 +1,33 @@ +/* + * InputEvent.h + * + * Created on: Apr 5, 2018 + * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht + */ + +#ifndef INPUTEVENT_H_ +#define INPUTEVENT_H_ + +#include +#include + +#include "InputEventHandler.h" + +namespace Input +{ + +class InputEvent +{ +public: + InputEvent(); + ~InputEvent(); + +private: + char address; + std::string name; +}; + +} + + +#endif /* INPUTEVENT_H_ */ diff --git a/FlippR-Driver/src/Input/InputEventHandler.h b/FlippR-Driver/src/Input/InputEventHandler.h new file mode 100644 index 0000000..1857a32 --- /dev/null +++ b/FlippR-Driver/src/Input/InputEventHandler.h @@ -0,0 +1,26 @@ +/* + * InputEventHandler.h + * + * Created on: Apr 5, 2018 + * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht + */ + +#ifndef INPUTEVENTHANDLER_H_ +#define INPUTEVENTHANDLER_H_ + +#include "InputEvent.h" + +namespace Input +{ + + +class InputEventHandler +{ +public: + virtual ~InputEventHandler(){}; + virtual void handle(InputEvent& event) = 0; +}; + +} + +#endif /* INPUTEVENTHANDLER_H_ */ diff --git a/FlippR-Driver/src/Input/InputFactory.h b/FlippR-Driver/src/Input/InputFactory.h new file mode 100644 index 0000000..aa86965 --- /dev/null +++ b/FlippR-Driver/src/Input/InputFactory.h @@ -0,0 +1,33 @@ +/* + * InputFactory.h + * + * Created on: Apr 5, 2018 + * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht + */ + +#ifndef INPUTFACTORY_H_ +#define INPUTFACTORY_H_ +#include + +#include "InputEvent.h" + +namespace Input +{ +class InputFactory +{ + +public: + InputFactory(); + ~InputFactory(); + + std::vector get_input_events(); + +private: + std::vector input_events; + +}; +} + + + +#endif /* INPUTFACTORY_H_ */ diff --git a/FlippR-Driver/src/Input/main.cpp b/FlippR-Driver/src/Input/main.cpp new file mode 100644 index 0000000..408487e --- /dev/null +++ b/FlippR-Driver/src/Input/main.cpp @@ -0,0 +1,12 @@ +#include +#include "InputEvent.h" +#include "Detector.h" +#include +int main() +{ + Input::Detector(std::vector()); + + std::printf("hallo"); + + return 0; +}