refactoring

This commit is contained in:
Jonas Zeunert
2018-05-06 19:26:59 +02:00
parent 20b5be8bfa
commit c2fb59139b
5 changed files with 39 additions and 38 deletions

View File

@@ -10,41 +10,38 @@
#include <vector>
#include <thread>
#include <set>
#include <map>
#include "InputEvent.h"
#include "InputEventHandler.h"
#define SLEEP_DURATION 10
#define SLEEP_DURATION_NANO 900
namespace Input
{
class Detector
{
public:
Detector(std::map<std::string, char> input_config, std::set<InputEvent> events);
Detector(std::map<std::string, char> input_config, std::map<char, InputEvent> events);
~Detector();
void detect();
void register_input_event_handler(InputEventHandler* handler);
void unregister_input_event_handler(InputEventHandler* handler);
private:
void detect();
bool check_inputs(char& address);
void notify_handlers(InputEvent& event);
InputEvent& find_event(char address);
private:
std::map<std::string, char> gpio;
std::set<InputEvent> input_events;
std::map<char, InputEvent> input_events;
std::set<InputEventHandler*> event_handler;
std::thread detect_thread;
bool is_running;
};
}