mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2025-04-19 20:43:49 +01:00
Compare commits
4 Commits
b35a29396b
...
f60fc231b0
Author | SHA1 | Date | |
---|---|---|---|
f60fc231b0 | |||
c1dad8b99c | |||
2f2e503ae3 | |||
ff69837f19 |
12
README.md
12
README.md
@ -48,6 +48,18 @@ Launch banana GUI, set log level to DEBUG, set Strip 0 label to podmic then prin
|
||||
.\vmrcli.exe -kbanana -D1 strip[0].label=podmic strip[2].label
|
||||
```
|
||||
|
||||
#### `Quick Commands`
|
||||
|
||||
A short list of quick commands are available:
|
||||
|
||||
- `lock`: command.lock=1
|
||||
- `unlock`: command.lock=0
|
||||
- `show`: command.show=1
|
||||
- `hide`: command.show=0
|
||||
- `restart`: command.restart=1
|
||||
|
||||
They may be used in direct or interactive mode.
|
||||
|
||||
## `Interactive Mode`
|
||||
|
||||
Running the following command in Powershell:
|
||||
|
@ -8,9 +8,16 @@
|
||||
#ifndef __UTIL_H__
|
||||
#define __UTIL_H__
|
||||
|
||||
struct quickcommand
|
||||
{
|
||||
char *name;
|
||||
char *fullcommand;
|
||||
};
|
||||
|
||||
void remove_last_part_of_path(char *fullpath);
|
||||
char *kind_as_string(char *s, int kind, int n);
|
||||
char *version_as_string(char *s, long v, int n);
|
||||
bool is_comment(char *s);
|
||||
struct quickcommand *command_in_quickcommands(const char *command, struct quickcommand *quickcommands, int n);
|
||||
|
||||
#endif /* __UTIL_H__ */
|
@ -3,7 +3,7 @@
|
||||
* @author Vincent Burel, Onyx and Iris (code@onyxandiris.online)
|
||||
* @brief Functions for initializing the iVMR interface.
|
||||
* Defines a single public function that returns a pointer to the interface.
|
||||
* @version 0.8.0
|
||||
* @version 0.9.0
|
||||
* @date 2024-07-06
|
||||
*
|
||||
* @copyright Vincent Burel(c)2015-2021 All Rights Reserved
|
||||
|
24
src/util.c
24
src/util.c
@ -2,7 +2,7 @@
|
||||
* @file util.c
|
||||
* @author Onyx and Iris (code@onyxandiris.online)
|
||||
* @brief Utility functions.
|
||||
* @version 0.8.0
|
||||
* @version 0.9.0
|
||||
* @date 2024-07-06
|
||||
*
|
||||
* @copyright Copyright (c) 2024
|
||||
@ -82,3 +82,25 @@ bool is_comment(char *s)
|
||||
{
|
||||
return s[0] == '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Searches the quickcommands array for a quickcommand
|
||||
* corresponding to the command_key.
|
||||
*
|
||||
* @param command_key The key used to search for the quickcommand
|
||||
* @param quickcommands Pointer to an array of quickcommands
|
||||
* @param n The number of quickcommands
|
||||
* @return struct quickcommand* Pointer to the found quickcommand
|
||||
* May return NULL if quickcommand not found.
|
||||
*/
|
||||
struct quickcommand *command_in_quickcommands(const char *command_key, struct quickcommand *quickcommands, int n)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (strncmp(command_key, quickcommands[i].name, strlen(command_key)) == 0)
|
||||
{
|
||||
return &quickcommands[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
21
src/vmrcli.c
21
src/vmrcli.c
@ -2,7 +2,7 @@
|
||||
* @file vmrcli.c
|
||||
* @author Onyx and Iris (code@onyxandiris.online)
|
||||
* @brief A Voicemeeter Remote Command Line Interface
|
||||
* @version 0.8.0
|
||||
* @version 0.9.0
|
||||
* @date 2024-07-06
|
||||
*
|
||||
* @copyright Copyright (c) 2024
|
||||
@ -33,6 +33,7 @@
|
||||
"\ts: Launch the StreamerView application"
|
||||
#define OPTSTR ":hk:msc:iID:v"
|
||||
#define MAX_LINE 512
|
||||
#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
/**
|
||||
* @enum The kind of values a get call may return.
|
||||
@ -56,6 +57,13 @@ struct result
|
||||
} val;
|
||||
};
|
||||
|
||||
struct quickcommand quickcommands[] = {
|
||||
{.name = "lock", .fullcommand = "command.lock=1"},
|
||||
{.name = "unlock", .fullcommand = "command.lock=0"},
|
||||
{.name = "show", .fullcommand = "command.show=1"},
|
||||
{.name = "hide", .fullcommand = "command.show=0"},
|
||||
{.name = "restart", .fullcommand = "command.restart=1"}};
|
||||
|
||||
static bool vflag = false;
|
||||
|
||||
static void usage(void);
|
||||
@ -290,6 +298,17 @@ void parse_command(PT_VMR vmr, char *command)
|
||||
{
|
||||
log_debug("Parsing %s", command);
|
||||
|
||||
struct quickcommand *qc_ptr = command_in_quickcommands(command, quickcommands, (int)COUNT_OF(quickcommands));
|
||||
if (qc_ptr != NULL)
|
||||
{
|
||||
set_parameters(vmr, qc_ptr->fullcommand);
|
||||
if (vflag)
|
||||
{
|
||||
printf("Setting %s\n", qc_ptr->fullcommand);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (command[0] == '!') /* toggle */
|
||||
{
|
||||
command++;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file wrapper.c
|
||||
* @author Onyx and Iris (code@onyxandiris.online)
|
||||
* @brief Provides public functions that wrap the iVMR calls
|
||||
* @version 0.8.0
|
||||
* @version 0.9.0
|
||||
* @date 2024-07-06
|
||||
*
|
||||
* @copyright Copyright (c) 2024
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#define KIND_STR_LEN 64
|
||||
#define VERSION_STR_LEN 32
|
||||
#define LOGIN_TIMEOUT 2
|
||||
|
||||
/**
|
||||
* @brief Logs into the API.
|
||||
@ -44,7 +45,6 @@ long login(PT_VMR vmr, int kind)
|
||||
kind_as_string(kind_s, kind, KIND_STR_LEN));
|
||||
}
|
||||
|
||||
int timeout = 2;
|
||||
time_t start = time(NULL);
|
||||
do
|
||||
{
|
||||
@ -57,7 +57,7 @@ long login(PT_VMR vmr, int kind)
|
||||
break;
|
||||
}
|
||||
Sleep(50);
|
||||
} while (time(NULL) < start + timeout);
|
||||
} while (difftime(time(NULL), start) < LOGIN_TIMEOUT);
|
||||
|
||||
if (rep == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user