remove wiiupc since libogc wiiuse now supports WiiU Pro controller.

remove update check completely. compatibility fixes for newer devkitppc.
This commit is contained in:
Daryl Borth 2018-08-01 12:43:16 -06:00
parent 296eccf273
commit 29ce302842
23 changed files with 85 additions and 851 deletions

View File

@ -28,18 +28,22 @@ INCLUDES := source
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O3 -LTO -Wall $(MACHDEP) $(INCLUDE) \
SHAREDFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
-DFRAMESKIP -DPSS_STYLE=1 -DPATH_MAX=1024 -DHAVE_ASPRINTF \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ -DUSE_VM \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ -DNOUNCRYPT -DNO_SOUND -DUSE_VM \
-fomit-frame-pointer \
-Wno-unused-parameter -Wno-strict-aliasing -Wno-write-strings
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -LTO -Wl,-Map,$(notdir $@).map
-Wno-format -Wno-format-overflow -Wno-stringop-overflow -Wno-format-truncation \
-Wno-unused-parameter -Wno-strict-aliasing -Wno-write-strings -Wno-stringop-truncation -Wno-sign-compare \
-Wno-unused-variable -Wno-parentheses -Wno-unused-function -Wno-switch -Wno-unused-but-set-variable \
-Wno-narrowing -Wno-misleading-indentation -Wno-restrict -Wno-maybe-uninitialized
CFLAGS = $(SHAREDFLAGS) -Wno-incompatible-pointer-types
CXXFLAGS = $(SHAREDFLAGS) -Wno-catch-value -Wno-class-memaccess
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lpng -lmxml -ltinysmb -lbba -lfat -liso9660 -lvorbisidec -lasnd -lz -logc -lfreetype
LIBS := -lpng -lmxml -ltinysmb -lbba -lfat -liso9660 -lasnd -lz -logc -lfreetype
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@ -71,7 +75,6 @@ SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf)))
LANGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.lang)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg)))
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm)))
#---------------------------------------------------------------------------------
@ -87,7 +90,7 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o) \
$(TTFFILES:.ttf=.ttf.o) $(LANGFILES:.lang=.lang.o) \
$(PNGFILES:.png=.png.o) \
$(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o)
$(PCMFILES:.pcm=.pcm.o)
#---------------------------------------------------------------------------------
# build a list of include paths
@ -138,7 +141,7 @@ $(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with these extensions: ttf lang png ogg pcm
# This rule links in binary data with these extensions: ttf lang png pcm
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
@echo $(notdir $<)
@ -152,10 +155,6 @@ $(OUTPUT).elf: $(OFILES)
@echo $(notdir $<)
$(bin2o)
%.ogg.o : %.ogg
@echo $(notdir $<)
$(bin2o)
%.pcm.o : %.pcm
@echo $(notdir $<)
$(bin2o)

View File

@ -28,19 +28,23 @@ INCLUDES := source
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNO_SOUND \
SHAREDFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
-DFRAMESKIP -DPSS_STYLE=1 -DPATH_MAX=1024 -DHAVE_ASPRINTF \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ -DNOUNCRYPT \
-fomit-frame-pointer \
-Wno-unused-parameter -Wno-strict-aliasing -Wno-write-strings
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,-wrap,wiiuse_register
-Wno-format -Wno-format-overflow -Wno-stringop-overflow -Wno-format-truncation \
-Wno-unused-parameter -Wno-strict-aliasing -Wno-write-strings -Wno-stringop-truncation -Wno-sign-compare \
-Wno-unused-variable -Wno-parentheses -Wno-unused-function -Wno-switch -Wno-unused-but-set-variable \
-Wno-narrowing -Wno-misleading-indentation -Wno-restrict -Wno-maybe-uninitialized
CFLAGS = $(SHAREDFLAGS) -Wno-incompatible-pointer-types
CXXFLAGS = $(SHAREDFLAGS) -Wno-catch-value -Wno-class-memaccess
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -ldi -liso9660 -lpng -lmxml \
-lfat -lwiiuse -lwupc -lz -lbte -lasnd -logc -lvorbisidec -lfreetype -ltinysmb
-lfat -lwiiuse -lz -lbte -lasnd -logc -lvorbisidec -lfreetype -ltinysmb
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View File

@ -17,7 +17,6 @@
#include <ogc/system.h>
#include <fat.h>
#include <wiiuse/wpad.h>
#include <wupc/wupc.h>
#include <malloc.h>
#include <sys/iosupport.h>
@ -293,7 +292,7 @@ bool SaneIOS(u32 ios)
static bool gecko = false;
static mutex_t gecko_mutex = 0;
static ssize_t __out_write(struct _reent *r, void* fd, const char *ptr, size_t len)
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len)
{
if (!gecko || len == 0)
return len;
@ -389,12 +388,10 @@ int main(int argc, char *argv[])
SYS_SetPowerCallback(ShutdownCB);
SYS_SetResetCallback(ResetCB);
WUPC_Init();
WPAD_Init();
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
DI_Init();
USBStorage_Initialize();
StartNetworkThread();
#else
DVD_Init (); // Initialize DVD subsystem (GameCube only)
#endif

View File

@ -12,7 +12,6 @@
#ifndef _FCEUGX_H_
#define _FCEUGX_H_
#define MAXPATHLEN 1024
#include <unistd.h>
#include "fceultra/driver.h"
@ -22,6 +21,7 @@
#define APPFOLDER "fceugx"
#define PREF_FILE_NAME "settings.xml"
#define MAXPATHLEN 1024
#define NOTSILENT 0
#define SILENT 1
@ -139,4 +139,4 @@ extern int fskipc;
extern int turbomode;
extern bool romLoaded;
#endif
#endif

View File

@ -13,6 +13,8 @@
#endif
#endif
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -3,6 +3,12 @@
//include this file LAST, or else the #defines will overwrite CRT and STL symbols
#ifdef GEKKO
#undef _X
#undef _S
#undef _P
#endif
#define _PC X.PC
#define _A X.A
#define _X X.X

View File

@ -107,8 +107,6 @@ extern const u8 icon_settings_gamecube_png[];
extern const u32 icon_settings_gamecube_png_size;
extern const u8 icon_settings_nunchuk_png[];
extern const u32 icon_settings_nunchuk_png_size;
extern const u8 icon_settings_wiiupro_png[];
extern const u32 icon_settings_wiiupro_png_size;
extern const u8 icon_settings_nescontroller_png[];
extern const u32 icon_settings_nescontroller_png_size;
@ -324,4 +322,4 @@ extern const u32 player3_grab_png_size;
extern const u8 player4_grab_png[];
extern const u32 player4_grab_png_size;
#endif
#endif

View File

@ -158,7 +158,6 @@ devicecallback (void *arg)
usleep(THREAD_SLEEP);
devsleep -= THREAD_SLEEP;
}
UpdateCheck();
}
return NULL;
}

