From 277aa925a66e7009a735fa389ee30670b8b00456 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 1 Nov 2013 22:21:08 +0000 Subject: Support ui:portMap feature to allow UIs to avoid hard-coded port indices git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5170 a436a847-0d15-0410-975c-d299462d15a1 --- src/jalv.c | 11 ++++++++++- src/jalv_internal.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/jalv.c b/src/jalv.c index f3a7f72..fe17d08 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -644,7 +644,7 @@ jack_session_cb(jack_session_event_t* event, void* arg) void jalv_ui_instantiate(Jalv* jalv, const char* native_ui_type, void* parent) { - jalv->ui_host = suil_host_new(jalv_ui_write, NULL, NULL, NULL); + jalv->ui_host = suil_host_new(jalv_ui_write, jalv_ui_port_index, NULL, NULL); const LV2_Feature parent_feature = { LV2_UI__parent, parent @@ -747,6 +747,15 @@ jalv_ui_write(SuilController controller, jack_ringbuffer_write(jalv->ui_events, buf, sizeof(buf)); } +uint32_t +jalv_ui_port_index(SuilController controller, const char* symbol) +{ + Jalv* const jalv = (Jalv*)controller; + struct Port* port = jalv_port_by_symbol(jalv, symbol); + + return port ? port->index : LV2UI_INVALID_PORT_INDEX; +} + bool jalv_emit_ui_events(Jalv* jalv) { diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 8ea45df..5bcb175 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -237,6 +237,9 @@ jalv_ui_write(SuilController controller, uint32_t protocol, const void* buffer); +uint32_t +jalv_ui_port_index(SuilController controller, const char* port_symbol); + void jalv_ui_port_event(Jalv* jalv, uint32_t port_index, -- cgit v1.2.1