Debian Codegraph @

xbmc/input/keyboard/KeyboardEasterEgg.cpp

raw
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 "input/keyboard/KeyboardEasterEgg.h"
10
11 #include "input/joysticks/JoystickEasterEgg.h"
12 #include "input/keyboard/Key.h"
13
14 using namespace KODI;
15 using namespace KEYBOARD;
16
17 std::vector<XBMCVKey> CKeyboardEasterEgg::m_sequence = {
18 XBMCVK_UP, XBMCVK_UP, XBMCVK_DOWN, XBMCVK_DOWN, XBMCVK_LEFT,
19 XBMCVK_RIGHT, XBMCVK_LEFT, XBMCVK_RIGHT, XBMCVK_B, XBMCVK_A,
20 };
21
22 bool CKeyboardEasterEgg::OnKeyPress(const CKey& key)
23 {
24 bool bHandled = false;
25
26 // Update state
27 if (key.GetVKey() == m_sequence[m_state])
28 m_state++;
29 else
30 m_state = 0;
31
32 // Capture input when finished with arrows (2 x up/down/left/right)
33 if (m_state > 8)
34 {
35 bHandled = true;
36
37 if (m_state >= m_sequence.size())
38 {
39 JOYSTICK::CJoystickEasterEgg::OnFinish();
40 m_state = 0;
41 }
42 }
43
44 return bHandled;
45 }