aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/visca.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-08-15 13:45:23 +0200
committercbdev <cb@cbcdn.com>2020-08-15 13:45:23 +0200
commit15826f63185211ff3974b29370d04b8082be9c53 (patch)
tree4e363f28428991a85f3c15a35080a863a5f53860 /backends/visca.c
parent690aec061db4cfab50b998822628f732e115e11e (diff)
downloadmidimonster-15826f63185211ff3974b29370d04b8082be9c53.tar.gz
midimonster-15826f63185211ff3974b29370d04b8082be9c53.tar.bz2
midimonster-15826f63185211ff3974b29370d04b8082be9c53.zip
Add VISCA documentation, fix some issues
Diffstat (limited to 'backends/visca.c')
-rw-r--r--backends/visca.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/backends/visca.c b/backends/visca.c
index f8bdae1..ae586a7 100644
--- a/backends/visca.c
+++ b/backends/visca.c
@@ -44,7 +44,7 @@ static int ptz_configure_instance(instance* inst, char* option, char* value){
data->cam_address = strtoul(value, NULL, 10);
return 0;
}
- if(!strcmp(option, "connect")){
+ else if(!strcmp(option, "connect")){
if(data->fd >= 0){
LOGPF("Instance %s already connected", inst->name);
return 1;
@@ -67,6 +67,24 @@ static int ptz_configure_instance(instance* inst, char* option, char* value){
}
return 0;
}
+ else if(!strcmp(option, "device")){
+ if(data->fd >= 0){
+ LOGPF("Instance %s already connected", inst->name);
+ return 1;
+ }
+
+ #ifdef _WIN32
+ LOGPF("Direct device connections are not possible on Windows");
+ return 1;
+ #else
+ data->fd = open(value, O_NONBLOCK);
+ if(data->fd < 0){
+ LOGPF("Failed to connect instance %s to device %s", inst->name, value);
+ return 1;
+ }
+ return 0;
+ #endif
+ }
LOGPF("Unknown instance configuration parameter %s for instance %s", option, inst->name);
return 1;
@@ -109,6 +127,7 @@ static channel* ptz_channel(instance* inst, char* spec, uint8_t flags){
return NULL;
}
+ //store the memory to be called above the command type
if(ident == call){
ident |= (strtoul(spec + strlen(ptz_channels[call].name), NULL, 10) << 8);
}
@@ -118,8 +137,8 @@ static channel* ptz_channel(instance* inst, char* spec, uint8_t flags){
static size_t ptz_set_pantilt(instance* inst, channel* c, channel_value* v, uint8_t* msg){
ptz_instance_data* data = (ptz_instance_data*) inst->impl;
- uint32_t* x = (uint32_t*) msg + 6;
- uint32_t* y = (uint32_t*) msg + 10;
+ uint32_t* x = (uint32_t*) (msg + 6);
+ uint32_t* y = (uint32_t*) (msg + 10);
if(c->ident == pan){
data->x = ((ptz_channels[pan].max - ptz_channels[pan].min) * v->normalised) + ptz_channels[pan].min;
@@ -144,17 +163,18 @@ static size_t ptz_set_ptspeed(instance* inst, channel* c, channel_value* v, uint
else{
data->tiltspeed = ((ptz_channels[tiltspeed].max - ptz_channels[tiltspeed].min) * v->normalised) + ptz_channels[tiltspeed].min;
}
+
return 0;
}
static size_t ptz_set_zoom(instance* inst, channel* c, channel_value* v, uint8_t* msg){
- uint32_t* position = (uint32_t*) msg + 4;
+ uint32_t* position = (uint32_t*) (msg + 4);
*position = htobe32(((ptz_channels[zoom].max - ptz_channels[zoom].min) * v->normalised) + ptz_channels[zoom].min);
return ptz_channels[zoom].bytes;
}
static size_t ptz_set_focus(instance* inst, channel* c, channel_value* v, uint8_t* msg){
- uint32_t* position = (uint32_t*) msg + 4;
+ uint32_t* position = (uint32_t*) (msg + 4);
*position = htobe32(((ptz_channels[focus].max - ptz_channels[focus].min) * v->normalised) + ptz_channels[focus].min);
return ptz_channels[focus].bytes;
}