summaryrefslogtreecommitdiffstats
path: root/xbmc/input/WindowKeymap.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/input/WindowKeymap.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/input/WindowKeymap.cpp')
-rw-r--r--xbmc/input/WindowKeymap.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/xbmc/input/WindowKeymap.cpp b/xbmc/input/WindowKeymap.cpp
new file mode 100644
index 0000000..4fd2ae0
--- /dev/null
+++ b/xbmc/input/WindowKeymap.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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 "WindowKeymap.h"
+
+#include "WindowTranslator.h"
+
+using namespace KODI;
+
+CWindowKeymap::CWindowKeymap(const std::string& controllerId) : m_controllerId(controllerId)
+{
+}
+
+void CWindowKeymap::MapAction(int windowId,
+ const std::string& keyName,
+ JOYSTICK::KeymapAction action)
+{
+ auto& actionGroup = m_windowKeymap[windowId][keyName];
+
+ actionGroup.windowId = windowId;
+ auto it = actionGroup.actions.begin();
+ while (it != actionGroup.actions.end())
+ {
+ if (it->holdTimeMs == action.holdTimeMs && it->hotkeys == action.hotkeys)
+ it = actionGroup.actions.erase(it);
+ else
+ it++;
+ }
+ actionGroup.actions.insert(std::move(action));
+}
+
+const JOYSTICK::KeymapActionGroup& CWindowKeymap::GetActions(int windowId,
+ const std::string& keyName) const
+{
+ // handle virtual windows
+ windowId = CWindowTranslator::GetVirtualWindow(windowId);
+
+ auto it = m_windowKeymap.find(windowId);
+ if (it != m_windowKeymap.end())
+ {
+ auto& keymap = it->second;
+ auto it2 = keymap.find(keyName);
+ if (it2 != keymap.end())
+ return it2->second;
+ }
+
+ static const JOYSTICK::KeymapActionGroup empty{};
+ return empty;
+}