summaryrefslogtreecommitdiffstats
path: root/xbmc/input/KeyboardStat.h
blob: 77d59a9b971a464067b47f871b074ab604613b2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 *  Copyright (C) 2007-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

//
// C++ Interface: CKeyboard
//
// Description: Adds features like international keyboard layout mapping on top of the
// platform specific low level keyboard classes.
// Here it must be done only once. Within the other mentioned classes it would have to be done
// several times.
//
// Keyboards always deliver printable characters, logical keys for functional behaviour, modifiers
// ... alongside Based on the same hardware with the same scancodes (also alongside) but delivered
// with different labels to customers the software must solve the mapping to the real labels. This
// is done here. The mapping must be specified by an xml configuration that should be able to access
// everything available, but this allows for double/redundant or ambiguous mapping definition, e.g.
// ASCII/unicode could be derived from scancodes, virtual keys, modifiers and/or other
// ASCII/unicode.

#include "input/Key.h"
#include "input/XBMC_keyboard.h"

#include <chrono>
#include <string>

class CKeyboardStat
{
public:
  CKeyboardStat();
  ~CKeyboardStat() = default;

  void Initialize();

  CKey TranslateKey(XBMC_keysym& keysym) const;

  void ProcessKeyDown(XBMC_keysym& keysym);
  void ProcessKeyUp(void);

  std::string GetKeyName(int KeyID);

private:
  static bool LookupSymAndUnicodePeripherals(XBMC_keysym& keysym, uint8_t* key, char* unicode);

  XBMC_keysym m_lastKeysym;
  std::chrono::time_point<std::chrono::steady_clock> m_lastKeyTime;
};