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