commenting and fixing bugs
This commit is contained in:
@@ -27,8 +27,8 @@ Detector::~Detector()
|
||||
{
|
||||
is_running = false;
|
||||
|
||||
detect_thread.join();
|
||||
notify_thread.join();
|
||||
detect_thread.join();
|
||||
}
|
||||
|
||||
void Detector::register_input_event_handler(InputEventHandler* handler)
|
||||
@@ -61,12 +61,13 @@ void Detector::notify_handlers()
|
||||
LOCK_EVENT_HANDLER();
|
||||
for(auto* handler : event_handler)
|
||||
{
|
||||
// todo timeout!
|
||||
handler->handle(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cycles over all inputs and enqueues an input event if detected.
|
||||
void Detector::detect()
|
||||
{
|
||||
while(is_running)
|
||||
@@ -74,12 +75,20 @@ void Detector::detect()
|
||||
char address;
|
||||
if(check_inputs(address))
|
||||
{
|
||||
InputEvent& event = input_events.at(address);
|
||||
event_queue.emplace(event);
|
||||
try
|
||||
{
|
||||
InputEvent& event = input_events.at(address);
|
||||
event_queue.emplace(event);
|
||||
}
|
||||
catch(std::out_of_range& e)
|
||||
{
|
||||
// todo log exception!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// todo work with gpiointerface
|
||||
bool Detector::check_inputs(char& address)
|
||||
{
|
||||
for(int row = 0; row < 8; row++)
|
||||
|
||||
Reference in New Issue
Block a user