Skip to content

Commit 50bd445

Browse files
committed
small changes to allow compile on windows / visual studio
1 parent 9ac4ab1 commit 50bd445

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

src/loader.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int check_version_string(fnusb_dev* dev) {
124124

125125

126126
FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) {
127-
freenect_context* ctx = dev->parent->parent;
127+
freenect_context* ctx = dev->parent->parent;
128128
/* Search for firmware file (audios.bin) in the following places:
129129
* $LIBFREENECT_FIRMWARE_PATH
130130
* .
@@ -138,7 +138,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) {
138138
char fw_filename[1024];
139139
sprintf(fw_filename, "/%s", filename);
140140

141-
int filenamelen = strlen(fw_filename);
141+
int filenamelen = strlen(fw_filename);
142142
int i;
143143
int searchpathcount;
144144
FILE* fw = NULL;
@@ -152,15 +152,15 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) {
152152
if (!envpath)
153153
continue;
154154
int pathlen = strlen(envpath);
155-
fwfile = malloc(pathlen + filenamelen + 1);
155+
fwfile = (char *)malloc(pathlen + filenamelen + 1);
156156
strcpy(fwfile, envpath);
157157
strcat(fwfile, fw_filename);
158158
needs_free = 1;
159159
}
160160
break;
161161
case 1:
162162
//fwfile = "./audios.bin";
163-
fwfile = malloc(2048);
163+
fwfile = (char *)malloc(2048);
164164
needs_free = 1;
165165
sprintf(fwfile, ".%s", fw_filename);
166166
break;
@@ -186,13 +186,13 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) {
186186
break;
187187
case 4:
188188
//fwfile = "/usr/share/libfreenect/audios.bin";
189-
fwfile = malloc(2048);
189+
fwfile = (char *)malloc(2048);
190190
needs_free = 1;
191191
sprintf(fwfile, "/usr/share/libfreenect%s", fw_filename);
192192
break;
193193
case 5:
194194
//fwfile = "./../Resources/audios.bin"; //default for OS X equivilant to: "./audios.bin";
195-
fwfile = malloc(2048);
195+
fwfile = (char *)malloc(2048);
196196
needs_free = 1;
197197
sprintf(fwfile, "./../Resources%s", fw_filename);
198198
break;
@@ -219,7 +219,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) {
219219
return -errno;
220220
}
221221

222-
unsigned char * fw_bytes = malloc(fw_num_bytes);
222+
unsigned char * fw_bytes = (unsigned char *)malloc(fw_num_bytes);
223223
int numRead = fread(fw_bytes, 1, fw_num_bytes, fw);
224224
fw_num_bytes = numRead; // just in case
225225

@@ -229,7 +229,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev, char * filename) {
229229
fw = NULL;
230230

231231
return retVal;
232-
}
232+
}
233233

234234
FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_from_mem, unsigned int fw_size_in_btyes) {
235235
freenect_context* ctx = dev->parent->parent;
@@ -269,7 +269,7 @@ FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_f
269269
FN_INFO("\tentry point 0x%08x\n", fwheader.entry_addr);
270270

271271

272-
uint32_t addr = fwheader.base_addr;
272+
uint32_t addr = fwheader.base_addr;
273273
unsigned char page[0x4000];
274274
int readIndex = 0;
275275
int total_bytes_sent = 0;
@@ -282,8 +282,8 @@ FN_INTERNAL int upload_firmware_from_memory(fnusb_dev* dev, unsigned char * fw_f
282282
read = bytesLeft;
283283
}
284284
if (read <= 0) {
285-
break;
286-
}
285+
break;
286+
}
287287

288288
memcpy(page, &readPtr[readIndex], read);
289289
readIndex += read;

src/tilt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,15 @@ int freenect_set_led_alt(freenect_device *dev, freenect_led_options state)
260260

261261
//The LED states are different between K4W/1473 and older 1414
262262
if( state == LED_GREEN ){
263-
state = LED_ALT_SOLID_GREEN;
263+
state = (freenect_led_options)LED_ALT_SOLID_GREEN;
264264
}else if( state == LED_RED ){
265-
state = LED_ALT_SOLID_RED;
265+
state = (freenect_led_options)LED_ALT_SOLID_RED;
266266
}else if( state == LED_YELLOW ){
267-
state = LED_ALT_SOLID_GREEN;
267+
state = (freenect_led_options)LED_ALT_SOLID_GREEN;
268268
}else if( state == LED_OFF ){
269-
state = LED_ALT_OFF;
269+
state = (freenect_led_options)LED_ALT_OFF;
270270
}else if( state == LED_BLINK_GREEN ){
271-
state = LED_ALT_BLINK_GREEN;
271+
state = (freenect_led_options)LED_ALT_BLINK_GREEN;
272272
}else{
273273
state = LED_GREEN;
274274
}

src/usb_libusb10.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#include "keep_alive.h"
3636

37+
38+
#ifdef _MSC_VER
39+
# define sleep(x) Sleep((x)*1000)
40+
#endif
41+
3742
FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx)
3843
{
3944
libusb_device **devs;
@@ -213,6 +218,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index)
213218
break;
214219
}
215220
if(desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)){
221+
222+
freenect_device_flags requested_devices = ctx->enabled_subdevices;
223+
216224
/* Not the old kinect so we only set up the camera*/
217225
ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA;
218226
ctx->zero_plane_res = 334;
@@ -228,8 +236,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index)
228236

229237
#ifdef BUILD_AUDIO
230238
//for newer devices we need to enable the audio device for motor control
231-
if( (ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) == 0 ){
232-
ctx->enabled_subdevices |= FREENECT_DEVICE_AUDIO;
239+
//we only do this though if motor has been requested.
240+
if( (requested_devices & FREENECT_DEVICE_MOTOR) && (requested_devices & FREENECT_DEVICE_AUDIO) == 0 ){
241+
ctx->enabled_subdevices = (freenect_device_flags)(ctx->enabled_subdevices | FREENECT_DEVICE_AUDIO);
233242
}
234243
#endif
235244

0 commit comments

Comments
 (0)