aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Brown <themagnificentmrb@gmail.com>2018-10-01 08:50:30 +0300
committerGarrett Brown <themagnificentmrb@gmail.com>2018-10-01 12:12:06 +0200
commit31b67fa5488e6ee02222f4bf26be28b7704df25c (patch)
treeba53a319930522c56eb5c807a1f6c2cb101b5d23
parent887846617e43e180f0c604d6794c5114e24a873b (diff)
Controller dialog: Fix ignoring input in sub-dialogs
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp13
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogAxisDetection.h1
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp14
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.h3
-rw-r--r--xbmc/games/controllers/windows/GUIConfigurationWizard.h1
-rw-r--r--xbmc/input/joysticks/generic/ButtonMapping.cpp21
-rw-r--r--xbmc/input/joysticks/interfaces/IButtonMapper.h11
7 files changed, 64 insertions, 0 deletions
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<XBMCKey>(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 <map>
#include <string>
@@ -52,6 +54,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
*
* \param buttonMap The button map being manipulated