xbmc
KeyboardStat.h
1 /*
2  * Copyright (C) 2007-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 //
12 // C++ Interface: CKeyboard
13 //
14 // Description: Adds features like international keyboard layout mapping on top of the
15 // platform specific low level keyboard classes.
16 // Here it must be done only once. Within the other mentioned classes it would have to be done
17 // several times.
18 //
19 // Keyboards always deliver printable characters, logical keys for functional behaviour, modifiers
20 // ... alongside Based on the same hardware with the same scancodes (also alongside) but delivered
21 // with different labels to customers the software must solve the mapping to the real labels. This
22 // is done here. The mapping must be specified by an xml configuration that should be able to access
23 // everything available, but this allows for double/redundant or ambiguous mapping definition, e.g.
24 // ASCII/unicode could be derived from scancodes, virtual keys, modifiers and/or other
25 // ASCII/unicode.
26 
27 #include "input/Key.h"
28 #include "input/XBMC_keyboard.h"
29 
30 #include <chrono>
31 #include <string>
32 
34 {
35 public:
36  CKeyboardStat();
37  ~CKeyboardStat() = default;
38 
39  void Initialize();
40 
41  CKey TranslateKey(XBMC_keysym& keysym) const;
42 
43  void ProcessKeyDown(XBMC_keysym& keysym);
44  void ProcessKeyUp(void);
45 
46  std::string GetKeyName(int KeyID);
47 
48 private:
49  static bool LookupSymAndUnicodePeripherals(XBMC_keysym& keysym, uint8_t* key, char* unicode);
50 
51  XBMC_keysym m_lastKeysym;
52  std::chrono::time_point<std::chrono::steady_clock> m_lastKeyTime;
53 };
Definition: KeyboardStat.h:33
Definition: XBMC_keyboard.h:36
Definition: Key.h:135