1 /***************************************************************************
3 * Copyright 2010, 2011 BMW Car IT GmbH
4 * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
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.
20 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
21 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
24 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
25 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
26 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 ****************************************************************************/
29 #ifndef _WAYLANDINPUTDEVICE_H_
30 #define _WAYLANDINPUTDEVICE_H_
31 #include <wayland-server.h>
34 #include "InputManager.h"
36 //////////////////////////////////////////////////////////////////////////////
37 class WaylandInputDevice
41 struct wl_display* m_wlDisplay;
42 struct wl_seat* m_wlSeat;
48 struct wl_surface* m_wlTouchFocus;
49 struct wl_listener m_wlTouchFocusListener;
50 struct wl_resource* m_wlTouchFocusResource;
51 struct wl_listener m_wlTouchFocusResourceListener;
55 struct wl_pointer* wlPointer;
56 struct wl_keyboard* wlKeyboard;
57 struct wl_touch* wlTouch;
62 WaylandInputDevice(wl_display *display);
63 virtual ~WaylandInputDevice();
65 void initPointerDevice();
66 void initKeyboardDevice();
67 void initTouchDevice();
69 struct wl_display* display();
70 struct wl_seat* seat();
71 bool hasPointer() const;
72 bool hasKeyboard() const;
73 bool hasTouch() const;
75 struct wl_pointer *pointerDevice();
76 struct wl_keyboard *keyboardDevice();
77 struct wl_touch *touchDevice();
78 const struct wl_pointer *pointerDevice() const;
79 const struct wl_keyboard *keyboardDevice() const;
80 const struct wl_touch *touchDevice() const;
82 void sendMousePressEvent(const Point& globalPos, const Point& localPos,
83 uint32_t button, uint32_t time);
84 void sendMouseReleaseEvent(const Point& globalPos, const Point& localPos,
85 uint32_t button, uint32_t time);
86 void sendMouseMotionEvent(struct wl_surface *surface,
87 const Point& globalPos, const Point& localPos, uint32_t time);
89 void sendKeyPressEvent(struct wl_surface *surface, uint32_t time, uint32_t code);
90 void sendKeyReleaseEvent(struct wl_surface *surface, uint32_t time, uint32_t code);
91 void setKeyboardFocus(struct wl_surface *surface);
93 void sendTouchPointEvent(struct wl_surface *surface, uint32_t time,
94 int touchId, int touchState, const Point& touchPos);
95 void sendTouchFrameEvent();
96 void sendTouchCancelEvent();
98 void sendModifiers(uint32_t serial);
101 void releaseDevices();
102 void cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev);
104 void setMouseFocus(struct wl_surface *surface,
105 const Point& globalPos,
106 const Point& localPos);
107 void sendMouseMotionEvent(const Point& globalPos,
108 const Point& localPos,
111 void setTouchFocus(struct wl_surface *surface);
113 const static struct wl_seat_interface m_seatInterface;
115 static void bindInputDevice(struct wl_client *client,
119 static void destroyResource(struct wl_resource *resource);
120 static void destroyDeviceResource(struct wl_resource *resource);
122 static void getPointer(struct wl_client *client,
123 struct wl_resource *resource,
125 static void getKeyboard(struct wl_client *client,
126 struct wl_resource *resource,
128 static void getTouch(struct wl_client *client,
129 struct wl_resource *resource,
133 inline struct wl_display* WaylandInputDevice::display()
138 inline struct wl_seat* WaylandInputDevice::seat()
143 inline bool WaylandInputDevice::hasPointer() const
148 inline bool WaylandInputDevice::hasKeyboard() const
150 return m_hasKeyboard;
153 inline bool WaylandInputDevice::hasTouch() const
158 inline struct wl_pointer* WaylandInputDevice::pointerDevice()
160 return m_deviceInterfaces.wlPointer;
163 inline struct wl_keyboard* WaylandInputDevice::keyboardDevice()
165 return m_deviceInterfaces.wlKeyboard;
168 inline struct wl_touch* WaylandInputDevice::touchDevice()
170 return m_deviceInterfaces.wlTouch;
173 inline const struct wl_pointer* WaylandInputDevice::pointerDevice() const
175 return m_deviceInterfaces.wlPointer;
178 inline const struct wl_keyboard* WaylandInputDevice::keyboardDevice() const
180 return m_deviceInterfaces.wlKeyboard;
183 inline const struct wl_touch* WaylandInputDevice::touchDevice() const
185 return m_deviceInterfaces.wlTouch;
188 #endif /* _WAYLANDINPUTDEVICE_H_ */