Compare commits

..

No commits in common. "master" and "v3.3.0" have entirely different histories.

26 changed files with 252 additions and 532 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
.*/
*~ *~
*.exe *.exe
*.o *.o

View File

@ -1,4 +1,4 @@
export APP_VERSION := 3.5.1 export APP_VERSION := 3.3.0
ifeq ($(RELEASE),) ifeq ($(RELEASE),)
export APP_VERSION := $(APP_VERSION)-$(shell git describe --dirty --always) export APP_VERSION := $(APP_VERSION)-$(shell git describe --dirty --always)

View File

@ -63,7 +63,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -ldeko3d -lphysfs `freetype-config --libs` -lconfig -lturbojpeg -lpng LIBS := -lminizip `freetype-config --libs` -lconfig -lturbojpeg -lpng
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing
@ -212,7 +212,6 @@ $(OUTPUT).nso : $(OUTPUT).elf
endif endif
menu.o : $(TOPDIR)/Makefile
$(OUTPUT).elf : $(OFILES) $(OUTPUT).elf : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN) $(OFILES_SRC) : $(HFILES_BIN)

View File

@ -14,7 +14,7 @@ test : pc_main/main.cpp pc_main/pc_launch.c pc_main/pc_power.c pc_main/pc_netsta
common/menu-entry.c common/menu-list.c common/message-box.c common/text.c \ common/menu-entry.c common/menu-list.c common/message-box.c common/text.c \
common/ui.c common/assets.c common/math.c common/theme.c \ common/ui.c common/assets.c common/math.c common/theme.c \
common/netloader.c common/netloader.c
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `pkg-config freetype2 --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ -lpthread `pkg-config freetype2 --libs` -lm -lphysfs -lz -lconfig -lturbojpeg -lpng $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@ gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `pkg-config freetype2 --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ -lpthread `pkg-config freetype2 --libs` -lm -lminizip -lz -lconfig -lturbojpeg -lpng $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@
clean: clean:
rm -rf build_pc/ test test.* rm -rf build_pc/ test test.*

View File

