From 887846617e43e180f0c604d6794c5114e24a873b Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Mon, 1 Oct 2018 08:39:30 +0300 Subject: [Cosmetic] Fix whitepace in comment --- xbmc/input/joysticks/interfaces/IButtonMapper.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xbmc/input/joysticks/interfaces/IButtonMapper.h b/xbmc/input/joysticks/interfaces/IButtonMapper.h index a6571ea686..1f3826cdd7 100644 --- a/xbmc/input/joysticks/interfaces/IButtonMapper.h +++ b/xbmc/input/joysticks/interfaces/IButtonMapper.h @@ -43,12 +43,12 @@ namespace JOYSTICK virtual std::string ControllerID(void) const = 0; /*! - * \brief Return true if the button mapper wants a cooldown between button - * mapping commands - * - * \return True to only send button mapping commands that occur after a small - * timeout from the previous command. - */ + * \brief Return true if the button mapper wants a cooldown between button + * mapping commands + * + * \return True to only send button mapping commands that occur after a small + * timeout from the previous command. + */ virtual bool NeedsCooldown(void) const = 0; /*! -- cgit v1.2.3 From 31b67fa5488e6ee02222f4bf26be28b7704df25c Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Mon, 1 Oct 2018 08:50:30 +0300 Subject: Controller dialog: Fix ignoring input in sub-dialogs --- .../controllers/dialogs/GUIDialogAxisDetection.cpp | 13 +++++++++++++ .../controllers/dialogs/GUIDialogAxisDetection.h | 1 + .../controllers/dialogs/GUIDialogIgnoreInput.cpp | 14 ++++++++++++++ .../controllers/dialogs/GUIDialogIgnoreInput.h | 3 +++ .../controllers/windows/GUIConfigurationWizard.h | 1 + xbmc/input/joysticks/generic/ButtonMapping.cpp | 21 +++++++++++++++++++++ xbmc/input/joysticks/interfaces/IButtonMapper.h | 11 +++++++++++ 7 files changed, 64 insertions(+) diff --git a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp index c12d7c4d91..0960f0780d 100644 --- a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp +++ b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp @@ -49,6 +49,19 @@ bool CGUIDialogAxisDetection::MapPrimitiveInternal(JOYSTICK::IButtonMap* buttonM return true; } +bool CGUIDialogAxisDetection::AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const +{ + switch (type) + { + case JOYSTICK::PRIMITIVE_TYPE::SEMIAXIS: + return true; + default: + break; + } + + return false; +} + void CGUIDialogAxisDetection::OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) { AddAxis(buttonMap->DeviceName(), axisIndex); diff --git a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.h b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.h index 2f25ab680c..09f30ab3ae 100644 --- a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.h +++ b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.h @@ -26,6 +26,7 @@ namespace GAME virtual ~CGUIDialogAxisDetection() = default; // specialization of IButtonMapper via CGUIDialogButtonCapture + bool AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const override; void OnLateAxis(const JOYSTICK::IButtonMap* buttonMap, unsigned int axisIndex) override; protected: diff --git a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp index 98e14433f2..cbca42dde0 100644 --- a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp +++ b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp @@ -20,6 +20,20 @@ using namespace KODI; using namespace GAME; +bool CGUIDialogIgnoreInput::AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const +{ + switch (type) + { + case JOYSTICK::PRIMITIVE_TYPE::BUTTON: + case JOYSTICK::PRIMITIVE_TYPE::SEMIAXIS: + return true; + default: + break; + } + + return false; +} + std::string CGUIDialogIgnoreInput::GetDialogText() { // "Some controllers have buttons and axes that interfere with mapping. Press diff --git a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.h b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.h index f86c23217a..a13a005795 100644 --- a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.h +++ b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.h @@ -25,6 +25,9 @@ namespace GAME virtual ~CGUIDialogIgnoreInput() = default; + // specialization of IButtonMapper via CGUIDialogButtonCapture + bool AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const override; + protected: // implementation of CGUIDialogButtonCapture virtual std::string GetDialogText() override; diff --git a/xbmc/games/controllers/windows/GUIConfigurationWizard.h b/xbmc/games/controllers/windows/GUIConfigurationWizard.h index a161f98113..d00203b07b 100644 --- a/xbmc/games/controllers/windows/GUIConfigurationWizard.h +++ b/xbmc/games/controllers/windows/GUIConfigurationWizard.h @@ -55,6 +55,7 @@ namespace GAME // implementation of IButtonMapper virtual std::string ControllerID(void) const override { return m_strControllerId; } virtual bool NeedsCooldown(void) const override { return true; } + virtual bool AcceptsPrimitive(JOYSTICK::PRIMITIVE_TYPE type) const override { return true; } virtual bool MapPrimitive(JOYSTICK::IButtonMap* buttonMap, IKeymap* keymap, const JOYSTICK::CDriverPrimitive& primitive) override; diff --git a/xbmc/input/joysticks/generic/ButtonMapping.cpp b/xbmc/input/joysticks/generic/ButtonMapping.cpp index 0675a8632d..58279a527c 100644 --- a/xbmc/input/joysticks/generic/ButtonMapping.cpp +++ b/xbmc/input/joysticks/generic/ButtonMapping.cpp @@ -364,16 +364,25 @@ CButtonMapping::CButtonMapping(IButtonMapper* buttonMapper, IButtonMap* buttonMa bool CButtonMapping::OnButtonMotion(unsigned int buttonIndex, bool bPressed) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::BUTTON)) + return false; + return GetButton(buttonIndex).OnMotion(bPressed); } bool CButtonMapping::OnHatMotion(unsigned int hatIndex, HAT_STATE state) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::HAT)) + return false; + return GetHat(hatIndex).OnMotion(state); } bool CButtonMapping::OnAxisMotion(unsigned int axisIndex, float position, int center, unsigned int range) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::SEMIAXIS)) + return false; + return GetAxis(axisIndex, position).OnMotion(position); } @@ -389,21 +398,33 @@ void CButtonMapping::ProcessAxisMotions(void) bool CButtonMapping::OnKeyPress(const CKey& key) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::KEY)) + return false; + return GetKey(static_cast(key.GetKeycode())).OnMotion(true); } bool CButtonMapping::OnPosition(int x, int y) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::RELATIVE_POINTER)) + return false; + return GetPointer().OnMotion(x, y); } bool CButtonMapping::OnButtonPress(MOUSE::BUTTON_ID button) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::MOUSE_BUTTON)) + return false; + return GetMouseButton(button).OnMotion(true); } void CButtonMapping::OnButtonRelease(MOUSE::BUTTON_ID button) { + if (!m_buttonMapper->AcceptsPrimitive(PRIMITIVE_TYPE::MOUSE_BUTTON)) + return; + GetMouseButton(button).OnMotion(false); } diff --git a/xbmc/input/joysticks/interfaces/IButtonMapper.h b/xbmc/input/joysticks/interfaces/IButtonMapper.h index 1f3826cdd7..f948b364a0 100644 --- a/xbmc/input/joysticks/interfaces/IButtonMapper.h +++ b/xbmc/input/joysticks/interfaces/IButtonMapper.h @@ -8,6 +8,8 @@ #pragma once +#include "input/joysticks/JoystickTypes.h" + #include #include @@ -51,6 +53,15 @@ namespace JOYSTICK */ virtual bool NeedsCooldown(void) const = 0; + /*! + * \brief Return true if the button mapper accepts primitives of the given type + * + * \param type The primitive type + * + * \return True if the button mapper can map the primitive type, false otherwise + */ + virtual bool AcceptsPrimitive(PRIMITIVE_TYPE type) const = 0; + /*! * \brief Handle button/hat press or axis threshold * -- cgit v1.2.3