summaryrefslogtreecommitdiffstats
path: root/source/gecko.c
blob: f08902794cb5a9a8b482890319793d50be92cf00 (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
#include "gecko.h"

int geckoFound = 0;

void checkForGecko()
{
	#ifdef DEBUG
	geckoFound = usb_isgeckoalive(EXI_CHANNEL_1);
	if(geckoFound){usb_flush(EXI_CHANNEL_1);}
	#endif
}

int gprintf(const char *str, ...)
{
	#ifdef DEBUG
	if(!geckoFound){return -1;}

	char astr[2048];
	snprintf(astr, 2048, "%s\r\n", str);

	char nstr[2048];
	va_list ap;
	va_start(ap, str);
	int size = vsnprintf(nstr, 2047, astr, ap);
	va_end(ap);

	usb_sendbuffer(1, nstr, size);
	usb_flush(EXI_CHANNEL_1);
	#endif
	return 0;
}