0fc0b1fbafd6a8cc0b8d5d93f2fbc5657800e7e7
[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
24 // INTERNAL INCLUDES
25 #include <base/interfaces/window-event-interface.h>
26 #include <wl-types.h>
27 #include <input/input-interface.h>
28 #include <input/seat.h>
29 #include <input/text/text-input-manager.h>
30
31
32
33 namespace Dali
34 {
35 namespace Internal
36 {
37 namespace Adaptor
38 {
39
40 /**
41  * @brief Listens to Wayland input events.
42  * Translates the wayland events into DALi events and forwards them to a WindowEventInterface
43  */
44 class InputManager : public InputInterface
45 {
46
47 public:
48
49
50   /**
51    * @brief Constructor
52    */
53   InputManager();
54
55   /**
56    * @brief Destructor
57    */
58   virtual ~InputManager();
59
60   /**
61    * @brief Assign the window event interface
62    * @param[in]  eventInterface event interface
63    */
64   void AssignWindowEventInterface( WindowEventInterface* eventInterface);
65
66   /**
67    * @brief Assign the Wayland connection
68    * @param[in] display Wayland display
69    */
70   void AssignDisplay( WlDisplay* display );
71
72   /**
73    * @brief Assign the Wayland surface
74    * @param[in] surface wayland surface
75    */
76   void AssignSurface( WlSurface* surface);
77
78   /**
79    * @brief listen to events on this seat
80    * @param[in] seatInterface output interface
81    */
82   void AddSeatListener( Dali::WlSeat* seatInterface );
83
84   /**
85    * @brief add text input manager interface
86    * @param[in] textInputManager text input manager
87    */
88   void AddTextInputManager( Dali::WlTextInputManager* textInputManager );
89
90
91 protected: //InputInterface, pointer events
92
93   /**
94    * @copydoc InputInterface::PointerEnter
95    */
96   virtual void PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y );
97
98   /**
99    * @copydoc InputInterface::PointerLeave
100    */
101   virtual void PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface );
102
103   /**
104    * @copydoc InputInterface::PointerMotion
105    */
106   virtual void PointerMotion( Seat* seat, unsigned int timestamp, float x, float y );
107
108   /**
109    * @copydoc InputInterface::PointerButton
110    */
111   virtual void PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state );
112
113   /**
114    * @copydoc InputInterface::PointerAxis
115    */
116   virtual void PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value );
117
118
119 protected: //InputInterface, keyboard events
120
121   /**
122    * @copydoc InputInterface::KeyboardKeymap
123    */
124   virtual void KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size );
125
126   /**
127    * @copydoc InputInterface::KeyFocusEnter
128    */
129   virtual void KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys );
130
131   /**
132    * @copydoc InputInterface::KeyFocusLeave
133    */
134   virtual void KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface );
135
136   /**
137    * @copydoc InputInterface::KeyEvent
138    */
139   virtual void KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state );
140
141   /**
142    * @copydoc InputInterface::KeyModifiers
143    */
144   virtual void KeyModifiers( Seat* seat,
145                             unsigned int serial,
146                             unsigned int depressed,
147                             unsigned int latched,
148                             unsigned int locked,
149                             unsigned int group );
150
151   /**
152    * @copydoc InputInterface::KeyRepeatInfo
153    */
154   virtual void KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay);
155
156 protected: //InputInterface, touch events
157
158   /**
159    * @copydoc InputInterface::TouchDown
160    */
161   virtual void TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y);
162
163   /**
164    * @copydoc InputInterface::TouchUp
165    */
166   virtual void TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId );
167
168   /**
169    * @copydoc InputInterface::TouchMotion
170    */
171   virtual void TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y );
172
173   /**
174    * @copydoc InputInterface::TouchFrame
175    */
176   virtual void TouchFrame( Seat* seat );
177
178   /**
179    * @copydoc InputInterface::TouchCancel
180    */
181   virtual void TouchCancel( Seat* seat );
182
183
184 protected: //InputInterface  Helper functions
185
186   /**
187    * @copydoc InputInterface::GetSeat( const WlKeyboard* keyboard )
188    */
189   virtual Seat* GetSeat( const WlKeyboard* keyboard );
190
191   /**
192    * @copydoc InputInterface::GetSeat( const WlPointer* pointer )
193    */
194   virtual Seat* GetSeat( const WlPointer* pointer );
195
196   /**
197    * @copydoc InputInterface::GetSeat( const WlTouch* touch )
198    */
199   virtual Seat* GetSeat( const WlTouch* touch );
200
201   /**
202    * @copydoc InputInterface::GetSeat( const WlSeat* seat )
203    */
204   virtual Seat* GetSeat( const WlSeat* seat );
205
206 public:
207
208   /**
209    * @brief Add a new seat ( collection of input devices)
210    * @param[in] wlRegistry
211    * @param[in] seatName seat name / id
212    * @param[in] version interface version
213    */
214   void AddSeat( Seat* seat );
215
216
217 private:
218
219  Dali::Vector< Seat* > mSeats;
220  TextInputManager mTextInputManger;
221  WlDisplay* mDisplay;
222  WindowEventInterface* mWindowEventInterface;
223
224 };
225
226 } // Internal
227 } // Adaptor
228 } // Dali
229
230 #endif  //__DALI_WAYLAND_INPUT_H__