@ -13,13 +13,13 @@ The following [pacman packages](https://devkitpro.org/wiki/devkitPro_pacman) are
- `switch-freetype` - `switch-freetype`
- `switch-libconfig` - `switch-libconfig`
- `switch-libjpeg-turbo` - `switch-libjpeg-turbo`
- `switch-physfs` - `switch-zlib`
The following libraries are required to build for PC: The following libraries are required to build for PC:
- `libfreetype` - `libfreetype`
- `libconfig` - `libconfig`
- `libjpeg-turbo` - `libjpeg-turbo`
- `libphysfs` - `libminizip`
Building for Switch/PC requires `zip`. Building for Switch/PC requires `zip`.

View File

@ -1,6 +1,6 @@
#include "common.h" #include "common.h"
#include <physfs.h> #include <minizip/unzip.h>
#include <png.h> #include <png.h>
#define GENASSET(_p, _mode, _w, _h) {{.path = _p, .imageMode = _mode, .imageSize = {_w, _h}}, {}} #define GENASSET(_p, _mode, _w, _h) {{.path = _p, .imageMode = _mode, .imageSize = {_w, _h}}, {}}
@ -46,9 +46,59 @@ static void assetsSetPixelSize(assetsDataEntry *entry) {
} }
} }
static int assetsLoadFile(unzFile zipf, assetsDataEntry *entry) {
int ret;
int filesize=0;
unz_file_info file_info;
u8* buffer = NULL;
assetsSetPixelSize(entry);
ret = unzLocateFile(zipf, entry->path, 0);
if (ret==UNZ_OK) ret = unzOpenCurrentFile(zipf);
if (ret==UNZ_OK) {
ret = unzGetCurrentFileInfo(zipf, &file_info, NULL, 0, NULL, 0, NULL, 0);
filesize = file_info.uncompressed_size;
if (filesize != entry->imageSize[0] * entry->imageSize[1] * entry->pixSize) ret = -10;
if (ret==UNZ_OK) {
buffer = (u8*)malloc(filesize);
if (buffer) {
memset(buffer, 0, filesize);
} else {
ret = -11;
}
}
if (ret==UNZ_OK) {
ret = unzReadCurrentFile(zipf, buffer, filesize);
if(ret < filesize) {
ret = -12;
} else {
ret = UNZ_OK;
}
}
if (ret!=UNZ_OK && buffer!=NULL) free(buffer);
unzCloseCurrentFile(zipf);
}
if (ret==UNZ_OK) {
entry->buffer = buffer;
entry->size = filesize;
}
return ret;
}
Result assetsInit(void) { Result assetsInit(void) {
bool ret=false; int ret=0;
int i, stopi; int i, stopi;
unzFile zipf;
assetsDataEntry *entry = NULL; assetsDataEntry *entry = NULL;
char tmp_path[PATH_MAX]; char tmp_path[PATH_MAX];
@ -67,34 +117,40 @@ Result assetsInit(void) {
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/romfs/assets.zip", menuGetRootBasePath()); snprintf(tmp_path, sizeof(tmp_path)-1, "%s/romfs/assets.zip", menuGetRootBasePath());
#endif #endif
if (PHYSFS_mount(tmp_path, "", 0)) { zipf = unzOpen(tmp_path);
ret=true; if(zipf==NULL) {
#ifdef __SWITCH__
romfsExit();
#endif
return 0x80;
}
for (i=0; i<AssetId_Max; i++) { for (i=0; i<AssetId_Max; i++) {
stopi = i; stopi = i;
entry = &g_assetsDataList[i][0]; entry = &g_assetsDataList[i][0];
if (entry->path[0]) { if (entry->path[0]) {
ret = assetsLoadData(i, NULL, NULL); ret = assetsLoadFile(zipf, entry);
if (!ret) break; if (ret!=UNZ_OK) break;
entry->initialized = true;
} }
} }
if (!ret) { if (ret!=UNZ_OK) {
for (i=0; i<stopi; i++) { for (i=0; i<stopi; i++) {
assetsClearEntry(&g_assetsDataList[i][0]); assetsClearEntry(&g_assetsDataList[i][0]);
} }
} }
if (ret) g_assetsInitialized = 1; if (ret==UNZ_OK) g_assetsInitialized = 1;
PHYSFS_unmount(tmp_path); unzClose(zipf);
}
#ifdef __SWITCH__ #ifdef __SWITCH__
romfsExit(); romfsExit();
return ret ? 0 : MAKERESULT(Module_Libnx, LibnxError_IoError);
#else
return ret ? 0 : 1;
#endif #endif
return ret;
} }
void assetsExit(void) { void assetsExit(void) {
@ -167,67 +223,31 @@ bool assetsLoadPngFromMemory(u8 *indata, size_t indata_size, u8 *outdata, ImageM
return ret; return ret;
} }
bool assetsPhysfsReadFile(const char *path, u8 **data_buf, size_t *filesize, bool nul_term) { bool assetsLoadFromTheme(AssetId id, const char *path, int *imageSize) {
bool ret=true;
*data_buf = NULL;
if (filesize) *filesize = 0;
PHYSFS_Stat tmpstat={0};
if (!(PHYSFS_stat(path, &tmpstat) && tmpstat.filesize!=-1)) ret = false;
if (ret) {
size_t bufsize = tmpstat.filesize;
if (nul_term) bufsize++;
*data_buf = (u8*)malloc(bufsize);
if (*data_buf) memset(*data_buf, 0, bufsize);
else ret = false;
}
if (ret) {
PHYSFS_File *f = PHYSFS_openRead(path);
if (f==NULL) ret = false;
else {
ret = PHYSFS_readBytes(f, *data_buf, tmpstat.filesize) == tmpstat.filesize;
PHYSFS_close(f);
}
}
if (ret) {
if (filesize) *filesize = tmpstat.filesize;
}
else {
free(*data_buf);
*data_buf = NULL;
}
return ret;
}
bool assetsLoadData(AssetId id, const char *path, int *imageSize) {
if (id < 0 || id >= AssetId_Max) return false; if (id < 0 || id >= AssetId_Max) return false;
assetsDataEntry *entry = &g_assetsDataList[id][path ? 1 : 0]; assetsDataEntry *entry = &g_assetsDataList[id][1];
if (entry->initialized) return false; if (entry->initialized) return false;
if (path) memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
if (imageSize) {
entry->imageSize[0] = imageSize[0]; entry->imageSize[0] = imageSize[0];
entry->imageSize[1] = imageSize[1]; entry->imageSize[1] = imageSize[1];
}
if (path) entry->imageMode = g_assetsDataList[id][0].imageMode; entry->imageMode = g_assetsDataList[id][0].imageMode;
assetsSetPixelSize(entry); assetsSetPixelSize(entry);
entry->size = entry->imageSize[0] * entry->imageSize[1] * entry->pixSize; entry->size = entry->imageSize[0] * entry->imageSize[1] * entry->pixSize;
if (path) strncpy(entry->path, path, sizeof(entry->path)-1); strncpy(entry->path, path, sizeof(entry->path)-1);
const char* ext = getExtension(entry->path); const char* ext = getExtension(entry->path);
bool ret=true; bool ret=true;
size_t filesize=0;
if (ext==NULL) ret = false; if (ext==NULL) ret = false;
u8 *data_buf = NULL; u8 *data_buf = NULL;
struct stat st;
if (ret && stat(path, &st)==-1) ret = false;
if (ret) { if (ret) {
entry->buffer = (u8*)malloc(entry->size); entry->buffer = (u8*)malloc(entry->size);
@ -235,18 +255,31 @@ bool assetsLoadData(AssetId id, const char *path, int *imageSize) {
else ret = false; else ret = false;
} }
if (ret) ret = assetsPhysfsReadFile(entry->path, &data_buf, &filesize, false); if (ret) {
data_buf = (u8*)malloc(st.st_size);
if (data_buf) memset(data_buf, 0, st.st_size);
else ret = false;
}
if (ret) {
FILE *f = fopen(entry->path, "rb");
if (f==NULL) ret = false;
else {
ret = fread(data_buf, st.st_size, 1, f) == 1;
fclose(f);
}
}
if (ret) { if (ret) {
if (strcasecmp(ext, ".bin")==0) { if (strcasecmp(ext, ".bin")==0) {
if (filesize != entry->size) ret = false; if (st.st_size != entry->size) ret = false;
if (ret) memcpy(entry->buffer, data_buf, entry->size); if (ret) memcpy(entry->buffer, data_buf, entry->size);
} }
else if (strcasecmp(ext, ".jpg")==0 || strcasecmp(ext, ".jpeg")==0) else if (strcasecmp(ext, ".jpg")==0 || strcasecmp(ext, ".jpeg")==0)
ret = assetsLoadJpgFromMemory(data_buf, filesize, entry->buffer, entry->imageMode, entry->imageSize[0], entry->imageSize[1]); ret = assetsLoadJpgFromMemory(data_buf, st.st_size, entry->buffer, entry->imageMode, entry->imageSize[0], entry->imageSize[1]);
else if (strcasecmp(ext, ".png")==0) else if (strcasecmp(ext, ".png")==0)
ret = assetsLoadPngFromMemory(data_buf, filesize, entry->buffer, entry->imageMode, entry->imageSize[0], entry->imageSize[1]); ret = assetsLoadPngFromMemory(data_buf, st.st_size, entry->buffer, entry->imageMode, entry->imageSize[0], entry->imageSize[1]);
else else
ret = false; // File extension not recognized. ret = false; // File extension not recognized.
} }

View File

@ -35,8 +35,7 @@ typedef struct {
Result assetsInit(void); Result assetsInit(void);
void assetsExit(void); void assetsExit(void);
void assetsClearTheme(void); void assetsClearTheme(void);
bool assetsPhysfsReadFile(const char *path, u8 **data_buf, size_t *filesize, bool nul_term); bool assetsLoadFromTheme(AssetId id, const char *path, int *imageSize);
bool assetsLoadData(AssetId id, const char *path, int *imageSize);
void assetsGetData(AssetId id, assetsDataEntry **out); void assetsGetData(AssetId id, assetsDataEntry **out);
u8 *assetsGetDataBuffer(AssetId id); u8 *assetsGetDataBuffer(AssetId id);

View File

@ -21,7 +21,6 @@
#include <stdint.h> #include <stdint.h>
typedef uint8_t u8; typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32; typedef uint32_t u32;
typedef uint64_t u64; typedef uint64_t u64;
typedef int8_t s8; typedef int8_t s8;

View File

@ -9,10 +9,6 @@
#define FONT_FACES_MAX 2 #define FONT_FACES_MAX 2
#endif #endif
#ifdef __SWITCH__
static bool s_plinited;
#endif
static FT_Error s_font_libret=1, s_font_facesret[FONT_FACES_MAX]; static FT_Error s_font_libret=1, s_font_facesret[FONT_FACES_MAX];
static FT_Library s_font_library; static FT_Library s_font_library;
@ -368,11 +364,7 @@ bool fontInitialize(void)
PlFontData fonts[PlSharedFontType_Total]; PlFontData fonts[PlSharedFontType_Total];
Result rc=0; Result rc=0;
rc = plInitialize(PlServiceType_User);
if (R_SUCCEEDED(rc)) {
s_plinited = true;
rc = plGetSharedFont(textGetLanguageCode(), fonts, FONT_FACES_MAX, &s_font_faces_total); rc = plGetSharedFont(textGetLanguageCode(), fonts, FONT_FACES_MAX, &s_font_faces_total);
}
if (R_FAILED(rc)) return false; if (R_FAILED(rc)) return false;
for (i=0; i<s_font_faces_total; i++) { for (i=0; i<s_font_faces_total; i++) {
@ -418,10 +410,6 @@ void fontExit()
if (s_font_facesret[i]==0) FT_Done_Face(s_font_faces[i]); if (s_font_facesret[i]==0) FT_Done_Face(s_font_faces[i]);
if (s_font_libret==0) FT_Done_FreeType(s_font_library); if (s_font_libret==0) FT_Done_FreeType(s_font_library);
#ifdef __SWITCH__
if (s_plinited) plExit();
#endif
} }
/*Automatically gives you the desired x-coordinate /*Automatically gives you the desired x-coordinate

View File

@ -43,15 +43,13 @@ const char* const g_strings[StrId_Max][17] =
STR_KO("로딩중…"), STR_KO("로딩중…"),
STR_RU("загрузка…"), STR_RU("загрузка…"),
STR_ZH_HANS("加载中…"), STR_ZH_HANS("加载中…"),
STR_ZH_HANT("中…"), STR_ZH_HANT("載中…"),
}, },
[StrId_AppletMode] = [StrId_AppletMode] =
{ {
STR_EN("● Applet Mode ●"), STR_EN("● Applet Mode ●"),
STR_ES("● Modo Applet ●"), STR_ES("● Modo Applet ●"),
STR_FR("● Mode Applet ●"),
STR_ZH_HANS("● 小程序模式 ●"),
}, },
[StrId_Directory] = [StrId_Directory] =
@ -99,7 +97,7 @@ const char* const g_strings[StrId_Max][17] =
STR_KO("알 수 없는 개발자"), STR_KO("알 수 없는 개발자"),
STR_RU("неизвестный автор"), STR_RU("неизвестный автор"),
STR_ZH_HANS("未知作者"), STR_ZH_HANS("未知作者"),
STR_ZH_HANT("作者未知"), STR_ZH_HANT("作者不詳"),
}, },
[StrId_IOError] = [StrId_IOError] =
@ -115,7 +113,7 @@ const char* const g_strings[StrId_Max][17] =
STR_KO("입출력 오류"), STR_KO("입출력 오류"),
STR_RU("I/O-ошибка"), STR_RU("I/O-ошибка"),
STR_ZH_HANS("读写出错"), STR_ZH_HANS("读写出错"),
STR_ZH_HANT("取存錯誤"), STR_ZH_HANT("讀寫錯誤"),
}, },
[StrId_CouldNotOpenFile] = [StrId_CouldNotOpenFile] =
@ -131,14 +129,7 @@ const char* const g_strings[StrId_Max][17] =
STR_KO("파일을 열 수 없습니다:\n%s"), STR_KO("파일을 열 수 없습니다:\n%s"),
STR_RU("Не могу открыть файл:\n%s"), STR_RU("Не могу открыть файл:\n%s"),
STR_ZH_HANS("无法打开文件:\n%s"), STR_ZH_HANS("无法打开文件:\n%s"),
STR_ZH_HANT("無法開啟檔案:\n%s"), STR_ZH_HANT("開啓檔案失敗:\n%s"),
},
[StrId_NroNotFound] =
{
STR_EN("Could not find executable: %s"),
STR_FR("Impossible trouver l'exécutable : %s"),
STR_ZH_HANS("找不到可执行文件"),
}, },
[StrId_NoAppsFound_Title] = [StrId_NoAppsFound_Title] =
@ -154,7 +145,7 @@ const char* const g_strings[StrId_Max][17] =
STR_KO("애플리케이션을 찾을 수 없습니다"), STR_KO("애플리케이션을 찾을 수 없습니다"),
STR_RU("приложение не найдено"), STR_RU("приложение не найдено"),
STR_ZH_HANS("找不到可执行的自制程序"), STR_ZH_HANS("找不到可执行的自制程序"),
STR_ZH_HANT("沒有可執行的自製程式"), STR_ZH_HANT("未能找到可執行的自製程式"),
}, },
[StrId_NoAppsFound_Msg] = [StrId_NoAppsFound_Msg] =
@ -215,14 +206,14 @@ const char* const g_strings[StrId_Max][17] =
"названием switch и она содержит приложения." "названием switch и она содержит приложения."
), ),
STR_ZH_HANS( STR_ZH_HANS(
"找不到任何自制程序(nro)\n" "内存卡找不到任何可执行的应用程序\n"
"在SD卡根目录建立“switch”文件夹\n" "请在内存卡的根目录建立「switch」子目录\n"
"将自制程序(nro)放在其中" "存放自制应用软件至该目录"
), ),
STR_ZH_HANT( STR_ZH_HANT(
"記憶卡內沒有可供執行的應用程式。\n" "記憶體找不到任何可執行的應用程式。\n"
"請在根目錄下建立「switch」資料夾\n" "請在記憶體建立「switch」資料夾\n"
"並將自製軟體複製到switch資料夾內" "然後儲存自製軟體到此處"
), ),
}, },
@ -235,19 +226,15 @@ const char* const g_strings[StrId_Max][17] =
STR_IT("L'ultima applicazione ha restituito un errore:"), STR_IT("L'ultima applicazione ha restituito un errore:"),
STR_JP("直前に実行したアプリでエラーが発生しました:"), STR_JP("直前に実行したアプリでエラーが発生しました:"),
STR_KO("최근 애플리케이션에서 오류가 발생했습니다:"), STR_KO("최근 애플리케이션에서 오류가 발생했습니다:"),
STR_ZH_HANS("程序运行后出现错误:"), STR_ZH_HANT("程式執行時發生錯誤:"),
STR_ZH_HANT("程式執行後出現錯誤:"),
}, },
[StrId_AppLaunchError] = [StrId_AppLaunchError] =
{ {
STR_EN("Failed to launch the application:"), STR_EN("Failed to launch the application:"),
STR_DE("Konnte die Anwendung nicht starten:"), STR_DE("Konnte die Anwendung nicht starten:"),
STR_FR("Erreur au lancement de l'application:"), STR_FR("Erreur au lancement de l'application"),
STR_IT("Errore nell'avvio dell'applicazione:"), STR_IT("Errore nell'avvio dell'applicazione:"),
STR_ES("No se ha podido iniciar la aplicación:"),
STR_ZH_HANS("运行程序时发生错误:"),
STR_ZH_HANT("執行程式時發生錯誤:"),
}, },
[StrId_AppInfo_Author] = [StrId_AppInfo_Author] =
@ -278,8 +265,8 @@ const char* const g_strings[StrId_Max][17] =
STR_NL("Versie"), STR_NL("Versie"),
STR_KO("버전"), STR_KO("버전"),
STR_RU("Версия"), STR_RU("Версия"),
STR_ZH_HANS(""), STR_ZH_HANS(""),
STR_ZH_HANT(""), STR_ZH_HANT(""),
}, },
[StrId_Actions_Launch] = [StrId_Actions_Launch] =
@ -287,7 +274,7 @@ const char* const g_strings[StrId_Max][17] =
STR_EN("Launch"), STR_EN("Launch"),
STR_ES("Lanzamiento"), STR_ES("Lanzamiento"),
STR_DE("Starten"), STR_DE("Starten"),
STR_FR("Lancer"), STR_FR("Lancement"),
STR_IT("Avvia"), STR_IT("Avvia"),
STR_JP("起動"), STR_JP("起動"),
STR_PT("Lançamento"), STR_PT("Lançamento"),
@ -326,8 +313,8 @@ const char* const g_strings[StrId_Max][17] =
STR_NL("Terug"), STR_NL("Terug"),
STR_KO("뒤로 가기"), STR_KO("뒤로 가기"),
STR_RU("возвращаться"), STR_RU("возвращаться"),
STR_ZH_HANS(""), STR_ZH_HANS(""),
STR_ZH_HANT(""), STR_ZH_HANT(""),
}, },
[StrId_MsgBox_OK] = [StrId_MsgBox_OK] =
@ -339,7 +326,6 @@ const char* const g_strings[StrId_Max][17] =
STR_ES("Aceptar"), STR_ES("Aceptar"),
STR_JP("了解"), STR_JP("了解"),
STR_KO("확인"), STR_KO("확인"),
STR_ZH_HANS("确认"),
STR_ZH_HANT("確認"), STR_ZH_HANT("確認"),
}, },
@ -352,8 +338,7 @@ const char* const g_strings[StrId_Max][17] =
STR_IT("Applica"), STR_IT("Applica"),
STR_JP("適用"), STR_JP("適用"),
STR_KO("적용"), STR_KO("적용"),
STR_ZH_HANS("应用"), STR_ZH_HANT("应用"),
STR_ZH_HANT("套用"),
}, },
[StrId_Actions_Star] = [StrId_Actions_Star] =
@ -361,8 +346,6 @@ const char* const g_strings[StrId_Max][17] =
STR_EN("Star"), STR_EN("Star"),
STR_ES("Agregar a favoritos"), STR_ES("Agregar a favoritos"),
STR_IT("Aggiungi ai preferiti"), STR_IT("Aggiungi ai preferiti"),
STR_FR("Ajouter aux favoris"),
STR_ZH_HANS("收藏"),
}, },
[StrId_Actions_Unstar] = [StrId_Actions_Unstar] =
@ -370,21 +353,18 @@ const char* const g_strings[StrId_Max][17] =
STR_EN("Unstar"), STR_EN("Unstar"),
STR_ES("Borrar de favoritos"), STR_ES("Borrar de favoritos"),
STR_IT("Rimuovi dai preferiti"), STR_IT("Rimuovi dai preferiti"),
STR_FR("Retirer des favoris"),
STR_ZH_HANS("取消收藏"),
}, },
[StrId_ThemeMenu] = [StrId_ThemeMenu] =
{ {
STR_EN("Theme Menu"), STR_EN("Theme Menu"),
STR_FR("Menu thèmes"), STR_FR("Menu Thème"),
STR_DE("Theme Menü"), STR_DE("Theme Menü"),
STR_ES("Menú temático"), STR_ES("Menú temático"),
STR_IT("Tema Menu"), STR_IT("Tema Menu"),
STR_JP("テーマメニュー"), STR_JP("テーマメニュー"),
STR_KO("테마 메뉴"), STR_KO("테마 메뉴"),
STR_ZH_HANS("主题菜单"), STR_ZH_HANT("主题菜单"),
STR_ZH_HANT("主題選單"),
}, },
[StrId_ThemeNotApplied] = [StrId_ThemeNotApplied] =
@ -396,8 +376,7 @@ const char* const g_strings[StrId_Max][17] =
STR_IT("Il tema non è stato applicato a causa di un errore."), STR_IT("Il tema non è stato applicato a causa di un errore."),
STR_JP("エラーが発生したため、テーマを適用できませんでした。"), STR_JP("エラーが発生したため、テーマを適用できませんでした。"),
STR_KO("오류가 발생 했기 때문에 테마를 적용할 수 없습니다."), STR_KO("오류가 발생 했기 때문에 테마를 적용할 수 없습니다."),
STR_ZH_HANS("由于发生错误, 无法应用主题。"), STR_ZH_HANT("由于发生错误, 无法应用主题。"),
STR_ZH_HANT("出現錯誤,無法套用主題。"),
}, },
[StrId_DefaultThemeName] = [StrId_DefaultThemeName] =
@ -406,9 +385,6 @@ const char* const g_strings[StrId_Max][17] =
STR_FR("Thème par défaut"), STR_FR("Thème par défaut"),
STR_DE("Standard Theme"), STR_DE("Standard Theme"),
STR_IT("Tema di default"), STR_IT("Tema di default"),
STR_ES("Tema por defecto"),
STR_ZH_HANS("默认主题"),
STR_ZH_HANT("預設主題"),
}, },
/*[StrId_Reboot] = /*[StrId_Reboot] =
@ -587,7 +563,7 @@ const char* const g_strings[StrId_Max][17] =
STR_DE("Fehler beim Lesen der Titel-Metadaten.\n%08lX%08lX@%d"), STR_DE("Fehler beim Lesen der Titel-Metadaten.\n%08lX%08lX@%d"),
STR_FR( STR_FR(
"Erreur lors de la lecture des métadonnées\n" "Erreur lors de la lecture des métadonnées\n"
"du titre.\n%08lX%08lX@%d" "de titre.\n%08lX%08lX@%d"
), ),
STR_IT("Errore nella lettura dei metadata dei titoli.\n%08lX%08lX@%d"), STR_IT("Errore nella lettura dei metadata dei titoli.\n%08lX%08lX@%d"),
STR_JP("タイトルメタデータを読み取ることができませんでした。\n%08lX%08lX@%d"), STR_JP("タイトルメタデータを読み取ることができませんでした。\n%08lX%08lX@%d"),
@ -596,7 +572,7 @@ const char* const g_strings[StrId_Max][17] =
STR_KO("타이틀 메타데이터를 읽는데 실패하였습니다.\n%08lX%08lX@%d"), STR_KO("타이틀 메타데이터를 읽는데 실패하였습니다.\n%08lX%08lX@%d"),
STR_RU("Ошибка чтения метаданных заголовка\n.%08lX%08lX@%d"), STR_RU("Ошибка чтения метаданных заголовка\n.%08lX%08lX@%d"),
STR_ZH_HANS("读取软件相关信息时发生错误:\n%08lX%08lX@%d"), STR_ZH_HANS("读取软件相关信息时发生错误:\n%08lX%08lX@%d"),
STR_ZH_HANT("讀取軟體相關資訊時發生錯誤:\n%08lX%08lX@%d"), STR_ZH_HANT("讀取軟體相關數據時發生錯誤:\n%08lX%08lX@%d"),
}, },
[StrId_NoTitlesFound] = [StrId_NoTitlesFound] =
@ -738,7 +714,7 @@ const char* const g_strings[StrId_Max][17] =
), ),
STR_ZH_HANT( STR_ZH_HANT(
"您所利用漏洞開啓的「自製軟體啓動器」\n" "您所利用漏洞開啓的「自製軟體啓動器」\n"
"無法在當前選中的軟體啓動自製軟\n" "無法在當前選中的軟體啓動自製軟\n"
"請利用其它漏洞來啓動「自製軟體啓動器」。" "請利用其它漏洞來啓動「自製軟體啓動器」。"
), ),
}, },
@ -800,7 +776,7 @@ const char* const g_strings[StrId_Max][17] =
STR_EN("NetLoader"), STR_EN("NetLoader"),
STR_ES("Cargador de programas"), STR_ES("Cargador de programas"),
STR_DE("Netzwerk-Loader"), STR_DE("Netzwerk-Loader"),
STR_FR("NetLoader"), STR_FR("Chargeur de programme"),
STR_IT("Caricamento programmi"), STR_IT("Caricamento programmi"),
STR_JP("ネットローダ"), STR_JP("ネットローダ"),
STR_PT("Carregador de programas"), STR_PT("Carregador de programas"),
@ -816,7 +792,7 @@ const char* const g_strings[StrId_Max][17] =
STR_EN("The NetLoader is currently unavailable."), STR_EN("The NetLoader is currently unavailable."),
STR_ES("El cargador de programas no está disponible."), STR_ES("El cargador de programas no está disponible."),
STR_DE("Der Netzwerk-Loader ist zur Zeit nicht verfügbar."), STR_DE("Der Netzwerk-Loader ist zur Zeit nicht verfügbar."),
STR_FR("Le programme nxlink est indisponible."), STR_FR("Le chargeur de programme nxlink est indisponible."),
STR_IT("Il caricamento programmi nxlink non è disponibile."), STR_IT("Il caricamento programmi nxlink non è disponibile."),
STR_JP("nxlinkネットローダは現在利用できません。"), STR_JP("nxlinkネットローダは現在利用できません。"),
STR_PT("O carregador de programas está de momento indisponível."), STR_PT("O carregador de programas está de momento indisponível."),
@ -849,11 +825,10 @@ const char* const g_strings[StrId_Max][17] =
STR_DE("Offline, warte auf Netzwerk…"), STR_DE("Offline, warte auf Netzwerk…"),
STR_FR("Hors-ligne, en attente d'une connection..."), STR_FR("Hors-ligne, en attente d'une connection..."),
STR_IT("Disconnesso, in attesa della connessione…"), STR_IT("Disconnesso, in attesa della connessione…"),
STR_ES("Desconectado, esperando a la red..."),
STR_JP("オフラインです。ネットワーク接続を待っています…"), STR_JP("オフラインです。ネットワーク接続を待っています…"),
STR_KO("연결 끊김, 네트워크 기다리는 중…"), STR_KO("연결 끊김, 네트워크 기다리는 중…"),
STR_ZH_HANS("无法连接网络,等待网络连接…"), STR_ZH_HANS("无法连接网络,等待网络连接…"),
STR_ZH_HANT("目前已離線,等待網路連線…"), STR_ZH_HANT("當前離線,等待網路連線…"),
}, },
[StrId_NetLoaderActive] = [StrId_NetLoaderActive] =
@ -960,3 +935,4 @@ const char* const g_strings[StrId_Max][17] =
), ),
}, },
}; };

View File

@ -11,7 +11,6 @@ typedef enum
StrId_DefaultPublisher, StrId_DefaultPublisher,
StrId_IOError, StrId_IOError,
StrId_CouldNotOpenFile, StrId_CouldNotOpenFile,
StrId_NroNotFound,
StrId_NoAppsFound_Title, StrId_NoAppsFound_Title,
StrId_NoAppsFound_Msg, StrId_NoAppsFound_Msg,

View File

@ -1,5 +1,4 @@
#include "common.h" #include "common.h"
#include <physfs.h>
void menuEntryInit(menuEntry_s* me, MenuEntryType type) { void menuEntryInit(menuEntry_s* me, MenuEntryType type) {
memset(me, 0, sizeof(*me)); memset(me, 0, sizeof(*me));
@ -81,13 +80,9 @@ static bool menuEntryLoadEmbeddedIcon(menuEntry_s* me) {
return ok; return ok;
} }
static bool menuEntryLoadExternalIcon(menuEntry_s* me, const char* path, bool data_source) { static bool menuEntryLoadExternalIcon(menuEntry_s* me, const char* path) {
struct stat st; struct stat st;
if (data_source) {
return assetsPhysfsReadFile(path, &me->icon, &me->icon_size, false);
}
if(stat(path, &st)==-1) return false; if(stat(path, &st)==-1) return false;
FILE* f = fopen(path, "rb"); FILE* f = fopen(path, "rb");
@ -331,7 +326,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut, bool check_
char* ext = getExtension(tempbuf); char* ext = getExtension(tempbuf);
strcpy(ext, ".jpg"); strcpy(ext, ".jpg");
iconLoaded = menuEntryLoadExternalIcon(me, tempbuf, false); iconLoaded = menuEntryLoadExternalIcon(me, tempbuf);
if (iconLoaded) break; if (iconLoaded) break;
if (isOldAppFolder) if (isOldAppFolder)
@ -339,7 +334,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut, bool check_
char* slash = getSlash(tempbuf); char* slash = getSlash(tempbuf);
strcpy(slash, "/icon.jpg"); strcpy(slash, "/icon.jpg");
iconLoaded = menuEntryLoadExternalIcon(me, tempbuf, false); iconLoaded = menuEntryLoadExternalIcon(me, tempbuf);
if (iconLoaded) break; if (iconLoaded) break;
}*/ }*/
@ -413,43 +408,18 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut, bool check_
*version = "1.0.0"; *version = "1.0.0";
const char* cfg_path = me->path; const char* cfg_path = me->path;
const char* theme_archive_path = NULL;
const char* ext = getExtension(me->path);
bool good_cfg = false;
bool is_archive = false;
#ifdef __SWITCH__ #ifdef __SWITCH__
const char* ext = getExtension(me->path);
bool is_romfs = false; bool is_romfs = false;
if (strcasecmp(ext, ".romfs")==0) { if (strcasecmp(ext, ".romfs")==0) {
if (R_FAILED(romfsMountFromFsdev(me->path, 0, "themetmp"))) if (R_FAILED(romfsMountFromFsdev(me->path, 0, "themetmp")))
return false; return false;
is_romfs = true; is_romfs = true;
cfg_path = "themetmp:/theme.cfg"; cfg_path = "themetmp:/theme.cfg";
theme_archive_path = "themetmp:/";
} }
#endif #endif
if (strcasecmp(ext, ".romfs")!=0 && strcasecmp(ext, ".cfg")!=0) { if (config_read_file(&cfg, cfg_path)) {
theme_archive_path = me->path;
}
if (theme_archive_path) {
if (!PHYSFS_mount(theme_archive_path, "themetmp", 0)) cfg_path = NULL;
else {
is_archive = true;
cfg_path = "themetmp/theme.cfg";
}
}
if (cfg_path) {
if (!is_archive) good_cfg = config_read_file(&cfg, cfg_path);
else {
u8 *cfg_buf = NULL;
good_cfg = assetsPhysfsReadFile(cfg_path, &cfg_buf, NULL, true);
if (good_cfg) good_cfg = config_read_string(&cfg, (char*)cfg_buf);
free(cfg_buf);
}
}
if (good_cfg) {
themeInfo = config_lookup(&cfg, "themeInfo"); themeInfo = config_lookup(&cfg, "themeInfo");
if (themeInfo != NULL) { if (themeInfo != NULL) {
if(config_setting_lookup_string(themeInfo, "name", &name)) if(config_setting_lookup_string(themeInfo, "name", &name))
@ -463,17 +433,15 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut, bool check_
strncpy(me->version, version, sizeof(me->version)-1); strncpy(me->version, version, sizeof(me->version)-1);
config_destroy(&cfg); config_destroy(&cfg);
if (good_cfg && is_archive) { #ifdef __SWITCH__
if (is_romfs) {
bool iconLoaded = false; bool iconLoaded = false;
iconLoaded = menuEntryLoadExternalIcon(me, "themetmp/icon.jpg", true); iconLoaded = menuEntryLoadExternalIcon(me, "themetmp:/icon.jpg");
if (iconLoaded) menuEntryParseIcon(me); if (iconLoaded) menuEntryParseIcon(me);
} }
if (is_archive) PHYSFS_unmount(theme_archive_path);
#ifdef __SWITCH__
if (is_romfs) romfsUnmount("themetmp"); if (is_romfs) romfsUnmount("themetmp");
#endif #endif
} }
@ -507,7 +475,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut, bool check_
bool iconLoaded = false; bool iconLoaded = false;
iconLoaded = menuEntryLoadExternalIcon(me, tempbuf, false); iconLoaded = menuEntryLoadExternalIcon(me, tempbuf);
if (iconLoaded) menuEntryParseIcon(me); if (iconLoaded) menuEntryParseIcon(me);
@ -592,8 +560,8 @@ void menuEntryFileassocLoad(const char* filepath) {
char target_file_extension[PATH_MAX+1]; char target_file_extension[PATH_MAX+1];
char target_filename[PATH_MAX+1]; char target_filename[PATH_MAX+1];
char app_author[ENTRY_AUTHORLENGTH+2]; char app_author[ENTRY_AUTHORLENGTH+1];
char app_version[ENTRY_VERLENGTH+2]; char app_version[ENTRY_VERLENGTH+1];
uint8_t *app_icon_gfx = NULL; uint8_t *app_icon_gfx = NULL;
uint8_t *app_icon_gfx_small = NULL; uint8_t *app_icon_gfx_small = NULL;
@ -687,8 +655,8 @@ void menuEntryFileassocLoad(const char* filepath) {
} }
me->fileassoc_str[sizeof(me->fileassoc_str)-1] = 0; me->fileassoc_str[sizeof(me->fileassoc_str)-1] = 0;
if (target_icon_path[0]) iconLoaded = menuEntryLoadExternalIcon(me, target_icon_path, false); if (target_icon_path[0]) iconLoaded = menuEntryLoadExternalIcon(me, target_icon_path);
if (!iconLoaded && main_icon_path[0]) iconLoaded = menuEntryLoadExternalIcon(me, main_icon_path, false); if (!iconLoaded && main_icon_path[0]) iconLoaded = menuEntryLoadExternalIcon(me, main_icon_path);
if (iconLoaded) { if (iconLoaded) {
menuEntryParseIcon(me); menuEntryParseIcon(me);

View File

@ -35,7 +35,6 @@ static void _menuAddEntry(menu_s *m, menuEntry_s* me) {
m->lastEntry = me; m->lastEntry = me;
} }
m->xPos = 0; m->xPos = 0;
m->slideSpeed = 0;
m->nEntries ++; m->nEntries ++;
} }
@ -60,7 +59,6 @@ static void menuAddEntryToFront(menuEntry_s* me) {
m->lastEntry = me; m->lastEntry = me;
} }
m->xPos = 0; m->xPos = 0;
m->slideSpeed = 0;
m->nEntries ++; m->nEntries ++;
} }
@ -246,23 +244,8 @@ int themeMenuScan(const char* target) {
memset(tmp_path, 0, sizeof(tmp_path)); memset(tmp_path, 0, sizeof(tmp_path));
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/%s", s_menu[!s_curMenu].dirname, dp->d_name); snprintf(tmp_path, sizeof(tmp_path)-1, "%s/%s", s_menu[!s_curMenu].dirname, dp->d_name);
bool entrytype=0;
#ifdef _DIRENT_HAVE_D_TYPE
if (dp->d_type == DT_UNKNOWN)
continue;
entrytype = dp->d_type != DT_REG;
#else
struct stat tmpstat;
if(stat(tmp_path, &tmpstat)==-1)
continue;
entrytype = (tmpstat.st_mode & S_IFMT) != S_IFREG;
#endif
const char* ext = getExtension(dp->d_name); const char* ext = getExtension(dp->d_name);
if (entrytype || strcasecmp(ext, ".cfg")==0 || strcasecmp(ext, ".romfs")==0 || strcasecmp(ext, ".zip")==0) if (strcasecmp(ext, ".cfg")==0 || strcasecmp(ext, ".romfs")==0)
me = menuCreateEntry(ENTRY_TYPE_THEME); me = menuCreateEntry(ENTRY_TYPE_THEME);
if (!me) if (!me)

View File

@ -6,8 +6,6 @@
#include "switch/runtime/nxlink.h" #include "switch/runtime/nxlink.h"
#endif #endif
double menuTimer;
char rootPathBase[PATH_MAX]; char rootPathBase[PATH_MAX];
char rootPath[PATH_MAX+8]; char rootPath[PATH_MAX+8];
@ -593,7 +591,7 @@ u32 drawStatus() {
if (statusGet(&netstatusFlag, &id, &temperatureFlag, &temperature)) { if (statusGet(&netstatusFlag, &id, &temperatureFlag, &temperature)) {
if (netstatusFlag) drawNetwork(tmpX, id); if (netstatusFlag) drawNetwork(tmpX, id);
if (temperatureFlag) { if (temperatureFlag) {
snprintf(tmpstr, sizeof(tmpstr)-1, "%d°C", temperature); snprintf(tmpstr, sizeof(tmpstr)-1, "%.1f°C", ((float)temperature) / 1000);
DrawTextFromLayout(ThemeLayoutId_Temperature, themeCurrent.textColor, tmpstr); DrawTextFromLayout(ThemeLayoutId_Temperature, themeCurrent.textColor, tmpstr);
} }
} }
@ -800,8 +798,6 @@ void menuLoop(void) {
int entries_count = layoutobj->posEnd[0]; int entries_count = layoutobj->posEnd[0];
layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuList]; layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuList];
// Gentle Realign only when not manually moving
if (menu->slideSpeed == 0) {
if (menu->nEntries > entries_count) { if (menu->nEntries > entries_count) {
int wanted_x = clamp(-menu->curEntry * layoutobj->posEnd[0], -(menu->nEntries - entries_count) * layoutobj->posEnd[0], 0); int wanted_x = clamp(-menu->curEntry * layoutobj->posEnd[0], -(menu->nEntries - entries_count) * layoutobj->posEnd[0], 0);
menu->xPos += v; menu->xPos += v;
@ -811,25 +807,6 @@ void menuLoop(void) {
else { else {
menu->xPos = v = 0; menu->xPos = v = 0;
} }
}
else {
menu->xPos += menu->slideSpeed;
if (abs(menu->slideSpeed) > 2) {
// Slow down way faster when outside the normal bounds
if (menu->xPos > 0 || menu->xPos < -(menu->nEntries) * layoutobj->posEnd[0]) {
menu->slideSpeed *= .5f;
}
else {
menu->slideSpeed *= .9f;
}
}
else {
menu->slideSpeed = 0;
}
menu->curEntry = clamp(roundf(-((float) menu->xPos / layoutobj->posEnd[0])), 0, menu->nEntries);
}
menuEntry_s *active_entry = NULL; menuEntry_s *active_entry = NULL;

View File

@ -33,7 +33,6 @@ struct menu_s_tag
int nEntries; int nEntries;
int curEntry; int curEntry;
int xPos; int xPos;
int slideSpeed;
char dirname[PATH_MAX+1]; char dirname[PATH_MAX+1];
}; };
@ -78,7 +77,7 @@ typedef enum
IMAGE_MODE_RGBA32 IMAGE_MODE_RGBA32
} ImageMode; } ImageMode;
extern double menuTimer; double menuTimer;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -1,5 +1,4 @@
#include "theme.h" #include "theme.h"
#include <physfs.h>
theme_t themeCurrent; theme_t themeCurrent;
ThemePreset themeGlobalPreset; ThemePreset themeGlobalPreset;
@ -83,9 +82,9 @@ bool assetObjectFromSetting(config_setting_t *asset_setting, AssetId id, ThemeLa
return false; return false;
memset(tmp_path, 0, sizeof(tmp_path)); memset(tmp_path, 0, sizeof(tmp_path));
snprintf(tmp_path, sizeof(tmp_path)-1, "theme/%s", path); snprintf(tmp_path, sizeof(tmp_path)-1, "theme:/%s", path);
return assetsLoadData(id, tmp_path, imageSize); return assetsLoadFromTheme(id, tmp_path, imageSize);
} }
void themeStartup(ThemePreset preset) { void themeStartup(ThemePreset preset) {
@ -420,48 +419,25 @@ void themeStartup(ThemePreset preset) {
const char *AText, *BText, *XText, *YText, *PText, *MText, *starOnText, *starOffText; const char *AText, *BText, *XText, *YText, *PText, *MText, *starOnText, *starOffText;
bool logoColor_set = false; bool logoColor_set = false;
bool good_cfg = false; bool good_cfg = false;
#ifdef __SWITCH__
bool is_romfs = false; bool is_romfs = false;
#endif
bool is_archive = false;
const char* theme_archive_path = NULL;
assetsClearTheme(); assetsClearTheme();
if(themePath[0]!=0) { if(themePath[0]!=0) {
const char* cfg_path = themePath; const char* cfg_path = themePath;
const char* ext = getExtension(themePath);
#ifdef __SWITCH__ #ifdef __SWITCH__
const char* ext = getExtension(themePath);
if (strcasecmp(ext, ".romfs")==0) { if (strcasecmp(ext, ".romfs")==0) {
if (R_FAILED(romfsMountFromFsdev(themePath, 0, "theme"))) if (R_FAILED(romfsMountFromFsdev(themePath, 0, "theme")))
cfg_path = NULL; cfg_path = NULL;
else { else {
is_romfs = true; is_romfs = true;
cfg_path = "theme:/theme.cfg"; cfg_path = "theme:/theme.cfg";
theme_archive_path = "theme:/";
} }
} }
#endif #endif
if (strcasecmp(ext, ".romfs")!=0 && strcasecmp(ext, ".cfg")!=0) {
theme_archive_path = themePath;
}
if (theme_archive_path) {
if (!PHYSFS_mount(theme_archive_path, "theme", 0)) cfg_path = NULL;
else {
is_archive = true;
cfg_path = "theme/theme.cfg";
}
}
if (cfg_path) { if (cfg_path) good_cfg = config_read_file(&cfg, cfg_path);
if (!is_archive) good_cfg = config_read_file(&cfg, cfg_path);
else {
u8 *cfg_buf = NULL;
good_cfg = assetsPhysfsReadFile(cfg_path, &cfg_buf, NULL, true);
if (good_cfg) good_cfg = config_read_string(&cfg, (char*)cfg_buf);
free(cfg_buf);
}
}
} }
switch (preset) { switch (preset) {
@ -607,8 +583,8 @@ void themeStartup(ThemePreset preset) {
layoutObjectFromSetting(config_setting_lookup(layout, "menuActiveEntryVersion"), &themeCurrent.layoutObjects[ThemeLayoutId_MenuActiveEntryVersion], false); layoutObjectFromSetting(config_setting_lookup(layout, "menuActiveEntryVersion"), &themeCurrent.layoutObjects[ThemeLayoutId_MenuActiveEntryVersion], false);
} }
if (is_archive) assets = config_lookup(&cfg, "assets"); if (is_romfs) assets = config_lookup(&cfg, "assets");
if (is_archive && assets) { if (is_romfs && assets) {
assetObjectFromSetting(config_setting_lookup(assets, "battery_icon"), AssetId_battery_icon, NULL); assetObjectFromSetting(config_setting_lookup(assets, "battery_icon"), AssetId_battery_icon, NULL);
assetObjectFromSetting(config_setting_lookup(assets, "charging_icon"), AssetId_charging_icon, NULL); assetObjectFromSetting(config_setting_lookup(assets, "charging_icon"), AssetId_charging_icon, NULL);
assetObjectFromSetting(config_setting_lookup(assets, "folder_icon"), AssetId_folder_icon, &themeCurrent.layoutObjects[ThemeLayoutId_MenuActiveEntryIcon]); assetObjectFromSetting(config_setting_lookup(assets, "folder_icon"), AssetId_folder_icon, &themeCurrent.layoutObjects[ThemeLayoutId_MenuActiveEntryIcon]);
@ -646,7 +622,6 @@ void themeStartup(ThemePreset preset) {
config_destroy(&cfg); config_destroy(&cfg);
if (is_archive) PHYSFS_unmount(theme_archive_path);
#ifdef __SWITCH__ #ifdef __SWITCH__
if (is_romfs) romfsUnmount("theme"); if (is_romfs) romfsUnmount("theme");
#endif #endif

View File

@ -68,20 +68,10 @@ static void launchFile(const char* path, argData_s* args)
init_args(argBuf, sizeof(argBuf)-1, args->buf, sizeof(args->buf)); init_args(argBuf, sizeof(argBuf)-1, args->buf, sizeof(args->buf));
struct stat st;
if (stat(path, &st) == -1) {
memset(msg, 0, sizeof(msg));
snprintf(msg, sizeof(msg)-1, textGetString(StrId_NroNotFound), path);
menuCreateMsgBox(780, 300, msg);
menuScan(".");
}
else {
Result rc = envSetNextLoad(path, argBuf); Result rc = envSetNextLoad(path, argBuf);
if(R_FAILED(rc)) { if(R_FAILED(rc)) {
memset(msg, 0, sizeof(msg)); memset(msg, 0, sizeof(msg));
snprintf(msg, sizeof(msg)-1, "%s\n2%03d-%04d", textGetString(StrId_AppLaunchError), R_MODULE(rc), R_DESCRIPTION(rc)); snprintf(msg, sizeof(msg)-1, "%s\n0x%x", textGetString(StrId_AppLaunchError), rc);
menuCreateMsgBox(780, 300, msg); menuCreateMsgBox(780, 300, msg);
} }
@ -89,7 +79,6 @@ static void launchFile(const char* path, argData_s* args)
uiExitLoop(); uiExitLoop();
} }
} }
}
const loaderFuncs_s loader_builtin = const loaderFuncs_s loader_builtin =
{ {

View File

@ -1,22 +1,19 @@
#include <switch.h> #include <switch.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <physfs.h>
#include "../common/common.h" #include "../common/common.h"
#include "nx_graphics.h"
#include "nx_touch.h" #include "nx_touch.h"
// Define the desired framebuffer resolution (here we set it to 720p). // Define the desired framebuffer resolution (here we set it to 720p).
#define FB_WIDTH 1280 #define FB_WIDTH 1280
#define FB_HEIGHT 720 #define FB_HEIGHT 720
Framebuffer g_framebufObj;
uint8_t* g_framebuf; uint8_t* g_framebuf;
u32 g_framebuf_width; u32 g_framebuf_width;
PadState g_pad;
PadRepeater g_pad_repeater;
bool menuUpdateErrorScreen(void); bool menuUpdateErrorScreen(void);
#ifdef PERF_LOG #ifdef PERF_LOG
@ -42,44 +39,35 @@ int main(int argc, char **argv)
u64 start_tick=0; u64 start_tick=0;
#endif #endif
padConfigureInput(8, HidNpadStyleSet_NpadStandard);
padInitializeAny(&g_pad);
padRepeaterInitialize(&g_pad_repeater, 20, 10);
hidSetNpadHandheldActivationMode(HidNpadHandheldActivationMode_Single);
touchInit();
memset(errormsg, 0, sizeof(errormsg)); memset(errormsg, 0, sizeof(errormsg));
appletLockExit(); appletLockExit();
appletSetScreenShotPermission(AppletScreenShotPermission_Enable); appletSetScreenShotPermission(AppletScreenShotPermission_Enable);
ColorSetId theme = ColorSetId_Light; ColorSetId theme;
rc = setsysInitialize(); rc = setsysInitialize();
if (R_FAILED(rc)) snprintf(errormsg, sizeof(errormsg)-1, "Error: setsysInitialize() failed: 0x%x.", rc);
if (R_SUCCEEDED(rc)) setsysGetColorSetId(&theme);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
setsysGetColorSetId(&theme); rc = plInitialize();
setsysExit(); if (R_FAILED(rc)) snprintf(errormsg, sizeof(errormsg)-1, "Error: plInitialize() failed: 0x%x.", rc);
} }
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
rc = textInit(); rc = textInit();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
snprintf(errormsg, sizeof(errormsg)-1, "Error: textInit() failed: 2%03d-%04d", R_MODULE(rc), R_DESCRIPTION(rc)); snprintf(errormsg, sizeof(errormsg)-1, "Error: textInit() failed: 0x%x.", rc);
} }
} }
if (R_SUCCEEDED(rc)) menuStartupPath(); if (R_SUCCEEDED(rc)) menuStartupPath();
if (R_SUCCEEDED(rc)) {
if (!PHYSFS_init(argv[0])) {
rc = 1;
snprintf(errormsg, sizeof(errormsg)-1, "Error: PHYSFS_init() failed: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
}
}
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
rc = assetsInit(); rc = assetsInit();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
snprintf(errormsg, sizeof(errormsg)-1, "Error: assetsInit() failed: 2%03d-%04d", R_MODULE(rc), R_DESCRIPTION(rc)); snprintf(errormsg, sizeof(errormsg)-1, "Error: assetsInit() failed: 0x%x.", rc);
} }
} }
@ -90,7 +78,7 @@ int main(int argc, char **argv)
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
rc = netloaderInit(); rc = netloaderInit();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
snprintf(errormsg, sizeof(errormsg)-1, "Error: netloaderInit() failed: 2%03d-%04d", R_MODULE(rc), R_DESCRIPTION(rc)); snprintf(errormsg, sizeof(errormsg)-1, "Error: netloaderInit() failed: 0x%x.", rc);
} }
} }
@ -127,7 +115,7 @@ int main(int argc, char **argv)
if (R_FAILED(lastret)) { if (R_FAILED(lastret)) {
memset(msg, 0, sizeof(msg)); memset(msg, 0, sizeof(msg));
snprintf(msg, sizeof(msg)-1, "%s\n2%03d-%04d", textGetString(StrId_LastLoadResult), R_MODULE(lastret), R_DESCRIPTION(lastret)); snprintf(msg, sizeof(msg)-1, "%s\n0x%x", textGetString(StrId_LastLoadResult), lastret);
menuCreateMsgBox(780, 300, msg); menuCreateMsgBox(780, 300, msg);
} }
@ -136,7 +124,8 @@ int main(int argc, char **argv)
if (errormsg[0]) error_screen = 1; if (errormsg[0]) error_screen = 1;
if (!error_screen) { if (!error_screen) {
graphicsInit(FB_WIDTH, FB_HEIGHT); framebufferCreate(&g_framebufObj, nwindowGetDefault(), FB_WIDTH, FB_HEIGHT, PIXEL_FORMAT_RGBA_8888, 2);
framebufferMakeLinear(&g_framebufObj);
} }
else { else {
consoleInit(NULL); consoleInit(NULL);
@ -146,17 +135,16 @@ int main(int argc, char **argv)
while (appletMainLoop()) while (appletMainLoop())
{ {
// Scan the gamepad. This should be done once for each frame
padUpdate(&g_pad);
padRepeaterUpdate(&g_pad_repeater, padGetButtons(&g_pad) & ( //Scan all the inputs. This should be done once for each frame
HidNpadButton_AnyLeft | HidNpadButton_AnyUp | HidNpadButton_AnyRight | HidNpadButton_AnyDown hidScanInput();
));
if (!error_screen) { if (!error_screen) {
if (!uiUpdate()) break; if (!uiUpdate()) break;
g_framebuf = graphicsFrameBegin(&g_framebuf_width); g_framebuf = framebufferBegin(&g_framebufObj, &g_framebuf_width);
#ifdef PERF_LOG #ifdef PERF_LOG
start_tick = armGetSystemTick(); start_tick = svcGetSystemTick();
#endif #endif
memset(g_framebuf, 237, g_framebuf_width * FB_HEIGHT); memset(g_framebuf, 237, g_framebuf_width * FB_HEIGHT);
menuLoop(); menuLoop();
@ -166,10 +154,10 @@ int main(int argc, char **argv)
} }
if (!error_screen) { if (!error_screen) {
graphicsFrameEnd(); framebufferEnd(&g_framebufObj);
#ifdef PERF_LOG #ifdef PERF_LOG
g_tickdiff_frame = armGetSystemTick() - start_tick; g_tickdiff_frame = svcGetSystemTick() - start_tick;
#endif #endif
} }
else { else {
@ -178,7 +166,7 @@ int main(int argc, char **argv)
} }
if (!error_screen) { if (!error_screen) {
graphicsExit(); framebufferClose(&g_framebufObj);
} }
else { else {
consoleExit(NULL); consoleExit(NULL);
@ -197,7 +185,8 @@ int main(int argc, char **argv)
netloaderExit(); netloaderExit();
powerExit(); powerExit();
assetsExit(); assetsExit();
PHYSFS_deinit(); plExit();
setsysExit();
appletUnlockExit(); appletUnlockExit();
@ -205,9 +194,14 @@ int main(int argc, char **argv)
} }
u64 menuGetKeysDown(void) { u64 menuGetKeysDown(void) {
u64 keys = padGetButtonsDown(&g_pad); u64 down = 0;
keys |= padRepeaterGetButtons(&g_pad_repeater);
return keys; for (u32 controller=0; controller<8; controller++) {
if (hidIsControllerConnected(controller)) down |= hidKeysDown(controller);
}
if (hidIsControllerConnected(CONTROLLER_HANDHELD)) down |= hidKeysDown(CONTROLLER_HANDHELD);
return down;
} }
//This is implemented here due to the hid code. //This is implemented here due to the hid code.
@ -220,26 +214,26 @@ bool menuUpdate(void) {
handleTouch(menu); handleTouch(menu);
if (down & HidNpadButton_Y) if (down & KEY_Y)
{ {
launchMenuNetloaderTask(); launchMenuNetloaderTask();
} }
else if (down & HidNpadButton_X) else if (down & KEY_X)
{ {
menuHandleXButton(); menuHandleXButton();
} }
else if (down & HidNpadButton_A) else if (down & KEY_A)
{ {
menuHandleAButton(); menuHandleAButton();
} }
else if (down & HidNpadButton_B) else if (down & KEY_B)
{ {
launchMenuBackTask(); launchMenuBackTask();
} }
else if(down & HidNpadButton_Minus){ else if(down & KEY_MINUS){
themeMenuStartup(); themeMenuStartup();
} }
else if (down & HidNpadButton_Plus) else if (down & KEY_PLUS)
{ {
exitflag = 1; exitflag = 1;
} }
@ -247,10 +241,10 @@ bool menuUpdate(void) {
{ {
int move = 0; int move = 0;
if (down & HidNpadButton_AnyLeft) move--; if (down & KEY_LEFT) move--;
if (down & HidNpadButton_AnyRight) move++; if (down & KEY_RIGHT) move++;
if (down & HidNpadButton_AnyDown) move-=entries_count; if (down & KEY_DOWN) move-=entries_count;
if (down & HidNpadButton_AnyUp) move+=entries_count; if (down & KEY_UP) move+=entries_count;
int newEntry = menu->curEntry + move; int newEntry = menu->curEntry + move;
if (newEntry < 0) newEntry = 0; if (newEntry < 0) newEntry = 0;
@ -265,7 +259,7 @@ bool menuUpdateErrorScreen(void) {
bool exitflag = 0; bool exitflag = 0;
u64 down = menuGetKeysDown(); u64 down = menuGetKeysDown();
if (down & HidNpadButton_Plus) if (down & KEY_PLUS)
{ {
exitflag = 1; exitflag = 1;
} }

View File

@ -1,141 +0,0 @@
#include <switch.h>
#include <deko3d.h>
#include "nx_graphics.h"
#define FB_NUM 2
#define CMDMEMSIZE 0x1000
static u32 s_fbWidth, s_fbHeight;
static DkDevice s_device;
static DkMemBlock s_fbMemBlock, s_workMemBlock, s_cmdMemBlock;
static DkSwapchain s_swapchain;
static DkCmdBuf s_cmdBuf;
static DkCmdList s_cmdLists[FB_NUM];
static DkFence s_fence;
static DkQueue s_queue;
void graphicsInit(u32 width, u32 height)
{
DkImageLayoutMaker imgLayoutMaker;
DkMemBlockMaker memBlockMaker;
// Create the device, which is the root object
DkDeviceMaker deviceMaker;
dkDeviceMakerDefaults(&deviceMaker);
s_device = dkDeviceCreate(&deviceMaker);
// Calculate layout for the framebuffers
DkImageLayout fbLayout;
dkImageLayoutMakerDefaults(&imgLayoutMaker, s_device);
imgLayoutMaker.flags = DkImageFlags_UsagePresent;
imgLayoutMaker.format = DkImageFormat_RGBA8_Unorm;
imgLayoutMaker.dimensions[0] = s_fbWidth = width;
imgLayoutMaker.dimensions[1] = s_fbHeight = height;
dkImageLayoutInitialize(&fbLayout, &imgLayoutMaker);
// Retrieve necessary size and alignment for the framebuffers
uint32_t fbSize = dkImageLayoutGetSize(&fbLayout);
uint32_t fbAlign = dkImageLayoutGetAlignment(&fbLayout);
fbSize = (fbSize + fbAlign - 1) &~ (fbAlign - 1);
// Create a memory block that will host the framebuffers
dkMemBlockMakerDefaults(&memBlockMaker, s_device, FB_NUM*fbSize);
memBlockMaker.flags = DkMemBlockFlags_GpuCached | DkMemBlockFlags_Image;
s_fbMemBlock = dkMemBlockCreate(&memBlockMaker);
// Initialize the framebuffers with the layout and backing memory we've just created
DkImage fbImages[FB_NUM];
DkImage const* swapchainImages[FB_NUM];
for (unsigned i = 0; i < FB_NUM; i ++)
{
swapchainImages[i] = &fbImages[i];
dkImageInitialize(&fbImages[i], &fbLayout, s_fbMemBlock, i*fbSize);
}
// Create a swapchain out of the framebuffers we've just initialized
DkSwapchainMaker swapchainMaker;
dkSwapchainMakerDefaults(&swapchainMaker, s_device, nwindowGetDefault(), swapchainImages, FB_NUM);
s_swapchain = dkSwapchainCreate(&swapchainMaker);
// Create a memory block for the linear framebuffer
dkMemBlockMakerDefaults(&memBlockMaker, s_device, width*height*4);
memBlockMaker.flags = DkMemBlockFlags_CpuCached | DkMemBlockFlags_GpuUncached;
s_workMemBlock = dkMemBlockCreate(&memBlockMaker);
// Create a memory block for the command lists
dkMemBlockMakerDefaults(&memBlockMaker, s_device, CMDMEMSIZE);
memBlockMaker.flags = DkMemBlockFlags_CpuUncached | DkMemBlockFlags_GpuCached;
s_cmdMemBlock = dkMemBlockCreate(&memBlockMaker);
// Create a command buffer
DkCmdBufMaker cmdBufMaker;
dkCmdBufMakerDefaults(&cmdBufMaker, s_device);
s_cmdBuf = dkCmdBufCreate(&cmdBufMaker);
dkCmdBufAddMemory(s_cmdBuf, s_cmdMemBlock, 0, CMDMEMSIZE);
// Define source for linear framebuffer copies
const DkCopyBuf linearSrc = {
.addr = dkMemBlockGetGpuAddr(s_workMemBlock),
.rowLength = 0,
.imageHeight = 0,
};
// Define rectangle for the copies
const DkImageRect copyRect = {
.x = 0, .y = 0, .z = 0,
.width = width, .height = height, .depth = 1,
};
// Record command lists for the copies
for (unsigned i = 0; i < FB_NUM; i ++) {
DkImageView tiledDst;
dkImageViewDefaults(&tiledDst, &fbImages[i]);
dkCmdBufCopyBufferToImage(s_cmdBuf, &linearSrc, &tiledDst, &copyRect, 0);
dkCmdBufSignalFence(s_cmdBuf, &s_fence, false);
s_cmdLists[i] = dkCmdBufFinishList(s_cmdBuf);
}
// Create a queue, to which we will submit our command lists
DkQueueMaker queueMaker;
dkQueueMakerDefaults(&queueMaker, s_device);
queueMaker.flags = 0; // we will only use this queue for transferring
s_queue = dkQueueCreate(&queueMaker);
}
void graphicsExit(void)
{
// Make sure the queue is idle before destroying anything
dkQueueWaitIdle(s_queue);
// Destroy all the resources we've created
dkQueueDestroy(s_queue);
dkCmdBufDestroy(s_cmdBuf);
dkMemBlockDestroy(s_cmdMemBlock);
dkMemBlockDestroy(s_workMemBlock);
dkSwapchainDestroy(s_swapchain);
dkMemBlockDestroy(s_fbMemBlock);
dkDeviceDestroy(s_device);
}
void* graphicsFrameBegin(u32* out_stride)
{
// Ensure the GPU is not reading from the framebuffer
dkFenceWait(&s_fence, -1);
// Return information
if (out_stride) *out_stride = s_fbWidth*4;
return dkMemBlockGetCpuAddr(s_workMemBlock);
}
void graphicsFrameEnd(void)
{
// Flush the linear framebuffer
dkMemBlockFlushCpuCache(s_workMemBlock, 0, s_fbWidth*s_fbHeight*4);
// Present a frame
int slot = dkQueueAcquireImage(s_queue, s_swapchain);
dkQueueSubmitCommands(s_queue, s_cmdLists[slot]);
dkQueuePresentImage(s_queue, s_swapchain, slot);
}

View File

@ -1,9 +0,0 @@
#pragma once
#include <switch.h>
void graphicsInit(u32 width, u32 height);
void graphicsExit(void);
void* graphicsFrameBegin(u32* out_stride);
void graphicsFrameEnd(void);

View File

@ -8,7 +8,7 @@ static bool powerCacheIsCharging;
static PsmSession powerSession; static PsmSession powerSession;
bool powerGetDetails(uint32_t *batteryCharge, bool *isCharging) { bool powerGetDetails(uint32_t *batteryCharge, bool *isCharging) {
PsmChargerType charger = PsmChargerType_Unconnected; ChargerType charger = ChargerType_None;
bool hwReadsSucceeded = false; bool hwReadsSucceeded = false;
bool use_cache = false; bool use_cache = false;
Result rc = 0; Result rc = 0;
@ -31,7 +31,7 @@ bool powerGetDetails(uint32_t *batteryCharge, bool *isCharging) {
else { else {
rc = psmGetChargerType(&charger); rc = psmGetChargerType(&charger);
hwReadsSucceeded &= R_SUCCEEDED(rc); hwReadsSucceeded &= R_SUCCEEDED(rc);
*isCharging = (charger != PsmChargerType_Unconnected); *isCharging = (charger > ChargerType_None);
} }
powerCacheCharge = *batteryCharge; powerCacheCharge = *batteryCharge;

View File

@ -9,6 +9,6 @@ void thermalstatusExit(void) {
} }
bool thermalstatusGetDetails(s32 *temperature) { bool thermalstatusGetDetails(s32 *temperature) {
return R_SUCCEEDED(tsGetTemperature(TsLocation_Internal, temperature)); return R_SUCCEEDED(tsGetTemperatureMilliC(TsLocation_Internal, temperature));
} }

View File

@ -10,13 +10,11 @@
struct touchInfo_s touchInfo; struct touchInfo_s touchInfo;
void touchInit(void) { void touchInit() {
touchInfo.gestureInProgress = false; touchInfo.gestureInProgress = false;
touchInfo.isTap = true; touchInfo.isTap = true;
touchInfo.initMenuXPos = 0; touchInfo.initMenuXPos = 0;
touchInfo.initMenuIndex = 0; touchInfo.initMenuIndex = 0;
touchInfo.lastSlideSpeed = 0;
hidInitializeTouchScreen();
} }
void handleTappingOnApp(menu_s* menu, int px) { void handleTappingOnApp(menu_s* menu, int px) {
@ -57,50 +55,50 @@ static inline bool checkInsideTextLayoutObject(ThemeLayoutId id, int x, int y) {
void handleTouch(menu_s* menu) { void handleTouch(menu_s* menu) {
ThemeLayoutObject *layoutobj = NULL; ThemeLayoutObject *layoutobj = NULL;
HidTouchScreenState touch = {0}; touchPosition currentTouch;
hidGetTouchScreenStates(&touch, 1); u32 touches = hidTouchCount();
layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuListTiles]; layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuListTiles];
int entries_count = layoutobj->posEnd[0]; int entries_count = layoutobj->posEnd[0];
layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuList]; layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_MenuList];
// On touch start. // On touch start.
if (touch.count == 1 && !touchInfo.gestureInProgress) { if (touches == 1 && !touchInfo.gestureInProgress) {
hidTouchRead(&currentTouch, 0);
touchInfo.gestureInProgress = true; touchInfo.gestureInProgress = true;
touchInfo.firstTouch = touch.touches[0]; touchInfo.firstTouch = currentTouch;
touchInfo.prevTouch = touch.touches[0]; touchInfo.prevTouch = currentTouch;
touchInfo.isTap = true; touchInfo.isTap = true;
touchInfo.initMenuXPos = menu->xPos; touchInfo.initMenuXPos = menu->xPos;
touchInfo.initMenuIndex = menu->curEntry; touchInfo.initMenuIndex = menu->curEntry;
touchInfo.lastSlideSpeed = 0;
menu->slideSpeed = 0;
} }
// On touch moving. // On touch moving.
else if (touch.count >= 1 && touchInfo.gestureInProgress) { else if (touches >= 1 && touchInfo.gestureInProgress) {
touchInfo.lastSlideSpeed = ((int)(touch.touches[0].x - touchInfo.prevTouch.x)); hidTouchRead(&currentTouch, 0);
touchInfo.prevTouch = touch.touches[0]; touchInfo.prevTouch = currentTouch;
if (touchInfo.isTap && (abs(touchInfo.firstTouch.x - touch.touches[0].x) > TAP_MOVEMENT_GAP || abs(touchInfo.firstTouch.y - touch.touches[0].y) > TAP_MOVEMENT_GAP)) { if (touchInfo.isTap && (abs(touchInfo.firstTouch.px - currentTouch.px) > TAP_MOVEMENT_GAP || abs(touchInfo.firstTouch.py - currentTouch.py) > TAP_MOVEMENT_GAP)) {
touchInfo.isTap = false; touchInfo.isTap = false;
} }
if (!menuIsMsgBoxOpen() && touchInfo.firstTouch.y > layoutobj->posStart[1] && touchInfo.firstTouch.y < layoutobj->posStart[1]+layoutobj->size[1] && !touchInfo.isTap && menu->nEntries > entries_count) { if (!menuIsMsgBoxOpen() && touchInfo.firstTouch.py > layoutobj->posStart[1] && touchInfo.firstTouch.py < layoutobj->posStart[1]+layoutobj->size[1] && !touchInfo.isTap && menu->nEntries > entries_count) {
menu->xPos = touchInfo.initMenuXPos + (currentTouch.px - touchInfo.firstTouch.px);
menu->curEntry = touchInfo.initMenuIndex + ((int) (touchInfo.firstTouch.px - currentTouch.px) / layoutobj->posEnd[0]);
if (!touchInfo.isTap) { if (menu->curEntry < 0)
menu->slideSpeed = touchInfo.lastSlideSpeed; menu->curEntry = 0;
}
if (menu->curEntry >= menu->nEntries - entries_count - 1)
menu->curEntry = menu->nEntries - entries_count;
} }
} }
// On touch end. // On touch end.
else if (touchInfo.gestureInProgress) { else if (touchInfo.gestureInProgress) {
int x1 = touchInfo.firstTouch.x; int x1 = touchInfo.firstTouch.px;
int y1 = touchInfo.firstTouch.y; int y1 = touchInfo.firstTouch.py;
int x2 = touchInfo.prevTouch.x; int x2 = touchInfo.prevTouch.px;
int y2 = touchInfo.prevTouch.y; int y2 = touchInfo.prevTouch.py;
if (!touchInfo.isTap) {
menu->slideSpeed = touchInfo.lastSlideSpeed;
}
bool netloader_active = menuIsNetloaderActive(); bool netloader_active = menuIsNetloaderActive();
@ -119,7 +117,7 @@ void handleTouch(menu_s* menu) {
} else if (touchInfo.isTap && !netloader_active) { } else if (touchInfo.isTap && !netloader_active) {
// App Icons // App Icons
if (y1 > layoutobj->posStart[1] && y1 < layoutobj->posStart[1]+layoutobj->size[1]) { if (y1 > layoutobj->posStart[1] && y1 < layoutobj->posStart[1]+layoutobj->size[1]) {
handleTappingOnApp(menu, touchInfo.prevTouch.x); handleTappingOnApp(menu, touchInfo.prevTouch.px);
} }
// Bottom Buttons // Bottom Buttons
else { else {

View File

@ -5,13 +5,11 @@
struct touchInfo_s { struct touchInfo_s {
bool gestureInProgress; bool gestureInProgress;
HidTouchState firstTouch; touchPosition firstTouch;
HidTouchState prevTouch; touchPosition prevTouch;
bool isTap; bool isTap;
int initMenuXPos; int initMenuXPos;
int initMenuIndex; int initMenuIndex;
int lastSlideSpeed;
}; };
void touchInit(void);
void handleTouch(menu_s* menu); void handleTouch(menu_s* menu);

View File

@ -1,7 +1,6 @@
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <physfs.h>
extern "C" { extern "C" {
@ -11,13 +10,12 @@ extern "C" {
color_t pixels[720][1280]; color_t pixels[720][1280];
int main(int argc, char **argv) int main()
{ {
sf::RenderWindow window(sf::VideoMode(1280, 720), "Test"); sf::RenderWindow window(sf::VideoMode(1280, 720), "Test");
window.setFramerateLimit(60); window.setFramerateLimit(60);
menuStartupPath(); menuStartupPath();
PHYSFS_init(argv[0]);
assetsInit(); assetsInit();
themeStartup(THEME_PRESET_LIGHT); themeStartup(THEME_PRESET_LIGHT);
textInit(); textInit();
@ -64,7 +62,6 @@ int main(int argc, char **argv)
netloaderExit(); netloaderExit();
fontExit(); fontExit();
assetsExit(); assetsExit();
PHYSFS_deinit();
return 0; return 0;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B