| 1 |
/* |
| 2 |
* Copyright (C) 2017-2024 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 |
#include "KeyboardInputHandling.h" |
| 10 |
|
| 11 |
#include "input/joysticks/DriverPrimitive.h" |
| 12 |
#include "input/joysticks/interfaces/IButtonMap.h" |
| 13 |
#include "input/keyboard/XBMC_keysym.h" |
| 14 |
#include "input/keyboard/interfaces/IKeyboardInputHandler.h" |
| 15 |
|
| 16 |
using namespace KODI; |
| 17 |
using namespace KEYBOARD; |
| 18 |
|
| 19 |
CKeyboardInputHandling::CKeyboardInputHandling(IKeyboardInputHandler* handler, |
| 20 |
JOYSTICK::IButtonMap* buttonMap) |
| 21 |
: m_handler(handler), m_buttonMap(buttonMap) |
| 22 |
{ |
| 23 |
} |
| 24 |
|
| 25 |
bool CKeyboardInputHandling::OnKeyPress(const CKey& key) |
| 26 |
{ |
| 27 |
bool bHandled = false; |
| 28 |
|
| 29 |
JOYSTICK::CDriverPrimitive source(static_cast<XBMCKey>(key.GetKeycode())); |
| 30 |
|
| 31 |
KeyName keyName; |
| 32 |
if (m_buttonMap->GetFeature(source, keyName)) |
| 33 |
{ |
| 34 |
const Modifier mod = static_cast<Modifier>(key.GetModifiers() | key.GetLockingModifiers()); |
| 35 |
bHandled = m_handler->OnKeyPress(keyName, mod, key.GetUnicode()); |
| 36 |
} |
| 37 |
|
| 38 |
return bHandled; |
| 39 |
} |
| 40 |
|
| 41 |
void CKeyboardInputHandling::OnKeyRelease(const CKey& key) |
| 42 |
{ |
| 43 |
JOYSTICK::CDriverPrimitive source(static_cast<XBMCKey>(key.GetKeycode())); |
| 44 |
|
| 45 |
KeyName keyName; |
| 46 |
if (m_buttonMap->GetFeature(source, keyName)) |
| 47 |
{ |
| 48 |
const Modifier mod = static_cast<Modifier>(key.GetModifiers() | key.GetLockingModifiers()); |
| 49 |
m_handler->OnKeyRelease(keyName, mod, key.GetUnicode()); |
| 50 |
} |
| 51 |
} |