diff --git a/README.md b/README.md index d716d2f..d961114 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Note: It currently has to run as root to access the hid | EV | set the ev id of your usb hid (if you need help look under detect hardware) | 'EV=1f' | | IP | set the ip address of your destination server | '10.10.10.220' | | PORT | set the incoming port of your destination server | '7001' | +| IP2 | set the ip address of your second destination server (optional) | '10.10.10.221' | +| PORT2 | set the incoming port of your second destination server (optional) | '7001' | | OSC_PATH | set the osc path to where the float should be sent | '/1/mastervolume' | | VOL_PLUS | set the vol plus command id of your usb hid (if you need help look under detect hardware) | 115 | | VOL_PLUS_TIMES | set the amount of events received to trigger one volume change (if you need help look under detect hardware) | 2 | diff --git a/src/volumehidtoosc.c b/src/volumehidtoosc.c index 4ef40f0..31c9c2d 100644 --- a/src/volumehidtoosc.c +++ b/src/volumehidtoosc.c @@ -43,7 +43,9 @@ cfg_opt_t opts[] = CFG_STR("PRODUCT", "Product=484d", CFGF_NONE), CFG_STR("EV", "EV=1f", CFGF_NONE), CFG_STR("IP", "10.10.10.220", CFGF_NONE), + CFG_STR("IP2", "", CFGF_NONE), CFG_STR("PORT", "7001", CFGF_NONE), + CFG_STR("PORT2", "", CFGF_NONE), CFG_STR("OSC_PATH", "/1/mastervolume", CFGF_NONE), CFG_INT("VOL_PLUS",115,CFGF_NONE), CFG_INT("VOL_PLUS_TIMES",2,CFGF_NONE), @@ -61,6 +63,7 @@ cfg_opt_t opts[] = //create objects cfg_t *cfg; lo_address t; +lo_address t2; FILE *logfile= NULL; @@ -147,6 +150,15 @@ int sendosc(float currvol) fprintf(logfile, "OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); fflush(logfile); } + + if (strcmp(cfg_getstr(cfg, "IP2"), "") != 0 && strcmp(cfg_getstr(cfg, "PORT2"), "") != 0) + { + if (lo_send(t2, cfg_getstr(cfg, "OSC_PATH"), "ff", currvol) == -1) { + fprintf(logfile, "OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); + fflush(logfile); + } + } + return 0; } @@ -195,7 +207,14 @@ int main(void) //create osc address object t = lo_address_new(cfg_getstr(cfg, "IP"), cfg_getstr(cfg, "PORT")); - + + //create second osc address object + if (strcmp(cfg_getstr(cfg, "IP2"), "") != 0 && strcmp(cfg_getstr(cfg, "PORT2"), "") != 0) + { + + t2 = lo_address_new(cfg_getstr(cfg, "IP2"), cfg_getstr(cfg, "PORT2")); + } + //get hid device and exif if not available diff --git a/volumehidtoosc.conf b/volumehidtoosc.conf index 1b731a6..8647cfa 100644 --- a/volumehidtoosc.conf +++ b/volumehidtoosc.conf @@ -3,6 +3,8 @@ PRODUCT='Product=484d' EV='EV=1f' IP='10.10.10.220' PORT='7001' +IP2='' +PORT2='' OSC_PATH='/1/mastervolume' VOL_PLUS=115 VOL_PLUS_TIMES=2