1 #ifndef __DALI_INTERNAL_ADAPTOR_INPUT_INTERFACE_H__
2 #define __DALI_INTERNAL_ADAPTOR_INPUT_INTERFACE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
37 * @brief interface used by the Wayland input listeners to signal an event.
39 * The events that come from keyboard, pointer and touch devices are from a specific seat.
40 * A single seat can have multiple keyboards, pointers and touch devices connected to it.
42 * For example you can have a car with 4 seats each with their own touch screen that
43 * are run by a central device with multi-display output.
45 * Some input events have serial numbers and time stamps.
47 * Serial numbers description from Wayland documentation:
48 * "To avoid race conditions, input events that are likely to trigger further requests
49 * (such as button presses, key events, pointer motions) carry serial numbers, and requests such as
50 * wl_surface.set_popup require that the serial number of the triggering event is specified."
52 * Time stamps description from Wayland documentation:
53 * "Input events also carry timestamps with millisecond granularity.
54 * Their base is undefined, so they can't be compared against system time
55 * (as obtained with clock_gettime or gettimeofday). They can be compared
56 * with each other though, and for instance be used to identify sequences
57 * of button presses as double or triple clicks."
62 public: // Pointer events. See wl_pointer_listener in wayland-client-protocol.h for more information.
65 * @brief Called when a seat's pointer has entered a surface
67 * When focus enters a surface, the pointer image is
68 * undefined and a client should respond to this event by setting
69 * an appropriate pointer image with the set_cursor request.
71 * @param[in] seat the seat that produced the event
72 * @param[in] serial serial number
73 * @param[in] surface surface
74 * @param[in] x x coordinate in surface-relative coordinates ( not screen )
75 * @param[in] y y coordinate in surface-relative coordinates ( not screen )
77 virtual void PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y) = 0;
80 * @brief Called when a seat's pointer leaves a surface
81 * @param[in] seat the seat that produced the event
82 * @param[in] serial serial number
83 * @param[in] surface surface
85 * The leave notification is sent before the enter notification for
88 virtual void PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface ) = 0;
91 * @brief pointer motion event
93 * @param[in] seat the seat that produced the event
94 * @param[in] timestamp timestamp with millisecond granularity
95 * @param[in] x x coordinate in surface-relative coordinates ( not screen )
96 * @param[in] y y coordinate in surface-relative coordinates ( not screen )
99 virtual void PointerMotion( Seat* seat, unsigned int timestamp, float x, float y ) = 0;
102 * @brief pointer click and release events
104 * @param[in] seat the seat that produced the event
105 * @param[in] serial serial number
106 * @param[in] timestamp timestamp with millisecond granularity
107 * @param[in] button pointer button pressed
108 * @param[in] state button state ( 1 = down, 0 = up)
110 * The location of the click is given by the last motion or enter
113 virtual void PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state ) = 0;
116 * @brief Pointer scroll and other axis notifications.
118 * @param[in] seat the seat that produced the event
119 * @param[in] timestamp timestamp with millisecond granularity
120 * @param[in] axis pointer axis
121 * @param[in] value length of a vector along the specified axis in a coordinate space identical to those of motion event
123 virtual void PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value ) = 0;
125 public: // Key events. See wl_keyboard_listener in wayland-client-protocol.h for more information.
128 * @brief keyboard mapping
129 * Provides a file descriptor which can be memory-mapped to a keyboard mapping description
131 * @param[in] seat the seat that produced the event
132 * @param[in] format see wl_keyboard_keymap_format
133 * @param[in] fd file descriptor
134 * @param[in] size size of the memory mapped region in bytes
136 virtual void KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size ) = 0;
139 * @brief The seat's keyboard focus has entered a surface
141 * @param[in] seat the seat that produced the event
142 * @param[in] serial serial number
143 * @param[in] surface surface
144 * @param[in] keys the currently pressed keys
146 virtual void KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys ) = 0;
149 * @brief The seat's keyboard focus has left a surface
151 * The leave notification is sent before the enter notification for the new focus.
152 * @param[in] seat the seat that produced the event
153 * @param[in] serial serial number
154 * @param[in] surface surface
156 virtual void KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface ) = 0;
159 * @brief Key has been pressed or released
161 * @param[in] seat the seat that produced the event
162 * @param[in] serial serial number
163 * @param[in] timestamp timestamp
164 * @param[in] keycode raw hardware key code
167 virtual void KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state) = 0;
170 * @brief Key modifier state has changed
172 * @param[in] seat the seat that produced the event
173 * @param[in] serial serial number
174 * @param[in] depressed modifiers depressed
175 * @param[in] latched modifiers latched
176 * @param[in] locked modifiers locked
177 * @param[in[ group group
179 virtual void KeyModifiers( Seat* seat,
181 unsigned int depressed,
182 unsigned int latched,
184 unsigned int group) = 0;
188 * @brief Key repeat rate and delay.
190 * Informs DALi of the keyboard's repeat rate and delay.
192 * Event sent when wl_keyboard object created, before any key events
193 * If rate == zero, repeating is disabled
195 * @param[in] seat the seat that produced the event
196 * @param[in] rate rate of repeating keys in characters per second
197 * @param[in] delay delay in milliseconds since key down until repeating starts
199 virtual void KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay) = 0;
202 public: // touch events. See wl_touch_listener in wayland-client-protocol.h for more information.
205 * @brief Touch down event on a surface.
207 * Future events from this touch point will have the same id which is valid
208 * until a touch up event.
209 * @param[in] seat the seat that produced the event
210 * @param[in] serial serial number
211 * @param[in] timestamp timestamp
212 * @param[in] surface surface
213 * @param[in] touchId unique touch id valid until touch is released
214 * @param[in] x coordinate in surface-relative coordinates
215 * @param[in[ y coordinate in surface-relative coordinates
217 virtual void TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y) = 0;
220 * @brief Touch up event on a surface.
222 * @param[in] seat the seat that produced the event
223 * @param[in] serial serial number
224 * @param[in] timestamp timestamp with millisecond granularity
225 * @param[in] touchId unique touch id valid until touch is released ( can be re-used for future events)
227 virtual void TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId ) = 0;
230 * @brief Touch Motion event on a surface.
231 * Events relating to the same touch point can be identified by the touchId
233 * @param[in] seat the seat that produced the event
234 * @param[in] timestamp timestamp with millisecond granularity
235 * @param[in] touchId unique touch id valid until touch is released ( then can be re-used)
236 * @param[in] x coordinate in surface-relative coordinates
237 * @param[in[ y coordinate in surface-relative coordinates
239 virtual void TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y ) = 0;
242 * @brief end of touch frame event
243 * Unsure what this means.
244 * @param[in] seat the seat that produced the event
246 virtual void TouchFrame( Seat* seat ) = 0;
249 * @brief Cancel current touch session
250 * If Wayland Compositor decides current touch stream is a global
251 * gesture we have to cancel any touch / gesture detection.
253 * Touch cancellation applies to all touch points currently active on
254 * our surface. TouchPoint::Interrupted will be sent to dali-core
256 * @param[in] seat the seat that produced the event
258 virtual void TouchCancel( Seat* seat ) = 0;
260 public: // Helper functions used to find the seat associated with the keyboard/pointer/touch device
263 * @brief get the seat that contains the keyboard interface
264 * @param[in] keyboard wayland keyboard interface
265 * @return the seat the keyboard belongs to
267 virtual Seat* GetSeat( const WlKeyboard* keyboard ) = 0;
270 * @brief get the seat that contains the pointer interface
271 * @param[in] pointer wayland pointer interface
272 * @return the seat the pointer belongs to
274 virtual Seat* GetSeat( const WlPointer* pointer ) = 0;
277 * @brief get the seat that contains the touch interface
278 * @param[in] touch wayland touch interface
279 * @return the seat the touch device belongs to
281 virtual Seat* GetSeat( const WlTouch* touch ) = 0;
284 * @brief get the seat that contains the wayland seat interface
285 * @param[in] seat wayland seat interface
286 * @return the seat the touch device belongs to
288 virtual Seat* GetSeat( const WlSeat* seat ) = 0;
302 virtual ~InputInterface()
306 // Undefined copy constructor.
307 InputInterface( const InputInterface& );
309 // Undefined assignment operator.
310 InputInterface& operator=( const InputInterface& );
319 #endif //__DALI_INTERNAL_ADAPTOR_INPUT_INTERFACE_H__