kodi
LibInputKeyboard.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/Timer.h"
12 #include "windowing/XBMC_events.h"
13 
14 #include <map>
15 #include <memory>
16 #include <vector>
17 
18 #include <libinput.h>
19 #include <xkbcommon/xkbcommon-compose.h>
20 #include <xkbcommon/xkbcommon.h>
21 
23 {
24 public:
26  ~CLibInputKeyboard() = default;
27 
28  void ProcessKey(libinput_event_keyboard *e);
29  void UpdateLeds(libinput_device *dev);
30  void GetRepeat(libinput_device *dev);
31 
32  bool SetKeymap(const std::string& layout);
33 
34 private:
35  XBMCKey XBMCKeyForKeysym(xkb_keysym_t sym, uint32_t scancode);
36  void KeyRepeatTimeout();
41  bool SupportsKeyComposition() const;
48  void NotifyKeyComposingEvent(uint8_t eventType, std::uint16_t unicodeCodepoint);
52  std::uint32_t UnicodeCodepointForKeycode(xkb_keycode_t code) const;
53  struct XkbContextDeleter
54  {
55  void operator()(xkb_context* ctx) const;
56  };
57  std::unique_ptr<xkb_context, XkbContextDeleter> m_ctx;
58 
59  struct XkbKeymapDeleter
60  {
61  void operator()(xkb_keymap* keymap) const;
62  };
63  std::unique_ptr<xkb_keymap, XkbKeymapDeleter> m_keymap;
64 
65  struct XkbStateDeleter
66  {
67  void operator()(xkb_state* state) const;
68  };
69  std::unique_ptr<xkb_state, XkbStateDeleter> m_state;
70 
71  struct XkbComposeTableDeleter
72  {
73  void operator()(xkb_compose_table* composeTable) const;
74  };
75  std::unique_ptr<xkb_compose_table, XkbComposeTableDeleter> m_composeTable;
76 
77  struct XkbComposeStateDeleter
78  {
79  void operator()(xkb_compose_state* state) const;
80  };
81  std::unique_ptr<xkb_compose_state, XkbComposeStateDeleter> m_composedState;
82 
83  xkb_mod_index_t m_modindex[4];
84  xkb_led_index_t m_ledindex[3];
85 
86  int m_leds;
87 
88  XBMC_Event m_repeatEvent;
89  std::map<libinput_device*, std::vector<int>> m_repeatData;
90  CTimer m_repeatTimer;
91  int m_repeatRate;
92 };
Definition: LibInputKeyboard.h:22
Definition: Timer.h:25
Definition: inftrees.h:24
Definition: XBMC_events.h:117