1 #ifndef __DALI_WAYLAND_SEAT_H__
2 #define __DALI_WAYLAND_SEAT_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.
23 #include <xkbcommon/xkbcommon.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/events/key-event.h>
44 * A single seat is a group of keyboards, pointers and touch devices.
46 * For example you can have a car with 4 seats each with their own touch screen that
47 * is run by a central computer with a multi-display output.
49 * Or you may have two people / two seats in an office sharing the same screen at the same time.
52 * There is a single wl_pointer / wl_touch and wl_keyboard interface per seat.
53 * But each interface can have multiple devices. E.g. wl_pointer interface may have 2
54 * mouse pointers attached.
56 * Input devices can be hot plugged. However wl_pointer / wl_touch and wl_keyboard interface
57 * will only be destroyed when the interface has no devices associated with it.
58 * E.g. if a seat has a single mouse, when you unplug the mouse the interface is deleted.
59 * If a seat has two mice, only when you unplug both mice is the interface deleted.
68 * @brief Seat interface status for a device class ( keyboard, touch, pointer )
72 INTERFACE_AVAILABLE, ///< Occurs when at least 1 device for this device class is plugged in
73 INTERFACE_NOT_AVAILABLE, ///< Occurs when all devices for a device class are unplugged (e.g. all mice )
78 * @param[in] inputInterface input interface
79 * @param[in] seatInterface Wayland seat interface
81 Seat( InputInterface* inputInterface, WlSeat* seatInterface );
84 * @brief non virtual destructor, not intended as base class
89 * @brief set Tizen Wayland Text Input interface
90 * @param[in] textInputManager interface
92 void SetTextInputInterface( WlTextInput* textInput );
95 * @brief set the surface
96 * @param[in] surface Wayland surface currently associated with this seat ( for input panel / IMF )
98 void SetSurfaceInterface( WlSurface* surface );
101 * @brief Set the pointer interface
102 * @param[in] pointer Wayland pointer interface
103 * @param[in] status of the interface
105 void SetPointerInterface( InterfaceStatus status );
108 * @brief Set the touch interface
109 * @param[in] pointer Wayland pointer interface
110 * @param[in] status of the interface
112 void SetTouchInterface( InterfaceStatus status );
115 * @brief Set the keyboard interface
116 * @param[in] pointer Wayland pointer interface
117 * @param[in] status of the interface
119 void SetKeyboardInterface( InterfaceStatus status );
122 * @brief Get the pointer interface
123 * @return Wayland pointer interface
125 WlPointer* GetPointerInterface();
128 * @brief Get the touch interface
129 * @return Wayland touch interface
131 WlTouch* GetTouchInterface();
134 * @brief Get the keyboard interface
135 * @return Wayland keyboard interface
137 WlKeyboard* GetKeyboardInterface();
140 * @brief Get the keyboard interface
141 * @return Wayland keyboard interface
143 WlSeat* GetSeatInterface();
146 * @brief Get the text input interface
147 * @return Wayland text input interface
149 WlTextInput* GetTextInputInterface();
152 * @brief Get the surface
153 * @return Wayland surface
155 WlSurface* GetSurface();
158 * @brief calls wl_pointer_destroy on the pointer interface
160 void DestroyPointerInterface();
163 * @brief calls wl_touch_destroy on the touch interface
165 void DestroyTouchInterface();
168 * @brief calls wl_touch_keyboard on the keyboard interface
170 void DestroyKeyboardInterface();
173 * @brief place holder store the seat name
174 * Currently we don't store the name as DALi core isn't seat name aware
175 * Need to think about adding Seat name to touch / key events.
176 * @param[in] name seat name
178 void SetName( const char* name );
181 * @brief get the seat name
182 * E.g. may return "front-passenger-seat"
185 const std::string& GetName() const;
188 * @brief get the last known pointer position
189 * @return pointer position
191 const Dali::Vector2& GetLastPointerPosition() const;
194 * @brief set the pointer position
195 * So we need to cache mouse x/y position, for pointer down events which
196 * don't have x,y position attached
197 * @param[in] position pointer position
199 void SetPointerPosition( Dali::Vector2 position);
202 * @brief keyboard mapping
203 * Provides a file descriptor which can be memory-mapped to a keyboard mapping description
204 * @param[in] seat the seat that produced the event
205 * @param[in] format see wl_keyboard_keymap_format
206 * @param[in] fd file descriptor
207 * @param[in] size size of the memory mapped region in bytes
209 void KeyboardKeymap( unsigned int format, int fd, unsigned int size );
212 * @brief get current depressed keyboard modifiers (not latched)
213 * @return keyboard modifiers
215 unsigned int GetDepressedKeyboardModifiers() const ;
218 * @brief get current depressed keyboard modifiers (not latched)
219 * @param[in] modifiers depressed keyboard modifiers
221 void SetDepressedKeyboardModifiers( unsigned int modifiers);
224 * @brief set key repeat rate and delay
225 * @param[in] rate repeat rate in milliseconds
226 * @param[in] delay delay in milliseconds
228 void SetKeyRepeatInfo( unsigned int rate, unsigned int delay );
232 * @brief Key has been pressed or released.
233 * Used for key events from Tizen Wayland wl_text_input interface.
235 * @param[in] seat the seat that produced the event
236 * @param[in] timestamp timestamp
237 * @param[in] symbol key symbol
238 * @param[in] state key state
239 * @param[in] modifiers keyboard modifiers
243 Dali::KeyEvent GetDALiKeyEventFromSymbol( unsigned int serial,
244 unsigned int timestamp,
247 unsigned int modifiers );
250 * @brief Key has been pressed or released. Used
252 * @param[in] seat the seat that produced the event
253 * @param[in] serial serial number
254 * @param[in] timestamp timestamp
255 * @param[in] keycode raw hardware key code
259 KeyEvent GetDALiKeyEvent( unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state );
262 private: // data specific to a single seat
282 struct xkb_context *mContext;
283 struct xkb_keymap* mKeymap;
284 struct xkb_state* mState;
285 xkb_mod_mask_t mControlMask;
286 xkb_mod_mask_t mAltMask;
287 xkb_mod_mask_t mShiftMask;
293 XkbData mXkbData; ///< Keyboard data. Believe this can vary per seat
294 std::string mName; ///< Seat name
295 WlPointer* mPointer; ///< Wayland Pointer interface ( for multiple pointers )
296 WlKeyboard* mKeyboard; ///< Wayland Keyboard interface ( for multiple keyboards )
297 WlTouch* mTouch; ///< Wayland Touch interface ( for multiple touch devices )
298 WlSeat* mWaylandSeat; ///< Wayland Seat interface
299 WlTextInput* mTextInput; ///< Wayland Tizen Text input interface (Virtual Keyboard / IMF)
300 WlSurface* mSurface; ///< Surface currently used by this seat
301 InputInterface* mInputInterface; ///< DALi Wayland Input interface
302 Vector2 mPointerPosition; ///< Current pointer X,Y position
303 unsigned int mDepressedKeyboardModifiers; ///< keyboard modifiers
304 unsigned int mKeyRepeatRate;
305 unsigned int mKeyRepeatDelay;
314 #endif //__DALI_WAYLAND_SEAT_H__