summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2023-12-28 05:03:40 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2023-12-28 05:03:40 +0100
commitd0f01f385a4610ace292b372d71f7d1482199868 (patch)
tree5e808b852ef16cfe3ee98175f358d64ad540c09e
parent7bbfc8aeafb2bd75a31da8b459d6515b0af80c8c (diff)
downloadpjctl-d0f01f385a4610ace292b372d71f7d1482199868.tar.gz
pjctl-d0f01f385a4610ace292b372d71f7d1482199868.tar.bz2
pjctl-d0f01f385a4610ace292b372d71f7d1482199868.zip
commit unstagednew
-rw-r--r--src/pjctl.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/pjctl.c b/src/pjctl.c
index 293bcd1..510ca7e 100644
--- a/src/pjctl.c
+++ b/src/pjctl.c
@@ -379,7 +379,7 @@ static int
source(struct pjctl *pjctl, union pjctl_param_parse *p);
static void
-switch_to_first_input_type(struct pjctl *pjctl, struct queue_command *cmd,
+source_first_input_of_type(struct pjctl *pjctl, struct queue_command *cmd,
char *op, char *param)
{
union pjctl_param_parse *p = cmd->user_data;
@@ -392,11 +392,11 @@ switch_to_first_input_type(struct pjctl *pjctl, struct queue_command *cmd,
if (param[i] == ('0' + p->source.type)) {
num = param[i+1] - '0';
if (num < 0 || num > 9) {
- return;
+ continue;
}
p->source.num = num;
source(pjctl, p);
- free(p);
+ break;
}
}
}
@@ -405,19 +405,20 @@ static int
source(struct pjctl *pjctl, union pjctl_param_parse *p)
{
struct queue_command *cmd;
- uint8_t type = p->source.type;
- int num = p->source.num;
+ uint8_t type = p->source.type, num = p->source.num;
const char *switches[] = { "rgb", "video", "digital", "storage", "net" };
cmd = calloc(1, sizeof *cmd);
if (!cmd)
return -1;
- if (num == -1) {
- cmd->response_func = switch_to_first_input_type;
+ if (num == 0) {
+ cmd->command = strdup("%1INST ?\r");
+ if (!cmd->command)
+ return -1;
+ cmd->response_func = source_first_input_of_type;
cmd->user_data = p;
insert_at_head(&pjctl->queue, cmd);
-
return 0;
}
@@ -427,7 +428,7 @@ source(struct pjctl *pjctl, union pjctl_param_parse *p)
insert_at_head(&pjctl->queue, cmd);
- printf("source select %s%d: ", switches[type-1], num);
+ printf("source select %s%hhu: ", switches[type-1], num);
return 0;
}
@@ -738,7 +739,7 @@ static struct pjctl_command {
{ "power", power, P{ P_SWITCH, P_END } },
{ "source", source,
P{ P_ATOM("rgb", "video", "digital", "storage", "net"),
- P_RANGE(1,9,-1), P_END }
+ P_RANGE(1,9,0), P_END }
},
{ "mute", avmute, P{ P_ATOM("video", "audio", "av"), P_SWITCH, P_END }},
{ "status", status, NULL },