aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Brown <themagnificentmrb@gmail.com>2018-10-02 16:30:37 +0200
committerGitHub <noreply@github.com>2018-10-02 16:30:37 +0200
commitc2e1b316f5679540f68ea37cba84d1bc2046b71b (patch)
tree5b7b4a041b7f3c855fb8370b2a355e5c5b93c905
parent06531d7be3ef7cf4d4d1d4723a8d892e7c151d12 (diff)
parent31b67fa5488e6ee02222f4bf26be28b7704df25c (diff)
Merge pull request #14502 from garbear/fix-ignore-input18.0b3-Leia
Controller dialog: Fix keyboard and mouse ignored 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.h23
7 files changed, 70 insertions, 6 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 a6571ea686..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>
@@ -43,15 +45,24 @@ 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;
/*!
+ * \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