Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WiiU support #19

Merged
merged 2 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Makefile.wiiu
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
BASEDIR := $(dir $(firstword $(MAKEFILE_LIST)))
VPATH := $(BASEDIR)


GET := ./libs/get/src
RAPIDJSON := ./libs/get/src/libs/rapidjson/include
MINIZIP := ./libs/get/src/libs/minizip

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := appstore
BUILD := build
SOURCES := . $(GET) $(MINIZIP) console gui
INCLUDES := -I. -I$(RAPIDJSON) -I$(MINIZIP)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS += -DUSE_FILE32API -DNOCRYPT -DINPUT_JOYSTICK $(INCLUDES)
CXXFLAGS += $(CFLAGS)
LDFLAGS += $(WUT_NEWLIB_LDFLAGS) $(WUT_STDCPP_LDFLAGS) $(WUT_DEVOPTAB_LDFLAGS) \
-lSDL2_ttf -lfreetype -lpng -lSDL2_gfx -lSDL2_image -lSDL2 -ljpeg -lz -lzip \
-lcoreinit -lvpad -lsysapp -lnsysnet -lnlibcurl -lproc_ui -lgx2 -lgfd -lwhb

#---------------------------------------------------------------------------------
# get a list of objects
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cpp))
SFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.s))
OBJECTS := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

#---------------------------------------------------------------------------------
# objectives
#---------------------------------------------------------------------------------
$(TARGET).rpx: $(OBJECTS)

clean:
rm -rf $(TARGET).rpx $(TARGET).rpx.elf $(OBJECTS) $(OBJECTS:.o=.d)

#---------------------------------------------------------------------------------
# wut
#---------------------------------------------------------------------------------
WUT_KEEP_RPLELF := 1
include $(WUT_ROOT)/share/wut.mk

#---------------------------------------------------------------------------------
# portlibs
#---------------------------------------------------------------------------------
PORTLIBS := $(DEVKITPRO)/portlibs/ppc
LDFLAGS += -L$(PORTLIBS)/lib
CFLAGS += -I$(PORTLIBS)/include
CXXFLAGS += -I$(PORTLIBS)/include
29 changes: 25 additions & 4 deletions console/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

Input::Input()
{
#if defined(INPUT_JOYSTICK)
if(SDL_Init(SDL_INIT_JOYSTICK) < 0)
return;

for (int i = 0; i < SDL_NumJoysticks(); i++)
if (!SDL_JoystickOpen(i))
printf("SDL_JoystickOpen: %s\n", SDL_GetError());
#endif
}

void Input::close()
Expand All @@ -10,17 +18,29 @@ void Input::close()

void Input::updateButtons()
{
// reset buttons
this->btns_h = 0b00000000;

SDL_Event event;
SDL_PollEvent(&event);

// reset buttons
this->btns_h = 0b00000000;

this->lstick_x = 0;
this->lstick_y = 0;
this->rstick_x = 0;
this->rstick_x = 0;


#if defined(INPUT_JOYSTICK)
if (event.type == SDL_JOYBUTTONDOWN)
{
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_A)? BUTTON_A : 0);
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_B)? BUTTON_B : 0);
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)? BUTTON_UP : 0);
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_MAX)? BUTTON_DOWN : 0);
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)? BUTTON_LEFT : 0);
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)? BUTTON_RIGHT : 0);
this->btns_h |= ((event.jbutton.button == SDL_CONTROLLER_BUTTON_DPAD_UP)? BUTTON_MINUS : 0);
}
#else
if (event.type == SDL_KEYDOWN)
{
this->btns_h |= ((event.key.keysym.sym == SDLK_a)? BUTTON_A : 0);
Expand All @@ -32,6 +52,7 @@ void Input::updateButtons()
this->btns_h |= ((event.key.keysym.sym == SDLK_MINUS|| event.key.keysym.sym == SDLK_RETURN)? BUTTON_MINUS : 0);
this->btns_h |= ((event.key.keysym.sym == SDLK_x)? BUTTON_X : 0);
}
#endif
}

bool Input::held(char b)
Expand Down
5 changes: 5 additions & 0 deletions gui/MainDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ bool MainDisplay::process(InputEvents* event)
// if we're on the splash/loading screen, we need to fetch icons+screenshots from the remote repo
// and load them into our surface cache with the pkg_name+version as the key

#if defined(__WIIU__)
//FIXME
if (this->showingSplash /*&& event->noop*/)
#else
if (this->showingSplash && event->noop)
#endif
{
// should be a progress bar
if (this->get->packages.size() != 1)
Expand Down
30 changes: 30 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,41 @@
#include <switch.h>
#endif

#if defined(__WIIU__)
#include <unistd.h>


//remove when the wiiu starts working
#include <whb/log.h>
#include <whb/log_udp.h>
#include <sys/iosupport.h>
static devoptab_t dotab_stdout;
static ssize_t wiiu_log_write (struct _reent *r, void *fd, const char *ptr, size_t len) {
WHBLogPrintf("%*.*s", len, len, ptr);
return len;
}

#endif

int main(int argc, char *argv[])
{
// consoleDebugInit(debugDevice_SVC);
// stdout = stderr; // for yuzu

#if defined(__WIIU__)

//remove when the wiiu starts working
WHBLogUdpInit();
memset(&dotab_stdout, 0, sizeof(devoptab_t));
dotab_stdout.name = "stdout_udp";
dotab_stdout.write_r = &wiiu_log_write;
devoptab_list[STD_OUT] = &dotab_stdout;
devoptab_list[STD_ERR] = &dotab_stdout;


chdir("fs:/vol/external01/wiiu/apps/appstore");
#endif

#if defined(NOGUI)
// if NOGUI variable defined, use the console's main method
int console_main(void);
Expand Down