add -k flag

use it to set kind

use kind to launch GUI
This commit is contained in:
onyx-and-iris 2024-06-25 16:46:35 +01:00
parent 65a9023c07
commit 278abf8e86
3 changed files with 76 additions and 23 deletions

View File

@ -4,9 +4,17 @@
#ifndef __VMR_H__ #ifndef __VMR_H__
#define __VMR_H__ #define __VMR_H__
long login(T_VBVMR_INTERFACE *iVMR); enum kind
{
BASIC = 1,
BANANA,
POTATO,
POTATOX64 = 6
};
long login(T_VBVMR_INTERFACE *iVMR, int kind);
long logout(T_VBVMR_INTERFACE *iVMR); long logout(T_VBVMR_INTERFACE *iVMR);
long run_voicemeeter(T_VBVMR_INTERFACE *iVMR); long run_voicemeeter(T_VBVMR_INTERFACE *iVMR, int kind);
long type(T_VBVMR_INTERFACE *iVMR, long *type); long type(T_VBVMR_INTERFACE *iVMR, long *type);
long version(T_VBVMR_INTERFACE *iVMR, long *version); long version(T_VBVMR_INTERFACE *iVMR, long *version);

View File

@ -2,25 +2,38 @@
#include <stdio.h> #include <stdio.h>
#include "vmr.h" #include "vmr.h"
enum kind long login(T_VBVMR_INTERFACE *iVMR, int kind)
{
BASIC = 1,
BANANA,
POTATO,
POTATOX64 = 6
} kind;
long login(T_VBVMR_INTERFACE *iVMR)
{ {
int rep; int rep;
rep = iVMR->VBVMR_Login(); rep = iVMR->VBVMR_Login();
Sleep(20);
if (rep == 1) if (rep == 1)
{ {
rep = run_voicemeeter(iVMR); rep = run_voicemeeter(iVMR, kind);
puts("Launching Voicemeeter GUI"); switch (kind)
{
case BASIC:
puts("Launching Voicemeeter Basic GUI");
break;
case BANANA:
puts("Launching Voicemeeter Banana GUI");
break;
case POTATO:
puts("Launching Voicemeeter Potato GUI");
break;
case POTATOX64:
puts("Launching Voicemeeter Potato x64 GUI");
break;
}
Sleep(1200); Sleep(1200);
} }
if (rep == 0)
{
puts("Successfully logged into the Voicemeeter API");
clear_dirty(iVMR);
}
return rep; return rep;
} }
@ -30,11 +43,8 @@ long logout(T_VBVMR_INTERFACE *iVMR)
return iVMR->VBVMR_Logout(); return iVMR->VBVMR_Logout();
} }
long run_voicemeeter(T_VBVMR_INTERFACE *iVMR) long run_voicemeeter(T_VBVMR_INTERFACE *iVMR, int kind)
{ {
int kind = POTATO;
if (sizeof(void *) == 8)
kind = POTATOX64;
return iVMR->VBVMR_RunVoicemeeter((long)kind); return iVMR->VBVMR_RunVoicemeeter((long)kind);
} }

View File

@ -7,21 +7,28 @@
#define MAX_LINE 1024 #define MAX_LINE 1024
int init_voicemeeter(T_VBVMR_INTERFACE *vmr); int set_kind(char *kval);
int init_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind);
void interactive(T_VBVMR_INTERFACE *vmr); void interactive(T_VBVMR_INTERFACE *vmr);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool iflag = false; bool iflag = false;
int c; int c;
char *kvalue;
int kind = BANANA;
while ((c = getopt(argc, argv, "i")) != -1) while ((c = getopt(argc, argv, "k:i")) != -1)
{ {
switch (c) switch (c)
{ {
case 'i': case 'i':
iflag = true; iflag = true;
break; break;
case 'k':
kvalue = optarg;
kind = set_kind(kvalue);
break;
default: default:
abort(); abort();
} }
@ -30,7 +37,7 @@ int main(int argc, char *argv[])
static T_VBVMR_INTERFACE iVMR; static T_VBVMR_INTERFACE iVMR;
T_VBVMR_INTERFACE *vmr = &iVMR; T_VBVMR_INTERFACE *vmr = &iVMR;
int rep = init_voicemeeter(vmr); int rep = init_voicemeeter(vmr, kind);
if (rep) if (rep)
{ {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -51,12 +58,41 @@ int main(int argc, char *argv[])
rep = logout(vmr); rep = logout(vmr);
if (!rep) if (!rep)
{
puts("Successfully logged out of Voicemeeter API");
return EXIT_SUCCESS; return EXIT_SUCCESS;
}
else else
{
return EXIT_FAILURE; return EXIT_FAILURE;
}
} }
int init_voicemeeter(T_VBVMR_INTERFACE *vmr) int set_kind(char *kval)
{
if (strcmp(kval, "basic") == 0)
{
return BASIC;
}
else if (strcmp(kval, "banana") == 0)
{
return BANANA;
}
else if (strcmp(kval, "potato") == 0)
{
if (sizeof(void *) == 8)
return POTATOX64;
else
return POTATO;
}
else
{
fprintf(stderr, "Unknown Voicemeeter kind '%s'\n", kval);
exit(EXIT_FAILURE);
}
}
int init_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind)
{ {
int rep = initialize_dll_interfaces(vmr); int rep = initialize_dll_interfaces(vmr);
if (rep < 0) if (rep < 0)
@ -72,13 +108,12 @@ int init_voicemeeter(T_VBVMR_INTERFACE *vmr)
return rep; return rep;
} }
rep = login(vmr); rep = login(vmr, kind);
if (rep != 0) if (rep != 0)
{ {
fputs("Error logging into Voicemeeter", stderr); fputs("Error logging into Voicemeeter", stderr);
return rep; return rep;
} }
clear_dirty(vmr);
return 0; return 0;
} }