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 an XInput2 event
77 * @param cookie X cookie
79 void ProcessEvent( XGenericEventCookie* cookie );
85 * @brief query x input devices
90 * @brief query multi-touch support
92 void QueryMultiTouchSupport();
95 * Uses XISelectEvents to select the events we want to recieve from each input device
97 void SelectInputEvents();
100 * @brief checks if we are filtering events from a specific device
101 * @param[in] deviceId device id
102 * @return true if the device is being filtered
104 bool FilteredDevice( int deviceId ) const;
107 * @brief Select specific events to be filtered on a device
108 * @param[in] device id
109 * @param[in] filter vector of X input events like XI_ButtonPress
111 void SelectEvents( int deviceId, const Dali::Vector< unsigned int >& filter );
114 * @brief checks if the event should be processed
115 * @param[in] deviceEvent device event
116 * @return true if should be processed
118 bool PreProcessEvent( XIDeviceEvent *deviceEvent ) const;
121 * @brief creates a DALi key event given a XIDeviceEvent for a key press
122 * @param[in] deviceEvent device event
123 * @param[out] keyEvent DALi key event
125 void CreateKeyEvent( const XIDeviceEvent* deviceEvent, KeyEvent& keyEvent ) const;
129 Dali::Vector< XInput2Device > mInputDeviceInfo; ///< list of input devices
130 WindowEventInterface* mEventInterface; ///< window event interface
131 Display* mDisplay; ///< X display
132 XID mWindow; ///< X window
133 int mXI2ExtensionId; ///< XI2 extension id
134 bool mMultiTouchSupport:1; ///< whether multi-touch is supported
137 } // namespace Adaptor
138 } // namespace Internal