osc/midi: messages received from a midi port only affect widgets that send to this port
This commit is contained in:
parent
d454222232
commit
0e8bb37212
2 changed files with 20 additions and 7 deletions
|
|
@ -5,6 +5,7 @@
|
|||
- bug fixes
|
||||
- xy: broken `spring` property
|
||||
- macOs: add support for emulated right click via `ctrl+click`
|
||||
- midi: messages received from a midi port now only affect widgets that send to this port
|
||||
|
||||
## 0.48.6
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
var widgetManager = require('./managers/widgets'),
|
||||
EventEmitter = require('./events/event-emitter'),
|
||||
ipc = require('./ipc/')
|
||||
ipc = require('./ipc/'),
|
||||
{deepEqual} = require('./utils')
|
||||
|
||||
var Osc = class Osc extends EventEmitter {
|
||||
|
||||
|
|
@ -40,13 +41,24 @@ var Osc = class Osc extends EventEmitter {
|
|||
var [widgets, restArgs] = widgetManager.getWidgetByAddressAndArgs(data.address, data.args)
|
||||
|
||||
for (let i in widgets) {
|
||||
let widgetTarget = widgets[i].getProp('target')
|
||||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the same target
|
||||
if (!data.target || !widgetTarget || String(widgetTarget) === String(data.target)) {
|
||||
// update matching widgets
|
||||
if (widgets[i] && widgets[i].setValue) widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target})
|
||||
|
||||
let widgetTarget = widgets[i].getProp('target'),
|
||||
match = true
|
||||
|
||||
if (data.target) {
|
||||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the exact same target
|
||||
match = deepEqual(widgetTarget, data.target)
|
||||
} else if (data.host === 'midi') {
|
||||
// if the message comes from a midi port, only update widgets that send to that port
|
||||
let widgetArrayTarget = Array.isArray(widgetTarget) ? widgetTarget : [widgetTarget]
|
||||
match = widgetArrayTarget.includes(data.host + ':' + data.port)
|
||||
}
|
||||
|
||||
if (match) {
|
||||
widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.trigger(data.address, data.args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue