-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d6eaf9
commit 830560b
Showing
14 changed files
with
395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
build/ | ||
Build/ | ||
Output/ | ||
*.nso | ||
*.nro | ||
*.elf | ||
.vscode/ | ||
.vs/ | ||
bin/ | ||
obj/ | ||
target/ | ||
.settings/ | ||
.classpath | ||
.project | ||
*.cmd | ||
*.pfs0 | ||
*.nacp |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
^http* |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
|
||
ifeq ($(strip $(DEVKITPRO)),) | ||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") | ||
endif | ||
|
||
TOPDIR ?= $(CURDIR) | ||
include $(DEVKITPRO)/libnx/switch_rules | ||
|
||
#--------------------------------------------------------------------------------- | ||
# 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 | ||
# DATA is a list of directories containing data files | ||
# INCLUDES is a list of directories containing header files | ||
# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". | ||
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional) | ||
# | ||
# NO_ICON: if set to anything, do not use icon. | ||
# NO_NACP: if set to anything, no .nacp file is generated. | ||
# APP_TITLE is the name of the app stored in the .nacp file (Optional) | ||
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional) | ||
# APP_VERSION is the version of the app stored in the .nacp file (Optional) | ||
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) | ||
# ICON is the filename of the icon (.jpg), relative to the project folder. | ||
# If not set, it attempts to use one of the following (in this order): | ||
# - <Project name>.jpg | ||
# - icon.jpg | ||
# - <libnx folder>/default_icon.jpg | ||
#--------------------------------------------------------------------------------- | ||
TARGET := $(notdir $(CURDIR)) | ||
BUILD := build | ||
SOURCES := Source | ||
DATA := data | ||
INCLUDES := Include | ||
EXEFS_SRC := exefs_src | ||
# ROMFS := romfs | ||
|
||
APP_TITLE := BrowseNX | ||
APP_AUTHOR := Kronos2308 | ||
APP_VERSION := 0.2 | ||
APP_TITLEID := 050032A5CF12E001 | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE | ||
|
||
CFLAGS := -g -Wall -O2 -ffunction-sections \ | ||
$(ARCH) $(DEFINES) | ||
|
||
CFLAGS += $(INCLUDE) -D__SWITCH__ -DTITLE='"$(APP_TITLE)"' -DVERSION='"$(APP_VERSION)"' | ||
|
||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions | ||
|
||
ASFLAGS := -g $(ARCH) | ||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) | ||
|
||
LIBS := -lnx | ||
|
||
#--------------------------------------------------------------------------------- | ||
# list of directories containing libraries, this must be the top level containing | ||
# include and lib | ||
#--------------------------------------------------------------------------------- | ||
LIBDIRS := $(PORTLIBS) $(LIBNX) | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
# no real need to edit anything past this point unless you need to add additional | ||
# rules for different file extensions | ||
#--------------------------------------------------------------------------------- | ||
ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
#--------------------------------------------------------------------------------- | ||
|
||
export OUTPUT := $(CURDIR)/Output/temp/$(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)/*.*))) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# use CXX for linking C++ projects, CC for standard C | ||
#--------------------------------------------------------------------------------- | ||
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) | ||
|
||
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC) | ||
|
||
ifeq ($(strip $(ICON)),) | ||
icons := $(wildcard *.jpg) | ||
ifneq (,$(findstring $(TARGET).jpg,$(icons))) | ||
export APP_ICON := $(TOPDIR)/$(TARGET).jpg | ||
else | ||
ifneq (,$(findstring icon.jpg,$(icons))) | ||
export APP_ICON := $(TOPDIR)/icon.jpg | ||
endif | ||
endif | ||
else | ||
export APP_ICON := $(TOPDIR)/$(ICON) | ||
endif | ||
|
||
ifeq ($(strip $(NO_ICON)),) | ||
export NROFLAGS += --icon=$(APP_ICON) | ||
endif | ||
|
||
ifeq ($(strip $(NO_NACP)),) | ||
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp | ||
endif | ||
|
||
ifneq ($(APP_TITLEID),) | ||
export NACPFLAGS += --titleid=$(APP_TITLEID) | ||
endif | ||
|
||
ifneq ($(ROMFS),) | ||
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) | ||
endif | ||
|
||
.PHONY: $(BUILD) clean all | ||
|
||
#--------------------------------------------------------------------------------- | ||
all: $(BUILD) | ||
|
||
$(BUILD): | ||
@[ -d $@ ] || mkdir -p $@ | ||
@[ -d $(CURDIR)/Output/temp ] || mkdir -p $(CURDIR)/Output/temp | ||
@[ -d $(CURDIR)/Output/control ] || mkdir -p $(CURDIR)/Output/control | ||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
@rm -rf $(CURDIR)/Control | ||
mkdir -p $(CURDIR)/Control | ||
@cp $(OUTPUT).nacp $(CURDIR)/Output/control/control.nacp | ||
@cp $(CURDIR)/Icon.jpg $(CURDIR)/Output/control/icon_AmericanEnglish.dat | ||
@$(CURDIR)/BuildTools/hacbrewpack.exe -k $(CURDIR)/BuildTools/keys.dat --titleid $(APP_TITLEID) --exefsdir $(BUILD)/exefs --noromfs --logodir $(CURDIR)/Logo --controldir $(CURDIR)/Output/control --htmldocdir $(CURDIR)/HtmlDoc --nspdir $(CURDIR)/build | ||
@rm -rf $(CURDIR)/Output/control | ||
@rm -rf $(CURDIR)/Output/temp | ||
@mv $(CURDIR)/build/$(APP_TITLEID).nsp "$(CURDIR)/Output/$(APP_TITLE)[$(APP_TITLEID)][v0].nsp" | ||
|
||
#--------------------------------------------------------------------------------- | ||
clean: | ||
@echo clean ... | ||
@rm -fr $(BUILD) $(TARGET).nso $(TARGET).elf | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
else | ||
.PHONY: all | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
all : $(OUTPUT).nso $(OUTPUT).pfs0 $(OUTPUT).nacp | ||
|
||
$(OUTPUT).nso : $(OUTPUT).elf | ||
|
||
$(OUTPUT).elf : $(OFILES) | ||
|
||
$(OFILES_SRC) : $(HFILES_BIN) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# you need a rule like this for each extension you use as binary data | ||
#--------------------------------------------------------------------------------- | ||
%.bin.o %_bin.h : %.bin | ||
#--------------------------------------------------------------------------------- | ||
@echo $(notdir $<) | ||
@$(bin2o) | ||
|
||
-include $(DEPENDS) | ||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include <cstring> | ||
#include <switch.h> | ||
#include <unistd.h> | ||
#include <iostream> | ||
#include <ostream> | ||
#include "applet.hpp" | ||
|
||
extern AccountUid uid; | ||
extern u32 __nx_applet_exit_mode; | ||
extern std::string urlc; | ||
|
||
bool GetAppletMode() | ||
{ | ||
AppletType at = appletGetAppletType(); | ||
if (at != AppletType_Application && at != AppletType_SystemApplication) | ||
{ | ||
return true; | ||
} | ||
__nx_applet_exit_mode = 1; | ||
return false; | ||
} | ||
|
||
SwkbdTextCheckResult Keyboard_ValidateText(char *string, size_t size) { | ||
if (strcmp(string, "") == 0) { | ||
strncpy(string, "No has escrito nada!.", size); | ||
return SwkbdTextCheckResult_Bad; | ||
} | ||
|
||
return SwkbdTextCheckResult_OK; | ||
} | ||
|
||
std::string KeyboardCall (std::string hint, std::string text){ | ||
Result ret = 0; | ||
SwkbdConfig swkbd; | ||
static char input_string[256]; | ||
|
||
if (R_FAILED(ret = swkbdCreate(&swkbd, 0))) { | ||
swkbdClose(&swkbd); | ||
return ""; | ||
} | ||
|
||
swkbdConfigMakePresetDefault(&swkbd); | ||
//swkbdConfigSetInitialCursorPos (&swkbd, 0); | ||
if (strlen(hint.c_str()) != 0) | ||
swkbdConfigSetGuideText(&swkbd, hint.c_str()); | ||
|
||
if (strlen(text.c_str()) != 0) | ||
swkbdConfigSetInitialText(&swkbd, text.c_str()); | ||
|
||
swkbdConfigSetTextCheckCallback(&swkbd, Keyboard_ValidateText); | ||
|
||
if (R_FAILED(ret = swkbdShow(&swkbd, input_string, sizeof(input_string)))) { | ||
swkbdClose(&swkbd); | ||
return ""; | ||
} | ||
|
||
swkbdClose(&swkbd); | ||
|
||
char *buf = (char*)malloc(256); | ||
strcpy(buf, input_string); | ||
return std::string(buf); | ||
} | ||
|
||
|
||
Result WebBrowserCall(std::string url,bool nag){ | ||
Result rc = 0; | ||
if (nag){ | ||
url = KeyboardCall ("Escribir URL http://", url); | ||
urlc = url; | ||
if (url.length() <= 0) return 0; | ||
} | ||
|
||
WebCommonConfig config; | ||
WebCommonReply reply; | ||
WebExitReason exitReason = (WebExitReason)0; | ||
// Create the config. There's a number of web*Create() funcs, see libnx web.h. | ||
// webPageCreate/webNewsCreate requires running under a host title which has HtmlDocument content, when the title is an Application. When the title is an Application when using webPageCreate/webNewsCreate, and webConfigSetWhitelist is not used, the whitelist will be loaded from the content. Atmosphère hbl_html can be used to handle this. | ||
rc = webPageCreate(&config, url.c_str()); | ||
|
||
printf("webPageCreate(): 0x%x\n", rc); | ||
if (R_SUCCEEDED(rc)) { | ||
if (nag){ | ||
printf("Try to save logins\n");// | ||
//mount user data to save logins and that stuff | ||
webConfigSetUid(&config,uid); | ||
} | ||
printf("SetMainConfigs\n"); | ||
webConfigSetScreenShot (&config, true); | ||
webConfigSetBootDisplayKind (&config, WebBootDisplayKind_Black); | ||
webConfigSetPageCache (&config, true); | ||
webConfigSetBootLoadingIcon (&config, true); | ||
webConfigSetPageScrollIndicator (&config, true); | ||
webConfigSetMediaPlayerSpeedControl (&config, true); | ||
webConfigSetMediaAutoPlay (&config, true); | ||
if (!nag){ | ||
printf("SetCapConfigs\n"); | ||
webConfigSetDisplayUrlKind (&config, false); | ||
webConfigSetMediaPlayerAutoClose (&config, true); | ||
//webConfigSetFooter(&config, false); | ||
|
||
//play direct links | ||
if(url.substr(9,9) == "-delivery") | ||
webConfigSetBootAsMediaPlayer(&config, true); | ||
|
||
//block redirection | ||
if(url.substr(0,32) == "https://jkanime.net/jkfembed.php") | ||
{ | ||
webConfigSetWhitelist(&config, "^https://jkanime\\.net($|/)"); | ||
} else webConfigSetWhitelist(&config, "^http*"); | ||
} | ||
|
||
|
||
// Launch the applet and wait for it to exit. | ||
printf("Running webConfigShow...\n"); | ||
rc = webConfigShow(&config, &reply); // If you don't use reply you can pass NULL for it. | ||
printf("webConfigShow(): 0x%x\n", rc); | ||
|
||
if (R_SUCCEEDED(rc)) { // Normally you can ignore exitReason. | ||
rc = webReplyGetExitReason(&reply, &exitReason); | ||
printf("webReplyGetExitReason(): 0x%x", rc); | ||
if (R_SUCCEEDED(rc)) printf(", 0x%x", exitReason); | ||
printf("\n"); | ||
} | ||
} | ||
return rc; | ||
} | ||
|
||
//KeyboardCall ("Buscar Anime (3 letras minimo.)", ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#include <string> | ||
std::string KeyboardCall (std::string hint="", std::string text=""); | ||
Result WebBrowserCall(std::string url="",bool nag=false); | ||
bool GetAppletMode(); |
Oops, something went wrong.