[cosmetic] cleanup copyright headers
[vuplus_xbmc] / xbmc / windowing / wayland / KeyboardProcessor.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
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)
10  *  any later version.
11  *
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.
16  *
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/>.
20  *
21  */
22 #include <boost/scoped_ptr.hpp>
23
24 #include "input/linux/Keymap.h"
25 #include "Keyboard.h"
26 #include "TimeoutManager.h"
27
28 class IDllXKBCommon;
29
30 struct wl_array;
31 struct wl_surface;
32 struct xkb_context;
33 enum wl_keyboard_key_state;
34
35 namespace xbmc
36 {
37 class IEventListener;
38
39 /* KeyboardProcessor implements IKeyboardReceiver and transforms
40  * keyboard events into XBMC events for further processing.
41  * 
42  * It needs to know whether or not a surface is in focus, so as soon
43  * as a surface is available, SetXBMCSurface should be called.
44  * 
45  * KeyboardProcessor also performs key-repeat and registers a callback
46  * function to repeat the currently depressed key if it has not been
47  * released within a certain period. As such it depends on
48  * ITimeoutManager */
49 class KeyboardProcessor :
50   public wayland::IKeyboardReceiver
51 {
52 public:
53
54   KeyboardProcessor(IEventListener &listener,
55                     ITimeoutManager &timeouts);
56   ~KeyboardProcessor();
57   
58   void SetXBMCSurface(struct wl_surface *xbmcWindow);
59
60 private:
61
62   void UpdateKeymap(ILinuxKeymap *);
63   void Enter(uint32_t serial,
64              struct wl_surface *surface,
65              struct wl_array *keys);
66   void Leave(uint32_t serial,
67              struct wl_surface *surface);
68   void Key(uint32_t serial,
69            uint32_t time,
70            uint32_t key,
71            enum wl_keyboard_key_state state);
72   void Modifier(uint32_t serial,
73                 uint32_t depressed,
74                 uint32_t latched,
75                 uint32_t locked,
76                 uint32_t group);
77                 
78   void SendKeyToXBMC(uint32_t key,
79                      uint32_t sym,
80                      uint32_t type);
81   void RepeatCallback(uint32_t key,
82                       uint32_t sym);
83
84   IEventListener &m_listener;
85   ITimeoutManager &m_timeouts;
86   struct wl_surface *m_xbmcWindow;
87   
88   ITimeoutManager::CallbackPtr m_repeatCallback;
89   uint32_t m_repeatSym;
90   
91   struct xkb_context *m_context;
92
93   /* KeyboardProcessor has an observing reference to the  keymap and
94    * does parts of its processing by delegating to the keymap the job 
95    * of looking up generic keysyms for keycodes */
96   ILinuxKeymap *m_keymap;
97 };
98 }