Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Last active October 1, 2023 21:12
Show Gist options
  • Save vgmoose/fa32485269198030812dedc3e91e85bf to your computer and use it in GitHub Desktop.
Save vgmoose/fa32485269198030812dedc3e91e85bf to your computer and use it in GitHub Desktop.
Wii U homebrew: open the browser and redirect to a given URL
build
code*
redirector*
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <whb/log.h>
#include <whb/log_console.h>
#include <whb/proc.h>
#include <sysapp/switch.h>
#include <string.h>
#define URL "https://forms.gle/NbafboLAc5oqeSQH8"
int main(int argc, char **argv)
{
WHBProcInit();
WHBLogConsoleInit();
SysAppBrowserArgs args = {0};
args.url = URL;
args.urlSize = strlen(URL);
SYSSwitchToBrowserForViewer(&args);
WHBLogPrintf("Opening " URL " in browser!");
WHBLogPrintf("Press HOME to exit.");
WHBLogConsoleDraw();
while(WHBProcIsRunning()) {
WHBLogConsoleDraw();
OSSleepTicks(OSMillisecondsToTicks(500));
}
OSSleepTicks(OSMillisecondsToTicks(500));
WHBLogConsoleFree();
WHBProcShutdown();
return 0;
}
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------
TOPDIR ?= $(CURDIR)
DEVKITPRO ?= /opt/devkitpro
DEVKITPPC ?= $(DEVKITPRO)/devkitPPC
export DEVKITPRO DEVKITPPC
APP_NAME := Survey
APP_SHORTNAME := Survey
APP_AUTHOR := 4TU Team
include $(DEVKITPRO)/wut/share/wut_rules
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := .
DATA := data
INCLUDES := include
CONTENT :=
ICON := icon.jpg
TV_SPLASH :=
DRC_SPLASH :=
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(MACHDEP)
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
CXXFLAGS := $(CFLAGS)
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)
LIBS := -lwut
LIBDIRS := $(PORTLIBS) $(WUT_ROOT)
ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifneq (,$(strip $(CONTENT)))
export APP_CONTENT := $(TOPDIR)/$(CONTENT)
endif
ifneq (,$(strip $(ICON)))
export APP_ICON := $(TOPDIR)/$(ICON)
else ifneq (,$(wildcard $(TOPDIR)/$(TARGET).png))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else ifneq (,$(wildcard $(TOPDIR)/icon.png))
export APP_ICON := $(TOPDIR)/icon.png
endif
ifneq (,$(strip $(TV_SPLASH)))
export APP_TV_SPLASH := $(TOPDIR)/$(TV_SPLASH)
else ifneq (,$(wildcard $(TOPDIR)/tv-splash.png))
export APP_TV_SPLASH := $(TOPDIR)/tv-splash.png
else ifneq (,$(wildcard $(TOPDIR)/splash.png))
export APP_TV_SPLASH := $(TOPDIR)/splash.png
endif
ifneq (,$(strip $(DRC_SPLASH)))
export APP_DRC_SPLASH := $(TOPDIR)/$(DRC_SPLASH)
else ifneq (,$(wildcard $(TOPDIR)/drc-splash.png))
export APP_DRC_SPLASH := $(TOPDIR)/drc-splash.png
else ifneq (,$(wildcard $(TOPDIR)/splash.png))
export APP_DRC_SPLASH := $(TOPDIR)/splash.png
endif
.PHONY: $(BUILD) clean all
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).wuhb $(TARGET).rpx $(TARGET).elf
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
all : $(OUTPUT).wuhb
$(OUTPUT).wuhb : $(OUTPUT).rpx
$(OUTPUT).rpx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN)
%.bin.o %_bin.h : %.bin
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment