summaryrefslogtreecommitdiff
path: root/lib/boblight.cpp
blob: 6c52136f376d9acb79e7663c92751effbf95a253 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * boblight
 * Copyright (C) Bob  2009 
 * 
 * boblight is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * boblight is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "boblight.h"
#include "boblight_client.h"

using namespace boblight;

//C wrapper for C++ class

void* boblight_init()
{
  CBoblight* boblight = new CBoblight;
  return reinterpret_cast<void*>(boblight);
}

void boblight_destroy(void* vpboblight)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  delete boblight;
}

int boblight_connect(void* vpboblight, const char* address, int port, int usectimeout)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->Connect(address, port, usectimeout);
}

int boblight_setpriority(void* vpboblight, int priority)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->SetPriority(priority);
}

const char* boblight_geterror(void* vpboblight)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->GetError();
}

int boblight_getnrlights(void* vpboblight)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->GetNrLights();
}

const char* boblight_getlightname(void* vpboblight, int lightnr)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->GetLightName(lightnr);
}

int boblight_getnroptions(void* vpboblight)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->GetNrOptions();
}

const char* boblight_getoptiondescript(void* vpboblight, int option)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->GetOptionDescription(option);
}

int boblight_setoption(void* vpboblight, int lightnr, const char* option)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->SetOption(lightnr, option);
}

int boblight_getoption(void* vpboblight, int lightnr, const char* option, const char** output)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->GetOption(lightnr, option, output);
}

void boblight_setscanrange(void* vpboblight, int width, int height)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  boblight->SetScanRange(width, height);
}

int boblight_addpixel(void* vpboblight, int lightnr, int* rgb)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->AddPixel(lightnr, rgb);
}

void boblight_addpixelxy(void* vpboblight, int x, int y, int* rgb)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  boblight->AddPixel(rgb, x, y);
}

int boblight_sendrgb(void* vpboblight, int sync, int* outputused)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->SendRGB(sync, outputused);
}

int boblight_ping(void* vpboblight, int* outputused)
{
  CBoblight* boblight = reinterpret_cast<CBoblight*>(vpboblight);
  return boblight->Ping(outputused, true);
}