blob: 69f32a166c0b25a94104ab6b41a451550a87ec58 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Copyright (C) 2016-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 "GUIThrottleButton.h"
#include "guilib/LocalizeStrings.h"
#include <string>
using namespace KODI;
using namespace GAME;
CGUIThrottleButton::CGUIThrottleButton(const CGUIButtonControl& buttonTemplate,
IConfigurationWizard* wizard,
const CPhysicalFeature& feature,
unsigned int index)
: CGUIFeatureButton(buttonTemplate, wizard, feature, index)
{
Reset();
}
bool CGUIThrottleButton::PromptForInput(CEvent& waitEvent)
{
using namespace JOYSTICK;
bool bInterrupted = false;
// Get the prompt for the current analog stick direction
std::string strPrompt;
std::string strWarn;
switch (m_state)
{
case STATE::THROTTLE_UP:
strPrompt = g_localizeStrings.Get(35092); // "Move %s up"
strWarn = g_localizeStrings.Get(35093); // "Move %s up (%d)"
break;
case STATE::THROTTLE_DOWN:
strPrompt = g_localizeStrings.Get(35094); // "Move %s down"
strWarn = g_localizeStrings.Get(35095); // "Move %s down (%d)"
break;
default:
break;
}
if (!strPrompt.empty())
{
bInterrupted = DoPrompt(strPrompt, strWarn, m_feature.Label(), waitEvent);
if (!bInterrupted)
m_state = STATE::FINISHED; // Not interrupted, must have timed out
else
m_state = GetNextState(m_state); // Interrupted by input, proceed
}
return bInterrupted;
}
bool CGUIThrottleButton::IsFinished(void) const
{
return m_state >= STATE::FINISHED;
}
JOYSTICK::THROTTLE_DIRECTION CGUIThrottleButton::GetThrottleDirection(void) const
{
using namespace JOYSTICK;
switch (m_state)
{
case STATE::THROTTLE_UP:
return THROTTLE_DIRECTION::UP;
case STATE::THROTTLE_DOWN:
return THROTTLE_DIRECTION::DOWN;
default:
break;
}
return THROTTLE_DIRECTION::NONE;
}
void CGUIThrottleButton::Reset(void)
{
m_state = STATE::THROTTLE_UP;
}
|