mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2026-04-08 09:53:32 +00:00
Compare commits
12 Commits
v0.8.0
...
de70cd39cf
| Author | SHA1 | Date | |
|---|---|---|---|
| de70cd39cf | |||
| b225ba5cc3 | |||
| 35335a60aa | |||
| a7c0bc1620 | |||
| 25692a9f35 | |||
| a05b029e9d | |||
| 68c2022ad7 | |||
| ff2970f4c5 | |||
| f60fc231b0 | |||
| c1dad8b99c | |||
| 2f2e503ae3 | |||
| ff69837f19 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -51,4 +51,6 @@ Module.symvers
|
|||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
test*
|
||||||
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
|
.\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`
|
## `Interactive Mode`
|
||||||
|
|
||||||
Running the following command in Powershell:
|
Running the following command in Powershell:
|
||||||
|
|||||||
@@ -8,9 +8,17 @@
|
|||||||
#ifndef __UTIL_H__
|
#ifndef __UTIL_H__
|
||||||
#define __UTIL_H__
|
#define __UTIL_H__
|
||||||
|
|
||||||
|
struct quickcommand
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *fullcommand;
|
||||||
|
};
|
||||||
|
|
||||||
void remove_last_part_of_path(char *fullpath);
|
void remove_last_part_of_path(char *fullpath);
|
||||||
char *kind_as_string(char *s, int kind, int n);
|
char *kind_as_string(char *s, int kind, int n);
|
||||||
char *version_as_string(char *s, long v, int n);
|
char *version_as_string(char *s, long v, int n);
|
||||||
bool is_comment(char *s);
|
bool is_comment(char *s);
|
||||||
|
struct quickcommand *command_in_quickcommands(const char *command, const struct quickcommand *quickcommands, int n);
|
||||||
|
void clear(PT_VMR vmr, bool (*f)(PT_VMR));
|
||||||
|
|
||||||
#endif /* __UTIL_H__ */
|
#endif /* __UTIL_H__ */
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "voicemeeterRemote.h"
|
#include "voicemeeterRemote.h"
|
||||||
|
|
||||||
enum kind
|
enum kind : int
|
||||||
{
|
{
|
||||||
UNKNOWN = -1,
|
UNKNOWN = -1,
|
||||||
BASIC = 1,
|
BASIC = 1,
|
||||||
@@ -41,6 +41,4 @@ bool is_mdirty(PT_VMR vmr);
|
|||||||
long macrobutton_getstatus(PT_VMR vmr, long n, float *val, long mode);
|
long macrobutton_getstatus(PT_VMR vmr, long n, float *val, long mode);
|
||||||
long macrobutton_setstatus(PT_VMR vmr, long n, float val, long mode);
|
long macrobutton_setstatus(PT_VMR vmr, long n, float val, long mode);
|
||||||
|
|
||||||
void clear_dirty(PT_VMR vmr);
|
|
||||||
|
|
||||||
#endif /* __WRAPPER_H__ */
|
#endif /* __WRAPPER_H__ */
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
* @author Vincent Burel, Onyx and Iris (code@onyxandiris.online)
|
* @author Vincent Burel, Onyx and Iris (code@onyxandiris.online)
|
||||||
* @brief Functions for initializing the iVMR interface.
|
* @brief Functions for initializing the iVMR interface.
|
||||||
* Defines a single public function that returns a pointer to the 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
|
* @date 2024-07-06
|
||||||
*
|
*
|
||||||
* @copyright Vincent Burel(c)2015-2021 All Rights Reserved
|
* @copyright Vincent Burel(c)2015-2021 All Rights Reserved
|
||||||
|
|||||||
38
src/util.c
38
src/util.c
@@ -2,7 +2,7 @@
|
|||||||
* @file util.c
|
* @file util.c
|
||||||
* @author Onyx and Iris (code@onyxandiris.online)
|
* @author Onyx and Iris (code@onyxandiris.online)
|
||||||
* @brief Utility functions.
|
* @brief Utility functions.
|
||||||
* @version 0.8.0
|
* @version 0.9.0
|
||||||
* @date 2024-07-06
|
* @date 2024-07-06
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2024
|
* @copyright Copyright (c) 2024
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <windows.h>
|
||||||
#include "wrapper.h"
|
#include "wrapper.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@@ -81,4 +82,39 @@ char *version_as_string(char *s, long v, int n)
|
|||||||
bool is_comment(char *s)
|
bool is_comment(char *s)
|
||||||
{
|
{
|
||||||
return s[0] == '#';
|
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, const struct quickcommand *quickcommands, int n)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(command_key, quickcommands[i].name) == 0)
|
||||||
|
{
|
||||||
|
return (struct quickcommand *)(quickcommands + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Continuously polls an is_{}dirty function until it clears.
|
||||||
|
*
|
||||||
|
* @param vmr Pointer to the iVMR interface
|
||||||
|
* @param f Pointer to a polling function
|
||||||
|
*/
|
||||||
|
void clear(PT_VMR vmr, bool (*f)(PT_VMR))
|
||||||
|
{
|
||||||
|
Sleep(30);
|
||||||
|
while (f(vmr))
|
||||||
|
Sleep(1);
|
||||||
}
|
}
|
||||||
47
src/vmrcli.c
47
src/vmrcli.c
@@ -2,7 +2,7 @@
|
|||||||
* @file vmrcli.c
|
* @file vmrcli.c
|
||||||
* @author Onyx and Iris (code@onyxandiris.online)
|
* @author Onyx and Iris (code@onyxandiris.online)
|
||||||
* @brief A Voicemeeter Remote Command Line Interface
|
* @brief A Voicemeeter Remote Command Line Interface
|
||||||
* @version 0.8.0
|
* @version 0.9.0
|
||||||
* @date 2024-07-06
|
* @date 2024-07-06
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2024
|
* @copyright Copyright (c) 2024
|
||||||
@@ -32,12 +32,15 @@
|
|||||||
"\tm: Launch the MacroButtons application\n" \
|
"\tm: Launch the MacroButtons application\n" \
|
||||||
"\ts: Launch the StreamerView application"
|
"\ts: Launch the StreamerView application"
|
||||||
#define OPTSTR ":hk:msc:iID:v"
|
#define OPTSTR ":hk:msc:iID:v"
|
||||||
#define MAX_LINE 512
|
#define MAX_LINE 4096 /* Size of the input buffer */
|
||||||
|
#define RES_SZ 512 /* Size of the buffer passed to VBVMR_GetParameterStringW */
|
||||||
|
#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
#define DELIMITERS " \t;,"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum The kind of values a get call may return.
|
* @enum The kind of values a get call may return.
|
||||||
*/
|
*/
|
||||||
enum
|
enum restype : int
|
||||||
{
|
{
|
||||||
FLOAT_T,
|
FLOAT_T,
|
||||||
STRING_T,
|
STRING_T,
|
||||||
@@ -48,17 +51,17 @@ enum
|
|||||||
*/
|
*/
|
||||||
struct result
|
struct result
|
||||||
{
|
{
|
||||||
int type;
|
enum restype type;
|
||||||
union val
|
union val
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
wchar_t s[MAX_LINE];
|
wchar_t s[RES_SZ];
|
||||||
} val;
|
} val;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool vflag = false;
|
static bool vflag = false;
|
||||||
|
|
||||||
static void usage(void);
|
static void usage();
|
||||||
enum kind set_kind(char *kval);
|
enum kind set_kind(char *kval);
|
||||||
void interactive(PT_VMR vmr, bool with_prompt);
|
void interactive(PT_VMR vmr, bool with_prompt);
|
||||||
void parse_input(PT_VMR vmr, char *input);
|
void parse_input(PT_VMR vmr, char *input);
|
||||||
@@ -172,7 +175,7 @@ int main(int argc, char *argv[])
|
|||||||
log_info("Profile %s loaded", cvalue);
|
log_info("Profile %s loaded", cvalue);
|
||||||
set_parameter_string(vmr, "command.load", cvalue);
|
set_parameter_string(vmr, "command.load", cvalue);
|
||||||
Sleep(300);
|
Sleep(300);
|
||||||
clear_dirty(vmr);
|
clear(vmr, is_pdirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iflag)
|
if (iflag)
|
||||||
@@ -234,22 +237,24 @@ enum kind set_kind(char *kval)
|
|||||||
* Each line is passed to parse_input()
|
* Each line is passed to parse_input()
|
||||||
*
|
*
|
||||||
* @param vmr Pointer to the iVMR interface
|
* @param vmr Pointer to the iVMR interface
|
||||||
|
* @param with_prompt If true, prints the interactive prompt '>>'
|
||||||
*/
|
*/
|
||||||
void interactive(PT_VMR vmr, bool with_prompt)
|
void interactive(PT_VMR vmr, bool with_prompt)
|
||||||
{
|
{
|
||||||
char input[MAX_LINE];
|
char input[MAX_LINE];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (with_prompt)
|
if (with_prompt)
|
||||||
printf(">> ");
|
printf(">> ");
|
||||||
while (fgets(input, MAX_LINE, stdin) != NULL)
|
while (fgets(input, MAX_LINE, stdin) != NULL)
|
||||||
{
|
{
|
||||||
input[strcspn(input, "\n")] = 0;
|
input[strcspn(input, "\n")] = 0;
|
||||||
if (strlen(input) == 1 && toupper(input[0]) == 'Q')
|
if ((len = strlen(input)) == 1 && toupper(input[0]) == 'Q')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
parse_input(vmr, input);
|
parse_input(vmr, input);
|
||||||
|
memset(input, 0, len); /* reset input buffer */
|
||||||
|
|
||||||
memset(input, 0, MAX_LINE); /* reset input buffer */
|
|
||||||
if (with_prompt)
|
if (with_prompt)
|
||||||
printf(">> ");
|
printf(">> ");
|
||||||
}
|
}
|
||||||
@@ -270,11 +275,11 @@ void parse_input(PT_VMR vmr, char *input)
|
|||||||
|
|
||||||
char *token, *p;
|
char *token, *p;
|
||||||
|
|
||||||
token = strtok_r(input, " \t;,", &p);
|
token = strtok_r(input, DELIMITERS, &p);
|
||||||
while (token != NULL)
|
while (token != NULL)
|
||||||
{
|
{
|
||||||
parse_command(vmr, token);
|
parse_command(vmr, token);
|
||||||
token = strtok_r(NULL, " \t;,", &p);
|
token = strtok_r(NULL, DELIMITERS, &p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +295,24 @@ void parse_command(PT_VMR vmr, char *command)
|
|||||||
{
|
{
|
||||||
log_debug("Parsing %s", command);
|
log_debug("Parsing %s", command);
|
||||||
|
|
||||||
|
static const 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"}};
|
||||||
|
|
||||||
|
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 */
|
if (command[0] == '!') /* toggle */
|
||||||
{
|
{
|
||||||
command++;
|
command++;
|
||||||
@@ -350,7 +373,7 @@ void parse_command(PT_VMR vmr, char *command)
|
|||||||
*/
|
*/
|
||||||
void get(PT_VMR vmr, char *command, struct result *res)
|
void get(PT_VMR vmr, char *command, struct result *res)
|
||||||
{
|
{
|
||||||
clear_dirty(vmr);
|
clear(vmr, is_pdirty);
|
||||||
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;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @file wrapper.c
|
* @file wrapper.c
|
||||||
* @author Onyx and Iris (code@onyxandiris.online)
|
* @author Onyx and Iris (code@onyxandiris.online)
|
||||||
* @brief Provides public functions that wrap the iVMR calls
|
* @brief Provides public functions that wrap the iVMR calls
|
||||||
* @version 0.8.0
|
* @version 0.9.0
|
||||||
* @date 2024-07-06
|
* @date 2024-07-06
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2024
|
* @copyright Copyright (c) 2024
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#define KIND_STR_LEN 64
|
#define KIND_STR_LEN 64
|
||||||
#define VERSION_STR_LEN 32
|
#define VERSION_STR_LEN 32
|
||||||
|
#define LOGIN_TIMEOUT 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Logs into the API.
|
* @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));
|
kind_as_string(kind_s, kind, KIND_STR_LEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeout = 2;
|
|
||||||
time_t start = time(NULL);
|
time_t start = time(NULL);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -57,11 +57,11 @@ long login(PT_VMR vmr, int kind)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
} while (time(NULL) < start + timeout);
|
} while (difftime(time(NULL), start) < LOGIN_TIMEOUT);
|
||||||
|
|
||||||
if (rep == 0)
|
if (rep == 0)
|
||||||
{
|
{
|
||||||
clear_dirty(vmr);
|
clear(vmr, is_pdirty);
|
||||||
}
|
}
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
@@ -156,10 +156,3 @@ long macrobutton_setstatus(PT_VMR vmr, long n, float val, long mode)
|
|||||||
log_trace("VBVMR_MacroButton_SetStatus(%ld, %d, %ld)", n, (int)val, mode);
|
log_trace("VBVMR_MacroButton_SetStatus(%ld, %d, %ld)", n, (int)val, mode);
|
||||||
return vmr->VBVMR_MacroButton_SetStatus(n, val, mode);
|
return vmr->VBVMR_MacroButton_SetStatus(n, val, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_dirty(PT_VMR vmr)
|
|
||||||
{
|
|
||||||
Sleep(30);
|
|
||||||
while (is_pdirty(vmr))
|
|
||||||
Sleep(1);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user