4 * Copyright (C) 2011-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
22 #include <boost/scoped_ptr.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/noncopyable.hpp>
26 #include <wayland-client.h>
28 #include "input/linux/Keymap.h"
30 class IDllWaylandClient;
39 class IKeyboardReceiver
43 virtual ~IKeyboardReceiver() {}
45 virtual void UpdateKeymap(ILinuxKeymap *) = 0;
46 virtual void Enter(uint32_t serial,
47 struct wl_surface *surface,
48 struct wl_array *keys) = 0;
49 virtual void Leave(uint32_t serial,
50 struct wl_surface *surface) = 0;
51 virtual void Key(uint32_t serial,
54 enum wl_keyboard_key_state state) = 0;
55 virtual void Modifier(uint32_t serial,
62 /* Wrapper class for a keyboard object. Generally there is one keyboard
65 * Keyboard events are translated into a more readable form and
66 * forwarded on to the injected IKeyboardReceiver for further
69 * Many of these events require some shared agreement between the
70 * compositor and the client as to the keymap in use. A file descriptor
71 * for a shared memory region to a serialized keymap parsable
72 * with libxkbcommon is provided in HandleKeymap and to the
73 * registered IKeyboardReceiever through UpdateKeymap. The delegate for
74 * that interface should ascertain the intended keymap before processing
78 public boost::noncopyable
82 Keyboard(IDllWaylandClient &,
88 struct wl_keyboard * GetWlKeyboard();
90 static void HandleKeymapCallback(void *,
95 static void HandleEnterCallback(void *,
100 static void HandleLeaveCallback(void *,
101 struct wl_keyboard *,
103 struct wl_surface *);
104 static void HandleKeyCallback(void *,
105 struct wl_keyboard *,
110 static void HandleModifiersCallback(void *,
111 struct wl_keyboard *,
120 void HandleKeymap(uint32_t format,
123 void HandleEnter(uint32_t serial,
124 struct wl_surface *surface,
125 struct wl_array *keys);
126 void HandleLeave(uint32_t serial,
127 struct wl_surface *surface);
128 void HandleKey(uint32_t serial,
132 void HandleModifiers(uint32_t serial,
133 uint32_t mods_depressed,
134 uint32_t mods_latched,
135 uint32_t mods_locked,
138 static const struct wl_keyboard_listener m_listener;
140 IDllWaylandClient &m_clientLibrary;
141 IDllXKBCommon &m_xkbCommonLibrary;
143 /* boost::scoped_ptr does not permit custom deleters
144 * and std::auto_ptr is deprecated, so we are using
145 * boost::shared_ptr instead */
146 boost::shared_ptr<struct xkb_context> m_xkbCommonContext;
147 struct wl_keyboard *m_keyboard;
148 IKeyboardReceiver &m_reciever;
150 /* Keyboard owns the keymap object, but it might inject observing
151 * references elsewhere in order to assist those objects in their
153 boost::scoped_ptr<ILinuxKeymap> m_keymap;