Debian Codegraph @

xbmc/games/controllers/guicontrols/GUIWheelButton.cpp

raw
1 /*
2 * Copyright (C) 2016-2018 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 "GUIWheelButton.h"
10
11 #include "guilib/LocalizeStrings.h"
12
13 #include <string>
14
15 using namespace KODI;
16 using namespace GAME;
17
18 CGUIWheelButton::CGUIWheelButton(const CGUIButtonControl& buttonTemplate,
19 IConfigurationWizard* wizard,
20 const CPhysicalFeature& feature,
21 unsigned int index)
22 : CGUIFeatureButton(buttonTemplate, wizard, feature, index)
23 {
24 Reset();
25 }
26
27 bool CGUIWheelButton::PromptForInput(CEvent& waitEvent)
28 {
29 using namespace JOYSTICK;
30
31 bool bInterrupted = false;
32
33 // Get the prompt for the current analog stick direction
34 std::string strPrompt;
35 std::string strWarn;
36 switch (m_state)
37 {
38 case STATE::WHEEL_LEFT:
39 strPrompt = g_localizeStrings.Get(35098); // "Move %s left"
40 strWarn = g_localizeStrings.Get(35099); // "Move %s left (%d)"
41 break;
42 case STATE::WHEEL_RIGHT:
43 strPrompt = g_localizeStrings.Get(35096); // "Move %s right"
44 strWarn = g_localizeStrings.Get(35097); // "Move %s right (%d)"
45 break;
46 default:
47 break;
48 }
49
50 if (!strPrompt.empty())
51 {
52 bInterrupted = DoPrompt(strPrompt, strWarn, m_feature.Label(), waitEvent);
53
54 if (!bInterrupted)
55 m_state = STATE::FINISHED; // Not interrupted, must have timed out
56 else
57 m_state = GetNextState(m_state); // Interrupted by input, proceed
58 }
59
60 return bInterrupted;
61 }
62
63 bool CGUIWheelButton::IsFinished(void) const
64 {
65 return m_state >= STATE::FINISHED;
66 }
67
68 JOYSTICK::WHEEL_DIRECTION CGUIWheelButton::GetWheelDirection(void) const
69 {
70 using namespace JOYSTICK;
71
72 switch (m_state)
73 {
74 case STATE::WHEEL_LEFT:
75 return WHEEL_DIRECTION::LEFT;
76 case STATE::WHEEL_RIGHT:
77 return WHEEL_DIRECTION::RIGHT;
78 default:
79 break;
80 }
81
82 return WHEEL_DIRECTION::NONE;
83 }
84
85 void CGUIWheelButton::Reset(void)
86 {
87 m_state = STATE::WHEEL_LEFT;
88 }