Skip to content

Commit

Permalink
feat: controller screen rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Oct 20, 2023
1 parent ac3c551 commit eff07d8
Show file tree
Hide file tree
Showing 31 changed files with 2,639 additions and 194 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,12 @@ target_sources(mixxx-lib PRIVATE
src/widget/wvumeterlegacy.cpp
src/widget/wwaveformviewer.cpp
)
if (NOT QML)
if (QML)
target_sources(mixxx-lib PRIVATE
# The following source depends of QML but aren't part of the new QML UI
src/controllers/rendering/controllerrenderingengine.cpp
)
else()
target_sources(mixxx-lib PRIVATE
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
Expand Down
21 changes: 21 additions & 0 deletions res/controllers/Dummy Device Screen.hid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version='1.0' encoding='utf-8'?>
<MixxxControllerPreset mixxxVersion="2.4.0" schemaVersion="1">
<info>
<name>Dummy Device (Screens)</name>
<author>A. Colombier</author>
<description>Dummy device screens</description>
<devices>
<product protocol="hid" vendor_id="0xdead" product_id="0xbeaf" />
</devices>
</info>
<controller id="DummyDevice">
<screens>
<screen identifier="main" width="480" height="360" targetFps="20" pixelType="RBGA" splashoff="2000" />
</screens>
<scriptfiles>
<file filename="DummyDeviceDefaultScreen.qml" />
</scriptfiles>
<qmllibraries>
</qmllibraries>
</controller>
</MixxxControllerPreset>
221 changes: 221 additions & 0 deletions res/controllers/DummyDeviceDefaultScreen.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
import QtQuick 2.15
import QtQuick.Window 2.3
import QtQuick.Scene3D 2.14

import QtQuick.Controls 2.15
import QtQuick.Shapes 1.11
import QtQuick.Layouts 1.3
import QtQuick.Window 2.15

import Qt5Compat.GraphicalEffects

import Mixxx 1.0 as Mixxx
import Mixxx.Controls 1.0 as MixxxControls

Item {
id: root

required property string screenId
property color fontColor: Qt.rgba(242/255,242/255,242/255, 1)
property color smallBoxBorder: Qt.rgba(44/255,44/255,44/255, 1)

property string group: "[Channel1]"
property var deckPlayer: Mixxx.PlayerManager.getPlayer(root.group)

function init(controlerName, isDebug) {
console.log(`Screen ${root.screenId} has started`)
loader.sourceComponent = live
}

function shutdown() {
console.log(`Screen ${root.screenId} is stopping`)
loader.sourceComponent = splashoff
}

function transformFrame(input, timestamp) {
return new ArrayBuffer(0);
}

Timer {
id: channelchange

interval: 2000
repeat: true
running: true

onTriggered: {
root.group = root.group === "[Channel1]" ? "[Channel2]" : "[Channel1]"
}
}

Component {
id: splashoff
Rectangle {
color: "black"
anchors.fill: parent
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectFit
source: "../images/templates/logo_mixxx.png"
}
}
}

Component {
id: live

Rectangle {
anchors.fill: parent
color: 'black'

antialiasing: true

ColumnLayout {
id: column
anchors.fill: parent
anchors.leftMargin: 0
anchors.rightMargin: 0
anchors.topMargin: 0
anchors.bottomMargin: 0
spacing: 6

RowLayout {
Layout.fillWidth: true
spacing: 0

Repeater {
id: debugColor

model: [
"black",
"white",
"red",
"green",
"blue",
Qt.rgba(0, 1, 1),
]

Rectangle {
required property var modelData

color: modelData
Layout.fillWidth: true
height: 80
}
}
}

RowLayout {
anchors.leftMargin: 6
anchors.rightMargin: 6
anchors.topMargin: 6
anchors.bottomMargin: 6

Layout.fillWidth: true
Layout.fillHeight: true
spacing: 6

Rectangle {
color: 'transparent'
Layout.fillWidth: true
Layout.fillHeight: true
Text {
text: qsTr("Group")
font.pixelSize: 24
font.family: "Noto Sans"
font.letterSpacing: -1
color: fontColor
}
}

Rectangle {
color: 'transparent'
Layout.fillWidth: true
Layout.fillHeight: true
Text {
text: `${root.group}`
font.pixelSize: 24
font.family: "Noto Sans"
font.letterSpacing: -1
color: fontColor
}
}
}

Repeater {
id: debugValue

model: [{
controllerKey: "beatloop_size",
title: "Beatloop Size"
}, {
controllerKey: "track_samples",
title: "Track sample"
}, {
controllerKey: "track_samplerate",
title: "Track sample rate"
}, {
controllerKey: "playposition",
title: "Play position"
}, {
controllerKey: "rate_ratio",
title: "Rate ratio"
}, {
controllerKey: "waveform_zoom",
title: "Waveform zoom"
}
]

RowLayout {
id: row
anchors.leftMargin: 6
anchors.rightMargin: 6
anchors.topMargin: 6
anchors.bottomMargin: 6
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 6
required property var modelData

Mixxx.ControlProxy {
id: mixxxValue
group: root.group
key: modelData.controllerKey
}

Rectangle {
color: 'transparent'
Layout.fillWidth: true
Layout.fillHeight: true
Text {
text: qsTr(modelData.title)
font.pixelSize: 24
font.family: "Noto Sans"
font.letterSpacing: -1
color: fontColor
}
}

Rectangle {
color: 'transparent'
Layout.fillWidth: true
Layout.fillHeight: true
Text {
text: `${mixxxValue.value}`
font.pixelSize: 24
font.family: "Noto Sans"
font.letterSpacing: -1
color: fontColor
}
}
}
}
}
}
}
Loader {
id: loader
anchors.fill: parent
sourceComponent: live
}
}
2 changes: 1 addition & 1 deletion src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void BulkController::sendBytes(const QByteArray& data) {
qCWarning(m_logOutput) << "Unable to send data to" << getName()
<< "serial #" << m_sUID;
} else {
qCDebug(m_logOutput) << ret << "bytes sent to" << getName()
qCDebug(m_logOutput) << transferred << "bytes sent to" << getName()
<< "serial #" << m_sUID;
}
}
9 changes: 8 additions & 1 deletion src/controllers/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include <QRegularExpression>
#include <algorithm>

