VTB: release CVBuffer after it actually has been rendered
[xbmc.git] / xbmc / input / joysticks / JoystickTranslator.cpp
blobe1f76a9f26f86252cd3387299c33c5c373f7d3b9
1 /*
2 * Copyright (C) 2015-2016 Team Kodi
3 * http://kodi.tv
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this Program; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "JoystickTranslator.h"
23 using namespace JOYSTICK;
25 const char* CJoystickTranslator::HatStateToString(HAT_STATE state)
27 switch (state)
29 case HAT_STATE::UP: return "UP";
30 case HAT_STATE::DOWN: return "DOWN";
31 case HAT_STATE::RIGHT: return "RIGHT";
32 case HAT_STATE::LEFT: return "LEFT";
33 case HAT_STATE::RIGHTUP: return "UP RIGHT";
34 case HAT_STATE::RIGHTDOWN: return "DOWN RIGHT";
35 case HAT_STATE::LEFTUP: return "UP LEFT";
36 case HAT_STATE::LEFTDOWN: return "DOWN LEFT";
37 case HAT_STATE::UNPRESSED:
38 default:
39 break;
42 return "RELEASED";
45 SEMIAXIS_DIRECTION CJoystickTranslator::PositionToSemiAxisDirection(float position)
47 if (position > 0) return SEMIAXIS_DIRECTION::POSITIVE;
48 else if (position < 0) return SEMIAXIS_DIRECTION::NEGATIVE;
50 return SEMIAXIS_DIRECTION::ZERO;
53 ANALOG_STICK_DIRECTION CJoystickTranslator::VectorToAnalogStickDirection(float x, float y)
55 if (y >= x && y > -x) return ANALOG_STICK_DIRECTION::UP;
56 else if (y < x && y >= -x) return ANALOG_STICK_DIRECTION::RIGHT;
57 else if (y <= x && y < -x) return ANALOG_STICK_DIRECTION::DOWN;
58 else if (y > x && y <= -x) return ANALOG_STICK_DIRECTION::LEFT;
60 return ANALOG_STICK_DIRECTION::UNKNOWN;