blob: 3c251215c54af177487e092c5d0ad26f330c5051 (
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
* 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 "JoystickUtils.h"
#include "JoystickTranslator.h"
#include "utils/StringUtils.h"
using namespace KODI;
using namespace JOYSTICK;
std::string CJoystickUtils::MakeKeyName(const FeatureName& feature)
{
return feature;
}
std::string CJoystickUtils::MakeKeyName(const FeatureName& feature, ANALOG_STICK_DIRECTION dir)
{
std::string keyName = feature;
if (dir != ANALOG_STICK_DIRECTION::NONE)
keyName += CJoystickTranslator::TranslateAnalogStickDirection(dir);
return keyName;
}
std::string CJoystickUtils::MakeKeyName(const FeatureName& feature, WHEEL_DIRECTION dir)
{
ANALOG_STICK_DIRECTION stickDir = ANALOG_STICK_DIRECTION::NONE;
switch (dir)
{
case WHEEL_DIRECTION::LEFT:
stickDir = ANALOG_STICK_DIRECTION::LEFT;
break;
case WHEEL_DIRECTION::RIGHT:
stickDir = ANALOG_STICK_DIRECTION::RIGHT;
break;
default:
break;
}
return MakeKeyName(feature, stickDir);
}
std::string CJoystickUtils::MakeKeyName(const FeatureName& feature, THROTTLE_DIRECTION dir)
{
ANALOG_STICK_DIRECTION stickDir = ANALOG_STICK_DIRECTION::NONE;
switch (dir)
{
case THROTTLE_DIRECTION::UP:
stickDir = ANALOG_STICK_DIRECTION::UP;
break;
case THROTTLE_DIRECTION::DOWN:
stickDir = ANALOG_STICK_DIRECTION::DOWN;
break;
default:
break;
}
return MakeKeyName(feature, stickDir);
}
const std::vector<ANALOG_STICK_DIRECTION>& CJoystickUtils::GetAnalogStickDirections()
{
static std::vector<ANALOG_STICK_DIRECTION> directions;
if (directions.empty())
{
directions.push_back(ANALOG_STICK_DIRECTION::UP);
directions.push_back(ANALOG_STICK_DIRECTION::DOWN);
directions.push_back(ANALOG_STICK_DIRECTION::RIGHT);
directions.push_back(ANALOG_STICK_DIRECTION::LEFT);
}
return directions;
}
const std::vector<WHEEL_DIRECTION>& CJoystickUtils::GetWheelDirections()
{
static std::vector<WHEEL_DIRECTION> directions;
if (directions.empty())
{
directions.push_back(WHEEL_DIRECTION::RIGHT);
directions.push_back(WHEEL_DIRECTION::LEFT);
}
return directions;
}
const std::vector<THROTTLE_DIRECTION>& CJoystickUtils::GetThrottleDirections()
{
static std::vector<THROTTLE_DIRECTION> directions;
if (directions.empty())
{
directions.push_back(THROTTLE_DIRECTION::UP);
directions.push_back(THROTTLE_DIRECTION::DOWN);
}
return directions;
}
|