blob: a2b431d0866e66aa100c33c331ddb6a2b585364e (
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
|
/*
* Copyright (C) 2017-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.
*/
#include "Keymap.h"
#include "IKeymapEnvironment.h"
using namespace KODI;
CKeymap::CKeymap(std::shared_ptr<const IWindowKeymap> keymap, const IKeymapEnvironment* environment)
: m_keymap(std::move(keymap)), m_environment(environment)
{
}
std::string CKeymap::ControllerID() const
{
return m_keymap->ControllerID();
}
const JOYSTICK::KeymapActionGroup& CKeymap::GetActions(const std::string& keyName) const
{
const int windowId = m_environment->GetWindowID();
const auto& actions = m_keymap->GetActions(windowId, keyName);
if (!actions.actions.empty())
return actions;
const int fallbackWindowId = m_environment->GetFallthrough(windowId);
if (fallbackWindowId >= 0)
{
const auto& fallbackActions = m_keymap->GetActions(fallbackWindowId, keyName);
if (!fallbackActions.actions.empty())
return fallbackActions;
}
if (m_environment->UseGlobalFallthrough())
{
const auto& globalActions = m_keymap->GetActions(-1, keyName);
if (!globalActions.actions.empty())
return globalActions;
}
static const JOYSTICK::KeymapActionGroup empty{};
return empty;
}
|