mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2025-01-18 08:41:08 +00:00
implement toggle
This commit is contained in:
parent
41c44db837
commit
529fb413f1
@ -21,6 +21,8 @@ long version(T_VBVMR_INTERFACE *iVMR, long *version);
|
|||||||
bool pdirty(T_VBVMR_INTERFACE *iVMR);
|
bool pdirty(T_VBVMR_INTERFACE *iVMR);
|
||||||
long get_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float *f);
|
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 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);
|
long set_parameters(T_VBVMR_INTERFACE *iVMR, char *command);
|
||||||
|
|
||||||
bool mdirty(T_VBVMR_INTERFACE *iVMR);
|
bool mdirty(T_VBVMR_INTERFACE *iVMR);
|
||||||
|
15
src/vmrcli.c
15
src/vmrcli.c
@ -168,10 +168,16 @@ void interactive(T_VBVMR_INTERFACE *vmr)
|
|||||||
|
|
||||||
void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
|
void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
|
||||||
{
|
{
|
||||||
printf("Parsing %s\n", command);
|
|
||||||
if (command[0] == '!') /* toggle */
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,10 +196,10 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
|
|||||||
printf("%.2f\n", res.val.f);
|
printf("%.2f\n", res.val.f);
|
||||||
break;
|
break;
|
||||||
case STRING_T:
|
case STRING_T:
|
||||||
printf("%s\n", res.val.s);
|
puts(res.val.s);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown result...");
|
fputs("Unknown result...", stderr);
|
||||||
break;
|
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)
|
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)
|
if (get_parameter_float(vmr, command, &res->val.f) != 0)
|
||||||
{
|
{
|
||||||
res->type = STRING_T;
|
res->type = STRING_T;
|
||||||
|
Loading…
Reference in New Issue
Block a user