1 #ifndef __DALI_INTERNAL_X_INPUT_2_MANAGER_H__
2 #define __DALI_INTERNAL_X_INPUT_2_MANAGER_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.
24 #include <X11/extensions/XInput2.h>
25 #include <X11/extensions/XI2.h>
26 #include <dali/public-api/common/dali-vector.h>
29 #include <base/interfaces/window-event-interface.h>
30 #include "x-input2-device.h"
43 * @brief Used to setup and process XInput2 events.
45 * For help with debugging, build DALi in debug mode then set the environment variables
46 * export LOG_X_INPUT_EVENTS=2
47 * export LOG_X_INPUT_DEVICES=2
57 XInput2( XID window, Display* display, WindowEventInterface* eventInterface );
65 * @brief enumerates input devices using XIQueryDevice then sets up event filtering using XISelectEvents
70 * @brief get X the extension id
73 int GetExtensionId() const;
76 * @brief process a generic X event
77 * @param[in] cookie X cookie
79 void ProcessGenericEvent( XGenericEventCookie* cookie );
82 * @brief process XKeyEvent
83 * @param[in] XKeyEvent key event
85 void ProcessKeyEvent( XKeyEvent* xKeyEvent );
88 * @brief process XKeyEvent
89 * @param[in] event x-event
91 void ProcessClientMessage( XEvent* event );
96 * @brief query x input devices
101 * @brief query multi-touch support
103 void QueryMultiTouchSupport();
106 * Uses XISelectEvents to select the events we want to recieve from each input device
108 void SelectInputEvents();
111 * @brief checks if we are filtering events from a specific device
112 * @param[in] deviceId device id
113 * @return true if the device is being filtered
115 bool FilteredDevice( int deviceId ) const;
118 * @brief Select specific events to be filtered on a device
119 * @param[in] device id
120 * @param[in] filter vector of X input events like XI_ButtonPress
122 void SelectEvents( int deviceId, const Dali::Vector< unsigned int >& filter );
125 * @brief checks if the event should be processed
126 * @param[in] deviceEvent device event
127 * @return true if should be processed
129 bool PreProcessEvent( XIDeviceEvent *deviceEvent ) const;
132 * @brief creates a DALi key event given a XIDeviceEvent for a key press
133 * @param[in] deviceEvent device event
134 * @param[out] keyEvent DALi key event
136 void CreateKeyEvent( const XIDeviceEvent* deviceEvent, KeyEvent& keyEvent ) const;
140 Dali::Vector< XInput2Device > mInputDeviceInfo; ///< list of input devices
141 WindowEventInterface* mEventInterface; ///< window event interface
142 Display* mDisplay; ///< X display
143 XID mWindow; ///< X window
144 int mXI2ExtensionId; ///< XI2 extension id
145 bool mMultiTouchSupport:1; ///< whether multi-touch is supported
148 } // namespace Adaptor
149 } // namespace Internal