aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/game.controller.default/resources/layout.xml22
-rw-r--r--xbmc/games/controllers/ControllerDefinitions.h11
-rw-r--r--xbmc/games/controllers/ControllerFeature.cpp29
-rw-r--r--xbmc/games/controllers/ControllerFeature.h4
-rw-r--r--xbmc/games/controllers/ControllerLayout.cpp11
-rw-r--r--xbmc/games/controllers/ControllerTranslator.cpp28
-rw-r--r--xbmc/games/controllers/ControllerTranslator.h3
-rw-r--r--xbmc/input/joysticks/JoystickTypes.h17
8 files changed, 100 insertions, 25 deletions
diff --git a/addons/game.controller.default/resources/layout.xml b/addons/game.controller.default/resources/layout.xml
index 77a308e7aa..b8df0e6b41 100644
--- a/addons/game.controller.default/resources/layout.xml
+++ b/addons/game.controller.default/resources/layout.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<layout name="default" label="30000" image="layout.png">
- <face>
+ <category name="face">
<button name="a" type="digital" label="30001" geometry="circle" x="651" y="266" radius="32"/>
<button name="b" type="digital" label="30002" geometry="circle" x="709" y="210" radius="32"/>
<button name="x" type="digital" label="30003" geometry="circle" x="583" y="210" radius="32"/>
@@ -9,22 +9,26 @@
<button name="back" type="digital" label="30006" geometry="ellipse" x="290" y="227" rx="22" ry="16"/>
<button name="guide" type="digital" label="30007" geometry="circle" x="386" y="221" radius="50"/>
<button name="up" type="digital" label="30010" geometry="circle" x="117" y="234" r="52"/>
- <button name="down" type="digital" label="30011" geometry="circle" x="500" y="342" r="52"/>
<button name="right" type="digital" label="30012" geometry="rectangle" x1="233" y1="288" x2="281" y2="332"/>
+ <button name="down" type="digital" label="30011" geometry="circle" x="500" y="342" r="52"/>
<button name="left" type="digital" label="30013" geometry="rectangle" x1="233" y1="353" x2="281" y2="397"/>
<button name="leftthumb" type="digital" label="30008" geometry="rectangle" x1="131" y1="0" x2="194" y2="40"/>
<button name="rightthumb" type="digital" label="30009" geometry="rectangle" x1="567" y1="0" x2="631" y2="40"/>
- </face>
- <shoulder>
+ </category>
+ <category name="shoulder">
<button name="leftbumper" type="digital" label="30014" geometry="rectangle" x1="272" y1="321" x2="316" y2="365"/>
<button name="rightbumper" type="digital" label="30015" geometry="rectangle" x1="198" y1="321" x2="242" y2="365"/>
- </shoulder>
- <triggers>
+ </category>
+ <category name="triggers">
<button name="lefttrigger" type="analog" label="30016" geometry="rectangle" x1="36" y1="40" x2="207" y2="108"/>
<button name="righttrigger" type="analog" label="30017" geometry="rectangle" x1="556" y1="40" x2="728" y2="108"/>
- </triggers>
- <analogsticks>
+ </category>
+ <category name="analogsticks">
<analogstick name="leftstick" label="30008" geometry="circle" x="500" y="342" r="52"/>
<analogstick name="rightstick" label="30009" geometry="circle" x="500" y="342" r="52"/>
- </analogsticks>
+ </category>
+ <category name="haptics">
+ <motor name="leftmotor"/>
+ <motor name="rightmotor"/>
+ </category>
</layout>
diff --git a/xbmc/games/controllers/ControllerDefinitions.h b/xbmc/games/controllers/ControllerDefinitions.h
index d8119d191b..366d49734f 100644
--- a/xbmc/games/controllers/ControllerDefinitions.h
+++ b/xbmc/games/controllers/ControllerDefinitions.h
@@ -21,14 +21,25 @@
#define LAYOUT_XML_ROOT "layout"
+#define LAYOUT_XML_ELM_CATEGORY "category"
+
#define LAYOUT_XML_ELM_BUTTON "button"
#define LAYOUT_XML_ELM_ANALOG_STICK "analogstick"
#define LAYOUT_XML_ELM_ACCELEROMETER "accelerometer"
+#define LAYOUT_XML_ELM_MOTOR "motor"
#define LAYOUT_XML_ATTR_LAYOUT_LABEL "label"
#define LAYOUT_XML_ATTR_LAYOUT_IMAGE "image"
#define LAYOUT_XML_ATTR_LAYOUT_OVERLAY "overlay"
+#define LAYOUT_XML_ATTR_CATEGORY_NAME "name"
+
+#define LAYOUT_XML_VALUE_CATEGORY_FACE "face"
+#define LAYOUT_XML_VALUE_CATEGORY_SHOULDER "shoulder"
+#define LAYOUT_XML_VALUE_CATEGORY_TRIGGERS "triggers"
+#define LAYOUT_XML_VALUE_CATEGORY_ANALOG_STICKS "analogsticks"
+#define LAYOUT_XML_VALUE_CATEGORY_HAPTICS "haptics"
+
#define LAYOUT_XML_ATTR_FEATURE_NAME "name"
#define LAYOUT_XML_ATTR_FEATURE_LABEL "label"
diff --git a/xbmc/games/controllers/ControllerFeature.cpp b/xbmc/games/controllers/ControllerFeature.cpp
index dfaea4dd5a..4c6eadf9b7 100644
--- a/xbmc/games/controllers/ControllerFeature.cpp
+++ b/xbmc/games/controllers/ControllerFeature.cpp
@@ -34,6 +34,7 @@ using namespace JOYSTICK;
void CControllerFeature::Reset(void)
{
m_type = FEATURE_TYPE::UNKNOWN;
+ m_category = FEATURE_CATEGORY::UNKNOWN;
m_strName.clear();
m_strLabel.clear();
m_labelId = 0;
@@ -45,6 +46,7 @@ CControllerFeature& CControllerFeature::operator=(const CControllerFeature& rhs)
if (this != &rhs)
{
m_type = rhs.m_type;
+ m_category = rhs.m_category;
m_strName = rhs.m_strName;
m_strLabel = rhs.m_strLabel;
m_labelId = rhs.m_labelId;
@@ -53,7 +55,7 @@ CControllerFeature& CControllerFeature::operator=(const CControllerFeature& rhs)
return *this;
}
-bool CControllerFeature::Deserialize(const TiXmlElement* pElement, const CController* controller)
+bool CControllerFeature::Deserialize(const TiXmlElement* pElement, const CController* controller, const std::string& strCategory)
{
Reset();
@@ -70,6 +72,9 @@ bool CControllerFeature::Deserialize(const TiXmlElement* pElement, const CContro
return false;
}
+ // Category was obtained from parent XML node
+ m_category = CControllerTranslator::TranslateCategory(strCategory);
+
// Name
m_strName = XMLUtils::GetAttribute(pElement, LAYOUT_XML_ATTR_FEATURE_NAME);
if (m_strName.empty())
@@ -78,17 +83,21 @@ bool CControllerFeature::Deserialize(const TiXmlElement* pElement, const CContro
return false;
}
- // Label ID
- std::string strLabel = XMLUtils::GetAttribute(pElement, LAYOUT_XML_ATTR_FEATURE_LABEL);
- if (strLabel.empty())
+ // Label (not used for motors)
+ if (m_type != FEATURE_TYPE::MOTOR)
{
- CLog::Log(LOGERROR, "<%s> tag has no \"%s\" attribute", strType.c_str(), LAYOUT_XML_ATTR_FEATURE_LABEL);
- return false;
- }
- std::istringstream(strLabel) >> m_labelId;
+ // Label ID
+ std::string strLabel = XMLUtils::GetAttribute(pElement, LAYOUT_XML_ATTR_FEATURE_LABEL);
+ if (strLabel.empty())
+ {
+ CLog::Log(LOGERROR, "<%s> tag has no \"%s\" attribute", strType.c_str(), LAYOUT_XML_ATTR_FEATURE_LABEL);
+ return false;
+ }
+ std::istringstream(strLabel) >> m_labelId;
- // Label (string)
- m_strLabel = g_localizeStrings.GetAddonString(controller->ID(), m_labelId);
+ // Label (string)
+ m_strLabel = g_localizeStrings.GetAddonString(controller->ID(), m_labelId);
+ }
// Input type
if (m_type == FEATURE_TYPE::SCALAR)
diff --git a/xbmc/games/controllers/ControllerFeature.h b/xbmc/games/controllers/ControllerFeature.h
index 8b2c104c4c..b68b02d4db 100644
--- a/xbmc/games/controllers/ControllerFeature.h
+++ b/xbmc/games/controllers/ControllerFeature.h
@@ -40,15 +40,17 @@ public:
CControllerFeature& operator=(const CControllerFeature& rhs);
JOYSTICK::FEATURE_TYPE Type(void) const { return m_type; }
+ JOYSTICK::FEATURE_CATEGORY Category(void) const { return m_category; }
const std::string& Name(void) const { return m_strName; }
const std::string& Label(void) const { return m_strLabel; }
unsigned int LabelID(void) const { return m_labelId; }
JOYSTICK::INPUT_TYPE InputType(void) const { return m_inputType; }
- bool Deserialize(const TiXmlElement* pElement, const CController* controller);
+ bool Deserialize(const TiXmlElement* pElement, const CController* controller, const std::string& strCategory);
private:
JOYSTICK::FEATURE_TYPE m_type;
+ JOYSTICK::FEATURE_CATEGORY m_category;
std::string m_strName;
std::string m_strLabel;
unsigned int m_labelId;
diff --git a/xbmc/games/controllers/ControllerLayout.cpp b/xbmc/games/controllers/ControllerLayout.cpp
index 34234fdedc..6ee6200b01 100644
--- a/xbmc/games/controllers/ControllerLayout.cpp
+++ b/xbmc/games/controllers/ControllerLayout.cpp
@@ -100,17 +100,18 @@ bool CControllerLayout::Deserialize(const TiXmlElement* pElement, const CControl
CLog::Log(LOGDEBUG, "<%s> tag has no \"%s\" attribute", LAYOUT_XML_ROOT, LAYOUT_XML_ATTR_LAYOUT_OVERLAY);
// Features
- for (const TiXmlElement* pCategory = pElement->FirstChildElement(); pCategory != NULL; pCategory = pCategory->NextSiblingElement())
+ for (const TiXmlElement* pCategory = pElement->FirstChildElement(); pCategory != nullptr; pCategory = pCategory->NextSiblingElement())
{
- std::string strCategory = pElement->Value();
+ if (std::string(pCategory->Value()) != std::string(LAYOUT_XML_ELM_CATEGORY))
+ continue;
- //! @todo Something with category
+ const std::string strCategoryName = XMLUtils::GetAttribute(pCategory, LAYOUT_XML_ATTR_CATEGORY_NAME);
- for (const TiXmlElement* pFeature = pCategory->FirstChildElement(); pFeature != NULL; pFeature = pFeature->NextSiblingElement())
+ for (const TiXmlElement* pFeature = pCategory->FirstChildElement(); pFeature != nullptr; pFeature = pFeature->NextSiblingElement())
{
CControllerFeature feature;
- if (!feature.Deserialize(pFeature, controller))
+ if (!feature.Deserialize(pFeature, controller, strCategoryName))
return false;
m_features.push_back(feature);
diff --git a/xbmc/games/controllers/ControllerTranslator.cpp b/xbmc/games/controllers/ControllerTranslator.cpp
index 9cb42a1a5e..275b87aaf4 100644
--- a/xbmc/games/controllers/ControllerTranslator.cpp
+++ b/xbmc/games/controllers/ControllerTranslator.cpp
@@ -31,6 +31,7 @@ const char* CControllerTranslator::TranslateFeatureType(FEATURE_TYPE type)
case FEATURE_TYPE::SCALAR: return LAYOUT_XML_ELM_BUTTON;
case FEATURE_TYPE::ANALOG_STICK: return LAYOUT_XML_ELM_ANALOG_STICK;
case FEATURE_TYPE::ACCELEROMETER: return LAYOUT_XML_ELM_ACCELEROMETER;
+ case FEATURE_TYPE::MOTOR: return LAYOUT_XML_ELM_MOTOR;
default:
break;
}
@@ -42,10 +43,37 @@ FEATURE_TYPE CControllerTranslator::TranslateFeatureType(const std::string& strT
if (strType == LAYOUT_XML_ELM_BUTTON) return FEATURE_TYPE::SCALAR;
if (strType == LAYOUT_XML_ELM_ANALOG_STICK) return FEATURE_TYPE::ANALOG_STICK;
if (strType == LAYOUT_XML_ELM_ACCELEROMETER) return FEATURE_TYPE::ACCELEROMETER;
+ if (strType == LAYOUT_XML_ELM_MOTOR) return FEATURE_TYPE::MOTOR;
return FEATURE_TYPE::UNKNOWN;
}
+const char* CControllerTranslator::TranslateCategory(FEATURE_CATEGORY category)
+{
+ switch (category)
+ {
+ case FEATURE_CATEGORY::FACE: return LAYOUT_XML_VALUE_CATEGORY_FACE;
+ case FEATURE_CATEGORY::SHOULDER: return LAYOUT_XML_VALUE_CATEGORY_SHOULDER;
+ case FEATURE_CATEGORY::TRIGGERS: return LAYOUT_XML_VALUE_CATEGORY_TRIGGERS;
+ case FEATURE_CATEGORY::ANALOG_STICKS: return LAYOUT_XML_VALUE_CATEGORY_ANALOG_STICKS;
+ case FEATURE_CATEGORY::HAPTICS: return LAYOUT_XML_VALUE_CATEGORY_HAPTICS;
+ default:
+ break;
+ }
+ return "";
+}
+
+FEATURE_CATEGORY CControllerTranslator::TranslateCategory(const std::string& strCategory)
+{
+ if (strCategory == LAYOUT_XML_VALUE_CATEGORY_FACE) return FEATURE_CATEGORY::FACE;
+ if (strCategory == LAYOUT_XML_VALUE_CATEGORY_SHOULDER) return FEATURE_CATEGORY::SHOULDER;
+ if (strCategory == LAYOUT_XML_VALUE_CATEGORY_TRIGGERS) return FEATURE_CATEGORY::TRIGGERS;
+ if (strCategory == LAYOUT_XML_VALUE_CATEGORY_ANALOG_STICKS) return FEATURE_CATEGORY::ANALOG_STICKS;
+ if (strCategory == LAYOUT_XML_VALUE_CATEGORY_HAPTICS) return FEATURE_CATEGORY::HAPTICS;
+
+ return FEATURE_CATEGORY::UNKNOWN;
+}
+
const char* CControllerTranslator::TranslateInputType(INPUT_TYPE type)
{
switch (type)
diff --git a/xbmc/games/controllers/ControllerTranslator.h b/xbmc/games/controllers/ControllerTranslator.h
index c7436134e4..c2c70b3030 100644
--- a/xbmc/games/controllers/ControllerTranslator.h
+++ b/xbmc/games/controllers/ControllerTranslator.h
@@ -33,6 +33,9 @@ public:
static const char* TranslateFeatureType(JOYSTICK::FEATURE_TYPE type);
static JOYSTICK::FEATURE_TYPE TranslateFeatureType(const std::string& strType);
+ static const char* TranslateCategory(JOYSTICK::FEATURE_CATEGORY category);
+ static JOYSTICK::FEATURE_CATEGORY TranslateCategory(const std::string& strCategory);
+
static const char* TranslateInputType(JOYSTICK::INPUT_TYPE type);
static JOYSTICK::INPUT_TYPE TranslateInputType(const std::string& strType);
};
diff --git a/xbmc/input/joysticks/JoystickTypes.h b/xbmc/input/joysticks/JoystickTypes.h
index fee25bdb44..dce8a46215 100644
--- a/xbmc/input/joysticks/JoystickTypes.h
+++ b/xbmc/input/joysticks/JoystickTypes.h
@@ -36,6 +36,7 @@ namespace JOYSTICK
* 1) scalar[1]
* 2) analog stick
* 3) accelerometer
+ * 4) rumble motor
*
* [1] All three driver primitives (buttons, hats and axes) have a state that
* can be represented using a single scalar value. For this reason,
@@ -47,6 +48,22 @@ namespace JOYSTICK
SCALAR,
ANALOG_STICK,
ACCELEROMETER,
+ MOTOR,
+ };
+
+ /*!
+ * \brief Types of categories that features can belong to
+ *
+ * Used to separate lists of features in the GUI.
+ */
+ enum class FEATURE_CATEGORY
+ {
+ UNKNOWN,
+ FACE,
+ SHOULDER,
+ TRIGGERS,
+ ANALOG_STICKS,
+ HAPTICS,
};
/*!