DUDS
Distributed Update of Data from Something
InputHandlers.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2020 Jeff Jackowski
9  */
10 // for open() and related items; may be more than needed
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <fcntl.h>
16 #include <boost/exception/errinfo_file_name.hpp>
17 #include <boost/exception/errinfo_errno.hpp>
18 #include <duds/general/Errors.hpp>
19 
20 namespace duds { namespace os { namespace linux {
21 
22 void InputHandlers::handleEvent(EventTypeCode etc, std::int32_t value) {
23  InputMap::const_iterator iter = receivers.find(etc);
24  const InputSignal *is;
25  if (iter != receivers.end()) {
26  is = &iter->second;
27  } else {
28  is = &defReceiver;
29  }
30  (*is)(etc, value);
31 }
32 
34  receivers.clear();
35  defReceiver.disconnect_all_slots();
36 }
37 
38 } } }
InputMap receivers
Relates events to signal handlers.
void handleEvent(EventTypeCode etc, std::int32_t value)
Dispatches the provided input event to the appropriate InputSignal.
boost::signals2::signal< void(EventTypeCode etc, std::int32_t value)> InputSignal
The signal type that will handle input events.
Combines an event type and an event code, as defined by libevdev, for the purpose of using a combinat...
void clear()
Removes all input handlers.
InputSignal defReceiver
Handles input for events that are not listed in the receivers InputMap.
General errors.