aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-09-22 23:05:14 +0200
committerDavid Robillard <d@drobilla.net>2018-09-22 23:09:34 +0200
commit1df4368056d53a308e985ef4c102969e55753624 (patch)
tree8982b2f38edf2c51c8a85de71a271e43a41dd0e8
parentd976b0df20c02d1a95dca1184132b77e25cc2d8c (diff)
downloadjalv-1df4368056d53a308e985ef4c102969e55753624.tar.gz
jalv-1df4368056d53a308e985ef4c102969e55753624.tar.bz2
jalv-1df4368056d53a308e985ef4c102969e55753624.zip
Add command to set control values by port index
-rw-r--r--src/jalv_console.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 7bf69a2..dc3511e 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -139,14 +139,23 @@ jalv_native_ui_type(Jalv* jalv)
static void
jalv_process_command(Jalv* jalv, const char* cmd)
{
- char sym[64];
- float value;
+ char sym[64];
+ uint32_t index;
+ float value;
if (!strncmp(cmd, "help", 4)) {
fprintf(stderr,
"Commands:\n"
" help Display this help message\n"
- " set SYMBOL VALUE Set control value\n"
- " SYMBOL = VALUE Set control value\n");
+ " set INDEX VALUE Set control value by port index\n"
+ " set SYMBOL VALUE Set control value by symbol\n"
+ " SYMBOL = VALUE Set control value by symbol\n");
+ } else if (sscanf(cmd, "set %u %f", &index, &value) == 2) {
+ if (index < jalv->num_ports) {
+ jalv->ports[index].control = value;
+ jalv_print_control(jalv, &jalv->ports[index], value);
+ } else {
+ fprintf(stderr, "error: port index out of range\n");
+ }
} else if (sscanf(cmd, "set %[a-zA-Z0-9_] %f", sym, &value) == 2 ||
sscanf(cmd, "%[a-zA-Z0-9_] = %f", sym, &value) == 2) {
struct Port* port = NULL;