aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-03-06 04:21:00 +0000
committerDavid Robillard <d@drobilla.net>2015-03-06 04:21:00 +0000
commit036267a27014069ab524b15dc71b64fca392a5c9 (patch)
tree5e5e2beb54d1b99e0d09206b4573f011daa01330 /src
parent74142600d82581921d31c7a6bcabeaa026c96990 (diff)
downloadjalv-036267a27014069ab524b15dc71b64fca392a5c9.tar.gz
jalv-036267a27014069ab524b15dc71b64fca392a5c9.tar.bz2
jalv-036267a27014069ab524b15dc71b64fca392a5c9.zip
Add command prompt to console version for changing controls.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5613 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/jalv_console.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 0632098..79cde0f 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -116,6 +116,30 @@ jalv_native_ui_type(Jalv* jalv)
return NULL;
}
+static void
+jalv_process_command(Jalv* jalv, const char* cmd)
+{
+ char sym[64];
+ float value;
+ if (sscanf(cmd, "%[a-zA-Z0-9] = %f", sym, &value) == 2) {
+ struct Port* port = NULL;
+ for (uint32_t i = 0; i < jalv->num_ports; ++i) {
+ struct Port* p = &jalv->ports[i];
+ const LilvNode* s = lilv_port_get_symbol(jalv->plugin, p->lilv_port);
+ if (!strcmp(lilv_node_as_string(s), sym)) {
+ port = p;
+ break;
+ }
+ }
+ if (port) {
+ port->control = value;
+ printf("%-*s = %f\n", jalv->longest_sym, sym, value);
+ } else {
+ fprintf(stderr, "error: no port `%s'\n", sym);
+ }
+ }
+}
+
int
jalv_open_ui(Jalv* jalv)
{
@@ -142,10 +166,22 @@ jalv_open_ui(Jalv* jalv)
show_iface->hide(suil_instance_get_handle(jalv->ui_instance));
- // Caller waits on the done sem, so increment it again to exit
- zix_sem_post(jalv->done);
- }
+ } else {
+ // Primitive command prompt for setting control values
+ while (!zix_sem_try_wait(jalv->done)) {
+ char line[128];
+ printf("> ");
+ if (fgets(line, sizeof(line), stdin)) {
+ jalv_process_command(jalv, line);
+ } else {
+ break;
+ }
+ }
+ }
+ // Caller waits on the done sem, so increment it again to exit
+ zix_sem_post(jalv->done);
+
return 0;
}