diff --git a/include/vmr.h b/include/vmr.h index 65cc953..1e9000f 100644 --- a/include/vmr.h +++ b/include/vmr.h @@ -4,9 +4,17 @@ #ifndef __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 run_voicemeeter(T_VBVMR_INTERFACE *iVMR); +long run_voicemeeter(T_VBVMR_INTERFACE *iVMR, int kind); long type(T_VBVMR_INTERFACE *iVMR, long *type); long version(T_VBVMR_INTERFACE *iVMR, long *version); diff --git a/src/vmr.c b/src/vmr.c index ff9aac6..2296d08 100644 --- a/src/vmr.c +++ b/src/vmr.c @@ -2,25 +2,38 @@ #include #include "vmr.h" -enum kind -{ - BASIC = 1, - BANANA, - POTATO, - POTATOX64 = 6 -} kind; - -long login(T_VBVMR_INTERFACE *iVMR) +long login(T_VBVMR_INTERFACE *iVMR, int kind) { int rep; rep = iVMR->VBVMR_Login(); + Sleep(20); if (rep == 1) { - rep = run_voicemeeter(iVMR); - puts("Launching Voicemeeter GUI"); + rep = run_voicemeeter(iVMR, kind); + 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); } + if (rep == 0) + { + puts("Successfully logged into the Voicemeeter API"); + clear_dirty(iVMR); + } return rep; } @@ -30,11 +43,8 @@ long logout(T_VBVMR_INTERFACE *iVMR) 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); } diff --git a/src/vmrcli.c b/src/vmrcli.c index dece72a..9ad510d 100644 --- a/src/vmrcli.c +++ b/src/vmrcli.c @@ -7,21 +7,28 @@ #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); int main(int argc, char *argv[]) { bool iflag = false; int c; + char *kvalue; + int kind = BANANA; - while ((c = getopt(argc, argv, "i")) != -1) + while ((c = getopt(argc, argv, "k:i")) != -1) { switch (c) { case 'i': iflag = true; break; + case 'k': + kvalue = optarg; + kind = set_kind(kvalue); + break; default: abort(); } @@ -30,7 +37,7 @@ int main(int argc, char *argv[]) static T_VBVMR_INTERFACE iVMR; T_VBVMR_INTERFACE *vmr = &iVMR; - int rep = init_voicemeeter(vmr); + int rep = init_voicemeeter(vmr, kind); if (rep) { exit(EXIT_FAILURE); @@ -51,12 +58,41 @@ int main(int argc, char *argv[]) rep = logout(vmr); if (!rep) + { + puts("Successfully logged out of Voicemeeter API"); return EXIT_SUCCESS; + } else + { 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); if (rep < 0) @@ -72,13 +108,12 @@ int init_voicemeeter(T_VBVMR_INTERFACE *vmr) return rep; } - rep = login(vmr); + rep = login(vmr, kind); if (rep != 0) { fputs("Error logging into Voicemeeter", stderr); return rep; } - clear_dirty(vmr); return 0; }