View File

@ -123,16 +123,6 @@ typedef struct _paddata {
u8 triggerR;
} PADData;
typedef struct _wupcfulldata {
u32 btns_d;
u32 btns_u;
u32 btns_h;
s16 stickX;
s16 stickY;
s16 substickX;
s16 substickY;
} WUPCFullData;
#define EFFECT_SLIDE_TOP 1
#define EFFECT_SLIDE_BOTTOM 2
#define EFFECT_SLIDE_RIGHT 4
@ -236,7 +226,6 @@ class GuiTrigger
WPADData wpaddata; //!< Wii controller trigger data
PADData pad; //!< GameCube controller trigger data
WUPCFullData wupcdata; //!< WiiU Pro controller trigger data
WPADData * wpad; //!< Wii controller trigger
s32 chan; //!< Trigger controller channel (0-3, -1 for all)
u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)
@ -671,7 +660,7 @@ class GuiText : public GuiElement
//!\param s Font size
//!\param h Text alignment (horizontal)
//!\param v Text alignment (vertical)
void SetPresets(int sz, GXColor c, int w, u16 s, int h, int v);
static void SetPresets(int sz, GXColor c, int w, u16 s, int h, int v);
//!Sets the font size
//!\param s Font size
void SetFontSize(int s);

View File

