implement toggle

This commit is contained in:
onyx-and-iris 2024-06-26 00:03:50 +01:00
parent 41c44db837
commit 529fb413f1
2 changed files with 13 additions and 4 deletions

View File

@ -21,6 +21,8 @@ long version(T_VBVMR_INTERFACE *iVMR, long *version);
bool pdirty(T_VBVMR_INTERFACE *iVMR);
long get_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float *f);
long get_parameter_string(T_VBVMR_INTERFACE *iVMR, char *param, char *s);
long set_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float val);
long set_parameter_string(T_VBVMR_INTERFACE *iVMR, char *param, char *s);
long set_parameters(T_VBVMR_INTERFACE *iVMR, char *command);
bool mdirty(T_VBVMR_INTERFACE *iVMR);

View File

@ -168,10 +168,16 @@ void interactive(T_VBVMR_INTERFACE *vmr)
void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
{
printf("Parsing %s\n", command);
if (command[0] == '!') /* toggle */
{
puts("Toggle");
command++;
struct result res = {.type = FLOAT_T};
get(vmr, command, &res);
if (res.type == FLOAT_T)
{
set_parameter_float(vmr, command, 1 - res.val.f);
}
return;
}
@ -190,10 +196,10 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
printf("%.2f\n", res.val.f);
break;
case STRING_T:
printf("%s\n", res.val.s);
puts(res.val.s);
break;
default:
printf("Unknown result...");
fputs("Unknown result...", stderr);
break;
}
}
@ -201,6 +207,7 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
struct result *get(T_VBVMR_INTERFACE *vmr, char *command, struct result *res)
{
clear_dirty(vmr);
if (get_parameter_float(vmr, command, &res->val.f) != 0)
{
res->type = STRING_T;