Merge "Remove the wearable definition in Makefile.am" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / input-manager.h
1 #ifndef __DALI_WAYLAND_INPUT_H__
2 #define __DALI_WAYLAND_INPUT_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/events/key-event.h>
24
25 // INTERNAL INCLUDES
26 #include <base/interfaces/window-event-interface.h>
27 #include <wl-types.h>
28 #include <input/input-interface.h>
29 #include <input/seat.h>
30 #include <input/text/text-input-manager.h>
31
32
33
34 namespace Dali
35 {
36 namespace Internal
37 {
38 namespace Adaptor
39 {
40
41 /**
42  * @brief Listens to Wayland input events.
43  * Translates the wayland events into DALi events and forwards them to a WindowEventInterface
44  */
45 class InputManager : public InputInterface
46 {
47
48 public:
49
50
51   /**
52    * @brief Constructor
53    */
54   InputManager();
55
56   /**
57    * @brief Destructor
58    */
59   virtual ~InputManager();
60
61   /**
62    * @brief Assign the window event interface
63    * @param[in]  eventInterface event interface
64    */
65   void AssignWindowEventInterface( WindowEventInterface* eventInterface);
66
67   /**
68    * @brief Assign the Wayland connection
69    * @param[in] display Wayland display
70    */
71   void AssignDisplay( WlDisplay* display );
72
73   /**
74    * @brief Assign the Wayland surface
75    * @param[in] surface wayland surface
76    */
77   void AssignSurface( WlSurface* surface);
78
79   /**
80    * @brief listen to events on this seat
81    * @param[in] seatInterface output interface
82    */
83   void AddSeatListener( Dali::WlSeat* seatInterface );
84
85   /**
86    * @brief add text input manager interface
87    * @param[in] textInputManager text input manager
88    */
89   void AddTextInputManager( Dali::WlTextInputManager* textInputManager );
90
91
92 protected: //InputInterface, pointer events
93
94   /**
95    * @copydoc InputInterface::PointerEnter
96    */
97   virtual void PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y );
98
99   /**
100    * @copydoc InputInterface::PointerLeave
101    */
102   virtual void PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface );
103
104   /**
105    * @copydoc InputInterface::PointerMotion
106    */
107   virtual void PointerMotion( Seat* seat, unsigned int timestamp, float x, float y );
108
109   /**
110    * @copydoc InputInterface::PointerButton
111    */
112   virtual void PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state );
113
114   /**
115    * @copydoc InputInterface::PointerAxis
116    */
117   virtual void PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value );
118
119
120 protected: //InputInterface, keyboard events
121
122   /**
123    * @copydoc InputInterface::KeyboardKeymap
124    */
125   virtual void KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size );
126
127   /**
128    * @copydoc InputInterface::KeyFocusEnter
129    */
130   virtual void KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys );
131
132   /**
133    * @copydoc InputInterface::KeyFocusLeave
134    */
135   virtual void KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface );
136
137   /**
138    * @copydoc InputInterface::KeyEvent
139    */
140   virtual void KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state );
141
142   /**
143    * @copydoc InputInterface::KeyModifiers
144    */
145   virtual void KeyModifiers( Seat* seat,
146                             unsigned int serial,
147                             unsigned int depressed,
148                             unsigned int latched,
149                             unsigned int locked,
150                             unsigned int group );
151
152   /**
153    * @copydoc InputInterface::KeyRepeatInfo
154    */
155   virtual void KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay);
156
157 protected: //InputInterface, touch events
158
159   /**
160    * @copydoc InputInterface::TouchDown
161    */
162   virtual void TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y);
163
164   /**
165    * @copydoc InputInterface::TouchUp
166    */
167   virtual void TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId );
168
169   /**
170    * @copydoc InputInterface::TouchMotion
171    */
172   virtual void TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y );
173
174   /**
175    * @copydoc InputInterface::TouchFrame
176    */
177   virtual void TouchFrame( Seat* seat );
178
179   /**
180    * @copydoc InputInterface::TouchCancel
181    */
182   virtual void TouchCancel( Seat* seat );
183
184
185 protected: //InputInterface  Helper functions
186
187   /**
188    * @copydoc InputInterface::GetSeat( const WlKeyboard* keyboard )
189    */
190   virtual Seat* GetSeat( const WlKeyboard* keyboard );
191
192   /**
193    * @copydoc InputInterface::GetSeat( const WlPointer* pointer )
194    */
195   virtual Seat* GetSeat( const WlPointer* pointer );
196
197   /**
198    * @copydoc InputInterface::GetSeat( const WlTouch* touch )
199    */
200   virtual Seat* GetSeat( const WlTouch* touch );
201
202   /**
203    * @copydoc InputInterface::GetSeat( const WlSeat* seat )
204    */
205   virtual Seat* GetSeat( const WlSeat* seat );
206
207 public:
208
209   /**
210    * @brief Add a new seat ( collection of input devices)
211    * @param[in] wlRegistry
212    * @param[in] seatName seat name / id
213    * @param[in] version interface version
214    */
215   void AddSeat( Seat* seat );
216
217
218 private:
219
220  Dali::Vector< Seat* > mSeats;
221  TextInputManager mTextInputManger;
222  WlDisplay* mDisplay;
223  WindowEventInterface* mWindowEventInterface;
224
225 };
226
227 } // Internal
228 } // Adaptor
229 } // Dali
230
231 #endif  //__DALI_WAYLAND_INPUT_H__