#include "controllers/controllermanager.h"
#include "controllers/defs_controllers.h"
#include "moc_controller.cpp"
#include "util/cmdlineargs.h"
#include "util/screensaver.h"

namespace {
Expand Down Expand Up @@ -78,6 +80,10 @@ bool Controller::applyMapping() {
}

m_pScriptEngineLegacy->setScriptFiles(scriptFiles);
#ifdef MIXXX_USE_QML
m_pScriptEngineLegacy->setLibraryDirectories(pMapping->getLibraryDirectories());
m_pScriptEngineLegacy->setInfoScrens(pMapping->getInfoScreens());
#endif
return m_pScriptEngineLegacy->initialize();
}

Expand Down Expand Up @@ -124,7 +130,8 @@ void Controller::receive(const QByteArray& data, mixxx::Duration timestamp) {
triggerActivity();

int length = data.size();
if (m_logInput().isDebugEnabled()) {
if (CmdlineArgs::Instance()
.getControllerDebug()) {
// Formatted packet display
QString message = QString("t:%2, %3 bytes:\n")
.arg(timestamp.formatMillisWithUnit(),
Expand Down
16 changes: 9 additions & 7 deletions src/controllers/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class Controller : public QObject {
return m_bLearning;
}

inline ControllerScriptEngineLegacy* getScriptEngine() const {
return m_pScriptEngineLegacy;
}

virtual bool matchMapping(const MappingInfo& mapping) = 0;

signals:
Expand Down Expand Up @@ -102,10 +106,6 @@ class Controller : public QObject {
// were required to specify it.
virtual void send(const QList<int>& data, unsigned int length = 0);

// This must be reimplemented by sub-classes desiring to send raw bytes to a
// controller.
virtual void sendBytes(const QByteArray& data) = 0;

// To be called in sub-class' open() functions after opening the device but
// before starting any input polling/processing.
virtual void startEngine();
Expand All @@ -117,9 +117,6 @@ class Controller : public QObject {
// To be called when receiving events
void triggerActivity();

inline ControllerScriptEngineLegacy* getScriptEngine() const {
return m_pScriptEngineLegacy;
}
inline void setDeviceCategory(const QString& deviceCategory) {
m_sDeviceCategory = deviceCategory;
}
Expand All @@ -139,6 +136,11 @@ class Controller : public QObject {
const RuntimeLoggingCategory m_logInput;
const RuntimeLoggingCategory m_logOutput;

public slots:
// This must be reimplemented by sub-classes desiring to send raw bytes to a
// controller.
virtual void sendBytes(const QByteArray& data) = 0;

private: // but used by ControllerManager

virtual int open() = 0;
Expand Down
10 changes: 4 additions & 6 deletions src/controllers/controllermappinginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ struct ProductInfo {
QString protocol;
QString vendor_id;
QString product_id;

// HID-specific
QString in_epaddr;
QString out_epaddr;

// Bulk-specific
QString usage_page;
QString usage;
QString interface_number;

// Bulk-specific
QString in_epaddr;
QString out_epaddr;
};

/// Base class handling enumeration and parsing of mapping info headers
Expand Down
Loading

0 comments on commit eff07d8

Please sign in to comment.