Skip to content

Commit

Permalink
added second server option
Browse files Browse the repository at this point in the history
  • Loading branch information
Apfelwurm committed Sep 7, 2021
1 parent 8d0c82c commit 77373bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
21 changes: 20 additions & 1 deletion src/volumehidtoosc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -61,6 +63,7 @@ cfg_opt_t opts[] =
//create objects
cfg_t *cfg;
lo_address t;
lo_address t2;
FILE *logfile= NULL;


Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions volumehidtoosc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77373bd

Please sign in to comment.