Skip to content

Commit

Permalink
Fix message value not applying to input actions correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
nhielost committed Apr 8, 2024
1 parent ae3d99f commit 7ec4025
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/mmg-binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ using namespace MMGUtils;
MMGBinding::MMGBinding(MMGBindingManager *parent, const QJsonObject &json_obj)
: QObject(parent),
_messages(new MMGMessageManager(this)),
_actions(new MMGActionManager(this)),
link(new MMGLink(this))
_actions(new MMGActionManager(this))
{
setObjectName(json_obj["name"].toString(mmgtr("Binding.Untitled")));
link = new MMGLink(this);

_enabled = json_obj["enabled"].toBool(true);
_type = (DeviceType)json_obj["type"].toInt();
reset_mode = json_obj["reset_mode"].toInt();
Expand Down
11 changes: 9 additions & 2 deletions src/mmg-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
*/

#include "mmg-link.h"
#include "mmg-binding.h"
#include "mmg-midi.h"

using namespace MMGUtils;
Expand Down Expand Up @@ -124,14 +125,20 @@ void MMGLink::executeOutput()

void MMGLink::messageReceived(const MMGSharedMessage &incoming)
{
if (!binding->messages(0)->acceptable(incoming.get())) return;
MMGMessage *checked_message = binding->messages(0);
if (!checked_message->acceptable(incoming.get())) return;

if (binding->actions()->size() < 1) {
blog(LOG_INFO, "FAILED: No actions to execute!");
return;
}

incoming->copy(incoming_message);
checked_message->copy(incoming_message);
incoming_message->type().setValue(incoming->type().value());
incoming_message->channel().setValue(incoming->channel().value());
incoming_message->note().setValue(incoming->note().value());
incoming_message->value().setValue(incoming->value().value());

execute();
}

Expand Down
10 changes: 8 additions & 2 deletions src/mmg-link.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/

#pragma once
#include "mmg-binding.h"
#ifndef MMG_LINK_H
#define MMG_LINK_H

#include "mmg-utils.h"
#include "mmg-message.h"

#include <QThread>
#include <mutex>

class MMGBinding;

class MMGLink : public QThread {
Q_OBJECT

Expand Down Expand Up @@ -56,3 +61,4 @@ public slots:

static short thread_count;
};
#endif // MMG_LINK_H
1 change: 0 additions & 1 deletion src/mmg-message.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "mmg-manager.h"

class MMGMIDIPort;
class MMGLink;

class MMGMessage : public QObject {
Q_OBJECT
Expand Down

0 comments on commit 7ec4025

Please sign in to comment.