@ -254,7 +254,7 @@ void GuiButton::Update(GuiTrigger * t)
// button triggers
if(this->IsClickable())
{
s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig, wupc_btns, wupc_btns_trig;
s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig;
for(int i=0; i<3; i++)
{
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
@ -267,16 +267,12 @@ void GuiButton::Update(GuiTrigger * t)
cc_btns = t->wpad->btns_d >> 16;
cc_btns_trig = trigger[i]->wpad->btns_d >> 16;
// lower 16 bits only (WiiU Pro controller)
wupc_btns = t->wupcdata.btns_d >> 16;
wupc_btns_trig = trigger[i]->wupcdata.btns_d >> 16;
if(
(t->wpad->btns_d > 0 &&
(wm_btns == wm_btns_trig ||
(cc_btns == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) ||
(t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0) ||
(wupc_btns == wupc_btns_trig && wupc_btns_trig > 0))
(t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0))
{
if(t->chan == stateChan || stateChan == -1)
{
@ -308,7 +304,7 @@ void GuiButton::Update(GuiTrigger * t)
if(this->IsHoldable())
{
bool held = false;
s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig, wupc_btns, wupc_btns_h, wupc_btns_trig;
s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig;
for(int i=0; i<3; i++)
{
@ -324,17 +320,11 @@ void GuiButton::Update(GuiTrigger * t)
cc_btns_h = t->wpad->btns_h >> 16;
cc_btns_trig = trigger[i]->wpad->btns_h >> 16;
// lower 16 bits only (WiiU Pro controller)
wupc_btns = t->wpad->btns_d >> 16;
wupc_btns_h = t->wpad->btns_h >> 16;
wupc_btns_trig = trigger[i]->wpad->btns_h >> 16;
if(
(t->wpad->btns_d > 0 &&
(wm_btns == wm_btns_trig ||
(cc_btns == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) ||
(t->pad.btns_d == trigger[i]->pad.btns_h && t->pad.btns_d > 0) ||
(wupc_btns == wupc_btns_trig && wupc_btns > 0))
(t->pad.btns_d == trigger[i]->pad.btns_h && t->pad.btns_d > 0))
{
if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED &&
(t->chan == stateChan || stateChan == -1))
@ -345,8 +335,8 @@ void GuiButton::Update(GuiTrigger * t)
(t->wpad->btns_h > 0 &&
(wm_btns_h == wm_btns_trig ||
(cc_btns_h == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) ||
(t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0) ||
(wupc_btns_h == wupc_btns_trig && wupc_btns_h > 0))
(t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0))
{
if(trigger[i]->type == TRIGGER_HELD)
held = true;

View File

@ -22,7 +22,6 @@ static u32 delay[4];
GuiTrigger::GuiTrigger()
{
chan = -1;
memset(&wupcdata, 0, sizeof(WUPCFullData));
memset(&wpaddata, 0, sizeof(WPADData));
memset(&pad, 0, sizeof(PADData));
wpad = &wpaddata;
@ -44,7 +43,6 @@ void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{
type = TRIGGER_SIMPLE;
chan = ch;
wupcdata.btns_d = wiibtns;
wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns;
}
@ -58,7 +56,6 @@ void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{
type = TRIGGER_HELD;
chan = ch;
wupcdata.btns_h = wiibtns;
wpaddata.btns_h = wiibtns;
pad.btns_h = gcbtns;
}
@ -71,7 +68,6 @@ void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{
type = TRIGGER_BUTTON_ONLY;
chan = ch;
wupcdata.btns_d = wiibtns;
wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns;
}
@ -85,7 +81,6 @@ void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{
type = TRIGGER_BUTTON_ONLY_IN_FOCUS;
chan = ch;
wupcdata.btns_d = wiibtns;
wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns;
}
@ -162,15 +157,12 @@ bool GuiTrigger::Left()
{
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_UP : WPAD_BUTTON_LEFT;
if(((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT))
|| ((wupcdata.btns_d | wupcdata.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT))
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT
|| pad.stickX < -PADCAL
|| WPAD_StickX(0) < -PADCAL
|| wupcdata.stickX < -WUPCCAL)
|| WPAD_StickX(0) < -PADCAL)
{
if((wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT))
|| (wupcdata.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT))
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| pad.btns_d & PAD_BUTTON_LEFT)
{
prev[chan] = gettime();
@ -198,15 +190,12 @@ bool GuiTrigger::Right()
{
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_DOWN : WPAD_BUTTON_RIGHT;
if(((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT))
|| ((wupcdata.btns_d | wupcdata.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT))
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT
|| pad.stickX > PADCAL
|| WPAD_StickX(0) > PADCAL
|| wupcdata.stickX > WUPCCAL)
|| WPAD_StickX(0) > PADCAL)
{
if((wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT))
|| (wupcdata.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT))
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| pad.btns_d & PAD_BUTTON_RIGHT)
{
prev[chan] = gettime();
@ -234,15 +223,12 @@ bool GuiTrigger::Up()
{
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_RIGHT : WPAD_BUTTON_UP;
if(((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP))
|| ((wupcdata.btns_d | wupcdata.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP))
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP
|| pad.stickY > PADCAL
|| WPAD_StickY(0) > PADCAL
|| wupcdata.stickY > WUPCCAL)
|| WPAD_StickY(0) > PADCAL)
{
if((wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP))
|| (wupcdata.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP))
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| pad.btns_d & PAD_BUTTON_UP)
{
prev[chan] = gettime();
@ -270,15 +256,12 @@ bool GuiTrigger::Down()
{
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_LEFT : WPAD_BUTTON_DOWN;
if(((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN))
|| ((wupcdata.btns_d | wupcdata.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN))
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN
|| pad.stickY < -PADCAL
|| WPAD_StickY(0) < -PADCAL
|| wupcdata.stickY < -WUPCCAL)
|| WPAD_StickY(0) < -PADCAL)
{
if((wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN))
|| wupcdata.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| pad.btns_d & PAD_BUTTON_DOWN)
{
prev[chan] = gettime();

View File

@ -229,7 +229,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
}
// change focus
else if((t->wpad->btns_d & (WPAD_BUTTON_1 | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|| (t->pad.btns_d & PAD_BUTTON_B) || (t->wupcdata.btns_d & WPAD_CLASSIC_BUTTON_B))
|| (t->pad.btns_d & PAD_BUTTON_B))
{
for (i = found; i < elemSize; ++i)
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@ -73,7 +73,6 @@ static GuiWindow * mainWindow = NULL;
static GuiText * settingText = NULL;
static GuiText * settingText2 = NULL;
static int lastMenu = MENU_NONE;
static int wiiuproCtrl = 0;
static int mapMenuCtrl = 0;
static int mapMenuCtrlNES = 0;
@ -252,27 +251,6 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
return choice;
}
#ifdef HW_RVL
/****************************************************************************
* EmulatorUpdate
*
* Prompts for confirmation, and downloads/installs updates
***************************************************************************/
static void *
EmulatorUpdate (void *arg)
{
bool installUpdate = WindowPrompt(
"Update Available",
"An update is available!",
"Update now",
"Update later");
if(installUpdate)
if(DownloadUpdate())
ExitRequested = 1;
return NULL;
}
#endif
/****************************************************************************
* UpdateGUI
*
@ -298,9 +276,9 @@ UpdateGUI (void *arg)
i = 3;
do
{
if(userInput[i].wpad->ir.valid)
Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48,
96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
if(userInput[i].wpad->ir.valid) {
Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48, 96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
}
DoRumble(i);
--i;
} while(i>=0);
@ -313,15 +291,6 @@ UpdateGUI (void *arg)
mainWindow->Update(&userInput[1]);
mainWindow->Update(&userInput[0]);
#ifdef HW_RVL
if(updateFound)
{
updateFound = false;
if(!loadingFile)
LWP_CreateThread (&updatethread, EmulatorUpdate, NULL, NULL, 0, 70);
}
#endif
if(ExitRequested || ShutdownRequested)
{
for(i = 0; i <= 255; i += 15)
@ -799,8 +768,7 @@ static void WindowCredits(void * ptr)
txt[i] = new GuiText("Official Site: https://github.com/dborth/fceugx", 20, (GXColor){0, 0, 0, 255});
txt[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); txt[i]->SetPosition(0,y); i++; y+=32;
txt[i]->SetPresets(20, (GXColor){0, 0, 0, 255}, 0,
FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP);
GuiText::SetPresets(20, (GXColor){0, 0, 0, 255}, 0, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP);
txt[i] = new GuiText("Coding & menu design");
txt[i]->SetPosition(40,y); i++;
@ -847,8 +815,7 @@ static void WindowCredits(void * ptr)
txt[i] = new GuiText("Armin Tamzarian");
txt[i]->SetPosition(335,y); i++; y+=48;
txt[i]->SetPresets(18, (GXColor){0, 0, 0, 255}, 0,
FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP, ALIGN_CENTRE, ALIGN_TOP);
GuiText::SetPresets(18, (GXColor){0, 0, 0, 255}, 0, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP, ALIGN_CENTRE, ALIGN_TOP);
txt[i] = new GuiText("This software is open source and may be copied,");
txt[i]->SetPosition(0,y); i++; y+=20;
@ -884,9 +851,9 @@ static void WindowCredits(void * ptr)
#ifdef HW_RVL
i = 3;
do {
if(userInput[i].wpad->ir.valid)
Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48,
96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
if(userInput[i].wpad->ir.valid) {
Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48, 96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
}
DoRumble(i);
--i;
} while(i >= 0);
@ -894,10 +861,10 @@ static void WindowCredits(void * ptr)
Menu_Render();
if((userInput[0].wpad->btns_d || userInput[0].pad.btns_d || userInput[0].wupcdata.btns_d) ||
(userInput[1].wpad->btns_d || userInput[1].pad.btns_d || userInput[1].wupcdata.btns_d) ||
(userInput[2].wpad->btns_d || userInput[2].pad.btns_d || userInput[2].wupcdata.btns_d) ||
(userInput[3].wpad->btns_d || userInput[3].pad.btns_d || userInput[3].wupcdata.btns_d))
if((userInput[0].wpad->btns_d || userInput[0].pad.btns_d) ||
(userInput[1].wpad->btns_d || userInput[1].pad.btns_d) ||
(userInput[2].wpad->btns_d || userInput[2].pad.btns_d) ||
(userInput[3].wpad->btns_d || userInput[3].pad.btns_d))
{
exit = true;
}
@ -907,7 +874,6 @@ static void WindowCredits(void * ptr)
// clear buttons pressed
for(i=0; i < 4; i++)
{
userInput[i].wupcdata.btns_d = 0;
userInput[i].wpad->btns_d = 0;
userInput[i].pad.btns_d = 0;
}
@ -995,7 +961,7 @@ static int MenuGameSelection()
GuiImage preview;
preview.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
preview.SetPosition(175, -8); //preview.SetPosition(380, 125);
preview.SetPosition(175, -8);
u8* imgBuffer = MEM_ALLOC(512 * 512 * 4);
int previousBrowserIndex = -1;
char screenshotPath[MAXJOLIET + 1];
@ -1495,17 +1461,8 @@ static int MenuGame()
}
else
{
struct WUPCData *data = WUPC_Data(i);
if(data != NULL)
{
newStatus = true;
newLevel = data->battery;
}
else
{
newStatus = false;
newLevel = 0;
}
newStatus = false;
newLevel = 0;
}
if(status[i] != newStatus || level[i] != newLevel)
@ -2392,7 +2349,6 @@ static int MenuSettingsMappingsController()
GuiImageData iconClassic(icon_settings_classic_png);
GuiImageData iconGamecube(icon_settings_gamecube_png);
GuiImageData iconNunchuk(icon_settings_nunchuk_png);
GuiImageData iconWiiupro(icon_settings_wiiupro_png);
GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255});
gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
@ -2446,24 +2402,6 @@ static int MenuSettingsMappingsController()
classicBtn.SetTrigger(trigA);
classicBtn.SetTrigger(trig2);
classicBtn.SetEffectGrow();
GuiText wiiuproBtnTxt("Wii U Pro Controller", 22, (GXColor){0, 0, 0, 255});
wiiuproBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-20);
GuiImage wiiuproBtnImg(&btnLargeOutline);
GuiImage wiiuproBtnImgOver(&btnLargeOutlineOver);
GuiImage wiiuproBtnIcon(&iconWiiupro);
GuiButton wiiuproBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
wiiuproBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
wiiuproBtn.SetPosition(0, 250);
wiiuproBtn.SetLabel(&wiiuproBtnTxt);
wiiuproBtn.SetImage(&wiiuproBtnImg);
wiiuproBtn.SetImageOver(&wiiuproBtnImgOver);
wiiuproBtn.SetIcon(&wiiuproBtnIcon);
wiiuproBtn.SetSoundOver(&btnSoundOver);
wiiuproBtn.SetSoundClick(&btnSoundClick);
wiiuproBtn.SetTrigger(trigA);
wiiuproBtn.SetTrigger(trig2);
wiiuproBtn.SetEffectGrow();
GuiText nunchukBtnTxt1("Wiimote", 22, (GXColor){0, 0, 0, 255});
GuiText nunchukBtnTxt2("&", 18, (GXColor){0, 0, 0, 255});
@ -2516,7 +2454,6 @@ static int MenuSettingsMappingsController()
{
w.Append(&nunchukBtn);
w.Append(&classicBtn);
w.Append(&wiiuproBtn);
}
#endif
w.Append(&backBtn);
@ -2541,13 +2478,6 @@ static int MenuSettingsMappingsController()
}
else if(classicBtn.GetState() == STATE_CLICKED)
{
wiiuproCtrl = 0;
menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
mapMenuCtrl = CTRLR_CLASSIC;
}
else if(wiiuproBtn.GetState() == STATE_CLICKED)
{
wiiuproCtrl = 1;
menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
mapMenuCtrl = CTRLR_CLASSIC;
}
@ -2602,14 +2532,7 @@ ButtonMappingWindow()
sprintf(msg, "Press any button on the Wiimote now. Press Home to clear the existing mapping.");
break;
case CTRLR_CLASSIC:
if(wiiuproCtrl == 1)
{
sprintf(msg, "Press any button on the Wii U Pro Controller now. Press Home to clear the existing mapping.");
}
else
{
sprintf(msg, "Press any button on the Classic Controller now. Press Home to clear the existing mapping.");
}
sprintf(msg, "Press any button on the Classic Controller now. Press Home to clear the existing mapping.");
break;
case CTRLR_NUNCHUK:
sprintf(msg, "Press any button on the Wiimote or Nunchuk now. Press Home to clear the existing mapping.");
@ -2677,13 +2600,10 @@ ButtonMappingWindow()
break;
}
}
if(pressed == 0)
pressed = userInput[0].wupcdata.btns_d;
}
}
if(pressed == WPAD_BUTTON_HOME
|| pressed == WPAD_CLASSIC_BUTTON_HOME)
if(pressed == WPAD_BUTTON_HOME || pressed == WPAD_CLASSIC_BUTTON_HOME)
pressed = 0;
HaltGui();
@ -2709,14 +2629,7 @@ static int MenuSettingsMappingsMap()
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,30);
if(wiiuproCtrl == 1)
{
sprintf(menuSubtitle, "%s - %s", gettext(ctrlName[mapMenuCtrlNES]),"Wii U Pro Controller");
}
else
{
sprintf(menuSubtitle, "%s - %s", gettext(ctrlName[mapMenuCtrlNES]), gettext(ctrlrName[mapMenuCtrl]));
}
sprintf(menuSubtitle, "%s - %s", gettext(ctrlName[mapMenuCtrlNES]), gettext(ctrlrName[mapMenuCtrl]));
GuiText subtitleTxt(menuSubtitle, 20, (GXColor){255, 255, 255, 255});
subtitleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
subtitleTxt.SetPosition(50,60);
@ -2858,7 +2771,7 @@ static int MenuSettingsMappingsMap()
optionBrowser.TriggerUpdate();
}
}
wiiuproCtrl = 0;
HaltGui();
mainWindow->Remove(&optionBrowser);
mainWindow->Remove(&w);

View File

@ -9,20 +9,17 @@
* Network and SMB support routines
****************************************************************************/
#include <errno.h>
#include <gccore.h>
#include <network.h>
#include <malloc.h>
#include <ogc/lwp_watchdog.h>
#include <smb.h>
#include <mxml.h>
#include "fceugx.h"
#include "menu.h"
#include "fileop.h"
#include "filebrowser.h"
#include "utils/http.h"
#include "utils/unzip/unzip.h"
#include "utils/unzip/miniunz.h"
static bool networkInit = false;
static bool networkShareInit = false;
@ -30,144 +27,6 @@ char wiiIP[16] = { 0 };
#ifdef HW_RVL
static int netHalt = 0;
static bool updateChecked = false; // true if checked for app update
static char updateURL[128]; // URL of app update
bool updateFound = false; // true if an app update was found
/****************************************************************************
* UpdateCheck
* Checks for an update for the application
***************************************************************************/
void UpdateCheck()
{
// we only check for an update if we have internet + SD/USB
if(updateChecked || !networkInit)
return;
if(!isMounted[DEVICE_SD] && !isMounted[DEVICE_USB])
return;
updateChecked = true;
u8 tmpbuffer[256];
if (http_request("http://www.wiimc.org/files/fceugx-update.xml", NULL, tmpbuffer, 256, SILENT) <= 0)
return;
mxml_node_t *xml;
mxml_node_t *item;
xml = mxmlLoadString(NULL, (char *)tmpbuffer, MXML_TEXT_CALLBACK);
if(!xml)
return;
// check settings version
item = mxmlFindElement(xml, xml, "app", "version", NULL, MXML_DESCEND);
if(item) // a version entry exists
{
const char * version = mxmlElementGetAttr(item, "version");
if(version && strlen(version) == 5)
{
int verMajor = version[0] - '0';
int verMinor = version[2] - '0';
int verPoint = version[4] - '0';
int curMajor = APPVERSION[0] - '0';
int curMinor = APPVERSION[2] - '0';
int curPoint = APPVERSION[4] - '0';
// check that the versioning is valid and is a newer version
if((verMajor >= 0 && verMajor <= 9 &&
verMinor >= 0 && verMinor <= 9 &&
verPoint >= 0 && verPoint <= 9) &&
(verMajor > curMajor ||
(verMajor == curMajor && verMinor > curMinor) ||
(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
{
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
if(item)
{
const char * tmp = mxmlElementGetAttr(item, "url");
if(tmp)
{
snprintf(updateURL, 128, "%s", tmp);
updateFound = true;
}
}
}
}
}
mxmlDelete(xml);
}
static bool unzipArchive(char * zipfilepath, char * unzipfolderpath)
{
unzFile uf = unzOpen(zipfilepath);
if (uf==NULL)
return false;
if(chdir(unzipfolderpath)) // can't access dir
{
makedir(unzipfolderpath); // attempt to make dir
if(chdir(unzipfolderpath)) // still can't access dir
return false;
}
extractZip(uf,0,1,0);
unzCloseCurrentFile(uf);
return true;
}
bool DownloadUpdate()
{
bool result = false;
if(updateURL[0] == 0 || appPath[0] == 0 || !ChangeInterface(appPath, NOTSILENT))
{
ErrorPrompt("Update failed!");
updateFound = false; // updating is finished (successful or not!)
return false;
}
// stop checking if devices were removed/inserted
// since we're saving a file
HaltDeviceThread();
int device;
FindDevice(appPath, &device);
char updateFile[50];
sprintf(updateFile, "%s%s Update.zip", pathPrefix[device], APPNAME);
FILE * hfile = fopen (updateFile, "wb");
if (hfile)
{
if(http_request(updateURL, hfile, NULL, (1024*1024*10), NOTSILENT) > 0)
{
fclose (hfile);
result = unzipArchive(updateFile, (char *)pathPrefix[device]);
}
else
{
fclose (hfile);
}
remove(updateFile); // delete update file
}
// go back to checking if devices were inserted/removed
ResumeDeviceThread();
if(result)
InfoPrompt("Update successful!");
else
ErrorPrompt("Update failed!");
updateFound = false; // updating is finished (successful or not!)
return result;
}
/****************************************************************************
* InitializeNetwork
@ -315,7 +174,7 @@ bool InitializeNetwork(bool silent)
break;
}
#else
networkInit = !(if_config(wiiIP, NULL, NULL, true, 10) < 0);
networkInit = !(if_config(wiiIP, NULL, NULL, true) < 0);
#endif
CancelAction();

View File

@ -11,14 +11,8 @@
#ifndef _NETWORKOP_H_
#define _NETWORKOP_H_
void UpdateCheck();
bool DownloadUpdate();
void StartNetworkThread();
bool InitializeNetwork(bool silent);
;
bool ConnectShare (bool silent);
void CloseShare();
extern bool updateFound;
#endif

View File

@ -191,7 +191,6 @@ void
UpdatePads()
{
#ifdef HW_RVL
WUPC_UpdateButtonStats();
WPAD_ScanPads();
#endif
@ -208,15 +207,6 @@ UpdatePads()
userInput[i].pad.substickY = PAD_SubStickY(i);
userInput[i].pad.triggerL = PAD_TriggerL(i);
userInput[i].pad.triggerR = PAD_TriggerR(i);
#ifdef HW_RVL
userInput[i].wupcdata.btns_d = WUPC_ButtonsDown(i);
userInput[i].wupcdata.btns_u = WUPC_ButtonsUp(i);
userInput[i].wupcdata.btns_h = WUPC_ButtonsHeld(i);
userInput[i].wupcdata.stickX = WUPC_lStickX(i);
userInput[i].wupcdata.stickY = WUPC_lStickY(i);
userInput[i].wupcdata.substickX = WUPC_rStickX(i);
userInput[i].wupcdata.substickY = WUPC_rStickY(i);
#endif
}
}
@ -298,7 +288,6 @@ static int pos_y = 0;
static void UpdateCursorPosition (int chan)
{
#define ZAPPERPADCAL 20
#define WUPCZAPPERPADCAL 160
// gc left joystick
if (userInput[chan].pad.stickX > ZAPPERPADCAL)
@ -354,32 +343,6 @@ static void UpdateCursorPosition (int chan)
pos_y -= (wm_ay*1.0)/ZAPPERPADCAL;
if (pos_y < 0) pos_y = 0;
}
/* WiiU Pro Controller */
s8 wupc_ax = userInput[chan].wupcdata.stickX;
s8 wupc_ay = userInput[chan].wupcdata.stickX;
if (wupc_ax > WUPCZAPPERPADCAL)
{
pos_x += (wupc_ax*1.0)/WUPCZAPPERPADCAL;
if (pos_x > 256) pos_x = 256;
}
if (wupc_ax < -WUPCZAPPERPADCAL)
{
pos_x -= (wupc_ax*-1.0)/WUPCZAPPERPADCAL;
if (pos_x < 0) pos_x = 0;
}
if (wupc_ay < -WUPCZAPPERPADCAL)
{
pos_y += (wupc_ay*-1.0)/WUPCZAPPERPADCAL;
if (pos_y > 224) pos_y = 224;
}
if (wupc_ay > WUPCZAPPERPADCAL)
{
pos_y -= (wupc_ay*1.0)/WUPCZAPPERPADCAL;
if (pos_y < 0) pos_y = 0;
}
}
#endif
}
@ -407,10 +370,6 @@ static unsigned char DecodeJoy(unsigned short chan)
u32 exp_type;
if ( WPAD_Probe(chan, &exp_type) != 0 )
exp_type = WPAD_EXP_NONE;
s16 wupc_ax = userInput[chan].wupcdata.stickX;
s16 wupc_ay = userInput[chan].wupcdata.stickY;
u32 wupcp = userInput[chan].wupcdata.btns_h;
#endif
/***
@ -448,20 +407,6 @@ static unsigned char DecodeJoy(unsigned short chan)
else if(sin(angle) < -THRES)
J |= JOY_DOWN;
}
/* WiiU Pro Controller */
if (wupc_ax * wupc_ax + wupc_ay * wupc_ay > WUPCCAL * WUPCCAL)
{
angle = atan2(wupc_ay, wupc_ax);
if(cos(angle) > THRES)
J |= JOY_RIGHT;
else if(cos(angle) < -THRES)
J |= JOY_LEFT;
if(sin(angle) > THRES)
J |= JOY_UP;
else if(sin(angle) < -THRES)
J |= JOY_DOWN;
}
#endif
bool zapper_triggered = false;
@ -525,7 +470,6 @@ static unsigned char DecodeJoy(unsigned short chan)
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) ) // wiimote
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) ) // classic controller
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote
|| ( (wupcp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) ) // WiiU Pro Controller
#endif
)
{
@ -580,8 +524,7 @@ bool MenuRequested()
)
#ifdef HW_RVL
|| (userInput[i].wpad->btns_h & WPAD_BUTTON_HOME) ||
(userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME) ||
(userInput[i].wupcdata.btns_h & WPAD_CLASSIC_BUTTON_HOME)
(userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME)
#endif
)
{
@ -601,7 +544,7 @@ void GetJoy()
// Turbo mode
// RIGHT on c-stick and on classic ctrlr right joystick
if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_StickX(1) > 70 || userInput[0].wupcdata.substickX > 560)
if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_StickX(1) > 70)
turbomode = 1;
else
turbomode = 0;

View File

@ -14,11 +14,9 @@
#include <gctypes.h>
#include <wiiuse/wpad.h>
#include <wupc/wupc.h>
#define PI 3.14159265f
#define PADCAL 50
#define WUPCCAL 400
#define MAXJP 11
#define RAPID_A 256
#define RAPID_B 512

View File

@ -21,7 +21,6 @@ When compiling in Visual Studio, set the project to compile
as C++ code (Properties -> C/C++ -> Advanced -> Compile As.)
*/
#include <memory.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <ogcsys.h>
#include <mxml.h>
@ -275,17 +276,12 @@ decodePrefsData ()
int verMajor = version[0] - '0';
int verMinor = version[2] - '0';
int verPoint = version[4] - '0';
int curMajor = APPVERSION[0] - '0';
int curMinor = APPVERSION[2] - '0';
int curPoint = APPVERSION[4] - '0';
// first we'll check that the versioning is valid
if(!(verMajor >= 0 && verMajor <= 9 &&
// check that the versioning is valid
if(!(verMajor >= 3 && verMajor <= 9 &&
verMinor >= 0 && verMinor <= 9 &&
verPoint >= 0 && verPoint <= 9))
result = false;
else if(verMajor < 3) // less than version 3.0.0
result = false; // reset settings
else
result = true;
}
@ -584,6 +580,8 @@ bool LoadPrefs()
sprintf(filepath[1], "cardb:/%s", APPFOLDER);
#endif
printf("in load prefs\n");
for(int i=0; i<numDevices; i++)
{
prefFound = LoadPrefsFromMethod(filepath[i]);

View File

@ -1,412 +0,0 @@
/****************************************************************************
* FCE Ultra
* Nintendo Wii/Gamecube Port
*
* Tantric December 2008
*
* http.cpp
*
* HTTP operations
* Written by dhewg/bushing, modified by Tantric
***************************************************************************/
#ifdef HW_RVL
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <ogcsys.h>
#include <network.h>
#include <ogc/lwp_watchdog.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <fcntl.h>
#include "menu.h"
#include "http.h"
#define TCP_CONNECT_TIMEOUT 4000 // 4 secs to make a connection
#define TCP_SEND_SIZE (32 * 1024)
#define TCP_RECV_SIZE (32 * 1024)
#define TCP_BLOCK_RECV_TIMEOUT 4000 // 4 secs to receive
#define TCP_BLOCK_SEND_TIMEOUT 4000 // 4 secs to send
#define TCP_BLOCK_SIZE 1024
#define HTTP_TIMEOUT 10000 // 10 secs to get an http response
#define IOS_O_NONBLOCK 0x04
static s32 tcp_socket(void)
{
s32 s, res;
s = net_socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
if (s < 0)
return s;
// Switch off Nagle with TCP_NODELAY
u32 nodelay = 1;
net_setsockopt(s,IPPROTO_TCP,TCP_NODELAY,&nodelay,sizeof(nodelay));
res = net_fcntl(s, F_GETFL, 0);
if (res < 0)
{
net_close(s);
return res;
}
res = net_fcntl(s, F_SETFL, res | IOS_O_NONBLOCK);
if (res < 0)
{
net_close(s);
return res;
}
return s;
}
static s32 tcp_connect(char *host, const u16 port)
{
struct hostent *hp;
struct sockaddr_in sa;
struct in_addr val;
s32 s, res;
u64 t1;
s = tcp_socket();
if (s < 0)
return s;
memset(&sa, 0, sizeof(struct sockaddr_in));
sa.sin_family= PF_INET;
sa.sin_len = sizeof(struct sockaddr_in);
sa.sin_port= htons(port);
if(strlen(host) < 16 && inet_aton(host, &val))
{
sa.sin_addr.s_addr = val.s_addr;
}
else
{
hp = net_gethostbyname (host);
if (!hp || !(hp->h_addrtype == PF_INET))
return errno;
memcpy((char *) &sa.sin_addr, hp->h_addr_list[0], hp->h_length);
}
t1=ticks_to_secs(gettime());
do
{
res = net_connect(s,(struct sockaddr*) &sa, sizeof (sa));
if(ticks_to_secs(gettime())-t1 > TCP_CONNECT_TIMEOUT*1000) break;
usleep(500);
}while(res != -EISCONN);
if(res != -EISCONN)
{
net_close(s);
return -1;
}
return s;
}
static int tcp_readln(const s32 s, char *buf, const u16 max_length)
{
s32 res = -1;
s32 ret;
u64 start_time = gettime();
u16 c = 0;
while (c < max_length)
{
if (ticks_to_millisecs(diff_ticks(start_time, gettime())) > HTTP_TIMEOUT)
break;
ret = net_read(s, &buf[c], 1);
if (ret == -EAGAIN)
{
usleep(20 * 1000);
continue;
}
if (ret <= 0)
break;
if (c > 0 && buf[c - 1] == '\r' && buf[c] == '\n')
{
res = 0;
buf[c-1] = 0;
break;
}
c++;
start_time = gettime();
usleep(100);
}
return res;
}
static u32 tcp_read(const s32 s, u8 *buffer, const u32 length)
{
char *p;
u32 left, block, received, step=0;
u64 t;
s32 res;
p = (char *)buffer;
left = length;
received = 0;
t = gettime();
while (left)
{
if (ticks_to_millisecs(diff_ticks(t, gettime()))
> TCP_BLOCK_RECV_TIMEOUT)
{
break;
}
block = left;
if (block > TCP_RECV_SIZE)
block = TCP_RECV_SIZE;
res = net_read(s, p, block);
if (res == -EAGAIN)
{
usleep(20 * 1000);
continue;
}
if(res<=0) break;
received += res;
left -= res;
p += res;
usleep(1000);
if ((received / TCP_BLOCK_SIZE) > step)
{
t = gettime ();
step++;
}
}
return received;
}
static u32 tcp_write(const s32 s, const u8 *buffer, const u32 length)
{
const u8 *p;
u32 left, block, sent, step=0;
s64 t;
s32 res;
p = buffer;
left = length;
sent = 0;
t = gettime();
while (left)
{
if (ticks_to_millisecs(diff_ticks(t, gettime()))
> TCP_BLOCK_SEND_TIMEOUT)
{
break;
}
block = left;
if (block > TCP_SEND_SIZE)
block = TCP_SEND_SIZE;
res = net_write(s, p, block);
if ((res == 0) || (res == -56))
{
usleep(20 * 1000);
continue;
}
if (res < 0)
break;
sent += res;
left -= res;
p += res;
usleep(100);
if ((sent / TCP_BLOCK_SIZE) > step)
{
t = gettime ();
step++;
}
}
return left == 0;
}
static bool http_split_url(char *host, char *path, const char *url)
{
const char *p;
char *c;
if (strncasecmp(url, "http://", 7))
return false;
p = url + 7;
c = strchr(p, '/');
if (c == NULL || c[0] == 0)
return false;
snprintf(host, c-p+1, "%s", p);
strcpy(path, c);
return true;
}
#define MAX_SIZE (1024*1024*15)
/****************************************************************************
* http_request
* Retrieves the specified URL, and stores it in the specified file or buffer
***************************************************************************/
int http_request(const char *url, FILE *hfile, u8 *buffer, u32 maxsize, bool silent)
{
int res = 0;
char http_host[1024];
char http_path[1024];
u16 http_port;
http_res result;
u32 http_status;
u32 sizeread = 0, content_length = 0;
int linecount;
if(maxsize > MAX_SIZE)
return 0;
if (url == NULL || (hfile == NULL && buffer == NULL))
return 0;
if (!http_split_url(http_host, http_path, url))
return 0;
http_port = 80;
http_status = 404;
int s = tcp_connect(http_host, http_port);
if (s < 0)
{
result = HTTPR_ERR_CONNECT;
return 0;
}
char request[1024];
char *r = request;
r += sprintf(r, "GET %s HTTP/1.1\r\n", http_path);
r += sprintf(r, "Host: %s\r\n", http_host);
r += sprintf(r, "Cache-Control: no-cache\r\n\r\n");
res = tcp_write(s, (u8 *) request, strlen(request));
char line[256];
for (linecount = 0; linecount < 32; linecount++)
{
if (tcp_readln(s, line, 255) != 0)
{
http_status = 404;
result = HTTPR_ERR_REQUEST;
break;
}
if (strlen(line) < 1)
break;
sscanf(line, "HTTP/1.%*u %u", &http_status);
sscanf(line, "Content-Length: %u", &content_length);
}
if (http_status != 200)
{
result = HTTPR_ERR_STATUS;
net_close(s);
return 0;
}
// length unknown - just read as much as we can
if(content_length == 0)
{
content_length = maxsize;
}
else if (content_length > maxsize)
{
result = HTTPR_ERR_TOOBIG;
net_close(s);
return 0;
}
if (buffer != NULL)
{
if(!silent)
ShowAction("Downloading...");
sizeread = tcp_read(s, buffer, content_length);
if(!silent)
CancelAction();
}
else
{
// read into file
u32 bufSize = (1024 * 32);
u32 bytesLeft = content_length;
u32 readSize;
if(!silent)
ShowProgress("Downloading...", 0, content_length);
u8 * fbuffer = (u8 *) malloc(bufSize);
if(fbuffer)
{
while (bytesLeft > 0)
{
if (bytesLeft < bufSize)
readSize = bytesLeft;
else
readSize = bufSize;
res = tcp_read(s, fbuffer, readSize);
if (!res)
break;
sizeread += res;
bytesLeft -= res;
res = fwrite(fbuffer, 1, res, hfile);
if (!res)
break;
if(!silent)
ShowProgress("Downloading...", (content_length - bytesLeft), content_length);
}
free(fbuffer);
}
if(!silent)
CancelAction();
}
net_close(s);
if (content_length < maxsize && sizeread != content_length)
{
result = HTTPR_ERR_RECEIVE;
return 0;
}
result = HTTPR_OK;
return sizeread;
}
#endif

View File

@ -1,26 +0,0 @@
/****************************************************************************
* FCE Ultra
* Nintendo Wii/Gamecube Port
*
* Tantric December 2008
*
* http.h
*
* HTTP operations
***************************************************************************/
#ifndef _HTTP_H_
#define _HTTP_H_
typedef enum {
HTTPR_OK,
HTTPR_ERR_CONNECT,
HTTPR_ERR_REQUEST,
HTTPR_ERR_STATUS,
HTTPR_ERR_TOOBIG,
HTTPR_ERR_RECEIVE
} http_res;
int http_request (const char *url, FILE * hfile, u8 * buffer, const u32 max_size, bool silent);
#endif

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include "pngu.h"
#include <png.h>