From dc45e1ab286ef3090368353314dd53e3d79571de Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Wed, 14 Feb 2024 12:18:00 -0800 Subject: Revert "[Android][Peripherals] Initialize buttonmap with Android mapping, if possible" This reverts commit 284df1a1394491141ba7c47c7a82af0644b265e3. --- xbmc/peripherals/Peripherals.cpp | 2 +- xbmc/peripherals/addons/AddonButtonMap.cpp | 29 +-- xbmc/peripherals/addons/AddonButtonMap.h | 5 +- xbmc/peripherals/addons/AddonButtonMapping.cpp | 2 +- xbmc/peripherals/addons/AddonInputHandling.cpp | 24 +-- xbmc/peripherals/addons/AddonInputHandling.h | 11 +- xbmc/peripherals/bus/PeripheralBus.h | 17 -- xbmc/peripherals/devices/Peripheral.cpp | 6 +- xbmc/peripherals/devices/PeripheralJoystick.cpp | 3 +- .../android/peripherals/AndroidJoystickState.cpp | 211 --------------------- .../android/peripherals/AndroidJoystickState.h | 30 --- .../peripherals/AndroidJoystickTranslator.cpp | 51 ----- .../peripherals/AndroidJoystickTranslator.h | 9 - .../android/peripherals/PeripheralBusAndroid.cpp | 45 ----- .../android/peripherals/PeripheralBusAndroid.h | 2 - 15 files changed, 19 insertions(+), 428 deletions(-) diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp index 1276cf52d6..e282fbf700 100644 --- a/xbmc/peripherals/Peripherals.cpp +++ b/xbmc/peripherals/Peripherals.cpp @@ -917,7 +917,7 @@ void CPeripherals::ResetButtonMaps(const std::string& controllerId) PeripheralAddonPtr addon; if (addonBus->GetAddonWithButtonMap(peripheral.get(), addon)) { - CAddonButtonMap buttonMap(peripheral.get(), addon, controllerId, *this); + CAddonButtonMap buttonMap(peripheral.get(), addon, controllerId); buttonMap.Reset(); } } diff --git a/xbmc/peripherals/addons/AddonButtonMap.cpp b/xbmc/peripherals/addons/AddonButtonMap.cpp index 0471d293eb..e9764ba81c 100644 --- a/xbmc/peripherals/addons/AddonButtonMap.cpp +++ b/xbmc/peripherals/addons/AddonButtonMap.cpp @@ -10,7 +10,6 @@ #include "PeripheralAddonTranslator.h" #include "input/joysticks/JoystickUtils.h" -#include "peripherals/Peripherals.h" #include "peripherals/devices/Peripheral.h" #include "utils/log.h" @@ -25,9 +24,8 @@ using namespace PERIPHERALS; CAddonButtonMap::CAddonButtonMap(CPeripheral* device, const std::weak_ptr& addon, - const std::string& strControllerId, - CPeripherals& manager) - : m_device(device), m_addon(addon), m_strControllerId(strControllerId), m_manager(manager) + const std::string& strControllerId) + : m_device(device), m_addon(addon), m_strControllerId(strControllerId) { auto peripheralAddon = m_addon.lock(); assert(peripheralAddon != nullptr); @@ -61,29 +59,6 @@ bool CAddonButtonMap::Load(void) bSuccess |= addon->GetIgnoredPrimitives(m_device, ignoredPrimitives); } - if (features.empty()) - { - // Check if we can initialize a buttonmap from the peripheral bus - PeripheralBusPtr peripheralBus = m_manager.GetBusByType(m_device->GetBusType()); - if (peripheralBus) - { - CLog::Log(LOGDEBUG, - "Buttonmap not found for {}, attempting to initialize from peripheral bus", - m_device->Location()); - if (peripheralBus->InitializeButtonMap(*m_device, *this)) - { - bSuccess = true; - - if (auto addon = m_addon.lock()) - { - addon->GetAppearance(m_device, controllerAppearance); - addon->GetFeatures(m_device, m_strControllerId, features); - addon->GetIgnoredPrimitives(m_device, ignoredPrimitives); - } - } - } - } - // GetFeatures() was changed to always return false if no features were // retrieved. Check here, just in case its contract is changed or violated in // the future. diff --git a/xbmc/peripherals/addons/AddonButtonMap.h b/xbmc/peripherals/addons/AddonButtonMap.h index 7bbc91947f..b4b6463fee 100644 --- a/xbmc/peripherals/addons/AddonButtonMap.h +++ b/xbmc/peripherals/addons/AddonButtonMap.h @@ -18,7 +18,6 @@ namespace PERIPHERALS { class CPeripheral; -class CPeripherals; /*! * \ingroup peripherals @@ -28,8 +27,7 @@ class CAddonButtonMap : public KODI::JOYSTICK::IButtonMap public: CAddonButtonMap(CPeripheral* device, const std::weak_ptr& addon, - const std::string& strControllerId, - CPeripherals& manager); + const std::string& strControllerId); ~CAddonButtonMap(void) override; @@ -135,7 +133,6 @@ private: CPeripheral* const m_device; const std::weak_ptr m_addon; const std::string m_strControllerId; - CPeripherals& m_manager; // Button map state std::string m_controllerAppearance; diff --git a/xbmc/peripherals/addons/AddonButtonMapping.cpp b/xbmc/peripherals/addons/AddonButtonMapping.cpp index 0da424ab27..3be55df3f6 100644 --- a/xbmc/peripherals/addons/AddonButtonMapping.cpp +++ b/xbmc/peripherals/addons/AddonButtonMapping.cpp @@ -33,7 +33,7 @@ CAddonButtonMapping::CAddonButtonMapping(CPeripherals& manager, else { const std::string controllerId = mapper->ControllerID(); - m_buttonMap = std::make_unique(peripheral, addon, controllerId, manager); + m_buttonMap = std::make_unique(peripheral, addon, controllerId); if (m_buttonMap->Load()) { KEYMAP::IKeymap* keymap = peripheral->GetKeymap(controllerId); diff --git a/xbmc/peripherals/addons/AddonInputHandling.cpp b/xbmc/peripherals/addons/AddonInputHandling.cpp index 4643e84e3f..088d01a2f1 100644 --- a/xbmc/peripherals/addons/AddonInputHandling.cpp +++ b/xbmc/peripherals/addons/AddonInputHandling.cpp @@ -24,38 +24,28 @@ using namespace KODI; using namespace JOYSTICK; using namespace PERIPHERALS; -CAddonInputHandling::CAddonInputHandling(CPeripherals& manager, - CPeripheral* peripheral, +CAddonInputHandling::CAddonInputHandling(CPeripheral* peripheral, std::shared_ptr addon, IInputHandler* handler, IDriverReceiver* receiver) - : m_manager(manager), - m_peripheral(peripheral), + : m_peripheral(peripheral), m_addon(std::move(addon)), m_joystickInputHandler(handler), m_joystickDriverReceiver(receiver) { } -CAddonInputHandling::CAddonInputHandling(CPeripherals& manager, - CPeripheral* peripheral, +CAddonInputHandling::CAddonInputHandling(CPeripheral* peripheral, std::shared_ptr addon, KEYBOARD::IKeyboardInputHandler* handler) - : m_manager(manager), - m_peripheral(peripheral), - m_addon(std::move(addon)), - m_keyboardInputHandler(handler) + : m_peripheral(peripheral), m_addon(std::move(addon)), m_keyboardInputHandler(handler) { } -CAddonInputHandling::CAddonInputHandling(CPeripherals& manager, - CPeripheral* peripheral, +CAddonInputHandling::CAddonInputHandling(CPeripheral* peripheral, std::shared_ptr addon, MOUSE::IMouseInputHandler* handler) - : m_manager(manager), - m_peripheral(peripheral), - m_addon(std::move(addon)), - m_mouseInputHandler(handler) + : m_peripheral(peripheral), m_addon(std::move(addon)), m_mouseInputHandler(handler) { } @@ -79,7 +69,7 @@ bool CAddonInputHandling::Load() controllerId = m_mouseInputHandler->ControllerID(); if (!controllerId.empty()) - m_buttonMap = std::make_unique(m_peripheral, m_addon, controllerId, m_manager); + m_buttonMap = std::make_unique(m_peripheral, m_addon, controllerId); if (m_buttonMap && m_buttonMap->Load()) { diff --git a/xbmc/peripherals/addons/AddonInputHandling.h b/xbmc/peripherals/addons/AddonInputHandling.h index 19816a6ca5..e5c98e3748 100644 --- a/xbmc/peripherals/addons/AddonInputHandling.h +++ b/xbmc/peripherals/addons/AddonInputHandling.h @@ -38,7 +38,6 @@ class IMouseInputHandler; namespace PERIPHERALS { class CPeripheral; -class CPeripherals; class CPeripheralAddon; /*! @@ -50,19 +49,16 @@ class CAddonInputHandling : public KODI::JOYSTICK::IDriverHandler, public KODI::MOUSE::IMouseDriverHandler { public: - CAddonInputHandling(CPeripherals& manager, - CPeripheral* peripheral, + CAddonInputHandling(CPeripheral* peripheral, std::shared_ptr addon, KODI::JOYSTICK::IInputHandler* handler, KODI::JOYSTICK::IDriverReceiver* receiver); - CAddonInputHandling(CPeripherals& manager, - CPeripheral* peripheral, + CAddonInputHandling(CPeripheral* peripheral, std::shared_ptr addon, KODI::KEYBOARD::IKeyboardInputHandler* handler); - CAddonInputHandling(CPeripherals& manager, - CPeripheral* peripheral, + CAddonInputHandling(CPeripheral* peripheral, std::shared_ptr addon, KODI::MOUSE::IMouseInputHandler* handler); @@ -93,7 +89,6 @@ public: private: // Construction parameters - CPeripherals& m_manager; CPeripheral* const m_peripheral; const std::shared_ptr m_addon; KODI::JOYSTICK::IInputHandler* const m_joystickInputHandler{nullptr}; diff --git a/xbmc/peripherals/bus/PeripheralBus.h b/xbmc/peripherals/bus/PeripheralBus.h index 33594a0faa..424d012d9f 100644 --- a/xbmc/peripherals/bus/PeripheralBus.h +++ b/xbmc/peripherals/bus/PeripheralBus.h @@ -17,14 +17,6 @@ class CFileItemList; -namespace KODI -{ -namespace JOYSTICK -{ -class IButtonMap; -} // namespace JOYSTICK -} // namespace KODI - namespace PERIPHERALS { class CPeripheral; @@ -67,15 +59,6 @@ public: */ virtual bool InitializeProperties(CPeripheral& peripheral); - /*! - * \brief Initialize a joystick buttonmap, if possible - */ - virtual bool InitializeButtonMap(const CPeripheral& peripheral, - KODI::JOYSTICK::IButtonMap& buttonMap) const - { - return false; - } - /*! * @brief Get the instance of the peripheral at the given location. * @param strLocation The location. diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp index bb00d516a3..ff9910c2ef 100644 --- a/xbmc/peripherals/devices/Peripheral.cpp +++ b/xbmc/peripherals/devices/Peripheral.cpp @@ -597,7 +597,7 @@ void CPeripheral::RegisterInputHandler(IInputHandler* handler, bool bPromiscuous if (addon) { std::unique_ptr addonInput = std::make_unique( - m_manager, this, std::move(addon), handler, GetDriverReceiver()); + this, std::move(addon), handler, GetDriverReceiver()); if (addonInput->Load()) { RegisterJoystickDriverHandler(addonInput.get(), bPromiscuous); @@ -638,7 +638,7 @@ void CPeripheral::RegisterKeyboardHandler(KEYBOARD::IKeyboardInputHandler* handl if (addon) { std::unique_ptr addonInput = - std::make_unique(m_manager, this, std::move(addon), handler); + std::make_unique(this, std::move(addon), handler); if (addonInput->Load()) keyboardDriverHandler = std::move(addonInput); } @@ -689,7 +689,7 @@ void CPeripheral::RegisterMouseHandler(MOUSE::IMouseInputHandler* handler, if (addon) { std::unique_ptr addonInput = - std::make_unique(m_manager, this, std::move(addon), handler); + std::make_unique(this, std::move(addon), handler); if (addonInput->Load()) mouseDriverHandler = std::move(addonInput); } diff --git a/xbmc/peripherals/devices/PeripheralJoystick.cpp b/xbmc/peripherals/devices/PeripheralJoystick.cpp index c5285c245e..a6029561d6 100644 --- a/xbmc/peripherals/devices/PeripheralJoystick.cpp +++ b/xbmc/peripherals/devices/PeripheralJoystick.cpp @@ -92,8 +92,7 @@ bool CPeripheralJoystick::InitialiseFeature(const PeripheralFeature feature) if (bSuccess) { - m_buttonMap = - std::make_unique(this, addon, DEFAULT_CONTROLLER_ID, m_manager); + m_buttonMap = std::make_unique(this, addon, DEFAULT_CONTROLLER_ID); if (m_buttonMap->Load()) { InitializeDeadzoneFiltering(*m_buttonMap); diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp index dcbd569c53..90409e65c0 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp @@ -9,11 +9,6 @@ #include "AndroidJoystickState.h" #include "AndroidJoystickTranslator.h" -#include "games/controllers/ControllerIDs.h" -#include "games/controllers/DefaultController.h" -#include "input/joysticks/DriverPrimitive.h" -#include "input/joysticks/JoystickTypes.h" -#include "input/joysticks/interfaces/IButtonMap.h" #include "utils/StringUtils.h" #include "utils/log.h" @@ -24,13 +19,10 @@ #include #include -using namespace KODI; using namespace PERIPHERALS; namespace { -// Used to set the appearance of PlayStation controllers -constexpr const char* CONTROLLER_ID_PLAYSTATION = "game.controller.ps.dualanalog"; // clang-format off static const std::vector ButtonKeycodes{ @@ -258,70 +250,6 @@ void CAndroidJoystickState::Deinitialize(void) m_digitalEvents.clear(); } -bool CAndroidJoystickState::InitializeButtonMap(KODI::JOYSTICK::IButtonMap& buttonMap) const -{ - // We only map the default controller - if (buttonMap.ControllerID() != DEFAULT_CONTROLLER_ID) - return false; - - bool success = false; - - // Map buttons - for (auto it = ButtonKeycodes.begin(); it != ButtonKeycodes.end(); ++it) - { - const int buttonKeycode = *it; - success |= MapButton(buttonMap, buttonKeycode); - } - - // Map D-pad - success |= MapDpad(buttonMap, AMOTION_EVENT_AXIS_HAT_X, AMOTION_EVENT_AXIS_HAT_Y); - - // Map triggers - // Note: This should come after buttons, because the PS4 controller uses - // both a digital button and an analog axis for the triggers, and we want - // the analog axis to override the button for full range of motion. - success |= MapTrigger(buttonMap, AMOTION_EVENT_AXIS_LTRIGGER, - GAME::CDefaultController::FEATURE_LEFT_TRIGGER); - success |= MapTrigger(buttonMap, AMOTION_EVENT_AXIS_RTRIGGER, - GAME::CDefaultController::FEATURE_RIGHT_TRIGGER); - - // Map analog sticks - success |= MapAnalogStick(buttonMap, AMOTION_EVENT_AXIS_X, AMOTION_EVENT_AXIS_Y, - GAME::CDefaultController::FEATURE_LEFT_STICK); - success |= MapAnalogStick(buttonMap, AMOTION_EVENT_AXIS_Z, AMOTION_EVENT_AXIS_RZ, - GAME::CDefaultController::FEATURE_RIGHT_STICK); - - if (success) - { - // If the controller has both L2/R2 buttons and LTRIGGER/RTRIGGER axes, it's - // probably a PS controller - size_t indexL2 = 0; - size_t indexR2 = 0; - size_t indexLTrigger = 0; - size_t indexRTrigger = 0; - if (GetAxesIndex({AKEYCODE_BUTTON_L2}, m_buttons, indexL2) && - GetAxesIndex({AKEYCODE_BUTTON_R2}, m_buttons, indexR2) && - GetAxesIndex({AMOTION_EVENT_AXIS_LTRIGGER}, m_axes, indexLTrigger) && - GetAxesIndex({AMOTION_EVENT_AXIS_RTRIGGER}, m_axes, indexRTrigger)) - { - CLog::Log(LOGDEBUG, "Detected dual-input triggers, ignoring digital buttons"); - std::vector ignoredPrimitives{ - {JOYSTICK::PRIMITIVE_TYPE::BUTTON, static_cast(indexL2)}, - {JOYSTICK::PRIMITIVE_TYPE::BUTTON, static_cast(indexR2)}, - }; - buttonMap.SetIgnoredPrimitives(ignoredPrimitives); - - CLog::Log(LOGDEBUG, "Setting appearance to {}", CONTROLLER_ID_PLAYSTATION); - buttonMap.SetAppearance(CONTROLLER_ID_PLAYSTATION); - } - - // Save the buttonmap - buttonMap.SaveButtonMap(); - } - - return success; -} - bool CAndroidJoystickState::ProcessEvent(const AInputEvent* event) { int32_t type = AInputEvent_getType(event); @@ -474,145 +402,6 @@ bool CAndroidJoystickState::SetAxisValue(const std::vector& axisIds, return true; } -bool CAndroidJoystickState::MapButton(KODI::JOYSTICK::IButtonMap& buttonMap, - int buttonKeycode) const -{ - size_t buttonIndex = 0; - std::string featureName; - - if (!GetAxesIndex({buttonKeycode}, m_buttons, buttonIndex)) - return false; - - // Check if button is already mapped - JOYSTICK::CDriverPrimitive buttonPrimitive{JOYSTICK::PRIMITIVE_TYPE::BUTTON, - static_cast(buttonIndex)}; - if (buttonMap.GetFeature(buttonPrimitive, featureName)) - return false; - - // Translate the button - std::string controllerButton = CAndroidJoystickTranslator::TranslateJoystickButton(buttonKeycode); - if (controllerButton.empty()) - return false; - - // Map the button - CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", controllerButton, - buttonPrimitive.ToString()); - buttonMap.AddScalar(controllerButton, buttonPrimitive); - - return true; -} - -bool CAndroidJoystickState::MapTrigger(KODI::JOYSTICK::IButtonMap& buttonMap, - int axisId, - const std::string& triggerName) const -{ - size_t axisIndex = 0; - std::string featureName; - - if (!GetAxesIndex({axisId}, m_axes, axisIndex)) - return false; - - const JOYSTICK::CDriverPrimitive semiaxis{static_cast(axisIndex), 0, - JOYSTICK::SEMIAXIS_DIRECTION::POSITIVE, 1}; - if (buttonMap.GetFeature(semiaxis, featureName)) - return false; - - CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", triggerName, semiaxis.ToString()); - buttonMap.AddScalar(triggerName, semiaxis); - - return true; -} - -bool CAndroidJoystickState::MapDpad(KODI::JOYSTICK::IButtonMap& buttonMap, - int horizAxisId, - int vertAxisId) const -{ - bool success = false; - - size_t axisIndex = 0; - std::string featureName; - - // Map horizontal axis - if (GetAxesIndex({horizAxisId}, m_axes, axisIndex)) - { - const JOYSTICK::CDriverPrimitive positiveSemiaxis{static_cast(axisIndex), 0, - JOYSTICK::SEMIAXIS_DIRECTION::POSITIVE, 1}; - const JOYSTICK::CDriverPrimitive negativeSemiaxis{static_cast(axisIndex), 0, - JOYSTICK::SEMIAXIS_DIRECTION::NEGATIVE, 1}; - if (!buttonMap.GetFeature(positiveSemiaxis, featureName) && - !buttonMap.GetFeature(negativeSemiaxis, featureName)) - { - CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", GAME::CDefaultController::FEATURE_LEFT, - negativeSemiaxis.ToString()); - CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", GAME::CDefaultController::FEATURE_RIGHT, - positiveSemiaxis.ToString()); - buttonMap.AddScalar(GAME::CDefaultController::FEATURE_LEFT, negativeSemiaxis); - buttonMap.AddScalar(GAME::CDefaultController::FEATURE_RIGHT, positiveSemiaxis); - success |= true; - } - } - - // Map vertical axis - if (GetAxesIndex({vertAxisId}, m_axes, axisIndex)) - { - const JOYSTICK::CDriverPrimitive positiveSemiaxis{static_cast(axisIndex), 0, - JOYSTICK::SEMIAXIS_DIRECTION::POSITIVE, 1}; - const JOYSTICK::CDriverPrimitive negativeSemiaxis{static_cast(axisIndex), 0, - JOYSTICK::SEMIAXIS_DIRECTION::NEGATIVE, 1}; - if (!buttonMap.GetFeature(positiveSemiaxis, featureName) && - !buttonMap.GetFeature(negativeSemiaxis, featureName)) - { - CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", GAME::CDefaultController::FEATURE_UP, - negativeSemiaxis.ToString()); - CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", GAME::CDefaultController::FEATURE_DOWN, - positiveSemiaxis.ToString()); - buttonMap.AddScalar(GAME::CDefaultController::FEATURE_DOWN, positiveSemiaxis); - buttonMap.AddScalar(GAME::CDefaultController::FEATURE_UP, negativeSemiaxis); - success |= true; - } - } - - return success; -} - -bool CAndroidJoystickState::MapAnalogStick(KODI::JOYSTICK::IButtonMap& buttonMap, - int horizAxisId, - int vertAxisId, - const std::string& analogStickName) const -{ - size_t axisIndex1 = 0; - size_t axisIndex2 = 0; - std::string featureName; - - if (!GetAxesIndex({horizAxisId}, m_axes, axisIndex1) || - !GetAxesIndex({vertAxisId}, m_axes, axisIndex2)) - return false; - - const JOYSTICK::CDriverPrimitive upSemiaxis{static_cast(axisIndex2), 0, - JOYSTICK::SEMIAXIS_DIRECTION::NEGATIVE, 1}; - const JOYSTICK::CDriverPrimitive downSemiaxis{static_cast(axisIndex2), 0, - JOYSTICK::SEMIAXIS_DIRECTION::POSITIVE, 1}; - const JOYSTICK::CDriverPrimitive leftSemiaxis{static_cast(axisIndex1), 0, - JOYSTICK::SEMIAXIS_DIRECTION::NEGATIVE, 1}; - const JOYSTICK::CDriverPrimitive rightSemiaxis{static_cast(axisIndex1), 0, - JOYSTICK::SEMIAXIS_DIRECTION::POSITIVE, 1}; - if (buttonMap.GetFeature(upSemiaxis, featureName) || - buttonMap.GetFeature(downSemiaxis, featureName) || - buttonMap.GetFeature(leftSemiaxis, featureName) || - buttonMap.GetFeature(rightSemiaxis, featureName)) - return false; - - CLog::Log(LOGDEBUG, "Automatically mapping {} to [{}, {}, {}, {}]", analogStickName, - upSemiaxis.ToString(), downSemiaxis.ToString(), leftSemiaxis.ToString(), - rightSemiaxis.ToString()); - buttonMap.AddAnalogStick(analogStickName, JOYSTICK::ANALOG_STICK_DIRECTION::UP, upSemiaxis); - buttonMap.AddAnalogStick(analogStickName, JOYSTICK::ANALOG_STICK_DIRECTION::DOWN, downSemiaxis); - buttonMap.AddAnalogStick(analogStickName, JOYSTICK::ANALOG_STICK_DIRECTION::LEFT, leftSemiaxis); - buttonMap.AddAnalogStick(analogStickName, JOYSTICK::ANALOG_STICK_DIRECTION::RIGHT, rightSemiaxis); - - return true; -} - float CAndroidJoystickState::Contain(float value, float min, float max) { if (value < min) diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.h b/xbmc/platform/android/peripherals/AndroidJoystickState.h index 550222d6f7..e146193541 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.h +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.h @@ -18,14 +18,6 @@ struct AInputEvent; class CJNIViewInputDevice; -namespace KODI -{ -namespace JOYSTICK -{ -class IButtonMap; -} // namespace JOYSTICK -} // namespace KODI - namespace PERIPHERALS { class CAndroidJoystickState @@ -47,18 +39,6 @@ public: */ bool Initialize(const CJNIViewInputDevice& inputDevice); - /*! - * \brief Initialize a joystick buttonmap, if possible - * - * Android has a large database of buttonmaps, which it uses to provide - * mapped button keycodes such as AKEYCODE_BUTTON_A. We can take advantage of - * this to initialize a default buttonmap based on these mappings. - * - * If Android can't map the buttons, it will use generic button keycodes such - * as AKEYCODE_BUTTON_1, in which case we can't initialize the buttonmap. - */ - bool InitializeButtonMap(KODI::JOYSTICK::IButtonMap& buttonMap) const; - /*! * \brief Deinitialize the joystick object * @@ -83,16 +63,6 @@ private: void GetButtonEvents(std::vector& events); void GetAxisEvents(std::vector& events) const; - bool MapButton(KODI::JOYSTICK::IButtonMap& buttonMap, int buttonKeycode) const; - bool MapTrigger(KODI::JOYSTICK::IButtonMap& buttonMap, - int axisId, - const std::string& triggerName) const; - bool MapDpad(KODI::JOYSTICK::IButtonMap& buttonMap, int horizAxisId, int vertAxisId) const; - bool MapAnalogStick(KODI::JOYSTICK::IButtonMap& buttonMap, - int horizAxisId, - int vertAxisId, - const std::string& analogStickName) const; - static float Contain(float value, float min, float max); static float Scale(float value, float max, float scaledMax); static float Deadzone(float value, float deadzone); diff --git a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp index e39050a0c4..a665f45a9c 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp @@ -8,12 +8,9 @@ #include "AndroidJoystickTranslator.h" -#include "games/controllers/DefaultController.h" - #include #include -using namespace KODI; using namespace PERIPHERALS; const char* CAndroidJoystickTranslator::TranslateAxis(int axisId) @@ -697,51 +694,3 @@ const char* CAndroidJoystickTranslator::TranslateKeyCode(int keyCode) return "unknown"; } - -const char* CAndroidJoystickTranslator::TranslateJoystickButton(int buttonKeycode) -{ - switch (buttonKeycode) - { - case AKEYCODE_BUTTON_A: - return GAME::CDefaultController::FEATURE_A; - case AKEYCODE_BUTTON_B: - return GAME::CDefaultController::FEATURE_B; - case AKEYCODE_BUTTON_X: - return GAME::CDefaultController::FEATURE_X; - case AKEYCODE_BUTTON_Y: - return GAME::CDefaultController::FEATURE_Y; - case AKEYCODE_BUTTON_START: - case AKEYCODE_MENU: - return GAME::CDefaultController::FEATURE_START; - case AKEYCODE_BUTTON_SELECT: - case AKEYCODE_BACK: - return GAME::CDefaultController::FEATURE_BACK; - case AKEYCODE_BUTTON_MODE: - case AKEYCODE_HOME: - return GAME::CDefaultController::FEATURE_GUIDE; - case AKEYCODE_DPAD_UP: - return GAME::CDefaultController::FEATURE_UP; - case AKEYCODE_DPAD_RIGHT: - return GAME::CDefaultController::FEATURE_RIGHT; - case AKEYCODE_DPAD_DOWN: - return GAME::CDefaultController::FEATURE_DOWN; - case AKEYCODE_DPAD_LEFT: - return GAME::CDefaultController::FEATURE_LEFT; - case AKEYCODE_BUTTON_L1: - return GAME::CDefaultController::FEATURE_LEFT_BUMPER; - case AKEYCODE_BUTTON_R1: - return GAME::CDefaultController::FEATURE_RIGHT_BUMPER; - case AKEYCODE_BUTTON_L2: - return GAME::CDefaultController::FEATURE_LEFT_TRIGGER; - case AKEYCODE_BUTTON_R2: - return GAME::CDefaultController::FEATURE_RIGHT_TRIGGER; - case AKEYCODE_BUTTON_THUMBL: - return GAME::CDefaultController::FEATURE_LEFT_THUMB; - case AKEYCODE_BUTTON_THUMBR: - return GAME::CDefaultController::FEATURE_RIGHT_THUMB; - default: - break; - } - - return ""; -} diff --git a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h index 8681de0c12..a5bb8e33d5 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h +++ b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h @@ -30,14 +30,5 @@ public: * \return The translated enum label, or "unknown" if unknown */ static const char* TranslateKeyCode(int keyCode); - - /*! - * \brief Translate a button key code to a feature on the default controller - * - * \param buttonKeycode The key code given in - * - * \return The translated feature, or "" if unknown - */ - static const char* TranslateJoystickButton(int buttonKeycode); }; } // namespace PERIPHERALS diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp index 3f269472ec..eed225d755 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp @@ -16,7 +16,6 @@ #include "utils/log.h" #include "platform/android/activity/XBMCApp.h" -#include "platform/android/peripherals/AndroidJoystickState.h" #include #include @@ -121,50 +120,6 @@ bool CPeripheralBusAndroid::InitializeProperties(CPeripheral& peripheral) return true; } -bool CPeripheralBusAndroid::InitializeButtonMap(const CPeripheral& peripheral, - KODI::JOYSTICK::IButtonMap& buttonMap) const -{ - int deviceId; - if (!GetDeviceId(peripheral.Location(), deviceId)) - { - CLog::Log(LOGWARNING, - "CPeripheralBusAndroid: failed to initialize buttonmap due to unknown device ID for " - "peripheral \"{}\"", - peripheral.Location()); - return false; - } - - // get the joystick state - auto it = m_joystickStates.find(deviceId); - if (it == m_joystickStates.end()) - { - CLog::Log(LOGWARNING, - "CPeripheralBusAndroid: joystick with device ID {} not found for peripheral \"{}\"", - deviceId, peripheral.Location()); - return false; - } - - const CAndroidJoystickState& joystick = it->second; - if (joystick.GetButtonCount() == 0 && joystick.GetAxisCount() == 0) - { - CLog::Log(LOGDEBUG, - "CPeripheralBusAndroid: joystick has no buttons or axes for peripheral \"{}\"", - peripheral.Location()); - return false; - } - - if (!joystick.InitializeButtonMap(buttonMap)) - { - CLog::Log( - LOGDEBUG, - "CPeripheralBusAndroid: failed to initialize joystick buttonmap for peripheral \"{}\"", - peripheral.Location()); - return false; - } - - return true; -} - void CPeripheralBusAndroid::Initialise(void) { CPeripheralBus::Initialise(); diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.h b/xbmc/platform/android/peripherals/PeripheralBusAndroid.h index 5ee9480970..c3c42aa730 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.h +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.h @@ -35,8 +35,6 @@ public: // specialisation of CPeripheralBus bool InitializeProperties(CPeripheral& peripheral) override; - bool InitializeButtonMap(const CPeripheral& peripheral, - KODI::JOYSTICK::IButtonMap& buttonMap) const override; void Initialise(void) override; void ProcessEvents() override; -- cgit v1.2.3