usbloadergx/source/gecko.c
Cyan fa4b1d162b * Fixed missing games in "GameCube Delete menu" if
the "GameCube Source" setting has USB priority.
* Fixed Playlog writing when using Hermes cIOS v4 (untested)
  (Requires AHB access).
* Fixed EmuNAND when using cIOS revision 65535 (issue 2225)
* Added Nintendont support:
  1. Select Nintendont's boot.dol folder in userpath settings.
  2. Set the "GameCube Mode" setting to Nintendont.
  3. Nintendont share some of DIOS MIOS (Lite) settings.
* Added sections in the Loader settings  
  (Wii/gamecube/Devolution/DIOS MIOS/Nintendont).
* Updated the GameCube game settings to display only 
  the selected GameCube mode related settings.
* Updated some menus to support more controller's input:
   - Prevent GC/CC X and Y buttons to change row number in
     Wall layout (use d-pad up/down only)
   - Added GC/CC support to carousel's arrow button
   - Added GC/CC support to Wall/Carousel continuous 
     scroll (+/- on CC, L/R on GC)
   - Added GC support L/R and Start buttons in the
     settings/homebrew browser.
   - Added D-pad support in listing windows if not pointing 
     the screen. The cursor now moves with the selection 
     (not very good with high Overscan value) (issue 2093)
* Changed the StartupProcess to speed up launch time by 
  using AHB access to read config files. IOS argument in
  meta.xml has priority over AHB detection.
* Added IOS58 + AHB support for launching the loader
  without cIOS (Wii games and EmuNAND still require cIOS).
* Added a Loader's IOS setting (now Loader and Games use 
  two separate settings: loader can use 58 and games 249).
* Added LibruntimeIOSPatch to patch IOS58 and Hermes v4 to
  get ISFS access and enable Banner mode, Channel's title
  and System font with these IOSes (Requires AHB access)
* Added a delete prompt if downloaded cheat file is empty.
* Force all launched homebrew to reload to IOS58 if available.
* Changed Gecko.c to send logs to wifigecko too.
* Changed wifigecko IP to send logs to all IP 192.168.0.x
* Updated French translation.
2013-10-01 21:13:08 +00:00

140 lines
2.7 KiB
C

#include <gccore.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <malloc.h>
#include <sys/iosupport.h>
// #define DEBUG_TO_FILE
// #define WIFI_GECKO // don't keep this for released build
#ifdef WIFI_GECKO
#include <utils/wifi_gecko.h>
#endif
/* init-globals */
static bool geckoinit = false;
void gprintf(const char *format, ...)
{
#ifndef DEBUG_TO_FILE
#ifndef WIFI_GECKO
if (!geckoinit)
return;
#endif
#endif
static char stringBuf[4096];
int len;
va_list va;
va_start(va, format);
if((len = vsnprintf(stringBuf, sizeof(stringBuf), format, va)) > 0)
{
#ifdef DEBUG_TO_FILE
FILE *debugF = fopen("sd:/debug.txt", "a");
if(!debugF)
debugF = fopen("sd:/debug.txt", "w");
if(debugF)
{
fwrite(stringBuf, 1, strlen(stringBuf), debugF);
fclose(debugF);
}
#else
usb_sendbuffer(1, stringBuf, len);
#endif
#ifdef WIFI_GECKO
wifi_printf(stringBuf);
#endif
}
va_end(va);
}
bool InitGecko()
{
u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
if (geckoattached)
{
usb_flush(EXI_CHANNEL_1);
geckoinit = true;
return true;
}
return false;
}
char ascii(char s)
{
if (s < 0x20) return '.';
if (s > 0x7E) return '.';
return s;
}
void hexdump(void *d, int len)
{
u8 *data;
int i, off;
data = (u8*) d;
gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
gprintf("\n==== =============================================== ================\n");
for (off = 0; off < len; off += 16)
{
gprintf("%04x ", off);
for (i = 0; i < 16; i++)
if ((i + off) >= len)
gprintf(" ");
else gprintf("%02x ", data[off + i]);
gprintf(" ");
for (i = 0; i < 16; i++)
if ((i + off) >= len)
gprintf(" ");
else gprintf("%c", ascii(data[off + i]));
gprintf("\n");
}
}
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len)
{
if(len > 0)
usb_sendbuffer(1, ptr, len);
return len;
}
static const devoptab_t gecko_out = {
"stdout", // device name
0, // size of file structure
NULL, // device open
NULL, // device close
__out_write,// device write
NULL, // device read
NULL, // device seek
NULL, // device fstat
NULL, // device stat
NULL, // device link
NULL, // device unlink
NULL, // device chdir
NULL, // device rename
NULL, // device mkdir
0, // dirStateSize
NULL, // device diropen_r
NULL, // device dirreset_r
NULL, // device dirnext_r
NULL, // device dirclose_r
NULL, // device statvfs_r
NULL, // device ftruncate_r
NULL, // device fsync_r
NULL, // device deviceData
NULL, // device chmod_r
NULL, // device fchmod_r
};
void USBGeckoOutput()
{
devoptab_list[STD_OUT] = &gecko_out;
devoptab_list[STD_ERR] = &gecko_out;
}