Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
input-monitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Jan Olszak <j.olszak@samsung.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 
25 #ifndef SERVER_INPUT_MONITOR_HPP
26 #define SERVER_INPUT_MONITOR_HPP
27 
28 #include "input-monitor-config.hpp"
30 
31 #include <linux/input.h>
32 #include <sys/time.h>
33 
34 #include <string>
35 #include <list>
36 #include <mutex>
37 
38 
39 namespace vasum {
40 
41 class ZonesManager;
42 
43 class InputMonitor {
44 public:
46  const InputConfig& inputConfig,
47  ZonesManager* zonesManager);
48  ~InputMonitor();
49 
50  void start();
51  void stop();
52 private:
53  typedef std::mutex Mutex;
54 
57  int mFd;
59  std::list<struct timeval> mEventTimes;
60  std::string mDevicePath;
62 
63  std::string getDevicePath() const;
64  void setHandler(const std::string& devicePath);
65  void handleInternal(int fd, cargo::ipc::epoll::Events events);
66  void leaveDevice();
67  bool isExpectedEventSequence(const struct input_event&);
68 };
69 
70 } // namespace vasum
71 
72 
73 #endif // SERVER_INPUT_MONITOR_HPP
cargo::ipc::epoll::EventPoll & mEventPoll
Definition: input-monitor.hpp:58
C++ epoll wrapper.
Definition: input-monitor-config.hpp:37
ZonesManager * mZonesManager
Definition: input-monitor.hpp:56
Definition: input-monitor.hpp:43
Mutex mMutex
Definition: input-monitor.hpp:61
void setHandler(const std::string &devicePath)
Definition: input-monitor.cpp:190
Definition: zones-manager.hpp:51
std::string mDevicePath
Definition: input-monitor.hpp:60
void stop()
Definition: input-monitor.cpp:118
void start()
Definition: input-monitor.cpp:112
std::list< struct timeval > mEventTimes
Definition: input-monitor.hpp:59
~InputMonitor()
Definition: input-monitor.cpp:105
std::string getDevicePath() const
Definition: input-monitor.cpp:164
InputMonitor(cargo::ipc::epoll::EventPoll &eventPoll, const InputConfig &inputConfig, ZonesManager *zonesManager)
Definition: input-monitor.cpp:72
void handleInternal(int fd, cargo::ipc::epoll::Events events)
Definition: input-monitor.cpp:205
InputConfig mConfig
Definition: input-monitor.hpp:55
unsigned int Events
bitmask of EPOLL* constants
Definition: events.hpp:39
bool isExpectedEventSequence(const struct input_event &)
Definition: input-monitor.cpp:235
std::mutex Mutex
Definition: input-monitor.hpp:53
This class waits on registered file descriptor for events.
Definition: event-poll.hpp:47
Declaration of the struct for storing input monitor configuration.
int mFd
Definition: input-monitor.hpp:57
void leaveDevice()
Definition: input-monitor.cpp:226