summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-02-09 20:42:11 +0100
committerDavid Robillard <d@drobilla.net>2017-02-09 20:42:11 +0100
commit2f2253a8a642edbccdb9ff477fd0f4f0060da283 (patch)
tree39500738b5f6bab58f1047cdb08339363712692c /src
parent2ce49e31eaa10b1f230c18df330c584fc6a7477c (diff)
downloadingen-2f2253a8a642edbccdb9ff477fd0f4f0060da283.tar.gz
ingen-2f2253a8a642edbccdb9ff477fd0f4f0060da283.tar.bz2
ingen-2f2253a8a642edbccdb9ff477fd0f4f0060da283.zip
Fix multiple control bindings
Fixes #1151
Diffstat (limited to 'src')
-rw-r--r--src/server/ControlBindings.cpp8
-rw-r--r--src/server/ControlBindings.hpp8
2 files changed, 10 insertions, 6 deletions
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 2c6d3acf..9e3d2fae 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -132,7 +132,7 @@ ControlBindings::set_port_binding(RunContext& context,
const Atom& value)
{
const Key key = binding_key(value);
- if (key) {
+ if (!!key) {
binding->key = key;
binding->port = port;
_bindings->insert(*binding);
@@ -150,7 +150,7 @@ ControlBindings::port_value_changed(RunContext& context,
{
Ingen::World* world = context.engine().world();
const Ingen::URIs& uris = world->uris();
- if (key) {
+ if (!!key) {
int16_t value = port_value_to_control(
context, port, key.type, value_atom);
uint16_t size = 0;
@@ -400,13 +400,13 @@ ControlBindings::pre_process(RunContext& context, Buffer* buffer)
const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
const Key key = midi_event_key(ev->body.size, buf, value);
- if (_learn_binding && key) {
+ if (_learn_binding && !!key) {
finish_learn(context, key); // Learn new binding
}
// Set all controls bound to this key
const Binding k = {key, NULL};
- for (Bindings::const_iterator i = _bindings->find(k);
+ for (Bindings::const_iterator i = _bindings->lower_bound(k);
i != _bindings->end() && i->key == key;
++i) {
set_port_value(context, i->port, key.type, value);
diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp
index 538ab3ef..832e36d1 100644
--- a/src/server/ControlBindings.hpp
+++ b/src/server/ControlBindings.hpp
@@ -53,9 +53,13 @@ public:
struct Key {
Key(Type t=Type::NULL_CONTROL, int16_t n=0) : type(t), num(n) {}
inline bool operator<(const Key& other) const {
- return (type == other.type) ? (num < other.num) : (type < other.type);
+ return ((type < other.type) ||
+ (type == other.type && num < other.num));
}
- inline operator bool() const { return type != Type::NULL_CONTROL; }
+ inline bool operator==(const Key& other) const {
+ return type == other.type && num == other.num;
+ }
+ inline bool operator!() const { return type == Type::NULL_CONTROL; }
Type type;
int16_t num;
};