aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Brown <themagnificentmrb@gmail.com>2018-01-15 15:47:10 -0800
committerGitHub <noreply@github.com>2018-01-15 15:47:10 -0800
commit86814f632a95ab2522d95b3ccfd7b433a2a26bc3 (patch)
tree1ec9629e5e696a987862f4a491876e11b22e823f
parenta4d5cafaff96ae2b68bddd057738dca30c62f758 (diff)
parent046df869d5e206d3795246bfde398824c1fcbdaa (diff)
Merge pull request #13354 from garbear/input-improvements
Input fixes and modernization
-rw-r--r--xbmc/games/addons/input/GameClientJoystick.cpp2
-rw-r--r--xbmc/games/addons/input/GameClientJoystick.h2
-rw-r--r--xbmc/games/addons/input/GameClientKeyboard.cpp2
-rw-r--r--xbmc/games/addons/input/GameClientKeyboard.h2
-rw-r--r--xbmc/games/addons/input/GameClientMouse.cpp2
-rw-r--r--xbmc/games/addons/input/GameClientMouse.h2
-rw-r--r--xbmc/games/controllers/CMakeLists.txt1
-rw-r--r--xbmc/games/controllers/ControllerDefinitions.h1
-rw-r--r--xbmc/games/controllers/ControllerFeature.cpp18
-rw-r--r--xbmc/games/controllers/ControllerFeature.h28
-rw-r--r--xbmc/games/controllers/ControllerIDs.h24
-rw-r--r--xbmc/games/controllers/ControllerManager.cpp2
-rw-r--r--xbmc/games/controllers/ControllerTranslator.cpp2
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp2
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogButtonCapture.cpp6
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogButtonCapture.h2
-rw-r--r--xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp4
-rw-r--r--xbmc/games/controllers/guicontrols/GUIFeatureControls.cpp8
-rw-r--r--xbmc/games/controllers/guicontrols/GUIFeatureControls.h4
-rw-r--r--xbmc/games/controllers/windows/GUIConfigurationWizard.cpp123
-rw-r--r--xbmc/games/controllers/windows/GUIConfigurationWizard.h11
-rw-r--r--xbmc/games/controllers/windows/GUIControllerList.cpp2
-rw-r--r--xbmc/games/controllers/windows/GUIControllerWindow.cpp8
-rw-r--r--xbmc/games/controllers/windows/GUIFeatureList.cpp41
-rw-r--r--xbmc/games/controllers/windows/GUIFeatureList.h7
-rw-r--r--xbmc/games/controllers/windows/IConfigurationWindow.h19
-rw-r--r--xbmc/games/ports/InputSink.cpp2
-rw-r--r--xbmc/games/ports/InputSink.h2
-rw-r--r--xbmc/games/ports/Port.h2
-rw-r--r--xbmc/games/ports/PortManager.cpp2
-rw-r--r--xbmc/input/ButtonTranslator.cpp5
-rw-r--r--xbmc/input/InputManager.cpp12
-rw-r--r--xbmc/input/InputManager.h4
-rw-r--r--xbmc/input/Key.cpp5
-rw-r--r--xbmc/input/Key.h9
-rw-r--r--xbmc/input/KeyboardStat.cpp14
-rw-r--r--xbmc/input/joysticks/CMakeLists.txt20
-rw-r--r--xbmc/input/joysticks/DeadzoneFilter.cpp3
-rw-r--r--xbmc/input/joysticks/DriverPrimitive.cpp51
-rw-r--r--xbmc/input/joysticks/DriverPrimitive.h20
-rw-r--r--xbmc/input/joysticks/JoystickEasterEgg.cpp2
-rw-r--r--xbmc/input/joysticks/JoystickEasterEgg.h2
-rw-r--r--xbmc/input/joysticks/JoystickIDs.h3
-rw-r--r--xbmc/input/joysticks/JoystickMonitor.cpp2
-rw-r--r--xbmc/input/joysticks/JoystickMonitor.h2
-rw-r--r--xbmc/input/joysticks/JoystickTypes.h3
-rw-r--r--xbmc/input/joysticks/RumbleGenerator.cpp4
-rw-r--r--xbmc/input/joysticks/generic/ButtonMapping.cpp44
-rw-r--r--xbmc/input/joysticks/generic/ButtonMapping.h49
-rw-r--r--xbmc/input/joysticks/generic/DriverReceiving.cpp4
-rw-r--r--xbmc/input/joysticks/generic/DriverReceiving.h2
-rw-r--r--xbmc/input/joysticks/generic/FeatureHandling.cpp4
-rw-r--r--xbmc/input/joysticks/generic/InputHandling.cpp2
-rw-r--r--xbmc/input/joysticks/generic/InputHandling.h2
-rw-r--r--xbmc/input/joysticks/interfaces/IButtonMap.h (renamed from xbmc/input/joysticks/IButtonMap.h)4
-rw-r--r--xbmc/input/joysticks/interfaces/IButtonMapCallback.h (renamed from xbmc/input/joysticks/IButtonMapCallback.h)0
-rw-r--r--xbmc/input/joysticks/interfaces/IButtonMapper.h (renamed from xbmc/input/joysticks/IButtonMapper.h)0
-rw-r--r--xbmc/input/joysticks/interfaces/IButtonSequence.h (renamed from xbmc/input/joysticks/IButtonSequence.h)2
-rw-r--r--xbmc/input/joysticks/interfaces/IDriverHandler.h (renamed from xbmc/input/joysticks/IDriverHandler.h)2
-rw-r--r--xbmc/input/joysticks/interfaces/IDriverReceiver.h (renamed from xbmc/input/joysticks/IDriverReceiver.h)0
-rw-r--r--xbmc/input/joysticks/interfaces/IInputHandler.h (renamed from xbmc/input/joysticks/IInputHandler.h)2
-rw-r--r--xbmc/input/joysticks/interfaces/IInputProvider.h (renamed from xbmc/input/joysticks/IInputProvider.h)0
-rw-r--r--xbmc/input/joysticks/interfaces/IInputReceiver.h (renamed from xbmc/input/joysticks/IInputReceiver.h)2
-rw-r--r--xbmc/input/joysticks/keymaps/KeymapHandler.h4
-rw-r--r--xbmc/input/joysticks/keymaps/KeymapHandling.cpp4
-rw-r--r--xbmc/input/keyboard/CMakeLists.txt6
-rw-r--r--xbmc/input/keyboard/KeyboardEasterEgg.h2
-rw-r--r--xbmc/input/keyboard/KeymapActionMap.h2
-rw-r--r--xbmc/input/keyboard/generic/JoystickEmulation.cpp2
-rw-r--r--xbmc/input/keyboard/generic/JoystickEmulation.h2
-rw-r--r--xbmc/input/keyboard/interfaces/IActionMap.h (renamed from xbmc/input/keyboard/IActionMap.h)0
-rw-r--r--xbmc/input/keyboard/interfaces/IKeyboardHandler.h (renamed from xbmc/input/keyboard/IKeyboardHandler.h)0
-rw-r--r--xbmc/input/keyboard/interfaces/IKeyboardInputProvider.h (renamed from xbmc/input/keyboard/IKeyboardInputProvider.h)0
-rw-r--r--xbmc/input/mouse/CMakeLists.txt8
-rw-r--r--xbmc/input/mouse/MouseWindowingButtonMap.h2
-rw-r--r--xbmc/input/mouse/generic/MouseInputHandling.cpp4
-rw-r--r--xbmc/input/mouse/generic/MouseInputHandling.h2
-rw-r--r--xbmc/input/mouse/interfaces/IMouseButtonMap.h (renamed from xbmc/input/mouse/IMouseButtonMap.h)0
-rw-r--r--xbmc/input/mouse/interfaces/IMouseDriverHandler.h (renamed from xbmc/input/mouse/IMouseDriverHandler.h)0
-rw-r--r--xbmc/input/mouse/interfaces/IMouseInputHandler.h (renamed from xbmc/input/mouse/IMouseInputHandler.h)0
-rw-r--r--xbmc/input/mouse/interfaces/IMouseInputProvider.h (renamed from xbmc/input/mouse/IMouseInputProvider.h)0
-rw-r--r--xbmc/peripherals/Peripherals.cpp2
-rw-r--r--xbmc/peripherals/addons/AddonButtonMap.cpp24
-rw-r--r--xbmc/peripherals/addons/AddonButtonMap.h2
-rw-r--r--xbmc/peripherals/addons/AddonButtonMapping.cpp2
-rw-r--r--xbmc/peripherals/addons/AddonButtonMapping.h4
-rw-r--r--xbmc/peripherals/addons/AddonInputHandling.cpp4
-rw-r--r--xbmc/peripherals/addons/AddonInputHandling.h4
-rw-r--r--xbmc/peripherals/addons/PeripheralAddon.cpp4
-rw-r--r--xbmc/peripherals/addons/PeripheralAddonTranslator.cpp8
-rw-r--r--xbmc/peripherals/devices/Peripheral.cpp18
-rw-r--r--xbmc/peripherals/devices/Peripheral.h5
-rw-r--r--xbmc/peripherals/devices/PeripheralJoystick.cpp4
-rw-r--r--xbmc/peripherals/devices/PeripheralJoystick.h2
-rw-r--r--xbmc/peripherals/devices/PeripheralJoystickEmulation.h2
95 files changed, 435 insertions, 301 deletions
diff --git a/xbmc/games/addons/input/GameClientJoystick.cpp b/xbmc/games/addons/input/GameClientJoystick.cpp
index 59e1765432..6d4c2002b4 100644
--- a/xbmc/games/addons/input/GameClientJoystick.cpp
+++ b/xbmc/games/addons/input/GameClientJoystick.cpp
@@ -22,7 +22,7 @@
#include "GameClientInput.h"
#include "games/addons/GameClient.h"
#include "games/controllers/Controller.h"
-#include "input/joysticks/IInputReceiver.h"
+#include "input/joysticks/interfaces/IInputReceiver.h"
#include "utils/log.h"
#include <assert.h>
diff --git a/xbmc/games/addons/input/GameClientJoystick.h b/xbmc/games/addons/input/GameClientJoystick.h
index bf218f6b8b..c8abe1fb66 100644
--- a/xbmc/games/addons/input/GameClientJoystick.h
+++ b/xbmc/games/addons/input/GameClientJoystick.h
@@ -20,7 +20,7 @@
#pragma once
#include "games/controllers/ControllerTypes.h"
-#include "input/joysticks/IInputHandler.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
struct KodiToAddonFuncTable_Game;
diff --git a/xbmc/games/addons/input/GameClientKeyboard.cpp b/xbmc/games/addons/input/GameClientKeyboard.cpp
index 5ea121ed32..6f4665babd 100644
--- a/xbmc/games/addons/input/GameClientKeyboard.cpp
+++ b/xbmc/games/addons/input/GameClientKeyboard.cpp
@@ -23,7 +23,7 @@
#include "addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h"
#include "games/addons/GameClient.h"
#include "games/addons/GameClientTranslator.h"
-#include "input/keyboard/IKeyboardInputProvider.h"
+#include "input/keyboard/interfaces/IKeyboardInputProvider.h"
#include "input/Key.h"
#include "utils/log.h"
diff --git a/xbmc/games/addons/input/GameClientKeyboard.h b/xbmc/games/addons/input/GameClientKeyboard.h
index 97e65da24e..271d3ff471 100644
--- a/xbmc/games/addons/input/GameClientKeyboard.h
+++ b/xbmc/games/addons/input/GameClientKeyboard.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/keyboard/IKeyboardHandler.h"
+#include "input/keyboard/interfaces/IKeyboardHandler.h"
struct KodiToAddonFuncTable_Game;
diff --git a/xbmc/games/addons/input/GameClientMouse.cpp b/xbmc/games/addons/input/GameClientMouse.cpp
index f437e9d567..98adb6ca18 100644
--- a/xbmc/games/addons/input/GameClientMouse.cpp
+++ b/xbmc/games/addons/input/GameClientMouse.cpp
@@ -22,7 +22,7 @@
#include "GameClientInput.h"
#include "addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h"
#include "games/addons/GameClient.h"
-#include "input/mouse/IMouseInputProvider.h"
+#include "input/mouse/interfaces/IMouseInputProvider.h"
#include "input/Key.h"
#include "utils/log.h"
diff --git a/xbmc/games/addons/input/GameClientMouse.h b/xbmc/games/addons/input/GameClientMouse.h
index 43af6ecb37..c5d253ea37 100644
--- a/xbmc/games/addons/input/GameClientMouse.h
+++ b/xbmc/games/addons/input/GameClientMouse.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/mouse/IMouseInputHandler.h"
+#include "input/mouse/interfaces/IMouseInputHandler.h"
struct KodiToAddonFuncTable_Game;
diff --git a/xbmc/games/controllers/CMakeLists.txt b/xbmc/games/controllers/CMakeLists.txt
index 564aaff121..899ffb733a 100644
--- a/xbmc/games/controllers/CMakeLists.txt
+++ b/xbmc/games/controllers/CMakeLists.txt
@@ -7,6 +7,7 @@ set(SOURCES Controller.cpp
set(HEADERS Controller.h
ControllerDefinitions.h
ControllerFeature.h
+ ControllerIDs.h
ControllerLayout.h
ControllerManager.h
ControllerTranslator.h
diff --git a/xbmc/games/controllers/ControllerDefinitions.h b/xbmc/games/controllers/ControllerDefinitions.h
index d06ae45ba1..244fdc09cf 100644
--- a/xbmc/games/controllers/ControllerDefinitions.h
+++ b/xbmc/games/controllers/ControllerDefinitions.h
@@ -53,3 +53,4 @@
#define FEATURE_CATEGORY_HARDWARE "hardware"
#define FEATURE_CATEGORY_WHEEL "wheel"
#define FEATURE_CATEGORY_JOYSTICK "joysticks"
+#define FEATURE_CATEGORY_PADDLE "paddles"
diff --git a/xbmc/games/controllers/ControllerFeature.cpp b/xbmc/games/controllers/ControllerFeature.cpp
index 399f679e66..cebbf35ca4 100644
--- a/xbmc/games/controllers/ControllerFeature.cpp
+++ b/xbmc/games/controllers/ControllerFeature.cpp
@@ -34,13 +34,7 @@ using namespace JOYSTICK;
void CControllerFeature::Reset(void)
{
- m_controller = nullptr;
- m_type = FEATURE_TYPE::UNKNOWN;
- m_category = FEATURE_CATEGORY::UNKNOWN;
- m_categoryLabelId = -1;
- m_strName.clear();
- m_labelId = -1;
- m_inputType = INPUT_TYPE::UNKNOWN;
+ *this = CControllerFeature();
}
CControllerFeature& CControllerFeature::operator=(const CControllerFeature& rhs)
@@ -48,12 +42,12 @@ CControllerFeature& CControllerFeature::operator=(const CControllerFeature& rhs)
if (this != &rhs)
{
m_controller = rhs.m_controller;
- m_type = rhs.m_type;
- m_category = rhs.m_category;
+ m_type = rhs.m_type;
+ m_category = rhs.m_category;
m_categoryLabelId = rhs.m_categoryLabelId;
- m_strName = rhs.m_strName;
- m_labelId = rhs.m_labelId;
- m_inputType = rhs.m_inputType;
+ m_strName = rhs.m_strName;
+ m_labelId = rhs.m_labelId;
+ m_inputType = rhs.m_inputType;
}
return *this;
}
diff --git a/xbmc/games/controllers/ControllerFeature.h b/xbmc/games/controllers/ControllerFeature.h
index c3b4c07f08..29a12cb3db 100644
--- a/xbmc/games/controllers/ControllerFeature.h
+++ b/xbmc/games/controllers/ControllerFeature.h
@@ -34,7 +34,7 @@ namespace GAME
class CControllerFeature
{
public:
- CControllerFeature(void) { Reset(); }
+ CControllerFeature() = default;
CControllerFeature(const CControllerFeature& other) { *this = other; }
void Reset(void);
@@ -43,10 +43,14 @@ public:
JOYSTICK::FEATURE_TYPE Type(void) const { return m_type; }
JOYSTICK::FEATURE_CATEGORY Category(void) const { return m_category; }
- std::string CategoryLabel(void) const;
- const std::string& Name(void) const { return m_strName; }
- std::string Label(void) const;
- int LabelID(void) const { return m_labelId; }
+ const std::string &Name(void) const { return m_strName; }
+
+ // GUI properties
+ std::string Label(void) const;
+ int LabelID(void) const { return m_labelId; }
+ std::string CategoryLabel(void) const;
+
+ // Input properties
JOYSTICK::INPUT_TYPE InputType(void) const { return m_inputType; }
bool Deserialize(const TiXmlElement* pElement,
@@ -55,13 +59,13 @@ public:
int categoryLabelId);
private:
- const CController *m_controller; // To get the controller ID for translating labels
- JOYSTICK::FEATURE_TYPE m_type;
- JOYSTICK::FEATURE_CATEGORY m_category;
- int m_categoryLabelId;
- std::string m_strName;
- int m_labelId;
- JOYSTICK::INPUT_TYPE m_inputType;
+ const CController *m_controller = nullptr; // Used for translating addon-specific labels
+ JOYSTICK::FEATURE_TYPE m_type = JOYSTICK::FEATURE_TYPE::UNKNOWN;
+ JOYSTICK::FEATURE_CATEGORY m_category = JOYSTICK::FEATURE_CATEGORY::UNKNOWN;
+ int m_categoryLabelId = -1;
+ std::string m_strName;
+ int m_labelId = -1;
+ JOYSTICK::INPUT_TYPE m_inputType = JOYSTICK::INPUT_TYPE::UNKNOWN;
};
}
diff --git a/xbmc/games/controllers/ControllerIDs.h b/xbmc/games/controllers/ControllerIDs.h
new file mode 100644
index 0000000000..d31fe383ca
--- /dev/null
+++ b/xbmc/games/controllers/ControllerIDs.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2017 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this Program; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+// Default controller IDs
+#define DEFAULT_CONTROLLER_ID "game.controller.default"
+#define DEFAULT_REMOTE_ID "game.controller.remote"
diff --git a/xbmc/games/controllers/ControllerManager.cpp b/xbmc/games/controllers/ControllerManager.cpp
index ddd051133c..af18eca8e8 100644
--- a/xbmc/games/controllers/ControllerManager.cpp
+++ b/xbmc/games/controllers/ControllerManager.cpp
@@ -20,9 +20,9 @@
#include "ControllerManager.h"
#include "Controller.h"
+#include "ControllerIDs.h"
#include "ServiceBroker.h"
#include "addons/AddonManager.h"
-#include "input/joysticks/JoystickIDs.h"
using namespace KODI;
using namespace GAME;
diff --git a/xbmc/games/controllers/ControllerTranslator.cpp b/xbmc/games/controllers/ControllerTranslator.cpp
index 334e4f306a..75d119720e 100644
--- a/xbmc/games/controllers/ControllerTranslator.cpp
+++ b/xbmc/games/controllers/ControllerTranslator.cpp
@@ -76,6 +76,7 @@ const char* CControllerTranslator::TranslateFeatureCategory(FEATURE_CATEGORY cat
case FEATURE_CATEGORY::HARDWARE: return FEATURE_CATEGORY_HARDWARE;
case FEATURE_CATEGORY::WHEEL: return FEATURE_CATEGORY_WHEEL;
case FEATURE_CATEGORY::JOYSTICK: return FEATURE_CATEGORY_JOYSTICK;
+ case FEATURE_CATEGORY::PADDLE: return FEATURE_CATEGORY_PADDLE;
default:
break;
}
@@ -99,6 +100,7 @@ FEATURE_CATEGORY CControllerTranslator::TranslateFeatureCategory(const std::stri
if (strCategory == FEATURE_CATEGORY_HARDWARE) return FEATURE_CATEGORY::HARDWARE;
if (strCategory == FEATURE_CATEGORY_WHEEL) return FEATURE_CATEGORY::WHEEL;
if (strCategory == FEATURE_CATEGORY_JOYSTICK) return FEATURE_CATEGORY::JOYSTICK;
+ if (strCategory == FEATURE_CATEGORY_PADDLE) return FEATURE_CATEGORY::PADDLE;
return FEATURE_CATEGORY::UNKNOWN;
}
diff --git a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp
index 07be9dff2c..8dcb8003b0 100644
--- a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp
+++ b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp
@@ -20,8 +20,8 @@
#include "GUIDialogAxisDetection.h"
#include "guilib/LocalizeStrings.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
#include "input/joysticks/JoystickTranslator.h"
#include "utils/StringUtils.h"
diff --git a/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.cpp b/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.cpp
index b5b6d9a8d1..15e5e038cf 100644
--- a/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.cpp
+++ b/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.cpp
@@ -19,11 +19,11 @@
*/
#include "GUIDialogButtonCapture.h"
+#include "games/controllers/ControllerIDs.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/WindowIDs.h"
-#include "input/joysticks/JoystickIDs.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IButtonMapCallback.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IButtonMapCallback.h"
#include "input/joysticks/JoystickUtils.h"
#include "input/IKeymap.h"
#include "input/ActionIDs.h"
diff --git a/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.h b/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.h
index 9504646aed..a1a7675080 100644
--- a/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.h
+++ b/xbmc/games/controllers/dialogs/GUIDialogButtonCapture.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/joysticks/IButtonMapper.h"
+#include "input/joysticks/interfaces/IButtonMapper.h"
#include "threads/Event.h"
#include "threads/Thread.h"
#include "utils/Observer.h"
diff --git a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp
index 59cb56769f..14c0a547b9 100644
--- a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp
+++ b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp
@@ -20,8 +20,8 @@
#include "GUIDialogIgnoreInput.h"
#include "guilib/LocalizeStrings.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IButtonMapCallback.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IButtonMapCallback.h"
#include "input/joysticks/JoystickTranslator.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
diff --git a/xbmc/games/controllers/guicontrols/GUIFeatureControls.cpp b/xbmc/games/controllers/guicontrols/GUIFeatureControls.cpp
index a07824ef27..c00e787d24 100644
--- a/xbmc/games/controllers/guicontrols/GUIFeatureControls.cpp
+++ b/xbmc/games/controllers/guicontrols/GUIFeatureControls.cpp
@@ -24,21 +24,21 @@
using namespace KODI;
using namespace GAME;
-CGUIFeatureGroupTitle::CGUIFeatureGroupTitle(const CGUILabelControl& groupTitleTemplate, const std::string& groupName, unsigned int featureIndex) :
+CGUIFeatureGroupTitle::CGUIFeatureGroupTitle(const CGUILabelControl& groupTitleTemplate, const std::string& groupName, unsigned int buttonIndex) :
CGUILabelControl(groupTitleTemplate)
{
// Initialize CGUILabelControl
SetLabel(groupName);
- SetID(CONTROL_FEATURE_GROUPS_START + featureIndex);
+ SetID(CONTROL_FEATURE_GROUPS_START + buttonIndex);
SetVisible(true);
AllocResources();
}
-CGUIFeatureSeparator::CGUIFeatureSeparator(const CGUIImage& separatorTemplate, unsigned int featureIndex) :
+CGUIFeatureSeparator::CGUIFeatureSeparator(const CGUIImage& separatorTemplate, unsigned int buttonIndex) :
CGUIImage(separatorTemplate)
{
// Initialize CGUIImage
- SetID(CONTROL_FEATURE_SEPARATORS_START + featureIndex);
+ SetID(CONTROL_FEATURE_SEPARATORS_START + buttonIndex);
SetVisible(true);
AllocResources();
}
diff --git a/xbmc/games/controllers/guicontrols/GUIFeatureControls.h b/xbmc/games/controllers/guicontrols/GUIFeatureControls.h
index ad670d3474..84d53b72d0 100644
--- a/xbmc/games/controllers/guicontrols/GUIFeatureControls.h
+++ b/xbmc/games/controllers/guicontrols/GUIFeatureControls.h
@@ -31,7 +31,7 @@ namespace GAME
class CGUIFeatureGroupTitle : public CGUILabelControl
{
public:
- CGUIFeatureGroupTitle(const CGUILabelControl& groupTitleTemplate, const std::string& groupName, unsigned int featureIndex);
+ CGUIFeatureGroupTitle(const CGUILabelControl& groupTitleTemplate, const std::string& groupName, unsigned int buttonIndex);
virtual ~CGUIFeatureGroupTitle() = default;
};
@@ -39,7 +39,7 @@ namespace GAME
class CGUIFeatureSeparator : public CGUIImage
{
public:
- CGUIFeatureSeparator(const CGUIImage& separatorTemplate, unsigned int featureIndex);
+ CGUIFeatureSeparator(const CGUIImage& separatorTemplate, unsigned int buttonIndex);
virtual ~CGUIFeatureSeparator() = default;
};
diff --git a/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp b/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp
index 42ac0a4f48..42851f957d 100644
--- a/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp
+++ b/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp
@@ -23,8 +23,8 @@
#include "games/controllers/guicontrols/GUIFeatureButton.h"
#include "games/controllers/Controller.h"
#include "games/controllers/ControllerFeature.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IButtonMapCallback.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IButtonMapCallback.h"
#include "input/joysticks/JoystickUtils.h"
#include "input/keyboard/KeymapActionMap.h"
#include "input/InputManager.h"
@@ -198,8 +198,8 @@ bool CGUIConfigurationWizard::MapPrimitive(JOYSTICK::IButtonMap* buttonMap,
bool bHandled = false;
- // Handle esc key separately
- if (!m_deviceName.empty() && m_deviceName != buttonMap->DeviceName())
+ // Abort if another controller cancels the prompt
+ if (IsMapping() && !IsMapping(buttonMap->DeviceName()))
{
bool bIsCancelAction = false;
@@ -272,52 +272,62 @@ bool CGUIConfigurationWizard::MapPrimitive(JOYSTICK::IButtonMap* buttonMap,
{
const CControllerFeature& feature = currentButton->Feature();
- CLog::Log(LOGDEBUG, "%s: mapping feature \"%s\" for device %s",
- m_strControllerId.c_str(), feature.Name().c_str(), buttonMap->DeviceName().c_str());
-
- switch (feature.Type())
+ if (feature.Type() == JOYSTICK::FEATURE_TYPE::UNKNOWN)
{
- case FEATURE_TYPE::SCALAR:
- {
- buttonMap->AddScalar(feature.Name(), primitive);
- bHandled = true;
- break;
- }
- case FEATURE_TYPE::ANALOG_STICK:
- {
- buttonMap->AddAnalogStick(feature.Name(), analogStickDirection, primitive);
- bHandled = true;
- break;
- }
- case FEATURE_TYPE::RELPOINTER:
- {
- buttonMap->AddRelativePointer(feature.Name(), analogStickDirection, primitive);
- bHandled = true;
- break;
- }
- case FEATURE_TYPE::WHEEL:
+ // Unknown feature, absorb input
+ bHandled = true;
+ }
+ else
+ {
+ CLog::Log(LOGDEBUG, "%s: mapping feature \"%s\" for device %s",
+ m_strControllerId.c_str(), feature.Name().c_str(), buttonMap->DeviceName().c_str());
+
+ switch (feature.Type())
{
- buttonMap->AddWheel(feature.Name(), wheelDirection, primitive);
- bHandled = true;
- break;
+ case FEATURE_TYPE::SCALAR:
+ {
+ buttonMap->AddScalar(feature.Name(), primitive);
+ bHandled = true;
+ break;
+ }
+ case FEATURE_TYPE::ANALOG_STICK:
+ {
+ buttonMap->AddAnalogStick(feature.Name(), analogStickDirection, primitive);
+ bHandled = true;
+ break;
+ }
+ case FEATURE_TYPE::RELPOINTER:
+ {
+ buttonMap->AddRelativePointer(feature.Name(), analogStickDirection, primitive);
+ bHandled = true;
+ break;
+ }
+ case FEATURE_TYPE::WHEEL:
+ {
+ buttonMap->AddWheel(feature.Name(), wheelDirection, primitive);
+ bHandled = true;
+ break;
+ }
+ case FEATURE_TYPE::THROTTLE:
+ {
+ buttonMap->AddThrottle(feature.Name(), throttleDirection, primitive);
+ bHandled = true;
+ break;
+ }
+ default:
+ break;
}
- case FEATURE_TYPE::THROTTLE:
+
+ if (bHandled)
{
- buttonMap->AddThrottle(feature.Name(), throttleDirection, primitive);
- bHandled = true;
- break;
- }
- default:
- break;
- }
+ m_history.insert(primitive);
- if (bHandled)
- {
- m_history.insert(primitive);
+ OnMotion(buttonMap);
+ m_inputEvent.Set();
- OnMotion(buttonMap);
- m_inputEvent.Set();
- m_deviceName = buttonMap->DeviceName();
+ if (m_deviceName.empty())
+ m_deviceName = buttonMap->DeviceName();
+ }
}
}
}
@@ -358,14 +368,20 @@ void CGUIConfigurationWizard::OnMotionless(const JOYSTICK::IButtonMap* buttonMap
bool CGUIConfigurationWizard::OnKeyPress(const CKey& key)
{
- using namespace KEYBOARD;
-
bool bHandled = false;
if (!m_bStop)
+ bHandled = OnKeyAction(m_actionMap->GetActionID(key));
+
+ return bHandled;
+}
+
+bool CGUIConfigurationWizard::OnKeyAction(unsigned int actionId)
+{
+ bool bHandled = false;
+
+ switch (actionId)
{
- switch (m_actionMap->GetActionID(key))
- {
case ACTION_MOVE_LEFT:
case ACTION_MOVE_RIGHT:
case ACTION_MOVE_UP:
@@ -389,7 +405,6 @@ bool CGUIConfigurationWizard::OnKeyPress(const CKey& key)
// Absorb keypress
bHandled = true;
break;
- }
}
return bHandled;
@@ -400,6 +415,16 @@ bool CGUIConfigurationWizard::OnButtonPress(const std::string& button)
return Abort(false);
}
+bool CGUIConfigurationWizard::IsMapping() const
+{
+ return !m_deviceName.empty();
+}
+
+bool CGUIConfigurationWizard::IsMapping(const std::string &deviceName) const
+{
+ return m_deviceName == deviceName;
+}
+
void CGUIConfigurationWizard::InstallHooks(void)
{
CServiceBroker::GetPeripherals().RegisterJoystickButtonMapper(this);
diff --git a/xbmc/games/controllers/windows/GUIConfigurationWizard.h b/xbmc/games/controllers/windows/GUIConfigurationWizard.h
index e3cb1d3806..69fa21af4e 100644
--- a/xbmc/games/controllers/windows/GUIConfigurationWizard.h
+++ b/xbmc/games/controllers/windows/GUIConfigurationWizard.h
@@ -21,9 +21,9 @@
#include "IConfigurationWindow.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMapper.h"
-#include "input/keyboard/IKeyboardHandler.h"
-#include "input/mouse/IMouseInputHandler.h"
+#include "input/joysticks/interfaces/IButtonMapper.h"
+#include "input/keyboard/interfaces/IKeyboardHandler.h"
+#include "input/mouse/interfaces/IMouseInputHandler.h"
#include "threads/CriticalSection.h"
#include "threads/Event.h"
#include "threads/Thread.h"
@@ -90,12 +90,17 @@ namespace GAME
private:
void InitializeState(void);
+ bool IsMapping() const;
+ bool IsMapping(const std::string &deviceName) const;
+
void InstallHooks(void);
void RemoveHooks(void);
void OnMotion(const JOYSTICK::IButtonMap* buttonMap);
void OnMotionless(const JOYSTICK::IButtonMap* buttonMap);
+ bool OnKeyAction(unsigned int actionId);
+
// Construction parameters
const bool m_bEmulation;
const unsigned int m_controllerNumber;
diff --git a/xbmc/games/controllers/windows/GUIControllerList.cpp b/xbmc/games/controllers/windows/GUIControllerList.cpp
index aa67da3e7b..9b4497e929 100644
--- a/xbmc/games/controllers/windows/GUIControllerList.cpp
+++ b/xbmc/games/controllers/windows/GUIControllerList.cpp
@@ -30,6 +30,7 @@
#include "addons/AddonManager.h"
#include "dialogs/GUIDialogYesNo.h"
#include "games/controllers/Controller.h"
+#include "games/controllers/ControllerIDs.h"
#include "games/controllers/ControllerFeature.h"
#include "games/controllers/ControllerLayout.h"
#include "games/controllers/guicontrols/GUIControllerButton.h"
@@ -39,7 +40,6 @@
#include "guilib/GUIControlGroupList.h"
#include "guilib/GUIWindow.h"
#include "guilib/WindowIDs.h"
-#include "input/joysticks/JoystickIDs.h"
#include "messaging/ApplicationMessenger.h"
#include "peripherals/Peripherals.h"
#include "utils/StringUtils.h"
diff --git a/xbmc/games/controllers/windows/GUIControllerWindow.cpp b/xbmc/games/controllers/windows/GUIControllerWindow.cpp
index bd12b4023a..cc87f73c56 100644
--- a/xbmc/games/controllers/windows/GUIControllerWindow.cpp
+++ b/xbmc/games/controllers/windows/GUIControllerWindow.cpp
@@ -269,16 +269,16 @@ void CGUIControllerWindow::OnControllerSelected(unsigned int controllerIndex)
m_controllerList->OnSelect(controllerIndex);
}
-void CGUIControllerWindow::OnFeatureFocused(unsigned int featureIndex)
+void CGUIControllerWindow::OnFeatureFocused(unsigned int buttonIndex)
{
if (m_featureList)
- m_featureList->OnFocus(featureIndex);
+ m_featureList->OnFocus(buttonIndex);
}
-void CGUIControllerWindow::OnFeatureSelected(unsigned int featureIndex)
+void CGUIControllerWindow::OnFeatureSelected(unsigned int buttonIndex)
{
if (m_featureList)
- m_featureList->OnSelect(featureIndex);
+ m_featureList->OnSelect(buttonIndex);
}
void CGUIControllerWindow::UpdateButtons(void)
diff --git a/xbmc/games/controllers/windows/GUIFeatureList.cpp b/xbmc/games/controllers/windows/GUIFeatureList.cpp
index cdfef9b715..bc8142193c 100644
--- a/xbmc/games/controllers/windows/GUIFeatureList.cpp
+++ b/xbmc/games/controllers/windows/GUIFeatureList.cpp
@@ -113,26 +113,30 @@ void CGUIFeatureList::Load(const ControllerPtr& controller)
auto featureGroups = GetFeatureGroups(features);
// Create controls
- unsigned int featureIndex = 0;
+ m_buttonCount = 0;
for (auto itGroup = featureGroups.begin(); itGroup != featureGroups.end(); ++itGroup)
{
const std::string& groupName = itGroup->groupName;
// Create buttons
- std::vector<CGUIButtonControl*> buttons = GetButtons(itGroup->features, featureIndex);
+ std::vector<CGUIButtonControl*> buttons = GetButtons(itGroup->features, m_buttonCount);
if (!buttons.empty())
{
+ // Just in case
+ if (m_buttonCount + buttons.size() >= MAX_FEATURE_COUNT)
+ break;
+
// Add a separator if the group list isn't empty
if (m_guiFeatureSeparator && m_guiList->GetTotalSize() > 0)
{
- CGUIFeatureSeparator* pSeparator = new CGUIFeatureSeparator(*m_guiFeatureSeparator, featureIndex);
+ CGUIFeatureSeparator* pSeparator = new CGUIFeatureSeparator(*m_guiFeatureSeparator, m_buttonCount);
m_guiList->AddControl(pSeparator);
}
// Add the group title
if (m_guiGroupTitle && !groupName.empty())
{
- CGUIFeatureGroupTitle* pGroupTitle = new CGUIFeatureGroupTitle(*m_guiGroupTitle, groupName, featureIndex);
+ CGUIFeatureGroupTitle* pGroupTitle = new CGUIFeatureGroupTitle(*m_guiGroupTitle, groupName, m_buttonCount);
m_guiList->AddControl(pGroupTitle);
}
@@ -140,24 +144,18 @@ void CGUIFeatureList::Load(const ControllerPtr& controller)
for (CGUIButtonControl* pButton : buttons)
m_guiList->AddControl(pButton);
- featureIndex += itGroup->features.size();
+ m_buttonCount += buttons.size();
}
-
- // Just in case
- if (featureIndex >= MAX_FEATURE_COUNT)
- break;
}
}
-void CGUIFeatureList::OnSelect(unsigned int index)
+void CGUIFeatureList::OnSelect(unsigned int buttonIndex)
{
- const unsigned int featureCount = m_controller->FeatureCount();
-
// Generate list of buttons for the wizard
std::vector<IFeatureButton*> buttons;
- for ( ; index < featureCount; index++)
+ for ( ; buttonIndex < m_buttonCount; buttonIndex++)
{
- IFeatureButton* control = GetButtonControl(index);
+ IFeatureButton* control = GetButtonControl(buttonIndex);
if (control)
buttons.push_back(control);
}
@@ -165,15 +163,17 @@ void CGUIFeatureList::OnSelect(unsigned int index)
m_wizard->Run(m_controller->ID(), buttons);
}
-IFeatureButton* CGUIFeatureList::GetButtonControl(unsigned int featureIndex)
+IFeatureButton* CGUIFeatureList::GetButtonControl(unsigned int buttonIndex)
{
- CGUIControl* control = m_guiList->GetControl(CONTROL_FEATURE_BUTTONS_START + featureIndex);
+ CGUIControl* control = m_guiList->GetControl(CONTROL_FEATURE_BUTTONS_START + buttonIndex);
return static_cast<IFeatureButton*>(dynamic_cast<CGUIFeatureButton*>(control));
}
void CGUIFeatureList::CleanupButtons(void)
{
+ m_buttonCount = 0;
+
m_wizard->Abort(true);
if (m_guiList)
@@ -225,18 +225,19 @@ std::vector<CGUIButtonControl*> CGUIFeatureList::GetButtons(const std::vector<CC
std::vector<CGUIButtonControl*> buttons;
// Create buttons
- unsigned int featureIndex = startIndex;
+ unsigned int buttonIndex = startIndex;
for (const CControllerFeature& feature : features)
{
BUTTON_TYPE buttonType = CGUIFeatureTranslator::GetButtonType(feature.Type());
- CGUIButtonControl* pButton = CGUIFeatureFactory::CreateButton(buttonType, *m_guiButtonTemplate, m_wizard, feature, featureIndex);
+ CGUIButtonControl* pButton = CGUIFeatureFactory::CreateButton(buttonType, *m_guiButtonTemplate, m_wizard, feature, buttonIndex);
// If successful, add button to result
if (pButton != nullptr)
+ {
buttons.push_back(pButton);
-
- featureIndex++;
+ buttonIndex++;
+ }
}
return buttons;
diff --git a/xbmc/games/controllers/windows/GUIFeatureList.h b/xbmc/games/controllers/windows/GUIFeatureList.h
index 226c0589d3..4389bcdb5f 100644
--- a/xbmc/games/controllers/windows/GUIFeatureList.h
+++ b/xbmc/games/controllers/windows/GUIFeatureList.h
@@ -45,11 +45,11 @@ namespace GAME
virtual void Deinitialize(void) override;
virtual bool HasButton(JOYSTICK::FEATURE_TYPE type) const override;
virtual void Load(const ControllerPtr& controller) override;
- virtual void OnFocus(unsigned int index) override { }
- virtual void OnSelect(unsigned int index) override;
+ virtual void OnFocus(unsigned int buttonIndex) override { }
+ virtual void OnSelect(unsigned int buttonIndex) override;
private:
- IFeatureButton* GetButtonControl(unsigned int featureIndex);
+ IFeatureButton* GetButtonControl(unsigned int buttonIndex);
void CleanupButtons(void);
@@ -65,6 +65,7 @@ namespace GAME
// GUI stuff
CGUIWindow* const m_window;
+ unsigned int m_buttonCount = 0;
CGUIControlGroupList* m_guiList;
CGUIButtonControl* m_guiButtonTemplate;
CGUILabelControl* m_guiGroupTitle;
diff --git a/xbmc/games/controllers/windows/IConfigurationWindow.h b/xbmc/games/controllers/windows/IConfigurationWindow.h
index 9729ed7080..9d3e3d2882 100644
--- a/xbmc/games/controllers/windows/IConfigurationWindow.h
+++ b/xbmc/games/controllers/windows/IConfigurationWindow.h
@@ -139,20 +139,20 @@ namespace GAME
virtual void Load(const ControllerPtr& controller) = 0;
/*!
- * \brief Focus has been set to the specified feature
- * \param featureIndex The index of the feature being focused
+ * \brief Focus has been set to the specified GUI button
+ * \param buttonIndex The index of the button being focused
*/
- virtual void OnFocus(unsigned int index) = 0;
+ virtual void OnFocus(unsigned int buttonIndex) = 0;
/*!
- * \brief The specified feature has been selected
- * \param featureIndex The index of the feature being selected
+ * \brief The specified GUI button has been selected
+ * \param buttonIndex The index of the button being selected
*/
- virtual void OnSelect(unsigned int index) = 0;
+ virtual void OnSelect(unsigned int buttonIndex) = 0;
};
/*!
- * \brief A button in a feature list
+ * \brief A GUI button in a feature list
*/
class IFeatureButton
{
@@ -216,8 +216,9 @@ namespace GAME
virtual ~IConfigurationWizard() = default;
/*!
- * \brief Start the wizard at the specified feature
- * \param featureIndex The index of the feature to start at
+ * \brief Start the wizard for the specified buttons
+ * \param controllerId The controller ID being mapped
+ * \param buttons The buttons to map
*/
virtual void Run(const std::string& strControllerId, const std::vector<IFeatureButton*>& buttons) = 0;
diff --git a/xbmc/games/ports/InputSink.cpp b/xbmc/games/ports/InputSink.cpp
index da0f1ba731..61b64e5533 100644
--- a/xbmc/games/ports/InputSink.cpp
+++ b/xbmc/games/ports/InputSink.cpp
@@ -20,8 +20,8 @@
#include "InputSink.h"
#include "games/addons/GameClient.h"
+#include "games/controllers/ControllerIDs.h"
#include "games/addons/input/GameClientInput.h"
-#include "input/joysticks/JoystickIDs.h"
using namespace KODI;
using namespace GAME;
diff --git a/xbmc/games/ports/InputSink.h b/xbmc/games/ports/InputSink.h
index fd23f4dff6..bf70838f82 100644
--- a/xbmc/games/ports/InputSink.h
+++ b/xbmc/games/ports/InputSink.h
@@ -20,7 +20,7 @@
#pragma once
#include "games/controllers/ControllerTypes.h"
-#include "input/joysticks/IInputHandler.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
namespace KODI
{
diff --git a/xbmc/games/ports/Port.h b/xbmc/games/ports/Port.h
index bc0878933c..e97617035d 100644
--- a/xbmc/games/ports/Port.h
+++ b/xbmc/games/ports/Port.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/joysticks/IInputHandler.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
#include "input/KeymapEnvironment.h"
#include <memory>
diff --git a/xbmc/games/ports/PortManager.cpp b/xbmc/games/ports/PortManager.cpp
index c7a5e3c6cb..4446e58503 100644
--- a/xbmc/games/ports/PortManager.cpp
+++ b/xbmc/games/ports/PortManager.cpp
@@ -21,7 +21,7 @@
#include "PortManager.h"
#include "PortMapper.h"
#include "input/hardware/IHardwareInput.h"
-#include "input/joysticks/IInputHandler.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
#include "peripherals/devices/Peripheral.h"
#include "peripherals/devices/PeripheralJoystick.h"
#include "peripherals/devices/PeripheralJoystickEmulation.h"
diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp
index de12d9da62..764275fe61 100644
--- a/xbmc/input/ButtonTranslator.cpp
+++ b/xbmc/input/ButtonTranslator.cpp
@@ -266,6 +266,11 @@ unsigned int CButtonTranslator::GetActionCode(int window, const CKey &key, std::
{
uint32_t code = key.GetButtonCode();
+ // Keymaps don't use locking modifiers
+ code &= ~CKey::MODIFIER_CAPSLOCK;
+ code &= ~CKey::MODIFIER_NUMLOCK;
+ code &= ~CKey::MODIFIER_SCROLLLOCK;
+
std::map<int, buttonMap>::const_iterator it = m_translatorMap.find(window);
if (it == m_translatorMap.end())
return ACTION_NONE;
diff --git a/xbmc/input/InputManager.cpp b/xbmc/input/InputManager.cpp
index 29bf72ca41..0c7d084081 100644
--- a/xbmc/input/InputManager.cpp
+++ b/xbmc/input/InputManager.cpp
@@ -28,9 +28,9 @@
#include "JoystickMapper.h"
#include "KeymapEnvironment.h"
#include "TouchTranslator.h"
-#include "input/keyboard/IKeyboardHandler.h"
+#include "input/keyboard/interfaces/IKeyboardHandler.h"
#include "input/mouse/generic/MouseInputHandling.h"
-#include "input/mouse/IMouseDriverHandler.h"
+#include "input/mouse/interfaces/IMouseDriverHandler.h"
#include "input/mouse/MouseWindowingButtonMap.h"
#include "input/keyboard/KeyboardEasterEgg.h"
#include "input/Key.h"
@@ -589,7 +589,7 @@ bool CInputManager::HandleKey(const CKey& key)
// If the key pressed is shift-A to shift-Z set usekeyboard to true.
// This causes the keypress to be used for list navigation.
- if (control->IsContainer() && key.GetModifiers() == CKey::MODIFIER_SHIFT && key.GetVKey() >= XBMCVK_A && key.GetVKey() <= XBMCVK_Z)
+ if (control->IsContainer() && (key.GetModifiers() & CKey::MODIFIER_SHIFT) && key.GetVKey() >= XBMCVK_A && key.GetVKey() <= XBMCVK_Z)
useKeyboard = true;
}
}
@@ -628,13 +628,13 @@ bool CInputManager::HandleKey(const CKey& key)
// Check for paste keypress
#ifdef TARGET_WINDOWS
// In Windows paste is ctrl-V
- if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_CTRL)
+ if (key.GetVKey() == XBMCVK_V && (key.GetModifiers() & CKey::MODIFIER_CTRL))
#elif defined(TARGET_LINUX)
// In Linux paste is ctrl-V
- if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_CTRL)
+ if (key.GetVKey() == XBMCVK_V && (key.GetModifiers() & CKey::MODIFIER_CTRL))
#elif defined(TARGET_DARWIN_OSX)
// In OSX paste is cmd-V
- if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_META)
+ if (key.GetVKey() == XBMCVK_V && (key.GetModifiers() & CKey::MODIFIER_META))
#else
// Placeholder for other operating systems
if (false)
diff --git a/xbmc/input/InputManager.h b/xbmc/input/InputManager.h
index 14da1b57e7..ed42ddb44b 100644
--- a/xbmc/input/InputManager.h
+++ b/xbmc/input/InputManager.h
@@ -33,8 +33,8 @@
#include "Action.h"
#include "windowing/XBMC_events.h"
-#include "input/keyboard/IKeyboardInputProvider.h"
-#include "input/mouse/IMouseInputProvider.h"
+#include "input/keyboard/interfaces/IKeyboardInputProvider.h"
+#include "input/mouse/interfaces/IMouseInputProvider.h"
#include "input/KeyboardStat.h"
#include "input/MouseStat.h"
#include "interfaces/IActionListener.h"
diff --git a/xbmc/input/Key.cpp b/xbmc/input/Key.cpp
index 3d1b90e3ca..c049fbcf3c 100644
--- a/xbmc/input/Key.cpp
+++ b/xbmc/input/Key.cpp
@@ -48,7 +48,7 @@ CKey::CKey(uint32_t buttonCode, unsigned int held)
m_held = held;
}
-CKey::CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held)
+CKey::CKey(uint32_t keycode, uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held)
{
Reset();
if (vkey) // FIXME: This needs cleaning up - should we always use the unicode key where available?
@@ -56,6 +56,7 @@ CKey::CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsign
else
m_buttonCode = KEY_UNICODE;
m_buttonCode |= modifiers;
+ m_keycode = keycode;
m_vkey = vkey;
m_unicode = unicode;
m_ascii = ascii;
@@ -79,6 +80,7 @@ void CKey::Reset()
m_repeat = 0.0f;
m_fromService = false;
m_buttonCode = KEY_INVALID;
+ m_keycode = 0;
m_vkey = 0;
m_unicode = 0;
m_ascii = 0;
@@ -98,6 +100,7 @@ CKey& CKey::operator=(const CKey& key)
m_repeat = key.m_repeat;
m_fromService = key.m_fromService;
m_buttonCode = key.m_buttonCode;
+ m_keycode = key.m_keycode;
m_vkey = key.m_vkey;
m_unicode = key.m_unicode;
m_ascii = key.m_ascii;
diff --git a/xbmc/input/Key.h b/xbmc/input/Key.h
index 916b689553..24c119002b 100644
--- a/xbmc/input/Key.h
+++ b/xbmc/input/Key.h
@@ -149,7 +149,7 @@ public:
CKey(void);
CKey(uint32_t buttonCode, uint8_t leftTrigger = 0, uint8_t rightTrigger = 0, float leftThumbX = 0.0f, float leftThumbY = 0.0f, float rightThumbX = 0.0f, float rightThumbY = 0.0f, float repeat = 0.0f);
CKey(uint32_t buttonCode, unsigned int held);
- CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held);
+ CKey(uint32_t keycode, uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held);
CKey(const CKey& key);
void Reset();
@@ -169,6 +169,7 @@ public:
bool GetFromService() const { return m_fromService; }
inline uint32_t GetButtonCode() const { return m_buttonCode; }
+ inline uint32_t GetKeycode() const { return m_keycode; } // XBMCKey enum in XBMC_keysym.h
inline uint8_t GetVKey() const { return m_vkey; }
inline wchar_t GetUnicode() const { return m_unicode; }
inline char GetAscii() const { return m_ascii; }
@@ -182,11 +183,15 @@ public:
MODIFIER_RALT = 0x00080000,
MODIFIER_SUPER = 0x00100000,
MODIFIER_META = 0X00200000,
- MODIFIER_LONG = 0X01000000
+ MODIFIER_LONG = 0X01000000,
+ MODIFIER_NUMLOCK = 0X02000000,
+ MODIFIER_CAPSLOCK = 0X04000000,
+ MODIFIER_SCROLLLOCK = 0X08000000,
};
private:
uint32_t m_buttonCode;
+ uint32_t m_keycode;
uint8_t m_vkey;
wchar_t m_unicode;
char m_ascii;
diff --git a/xbmc/input/KeyboardStat.cpp b/xbmc/input/KeyboardStat.cpp
index 22417de05d..071b895cdd 100644
--- a/xbmc/input/KeyboardStat.cpp
+++ b/xbmc/input/KeyboardStat.cpp
@@ -74,6 +74,7 @@ bool CKeyboardStat::LookupSymAndUnicodePeripherals(XBMC_keysym &keysym, uint8_t
CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
{
+ uint32_t keycode;
uint8_t vkey;
wchar_t unicode;
char ascii;
@@ -92,12 +93,19 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
modifiers |= CKey::MODIFIER_SUPER;
if (keysym.mod & XBMCKMOD_META)
modifiers |= CKey::MODIFIER_META;
+ if (keysym.mod & XBMCKMOD_NUM)
+ modifiers |= CKey::MODIFIER_NUMLOCK;
+ if (keysym.mod & XBMCKMOD_CAPS)
+ modifiers |= CKey::MODIFIER_CAPSLOCK;
+ if (keysym.mod & XBMCKMOD_MODE)
+ modifiers |= CKey::MODIFIER_SCROLLLOCK;
CLog::Log(LOGDEBUG, "Keyboard: scancode: 0x%02x, sym: 0x%04x, unicode: 0x%04x, modifier: 0x%x", keysym.scancode, keysym.sym, keysym.unicode, keysym.mod);
// The keysym.unicode is usually valid, even if it is zero. A zero
// unicode just means this is a non-printing keypress. The ascii and
// vkey will be set below.
+ keycode = keysym.sym;
unicode = keysym.unicode;
ascii = 0;
vkey = 0;
@@ -121,6 +129,8 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
// will match keys like \ that are on different keys on regional keyboards.
else if (KeyTableLookupUnicode(keysym.unicode, &keytable))
{
+ if (keycode == 0)
+ keycode = keytable.sym;
vkey = keytable.vkey;
ascii = keytable.ascii;
}
@@ -169,13 +179,13 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
// The A-Z keys are exempted because shift-A-Z is used for navigation in lists.
// The function keys are exempted because function keys have no shifted value and
// the Nyxboard remote uses keys like Shift-F3 for some buttons.
- if (modifiers == CKey::MODIFIER_SHIFT)
+ if (modifiers & CKey::MODIFIER_SHIFT)
if ((unicode < 'A' || unicode > 'Z') && (unicode < 'a' || unicode > 'z') && (vkey < XBMCVK_F1 || vkey > XBMCVK_F24))
modifiers = 0;
// Create and return a CKey
- CKey key(vkey, unicode, ascii, modifiers, held);
+ CKey key(keycode, vkey, unicode, ascii, modifiers, held);
return key;
}
diff --git a/xbmc/input/joysticks/CMakeLists.txt b/xbmc/input/joysticks/CMakeLists.txt
index 1fee11a031..0155e5e39a 100644
--- a/xbmc/input/joysticks/CMakeLists.txt
+++ b/xbmc/input/joysticks/CMakeLists.txt
@@ -6,19 +6,19 @@ set(SOURCES DeadzoneFilter.cpp
JoystickUtils.cpp
RumbleGenerator.cpp)
-set(HEADERS interfaces/IKeyHandler.h
+set(HEADERS interfaces/IButtonMap.h
+ interfaces/IButtonMapCallback.h
+ interfaces/IButtonMapper.h
+ interfaces/IButtonSequence.h
+ interfaces/IDriverHandler.h
+ interfaces/IDriverReceiver.h
+ interfaces/IInputHandler.h
+ interfaces/IInputProvider.h
+ interfaces/IInputReceiver.h
+ interfaces/IKeyHandler.h
interfaces/IKeymapHandler.h
DeadzoneFilter.h
DriverPrimitive.h
- IButtonMap.h
- IButtonMapCallback.h
- IButtonMapper.h
- IButtonSequence.h
- IDriverHandler.h
- IDriverReceiver.h
- IInputHandler.h
- IInputProvider.h
- IInputReceiver.h
JoystickEasterEgg.h
JoystickIDs.h
JoystickMonitor.h
diff --git a/xbmc/input/joysticks/DeadzoneFilter.cpp b/xbmc/input/joysticks/DeadzoneFilter.cpp
index d49f1bb8d3..00b756d937 100644
--- a/xbmc/input/joysticks/DeadzoneFilter.cpp
+++ b/xbmc/input/joysticks/DeadzoneFilter.cpp
@@ -20,7 +20,8 @@
#include "DeadzoneFilter.h"
#include "JoystickIDs.h"
-#include "IButtonMap.h"
+#include "games/controllers/ControllerIDs.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
#include "peripherals/devices/Peripheral.h"
#include "utils/log.h"
diff --git a/xbmc/input/joysticks/DriverPrimitive.cpp b/xbmc/input/joysticks/DriverPrimitive.cpp
index b5e06efa62..2b7d8b44c0 100644
--- a/xbmc/input/joysticks/DriverPrimitive.cpp
+++ b/xbmc/input/joysticks/DriverPrimitive.cpp
@@ -23,40 +23,24 @@
using namespace KODI;
using namespace JOYSTICK;
-CDriverPrimitive::CDriverPrimitive(void)
- : m_type(),
- m_driverIndex(0),
- m_hatDirection(),
- m_center(0),
- m_semiAxisDirection(),
- m_range(1)
-{
-}
+CDriverPrimitive::CDriverPrimitive(void) = default;
CDriverPrimitive::CDriverPrimitive(PRIMITIVE_TYPE type, unsigned int index)
: m_type(type),
- m_driverIndex(index),
- m_hatDirection(),
- m_center(0),
- m_semiAxisDirection(),
- m_range(1)
+ m_driverIndex(index)
{
}
CDriverPrimitive::CDriverPrimitive(unsigned int hatIndex, HAT_DIRECTION direction)
- : m_type(HAT),
+ : m_type(PRIMITIVE_TYPE::HAT),
m_driverIndex(hatIndex),
- m_hatDirection(direction),
- m_center(0),
- m_semiAxisDirection(),
- m_range(1)
+ m_hatDirection(direction)
{
}
CDriverPrimitive::CDriverPrimitive(unsigned int axisIndex, int center, SEMIAXIS_DIRECTION direction, unsigned int range)
- : m_type(SEMIAXIS),
+ : m_type(PRIMITIVE_TYPE::SEMIAXIS),
m_driverIndex(axisIndex),
- m_hatDirection(),
m_center(center),
m_semiAxisDirection(direction),
m_range(range)
@@ -69,12 +53,12 @@ bool CDriverPrimitive::operator==(const CDriverPrimitive& rhs) const
{
switch (m_type)
{
- case BUTTON:
- case MOTOR:
+ case PRIMITIVE_TYPE::BUTTON:
+ case PRIMITIVE_TYPE::MOTOR:
return m_driverIndex == rhs.m_driverIndex;
- case HAT:
+ case PRIMITIVE_TYPE::HAT:
return m_driverIndex == rhs.m_driverIndex && m_hatDirection == rhs.m_hatDirection;
- case SEMIAXIS:
+ case PRIMITIVE_TYPE::SEMIAXIS:
return m_driverIndex == rhs.m_driverIndex &&
m_center == rhs.m_center &&
m_semiAxisDirection == rhs.m_semiAxisDirection &&
@@ -91,20 +75,22 @@ bool CDriverPrimitive::operator<(const CDriverPrimitive& rhs) const
if (m_type < rhs.m_type) return true;
if (m_type > rhs.m_type) return false;
- // Driver index is common to all valid primitives
- if (m_type != UNKNOWN)
+ if (m_type == PRIMITIVE_TYPE::BUTTON ||
+ m_type == PRIMITIVE_TYPE::HAT ||
+ m_type == PRIMITIVE_TYPE::SEMIAXIS ||
+ m_type == PRIMITIVE_TYPE::MOTOR)
{
if (m_driverIndex < rhs.m_driverIndex) return true;
if (m_driverIndex > rhs.m_driverIndex) return false;
}
- if (m_type == HAT)
+ if (m_type == PRIMITIVE_TYPE::HAT)
{
if (m_hatDirection < rhs.m_hatDirection) return true;
if (m_hatDirection > rhs.m_hatDirection) return false;
}
- if (m_type == SEMIAXIS)
+ if (m_type == PRIMITIVE_TYPE::SEMIAXIS)
{
if (m_center < rhs.m_center) return true;
if (m_center > rhs.m_center) return false;
@@ -121,10 +107,11 @@ bool CDriverPrimitive::operator<(const CDriverPrimitive& rhs) const
bool CDriverPrimitive::IsValid(void) const
{
- if (m_type == BUTTON || m_type == MOTOR)
+ if (m_type == PRIMITIVE_TYPE::BUTTON ||
+ m_type == PRIMITIVE_TYPE::MOTOR)
return true;
- if (m_type == HAT)
+ if (m_type == PRIMITIVE_TYPE::HAT)
{
return m_hatDirection == HAT_DIRECTION::UP ||
m_hatDirection == HAT_DIRECTION::DOWN ||
@@ -132,7 +119,7 @@ bool CDriverPrimitive::IsValid(void) const
m_hatDirection == HAT_DIRECTION::LEFT;
}
- if (m_type == SEMIAXIS)
+ if (m_type == PRIMITIVE_TYPE::SEMIAXIS)
{
unsigned int maxRange = 1;
diff --git a/xbmc/input/joysticks/DriverPrimitive.h b/xbmc/input/joysticks/DriverPrimitive.h
index 47b56a35f2..df80271b41 100644
--- a/xbmc/input/joysticks/DriverPrimitive.h
+++ b/xbmc/input/joysticks/DriverPrimitive.h
@@ -105,7 +105,13 @@ namespace JOYSTICK
PRIMITIVE_TYPE Type(void) const { return m_type; }
/*!
- * \brief The index used by the driver (valid for all types)
+ * \brief The index used by the joystick driver
+ *
+ * Valid for:
+ * - buttons
+ * - hats
+ * - semiaxes
+ * - motors
*/
unsigned int Index(void) const { return m_driverIndex; }
@@ -140,12 +146,12 @@ namespace JOYSTICK
bool IsValid(void) const;
private:
- PRIMITIVE_TYPE m_type;
- unsigned int m_driverIndex;
- HAT_DIRECTION m_hatDirection;
- int m_center;
- SEMIAXIS_DIRECTION m_semiAxisDirection;
- unsigned int m_range;
+ PRIMITIVE_TYPE m_type = PRIMITIVE_TYPE::UNKNOWN;
+ unsigned int m_driverIndex = 0;
+ HAT_DIRECTION m_hatDirection = HAT_DIRECTION::UNKNOWN;
+ int m_center = 0;
+ SEMIAXIS_DIRECTION m_semiAxisDirection = SEMIAXIS_DIRECTION::ZERO;
+ unsigned int m_range = 1;
};
}
}
diff --git a/xbmc/input/joysticks/JoystickEasterEgg.cpp b/xbmc/input/joysticks/JoystickEasterEgg.cpp
index f2a13e10ec..b03d91575a 100644
--- a/xbmc/input/joysticks/JoystickEasterEgg.cpp
+++ b/xbmc/input/joysticks/JoystickEasterEgg.cpp
@@ -19,8 +19,8 @@
*/
#include "JoystickEasterEgg.h"
-#include "JoystickIDs.h"
#include "ServiceBroker.h"
+#include "games/controllers/ControllerIDs.h"
#include "guilib/GUIAudioManager.h"
#include "guilib/WindowIDs.h"
#include "settings/Settings.h"
diff --git a/xbmc/input/joysticks/JoystickEasterEgg.h b/xbmc/input/joysticks/JoystickEasterEgg.h
index fc907c4ec5..88a9db792f 100644
--- a/xbmc/input/joysticks/JoystickEasterEgg.h
+++ b/xbmc/input/joysticks/JoystickEasterEgg.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "IButtonSequence.h"
+#include "input/joysticks/interfaces/IButtonSequence.h"
#include <map>
#include <string>
diff --git a/xbmc/input/joysticks/JoystickIDs.h b/xbmc/input/joysticks/JoystickIDs.h
index ea1bad0b58..1225422c34 100644
--- a/xbmc/input/joysticks/JoystickIDs.h
+++ b/xbmc/input/joysticks/JoystickIDs.h
@@ -19,9 +19,6 @@
*/
#pragma once
-#define DEFAULT_CONTROLLER_ID "game.controller.default"
-#define DEFAULT_REMOTE_ID "game.controller.remote"
-
// Analog sticks on the default controller
#define DEFAULT_LEFT_STICK_NAME "leftstick"
#define DEFAULT_RIGHT_STICK_NAME "rightstick"
diff --git a/xbmc/input/joysticks/JoystickMonitor.cpp b/xbmc/input/joysticks/JoystickMonitor.cpp
index 3a04d3045f..8a665e4d56 100644
--- a/xbmc/input/joysticks/JoystickMonitor.cpp
+++ b/xbmc/input/joysticks/JoystickMonitor.cpp
@@ -19,8 +19,8 @@
*/
#include "JoystickMonitor.h"
-#include "JoystickIDs.h"
#include "Application.h"
+#include "games/controllers/ControllerIDs.h"
#include "input/InputManager.h"
#include "ServiceBroker.h"
diff --git a/xbmc/input/joysticks/JoystickMonitor.h b/xbmc/input/joysticks/JoystickMonitor.h
index aaf0cf97cb..b037361e3f 100644
--- a/xbmc/input/joysticks/JoystickMonitor.h
+++ b/xbmc/input/joysticks/JoystickMonitor.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "IInputHandler.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
namespace KODI
{
diff --git a/xbmc/input/joysticks/JoystickTypes.h b/xbmc/input/joysticks/JoystickTypes.h
index 6e505b6748..6690a6b278 100644
--- a/xbmc/input/joysticks/JoystickTypes.h
+++ b/xbmc/input/joysticks/JoystickTypes.h
@@ -88,6 +88,7 @@ namespace JOYSTICK
HARDWARE, // A button or functionality on the console
WHEEL,
JOYSTICK,
+ PADDLE,
};
/*!
@@ -166,7 +167,7 @@ namespace JOYSTICK
/*!
* \brief Type of driver primitive
*/
- enum PRIMITIVE_TYPE
+ enum class PRIMITIVE_TYPE
{
UNKNOWN = 0, // primitive has no type (invalid)
BUTTON, // a digital button
diff --git a/xbmc/input/joysticks/RumbleGenerator.cpp b/xbmc/input/joysticks/RumbleGenerator.cpp
index c4fc8c6c3c..93410b5f30 100644
--- a/xbmc/input/joysticks/RumbleGenerator.cpp
+++ b/xbmc/input/joysticks/RumbleGenerator.cpp
@@ -20,9 +20,9 @@
#include "RumbleGenerator.h"
#include "games/controllers/Controller.h"
+#include "games/controllers/ControllerIDs.h"
#include "games/controllers/ControllerManager.h"
-#include "input/joysticks/IInputReceiver.h"
-#include "input/joysticks/JoystickIDs.h"
+#include "input/joysticks/interfaces/IInputReceiver.h"
#include "ServiceBroker.h"
#include <algorithm>
diff --git a/xbmc/input/joysticks/generic/ButtonMapping.cpp b/xbmc/input/joysticks/generic/ButtonMapping.cpp
index b7e247e590..90cb2a8caa 100644
--- a/xbmc/input/joysticks/generic/ButtonMapping.cpp
+++ b/xbmc/input/joysticks/generic/ButtonMapping.cpp
@@ -22,9 +22,9 @@
#include "games/controllers/Controller.h"
#include "games/controllers/ControllerFeature.h"
#include "games/controllers/ControllerManager.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IButtonMapper.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IButtonMapper.h"
#include "input/joysticks/JoystickTranslator.h"
#include "input/joysticks/JoystickUtils.h"
#include "input/IKeymap.h"
@@ -45,10 +45,25 @@ using namespace XbmcThreads;
#define AXIS_THRESHOLD 0.75f // Axis must exceed this value to be mapped
#define TRIGGER_DELAY_MS 200 // Delay trigger detection to handle anomalous triggers with non-zero center
+// --- CPrimitiveDetector ------------------------------------------------------
+
+CPrimitiveDetector::CPrimitiveDetector(CButtonMapping* buttonMapping) :
+ m_buttonMapping(buttonMapping)
+{
+}
+
+bool CPrimitiveDetector::MapPrimitive(const CDriverPrimitive &primitive)
+{
+ if (primitive.IsValid())
+ return m_buttonMapping->MapPrimitive(primitive);
+
+ return false;
+}
+
// --- CButtonDetector ---------------------------------------------------------
CButtonDetector::CButtonDetector(CButtonMapping* buttonMapping, unsigned int buttonIndex) :
- m_buttonMapping(buttonMapping),
+ CPrimitiveDetector(buttonMapping),
m_buttonIndex(buttonIndex)
{
}
@@ -56,13 +71,7 @@ CButtonDetector::CButtonDetector(CButtonMapping* buttonMapping, unsigned int but
bool CButtonDetector::OnMotion(bool bPressed)
{
if (bPressed)
- {
- CDriverPrimitive buttonPrimitive(PRIMITIVE_TYPE::BUTTON, m_buttonIndex);
- if (buttonPrimitive.IsValid())
- {
- return m_buttonMapping->MapPrimitive(buttonPrimitive);
- }
- }
+ return MapPrimitive(CDriverPrimitive(PRIMITIVE_TYPE::BUTTON, m_buttonIndex));
return false;
}
@@ -70,27 +79,20 @@ bool CButtonDetector::OnMotion(bool bPressed)
// --- CHatDetector ------------------------------------------------------------
CHatDetector::CHatDetector(CButtonMapping* buttonMapping, unsigned int hatIndex) :
- m_buttonMapping(buttonMapping),
+ CPrimitiveDetector(buttonMapping),
m_hatIndex(hatIndex)
{
}
bool CHatDetector::OnMotion(HAT_STATE state)
{
- CDriverPrimitive hatPrimitive(m_hatIndex, static_cast<HAT_DIRECTION>(state));
- if (hatPrimitive.IsValid())
- {
- m_buttonMapping->MapPrimitive(hatPrimitive);
- return true;
- }
-
- return false;
+ return MapPrimitive(CDriverPrimitive(m_hatIndex, static_cast<HAT_DIRECTION>(state)));
}
// --- CAxisDetector -----------------------------------------------------------
CAxisDetector::CAxisDetector(CButtonMapping* buttonMapping, unsigned int axisIndex, const AxisConfiguration& config) :
- m_buttonMapping(buttonMapping),
+ CPrimitiveDetector(buttonMapping),
m_axisIndex(axisIndex),
m_config(config),
m_state(AXIS_STATE::INACTIVE),
@@ -166,7 +168,7 @@ void CAxisDetector::ProcessMotion()
}
// Map primitive
- if (!m_buttonMapping->MapPrimitive(m_activatedPrimitive))
+ if (!MapPrimitive(m_activatedPrimitive))
{
if (m_type == AXIS_TYPE::OFFSET)
CLog::Log(LOGDEBUG, "Mapping offset axis %u failed", m_axisIndex);
diff --git a/xbmc/input/joysticks/generic/ButtonMapping.h b/xbmc/input/joysticks/generic/ButtonMapping.h
index c3f97eb020..e5e31c8414 100644
--- a/xbmc/input/joysticks/generic/ButtonMapping.h
+++ b/xbmc/input/joysticks/generic/ButtonMapping.h
@@ -19,9 +19,9 @@
*/
#pragma once
+#include "input/joysticks/interfaces/IButtonMapCallback.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMapCallback.h"
-#include "input/joysticks/IDriverHandler.h"
#include <map>
#include <stdint.h>
@@ -36,7 +36,35 @@ namespace JOYSTICK
class IButtonMap;
class IButtonMapper;
- class CButtonDetector
+ /*!
+ * \brief Detects and dispatches mapping events
+ *
+ * A mapping event usually occurs when a driver primitive is pressed or
+ * exceeds a certain threshold.
+ *
+ * Detection can be quite complicated due to driver bugs, so each type of
+ * driver primitive is given its own detector class inheriting from this one.
+ */
+ class CPrimitiveDetector
+ {
+ protected:
+ CPrimitiveDetector(CButtonMapping* buttonMapping);
+
+ /*!
+ * \brief Dispatch a mapping event
+ *
+ * \return True if the primitive was mapped, false otherwise
+ */
+ bool MapPrimitive(const CDriverPrimitive &primitive);
+
+ private:
+ CButtonMapping* const m_buttonMapping;
+ };
+
+ /*!
+ * \brief Detects when a button should be mapped
+ */
+ class CButtonDetector : public CPrimitiveDetector
{
public:
CButtonDetector(CButtonMapping* buttonMapping, unsigned int buttonIndex);
@@ -46,18 +74,20 @@ namespace JOYSTICK
*
* \param bPressed The new state
*
- * \return True if this press was absorbed, false if it should fall through
+ * \return True if this press was handled, false if it should fall through
* to the next driver handler
*/
bool OnMotion(bool bPressed);
private:
// Construction parameters
- CButtonMapping* const m_buttonMapping;
const unsigned int m_buttonIndex;
};
- class CHatDetector
+ /*!
+ * \brief Detects when a D-pad direction should be mapped
+ */
+ class CHatDetector : public CPrimitiveDetector
{
public:
CHatDetector(CButtonMapping* buttonMapping, unsigned int hatIndex);
@@ -73,7 +103,6 @@ namespace JOYSTICK
private:
// Construction parameters
- CButtonMapping* const m_buttonMapping;
const unsigned int m_hatIndex;
};
@@ -85,7 +114,10 @@ namespace JOYSTICK
bool bLateDiscovery = false;
};
- class CAxisDetector
+ /*!
+ * \brief Detects when an axis should be mapped
+ */
+ class CAxisDetector : public CPrimitiveDetector
{
public:
CAxisDetector(CButtonMapping* buttonMapping, unsigned int axisIndex, const AxisConfiguration& config);
@@ -178,7 +210,6 @@ namespace JOYSTICK
void DetectType(float position);
// Construction parameters
- CButtonMapping* const m_buttonMapping;
const unsigned int m_axisIndex;
AxisConfiguration m_config; // mutable
diff --git a/xbmc/input/joysticks/generic/DriverReceiving.cpp b/xbmc/input/joysticks/generic/DriverReceiving.cpp
index e41dcc0c69..d0ec4edb41 100644
--- a/xbmc/input/joysticks/generic/DriverReceiving.cpp
+++ b/xbmc/input/joysticks/generic/DriverReceiving.cpp
@@ -19,9 +19,9 @@
*/
#include "DriverReceiving.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IDriverReceiver.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IDriverReceiver.h"
using namespace KODI;
using namespace JOYSTICK;
diff --git a/xbmc/input/joysticks/generic/DriverReceiving.h b/xbmc/input/joysticks/generic/DriverReceiving.h
index 1ab9082ba6..5f5fd8e2d6 100644
--- a/xbmc/input/joysticks/generic/DriverReceiving.h
+++ b/xbmc/input/joysticks/generic/DriverReceiving.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/joysticks/IInputReceiver.h"
+#include "input/joysticks/interfaces/IInputReceiver.h"
#include "input/joysticks/JoystickTypes.h"
#include <map>
diff --git a/xbmc/input/joysticks/generic/FeatureHandling.cpp b/xbmc/input/joysticks/generic/FeatureHandling.cpp
index 1bed74606b..7e186c9472 100644
--- a/xbmc/input/joysticks/generic/FeatureHandling.cpp
+++ b/xbmc/input/joysticks/generic/FeatureHandling.cpp
@@ -21,9 +21,9 @@
#include "FeatureHandling.h"
#include "games/controllers/Controller.h"
#include "games/controllers/ControllerManager.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IInputHandler.h"
#include "threads/SystemClock.h"
#include "utils/log.h"
#include "ServiceBroker.h"
diff --git a/xbmc/input/joysticks/generic/InputHandling.cpp b/xbmc/input/joysticks/generic/InputHandling.cpp
index 1bcf024aea..1e4d9ff01c 100644
--- a/xbmc/input/joysticks/generic/InputHandling.cpp
+++ b/xbmc/input/joysticks/generic/InputHandling.cpp
@@ -20,8 +20,8 @@
#include "InputHandling.h"
#include "input/joysticks/dialogs/GUIDialogNewJoystick.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
#include "input/joysticks/JoystickUtils.h"
#include "utils/log.h"
diff --git a/xbmc/input/joysticks/generic/InputHandling.h b/xbmc/input/joysticks/generic/InputHandling.h
index bed6a33d03..93fc8c25e7 100644
--- a/xbmc/input/joysticks/generic/InputHandling.h
+++ b/xbmc/input/joysticks/generic/InputHandling.h
@@ -20,7 +20,7 @@
#pragma once
#include "FeatureHandling.h"
-#include "input/joysticks/IDriverHandler.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
#include "input/joysticks/JoystickTypes.h"
#include <map>
diff --git a/xbmc/input/joysticks/IButtonMap.h b/xbmc/input/joysticks/interfaces/IButtonMap.h
index 500e1bfe6a..941a3c2cfe 100644
--- a/xbmc/input/joysticks/IButtonMap.h
+++ b/xbmc/input/joysticks/interfaces/IButtonMap.h
@@ -19,8 +19,8 @@
*/
#pragma once
-#include "DriverPrimitive.h"
-#include "JoystickTypes.h"
+#include "input/joysticks/DriverPrimitive.h"
+#include "input/joysticks/JoystickTypes.h"
#include <string>
#include <vector>
diff --git a/xbmc/input/joysticks/IButtonMapCallback.h b/xbmc/input/joysticks/interfaces/IButtonMapCallback.h
index 15e121563a..15e121563a 100644
--- a/xbmc/input/joysticks/IButtonMapCallback.h
+++ b/xbmc/input/joysticks/interfaces/IButtonMapCallback.h
diff --git a/xbmc/input/joysticks/IButtonMapper.h b/xbmc/input/joysticks/interfaces/IButtonMapper.h
index c2f4549536..c2f4549536 100644
--- a/xbmc/input/joysticks/IButtonMapper.h
+++ b/xbmc/input/joysticks/interfaces/IButtonMapper.h
diff --git a/xbmc/input/joysticks/IButtonSequence.h b/xbmc/input/joysticks/interfaces/IButtonSequence.h
index 44dd6a784a..1d44749251 100644
--- a/xbmc/input/joysticks/IButtonSequence.h
+++ b/xbmc/input/joysticks/interfaces/IButtonSequence.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "JoystickTypes.h"
+#include "input/joysticks/JoystickTypes.h"
namespace KODI
{
diff --git a/xbmc/input/joysticks/IDriverHandler.h b/xbmc/input/joysticks/interfaces/IDriverHandler.h
index c6ab1d7a92..bc7d42481e 100644
--- a/xbmc/input/joysticks/IDriverHandler.h
+++ b/xbmc/input/joysticks/interfaces/IDriverHandler.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "JoystickTypes.h"
+#include "input/joysticks/JoystickTypes.h"
namespace KODI
{
diff --git a/xbmc/input/joysticks/IDriverReceiver.h b/xbmc/input/joysticks/interfaces/IDriverReceiver.h
index fffe0ea633..fffe0ea633 100644
--- a/xbmc/input/joysticks/IDriverReceiver.h
+++ b/xbmc/input/joysticks/interfaces/IDriverReceiver.h
diff --git a/xbmc/input/joysticks/IInputHandler.h b/xbmc/input/joysticks/interfaces/IInputHandler.h
index 834843ff30..95f1217461 100644
--- a/xbmc/input/joysticks/IInputHandler.h
+++ b/xbmc/input/joysticks/interfaces/IInputHandler.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "JoystickTypes.h"
+#include "input/joysticks/JoystickTypes.h"
#include <string>
diff --git a/xbmc/input/joysticks/IInputProvider.h b/xbmc/input/joysticks/interfaces/IInputProvider.h
index 20f1be5a0a..20f1be5a0a 100644
--- a/xbmc/input/joysticks/IInputProvider.h
+++ b/xbmc/input/joysticks/interfaces/IInputProvider.h
diff --git a/xbmc/input/joysticks/IInputReceiver.h b/xbmc/input/joysticks/interfaces/IInputReceiver.h
index 22eecda866..96a2a5b174 100644
--- a/xbmc/input/joysticks/IInputReceiver.h
+++ b/xbmc/input/joysticks/interfaces/IInputReceiver.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "JoystickTypes.h"
+#include "input/joysticks/JoystickTypes.h"
namespace KODI
{
diff --git a/xbmc/input/joysticks/keymaps/KeymapHandler.h b/xbmc/input/joysticks/keymaps/KeymapHandler.h
index daa573c8a8..5ad2170f7b 100644
--- a/xbmc/input/joysticks/keymaps/KeymapHandler.h
+++ b/xbmc/input/joysticks/keymaps/KeymapHandler.h
@@ -19,8 +19,8 @@
*/
#pragma once
-#include "input/joysticks/IButtonSequence.h"
-#include "input/joysticks/IInputHandler.h"
+#include "input/joysticks/interfaces/IButtonSequence.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
#include "input/joysticks/interfaces/IKeymapHandler.h"
#include "input/joysticks/JoystickTypes.h"
diff --git a/xbmc/input/joysticks/keymaps/KeymapHandling.cpp b/xbmc/input/joysticks/keymaps/KeymapHandling.cpp
index bff29f9896..90311b68ca 100644
--- a/xbmc/input/joysticks/keymaps/KeymapHandling.cpp
+++ b/xbmc/input/joysticks/keymaps/KeymapHandling.cpp
@@ -20,8 +20,8 @@
#include "KeymapHandling.h"
#include "KeymapHandler.h"
-#include "input/joysticks/IInputHandler.h"
-#include "input/joysticks/IInputProvider.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
+#include "input/joysticks/interfaces/IInputProvider.h"
#include "input/Keymap.h"
#include "input/ButtonTranslator.h"
#include "input/InputManager.h"
diff --git a/xbmc/input/keyboard/CMakeLists.txt b/xbmc/input/keyboard/CMakeLists.txt
index 517dab53c5..8cfa745ca7 100644
--- a/xbmc/input/keyboard/CMakeLists.txt
+++ b/xbmc/input/keyboard/CMakeLists.txt
@@ -2,9 +2,9 @@ set(SOURCES KeyboardEasterEgg.cpp
KeymapActionMap.cpp
)
-set(HEADERS IActionMap.h
- IKeyboardHandler.h
- IKeyboardInputProvider.h
+set(HEADERS interfaces/IActionMap.h
+ interfaces/IKeyboardHandler.h
+ interfaces/IKeyboardInputProvider.h
KeyboardEasterEgg.h
KeymapActionMap.h
)
diff --git a/xbmc/input/keyboard/KeyboardEasterEgg.h b/xbmc/input/keyboard/KeyboardEasterEgg.h
index a1a28a226f..a624f1342a 100644
--- a/xbmc/input/keyboard/KeyboardEasterEgg.h
+++ b/xbmc/input/keyboard/KeyboardEasterEgg.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "IKeyboardHandler.h"
+#include "input/keyboard/interfaces/IKeyboardHandler.h"
#include "input/XBMC_vkeys.h"
#include <vector>
diff --git a/xbmc/input/keyboard/KeymapActionMap.h b/xbmc/input/keyboard/KeymapActionMap.h
index fbbc6f1e3f..1a805aabc0 100644
--- a/xbmc/input/keyboard/KeymapActionMap.h
+++ b/xbmc/input/keyboard/KeymapActionMap.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/keyboard/IActionMap.h"
+#include "input/keyboard/interfaces/IActionMap.h"
namespace KODI
{
diff --git a/xbmc/input/keyboard/generic/JoystickEmulation.cpp b/xbmc/input/keyboard/generic/JoystickEmulation.cpp
index 2d17fb7e11..b4eb0c9502 100644
--- a/xbmc/input/keyboard/generic/JoystickEmulation.cpp
+++ b/xbmc/input/keyboard/generic/JoystickEmulation.cpp
@@ -19,7 +19,7 @@
*/
#include "JoystickEmulation.h"
-#include "input/joysticks/IDriverHandler.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
#include "input/Key.h"
#include <algorithm>
diff --git a/xbmc/input/keyboard/generic/JoystickEmulation.h b/xbmc/input/keyboard/generic/JoystickEmulation.h
index cf6c33c954..2d6b5290a7 100644
--- a/xbmc/input/keyboard/generic/JoystickEmulation.h
+++ b/xbmc/input/keyboard/generic/JoystickEmulation.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/keyboard/IKeyboardHandler.h"
+#include "input/keyboard/interfaces/IKeyboardHandler.h"
#include <vector>
diff --git a/xbmc/input/keyboard/IActionMap.h b/xbmc/input/keyboard/interfaces/IActionMap.h
index ae89742d41..ae89742d41 100644
--- a/xbmc/input/keyboard/IActionMap.h
+++ b/xbmc/input/keyboard/interfaces/IActionMap.h
diff --git a/xbmc/input/keyboard/IKeyboardHandler.h b/xbmc/input/keyboard/interfaces/IKeyboardHandler.h
index 64855a1f30..64855a1f30 100644
--- a/xbmc/input/keyboard/IKeyboardHandler.h
+++ b/xbmc/input/keyboard/interfaces/IKeyboardHandler.h
diff --git a/xbmc/input/keyboard/IKeyboardInputProvider.h b/xbmc/input/keyboard/interfaces/IKeyboardInputProvider.h
index eeb7d8719f..eeb7d8719f 100644
--- a/xbmc/input/keyboard/IKeyboardInputProvider.h
+++ b/xbmc/input/keyboard/interfaces/IKeyboardInputProvider.h
diff --git a/xbmc/input/mouse/CMakeLists.txt b/xbmc/input/mouse/CMakeLists.txt
index a99651611b..bebe854d7a 100644
--- a/xbmc/input/mouse/CMakeLists.txt
+++ b/xbmc/input/mouse/CMakeLists.txt
@@ -1,9 +1,9 @@
set(SOURCES MouseWindowingButtonMap.cpp)
-set(HEADERS IMouseButtonMap.h
- IMouseDriverHandler.h
- IMouseInputHandler.h
- IMouseInputProvider.h
+set(HEADERS interfaces/IMouseButtonMap.h
+ interfaces/IMouseDriverHandler.h
+ interfaces/IMouseInputHandler.h
+ interfaces/IMouseInputProvider.h
MouseWindowingButtonMap.h)
core_add_library(input_mouse)
diff --git a/xbmc/input/mouse/MouseWindowingButtonMap.h b/xbmc/input/mouse/MouseWindowingButtonMap.h
index 335160bc31..55262178ac 100644
--- a/xbmc/input/mouse/MouseWindowingButtonMap.h
+++ b/xbmc/input/mouse/MouseWindowingButtonMap.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/mouse/IMouseButtonMap.h"
+#include "input/mouse/interfaces/IMouseButtonMap.h"
#include <string>
#include <utility>
diff --git a/xbmc/input/mouse/generic/MouseInputHandling.cpp b/xbmc/input/mouse/generic/MouseInputHandling.cpp
index d91e3b08bf..a4e55e63c1 100644
--- a/xbmc/input/mouse/generic/MouseInputHandling.cpp
+++ b/xbmc/input/mouse/generic/MouseInputHandling.cpp
@@ -19,8 +19,8 @@
*/
#include "MouseInputHandling.h"
-#include "input/mouse/IMouseButtonMap.h"
-#include "input/mouse/IMouseInputHandler.h"
+#include "input/mouse/interfaces/IMouseButtonMap.h"
+#include "input/mouse/interfaces/IMouseInputHandler.h"
using namespace KODI;
using namespace MOUSE;
diff --git a/xbmc/input/mouse/generic/MouseInputHandling.h b/xbmc/input/mouse/generic/MouseInputHandling.h
index 8f86c0026c..e41973534c 100644
--- a/xbmc/input/mouse/generic/MouseInputHandling.h
+++ b/xbmc/input/mouse/generic/MouseInputHandling.h
@@ -19,7 +19,7 @@
*/
#pragma once
-#include "input/mouse/IMouseDriverHandler.h"
+#include "input/mouse/interfaces/IMouseDriverHandler.h"
namespace KODI
{
diff --git a/xbmc/input/mouse/IMouseButtonMap.h b/xbmc/input/mouse/interfaces/IMouseButtonMap.h
index b237f483ad..b237f483ad 100644
--- a/xbmc/input/mouse/IMouseButtonMap.h
+++ b/xbmc/input/mouse/interfaces/IMouseButtonMap.h
diff --git a/xbmc/input/mouse/IMouseDriverHandler.h b/xbmc/input/mouse/interfaces/IMouseDriverHandler.h
index 41f7096d57..41f7096d57 100644
--- a/xbmc/input/mouse/IMouseDriverHandler.h
+++ b/xbmc/input/mouse/interfaces/IMouseDriverHandler.h
diff --git a/xbmc/input/mouse/IMouseInputHandler.h b/xbmc/input/mouse/interfaces/IMouseInputHandler.h
index 1e9e093cc2..1e9e093cc2 100644
--- a/xbmc/input/mouse/IMouseInputHandler.h
+++ b/xbmc/input/mouse/interfaces/IMouseInputHandler.h
diff --git a/xbmc/input/mouse/IMouseInputProvider.h b/xbmc/input/mouse/interfaces/IMouseInputProvider.h
index b2069aa1e6..b2069aa1e6 100644
--- a/xbmc/input/mouse/IMouseInputProvider.h
+++ b/xbmc/input/mouse/interfaces/IMouseInputProvider.h
diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp
index d42478165d..9ec71c1942 100644
--- a/xbmc/peripherals/Peripherals.cpp
+++ b/xbmc/peripherals/Peripherals.cpp
@@ -46,7 +46,7 @@
#include "dialogs/GUIDialogKaiToast.h"
#include "FileItem.h"
#include "bus/virtual/PeripheralBusApplication.h"
-#include "input/joysticks/IButtonMapper.h"
+#include "input/joysticks/interfaces/IButtonMapper.h"
#include "interfaces/AnnouncementManager.h"
#include "filesystem/Directory.h"
#include "guilib/GUIWindowManager.h"
diff --git a/xbmc/peripherals/addons/AddonButtonMap.cpp b/xbmc/peripherals/addons/AddonButtonMap.cpp
index 6e440b6c85..d5375d6243 100644
--- a/xbmc/peripherals/addons/AddonButtonMap.cpp
+++ b/xbmc/peripherals/addons/AddonButtonMap.cpp
@@ -518,6 +518,30 @@ CAddonButtonMap::DriverMap CAddonButtonMap::CreateLookupTable(const FeatureMap&
break;
}
+ case JOYSTICK_FEATURE_TYPE_WHEEL:
+ {
+ std::vector<JOYSTICK_FEATURE_PRIMITIVE> primitives = {
+ JOYSTICK_WHEEL_LEFT,
+ JOYSTICK_WHEEL_RIGHT,
+ };
+
+ for (auto primitive : primitives)
+ driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(primitive))] = it->first;
+ break;
+ }
+
+ case JOYSTICK_FEATURE_TYPE_THROTTLE:
+ {
+ std::vector<JOYSTICK_FEATURE_PRIMITIVE> primitives = {
+ JOYSTICK_THROTTLE_UP,
+ JOYSTICK_THROTTLE_DOWN,
+ };
+
+ for (auto primitive : primitives)
+ driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(primitive))] = it->first;
+ break;
+ }
+
default:
break;
}
diff --git a/xbmc/peripherals/addons/AddonButtonMap.h b/xbmc/peripherals/addons/AddonButtonMap.h
index 67b10dbcda..5eeb7c9177 100644
--- a/xbmc/peripherals/addons/AddonButtonMap.h
+++ b/xbmc/peripherals/addons/AddonButtonMap.h
@@ -21,8 +21,8 @@
#include "PeripheralAddon.h" // for FeatureMap
#include "addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
#include "input/joysticks/JoystickTypes.h"
#include "peripherals/PeripheralTypes.h"
#include "threads/CriticalSection.h"
diff --git a/xbmc/peripherals/addons/AddonButtonMapping.cpp b/xbmc/peripherals/addons/AddonButtonMapping.cpp
index 0ef744803b..d49408e88a 100644
--- a/xbmc/peripherals/addons/AddonButtonMapping.cpp
+++ b/xbmc/peripherals/addons/AddonButtonMapping.cpp
@@ -20,7 +20,7 @@
#include "AddonButtonMapping.h"
#include "input/joysticks/generic/ButtonMapping.h"
-#include "input/joysticks/IButtonMapper.h"
+#include "input/joysticks/interfaces/IButtonMapper.h"
#include "peripherals/addons/AddonButtonMap.h"
#include "peripherals/Peripherals.h"
#include "utils/log.h"
diff --git a/xbmc/peripherals/addons/AddonButtonMapping.h b/xbmc/peripherals/addons/AddonButtonMapping.h
index fef30a8b38..b8a84111a9 100644
--- a/xbmc/peripherals/addons/AddonButtonMapping.h
+++ b/xbmc/peripherals/addons/AddonButtonMapping.h
@@ -19,8 +19,8 @@
*/
#pragma once
-#include "input/joysticks/IButtonMapCallback.h"
-#include "input/joysticks/IDriverHandler.h"
+#include "input/joysticks/interfaces/IButtonMapCallback.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
#include <memory>
diff --git a/xbmc/peripherals/addons/AddonInputHandling.cpp b/xbmc/peripherals/addons/AddonInputHandling.cpp
index fdaf785afd..ce0b4b3819 100644
--- a/xbmc/peripherals/addons/AddonInputHandling.cpp
+++ b/xbmc/peripherals/addons/AddonInputHandling.cpp
@@ -21,8 +21,8 @@
#include "AddonInputHandling.h"
#include "input/joysticks/generic/DriverReceiving.h"
#include "input/joysticks/generic/InputHandling.h"
-#include "input/joysticks/IInputHandler.h"
-#include "input/joysticks/IDriverReceiver.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
+#include "input/joysticks/interfaces/IDriverReceiver.h"
#include "peripherals/addons/AddonButtonMap.h"
#include "peripherals/devices/PeripheralJoystick.h"
#include "peripherals/Peripherals.h"
diff --git a/xbmc/peripherals/addons/AddonInputHandling.h b/xbmc/peripherals/addons/AddonInputHandling.h
index fbdaeadb7e..ce23114aa4 100644
--- a/xbmc/peripherals/addons/AddonInputHandling.h
+++ b/xbmc/peripherals/addons/AddonInputHandling.h
@@ -19,8 +19,8 @@
*/
#pragma once
-#include "input/joysticks/IDriverHandler.h"
-#include "input/joysticks/IInputReceiver.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
+#include "input/joysticks/interfaces/IInputReceiver.h"
#include <memory>
diff --git a/xbmc/peripherals/addons/PeripheralAddon.cpp b/xbmc/peripherals/addons/PeripheralAddon.cpp
index 2c86968f51..b35a9c3746 100644
--- a/xbmc/peripherals/addons/PeripheralAddon.cpp
+++ b/xbmc/peripherals/addons/PeripheralAddon.cpp
@@ -28,9 +28,9 @@
#include "filesystem/SpecialProtocol.h"
#include "games/controllers/Controller.h"
#include "games/controllers/ControllerManager.h"
+#include "input/joysticks/interfaces/IButtonMap.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
#include "input/joysticks/DriverPrimitive.h"
-#include "input/joysticks/IButtonMap.h"
-#include "input/joysticks/IDriverHandler.h"
#include "input/joysticks/JoystickTranslator.h"
#include "input/joysticks/JoystickUtils.h"
#include "peripherals/Peripherals.h"
diff --git a/xbmc/peripherals/addons/PeripheralAddonTranslator.cpp b/xbmc/peripherals/addons/PeripheralAddonTranslator.cpp
index 152b5b1ac2..4af54d433b 100644
--- a/xbmc/peripherals/addons/PeripheralAddonTranslator.cpp
+++ b/xbmc/peripherals/addons/PeripheralAddonTranslator.cpp
@@ -126,22 +126,22 @@ kodi::addon::DriverPrimitive CPeripheralAddonTranslator::TranslatePrimitive(cons
switch (primitive.Type())
{
- case BUTTON:
+ case PRIMITIVE_TYPE::BUTTON:
{
retVal = kodi::addon::DriverPrimitive::CreateButton(primitive.Index());
break;
}
- case HAT:
+ case PRIMITIVE_TYPE::HAT:
{
retVal = kodi::addon::DriverPrimitive(primitive.Index(), TranslateHatDirection(primitive.HatDirection()));
break;
}
- case SEMIAXIS:
+ case PRIMITIVE_TYPE::SEMIAXIS:
{
retVal = kodi::addon::DriverPrimitive(primitive.Index(), primitive.Center(), TranslateSemiAxisDirection(primitive.SemiAxisDirection()), primitive.Range());
break;
}
- case MOTOR:
+ case PRIMITIVE_TYPE::MOTOR:
{
retVal = kodi::addon::DriverPrimitive::CreateMotor(primitive.Index());
break;
diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp
index 18631d9051..0a109f112f 100644
--- a/xbmc/peripherals/devices/Peripheral.cpp
+++ b/xbmc/peripherals/devices/Peripheral.cpp
@@ -23,7 +23,7 @@
#include <utility>
#include "guilib/LocalizeStrings.h"
-#include "input/joysticks/IInputHandler.h"
+#include "input/joysticks/interfaces/IInputHandler.h"
#include "peripherals/addons/PeripheralAddon.h"
#include "peripherals/bus/virtual/PeripheralBusAddon.h"
#include "peripherals/Peripherals.h"
@@ -586,22 +586,24 @@ void CPeripheral::UnregisterInputHandler(IInputHandler* handler)
void CPeripheral::RegisterJoystickButtonMapper(IButtonMapper* mapper)
{
- std::map<IButtonMapper*, IDriverHandler*>::iterator it = m_buttonMappers.find(mapper);
+ auto it = m_buttonMappers.find(mapper);
if (it == m_buttonMappers.end())
{
- IDriverHandler* addonMapping = new CAddonButtonMapping(m_manager, this, mapper);
- RegisterJoystickDriverHandler(addonMapping, false);
- m_buttonMappers[mapper] = addonMapping;
+ std::unique_ptr<CAddonButtonMapping> addonMapping(new CAddonButtonMapping(m_manager, this, mapper));
+
+ RegisterJoystickDriverHandler(addonMapping.get(), false);
+
+ m_buttonMappers[mapper] = std::move(addonMapping);
}
}
void CPeripheral::UnregisterJoystickButtonMapper(IButtonMapper* mapper)
{
- std::map<IButtonMapper*, IDriverHandler*>::iterator it = m_buttonMappers.find(mapper);
+ auto it = m_buttonMappers.find(mapper);
if (it != m_buttonMappers.end())
{
- UnregisterJoystickDriverHandler(it->second);
- delete it->second;
+ UnregisterJoystickDriverHandler(it->second.get());
+
m_buttonMappers.erase(it);
}
}
diff --git a/xbmc/peripherals/devices/Peripheral.h b/xbmc/peripherals/devices/Peripheral.h
index a14ec330a5..953121318a 100644
--- a/xbmc/peripherals/devices/Peripheral.h
+++ b/xbmc/peripherals/devices/Peripheral.h
@@ -24,7 +24,7 @@
#include <string>
#include <vector>
-#include "input/joysticks/IInputProvider.h"
+#include "input/joysticks/interfaces/IInputProvider.h"
#include "peripherals/PeripheralTypes.h"
class TiXmlDocument;
@@ -44,6 +44,7 @@ namespace JOYSTICK
namespace PERIPHERALS
{
+ class CAddonButtonMapping;
class CGUIDialogPeripheralSettings;
class CPeripheralBus;
class CPeripherals;
@@ -237,6 +238,6 @@ namespace PERIPHERALS
std::set<std::string> m_changedSettings;
CPeripheralBus* m_bus;
std::map<KODI::JOYSTICK::IInputHandler*, std::unique_ptr<KODI::JOYSTICK::IDriverHandler>> m_inputHandlers;
- std::map<KODI::JOYSTICK::IButtonMapper*, KODI::JOYSTICK::IDriverHandler*> m_buttonMappers;
+ std::map<KODI::JOYSTICK::IButtonMapper*, std::unique_ptr<CAddonButtonMapping>> m_buttonMappers;
};
}
diff --git a/xbmc/peripherals/devices/PeripheralJoystick.cpp b/xbmc/peripherals/devices/PeripheralJoystick.cpp
index 58f03b5280..ff97956163 100644
--- a/xbmc/peripherals/devices/PeripheralJoystick.cpp
+++ b/xbmc/peripherals/devices/PeripheralJoystick.cpp
@@ -19,10 +19,10 @@
*/
#include "PeripheralJoystick.h"
+#include "games/controllers/ControllerIDs.h"
+#include "input/joysticks/interfaces/IDriverHandler.h"
#include "input/joysticks/keymaps/KeymapHandling.h"
#include "input/joysticks/DeadzoneFilter.h"
-#include "input/joysticks/IDriverHandler.h"
-#include "input/joysticks/JoystickIDs.h"
#include "input/joysticks/JoystickMonitor.h"
#include "input/joysticks/JoystickTranslator.h"
#include "input/joysticks/RumbleGenerator.h"
diff --git a/xbmc/peripherals/devices/PeripheralJoystick.h b/xbmc/peripherals/devices/PeripheralJoystick.h
index a0ffef300b..0d1f6dc5eb 100644
--- a/xbmc/peripherals/devices/PeripheralJoystick.h
+++ b/xbmc/peripherals/devices/PeripheralJoystick.h
@@ -20,7 +20,7 @@
#pragma once
#include "Peripheral.h"
-#include "input/joysticks/IDriverReceiver.h"
+#include "input/joysticks/interfaces/IDriverReceiver.h"
#include "input/joysticks/JoystickTypes.h"
#include "threads/CriticalSection.h"
diff --git a/xbmc/peripherals/devices/PeripheralJoystickEmulation.h b/xbmc/peripherals/devices/PeripheralJoystickEmulation.h
index 0c36363c96..0c2cb0a87d 100644
--- a/xbmc/peripherals/devices/PeripheralJoystickEmulation.h
+++ b/xbmc/peripherals/devices/PeripheralJoystickEmulation.h
@@ -20,7 +20,7 @@
#pragma once
#include "Peripheral.h"
-#include "input/keyboard/IKeyboardHandler.h"
+#include "input/keyboard/interfaces/IKeyboardHandler.h"
#include "threads/CriticalSection.h"
#include <vector>