summaryrefslogtreecommitdiffstats
path: root/src/controllers/controllerpresetinfo.cpp
diff options
context:
space:
mode:
authorBe <be@mixxx.org>2020-12-20 11:11:25 -0600
committerBe <be@mixxx.org>2020-12-20 12:43:43 -0600
commite2b8cd7bc038d8fab2a86ce11c7e0147a119e58e (patch)
tree09133d12756cb8e4fcf27ba5c0254e9e3f29b939 /src/controllers/controllerpresetinfo.cpp
parent7b00e93db045560bb961ddb57da4bc5c605ca8d0 (diff)
rename ControllerPreset to LegacyControllerMapping
Diffstat (limited to 'src/controllers/controllerpresetinfo.cpp')
-rw-r--r--src/controllers/controllerpresetinfo.cpp119
1 files changed, 0 insertions, 119 deletions
diff --git a/src/controllers/controllerpresetinfo.cpp b/src/controllers/controllerpresetinfo.cpp
deleted file mode 100644
index b519330acb..0000000000
--- a/src/controllers/controllerpresetinfo.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "controllers/controllerpresetinfo.h"
-
-#include "controllers/defs_controllers.h"
-#include "util/xml.h"
-
-PresetInfo::PresetInfo()
- : m_valid(false) {
-}
-
-PresetInfo::PresetInfo(const QString& preset_path)
- : m_valid(false) {
- // Parse <info> header section from a controller description XML file
- // Contents parsed by xml path:
- // info.name Preset name, used for drop down menus in dialogs
- // info.author Preset author
- // info.description Preset description
- // info.forums Link to mixxx forum discussion for the preset
- // info.wiki Link to mixxx wiki for the preset
- // info.devices.product List of device matches, specific to device type
- QFileInfo fileInfo(preset_path);
- m_path = fileInfo.absoluteFilePath();
- m_dirPath = fileInfo.dir().absolutePath();
- m_name = "";
- m_author = "";
- m_description = "";
- m_forumlink = "";
- m_wikilink = "";
-
- QDomElement root = XmlParse::openXMLFile(m_path, "controller");
- if (root.isNull()) {
- qWarning() << "ERROR parsing" << m_path;
- return;
- }
- QDomElement info = root.firstChildElement("info");
- if (info.isNull()) {
- qDebug() << "MISSING <info> ELEMENT: " << m_path;
- return;
- }
-
- m_valid = true;
-
- QDomElement dom_name = info.firstChildElement("name");
- if (!dom_name.isNull()) {
- m_name = dom_name.text();
- } else {
- m_name = fileInfo.baseName();
- }
-
- QDomElement dom_author = info.firstChildElement("author");
- if (!dom_author.isNull()) {
- m_author = dom_author.text();
- }
-
- QDomElement dom_description = info.firstChildElement("description");
- if (!dom_description.isNull()) {
- m_description = dom_description.text();
- }
-
- QDomElement dom_forums = info.firstChildElement("forums");
- if (!dom_forums.isNull()) {
- m_forumlink = dom_forums.text();
- }
-
- QDomElement dom_wiki = info.firstChildElement("wiki");
- if (!dom_wiki.isNull()) {
- m_wikilink = dom_wiki.text();
- }
-
- QDomElement devices = info.firstChildElement("devices");
- if (!devices.isNull()) {
- QDomElement product = devices.firstChildElement("product");
- while (!product.isNull()) {
- QString protocol = product.attribute("protocol","");
- if (protocol=="hid") {
- m_products.append(parseHIDProduct(product));
- } else if (protocol=="bulk") {
- m_products.append(parseBulkProduct(product));
- } else if (protocol=="midi") {
- qDebug("MIDI product info parsing not yet implemented");
- //m_products.append(parseMIDIProduct(product);
- } else if (protocol=="osc") {
- qDebug("OSC product info parsing not yet implemented");
- //m_products.append(parseOSCProduct(product);
- } else {
- qDebug("Product specification missing protocol attribute");
- }
- product = product.nextSiblingElement("product");
- }
- }
-}
-
-ProductInfo PresetInfo::parseBulkProduct(const QDomElement& element) const {
- // <product protocol="bulk" vendor_id="0x06f8" product_id="0x0b105" in_epaddr="0x82" out_epaddr="0x03">
- ProductInfo product;
- product.protocol = element.attribute("protocol");
- product.vendor_id = element.attribute("vendor_id");
- product.product_id = element.attribute("product_id");
- product.in_epaddr = element.attribute("in_epaddr");
- product.out_epaddr = element.attribute("out_epaddr");
- return product;
-}
-
-ProductInfo PresetInfo::parseHIDProduct(const QDomElement& element) const {
- // HID device <product> element parsing. Example of valid element:
- // <product protocol="hid" vendor_id="0x1" product_id="0x2" usage_page="0x3" usage="0x4" interface_number="0x3" />
- // All numbers must be hex prefixed with 0x
- // Only vendor_id and product_id fields are required to map a device.
- // usage_page and usage are matched on OS/X and windows
- // interface_number is matched on linux, which does support usage_page/usage
-
- ProductInfo product;
- product.protocol = element.attribute("protocol");
- product.vendor_id = element.attribute("vendor_id");
- product.product_id = element.attribute("product_id");
- product.usage_page = element.attribute("usage_page");
- product.usage = element.attribute("usage");
- product.interface_number = element.attribute("interface_number");
- return product;
-}