131 Commits

Author SHA1 Message Date
Niklas080208
ad4dd48026 Fix storage bar colours when theme uses custom background image
Some checks failed
build / build (ubuntu-latest, Release) (push) Failing after 22s
The header storage bar (microSD/System) used ThemeEntryID_BACKGROUND and ThemeEntryID_TEXT_INFO. When a theme sets background to an image path, no colour is set for that entry, so the bar got an unset/default colour (often white) and looked wrong on dark themes. Use PROGRESSBAR and PROGRESSBAR_BACKGROUND for the bar so it always uses theme colours that are defined as colours, not images.
2026-02-06 22:06:01 +01:00
dragonflylee
0474566576 Update chinese localization (#234) 2025-12-01 07:19:51 +09:00
david082321
09e8e50e69 Add Traditional Chinese localization (#223)
* Add Traditional Chinese localization

* Update

Upate to this version
dbb0501420/assets/romfs/i18n/zh-TW.json

* Translate

---------

Co-authored-by: Yorunokyujitsu <164279972+Yorunokyujitsu@users.noreply.github.com>
2025-11-29 06:55:12 +09:00
Yorunokyujitsu
db72e84c5b json: Fixed incorrect Simplified and Traditional Chinese labels 2025-11-29 06:49:40 +09:00
Yorunokyujitsu
d47bb0a41d Update Japanese and Korean.
- Update Japanese translation.
- Update Korean translation.
- Fix JSON syntax error (extra comma) in nl.json.
- Fix several translation strings.
2025-11-28 07:29:27 +09:00
stevo_ko
3b741f3180 Updated German Translation (#214)
* Updated German Translation

Just updated the German Translation, it is probably still not perfect

* Missing semicolons

---------

Co-authored-by: Yorunokyujitsu <164279972+Yorunokyujitsu@users.noreply.github.com>
2025-11-28 06:59:18 +09:00
Ninji418
a8965c0d4a Spanish translations (#230)
* Spanish translations

-Added Spanish translations for backup, USB, and mount menus
-Translations sourced from Google Translate and AI suggestions
-Preserved original formatting, line breaks, and 2-space line prefixes
-Miscellaneous minor UI strings translated
-all translations are taken from the en.json since the es.json has a bunch of empty fields
once again this isn't my native language, anyone is free to correct me on any part they deem necessary
2025-11-28 06:52:07 +09:00
redraz
87c277470e Update ru.json (#200)
Co-authored-by: Yorunokyujitsu <164279972+Yorunokyujitsu@users.noreply.github.com>
2025-11-28 06:24:10 +09:00
Yorunokyujitsu
c1b6287437 Added the missing parentheses. 2025-11-25 19:21:52 +09:00
Yorunokyujitsu
4540dd0112 homebrew: Added a Back button.
- Fixed an issue where entering through Menus could trap the user inside the menu.
2025-11-25 19:12:03 +09:00
Yorunokyujitsu
dbb0501420 json: Updated based on version 1.0.0.
- Removed all deprecated/unused strings.
- Added all missing translatable strings.
- Removed the previous unified Chinese translation and added separate Simplified and Traditional Chinese support.
2025-11-25 19:11:29 +09:00
Yorunokyujitsu
28411fcdd1 i18n: Added translatable strings, new languages, and extended localization features.
- Added sub-keys to better manage long strings, allowing either the sub-key value or the original text to be used.
- Multi-line values are now supported in language.json to prevent overly long single lines.
- Added word-order adjustment for certain Asian languages such as Japanese and Korean.
- Added separate support for Simplified and Traditional Chinese.
2025-11-25 19:10:45 +09:00
ITotalJustice
7f2d0e72f2 fix workflow 2025-11-18 18:29:38 +00:00
ITotalJustice
c9552f9785 bump version for new release 0.13.3 -> 1.0.0. 2025-11-18 18:11:59 +00:00
ITotalJustice
444ff3e2d1 swkdb: add support for setting the header. save: add support for setting the name for the save file. 2025-10-09 14:45:08 +01:00
ITotalJustice
7d56c8a381 increase list scroll speed. add list jump start/end. add L2 + scroll to select multiple enrties. 2025-10-07 07:05:38 +01:00
ITotalJustice
da051f8d8f add support for replacing the homebrew menu tab with another menu. 2025-10-03 09:58:48 +01:00
ITotalJustice
81e6bc5833 disable sftp as it was unused and very slow compared to other clients. 2025-10-03 09:07:12 +01:00
ITotalJustice
ca5ea827b2 devoptab: fix nginx listing, fix modifying entry overriding the scheme, fix smb failing to parse url if path isn't set. ftpsrv: workaround clients sending PASS for anon. 2025-10-03 07:31:10 +01:00
ITotalJustice
b700fff9ac devoptab: fix create new mount entries failing if the mount folder didn't already exist. 2025-09-29 02:19:25 +01:00
ITotalJustice
81741364a7 homebrew: fix crashing due to using the wrong array size when scrolling. 2025-09-28 23:04:16 +01:00
ITotalJustice
faebc42f0d fs: fix stdio dir count not filtering types. game/bfsar: fix dir listing loop exiting early due to post increment in the loop. 2025-09-27 03:37:29 +01:00
ITotalJustice
63e11ca377 remove unused 12h clock option. add option to hide ip address. 2025-09-21 22:13:53 +01:00
ITotalJustice
54a2215e04 support for filtering mtp/ftp mount options. use builtin config for ftp port,user,pass. 2025-09-21 21:56:36 +01:00
ITotalJustice
5edc3869cd display storage sizes, properly colour info text, and more (see below)
- display internal and sd card storage sizes.
- removed battery info.
- removed current time info.
- fix dumping save to sd card due to not opening the file with append.
- change all sizes to display GB instead of GiB.
- change progress bar units to 1000 rather than 1024.
- all info text, such as sizes and timestamps now use the info text colouring.
- shorten the ncm content type names.
2025-09-21 18:54:08 +01:00
ITotalJustice
a772d660f3 use spinner instead of default icon for homebrew + games menus.
more menus will use it soon.
need to have a way to show the spinner when loading, then revert to the default icon if
failed to load, or an icon doesn't exist.

otherwise, the user may think that the icon is still loading and wait for it.
2025-09-21 04:08:36 +01:00
ITotalJustice
3c504cc85d devoptab: add mounts (wrapper around all mounts, exposed via MTP/FTP). lots of fixes (see below).
- updated libhaze to 81154c1.
- increase ftpsrv stack size as it would crash when modifying custom mounts.
- fix warning for unused log data in haze.
- fix eof read for nsp/xci source by instead returning 0 for bytes read, rather than error.
- add support for lstat the root of a mount.
- handle zero size reads when reading games via devoptab.
2025-09-21 03:51:13 +01:00
ITotalJustice
0a2c16db0c mtp: bump to 6e24502, fixes freezing if write blocks for too long, simplify stream install for mtp and ftp.
see: https://github.com/ITotalJustice/libhaze/issues/1
2025-09-20 20:27:02 +01:00
ITotalJustice
2bd84c8d5a add version overrides for builds. 2025-09-19 19:43:38 +01:00
ITotalJustice
7cd668efb7 keyboard: swap Z/X 2025-09-18 17:14:37 +01:00
ITotalJustice
a6265c3089 add keyboard navigation support. 2025-09-18 17:06:22 +01:00
ITotalJustice
a2300c1a96 fix crashes when signalling a event thats not created yet.
this caused a crash after installing a game if the games menu wasn't init.
the same would happen if the games menu signalled the save menu.
2025-09-18 15:35:24 +01:00
ITotalJustice
3dae3f9173 devoptab/curl: fix rare deadlock casued by sleeping/blocking in curl callback functions.
it seems that curl does not like long blocking in the r/w callbacks.
blocking for too seems to cause a deadlock as the server stops send/recv anymore data.

to fix this, i now use curls pause api.
this api is not thread safe, so it's a little more involved than it needs to be.

however this fixes the deadlock as curls pause actually reduces the download/upload speed
to the minimum. it also reduces exit latency as now exiting is handled in the progress callback
as well, which is called far more often than r/w.
2025-09-16 04:15:56 +01:00
ITotalJustice
63c420d5d8 devoptab: set default url scheme and port in creator. make form sidebar slightly wider and always show on the left side. 2025-09-15 21:51:06 +01:00
ITotalJustice
a94c6bb581 devoptab: add games. add MTP and FTP game exporting. update ftpsrv (see below). fix "fix_path()" parsing.
ftpsrv was updated to support MLST and MLSD, as well as fixing SIZE (was fixed to 32bit).
2025-09-15 21:18:53 +01:00
ITotalJustice
9fe0044a65 devoptab: only push popuplist if the items array is non-empty. curl: guess the url scheme rather than force https. 2025-09-14 15:14:35 +01:00
ITotalJustice
c05ce5eff4 yati: signal change to games menu when a new game is installed. 2025-09-14 14:52:21 +01:00
ITotalJustice
a019103ed5 mui: create menus info text from the menus array, rather than hardcoding them. 2025-09-14 14:37:00 +01:00
ITotalJustice
50e55f4fca mtp: support overriding vid/pid. 2025-09-14 14:30:46 +01:00
ITotalJustice
0706683690 mui: rename misc to menus, change menu options order so that menus is at the top, improve some info boxes text. 2025-09-14 14:16:50 +01:00
ITotalJustice
9cdb77bafa devoptab: add mount creator. 2025-09-14 14:04:20 +01:00
ITotalJustice
b476c54825 devoptab: add workaround for dkp nullptr bug.
manually set the array at startup to avoid nullptr access.
2025-09-13 13:28:55 +01:00
ITotalJustice
8b2e541b1d lots of changes, see description.
- enable sftp by default.
- add more descriptive stdio errors.
- disable devoptab timeout by default.
- handle errors for devoptab seek.
- add r/d/w progress events for threaded_file_transfer
- remove system album from file browser, only show sd card.
- do not clear game selection in games menu. useful for selecting games to backup, then delete after.
- change smb2 r/w to only send max amount, matches nfs behaviour. not sure if its needed as smb probably handles it for us.
2025-09-13 13:16:18 +01:00
ITotalJustice
931531e799 devoptab: add SFTP. fs: disable stdio buffering. cmake: add options to disable components of sphaira, add new "lite" build with minimal features. 2025-09-09 18:39:03 +01:00
ITotalJustice
1695d69aa3 audio: enable flac, make thread safe, fix crash on exit if audio wasn't init. 2025-09-09 10:39:52 +01:00
ITotalJustice
217bd3bed3 mui: add list index to sidebar and popup_list, and better center the index text. 2025-09-08 01:47:41 +01:00
ITotalJustice
384e8794bf devoptab: refactor all custom mounts to inherit from helper struct. 2025-09-08 01:34:20 +01:00
ITotalJustice
61b398a89a fatfs: use devoptab mounting. devoptab: add config for hidding from fs and dump, fix http being writeable. 2025-09-07 17:35:37 +01:00
ITotalJustice
ba78fd0dc5 devoptab: add vfs, change mount.ini path location. 2025-09-07 15:43:01 +01:00
ITotalJustice
43969a773e fs: fix CreateDirectoryRecursivelyWithPath() for root files. save: fix restore detection. devoptab: return proper errno codes. 2025-09-07 14:40:45 +01:00
ITotalJustice
6e1eabbe0f devoptab: deprecate locations.ini in favour of hdd/network mounts, better handle folder creation errors. 2025-09-07 13:30:53 +01:00
ITotalJustice
b99d1e5dea devoptab: add webdav, refactor network devices, multi thread r/w to improve perf and support webdav uploads. 2025-09-07 12:40:45 +01:00
ITotalJustice
6ce566aea5 http: optimise the dir_list parsing, only parse tables. filebrowser: option to disable stat per fs.
this improves network fs speed by disabling stat for http entriely, and only enabling file stat for everything else.
this can be overriden in the config.
2025-09-05 14:10:06 +01:00
ITotalJustice
a4209961e2 devoptab: add ftp mount with random read and streaming write support.
read still needs some work. opening a file should open a thread where data is read/written async.
this avoids the huge number of roundtrips per r/w.

eg, a read currently has to REST, open the data socket, send the file data, send ABOR to close and then close the data socket.

using the thread approach would just send the file over the already open data socket.
writes will also benefit from the above, just instead of REST it would be APPE.

seeks would need to do the above ABORT, close and re-open. however most reads in sphaira are not random access. so this isn't an issue.
2025-09-04 22:29:35 +01:00
ITotalJustice
181ff3f2bf devoptab: fix http config parsing, add more options to network mounts (timeout,uid,port). fs: update path size.
fs path was changed to 255 in the past because that is the real path size that fs can handle.
however, this restriction does not apply to nfs, samba, http - and it is very easy to exceed this 255 path length.

to fix this, i have increased the path len to 1024. this allows fs to continue to work as the buffer is
big enough, but also gives network mounts enough space to work with.
2025-09-04 12:18:34 +01:00
ITotalJustice
b85b522643 app: remove ams erpt disable as it is possible to cause ams to fatal if a crash report fails to write. 2025-09-04 09:40:39 +01:00
ITotalJustice
5158e264c0 devoptab: add http, nfs and smb mount. nca: zero init ncz structs. fs: fix FsPath compare. 2025-09-03 18:56:54 +01:00
ITotalJustice
fd67da0527 webusb: add support for exporting. usb: block requests with no timeout, using pbox to cancel if the user presses B. 2025-09-02 04:24:45 +01:00
ITotalJustice
7bdec8457f tests: move location of usb tests and update workflows for the new paths. 2025-08-31 07:37:54 +01:00
ITotalJustice
bc75c9a89f workflow: temp disable main workflow on dev until libnx pushes a new release. 2025-08-31 07:30:13 +01:00
ITotalJustice
c2e8734e85 webusb: add webUSB page and workflow to auto build it. 2025-08-31 07:15:53 +01:00
ITotalJustice
22e965521a usb: change api so that every packet sent is crc32c, update python usb api, add automated tests for usb. 2025-08-31 06:12:02 +01:00
ITotalJustice
b6b1af5959 Revert "Clean up python (#212)"
This reverts commit 0a8bc01870.
2025-08-31 04:27:53 +01:00
ITotalJustice
876be3b7b6 download: add ref count to cache init/exit and have all threads call init.
this ensures that the etag cache is ready to use before a download request is made, avoiding a rare race condition.
2025-08-31 03:50:44 +01:00
ITotalJustice
62f48353ba download: use new etag cache file and delete the old one, this removes all the old themezer entries. 2025-08-31 03:50:44 +01:00
ITotalJustice
9c65e5a12d app: remove old themezer cache 2025-08-31 03:50:44 +01:00
ITotalJustice
235e947186 app: move config to async init 2025-08-31 03:50:44 +01:00
AndrewSpangler
0a8bc01870 Clean up python (#212)
* Python cleanup
2025-08-31 03:48:37 +01:00
ITotalJustice
f0bdc01156 huge changes to everything (see below).
Changelog:
- re-enable use in release build.
- remove ftpsrv and untitled from builtin ghdl options, as both packages are available in the appstore.
- add image viewer (png, jpg, bmp)
- add music player (bfstm, bfwav, mp3, wav, ogg)
- add idv3 tag parsing support for mp3.
- add "decyption" of GTA Vice City mp3.
- add usbdvd support for music playback and file browsing.
- add nsz export support (solid, block, ldm).
- add xcz export support (same as above).
- add nro fs proper mount support (romfs, nacp, icon).
- add program nca fs support.
- add bfsar fs support.
- re-write the usb protocol, still wip. replaces tinfoil protocol.
- all threads are now create with pre-emptive support with the proper affinity mask set.
- fix oob crash in libpulsar when a bfwav was opened that had more than 2 channels.
- bump yyjson version.
- bump usbhsfs version.
- disable nvjpg.
- add support for theme music of any supported playback type (bfstm, bfwav, mp3, wav, ogg).
- add support for setting background music.
- add async exit to blocking threads (download, nxlink, ftpsrv) to reduce exit time.
- add support for dumping to pc via usb.
- add null, deflate, zstd hash options, mainly used for benchmarking.
- add sidebar slider (currently unused).
- file_viwer can now be used with any filesystem.
- filebrowser will only ever stat file once. previously it would keep stat'ing until it succeeded.
- disabled themezer due to the api breaking and i am not willing to keep maintaining it.
- disable zlt handling in usbds as it's not needed for my api's because the size is always known.
- remove usbds enums and GetSpeed() as i pr'd it to libnx.
- added support for mounting nca's from any source, including files, memory, nsps, xcis etc.
- split the lru cache into it's own header as it's now used in multiple places (nsz, all mounted options).
- add support for fetching and decrypting es personalised tickets.
- fix es common ticket converting where i forgot to also convert the cert chain as well.
- remove the download default music option.
- improve performance of libpulsar when opening a bfsar by remove the large setvbuf option. instead, use the default 1k buffer and handle large buffers manually in sphaira by using a lru cache (todo: just write my own bfsar parser).
- during app init and exit, load times have been halved as i now load/exit async. timestamps have also been added to measure how long everything takes.
- download now async loads / exits the etag json file to improve init times.
- add custom zip io to dumper to support writing a zip to any dest (such as usb).
- dumper now returns a proper error if the transfer was cancelled by the user.
- fatfs mount now sets the timestamp for files.
- fatfs mount handles folders with the archive bit by reporting them as a file.
- ftpsrv config is async loaded to speed up load times.
- nxlink now tries attempt to connect/accept by handling blocking rather than just bailing out.
- added support for minini floats.
- thread_file_transfer now spawns 3 threads rather than 2, to have the middle thread be a optional processor (mainly used for compressing/decompressing).
- added spinner to progress box, taken from nvg demo.
- progress box disables sleep mode on init.
- add gamecard detection to game menu to detect a refresh.
- handle xci that have the key area prepended.
- change gamecard mount fs to use the xci mount code instead of native fs, that way we can see all the partitions rather than just secure.
- reformat the ghdl entries to show the timestamp first.
- support for exporting saves to pc via usb.
- zip fs now uses lru cache.
2025-08-28 23:12:34 +01:00
ITotalJustice
cd6fed6aae devoptab: use fixed size array of entries rather than vector as vector can change/break pointers when it reallocs. fs: disable loading assoc when mounting custom fs. 2025-08-12 08:04:24 +01:00
ITotalJustice
7835ebc346 perf: async signal exit ftpsrv and nxlink thread in order to not block. add perf logging for exit. 2025-08-11 22:26:28 +01:00
ITotalJustice
3c33581a08 devoptab: cache all reads to max read throughput, now as fast as normal sd card reads, including compressed zips (80MiB/s). 2025-08-11 21:35:43 +01:00
ITotalJustice
3e9a8c9249 devoptab: only add new entry if mounting is successful. 2025-08-11 20:59:56 +01:00
ITotalJustice
d6c8f120c6 fs: add zip mount support. hash: fix not checking open result for file. fs: fix stdio not checking nullptr access. 2025-08-11 20:01:53 +01:00
ITotalJustice
cb2fa1abfc fs: add support for mounting nsp an xci files in the filebrowser. 2025-08-11 07:01:52 +01:00
ITotalJustice
25f2cfbff2 save: support for mounting save fs, add LRU cache for fatfs. add mounting nro romfs. 2025-08-10 17:31:22 +01:00
ITotalJustice
3404d4cece app: destroy widgets in reverse order on exit as the widgets are a stack. 2025-08-09 11:45:13 +01:00
ITotalJustice
44e1584461 fs: add support for mounting nca, save and gamecard fs. file picker inherits from browser. fix bugs (see below).
- fixed fs real path length not actually being 0x301, but instead 255. fixes #204
- file picker inherits from file browser now so there's a lot less duplicated code.
- file browser now saves the last highlighted file.
- fix bug in file browser where the new file path could be empty (ie not containing a /).
- added support for viewing qlaunch romfs.
- moved fs mount options to the top of the list (may revert).
2025-08-09 11:34:35 +01:00
ITotalJustice
8a16188996 fat: add support for mounting fat bis paritions (prodinfof, safe, user, system), inital work needed for fetching personalised es tickets. 2025-08-08 05:12:51 +01:00
ITotalJustice
70518762ae game_menu: remove stubbed option to enable/disable title cache.
the option was never actually implemented and there's no benifit to disabling it anyway.
2025-08-06 14:11:59 +01:00
ITotalJustice
a0370912da Add content/nca viewer for games menu, fix manual nca title fetch for chinese lang icon, rename "dump" to "export". 2025-08-06 14:11:05 +01:00
ITotalJustice
3fee702ee2 ftp_menu: fix passphrase ascii convert which could cause a stack overflow.
from my notes:
this converts the passphrase array into an ascii string
well, turns out std::transform does not actually increase the std::string size when pushing the new ascii characters
basically, std::string (normally) has small string optimisation. For this, they have a small array which it uses instead of allocating memory.

std::transform casts the std::string itr to a void*. sooo it was basically manually writing to the class, which just so happened to be the SSO buffer. however after 32chars, it runs out...and starts overwriting the stack. so this was a stack overflow lmao
only reason i found this is because i changed some optimisation flags, so the compiler ended up inlining std::transform, which detected the buffer overflow. and then i realised how fucked it was lol.
2025-08-04 20:17:14 +01:00
ITotalJustice
54d73a6d3b optimise: pass all large objects (std::function, std::string, structs) by const ref rather than value.
really, these functions should be passed by && and using std::forward on assignment.
however, this means writing a lot of extra code for every single class, as well as explicitly calling move
in a lot of cases.

In the case of std::string, passing by value and calling std::move is the correct approach, especially if the
string is created as an rvalue, then it is only created once and moved into the dest.
Whereas with a const ref, the string is created and then copied into the dst, basically creating 2 copies.
The same thing happens std::function, and well any object.

However, accepting everything by value sucks if you call a constructor from within a constructor, as now you need to create 2 impls
that accept by value and the other by rvalue. All of this extra code to have a more efficent impl just isn't worth it when, going by
the benchmarks, makes no measurable difference (i count anything within >= 1ms as measurable).
2025-08-04 18:58:20 +01:00
ITotalJustice
9fe9c9d491 themezer: only show latest release for nxtheme when prompting user to download nro. 2025-08-03 04:00:21 +01:00
ITotalJustice
4300c9ee1b filebrowser/picker: backport changes in totalsms (optimise zip peek, remove unused vars and code, optimise folder count, fix missed extension parse). 2025-08-03 03:26:24 +01:00
ITotalJustice
a3780bdcea filebrowser: add forwarder creator. 2025-08-03 00:58:03 +01:00
ITotalJustice
6554b68efa menu: add filepicker, sidebar: add file picker entry.
the filepicker is a stripped down version of the file browser. only file picking is supported atm, no "select folder" yet.
2025-08-02 22:19:48 +01:00
ITotalJustice
1a00db9d55 sidebar: add text input entry 2025-08-02 19:18:42 +01:00
ITotalJustice
fb3ad260da install: add enable prompt to filebrowser and gc menu when an install option is clicked whilst disabled. 2025-08-02 18:41:52 +01:00
ITotalJustice
ed02b0f260 sidebar: add callback when a disabled option is clicked. install: option to enable when a disabled option is clicked. 2025-08-02 18:30:56 +01:00
ITotalJustice
620334439c themezer: show option to launch nro. 2025-08-02 17:51:36 +01:00
ITotalJustice
ab5c54b47a themeze: prompt user to install theme after installing. 2025-08-02 17:47:09 +01:00
ITotalJustice
40e4616520 themezer: prompt user to download ThemeInjector if not installed on launch. 2025-08-02 17:21:07 +01:00
ITotalJustice
3ebb3bd055 option to hide homebrew. 2025-07-31 18:47:41 +01:00
ITotalJustice
25e19b22f7 fix broken link in readme for switch-010editor-templates 2025-07-31 03:05:47 +01:00
ITotalJustice
c67266fe1a display install options by default, but warn the user that installing is disabled an instruct them on how to enable. 2025-07-31 02:48:19 +01:00
ITotalJustice
92d747a0f5 remove seconds from the clock, fix long file name in info box for theme music. 2025-07-31 01:41:07 +01:00
ITotalJustice
79b52ed13e fix the spacing on some of the info boxes 2025-07-31 01:32:21 +01:00
ITotalJustice
bd3ad8782a bump ftpsrv and haze versions (ftpsrv 85b3cf0, haze 0be1523). haze now has 4gb+ support. 2025-07-31 01:23:50 +01:00
ITotalJustice
6b57619871 change default option when installing for nca verify.
the default options where to always verify the nca content, this was for brick protection.
however, users seem to not care about this protection and get frustrated with the default values,
seemingly unable to find the install menu to disable said options.

this change skips verify by default. less issues for me, less unhappy users, win win.
2025-07-30 23:28:25 +01:00
ITotalJustice
c8644c80cd add more info boxes to options, merge option.cpp changes from totalsms. 2025-07-30 23:26:15 +01:00
ITotalJustice
430ee2280a update scrolling using delta_time to allow for smooth scrolling at different refresh rates (ie, using fpslocker). 2025-07-30 18:03:50 +01:00
vanTheodore
f71c10619c Update es.json (#194) 2025-07-30 18:03:28 +01:00
ITotalJustice
b6497c03f6 backport widget changes from totalsms 2025-07-21 12:40:54 +01:00
ITotalJustice
ecb470b938 ghdl: display timestamp for each release and asset 2025-07-21 12:24:28 +01:00
ITotalJustice
a9d3734117 ghdl: list all releases 2025-07-21 11:23:43 +01:00
redraz
faf77d8212 Update ru.json (#192) 2025-07-21 10:34:10 +01:00
Ny'hrarr
3e6d7af720 Update pt.json (#189) 2025-07-21 10:33:57 +01:00
BIGBIGSUI
f69cf8130d Update zh.json (#187)
an updated zh.json.  hope it helps.
2025-07-21 10:33:42 +01:00
ITotalJustice
796208722e workflow: only push new workflow release on push, set specific cmake version, use nproc to use all cores when building. 2025-07-21 10:30:11 +01:00
ITotalJustice
85dbc54641 remove unused usb script 2025-07-21 10:20:58 +01:00
ITotalJustice
8381446a69 disable usb and ftp installs 2025-07-21 10:17:27 +01:00
ITotalJustice
97dc39620c use condivar in install stream to wait until the buffer is empty 2025-07-20 20:25:49 +01:00
ITotalJustice
7fb973c28d handle more usb errors, set max for notifications, usb transfer uses unique ptr over vector, show usb speed in usb menu. 2025-07-19 20:29:53 +01:00
ITotalJustice
4421ac1ceb use uevent in transfer loops to reduce latency between exiting and updating progress time. 2025-07-19 18:33:47 +01:00
ITotalJustice
159abfa246 bump libhaze version, multithread mtp transfers to maximise sd throughput (77MiB/s read, 40MiB/s write) 2025-07-19 17:45:39 +01:00
ITotalJustice
4b06700187 add info boxes, fix case sensitive path compares, many other changes (see comments)
- nca::ParseControl now gets the nacp base on the language.
- xci returns a more descriptive error and logs info during install.
- replace volatile with atmoic, label atmoic methods with volatile as per the standard.
- s2s usb install skips verifying the content as its being installed from another switch.
- fix game / save menu bug where it would only load the nacp if it has started yet, now it will force load even if its in progress.
  this fixes save file zips having empty names.
- game menu saves the application type, to be later used for displaying if its a gamecard (inserted or not), launched etc.
2025-07-19 17:33:28 +01:00
Chronoss
ee68ca54b8 Update fr.json (#182) 2025-06-25 19:31:22 +01:00
ITotalJustice
0bfd336796 always set FsCreateOption_BigFile in fs.cpp when creating 4GiB+ file. 2025-06-25 19:28:23 +01:00
ITotalJustice
9b967a9af0 set FsSaveDataMetaInfo in save creation to match hos. 2025-06-25 19:25:00 +01:00
ITotalJustice
299aaa5359 fix save menu crash caused by commit 2ff2923. 2025-06-25 19:17:35 +01:00
ITotalJustice
4e3927bbd0 reduce explicit calls to make_unique by having app::push and options::add call it for us.
this commit doesn't change the codegen. it just cleans up the code slightly.
2025-06-25 19:17:01 +01:00
ITotalJustice
38f19ec778 add option to disable erpt_reports 2025-06-25 17:49:45 +01:00
ITotalJustice
168f4b0303 slightly optimise hbl by reading nro in a single pass and remove dynamic memory. 2025-06-25 17:37:28 +01:00
ITotalJustice
6f8300fb32 filter out some apps (hbmenu, retroarch core) if replaced via another app, or false positive. remove uneeded file.close() and commit calls. 2025-06-25 01:39:46 +01:00
ITotalJustice
2ff2923d39 replace almost all uses of shared_ptr with unique_ptr. 2025-06-23 20:02:04 +01:00
ITotalJustice
aa724e12ba fix invalid character being set in file path for themes (via theme name or author). log module in error box.
fixes #184
2025-06-23 17:08:42 +01:00
ITotalJustice
e039309a77 clear title result array when nxtc cache is deleted. rename sys-tweek -> sys-tweak. 2025-06-22 21:34:36 +01:00
ITotalJustice
a4f0a97088 use app_id for save backups for when the app is corrupted. 2025-06-21 23:25:21 +01:00
ITotalJustice
9d4c431eef add save creation. add loading sys-tweek entries. add title cache delete. 2025-06-21 22:25:51 +01:00
ITotalJustice
1f7179e941 simplify title cache loading. 2025-06-21 15:32:55 +01:00
226 changed files with 68318 additions and 11479 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,6 +1,12 @@
name: build
on: [push, pull_request]
on:
push:
branches-ignore:
- dev
pull_request:
branches-ignore:
- dev
jobs:
build:
@@ -8,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
preset: [MinSizeRel]
preset: [Release]
runs-on: ${{ matrix.os }}
container: devkitpro/devkita64:latest
@@ -16,16 +22,17 @@ jobs:
- uses: actions/checkout@v3
# fetch latest cmake
- uses: lukka/get-cmake@latest
- uses: lukka/get-cmake@v3.31.6
- name: Configure CMake
run: |
cmake --preset ${{ matrix.preset }} -DUSE_VFS_GC=0
run: cmake --preset ${{ matrix.preset }}
- name: Build
run: cmake --build --preset ${{ matrix.preset }} --parallel 4
run: cmake --build --preset ${{ matrix.preset }} --parallel $(nproc)
- uses: actions/upload-artifact@master
- name: Deploy
if: ${{ github.event_name != 'pull_request' && github.event.action != 'unassigned' }}
uses: actions/upload-artifact@master
with:
name: sphaira-${{ matrix.preset }}
path: build/${{ matrix.preset }}/sphaira.nro

33
.github/workflows/python-usb-export.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: USB Export Python Tests
on:
push:
paths: &python_usb_export_paths
- 'tools/tests/test_usb_export.py'
- 'tools/usb_export.py'
- 'tools/usb_common.py'
- 'tools/requirements.txt'
- '.github/workflows/python-usb-export.yml'
pull_request:
paths: *python_usb_export_paths
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tools/requirements.txt
- name: Run tests
run: |
python3 tools/tests/test_usb_export.py

View File

@@ -0,0 +1,33 @@
name: USB Install Python Tests
on:
push:
paths: &python_usb_install_paths
- 'tools/tests/test_usb_install.py'
- 'tools/usb_install.py'
- 'tools/usb_common.py'
- 'tools/requirements.txt'
- '.github/workflows/python-usb-install.yml'
pull_request:
paths: *python_usb_install_paths
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tools/requirements.txt
- name: Run tests
run: |
python3 tools/tests/test_usb_install.py

55
.github/workflows/webusb-build.yml vendored Normal file
View File

@@ -0,0 +1,55 @@
name: Build and Deploy WebUSB Site
on:
push:
paths:
- 'tools/webusb/**'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install minifiers
run: |
npm install -g html-minifier-terser terser csso-cli
- name: Minify HTML
run: |
html-minifier-terser --collapse-whitespace --remove-comments --minify-css true --minify-js true -o tools/webusb/index.html.min tools/webusb/index.html
- name: Minify JS
run: |
terser tools/webusb/index.js -c -m -o tools/webusb/index.js.min
- name: Minify CSS
run: |
csso tools/webusb/index.css --output tools/webusb/index.css.min
- name: Prepare deploy branch
run: |
rm -rf webusb
mkdir webusb
cp tools/webusb/index.html.min webusb/index.html
cp tools/webusb/index.js.min webusb/index.js
cp tools/webusb/index.css.min webusb/index.css
cp -r tools/webusb/assets webusb/assets
- name: Commit and force-push to webusb branch
run: |
cd webusb
git init
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Deploy minified webusb build"
git branch -M webusb
git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
git push --force origin webusb

5
.gitignore vendored
View File

@@ -25,3 +25,8 @@ compile_commands.json
out
usb_test/
__pycache__
usb_*.spec
CMakeUserPresets.json
build_patreon.sh

View File

@@ -21,19 +21,21 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# enable LTO (only in release builds)
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error)
if (ipo_supported)
message(STATUS "IPO / LTO enabled for ALL targets")
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if (LTO)
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error)
if (ipo_supported)
message(STATUS "IPO / LTO enabled for ALL targets")
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${ipo_error}>")
endif()
else()
message(STATUS "IPO / LTO not supported: <${ipo_error}>")
message(STATUS "IPO / LTO not enabled in debug build")
endif()
else()
message(STATUS "IPO / LTO not enabled in debug build")
endif()
function(dkp_fatal_if_not_found var package)

View File

@@ -16,25 +16,49 @@
"name": "Release",
"displayName": "Release",
"inherits":["core"],
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel",
"LTO": true
}
},
{
"name": "RelWithDebInfo",
"displayName": "RelWithDebInfo",
"name": "Lite",
"displayName": "Lite",
"inherits":["core"],
"cacheVariables": { "CMAKE_BUILD_TYPE":"RelWithDebInfo" }
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel",
"LTO": true,
"ENABLE_NVJPG": false,
"ENABLE_NSZ": false,
"ENABLE_LIBUSBHSFS": false,
"ENABLE_LIBUSBDVD": false,
"ENABLE_FTPSRV": false,
"ENABLE_LIBHAZE": false,
"ENABLE_AUDIO_MP3": false,
"ENABLE_AUDIO_OGG": false,
"ENABLE_AUDIO_WAV": false,
"ENABLE_AUDIO_FLAC": false,
"ENABLE_DEVOPTAB_HTTP": false,
"ENABLE_DEVOPTAB_NFS": false,
"ENABLE_DEVOPTAB_SMB2": false,
"ENABLE_DEVOPTAB_FTP": false,
"ENABLE_DEVOPTAB_SFTP": false,
"ENABLE_DEVOPTAB_WEBDAV": false
}
},
{
"name": "MinSizeRel",
"displayName": "MinSizeRel",
"name": "Dev",
"displayName": "Dev",
"inherits":["core"],
"cacheVariables": { "CMAKE_BUILD_TYPE":"MinSizeRel" }
},
{
"name": "Debug",
"displayName": "Debug",
"inherits":["core"],
"cacheVariables": { "CMAKE_BUILD_TYPE":"Debug" }
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel",
"LTO": false,
"DEV_BUILD": true
}
}
],
"buildPresets": [
@@ -44,18 +68,13 @@
"jobs": 16
},
{
"name": "RelWithDebInfo",
"configurePreset": "RelWithDebInfo",
"name": "Lite",
"configurePreset": "Lite",
"jobs": 16
},
{
"name": "MinSizeRel",
"configurePreset": "MinSizeRel",
"jobs": 16
},
{
"name": "Debug",
"configurePreset": "Debug",
"name": "Dev",
"configurePreset": "Dev",
"jobs": 16
}
]

View File

@@ -98,7 +98,7 @@ The output will be found in `build/MinSizeRel/sphaira.nro`
- [hb-appstore](https://github.com/fortheusers/hb-appstore)
- [haze](https://github.com/Atmosphere-NX/Atmosphere/tree/master/troposphere/haze)
- [nxdumptool](https://github.com/DarkMatterCore/nxdumptool) (for gamecard bin dumping and rsa verify code)
- [Liam0](switch-010editor-templates) (for ticket / cert structs)
- [Liam0](https://github.com/ThatNerdyPikachu/switch-010editor-templates) (for ticket / cert structs)
- [libusbhsfs](https://github.com/DarkMatterCore/libusbhsfs)
- [libnxtc](https://github.com/DarkMatterCore/libnxtc)
- [oss-nvjpg](https://github.com/averne/oss-nvjpg)

View File

@@ -1,8 +0,0 @@
{
"url": "https://github.com/ITotalJustice/ftpsrv",
"assets": [
{
"name": "switch"
}
]
}

View File

@@ -1,3 +0,0 @@
{
"url": "https://github.com/ITotalJustice/untitled"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,918 @@
{
"Homebrew": "自制软件",
"FileBrowser": "文件浏览器",
"Appstore": "应用商店",
"Corrupted": "已损坏",
"enable_install_info": [
"安装功能已禁用.\n",
"可以通过选择 菜单 (Y) -> 高级选项 -> 安装选项 -> 启用"
],
"On": "开启",
"Off": "关闭",
"Entry": "条目",
"Store": "商店",
"File": "文件",
"Files": "文件",
"FTP": "FTP",
"Games": "游戏",
"Meta": "元数据",
"Nca": "NCA",
"GC": "GC",
"GitHub": "GitHub",
"Apps": "应用",
"IRS": "IRS",
"MTP": "MTP",
"Saves": "存档",
"USB": "USB",
"Level 0 (no compression)": "",
"Level 1": "",
"Level 2": "",
"Level 3 (default)": "",
"Level 4": "",
"Level 5": "",
"Level 6": "",
"Level 7": "",
"Level 8": "",
"0 (single threaded)": "",
"1": "",
"2": "",
"3 (default)": "",
"4": "",
"16 KB": "",
"32 KB": "",
"64 KB": "",
"128 KB": "",
"256 KB": "",
"512 KB": "",
"1 MB (default)": "",
"2 MB": "",
"4 MB": "",
"8 MB": "",
"16 MB": "",
"Switch-Handheld!": "切换至掌机模式!",
"Switch-Docked!": "切换至底座模式!",
"Nxlink Connected": "Nxlink已连接",
"Nxlink Upload": "Nxlink上传中",
"Nxlink Finished": "Nxlink已结束",
"Restore hbmenu?": "恢复 hbmenu",
"Back": "返回",
"Restore": "恢复",
"missing_hbmenu_info": [
"未找到 /switch/hbmenu.nro",
"请使用应用商店重新安装 hbmenu"
],
"OK": "确定",
"Failed to restore hbmenu, please re-download hbmenu": "恢复 hbmenu 失败,请重新下载 hbmenu",
"Failed to restore hbmenu, using sphaira instead": "恢复 hbmenu 失败,改用 Sphaira",
"Restored hbmenu, closing sphaira": "已恢复 hbmenu正在关闭 Sphaira",
"Restored hbmenu": "已恢复 hbmenu",
"Restart Sphaira?": "重启 Sphaira",
"Restart": "重启",
"Installing Forwarder": "正在生成前端应用",
"Failed to install forwarder": "前端应用安装失败",
"Installed!": "安装完成!",
"Warning! Logs are enabled, Sphaira will run slowly!": "警告日志已启用将导致Sphaira运行缓慢",
"Audio disabled due to suspended game": "由于游戏暂停,音频已禁用",
"Theme Options": "主题选项",
"Select Theme": "选择主题",
"Customise the look of Sphaira by changing the theme": "通过更换主题来自定义Sphaira的外观",
"Music": "音乐",
"bgm_enable_info": [
"启用背景音乐\n",
"每个主题设置独立的音乐文件。",
"如果主题未设置音乐文件,则加载默认音乐(如果存在)。"
],
"Show IP address": "显示 IP 地址",
"display_ip_info": [
"在所有菜单中显示IP地址包括WiFi信号栏。\n",
"注意在小程序模式下IP地址将被隐藏因为小程序警告会显示在其位置。"
],
"Remove Background Music": "移除背景音乐",
"Removes the background music file": "删除背景音乐文件",
"No background music file is set": "未设置背景音乐文件",
"Menus": "菜单",
"Web": "网络",
"Enter custom URL": "输入自定义链接",
"Select URL": "选择链接",
"Enter URL": "输入网址",
"web_browser_info": [
"启动内置浏览器\n",
"注意浏览器功能受限某些网站可能无法加载并且浏览器会在30分钟超时后关闭"
],
"Advanced Options": "高级选项",
"Slow": "慢",
"Normal": "正常",
"Fast": "快",
"Logging": "日志",
"Logs to /config/sphaira/log.txt": "日志输出到 /config/sphaira/log.txt",
"Replace hbmenu on exit": "退出后用Sphaira替换hbmenu",
"hbmenu_replace_info": [
"启用后,将用 Sphaira 替换 /hbmenu.nro并将 hbmenu 备份到 /switch/hbmenu.nro \n",
"禁用后将为您提供还原 hbmenu 的选项。"
],
"Add / modify mounts": "添加/修改挂载点",
"mount_options_info": [
"创建、修改、删除网络挂载 (HTTP, FTP, SFTP, SMB, NFS)\n",
"挂载选项只需要设置 URL 和名称,其他字段(如端口、用户、密码等)为可选\n",
"任何更改都需要重启 Sphaira 后生效"
],
"Boost CPU during transfer": "传输时提升CPU频率",
"transfer_boost_info": [
"在传输期间启用加速模式,可提高传输速度。 ",
"这会将 CPU 设置为 1785MHz并将 GPU 降至 76MHz"
],
"Text scroll speed": "文本滚动速度",
"Change how fast the scrolling text updates": "更改滚动文本的更新速度",
"Set center menu": "设置中间菜单",
"Press OK to restart Sphaira": "按OK键以重启shphaira菜单",
"Set the menu that appears on the center tab.": "设置显示在中间选项卡上的菜单。",
"Set left-side menu": "设置左侧菜单",
"Set the menu that appears on the left tab.": "设置显示在左侧选项卡上的菜单。",
"Set right-side menu": "设置右侧菜单",
"Set the menu that appears on the right tab.": "设置显示在右侧选项卡上的菜单。",
"Install options": "安装选项",
"install_options_info": [
"更改安装选项。\n",
"您可以在此启用安装功能"
],
"Export options": "导出选项",
"Change the export options.": "更改导出选项。",
"Install Options": "安装选项",
"System memory": "主机内存",
"microSD card": "SD卡",
"Enable sysmmc": "启用sysmmc",
"Enables installing whilst in sysMMC mode.": "允许在 sysMMC 模式下安装。",
"Enable emummc": "启用emummc",
"Enables installing whilst in emuMMC mode.": "允许在 emuMMC 模式下安装。",
"Install location": "安装位置",
"Allow downgrade": "允许降级",
"Allows for installing title updates that are lower than the currently installed update.": "允许安装低于当前已安装版本的游戏更新。",
"Skip if already installed": "若已安装则跳过",
"Skips installing titles / ncas if they're already installed.": "跳过已安装的游戏/NCA",
"Ticket only": "仅安装票据",
"Installs tickets only, useful if the title was already installed however the tickets were missing or corrupted.": "仅安装 tickets, 适用于已安装但损坏的游戏",
"Skip base": "跳过基础部分",
"Skips installing the base application.": "跳过安装基础应用程序。",
"Skip patch": "跳过更新补丁(UPD)",
"Skips installing updates.": "跳过安装更新。",
"Skip dlc": "跳过追加内容(DLC)",
"Skips installing DLC.": "跳过安装 DLC。",
"Skip data patch": "跳过数据补丁",
"Skips installing DLC update (data patch).": "跳过安装 DLC 更新(数据补丁)。",
"Skip ticket": "跳过票据",
"Skips installing tickets, not recommended.": "跳过安装票据,不推荐。",
"Skip NCA hash verify": "跳过 NCA 哈希验证",
"skip_nca_info": [
"启用跳过完整 NCA 的 sha256 验证。",
"用于验证 NCA 是否有效/未损坏。",
"当安装损坏的游戏时,您可能看到过\"检查损坏数据\"的选项",
"该检查会执行包括对 NCA 在内的各种哈希校验\n",
"建议保持禁用状态。"
],
"Skip RSA header verify": "跳过 RSA 头部验证",
"nca_verify_info": [
"启用跳过 RSA NCA固定密钥验证。",
"这是对NCA头的哈希值。它用于验证头部是否未被修改。 ",
"头部由任天堂签名因此无法伪造可以可靠地检测修改过的NCA头如NSP/XCI转换。\n",
"建议保持禁用状态除非您需要安装nsp/xci转换文件。"
],
"Skip RSA NPDM verify": "跳过 RSA NPDM 验证",
"npdm_verify_info": [
"启用跳过RSA NPDM固定密钥验证\n",
"目前此选项未实现。"
],
"Ignore distribution bit": "忽略发行位",
"nca_distbit_info": [
"如果设置,将忽略 NCA 头部中的发行位",
"发行位用于标识NCA是来自Eshop还是游戏卡。",
"您通常无法启动将发行位设置为游戏卡的已安装游戏。\n",
"建议保持禁用状态。"
],
"Convert to common ticket": "转换为公共票据",
"ticket_convert_info": [
"[需要密钥] 将个人票据转换为公共(虚拟)票据。\n",
"建议保持启用状态。"
],
"Convert to standard crypto": "转换为标准加密方式",
"titlekey_crypto_info": [
"[需要密钥] 将标题密钥转换为标准加密,也称为\"无票据\"。\n",
"建议保持禁用状态。"
],
"Lower master key": "降低主密钥",
"keyarea_crypto_info": [
"[需要密钥] 使用主密钥0加密keak密钥区域密钥允许游戏在任何固件上启动。 ",
"隐式执行标准加密。\n",
"请注意仅仅因为游戏可以在任何固件上启动因为它可以被解密并不意味着它就能正常工作。强烈建议更新您的固件和Atmosphere版本以玩游戏而不是启用此选项。\n",
"建议保持禁用状态。"
],
"Lower system version": "降低系统版本",
"cnmt_fw_info": [
"将cnmt扩展头中的system_firmware字段设置为0。",
"注意如果主密钥高于固件版本游戏仍然无法启动因为固件没有解密keak的密钥见上文。\n",
"建议保持禁用状态。"
],
"Export Options": "导出选项",
"Created nested folder": "已创建嵌套文件夹",
"game_folder_info": [
"使用游戏名称创建文件夹。\n",
"例如:/name/name.xci",
"禁用后将使用 /name.xci"
],
"Append folder with .xci": "用.xci附加文件夹",
"xci_folder_info": [
"XCI转储将使用.xci扩展名命名文件夹。\n",
"例如:/name.xci/name.xci\n",
"某些设备仅在xci文件夹名称与xci文件完全相同时才能正常工作。"
],
"Trim XCI": "裁剪 XCI",
"Removes the unused data at the end of the XCI, making the output smaller.": "移除 XCI 末尾未使用的数据,使输出更小。",
"Label trimmed XCI": "标记已裁剪的XCI",
"Names the trimmed xci.\nFor example, /name/name (trimmed).xci": "为修剪后的xci命名。\n例如/name/name (trimmed).xci",
"Converts personalised ticket to a fake common ticket.": "将个人票据转换为虚拟公共票据。",
"NSZ level": "NSZ 压缩级别",
"compress_level_info": [
"设置导出NSZ时使用的压缩级别。\n",
"注意Switch的CPU速度不是很快将值设置得过高会导致导出耗时非常长但文件大小仅有很小的改善。\n",
"建议将此值设置为3。"
],
"NSZ threads": "NSZ 线程数",
"compress_threads_info": [
"设置压缩NCA时使用的线程数。\n",
"小于3的值允许另一个线程自由运行例如读/写线程。但在我的测试中值为3时通常性能最佳。\n",
"值为0将不使用线程仅应用于测试因为它总是更慢。\n",
"建议将此值设置在1-3之间。"
],
"NSZ long distance mode": "NSZ 远距离模式",
"Enables \"Long Distance Mode\" which can reduce the output size at the cost of speed.": "启用\"远距离模式\",可以减少输出大小,但会降低速度。",
"NSZ block compression": "NSZ 块压缩",
"block_compress_info": [
"启用块压缩将NCA压缩成块代价是压缩率降低 ",
"允许随机访问使NCZ可以作为文件系统挂载。\n",
"注意Sphaira目前还不支持将NCZ作为文件系统挂载但最终会添加此功能。"
],
"NSZ block size": "NSZ 块大小",
"Sets the size of each block. The smaller the size, the faster the random access is at the cost of compression ratio.": "设置每个块的大小。块越小,随机访问速度越快,但压缩率会降低。",
"NSZ block compression is disabled.": "NSZ 块压缩已禁用。",
"FTP Options": "FTP选项",
"Restarting FTP server...": "正在重启 FTP 服务器...",
"Enable": "启用",
"Enable FTP server to run in the background.": "启用 FTP 服务器后台运行。",
"Port": "端口号",
"Opens the FTP server on this port.": "在此端口上打开 FTP 服务器。",
"Anon": "匿名登录",
"login_require_info": [
"允许您无需设置用户名和密码即可登录。\n",
"如果禁用,您必须在下方设置用户名和密码!"
],
"User": "用户",
"Sets the username, must be set if anon is disabled.": "设置用户名,如果禁用匿名登录则必须设置。",
"Pass": "密码",
"Sets the password, must be set if anon is disabled.": "设置密码,如果禁用匿名登录则必须设置。",
"Show album": "显示相册",
"Shows the microSD card album folder.": "显示 microSD 卡的相册文件夹。",
"Show Atmosphere contents": "显示 Atmosphere 内容",
"Shows the shortcut for the /atmosphere/contents folder.": "显示 /atmosphere/contents 文件夹的快捷方式。",
"Show bis storage": "显示 bis 存储",
"bis_contents_info": [
"显示包含以下文件的bis文件夹:",
"- BootPartition1Root.bin",
"- BootPartition2Root.bin",
"- UserDataRoot.bin",
"- BootConfigAndPackage2Part1.bin",
"- BootConfigAndPackage2Part2.bin",
"- BootConfigAndPackage2Part3.bin",
"- BootConfigAndPackage2Part4.bin",
"- BootConfigAndPackage2Part5.bin",
"- BootConfigAndPackage2Part6.bin",
"- CalibrationFile.bin",
"- SafeMode.bin",
"- User.bin",
"- System.bin",
"- SystemProperEncryption.bin"
],
"Show bis file systems": "显示 bis 文件系统",
"bis_fs_info": [
"显示以下bis文件系统:",
"- bis_calibration_file",
"- bis_safe_mode",
"- bis_user",
"- bis_system"
],
"Show system contents": "显示系统内容",
"Shows the system contents folder.": "显示系统内容文件夹。",
"Show user contents": "显示用户内容",
"Shows the user contents folder.": "显示用户内容文件夹。",
"Show microSD contents": "显示 microSD 卡内容",
"microsd_contents_info": [
"显示microSD contents文件夹。\n",
"注意这不是普通的microSD卡存储而是NCA存储的位置。",
"普通microSD卡始终是挂载的。"
],
"Show games": "显示游戏",
"games_ftp_info": [
"显示games文件夹。\n",
"此文件夹包含您所有已安装的游戏允许您通过FTP创建备份\n",
"注意此文件夹是只读的。您无法通过FTP删除游戏。"
],
"Show install": "显示安装文件夹",
"install_ftp_info": [
"显示install文件夹。\n",
"此文件夹用于通过FTP安装游戏。\n",
"注意:尝试安装游戏时必须打开\"FTP安装\"菜单!"
],
"Show mounts": "显示挂载点",
"mounts_ftp_info": [
"显示mounts文件夹。\n",
"此文件夹包含添加到Sphaira的所有挂载点允许您通过FTP访问它们",
"例如您可以通过FTP访问SMB、WebDav或其他FTP挂载点。"
],
"Show switch": "显示 Switch 目录",
"homebrew_folder_info": [
"显示/switch文件夹的快捷方式。",
"这是包含所有自制软件NRO的文件夹。"
],
"MTP Options": "MTP选项",
"Restarting MTP server...": "正在重启 MTP 服务器...",
"Enable MTP server to run in the background.": "启用 MTP 服务器后台运行。",
"Pre-allocate file": "预分配文件",
"prealloc_info": [
"在写入前启用文件大小预分配。",
"这会加快文件写入速度,但如果同时满足以下所有条件,可能会导致超时:",
"- 使用 Windows 系统",
"- 使用 emuMMC",
"- 传输大文件(>1GB\n",
"建议保持此选项启用,但如果您使用上述配置并遇到超时, ",
"请在禁用此选项后重试。"
],
"games_mtp_info": [
"显示games文件夹。\n",
"此文件夹包含您所有已安装的游戏允许您通过MTP创建备份\n",
"注意此文件夹是只读的。您无法通过MTP删除游戏。"
],
"install_mtp_info": [
"显示install文件夹。\n",
"此文件夹用于通过MTP安装游戏。\n",
"注意:尝试安装游戏时必须打开\"MTP安装\"菜单!"
],
"mounts_mtp_info": [
"显示mounts文件夹。\n",
"此文件夹包含添加到Sphaira的所有挂载点允许您通过MTP访问它们",
"例如您可以通过MTP访问SMB、WebDav和FTP挂载点。"
],
"Show DevNull": "显示 DevNull",
"usb_benchmark_info": [
"显示DevNull速度测试文件夹。\n",
"此文件夹用于USB上传的基准测试。",
"这是一个虚拟文件夹,实际上不会向磁盘写入任何内容。"
],
"HDD Options": "硬盘选项",
"mount_hdd_info": [
"启用已连接的USB/HDD设备挂载。 ",
"已连接的设备可在文件浏览器中使用,也可作为转储游戏和存档时的备份位置。"
],
"HDD write protect": "硬盘写保护",
"Makes the connected HDD read-only.": "将已连接的硬盘设置为只读。",
"Installing is disabled, enable now?": "安装功能已禁用,现在启用吗?",
"WARNING: Installing apps will lead to a ban!": "警告:安装应用程序将导致封禁!",
"Installing enabled!": "已启用安装!",
"microSD card (/dumps/)": "",
"USB export to PC (usb_export.py)": "",
"USB transfer (Switch 2 Switch)": "USB传输Switch对Switch",
"/dev/null (Speed Test)": "/dev/null速度测试",
"Waiting for USB connection...": "",
"USB connected, sending file list": "USB已连接正在发送文件列表",
"Sent file list, waiting for command...": "已发送文件列表,正在等待命令...",
"waiting for usb connection...": "等待USB连接...",
"Exporting": "正在导出",
"Export failed!": "导出失败!",
"Export successfull!": "导出成功!",
"Select export location": "选择导出位置",
"Please launch MTP install menu before trying to install": "请在尝试安装前启动 MTP 安装菜单",
"Album": "专辑",
"Install (NSP, XCI, NSZ, XCZ)": "安装 (NSP, XCI, NSZ, XCZ)",
" (Read Only)": " (只读)",
"Unknown": "未知",
"Application": "",
"Creating Program": "正在创建程序",
"Creating Control": "正在创建控制器",
"Creating Meta": "正在创建元数据",
"Writing Nca": "正在写入Nca",
"Updating ncm database": "正在更新ncm数据库",
"Pushing application record": "正在推送应用记录",
"Failed to remove old forwarder, please manually remove it!": "删除旧前端应用失败,请手动删除!",
"An error occurred": "发生错误",
"If this message appears repeatedly, please open an issue.": "若此消息反复出现,请提交问题报告。",
"Failed to load music": "音乐加载失败",
"Artist: Unknown": "艺术家: 未知",
"Album: Unknown": "专辑: 未知",
"Select": "选择",
"Are you sure you wish to cancel?": "您确定要取消吗?",
"No": "否",
"Yes": "是",
"%zu hours %zu minutes remaining": "剩余 %zu 小时 %zu 分钟",
"%zu minutes %zu seconds remaining": "剩余 %zu 分钟 %zu 秒",
"%zu seconds remaining": "剩余 %zu 秒",
"Closing empty sidebar": "关闭空侧边栏",
"All": "全部",
"Emulators": "模拟器",
"Tools": "工具",
"Advanced": "高级",
"Themes": "主题",
"Legacy": "旧版",
"Misc": "拓展",
"Updated": "最近使用",
"Downloads": "下载",
"Size": "按大小",
"Alphabetical": "按字母顺序",
"Desc": "降序",
"Asc": "升序",
"Removing ": "正在移除 ",
"Downloading ": "正在下载 ",
"Checking MD5": "正在校验 MD5",
"Options": "选项",
"More by Author": "作者更多作品",
"Leave Feedback": "留言反馈",
"Visit Website": "访问网站",
"version: %s": "版本: %s",
"updated: %s": "更新时间: %s",
"category: %s": "分类: %s",
"extracted: %s": "已解压:%s",
"app_dls: %s": "下载量: %s",
"Loading...": "加载中...",
"Failed to download manifest": "下载清单失败",
"Details": "详情",
"Changelog": "更新日志",
"Downloaded ": "已下载 ",
"Uninstalling ": "正在卸载 ",
"Removed ": "已移除 ",
"Install": "安装",
"Update": "更新",
"Launch": "启动",
"Remove": "删除",
"Completely remove ": "彻底删除 ",
"AppStore": "应用商店",
"Info": "信息",
"AppStore Options": "应用商店选项",
"Descending": "降序",
"Ascending": "升序",
"List": "列表",
"Icon": "图标",
"Grid": "网格",
"Filter": "筛选",
"Sort": "排序",
"Order": "顺序",
"Layout": "布局",
"Search": "搜索",
"Empty!": "空空如也!",
"Filter: %s | Sort: %s | Order: %s": "筛选: %s | 排序: %s | 顺序: %s",
"File Picker": "文件选择器",
"Failed to parse nro": "解析 nro 失败",
"Name": "名称",
"Set the name of the application": "设置应用程序的名称",
"Author": "作者",
"Set the author of the application": "设置应用程序的作者",
"Version": "版本",
"Set the display version of the application": "设置应用程序的显示版本",
"Set the path to the icon for the forwarder": "设置前端启动器图标的路径",
"Create": "创建",
"Failed to load icon": "加载图标失败",
"Create the forwarder.": "创建前端启动器。",
"All fields must be non-empty!": "所有字段不能为空!",
"Open": "打开",
"Empty...": "空...",
"%zd files": "%zd 个文件",
"%zd dirs": "%zd 个文件夹",
"Open with DayBreak?": "使用DayBreak打开",
"Launch ": "启动 ",
"Launch option for: ": "启动选项:",
"Select launcher for: ": "选择启动器用于:",
"Install Selected files?": "安装所选文件?",
"Installing ": "正在安装 ",
"Installed ": "已安装",
"File install failed!": "文件安装失败!",
"Extracting ": "正在解压",
"Extract failed!": "解压失败!",
"Extract success!": "解压成功!",
"Compressing ": "正在压缩 ",
"Compress failed!": "压缩失败",
"Compress success!": "压缩成功!",
"Failed to delete directory": "删除目录失败",
"Failed to delete file": "删除文件失败",
"Deleting": "正在删除",
"Scanning ": "正在扫描 ",
"Pasting": "正在粘贴",
"Pasting ": "正在粘贴 ",
"Creating ": "正在创建 ",
"Copying ": "正在复制 ",
"Deleting ": "正在删除 ",
"Hashing": "正在计算文件哈希",
"Failed to hash file...": "计算文件哈希失败...",
"File Options": "文件选项",
"Mount": "挂载",
"Sort By": "排序方式",
"Sort Options": "排序选项",
"Show Hidden": "显示隐藏项目",
"Folders First": "文件夹靠前",
"Hidden Last": "隐藏项目置后",
"Cut": "剪切",
"Copy": "复制",
"Paste": "粘贴",
"Paste file(s)?": "粘贴 个文件(夹)",
"Rename": "重命名",
"Set new name": "设置新名称",
"Failed to rename file: ": "重命名文件失败: ",
"Delete": "删除",
"Delete Selected files?": "删除选中的文件?",
"Install Forwarder": "安装前端应用",
"Extract zip": "解压 zip",
"Extract Options": "解压选项",
"Extract here": "解压到这里",
"Extract to root": "解压到根目录",
"Are you sure you want to extract to root?": "您确定要解压到根目录吗?",
"Extract to...": "解压到...",
"Enter the path to the folder to extract into": "输入要解压到的文件夹的路径",
"Compress to zip": "压缩到zip",
"Compress Options": "压缩选项",
"Compress": "压缩",
"Compress to...": "压缩到...",
"Enter the path to the folder to compress into": "输入要压缩的文件夹路径",
"Create File": "新建文件",
"Set File Name": "输入文件名",
"Create Folder": "新建文件夹",
"Set Folder Name": "输入文件夹名",
"View as text (unfinished)": "以文本形式查看(未完善)",
"Set as background music": "设置为背景音乐",
"Failed to set default music path": "设置默认音乐路径失败",
"Hash": "哈希",
"Hash Options": "哈希选项",
"Ignore read only": "忽略只读",
"Failed to mount FS.": "文件系统挂载失败。",
"Close FileBrowser?": "是否关闭文件浏览器?",
"Split": "拆分",
"Close": "关闭",
"FTP Install": "通过 FTP 安装",
"Connection Type: WiFi | Strength: ": "连接类型WiFi |强度:",
"Connection Type: Ethernet": "连接类型:以太网",
"Connection Type: None": "连接类型:无",
"Host:": "主机:",
"Port:": "端口:",
"Username:": "用户名:",
"Password:": "密码:",
"SSID:": "网络名称:",
"Passphrase:": "密码:",
"Success": "成功",
"Failed to launch application": "",
"Game Options": "游戏选项",
"Hide forwarders": "隐藏前端启动",
"View application content": "查看应用程序内容",
"Launch random game": "启动随机游戏",
"Export NSP": "导出 NSP",
"Not supported in Applet Mode": "小程序模式不支持",
"Export NSZ": "导出 NSZ",
"Exports to NSZ (compressed NSP)": "导出为 NSZ压缩的 NSP",
"Are you sure you want to delete ": "您确定要删除吗 ",
"Advanced options": "高级选项",
"Refresh": "刷新",
"Create contents folder": "创建内容文件夹",
"Folder create failed!": "文件夹创建失败!",
"Folder created!": "文件夹创建成功!",
"Create save": "创建存档",
"Select user to create save for": "选择要为其创建存档的用户",
"Delete title cache": "删除游戏缓存",
"Are you sure you want to delete the title cache?": "您确定要删除标题缓存吗?",
"Updating application record list": "更新应用程序记录列表",
"Delete failed!": "删除失败!",
"Delete successfull!": "删除成功!",
"Select content to export": "选择要导出的内容",
"Export All": "导出全部",
"Export Application": "导出应用程序",
"Export Patch": "导出补丁",
"Export AddOnContent": "导出追加内容(DLC)",
"Export DataPatch": "导出数据补丁",
"Creating": "正在创建",
"Save create failed!": "存档创建失败!",
"Save create successfull!": "存档创建成功!",
"Failed to delete meta entry": "删除元数据失败",
"None": "无",
"Common": "公共",
"Personalised": "个性化",
"Missing": "丢失",
"View Content": "查看内容",
"Content Options": "内容选项",
"Are you sure you want to delete the selected entries?": "您确定要删除选定的条目吗?",
"Reset required system version": "重置所需系统版本",
"Are you sure you want to reset required system version?": "您确定要重置所需的系统版本吗?",
"Reset": "重置",
"Failed to reset required system version": "重置所需系统版本失败",
"Required System Version: %u.%u.%u": "",
"Required Application Version: v%u": "",
"Content Count: %u (%u missing)": "",
"Content Count: %u": "",
"Ticket: %s": "",
"Key Generation: %u (%s)": "",
"Display Version: %s": "",
"Mount Fs": "挂载文件系统",
"Failed to mount NCA": "NCA 挂载失败",
"NCA Options": "NCA选项",
"Export NCA": "导出NCA",
"Export NCA decrypted": "导出已解密的 NCA",
"Exports the NCA with all fs sections decrypted (NCA header is still encrypted).": "导出所有文件系统分区已解密的 NCANCA 头仍为加密)。",
"Verify NCA 256 hash": "验证 NCA 256 哈希",
"NCA hash missmatch!": "NCA 哈希值不匹配!",
"NCA hash valid.": "NCA 哈希值有效。",
"nca_validate_info": [
"对NCA执行sha256哈希以检查其是否有效。\n",
"注意:这仅检测哈希是否不匹配,并不验证内容是否已被修改。"
],
"Verify NCA fixed key": "验证NCA固定密钥",
"NCA fixed key is invalid!": "NCA固定密钥无效",
"NCA fixed key is valid.": "NCA固定密钥有效。",
"nca_fixedkey_info": [
"执行RSA NCA固定密钥验证。",
"这是对NCA头部的哈希值。它用于验证头部是否未被修改。 ",
"头部由任天堂签名因此无法伪造可以可靠地检测修改过的NCA头如NSP/XCI转换。"
],
"Failed to decrypt NCA": "解密 NCA 失败",
"Application Type: %s": "",
"Content Type: %s": "",
"Distribution Type: %s": "",
"Program ID: %016lX": "",
"SDK Version: %u.%u.%u.%u": "",
"Export XCI (Gamecard)": "",
"Export XCZ (Compressed XCI)": "",
"GameCard": "游戏卡",
"Gc install failed!": "游戏安装失败。",
"Gc install success!": "游戏安装成功。",
"Select content to dump": "选择要转储的内容",
"Export All Bins": "导出所有 Bin 文件",
"Export XCI": "导出 XCI",
"Export Card ID Set": "导出游戏卡ID集",
"Export Card UID": "导出游戏卡UID",
"Export Certificate": "导出证书",
"Export Initial Data": "导出初始数据",
"Failed to mount GameCard filesystem": "游戏卡文件系统挂载失败",
"System memory %.1f GB": "主机内存 %.1f GB",
"microSD card %.1f GB": "microSD卡 %.1f GB",
"App-ID: 0%lX": "",
"Key-Gen: %u (%s)": "",
"Size: %.2f GB": "",
"Base: %zu Patch: %zu Addon: %zu Data: %zu": "",
"Prev": "上一项",
"Next": "下一项",
"No GameCard inserted": "未插入游戏卡",
"WARNING: GameCard is already trimmed!": "警告:游戏卡已被修剪!",
"Continue": "继续",
"GameCard is trimmed, full dump is not possible!": "游戏卡已被裁剪,无法进行完整转储!",
"Downloading json": "正在下载JSON",
"Download": "下载",
"Failed to download json": "下载JSON失败",
"Select release to download for ": "选择要下载的版本:",
"Select asset to download for ": "选择要下载的资源:",
"Failed to download app!": "下载应用失败!",
"Unstar": "取消星标",
"Unstarred ": "取消星标 ",
"Star": "星标",
"Starred ": "已星标 ",
"Homebrew Options": "自制软件选项",
"Updated (Star)": "最近更新(星标优先)",
"Alphabetical (Star)": "按字母顺序(星标优先)",
"Size (Star)": "按大小(星标优先)",
"Display entries in Ascending or Descending order.": "以升序或降序显示条目。",
"Change the layout to List, Icon and Grid.": "切换布局:列表、图标和网格。",
"Show hidden": "显示隐藏项目",
"Shows all hidden homebrew.": "显示所有隐藏的自制软件。",
"Test": "测试",
"Hide": "隐藏",
"Hides the selected homebrew.\nTo unhide homebrew, enable \"Show hidden\" in the sort options.": "隐藏所选自制软件。\n要取消隐藏自制软件请在排序选项中启用\"显示隐藏项目\"。",
"Mount NRO Fs": "挂载 NRO 文件系统",
"Failed to mount NRO FileSystem": "NRO 文件系统挂载失败",
"Mounts the NRO FileSystem (icon, nacp and RomFS).": "挂载 NRO 文件系统图标、nacp 和 RomFS。",
"hb_remove_info": [
"永久删除所选自制软件。\n",
"自制软件创建的文件和文件夹仍将保留。 ",
"请使用文件浏览器删除它们。"
],
"Failed to load image": "图片加载失败",
"Install failed!": "通过 FTP 安装失败。",
"Install success!": "通过 FTP 安装成功。",
"Drag'n'Drop (NSP, XCI, NSZ, XCZ) to the install folder": "拖放文件(NSP, XCI, NSZ, XCZ)至安装文件夹",
"Failed to install, press B to exit...": "通过 FTP 安装失败,按 B 键退出...",
"Irs": "红外成像",
"0 (Sideways)": "0度",
"90 (Flat)": "90度",
"180 (-Sideways)": "180度",
"270 (Upside down)": "270度",
"Grey": "灰色",
"Ironbow": "紫黄",
"Green": "绿色",
"Red": "红色",
"Blue": "蓝色",
"All leds": "全部",
"Bright group": "亮色组",
"Dim group": "暗色组",
"Normal image": "正常图像",
"Negative image": "负片图像",
"Controller": "控制器",
"Rotation": "旋转",
"Colour": "颜色",
"Light Target": "光源目标",
"Gain": "曝光",
"Negative Image": "负片图像",
"Format": "格式",
"Trimming Format": "修剪格式",
"External Light Filter": "外部光滤镜",
"Load Default": "加载默认值",
"Ambient Noise Level: ": "环境噪声等级:",
"Pad ": "手柄 ",
"HandHeld": "掌机模式",
" (Available)": " (可用)",
" (Unsupported)": " (不支持)",
" (Unconnected)": " (未连接)",
"The homebrew menu.\n\nAllows you to launch, delete and mount homebrew!": "自制软件菜单。\n\n允许您启动、删除和挂载自制软件",
"Download and update apps.\n\nInternet connection required.": "下载和更新应用。\n\n需要互联网连接。",
"View all installed games. In this menu you can launch, backup, create savedata and much more.": "查看所有已安装的游戏。在此菜单中,您可以启动、备份、创建存档等操作。",
"Browse files on you SD Card. You can move, copy, delete, extract zip, create zip, upload and much more.\n\nA connected USB/HDD can be opened by mounting it in the advanced options.": "浏览您的SD卡文件。您可以移动、复制、删除、解压zip、创建zip、上传等更多操作。\n\n连接的USB/HDD可以通过在高级选项中挂载来打开。",
"View save data for each user. You can backup and restore saves.\n\nExperimental support for backing up system saves is possible.": "查看每个用户的存档数据。您可以备份和还原存档。\n\n可能支持备份系统存档实验性功能。",
"Download releases directly from GitHub. Custom entries can be added to /config/sphaira/github": "直接从GitHub下载发布版本。自定义条目可以添加到 /config/sphaira/github",
"Install apps via FTP.": "通过FTP安装应用。",
"MTP Install": "MTP安装",
"Install apps via MTP.": "通过MTP安装应用。",
"USB Install": "通过 USB 安装",
"Install apps via USB.\n\nA USB client is required on PC.": "通过USB安装应用。\n\n需要在PC上安装USB客户端。",
"View info on the inserted Game Card (GC). You can backup and install the inserted GC. To swap GC's, simply remove the old GC and insert the new one. You do not need to exit the menu.": "查看已插入游戏卡GC的信息。您可以备份和安装已插入的游戏卡。要更换游戏卡只需取出旧游戏卡并插入新的。无需退出菜单。",
"IRS (Infrared Joycon Camera)": "IRS(Joycon红外摄像头)",
"InfraRed Sensor (IRS) is the small camera found on right JoyCon.": "红外传感器IRS是右侧JoyCon上的小型摄像头。",
"Update avaliable: ": "有可用更新!",
"Download via the Network options!": "通过网络选项下载!",
"Menu": "菜单",
"Menu Options": "菜单选项",
"Auto": "自动",
"English": "English",
"Japanese": "日本語",
"French": "Français",
"German": "Deutsch",
"Italian": "Italiano",
"Spanish": "Español",
"Chinese (Simplified)": "简体中文",
"Korean": "한국어",
"Dutch": "Dutch",
"Portuguese": "Português",
"Russian": "Русский",
"Chinese (Traditional)": "繁體中文",
"Swedish": "Svenska",
"Vietnamese": "Vietnamese",
"Ukrainian": "Українська",
"Launch one of Sphaira's menus:\n": "启动Sphaira的一个菜单\n",
"\nYou can change the left/right menu in the Advanced Options.": "\n您可以在高级选项中更改左/右菜单。",
"Network": "网络",
"Network Options": "网络选项",
"Download update: ": "下载更新:",
"Failed to download update": "更新下载失败",
"Updated to ": "更新至 ",
"ftp_settings_info": [
"启用/修改FTP服务器设置如端口、用户/密码以及显示的文件夹。\n",
"注意更改任何选项将在退出选项菜单时自动重启FTP服务器。"
],
"mtp_settings_info": [
"启用/修改MTP响应器设置如显示的文件夹。\n",
"注意更改任何选项将在退出选项菜单时自动重启MTP服务器。"
],
"HDD": "硬盘",
"Enable / modify the HDD mount options.": "启用/修改 HDD 挂载选项。",
"NXlink": "NXlink",
"nxlink_enable_info": [
"启用NXlink服务器后台运行",
"NXlink用于从DC向Switch发送.nro文件\n",
"如果您不是开发者,可以禁用此选项。"
],
"nxlink_toggle_info": [
"切换FTP、MTP、HDD和NXlink\n",
"如果Sphaira有可用更新您可以从此菜单下载"
],
"Theme": "主题",
"Language": "语言",
"translation_info": [
"更改语言\n",
"如果找不到您的语言或翻译缺失,请考虑在 github.com/ITotalJustice/sphaira 提交PR"
],
"advanced_options_info": [
"更改高级选项。",
"请查看信息框以更好地理解每个选项。"
],
"System %.1f GB": "系统 %.1f GB",
"microSD %.1f GB": "microSD %.1f GB",
"[Applet Mode]": "[小程序模式]",
"Ethernet": "以太网",
"No Internet": "网络未连接",
"State: %s | Speed: %s": "状态: %s | 速度: %s",
"Failed to mount save filesystem": "存档文件系统挂载失败",
"Save Options": "存档选项",
"System": "系统",
"Account": "账户",
"BCAT": "BCAT数据",
"Device": "设备",
"Temporary": "临时",
"Cache": "缓存",
"System BCAT": "系统备份",
"Data Type": "数据类型",
"Backup": "备份",
"Backup the selected save(s) to a location of your choice.": "将选中的存档备份到您选择的位置。",
"Backup to...": "备份到...",
"Backup the selected save(s) to a location of your choice, and set the name of the backup.": "将选定的存档备份到您选择的位置,并设置备份名称。",
"save_backuprestore_info": [
"还原当前游戏的存档。",
"如果启用了\"自动备份\",存档将首先被备份然后还原。 ",
"自动备份的存档名称中将包含\"Auto\"。"
],
"Auto backup on restore": "还原时自动备份",
"If enabled, when restoring a save, the current save will first be backed up.": "如果启用,当还原存档时,当前存档将首先被备份。",
"Compress backup": "压缩备份",
"save_backup_compress_info": [
"如果启用备份将被压缩为zip文件。\n",
"注意禁用此选项不会禁用zip文件它只会禁用zip中存储文件的压缩。",
"禁用将使备份速度更快,但代价是文件大小增加。"
],
"Select backup location": "选择备份位置",
"Backup failed!": "备份失败!",
"Backup successfull!": "已备份成功!",
"Select restore location": "选择还原位置",
"Invalid location type!": "位置类型无效!",
"No saves found in ": "未找到存档 ",
"Restore save for: ": "还原备份文件: ",
"Are you sure you want to restore ": "您确定要还原已备份文件吗 ",
"Auto backup": "自动备份",
"Restore failed!": "还原失败!",
"Restore successfull!": "已还原成功!",
"Set name for ": "设置名称为:",
"Set backup name": "设备备份名称",
"Flushing zip to file": "将压缩包写入文件",
"Disable MTP for usb install": "暂时禁用 USB 安装的 MTP 功能",
"Re-enabled MTP": "重新启用 MTP",
"Installed via usb": "通过 USB 安装",
"USB install failed!": "USB 安装失败!",
"Usb install success!": "USB安装成功",
"Waiting for connection...": "等待连接中...",
"Connected, waiting for file list...": "已连接,正在等待文件列表...",
"Connected, starting transfer...": "已连接,开始传输...",
"Transferring data...": "正在传输数据...",
"Press B to exit...": "按 B 键退出...",
"Failed to init usb, press B to exit...": "USB 初始化失败,按 B 键退出...",
"Detached": "已断开",
"Attached": "已连接",
"Powered": "已供电",
"Default": "默认",
"Address": "地址",
"Configured": "已配置",
"Suspended": "已挂起",
"USB 1.0 Low Speed": "USB 1.0 低速",
"USB 1.1 Full Speed": "USB 1.1 全速",
"USB 2.0 High Speed": "USB 2.0 高速",
"USB 3.0 Super Speed": "USB 3.0 超高速",
"Mount Creator": "创建挂载",
"Type": "类型",
"Select the type of the forwarder.": "选择前端启动器的类型。",
"URL": "",
"Set the URL of the application": "设置应用程序的 URL",
"Optional: Set the port of the server. If left empty, the default port for the protocol will be used.": "可选:设置服务器端口。如果留空,将使用协议的默认端口。",
"Timeout": "超时",
"Timeout in milliseconds": "超时(毫秒)",
"Optional: Set the timeout in seconds.": "可选:设置超时时间(秒)。",
"Optional: Set the username of the application": "可选:设置应用程序的用户名",
"Optional: Set the password of the application": "可选:设置应用程序的密码",
"Dump path": "转储路径",
"Optional: Set the dump path used when exporting games and saves.": "可选:设置导出游戏和存档时使用的转储路径。",
"Read only": "只读",
"mount_readonly_info": [
"将文件系统挂载为只读。\n",
"设置此选项还会隐藏挂载点,使其不显示为导出选项。"
],
"No stat file": "",
"filecheck_disable_info": [
"启用后将阻止文件浏览器检查每个文件的大小和时间戳。",
"这可以提高浏览性能。"
],
"No stat dir": "",
"dircheck_disable_info": [
"启用后,文件浏览器将停止检查文件夹中有多少文件和文件夹。",
"这可以提高浏览性能,尤其是对于目录列表速度慢的服务器。"
],
"FS hidden": "隐藏挂载点",
"Hide the mount from being visible in the file browser.": "隐藏挂载点,不在文件浏览器中显示。",
"Export hidden": "隐藏到处",
"Hide the mount from being visible as a export option for games and saves.": "隐藏挂载点,不显示为游戏和存档的导出选项。",
"Save": "保存",
"Mount entry saved. Restart Sphaira to apply changes.": "挂载条目已保存。重启 Sphaira 以应用更改。",
"Saves the mount entry.\n\nNOTE: You must restart Sphaira for changes to take effect!": "保存挂载条目。\n\n注意您必须重启Sphaira才能使更改生效",
"Name and URL must be set!": "必须设置名称和URL",
"Devoptab Options": "Devoptab选项",
"Create New Entry": "创建新条目",
"Creates a new mount option.\n\nNOTE: You must restart Sphaira for changes to take effect!": "创建新的挂载选项。\n\n注意您必须重启Sphaira才能使更改生效",
"Modify Existing Entry": "修改现有条目",
"No mount entries found.": "未找到挂载条目。",
"Modify Entry": "修改条目",
"Modify an existing mount option.\n\nNOTE: You must restart Sphaira for changes to take effect!": "修改现有的挂载选项。\n\n注意您必须重启Sphaira才能使更改生效",
"Delete Existing Entry": "删除现有条目",
"Delete Entry": "删除条目",
"Delete an existing mount option.\n\nNOTE: You must restart Sphaira for changes to take effect!": "删除现有的挂载选项。\n\n注意您必须重启Sphaira才能使更改生效",
"Section #": ""
}

View File

@@ -0,0 +1,923 @@
{
"Homebrew": "自製軟體",
"FileBrowser": "檔案瀏覽器",
"Appstore": "程式商店",
"Corrupted": "已損毀",
"enable_install_info": [
"安裝功能已停用。\n",
"請在 選單 (Y) -> 進階 -> 安裝選項 -> 啟用 中開啟。"
],
"On": "開",
"Off": "關",
"Entry": "入口",
"Store": "商店",
"File": "檔案",
"Files": "檔案",
"FTP": "FTP",
"Games": "遊戲",
"Meta": "Meta",
"Nca": "NCA",
"GC": "卡匣",
"GitHub": "GitHub",
"Apps": "應用程式",
"IRS": "IRS",
"MTP": "MTP",
"Saves": "存檔",
"USB": "USB",
"Level 0 (no compression)": "等級 0 (無壓縮)",
"Level 1": "等級 1",
"Level 2": "等級 2",
"Level 3 (default)": "等級 3 (預設)",
"Level 4": "等級 4",
"Level 5": "等級 5",
"Level 6": "等級 6",
"Level 7": "等級 7",
"Level 8": "等級 8",
"0 (single threaded)": "0 (單執行緒)",
"1": "1",
"2": "2",
"3 (default)": "3 (預設)",
"4": "4",
"16 KB": "16 KB",
"32 KB": "32 KB",
"64 KB": "64 KB",
"128 KB": "128 KB",
"256 KB": "256 KB",
"512 KB": "512 KB",
"1 MB (default)": "1 MB (預設)",
"2 MB": "2 MB",
"4 MB": "4 MB",
"8 MB": "8 MB",
"16 MB": "16 MB",
"Switch-Handheld!": "切換到手提模式!",
"Switch-Docked!": "切換到底座模式!",
"Nxlink Connected": "Nxlink 已連線",
"Nxlink Upload": "Nxlink 上傳",
"Nxlink Finished": "Nxlink 完成",
"Restore hbmenu?": "還原 hbmenu",
"Back": "返回",
"Restore": "還原",
"missing_hbmenu_info": [
"找不到 /switch/hbmenu.nro",
"請使用程式商店重新安裝 hbmenu"
],
"OK": "確定",
"Failed to restore hbmenu, please re-download hbmenu": "還原 hbmenu 失敗,請重新下載 hbmenu",
"Failed to restore hbmenu, using sphaira instead": "還原 hbmenu 失敗,改用 Sphaira",
"Restored hbmenu, closing sphaira": "已還原 hbmenu正在關閉 Sphaira",
"Restored hbmenu": "已還原 hbmenu",
"Restart Sphaira?": "重新啟動 Sphaira",
"Restart": "重新啟動",
"Installing Forwarder": "正在安裝前導程式",
"Failed to install forwarder": "安裝前導程式失敗",
"Installed!": "已安裝!",
"Warning! Logs are enabled, Sphaira will run slowly!": "警告記錄檔已啟用Sphaira 執行速度將變慢!",
"Audio disabled due to suspended game": "因遊戲暫停而停用音訊",
"Theme Options": "佈景主題選項",
"Select Theme": "選擇佈景主題",
"Customise the look of Sphaira by changing the theme": "更換佈景主題以自訂 Sphaira 的外觀",
"Music": "音樂",
"bgm_enable_info": [
"啟用背景音樂。",
"每個佈景主題都可以有自己的音樂檔案。",
"如果佈景主題未設定音樂檔案,則會載入預設音樂 (若存在)。"
],
"Show IP address": "顯示 IP 位址",
"display_ip_info": [
"在所有選單中顯示 IP 位址 (包含 WiFi 強度)。\n",
"注意在小程式模式下由於該位置會顯示警告訊息IP 位址將被隱藏。"
],
"Remove Background Music": "移除背景音樂",
"Removes the background music file": "移除背景音樂檔案",
"No background music file is set": "未設定背景音樂檔案",
"Menus": "選單",
"Web": "網頁",
"Enter custom URL": "輸入自訂網址",
"Select URL": "選擇網址",
"Enter URL": "輸入網址",
"web_browser_info": [
"啟動內建網頁瀏覽器。\n",
"注意:此瀏覽器功能非常有限,部分網站可能無法載入,且有 30 分鐘逾時限制,超時後將關閉瀏覽器。"
],
"Advanced Options": "進階選項",
"Slow": "慢",
"Normal": "正常",
"Fast": "快",
"Logging": "記錄檔",
"Logs to /config/sphaira/log.txt": "記錄至 /config/sphaira/log.txt",
"Replace hbmenu on exit": "離開時取代 hbmenu",
"hbmenu_replace_info": [
"啟用後,會將 /hbmenu.nro 替換為 Sphaira並將 hbmenu 備份至 /switch/hbmenu.nro\n",
"停用此選項將可選擇還原 hbmenu。"
],
"Add / modify mounts": "新增 / 修改掛載點",
"mount_options_info": [
"建立、修改、刪除網路掛載 (HTTP, FTP, SFTP, SMB, NFS)。",
"掛載選項僅需設定網址和名稱,其他欄位 (如連接埠、使用者、密碼等) 為選填。\n",
"任何變更都需要重新啟動 Sphaira 才能生效。"
],
"Boost CPU during transfer": "傳輸時加速 CPU",
"transfer_boost_info": [
"在傳輸期間啟用加速模式,可提高傳輸速度。",
"這會將 CPU 設定為 1785mhz 並將 GPU 降低至 76mhz。"
],
"Text scroll speed": "文字捲動速度",
"Change how fast the scrolling text updates": "更改捲動文字的更新速度",
"Set center menu": "設定中央選單",
"Press OK to restart Sphaira": "按 OK 重新啟動 Sphaira",
"Set the menu that appears on the center tab.": "設定顯示在中央分頁的選單。",
"Set left-side menu": "設定左側選單",
"Set the menu that appears on the left tab.": "設定顯示在左側分頁的選單。",
"Set right-side menu": "設定右側選單",
"Set the menu that appears on the right tab.": "設定顯示在右側分頁的選單。",
"Install options": "安裝選項",
"install_options_info": [
"更改安裝選項。",
"您可以從此處啟用安裝功能。"
],
"Export options": "匯出選項",
"Change the export options.": "更改匯出選項。",
"Install Options": "安裝選項",
"System memory": "系統記憶體",
"microSD card": "microSD 卡",
"Enable sysmmc": "啟用真實系統 (SysMMC)",
"Enables installing whilst in sysMMC mode.": "啟用在真實系統模式下進行安裝。",
"Enable emummc": "啟用虛擬系統 (EmuMMC)",
"Enables installing whilst in emuMMC mode.": "啟用在虛擬系統模式下進行安裝。",
"Install location": "安裝位置",
"Allow downgrade": "允許降級",
"Allows for installing title updates that are lower than the currently installed update.": "允許安裝比目前已安裝版本更舊的更新檔。",
"Skip if already installed": "若已安裝則跳過",
"Skips installing titles / ncas if they're already installed.": "若已安裝該 Title / NCA則跳過安裝。",
"Ticket only": "僅安裝 Ticket",
"Installs tickets only, useful if the title was already installed however the tickets were missing or corrupted.": "僅安裝 Ticket適用於遊戲已安裝但 Ticket 遺失或損毀的情況。",
"Skip base": "跳過本體",
"Skips installing the base application.": "跳過安裝應用程式本體。",
"Skip patch": "跳過更新檔 (UPD)",
"Skips installing updates.": "跳過安裝更新檔。",
"Skip dlc": "跳過追加內容 (DLC)",
"Skips installing DLC.": "跳過安裝 DLC。",
"Skip data patch": "跳過資料更新",
"Skips installing DLC update (data patch).": "跳過安裝 DLC 更新 (資料更新)。",
"Skip ticket": "跳過 Ticket",
"Skips installing tickets, not recommended.": "跳過安裝 Ticket不建議使用。",
"Skip NCA hash verify": "跳過 NCA 雜湊驗證",
"skip_nca_info": [
"啟用此選項以跳過 sha256 驗證。這是針對整個 NCA 的雜湊檢查。",
"用於驗證 NCA 是否有效且未損毀。",
"您可能在安裝損毀的遊戲時看過「正在檢查損毀資料」的選項。",
"該檢查執行各種雜湊檢查,包括針對 NCA 的雜湊。\n",
"建議保持停用此選項。"
],
"Skip RSA header verify": "跳過 RSA 標頭驗證",
"nca_verify_info": [
"啟用此選項以跳過 RSA NCA 固定金鑰驗證。",
"這是針對 NCA 標頭的雜湊檢查,用於驗證標頭是否被修改。",
"標頭由任天堂簽署,因此無法偽造,能可靠地檢測修改過的 NCA 標頭 (如 NSP/XCI 轉換檔)。\n",
"建議保持停用此選項,除非您需要安裝 NSP/XCI 轉換檔。"
],
"Skip RSA NPDM verify": "跳過 RSA NPDM 驗證",
"npdm_verify_info": [
"啟用此選項以跳過 RSA NPDM 固定金鑰驗證。\n",
"目前此選項尚未實作 (Stubbed)。"
],
"Ignore distribution bit": "忽略分發位元",
"nca_distbit_info": [
"若設定,將忽略 NCA 標頭中的分發位元 (Distribution bit)。",
"分發位元用於標示 NCA 是 Eshop 版還是卡匣 (GameCard) 版。",
"您通常無法啟動安裝後且分發位元設為卡匣版的遊戲。\n",
"建議保持停用此選項。"
],
"Convert to common ticket": "轉換為通用 Ticket",
"ticket_convert_info": [
"[需要金鑰] 將個人化 Ticket 轉換為通用 (偽造) Ticket。\n",
"建議保持啟用此選項。"
],
"Convert to standard crypto": "轉換為標準加密",
"titlekey_crypto_info": [
"[需要金鑰] 將 TitleKey 轉換為標準加密,也稱為「無 Ticket (Ticketless)」。\n",
"建議保持停用此選項。"
],
"Lower master key": "降低主金鑰 (Master Key)",
"keyarea_crypto_info": [
"[需要金鑰] 使用主金鑰 0 加密 Keak (金鑰區域金鑰),允許遊戲在所有韌體版本上啟動。",
"隱含執行標準加密。\n",
"請注意,僅因遊戲可解密而在任何韌體上啟動,並不代表它能正常運作。強烈建議更新您的韌體和 Atmosphere 版本來遊玩遊戲,而不是啟用此選項。\n",
"建議保持停用此選項。"
],
"Lower system version": "降低系統版本要求",
"cnmt_fw_info": [
"將 CNMT 擴充標頭中的 system_firmware 欄位設定為 0。",
"注意:如果主金鑰高於韌體版本,遊戲仍無法啟動,因為韌體沒有解密 Keak 的金鑰 (見上文)。\n",
"建議保持停用此選項。"
],
"Export Options": "匯出選項",
"Created nested folder": "已建立巢狀資料夾",
"game_folder_info": [
"使用遊戲名稱建立資料夾。",
"例如:/名稱/名稱.xci",
"停用此選項將使用 /名稱.xci"
],
"Append folder with .xci": "資料夾名稱加上 .xci",
"xci_folder_info": [
"XCI 提取時會在資料夾名稱加上 .xci 副檔名。",
"例如:/名稱.xci/名稱.xci\n",
"某些裝置僅在 XCI 資料夾名稱與 XCI 檔案名稱完全相同時才能運作。"
],
"Trim XCI": "裁剪 XCI (瘦身)",
"Removes the unused data at the end of the XCI, making the output smaller.": "移除 XCI 尾端未使用的資料,讓輸出的檔案更小。",
"Label trimmed XCI": "標記已裁剪的 XCI",
"Names the trimmed xci.\nFor example, /name/name (trimmed).xci": "命名已裁剪的 XCI。\n例如/名稱/名稱 (trimmed).xci",
"Converts personalised ticket to a fake common ticket.": "將個人化 Ticket 轉換為偽造的通用 Ticket。",
"NSZ level": "NSZ 壓縮等級",
"compress_level_info": [
"設定匯出為 NSZ 時使用的壓縮等級。\n",
"注意Switch CPU 速度不快,設定太高的值會導致",
"匯出時間非常長,但檔案大小縮減有限。\n",
"建議將此值設定為 3。"
],
"NSZ threads": "NSZ 執行緒",
"compress_threads_info": [
"設定壓縮 NCA 時使用的執行緒數量。\n",
"小於 3 的值允許另一個執行緒自由運作,例如讀/寫執行緒。",
"但在測試中,值為 3 通常效能最佳。",
"值為 0 將不使用執行緒,僅應於測試時使用,因為速度總是較慢。\n",
"建議將此值設定在 1-3 之間。"
],
"NSZ long distance mode": "NSZ 長距離模式",
"Enables \"Long Distance Mode\" which can reduce the output size at the cost of speed.": "啟用「長距離模式」,可縮小輸出檔案大小,但會降低速度。",
"NSZ block compression": "NSZ 區塊壓縮",
"block_compress_info": [
"啟用區塊壓縮,將 NCA 壓縮成區塊 (代價是壓縮率較差)",
"這允許隨機存取,讓 NCZ 可以像檔案系統一樣被掛載。\n",
"注意Sphaira 尚不支援將 NCZ 掛載為檔案系統,但最終將會加入此功能。"
],
"NSZ block size": "NSZ 區塊大小",
"Sets the size of each block. The smaller the size, the faster the random access is at the cost of compression ratio.": "設定每個區塊的大小。區塊越小,隨機存取速度越快,但壓縮率較低。",
"NSZ block compression is disabled.": "NSZ 區塊壓縮已停用。",
"FTP Options": "FTP 選項",
"Restarting FTP server...": "正在重新啟動 FTP 伺服器...",
"Enable": "啟用",
"Enable FTP server to run in the background.": "啟用 FTP 伺服器在背景執行。",
"Port": "連接埠",
"Opens the FTP server on this port.": "在此連接埠開啟 FTP 伺服器。",
"Anon": "匿名",
"login_require_info": [
"允許您在未設定使用者名稱和密碼的情況下登入。",
"如果停用,您必須在下方設定使用者名稱和密碼!"
],
"User": "使用者",
"Sets the username, must be set if anon is disabled.": "設定使用者名稱,若停用匿名則必須設定。",
"Pass": "密碼",
"Sets the password, must be set if anon is disabled.": "設定密碼,若停用匿名則必須設定。",
"Show album": "顯示相簿",
"Shows the microSD card album folder.": "顯示 microSD 卡的相簿資料夾。",
"Show Atmosphere contents": "顯示 Atmosphere contents",
"Shows the shortcut for the /atmosphere/contents folder.": "顯示 /atmosphere/contents 資料夾的捷徑。",
"Show bis storage": "顯示 BIS 儲存區",
"bis_contents_info": [
"顯示 BIS 資料夾,包含以下內容:",
"- BootPartition1Root.bin",
"- BootPartition2Root.bin",
"- UserDataRoot.bin",
"- BootConfigAndPackage2Part1.bin",
"- BootConfigAndPackage2Part2.bin",
"- BootConfigAndPackage2Part3.bin",
"- BootConfigAndPackage2Part4.bin",
"- BootConfigAndPackage2Part5.bin",
"- BootConfigAndPackage2Part6.bin",
"- CalibrationFile.bin",
"- SafeMode.bin",
"- User.bin",
"- System.bin",
"- SystemProperEncryption.bin"
],
"Show bis file systems": "顯示 BIS 檔案系統",
"bis_fs_info": [
"顯示以下 BIS 檔案系統:",
"- bis_calibration_file",
"- bis_safe_mode",
"- bis_user",
"- bis_system"
],
"Show system contents": "顯示系統 contents",
"Shows the system contents folder.": "顯示系統 contents 資料夾。",
"Show user contents": "顯示使用者 contents",
"Shows the user contents folder.": "顯示使用者 contents 資料夾。",
"Show microSD contents": "顯示 microSD contents",
"microsd_contents_info": [
"顯示 microSD contents 資料夾。\n",
"注意:這不是一般的 microSD 卡儲存空間,而是",
"儲存 NCA 的位置。一般的 microSD 卡總是會被掛載。"
],
"Show games": "顯示遊戲",
"games_ftp_info": [
"顯示遊戲資料夾。\n",
"此資料夾包含所有您已安裝的遊戲,允許您透過 FTP 建立備份!\n",
"注意:此資料夾為唯讀。您無法透過 FTP 刪除遊戲。"
],
"Show install": "顯示安裝目錄",
"install_ftp_info": [
"顯示安裝資料夾。\n",
"此資料夾用於透過 FTP 安裝遊戲。\n",
"注意嘗試安裝遊戲時您必須開啟「FTP 安裝」選單!"
],
"Show mounts": "顯示掛載點",
"mounts_ftp_info": [
"顯示掛載資料夾。\n",
"此資料夾包含所有新增至 Sphaira 的掛載點,允許您透過 FTP 存取它們!",
"例如,您可以透過 FTP 存取您的 SMB、WebDav 或其他 FTP 掛載。"
],
"Show switch": "顯示 Switch 目錄",
"homebrew_folder_info": [
"顯示 /switch 資料夾的捷徑。",
"這是包含您所有自製軟體 (NRO) 的資料夾。"
],
"MTP Options": "MTP 選項",
"Restarting MTP server...": "正在重新啟動 MTP 伺服器...",
"Enable MTP server to run in the background.": "啟用 MTP 伺服器在背景執行。",
"Pre-allocate file": "預先配置檔案",
"prealloc_info": [
"啟用在寫入前預先配置檔案大小。",
"這能加快檔案寫入速度,但如果符合以下所有條件,可能會導致逾時:",
"- 使用 Windows",
"- 使用虛擬系統 (emuMMC)",
"- 傳輸大型檔案 (>1GB)\n",
"此選項應保持啟用,但如果您符合上述條件並遇到逾時,",
"請嘗試停用此選項後重試。"
],
"games_mtp_info": [
"顯示遊戲資料夾。\n",
"此資料夾包含所有您已安裝的遊戲,允許您透過 MTP 建立備份!\n",
"注意:此資料夾為唯讀。您無法透過 MTP 刪除遊戲。"
],
"install_mtp_info": [
"顯示安裝資料夾。\n",
"此資料夾用於透過 MTP 安裝遊戲。\n",
"注意嘗試安裝遊戲時您必須開啟「MTP 安裝」選單!"
],
"mounts_mtp_info": [
"顯示掛載資料夾。\n",
"此資料夾包含所有新增至 Sphaira 的掛載點,允許您透過 MTP 存取它們!",
"例如,您可以透過 MTP 存取您的 SMB、WebDav 和 FTP 掛載。"
],
"Show DevNull": "顯示 DevNull",
"usb_benchmark_info": [
"顯示 DevNull (速度測試) 資料夾。\n",
"此資料夾用於測試 USB 上傳效能。",
"這是一個虛擬資料夾,實際上不會寫入任何資料到磁碟。"
],
"HDD Options": "硬碟選項",
"mount_hdd_info": [
"啟用掛載已連接的 USB/HDD 硬碟裝置。",
"連接的裝置可用於檔案瀏覽器,也可作為提取遊戲和存檔時的備份位置。"
],
"HDD write protect": "硬碟寫入保護",
"Makes the connected HDD read-only.": "將連接的硬碟設為唯讀。",
"Installing is disabled, enable now?": "安裝功能已停用,要現在啟用嗎?",
"WARNING: Installing apps will lead to a ban!": "警告:安裝未授權的應用程式會導致主機被 Ban",
"Installing enabled!": "安裝功能已啟用!",
"microSD card (/dumps/)": "microSD 卡 (/dumps/)",
"USB export to PC (usb_export.py)": "USB 匯出至電腦 (usb_export.py)",
"USB transfer (Switch 2 Switch)": "USB 傳輸 (Switch 對 Switch)",
"/dev/null (Speed Test)": "/dev/null (速度測試)",
"Waiting for USB connection...": "等待 USB 連線中...",
"USB connected, sending file list": "USB 已連線,正在傳送檔案列表",
"Sent file list, waiting for command...": "已傳送檔案列表,等待指令中...",
"waiting for usb connection...": "等待 USB 連線中...",
"Exporting": "正在匯出",
"Export failed!": "匯出失敗!",
"Export successfull!": "匯出成功!",
"Select export location": "選擇匯出位置",
"Please launch MTP install menu before trying to install": "嘗試安裝前請先開啟 MTP 安裝選單",
"Album": "相簿",
"Install (NSP, XCI, NSZ, XCZ)": "安裝 (NSP、XCI、NSZ、XCZ)",
" (Read Only)": " (唯讀)",
"Unknown": "未知",
"Application": "應用程式",
"Creating Program": "正在建立程式",
"Creating Control": "正在建立控制項",
"Creating Meta": "正在建立 Meta",
"Writing Nca": "正在寫入 Nca",
"Updating ncm database": "正在更新 ncm 資料庫",
"Pushing application record": "正在推送應用程式記錄",
"Failed to remove old forwarder, please manually remove it!": "移除舊的前導程式失敗,請手動移除!",
"An error occurred": "發生錯誤",
"If this message appears repeatedly, please open an issue.": "如果此訊息重複出現,請回報問題 (Issue)。",
"Failed to load music": "無法載入音樂",
"Artist: Unknown": "演出者:未知",
"Album: Unknown": "專輯:未知",
"Select": "選擇",
"Are you sure you wish to cancel?": "您確定要取消嗎?",
"No": "否",
"Yes": "是",
"%zu hours %zu minutes remaining": "剩餘 %zu 時 %zu 分",
"%zu minutes %zu seconds remaining": "剩餘 %zu 分 %zu 秒",
"%zu seconds remaining": "剩餘 %zu 秒",
"Closing empty sidebar": "關閉空的側邊欄",
"All": "全部",
"Emulators": "模擬器",
"Tools": "工具",
"Advanced": "進階",
"Themes": "佈景主題",
"Legacy": "舊版相容",
"Misc": "雜項",
"Updated": "更新時間",
"Downloads": "下載次數",
"Size": "大小",
"Alphabetical": "按字母順序",
"Desc": "遞減",
"Asc": "遞增",
"Removing ": "正在移除 ",
"Downloading ": "正在下載 ",
"Checking MD5": "正在檢查 MD5",
"Options": "選項",
"More by Author": "作者的其他作品",
"Leave Feedback": "留下回饋",
"Visit Website": "造訪網站",
"version: %s": "版本:%s",
"updated: %s": "更新日期:%s",
"category: %s": "分類:%s",
"extracted: %s": "已解壓:%s",
"app_dls: %s": "下載次數:%s",
"Loading...": "載入中...",
"Failed to download manifest": "無法下載資訊清單",
"Details": "詳細資料",
"Changelog": "更新日誌",
"Downloaded ": "已下載 ",
"Uninstalling ": "正在解除安裝 ",
"Removed ": "已移除 ",
"Install": "安裝",
"Update": "更新",
"Launch": "啟動",
"Remove": "移除",
"Completely remove ": "完全移除 ",
"AppStore": "程式商店",
"Info": "資訊",
"AppStore Options": "程式商店選項",
"Descending": "遞減",
"Ascending": "遞增",
"List": "列表",
"Icon": "圖示",
"Grid": "格狀",
"Filter": "篩選",
"Sort": "排序",
"Order": "順序",
"Layout": "版面配置",
"Search": "搜尋",
"Empty!": "空的!",
"Filter: %s | Sort: %s | Order: %s": "篩選:%s | 排序:%s | 順序:%s",
"File Picker": "檔案選擇器",
"Failed to parse nro": "解析 NRO 失敗",
"Name": "名稱",
"Set the name of the application": "設定應用程式名稱",
"Author": "作者",
"Set the author of the application": "設定應用程式作者",
"Version": "版本",
"Set the display version of the application": "設定應用程式的顯示版本",
"Set the path to the icon for the forwarder": "設定前導程式的圖示路徑",
"Create": "建立",
"Failed to load icon": "載入圖示失敗",
"Create the forwarder.": "建立前導程式。",
"All fields must be non-empty!": "所有欄位都不能留空!",
"Open": "開啟",
"Empty...": "空的...",
"%zd files": "%zd 個檔案",
"%zd dirs": "%zd 個目錄",
"Open with DayBreak?": "用 DayBreak 開啟?",
"Launch ": "啟動 ",
"Launch option for: ": "啟動選項:",
"Select launcher for: ": "選擇啟動器:",
"Install Selected files?": "安裝選取的檔案?",
"Installing ": "正在安裝 ",
"Installed ": "已安裝 ",
"File install failed!": "檔案安裝失敗!",
"Extracting ": "正在解壓縮 ",
"Extract failed!": "解壓縮失敗!",
"Extract success!": "解壓縮成功!",
"Compressing ": "正在壓縮 ",
"Compress failed!": "壓縮失敗!",
"Compress success!": "壓縮成功!",
"Failed to delete directory": "無法刪除資料夾",
"Failed to delete file": "無法刪除檔案",
"Deleting": "正在刪除",
"Scanning ": "正在掃描 ",
"Pasting": "正在貼上",
"Pasting ": "正在貼上 ",
"Creating ": "正在建立 ",
"Copying ": "正在複製 ",
"Deleting ": "正在刪除 ",
"Hashing": "正在計算雜湊",
"Failed to hash file...": "計算檔案雜湊失敗...",
"File Options": "檔案選項",
"Mount": "掛載",
"Sort By": "排序依據",
"Sort Options": "排序選項",
"Show Hidden": "顯示隱藏檔",
"Folders First": "資料夾優先",
"Hidden Last": "隱藏檔置後",
"Cut": "剪下",
"Copy": "複製",
"Paste": "貼上",
"Paste file(s)?": "貼上檔案?",
"Rename": "重新命名",
"Set new name": "設定新名稱",
"Failed to rename file: ": "重新命名檔案失敗:",
"Delete": "刪除",
"Delete Selected files?": "刪除選取的檔案?",
"Install Forwarder": "安裝前導程式",
"Extract zip": "解壓縮 zip",
"Extract Options": "解壓縮選項",
"Extract here": "解壓縮至此",
"Extract to root": "解壓縮至根目錄",
"Are you sure you want to extract to root?": "確定要解壓縮至根目錄嗎?",
"Extract to...": "解壓縮至...",
"Enter the path to the folder to extract into": "輸入要解壓縮到的資料夾路徑",
"Compress to zip": "壓縮為 zip",
"Compress Options": "壓縮選項",
"Compress": "壓縮",
"Compress to...": "壓縮至...",
"Enter the path to the folder to compress into": "輸入要壓縮到的資料夾路徑",
"Create File": "建立檔案",
"Set File Name": "設定檔案名稱",
"Create Folder": "建立資料夾",
"Set Folder Name": "設定資料夾名稱",
"View as text (unfinished)": "以文字檢視 (未完成)",
"Set as background music": "設為背景音樂",
"Failed to set default music path": "設定預設音樂路徑失敗",
"Hash": "雜湊",
"Hash Options": "雜湊選項",
"Ignore read only": "忽略唯讀屬性",
"Failed to mount FS.": "掛載檔案系統失敗。",
"Close FileBrowser?": "關閉檔案瀏覽器?",
"Split": "分割",
"Close": "關閉",
"FTP Install": "FTP 安裝",
"Connection Type: WiFi | Strength: ": "連線類型WiFi | 強度:",
"Connection Type: Ethernet": "連線類型:乙太網路",
"Connection Type: None": "連線類型:無",
"Host:": "主機:",
"Port:": "連接埠:",
"Username:": "使用者名稱:",
"Password:": "密碼:",
"SSID:": "SSID",
"Passphrase:": "密碼:",
"Success": "成功",
"Failed to launch application": "啟動應用程式失敗",
"Game Options": "遊戲選項",
"Hide forwarders": "隱藏前導程式",
"View application content": "檢視應用程式內容",
"Launch random game": "隨機啟動遊戲",
"Export NSP": "匯出 NSP",
"Not supported in Applet Mode": "不支援小程式模式",
"Export NSZ": "匯出 NSZ",
"Exports to NSZ (compressed NSP)": "匯出為 NSZ (壓縮的 NSP)",
"Are you sure you want to delete ": "確定要刪除 ",
"Advanced options": "進階選項",
"Refresh": "重新整理",
"Create contents folder": "建立 contents 資料夾",
"Folder create failed!": "建立資料夾失敗!",
"Folder created!": "資料夾已建立!",
"Create save": "建立存檔",
"Select user to create save for": "選擇要建立存檔的使用者",
"Delete title cache": "刪除 Title 快取",
"Are you sure you want to delete the title cache?": "您確定要刪除 Title 快取嗎?",
"Updating application record list": "正在更新應用程式記錄列表",
"Delete failed!": "刪除失敗!",
"Delete successfull!": "刪除成功!",
"Select content to export": "選擇要匯出的內容",
"Export All": "匯出全部",
"Export Application": "匯出應用程式",
"Export Patch": "匯出更新檔 (Patch)",
"Export AddOnContent": "匯出追加內容 (DLC)",
"Export DataPatch": "匯出資料更新 (DataPatch)",
"Creating": "正在建立",
"Save create failed!": "建立存檔失敗!",
"Save create successfull!": "建立存檔成功!",
"Failed to delete meta entry": "刪除 Meta 項目失敗",
"None": "無",
"Common": "通用",
"Personalised": "個人化",
"Missing": "遺失",
"View Content": "檢視內容",
"Content Options": "內容選項",
"Are you sure you want to delete the selected entries?": "您確定要刪除選取的項目嗎?",
"Reset required system version": "重設系統版本要求",
"Are you sure you want to reset required system version?": "您確定要重設系統版本要求嗎?",
"Reset": "重設",
"Failed to reset required system version": "重設系統版本要求失敗",
"Required System Version: %u.%u.%u": "系統版本要求:%u.%u.%u",
"Required Application Version: v%u": "應用程式版本要求v%u",
"Content Count: %u (%u missing)": "內容數量:%u (遺失 %u)",
"Content Count: %u": "內容數量:%u",
"Ticket: %s": "Ticket%s",
"Key Generation: %u (%s)": "金鑰世代:%u (%s)",
"Display Version: %s": "顯示版本:%s",
"Mount Fs": "掛載檔案系統",
"Failed to mount NCA": "掛載 NCA 失敗",
"NCA Options": "NCA 選項",
"Export NCA": "匯出 NCA",
"Export NCA decrypted": "匯出已解密 NCA",
"Exports the NCA with all fs sections decrypted (NCA header is still encrypted).": "匯出所有檔案系統區段皆已解密的 NCA (NCA 標頭仍為加密狀態)。",
"Verify NCA 256 hash": "驗證 NCA 256 雜湊",
"NCA hash missmatch!": "NCA 雜湊不符!",
"NCA hash valid.": "NCA 雜湊有效。",
"nca_validate_info": [
"對 NCA 執行 sha256 雜湊運算以檢查其是否有效。\n",
"注意:這只能檢測雜湊是否不符,無法驗證",
"內容是否經過修改。"
],
"Verify NCA fixed key": "驗證 NCA 固定金鑰",
"NCA fixed key is invalid!": "NCA 固定金鑰無效!",
"NCA fixed key is valid.": "NCA 固定金鑰有效。",
"nca_fixedkey_info": [
"執行 RSA NCA 固定金鑰驗證。",
"這是針對 NCA 標頭的雜湊檢查,用於驗證標頭是否被修改。",
"標頭由任天堂簽署,因此無法偽造,能可靠地檢測修改過的 NCA 標頭 (如 NSP/XCI 轉換檔)。"
],
"Failed to decrypt NCA": "解密 NCA 失敗",
"Application Type: %s": "應用程式類型:%s",
"Content Type: %s": "內容類型:%s",
"Distribution Type: %s": "分發類型:%s",
"Program ID: %016lX": "程式 ID%016lX",
"SDK Version: %u.%u.%u.%u": "SDK 版本:%u.%u.%u.%u",
"Export XCI (Gamecard)": "匯出 XCI (遊戲卡匣)",
"Export XCZ (Compressed XCI)": "匯出 XCZ (壓縮的 XCI)",
"GameCard": "遊戲卡匣",
"Gc install failed!": "卡匣安裝失敗!",
"Gc install success!": "卡匣安裝成功!",
"Select content to dump": "選擇要提取的內容",
"Export All Bins": "匯出所有 Bin",
"Export XCI": "匯出 XCI",
"Export Card ID Set": "匯出卡匣 ID Set",
"Export Card UID": "匯出卡匣 UID",
"Export Certificate": "匯出憑證",
"Export Initial Data": "匯出初始資料",
"Failed to mount GameCard filesystem": "掛載遊戲卡匣檔案系統失敗",
"System memory %.1f GB": "系統記憶體 %.1f GB",
"microSD card %.1f GB": "microSD 卡 %.1f GB",
"App-ID: 0%lX": "App-ID0%lX",
"Key-Gen: %u (%s)": "金鑰世代:%u (%s)",
"Size: %.2f GB": "大小:%.2f GB",
"Base: %zu Patch: %zu Addon: %zu Data: %zu": "本體:%zu 更新:%zu DLC%zu 資料:%zu",
"Prev": "上一個",
"Next": "下一個",
"No GameCard inserted": "未插入遊戲卡匣",
"WARNING: GameCard is already trimmed!": "警告:遊戲卡匣已經過裁剪!",
"Continue": "繼續",
"GameCard is trimmed, full dump is not possible!": "遊戲卡匣已經過裁剪,無法完整提取!",
"Downloading json": "正在下載 json",
"Download": "下載",
"Failed to download json": "下載 json 失敗",
"Select release to download for ": "選擇要下載的版本:",
"Select asset to download for ": "選擇要下載的資源檔:",
"Failed to download app!": "下載應用程式失敗!",
"Unstar": "取消星號",
"Unstarred ": "已取消星號 ",
"Star": "加上星號",
"Starred ": "已加星號 ",
"Homebrew Options": "自製軟體選項",
"Updated (Star)": "更新時間 (星號)",
"Alphabetical (Star)": "按字母順序 (星號)",
"Size (Star)": "大小 (星號)",
"Display entries in Ascending or Descending order.": "以遞增或遞減順序顯示項目。",
"Change the layout to List, Icon and Grid.": "將版面配置更改為列表、圖示和格狀。",
"Show hidden": "顯示隱藏檔",
"Shows all hidden homebrew.": "顯示所有隱藏的自製軟體。",
"Test": "測試",
"Hide": "隱藏",
"Hides the selected homebrew.\n\nTo unhide homebrew, enable \"Show hidden\" in the sort options.": "隱藏選取的自製軟體。\n\n若要取消隱藏請在排序選項中啟用「顯示隱藏檔」。",
"Mount NRO Fs": "掛載 NRO 檔案系統",
"Failed to mount NRO FileSystem": "掛載 NRO 檔案系統失敗",
"Mounts the NRO FileSystem (icon, nacp and RomFS).": "掛載 NRO 檔案系統 (圖示、NACP 和 RomFS)。",
"hb_remove_info": [
"永久刪除選取的自製軟體。\n",
"該自製軟體建立的檔案和資料夾仍會保留。",
"請使用檔案瀏覽器刪除它們。"
],
"Failed to load image": "載入圖片失敗",
"Install failed!": "安裝失敗!",
"Install success!": "安裝成功!",
"Drag'n'Drop (NSP, XCI, NSZ, XCZ) to the install folder": "拖放檔案 (NSP、XCI、NSZ、XCZ) 至 install 資料夾",
"Failed to install, press B to exit...": "安裝失敗,請按  離開...",
"Irs": "紅外成像",
"0 (Sideways)": "0 (橫向)",
"90 (Flat)": "90 (平放)",
"180 (-Sideways)": "180 (反向橫向)",
"270 (Upside down)": "270 (倒置)",
"Grey": "灰色",
"Ironbow": "彩虹熱圖 (Ironbow)",
"Green": "綠色",
"Red": "紅色",
"Blue": "藍色",
"All leds": "所有 LED",
"Bright group": "高亮度群組",
"Dim group": "低亮度群組",
"Normal image": "正常影像",
"Negative image": "負片影像",
"Controller": "控制器",
"Rotation": "旋轉",
"Colour": "色彩",
"Light Target": "照明目標",
"Gain": "增益",
"Negative Image": "負片影像",
"Format": "格式",
"Trimming Format": "裁剪格式",
"External Light Filter": "外部濾光片",
"Load Default": "載入預設值",
"Ambient Noise Level: ": "環境噪音等級:",
"Pad ": "控制器 ",
"HandHeld": "手提模式",
" (Available)": " (可用)",
" (Unsupported)": " (不支援)",
" (Unconnected)": " (未連線)",
"The homebrew menu.\n\nAllows you to launch, delete and mount homebrew!": "自製軟體選單。\n\n允許您啟動、刪除和掛載自製軟體",
"Download and update apps.\n\nInternet connection required.": "下載並更新應用程式。\n\n需要網際網路連線。",
"View all installed games. In this menu you can launch, backup, create savedata and much more.": "檢視所有已安裝的遊戲。您可以在此選單中啟動、備份、建立存檔等。",
"Browse files on you SD Card. You can move, copy, delete, extract zip, create zip, upload and much more.\n\nA connected USB/HDD can be opened by mounting it in the advanced options.": "瀏覽 SD 卡上的檔案。您可以移動、複製、刪除、解壓縮 zip、建立 zip、上傳等。\n\n連接的 USB/HDD 可透過進階選項中的掛載功能開啟。",
"View save data for each user. You can backup and restore saves.\n\nExperimental support for backing up system saves is possible.": "檢視每位使用者的存檔資料。您可以備份和還原存檔。\n\n支援實驗性的系統存檔備份功能。",
"Download releases directly from GitHub. Custom entries can be added to /config/sphaira/github": "直接從 GitHub 下載發行版本。可將自訂項目新增至 /config/sphaira/github",
"Install apps via FTP.": "透過 FTP 安裝應用程式。",
"MTP Install": "MTP 安裝",
"Install apps via MTP.": "透過 MTP 安裝應用程式。",
"USB Install": "USB 安裝",
"Install apps via USB.\n\nA USB client is required on PC.": "透過 USB 安裝應用程式。\n\n電腦端需要 USB 用戶端軟體。",
"View info on the inserted Game Card (GC). You can backup and install the inserted GC. To swap GC's, simply remove the old GC and insert the new one. You do not need to exit the menu.": "檢視已插入遊戲卡匣的資訊。您可以備份和安裝已插入的卡匣。如要更換卡匣,只需取出舊卡匣並插入新卡匣即可,無需離開選單。",
"IRS (Infrared Joycon Camera)": "IRS (紅外線 Joy-Con 攝影機)",
"InfraRed Sensor (IRS) is the small camera found on right JoyCon.": "紅外線感應器 (IRS) 是位於右側 Joy-Con 上的小型攝影機。",
"Update avaliable: ": "有可用更新:",
"Download via the Network options!": "請透過網路選項下載!",
"Menu": "選單",
"Menu Options": "選單選項",
"Auto": "自動",
"English": "English",
"Japanese": "日本語",
"French": "Français",
"German": "Deutsch",
"Italian": "Italiano",
"Spanish": "Español",
"Chinese (Simplified)": "简体中文",
"Korean": "한국어",
"Dutch": "Dutch",
"Portuguese": "Português",
"Russian": "Русский",
"Chinese (Traditional)": "繁體中文",
"Swedish": "Svenska",
"Vietnamese": "Vietnamese",
"Ukrainian": "Українська",
"Launch one of Sphaira's menus:\n": "啟動 Sphaira 的其中一個選單:\n",
"\nYou can change the left/right menu in the Advanced Options.": " \n您可以在進階選項中更改左側/右側選單。",
"Network": "網路",
"Network Options": "網路選項",
"Download update: ": "下載更新:",
"Failed to download update": "下載更新失敗",
"Updated to ": "已更新至 ",
"ftp_settings_info": [
"啟用 / 修改 FTP 伺服器設定,例如連接埠、使用者/密碼和顯示的資料夾。\n",
"注意:更改任何選項,會在離開選項選單時自動重新啟動 FTP 伺服器。"
],
"mtp_settings_info": [
"啟用 / 修改 MTP 回應端設定,例如顯示的資料夾。\n",
"注意:更改任何選項,會在離開選項選單時自動重新啟動 MTP 伺服器。"
],
"HDD": "HDD 硬碟",
"Enable / modify the HDD mount options.": "啟用 / 修改硬碟掛載選項。",
"NXlink": "NXlink",
"nxlink_enable_info": [
"啟用 NXlink 伺服器在背景執行。",
"NXlink 用於將 .nro 從電腦傳送到 Switch。\n",
"如果您不是開發者,可以停用此選項。"
],
"nxlink_toggle_info": [
"切換 FTP、MTP、硬碟 和 NXlink\n",
"如果 Sphaira 有可用更新,您可以從此選單下載。"
],
"Theme": "佈景主題",
"Language": "語言",
"translation_info": [
"更換語言。\n",
"如果找不到您的語言,或缺少翻譯,請考慮在 github.com/ITotalJustice/sphaira 提交 PR (Pull Request)。",
""
],
"advanced_options_info": [
"更改進階選項。",
"請查看資訊框以更了解每個選項。"
],
"System %.1f GB": "系統 %.1f GB",
"microSD %.1f GB": "microSD %.1f GB",
"[Applet Mode]": "[小程式模式]",
"Ethernet": "乙太網路",
"No Internet": "無網際網路連線",
"State: %s | Speed: %s": "狀態:%s | 速度:%s",
"Failed to mount save filesystem": "掛載存檔檔案系統失敗",
"Save Options": "存檔選項",
"System": "系統",
"Account": "帳號",
"BCAT": "BCAT",
"Device": "裝置",
"Temporary": "暫存",
"Cache": "快取",
"System BCAT": "系統 BCAT",
"Data Type": "資料類型",
"Backup": "備份",
"Backup the selected save(s) to a location of your choice.": "將選取的存檔備份至您選擇的位置。",
"Backup to...": "備份至...",
"Backup the selected save(s) to a location of your choice, and set the name of the backup.": "將選取的存檔備份至您選擇的位置,並設定備份名稱。",
"save_backuprestore_info": [
"還原目前 Title 的存檔。",
"如果啟用「自動備份」,存檔將先被備份然後才還原。",
"自動備份的存檔名稱中將包含「Auto」。"
],
"Auto backup on restore": "還原時自動備份",
"If enabled, when restoring a save, the current save will first be backed up.": "啟用時,還原存檔前會先備份目前的存檔。",
"Compress backup": "壓縮備份",
"save_backup_compress_info": [
"如果啟用,備份將被壓縮為 zip 檔案。\n",
"注意:停用此選項不會停用 zip 檔案格式,只會停用壓縮",
"儲存在 zip 中的檔案。",
"停用壓縮將使備份速度更快,但檔案較大。"
],
"Select backup location": "選擇備份位置",
"Backup failed!": "備份失敗!",
"Backup successfull!": "備份成功!",
"Select restore location": "選擇還原位置",
"Invalid location type!": "無效的位置類型!",
"No saves found in ": "找不到存檔於 ",
"Restore save for: ": "還原存檔給:",
"Are you sure you want to restore ": "您確定要還原 ",
"Auto backup": "自動備份",
"Restore failed!": "還原失敗!",
"Restore successfull!": "還原成功!",
"Set name for ": "設定名稱給 ",
"Set backup name": "設定備份名稱",
"Flushing zip to file": "正在將 zip 寫入檔案",
"Disable MTP for usb install": "為 USB 安裝停用 MTP",
"Re-enabled MTP": "已重新啟用 MTP",
"Installed via usb": "已透過 USB 安裝",
"USB install failed!": "USB 安裝失敗!",
"Usb install success!": "USB 安裝成功!",
"Waiting for connection...": "等待連線中...",
"Connected, waiting for file list...": "已連線,等待檔案列表中...",
"Connected, starting transfer...": "已連線,開始傳輸...",
"Transferring data...": "資料傳輸中...",
"Press B to exit...": "請按  離開...",
"Failed to init usb, press B to exit...": "USB 初始化失敗,請按  離開...",
"Detached": "已斷開",
"Attached": "已連接",
"Powered": "已供電",
"Default": "預設",
"Address": "位址",
"Configured": "已設定",
"Suspended": "已暫停",
"USB 1.0 Low Speed": "USB 1.0 低速",
"USB 1.1 Full Speed": "USB 1.1 全速",
"USB 2.0 High Speed": "USB 2.0 高速",
"USB 3.0 Super Speed": "USB 3.0 超高速",
"Mount Creator": "掛載建立器",
"Type": "類型",
"Select the type of the forwarder.": "選擇前導程式的類型。",
"URL": "網址",
"Set the URL of the application": "設定應用程式的網址",
"Optional: Set the port of the server. If left empty, the default port for the protocol will be used.": "選填:設定伺服器的連接埠。若留空,將使用通訊協定的預設連接埠。",
"Timeout": "逾時",
"Timeout in milliseconds": "逾時 (毫秒)",
"Optional: Set the timeout in seconds.": "選填:設定逾時秒數。",
"Optional: Set the username of the application": "選填:設定應用程式的使用者名稱",
"Optional: Set the password of the application": "選填:設定應用程式的密碼",
"Dump path": "提取路徑",
"Optional: Set the dump path used when exporting games and saves.": "選填:設定匯出遊戲和存檔時使用的提取路徑。",
"Read only": "唯讀",
"mount_readonly_info": [
"將檔案系統掛載為唯讀。\n",
"設定此選項也會隱藏該掛載點,使其不顯示為匯出選項。"
],
"No stat file": "不檢查檔案狀態",
"filecheck_disable_info": [
"啟用此選項可停止檔案瀏覽器檢查每個檔案的大小和時間戳記。",
"這能改善瀏覽效能。"
],
"No stat dir": "不檢查目錄狀態",
"dircheck_disable_info": [
"啟用此選項可停止檔案瀏覽器檢查資料夾中的檔案和資料夾數量。",
"這能改善瀏覽效能,特別是對於目錄列表速度較慢的伺服器。"
],
"FS hidden": "隱藏檔案系統",
"Hide the mount from being visible in the file browser.": "隱藏掛載點,使其不顯示於檔案瀏覽器中。",
"Export hidden": "隱藏匯出",
"Hide the mount from being visible as a export option for games and saves.": "隱藏掛載點,使其不顯示於遊戲和存檔的匯出選項中。",
"Save": "儲存",
"Mount entry saved. Restart Sphaira to apply changes.": "掛載項目已儲存。請重新啟動 Sphaira 以套用變更。",
"Saves the mount entry.\n\nNOTE: You must restart Sphaira for changes to take effect!": "儲存掛載項目。\n\n注意您必須重新啟動 Sphaira 才能使變更生效!",
"Name and URL must be set!": "名稱和網址必須設定!",
"Devoptab Options": "Devoptab 選項",
"Create New Entry": "建立新項目",
"Creates a new mount option.\n\nNOTE: You must restart Sphaira for changes to take effect!": "建立新的掛載選項。\n\n注意您必須重新啟動 Sphaira 才能使變更生效!",
"Modify Existing Entry": "修改現有項目",
"No mount entries found.": "找不到掛載項目。",
"Modify Entry": "修改項目",
"Modify an existing mount option.\n\nNOTE: You must restart Sphaira for changes to take effect!": "修改現有的掛載選項。\n\n注意您必須重新啟動 Sphaira 才能使變更生效!",
"Delete Existing Entry": "刪除現有項目",
"Delete Entry": "刪除項目",
"Delete an existing mount option.\n\nNOTE: You must restart Sphaira for changes to take effect!": "刪除現有的掛載選項。\n\n注意您必須重新啟動 Sphaira 才能使變更生效!",
"Section #": "區段 #"
}

View File

@@ -1,446 +0,0 @@
{
"[Applet Mode]": "[小程序模式]",
"No Internet": "网络未连接",
"Switch-Handheld!": "切换至掌机模式!",
"Switch-Docked!": "切换至底座模式!",
"Warning! Logs are enabled, Sphaira will run slowly!": "警告日志已启用将导致Sphaira运行缓慢",
"Audio disabled due to suspended game": "由于游戏暂停,音频已禁用",
"Are you sure you wish to cancel?": "您确定要取消吗?",
"An error occurred": "发生错误",
"If this message appears repeatedly, please open an issue.": "若此消息反复出现,请提交问题报告。",
"Menu Options": "菜单选项",
"Menu": "菜单",
"Theme": "主题",
"Theme Options": "主题选项",
"Select Theme": "选择主题",
"Music": "音乐",
"12 Hour Time": "12小时制时间",
"Download Default Music": "下载默认音乐",
"Failed to download default_music.bfstm, please try again": "下载default_music.bfstm失败请重试",
"Overwrite current default music?": "覆盖当前默认音乐?",
"Network": "网络",
"Network Options": "网络选项",
"Ftp": "FTP",
"Mtp": "MTP",
"Nxlink": "Nxlink插件提交",
"Nxlink Connected": "Nxlink 已连接",
"Nxlink Upload": "Nxlink 上传中",
"Nxlink Finished": "Nxlink 已结束",
"Hdd": "HDD",
"Hdd write protect": "HDD写保护",
"Language": "语言",
"Auto": "自动",
"English": "English",
"Japanese": "日本語",
"French": "Français",
"German": "Deutsch",
"Italian": "Italiano",
"Spanish": "Español",
"Chinese": "中文",
"Korean": "한국어",
"Dutch": "Dutch",
"Portuguese": "Português",
"Russian": "Русский",
"Swedish": "Svenska",
"Vietnamese": "Vietnamese",
"Ukrainian": "Українська",
"Misc": "拓展",
"Misc Options": "拓展选项",
"Games": "游戏",
"Game Options": "游戏选项",
"Hide forwarders": "隐藏前端启动",
"Launch random game": "启动随机游戏",
"List meta records": "列出元数据记录",
"Entries": "条目",
"Failed to list application meta entries": "未能列出应用程序元条目",
"No meta entries found...\n": "未找到元条目...\n",
"Updating application record list": "更新应用程序记录列表",
"Dump": "转储",
"Select content to dump": "选择要转储的内容",
"Dump All": "转储全部内容",
"Dump Application": "转储应用程序(本体)",
"Dump Patch": "转储更新补丁(UPD)",
"Dump AddOnContent": "转储追加内容(DLC)",
"Dump DataPatch": "转储数据补丁",
"Dump All Bins": "转储全部文件",
"Dump XCI": "转储.xci",
"Dump Card ID Set": "转储游戏卡ID",
"Dump Card UID": "转储游戏卡UID",
"Dump Certificate": "转储游戏证书",
"Dump Initial Data": "转储初始数据",
"Select dump location": "选择转储位置",
"microSD card (/dumps/NSP/)": "microSD卡/dumps/NSP/",
"USB transfer (Switch 2 Switch)": "USB传输Switch对Switch",
"/dev/null (Speed Test)": "/dev/null速度测试",
"Dumping": "正在转储",
"Dump successfull!": "转储成功!",
"Dump failed!": "转储失败!",
"Success": "成功",
"Delete successfull!": "删除成功!",
"Delete failed!": "删除失败!",
"Title cache": "标题缓存",
"Saves": "存档",
"Save Options": "存档选项",
"Account": "账户",
"Backup": "备份",
"Auto backup": "自动备份",
"Auto backup on restore": "还原时自动备份",
"Compress backup": "压缩备份",
"Are you sure you want to backup save(s)?": "您确定要备份存档吗?",
"No saves found in ": "未找到存档 ",
"Backed up to ": "已备份到 ",
"Backup successfull!": "已备份成功!",
"Backup failed!": "备份失败!",
"Restore save for: ": "还原备份文件: ",
"Are you sure you want to restore ": "您确定要还原已备份文件吗 ",
"Restore successfull!": "已还原成功!",
"Restore failed!": "还原失败!",
"Themezer": "在线主题",
"Themezer Options": "在线主题选项",
"Nsfw": "公共场合不宜的主题",
"Page": "页面",
"Page %zu / %zu": "页面 %zu / %zu",
"Enter Page Number": "输入跳转的页码",
"Bad Page": "错误的页面",
"Download theme?": "下载该主题?",
"GitHub": "GitHub",
"Downloading json": "正在下载 json",
"Select asset to download for ": "选择要下载的资源用于 ",
"Failed to download json": "下载json失败",
"Failed to download app!": "下载应用程序失败!",
"FTP Install": "通过 FTP 安装",
"Connection Type: WiFi | Strength: ": "连接类型WiFi |强度:",
"Connection Type: Ethernet": "连接类型:以太网",
"Connection Type: None": "连接类型:无",
"Host:": "主机:",
"Port:": "端口:",
"Username:": "用户名:",
"Password:": "密码:",
"SSID:": "网络名称:",
"Passphrase:": "密码:",
"Failed to install, press B to exit...": "通过 FTP 安装失败,按 B 键退出...",
"Install success!": "通过 FTP 安装成功。",
"Install failed!": "通过 FTP 安装失败。",
"USB Install": "通过 USB 安装",
"USB": "USB",
"Connected, waiting for file list...": "已连接,正在等待文件列表...",
"Connected, starting transfer...": "已连接,开始传输...",
"Failed to init usb, press B to exit...": "USB 初始化失败,按 B 键退出...",
"Waiting for connection...": "等待连接中...",
"Transferring data...": "正在传输数据...",
"USB connected, sending file list": "USB已连接正在发送文件列表",
"Sent file list, waiting for command...": "已发送文件列表,正在等待命令...",
"waiting for usb connection...": "等待USB连接...",
"Disable MTP for usb install": "暂时禁用 USB 安装的 MTP 功能",
"Re-enabled MTP": "重新启用 MTP",
"Installed via usb": "通过 USB 安装",
"Usb install success!": "通过 USB 安装成功。",
"Usb install failed!": "通过 USB 安装失败。",
"Press B to exit...": "按 B 键退出...",
"GameCard Install": "游戏卡安装",
"GameCard": "游戏卡",
"GC": "GC",
"System memory %.1f GB": "主机内存 %.1f GB",
"microSD card %.1f GB": "SD卡 %.1f GB",
"Exit": "退出",
"Install disabled...\nPlease enable installing via the install options.": "安装已禁用...\n请通过安装选项启用安装。",
"No GameCard inserted": "未插入游戏卡",
"GameCard is already trimmed!": "游戏卡已被修剪!",
"WARNING: GameCard is already trimmed!": "警告:游戏卡已被修剪!",
"Continue": "继续",
"Gc install success!": "游戏安装成功。",
"Gc install failed!": "游戏安装失败。",
"IRS (Infrared Joycon Camera)": "IRS(Joycon红外摄像头)",
"IRS": "IRS",
"Irs": "红外成像",
"Ambient Noise Level: ": "环境噪声等级:",
"Controller": "控制器",
"Pad ": "手柄 ",
"HandHeld": "掌机模式",
" (Available)": " (可用)",
" (Unsupported)": " (不支持)",
" (Unconnected)": " (未连接)",
"Rotation": "旋转",
"0 (Sideways)": "0度",
"90 (Flat)": "90度",
"180 (-Sideways)": "180度",
"270 (Upside down)": "270度",
"Colour": "颜色",
"Grey": "灰色",
"Ironbow": "紫黄",
"Green": "绿色",
"Red": "红色",
"Blue": "蓝色",
"Light Target": "光源目标",
"All leds": "全部",
"Bright group": "亮色组",
"Dim group": "暗色组",
"None": "无",
"Gain": "曝光",
"Negative Image": "负片图像",
"Normal image": "正常图像",
"Negative image": "负片图像",
"Format": "格式",
"Trimming Format": "修剪格式",
"320x240": "320×240",
"160x120": "160×120",
"80x60": "80×60",
"40x30": "40×30",
"20x15": "20×15",
"External Light Filter": "外部光滤镜",
"Load Default": "加载默认值",
"Web": "网络",
"Select URL": "选择链接",
"Enter custom URL": "输入自定义链接",
"Enter URL": "输入网址",
"Advanced": "高级",
"Advanced Options": "高级选项",
"Logging": "日志",
"Replace hbmenu on exit": "退出后用Sphaira替换hbmenu",
"Restore hbmenu?": "恢复 hbmenu",
"Restore": "恢复",
"Failed to find /switch/hbmenu.nro\nUse the Appstore to re-install hbmenu": "未能找到 /switch/hbmenu.nro\n请使用应用商店重新安装 hbmenu",
"Failed to restore hbmenu, please re-download hbmenu": "恢复 hbmenu 失败,请重新下载 hbmenu",
"Failed to restore hbmenu, using sphaira instead": "恢复 hbmenu 失败,改用 Sphaira",
"Restored hbmenu, closing sphaira": "已恢复 hbmenu正在关闭 Sphaira",
"Restored hbmenu": "已恢复 hbmenu",
"Restart Sphaira?": "重启 Sphaira",
"Press OK to restart Sphaira": "按OK键以重启shphaira菜单",
"Boost CPU during transfer": "传输时提升CPU频率",
"Text scroll speed": "文本滚动速度",
"Slow": "慢",
"Normal": "正常",
"Fast": "快",
"Set left-side menu": "设置左侧菜单",
"Set right-side menu": "设置右侧菜单",
"Install options": "安装选项",
"Install Options": "安装选项",
"Enable sysmmc": "启用sysmmc",
"Enable emummc": "启用emummc",
"Show install warning": "显示安装警告",
"Install location": "安装位置",
"System memory": "主机内存",
"microSD card": "SD卡",
"Boost CPU clock": "提升 CPU 频率",
"Allow downgrade": "允许降级",
"Skip if already installed": "若已安装则跳过",
"Ticket only": "仅安装票据",
"Skip base": "跳过基础部分",
"Skip patch": "跳过更新补丁(UPD)",
"Skip dlc": "跳过追加内容(DLC)",
"Skip data patch": "跳过数据补丁",
"Skip ticket": "跳过票据",
"Skip NCA hash verify": "跳过 NCA 哈希验证",
"Skip RSA header verify": "跳过 RSA 头部验证",
"Skip RSA NPDM verify": "跳过 RSA NPDM 验证",
"Ignore distribution bit": "忽略分布位",
"Convert to standard crypto": "转换为标准加密方式",
"Lower master key": "降低主密钥",
"Lower system version": "降低系统版本",
"Dump options": "转储选项",
"Dump Options": "转储选项",
"Created nested folder": "已创建嵌套文件夹",
"Append folder with .xci": "用.xci附加文件夹",
"Trim XCI": "修剪 XCI",
"Label trimmed XCI": "标记已修剪的XCI",
"Multi-threaded USB transfer": "多线程USB传输",
"Homebrew": "应用列表",
"Apps": "应用",
"Homebrew Options": "应用选项",
"Hide Sphaira": "在应用列表中隐藏Sphaira",
"Install Forwarder": "安装前端应用",
"WARNING: Installing forwarders will lead to a ban!": "警告安装前端应用可能导致ban机",
"Installing Forwarder": "正在生成前端应用",
"Creating Program": "正在创建程序",
"Creating Control": "正在创建控制器",
"Creating Meta": "正在创建元数据",
"Writing Nca": "正在写入Nca",
"Updating ncm database": "正在更新ncm数据库",
"Pushing application record": "正在推送应用记录",
"Failed to install forwarder": "前端应用安装失败",
"Unstar": "取消星标",
"Star": "星标",
"Unstarred ": "取消星标 ",
"Starred ": "已星标 ",
"Failed to remove old forwarder, please manually remove it!": "删除旧前端应用失败,请手动删除!",
"AppStore": "应用商店",
"Appstore": "应用商店",
"Store": "商店",
"Filter: %s | Sort: %s | Order: %s": "筛选: %s | 排序: %s | 顺序: %s",
"AppStore Options": "应用商店选项",
"Info": "信息",
"Changelog": "更新日志",
"Details": "详情",
"version: %s": "版本: %s",
"updated: %s": "更新时间: %s",
"category: %s": "分类: %s",
"extracted: %.2f MiB": "应用大小: %.2f MiB",
"app_dls: %s": "下载量: %s",
"More by Author": "作者更多作品",
"Leave Feedback": "留言反馈",
"FileBrowser": "文件浏览",
"Files": "文件",
"%zd files": "%zd 个文件",
"%zd dirs": "%zd 个文件夹",
"File Options": "文件选项",
"Show Hidden": "显示隐藏项目",
"Folders First": "文件夹靠前",
"Hidden Last": "隐藏项目置后",
"Cut": "剪切",
"Copy": "复制",
"Copying ": "正在复制 ",
"Paste": "粘贴",
"Paste file(s)?": "粘贴 个文件(夹)",
"Pasting ": "正在粘贴 ",
"Pasting": "正在粘贴",
"Rename": "重命名",
"Set New File Name": "输入新命名",
"Failed to delete directory": "删除目录失败",
"Failed to delete file": "删除文件失败",
"Extract zip": "解压 zip",
"Extract Options": "解压选项",
"Extract here": "解压到这里",
"Extract to root": "解压到根目录",
"Are you sure you want to extract to root?": "您确定要解压到根目录吗?",
"Extract to...": "解压到...",
"Enter the path to the folder to extract into": "输入要解压到的文件夹的路径",
"Extracting ": "正在解压",
"Extract success!": "解压成功!",
"Extract failed!": "解压失败!",
"Compress to zip": "压缩到zip",
"Compress Options": "压缩选项",
"Compress": "压缩",
"Compress to...": "压缩到...",
"Compressing ": "正在压缩 ",
"Compress success!": "压缩成功!",
"Compress failed!": "压缩失败",
"Create File": "新建文件",
"Set File Name": "输入文件名",
"Create Folder": "新建文件夹",
"Set Folder Name": "输入文件夹名",
"Creating ": "正在创建 ",
"View as text (unfinished)": "以文本形式查看(未完善)",
"Upload": "上传",
"Select upload location": "选择上传位置",
"No upload locations set!": "未设置上传位置",
"Uploading": "正在上传",
"Upload successfull!": "上传成功!",
"Upload failed!": "上传失败!",
"Hash": "哈希",
"Hash Options": "哈希选项",
"Hashing": "正在计算文件哈希",
"Failed to hash file...": "计算文件哈希失败...",
"Ignore read only": "忽略只读",
"Mount": "挂载",
"Sd": "SD卡",
"Image System memory": "主机内存图像",
"Image microSD card": "SD卡图像",
"Empty...": "空...",
"Open with DayBreak?": "使用DayBreak打开",
"Launch ": "启动 ",
"Launch option for: ": "启动选项:",
"Select launcher for: ": "选择启动器用于:",
"Close FileBrowser?": "是否关闭文件浏览器?",
"Sort By": "排序方式",
"Sort Options": "排序选项",
"Filter": "筛选",
"All": "全部",
"Emulators": "模拟器",
"Tools": "工具",
"Themes": "主题",
"Legacy": "可更新",
"Sort": "排序",
"Size": "按大小",
"Size (Star)": "按大小(星标优先)",
"Alphabetical": "按字母顺序",
"Alphabetical (Star)": "按字母顺序(星标优先)",
"Updated": "最近使用",
"Updated (Star)": "最近更新(星标优先)",
"Downloads": "下载",
"Likes": "点赞量",
"ID": "ID",
"Order": "顺序",
"Descending": "降序",
"Descending (down)": "降序",
"Desc": "降序",
"Ascending": "升序",
"Ascending (Up)": "升序",
"Asc": "升序",
"Layout": "布局",
"List": "列表",
"Icon": "图标",
"Grid": "网格",
"Search": "搜索",
"Options": "选项",
"Split": "拆分",
"OK": "确定",
"Back": "返回",
"Select": "选择",
"Open": "打开",
"Close": "关闭",
"Launch": "启动",
"Restart": "重启",
"Next": "下一项",
"Prev": "上一项",
"Yes": "是",
"No": "否",
"On": "开启",
"Off": "关闭",
"Install": "安装",
"Install Selected files?": "安装所选文件?",
"Installing ": "正在安装 ",
"Installed ": "已安装",
"Installed!": "安装完成!",
"Trying to load ": "尝试加载 ",
"Checking MD5": "正在校验 MD5",
"Delete": "删除",
"Delete Selected files?": "删除选中的文件?",
"Are you sure you want to delete ": "您确定要删除吗 ",
"Scanning ": "正在扫描 ",
"Deleting ": "正在删除 ",
"Deleting": "正在删除",
"Remove": "删除",
"Completely remove ": "彻底删除 ",
"Removing ": "正在移除 ",
"Uninstalling ": "正在卸载 ",
"Removed ": "已移除 ",
"Download": "下载",
"Downloading ": "正在下载 ",
"Downloaded ": "已下载 ",
"Download via the Network options!": "通过网络选项下载!",
"Update": "更新",
"Update avaliable: ": "有可用更新!",
"Download update: ": "下载更新:",
"Updated to ": "更新至 ",
"Failed to download update": "更新下载失败",
"%zu hours %zu minutes remaining": "剩余 %zu 小时 %zu 分钟",
"%zu minutes %zu seconds remaining": "剩余 %zu 分钟 %zu 秒",
"%zu seconds remaining": "剩余 %zu 秒",
"Loading...": "加载中...",
"Loading": "加载中",
"Empty!": "空空如也!",
"Not Ready...": "尚未准备好...",
"Error loading page!": "页面加载失败!"
}

View File

@@ -8,13 +8,13 @@ build_preset() {
cmake --build --preset $1
}
build_preset MinSizeRel
build_preset Release
rm -rf out
# --- SWITCH --- #
mkdir -p out/switch/sphaira/
cp -r build/MinSizeRel/*.nro out/switch/sphaira/sphaira.nro
cp -r build/Release/*.nro out/switch/sphaira/sphaira.nro
pushd out
zip -r9 sphaira.zip switch
popd

View File

@@ -1,10 +1,9 @@
#include <switch.h>
#include <string.h>
#include <stdlib.h>
#define EXIT_DETECTION_STR "if this isn't replaced i will exit :)"
// this uses 3-4KiB more than nx-hbloader.
// this uses 16KiB less than nx-hbloader.
static char g_argv[2048] = {0};
// this can and will be modified by libnx if launched nro calls envSetNextLoad().
static char g_nextArgv[2048] = {0};
@@ -47,7 +46,7 @@ static void fix_nro_path(char* path) {
// Credit to behemoth
// SOURCE: https://github.com/HookedBehemoth/nx-hbloader/commit/7f8000a41bc5e8a6ad96a097ef56634cfd2fabcb
static NX_NORETURN void selfExit(void) {
static void NX_NORETURN selfExit(void) {
Result rc = smInitialize();
if (R_FAILED(rc))
goto fail0;
@@ -162,7 +161,8 @@ static void getOwnProcessHandle(void) {
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 12));
Thread t;
rc = threadCreate(&t, &procHandleReceiveThread, (void*)(uintptr_t)server_handle, NULL, 0x1000, 0x20, 0);
u8* stack = g_heapAddr;
rc = threadCreate(&t, &procHandleReceiveThread, (void*)(uintptr_t)server_handle, stack, 0x1000, 0x20, 0);
if (R_FAILED(rc))
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 10));
@@ -290,10 +290,10 @@ void NX_NORETURN loadNro(void) {
diagAbortWithResult(rc);
}
u8* romfs_dirs = malloc(romfs_header.dirTableSize); // should be 1 entry ("/")
u8* romfs_files = malloc(romfs_header.fileTableSize); // should be 2 entries (argv and nro)
u8 romfs_dirs[1024 * 2]; // should be 1 entry ("/")
u8 romfs_files[1024 * 4]; // should be 2 entries (argv and nro)
if (!romfs_dirs || !romfs_files) {
if (romfs_header.dirTableSize > sizeof(romfs_dirs) || romfs_header.fileTableSize > sizeof(romfs_files)) {
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, LibnxError_OutOfMemory));
}
@@ -317,8 +317,6 @@ void NX_NORETURN loadNro(void) {
diagAbortWithResult(rc);
}
free(romfs_dirs);
free(romfs_files);
fsStorageClose(&s);
strcpy(g_defaultNroPath, g_nextNroPath);
@@ -337,40 +335,24 @@ void NX_NORETURN loadNro(void) {
}
uint8_t *nrobuf = (uint8_t*) g_heapAddr;
NroStart* start = (NroStart*) (nrobuf + 0);
header = (NroHeader*) (nrobuf + sizeof(NroStart));
uint8_t* rest = (uint8_t*) (nrobuf + sizeof(NroStart) + sizeof(NroHeader));
FsFileSystem fs;
FsFile f;
u64 bytes_read = 0;
s64 offset = 0;
if (R_FAILED(rc = fsOpenSdCardFileSystem(&fs))) {
diagAbortWithResult(rc);
}
// don't fatal if we don't find the nro, exit to menu
FsFile f;
if (R_FAILED(rc = fsFsOpenFile(&fs, fixedNextNroPath, FsOpenMode_Read, &f))) {
diagAbortWithResult(rc);
}
if (R_FAILED(rc = fsFileRead(&f, offset, start, sizeof(*start), FsReadOption_None, &bytes_read)) ||
bytes_read != sizeof(*start)) {
diagAbortWithResult(rc);
}
offset += sizeof(*start);
if (R_FAILED(rc = fsFileRead(&f, offset, header, sizeof(*header), FsReadOption_None, &bytes_read)) ||
bytes_read != sizeof(*header) || header->magic != NROHEADER_MAGIC) {
diagAbortWithResult(rc);
}
offset += sizeof(*header);
const size_t rest_size = header->size - (sizeof(NroStart) + sizeof(NroHeader));
if (R_FAILED(rc = fsFileRead(&f, offset, rest, rest_size, FsReadOption_None, &bytes_read)) ||
bytes_read != rest_size) {
u64 bytes_read;
if (R_FAILED(rc = fsFileRead(&f, 0, start, g_heapSize, FsReadOption_None, &bytes_read)) ||
header->magic != NROHEADER_MAGIC ||
bytes_read < sizeof(*start) + sizeof(*header) + header->size) {
diagAbortWithResult(rc);
}
@@ -513,13 +495,11 @@ bool __nx_fsdev_support_cwd = false;
// u32 __nx_applet_exit_mode = 0;
void __libnx_initheap(void) {
static char g_innerheap[0x4000];
extern char* fake_heap_start;
extern char* fake_heap_end;
fake_heap_start = &g_innerheap[0];
fake_heap_end = &g_innerheap[sizeof(g_innerheap)];
fake_heap_start = NULL;
fake_heap_end = NULL;
}
void __appInit(void) {
@@ -557,7 +537,20 @@ void __appExit(void) {
}
// exit() effectively never gets called, so let's stub it out.
void __wrap_exit(void) {
// exit() effectively never gets called, so let's stub it out.
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 39));
}
// stub alloc calls as they're not used (saves 4KiB).
void* __libnx_alloc(size_t size) {
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 40));
}
void* __libnx_aligned_alloc(size_t alignment, size_t size) {
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 41));
}
void __libnx_free(void* p) {
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 43));
}

View File

@@ -1,6 +1,34 @@
cmake_minimum_required(VERSION 3.13)
set(sphaira_VERSION 0.13.3)
# generic options.
option(ENABLE_NVJPG "" OFF)
option(ENABLE_NSZ "enables exporting to nsz" ON)
# lib options.
option(ENABLE_LIBUSBHSFS "enables FAT/exFAT hdd mounting" ON)
option(ENABLE_LIBUSBDVD "enables cd/dvd/iso/cue mounting" ON)
option(ENABLE_FTPSRV "enables MTP server support" ON)
option(ENABLE_LIBHAZE "enables MTP server support" ON)
# audio options.
option(ENABLE_AUDIO_MP3 "" ON)
option(ENABLE_AUDIO_OGG "" ON)
option(ENABLE_AUDIO_WAV "" ON)
option(ENABLE_AUDIO_FLAC "" ON)
# devoptab options.
option(ENABLE_DEVOPTAB_HTTP "" ON)
option(ENABLE_DEVOPTAB_NFS "" ON)
option(ENABLE_DEVOPTAB_SMB2 "" ON)
option(ENABLE_DEVOPTAB_FTP "" ON)
option(ENABLE_DEVOPTAB_WEBDAV "" ON)
# disable by default because we are CPU bound for upload/download.
# max speed is 8MiB/s, which is fine for wifi, but awful for ethernet.
# other clients get 36-40MiB/s.
# it also adds 230k to binary size, and i don't think anyone will use it.
option(ENABLE_DEVOPTAB_SFTP "" OFF)
set(sphaira_VERSION 1.0.0)
project(sphaira
VERSION ${sphaira_VERSION}
@@ -30,12 +58,18 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(sphaira_VERSION_HASH "${sphaira_VERSION} [${GIT_COMMIT}]")
if (DEFINED sphaira_VERSION_OVERRIDE)
set(sphaira_DISPLAY_VERSION "${sphaira_VERSION_OVERRIDE} [${GIT_COMMIT}]")
else()
set(sphaira_DISPLAY_VERSION "${sphaira_VERSION} [${GIT_COMMIT}]")
endif()
add_executable(sphaira
source/ui/menus/appstore.cpp
source/ui/menus/file_viewer.cpp
source/ui/menus/image_viewer.cpp
source/ui/menus/filebrowser.cpp
source/ui/menus/file_picker.cpp
source/ui/menus/homebrew.cpp
source/ui/menus/irs_menu.cpp
source/ui/menus/main_menu.cpp
@@ -44,10 +78,10 @@ add_executable(sphaira
source/ui/menus/themezer.cpp
source/ui/menus/ghdl.cpp
source/ui/menus/usb_menu.cpp
source/ui/menus/ftp_menu.cpp
source/ui/menus/mtp_menu.cpp
source/ui/menus/gc_menu.cpp
source/ui/menus/game_menu.cpp
source/ui/menus/game_meta_menu.cpp
source/ui/menus/game_nca_menu.cpp
source/ui/menus/grid_menu_base.cpp
source/ui/menus/install_stream_menu_base.cpp
@@ -62,6 +96,7 @@ add_executable(sphaira
source/ui/widget.cpp
source/ui/list.cpp
source/ui/scrolling_text.cpp
source/ui/music_player.cpp
source/app.cpp
source/download.cpp
@@ -80,36 +115,58 @@ add_executable(sphaira
source/web.cpp
source/hasher.cpp
source/i18n.cpp
source/ftpsrv_helper.cpp
source/haze_helper.cpp
source/threaded_file_transfer.cpp
source/title_info.cpp
source/minizip_helper.cpp
source/utils/utils.cpp
source/utils/audio.cpp
source/utils/devoptab_common.cpp
source/utils/devoptab_romfs.cpp
source/utils/devoptab_save.cpp
source/utils/devoptab_nro.cpp
source/utils/devoptab_nca.cpp
source/utils/devoptab_nsp.cpp
source/utils/devoptab_xci.cpp
source/utils/devoptab_zip.cpp
source/utils/devoptab_bfsar.cpp
source/utils/devoptab_vfs.cpp
source/utils/devoptab_fatfs.cpp
source/utils/devoptab_game.cpp
source/utils/devoptab_mounts.cpp
source/utils/devoptab.cpp
source/usb/base.cpp
source/usb/usbds.cpp
source/usb/usbhs.cpp
source/usb/usb_uploader.cpp
source/usb/usb_installer.cpp
source/usb/usb_dumper.cpp
source/yati/yati.cpp
source/yati/container/nsp.cpp
source/yati/container/xci.cpp
source/yati/source/file.cpp
source/yati/source/usb.cpp
source/yati/source/stream.cpp
source/yati/source/stream_file.cpp
source/yati/nx/es.cpp
source/yati/nx/keys.cpp
source/yati/nx/nca.cpp
source/yati/nx/ncz.cpp
source/yati/nx/ncm.cpp
source/yati/nx/ns.cpp
source/yati/nx/nxdumptool_rsa.c
source/yati/nx/nxdumptool/save.c
)
target_compile_definitions(sphaira PRIVATE
-DAPP_VERSION="${sphaira_VERSION}"
-DAPP_VERSION_HASH="${sphaira_VERSION_HASH}"
-DAPP_DISPLAY_VERSION="${sphaira_DISPLAY_VERSION}"
-DCURL_NO_OLDIES=1
-DDEV_BUILD=$<BOOL:${DEV_BUILD}>
-DZSTD_STATIC_LINKING_ONLY=1
)
target_compile_options(sphaira PRIVATE
@@ -131,6 +188,8 @@ target_compile_options(sphaira PRIVATE
# disabled as it warns for strcat 2 paths together, but it will never
# overflow due to fs enforcing a max path len anyway.
-Wno-format-truncation
# many false positives when LTO is not enabled.
-Wno-suggest-final-types
# the below are taken from my gba emulator, they've served me well ;)
-Wformat-overflow=2
@@ -147,28 +206,15 @@ target_compile_options(sphaira PRIVATE
-Wcast-qual
-Wcast-align
-Wimplicit-fallthrough=5
-Wsuggest-final-types
-Wuninitialized
)
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(ftpsrv
GIT_REPOSITORY https://github.com/ITotalJustice/ftpsrv.git
# GIT_TAG 1.2.2
GIT_TAG 8782f6b
SOURCE_SUBDIR NONE
)
FetchContent_Declare(libhaze
GIT_REPOSITORY https://github.com/ITotalJustice/libhaze.git
GIT_TAG af69c0a
)
FetchContent_Declare(libpulsar
GIT_REPOSITORY https://github.com/ITotalJustice/switch-libpulsar.git
GIT_TAG de656e4
GIT_TAG ac7bc97
)
FetchContent_Declare(nanovg
@@ -183,12 +229,12 @@ FetchContent_Declare(stb
FetchContent_Declare(yyjson
GIT_REPOSITORY https://github.com/ibireme/yyjson.git
GIT_TAG 0.11.1
GIT_TAG 0.12.0
)
FetchContent_Declare(minIni
GIT_REPOSITORY https://github.com/ITotalJustice/minIni-nx.git
GIT_TAG 11cac8b
GIT_TAG 6e952b6
)
FetchContent_Declare(zstd
@@ -197,14 +243,9 @@ FetchContent_Declare(zstd
SOURCE_SUBDIR build/cmake
)
FetchContent_Declare(libusbhsfs
GIT_REPOSITORY https://github.com/ITotalJustice/libusbhsfs.git
GIT_TAG d0a973e
)
FetchContent_Declare(libnxtc
GIT_REPOSITORY https://github.com/ITotalJustice/libnxtc.git
GIT_TAG 0d369b8
GIT_TAG 88ce3d8
)
FetchContent_Declare(nvjpg
@@ -212,31 +253,291 @@ FetchContent_Declare(nvjpg
GIT_TAG 45680e7
)
set(USE_NEW_ZSTD ON)
# has issues with some homebrew and game icons (oxenfree, overwatch2).
set(USE_NVJPG ON)
FetchContent_Declare(dr_libs
GIT_REPOSITORY https://github.com/mackron/dr_libs.git
GIT_TAG b962384
SOURCE_SUBDIR NONE
)
if (ENABLE_NVJPG)
FetchContent_Declare(nvjpg
GIT_REPOSITORY https://github.com/ITotalJustice/oss-nvjpg.git
GIT_TAG 45680e7
)
FetchContent_MakeAvailable(nvjpg)
add_library(nvjpg
${nvjpg_SOURCE_DIR}/lib/decoder.cpp
${nvjpg_SOURCE_DIR}/lib/image.cpp
${nvjpg_SOURCE_DIR}/lib/surface.cpp
)
target_include_directories(nvjpg PUBLIC ${nvjpg_SOURCE_DIR}/include)
set_target_properties(nvjpg PROPERTIES CXX_STANDARD 26)
target_link_libraries(nvjpg PRIVATE nvjpg)
target_compile_definitions(sphaira PRIVATE ENABLE_NVJPG)
endif()
if (ENABLE_NSZ)
target_sources(sphaira PRIVATE source/utils/nsz_dumper.cpp)
target_compile_definitions(sphaira PRIVATE ENABLE_NSZ)
endif()
if (ENABLE_LIBUSBHSFS)
# enable this if you want ntfs and ext4 support, at the cost of a huge final binary size.
set(USBHSFS_GPL OFF)
set(USBHSFS_SXOS_DISABLE ON)
FetchContent_Declare(libusbhsfs
GIT_REPOSITORY https://github.com/ITotalJustice/libusbhsfs.git
GIT_TAG 625269b
)
FetchContent_MakeAvailable(libusbhsfs)
target_compile_definitions(sphaira PRIVATE ENABLE_LIBUSBHSFS)
target_link_libraries(sphaira PRIVATE libusbhsfs)
else()
target_sources(sphaira PRIVATE source/ff16/ffunicode.c)
endif()
if (ENABLE_LIBUSBDVD)
FetchContent_Declare(libusbdvd
GIT_REPOSITORY https://github.com/proconsule/libusbdvd.git
GIT_TAG 3cb0613
)
FetchContent_MakeAvailable(libusbdvd)
add_library(libusbdvd
${libusbdvd_SOURCE_DIR}/source/usbdvd.cpp
${libusbdvd_SOURCE_DIR}/source/usbdvd_scsi.cpp
${libusbdvd_SOURCE_DIR}/source/usbdvd_utils.cpp
${libusbdvd_SOURCE_DIR}/source/fs/usbdvd_datadisc.cpp
${libusbdvd_SOURCE_DIR}/source/fs/audiocdfs/audiocdfs.cpp
${libusbdvd_SOURCE_DIR}/source/fs/audiocdfs/cdaudio_devoptab.cpp
${libusbdvd_SOURCE_DIR}/source/fs/iso9660/usbdvd_iso9660.cpp
${libusbdvd_SOURCE_DIR}/source/fs/iso9660/iso9660_devoptab.cpp
${libusbdvd_SOURCE_DIR}/source/fs/udf/usbdvd_udf.cpp
${libusbdvd_SOURCE_DIR}/source/fs/udf/udf_devoptab.cpp
${libusbdvd_SOURCE_DIR}/source/os/switch/switch_usb.cpp
)
target_include_directories(libusbdvd PRIVATE ${libusbdvd_SOURCE_DIR}/source/)
target_include_directories(libusbdvd PRIVATE ${libusbdvd_SOURCE_DIR}/source/os/switch)
target_include_directories(libusbdvd PRIVATE ${libusbdvd_SOURCE_DIR}/source/fs)
target_include_directories(libusbdvd PRIVATE ${libusbdvd_SOURCE_DIR}/source/fs/audiocdfs)
target_include_directories(libusbdvd PRIVATE ${libusbdvd_SOURCE_DIR}/source/fs/iso9660)
target_include_directories(libusbdvd PRIVATE ${libusbdvd_SOURCE_DIR}/source/fs/udf)
target_include_directories(libusbdvd PUBLIC ${libusbdvd_SOURCE_DIR}/include)
target_compile_definitions(sphaira PRIVATE ENABLE_LIBUSBDVD)
target_link_libraries(sphaira PRIVATE libusbdvd)
target_sources(sphaira PRIVATE source/usbdvd.cpp)
endif()
if (ENABLE_FTPSRV)
FetchContent_Declare(ftpsrv
GIT_REPOSITORY https://github.com/ITotalJustice/ftpsrv.git
GIT_TAG 7c82402
SOURCE_SUBDIR NONE
)
FetchContent_MakeAvailable(ftpsrv)
set(FTPSRV_LIB_BUILD TRUE)
set(FTPSRV_LIB_VFS_CUSTOM ${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs_nx.h)
set(FTPSRV_LIB_PATH_SIZE 0x301)
set(FTPSRV_LIB_SESSIONS 16)
set(FTPSRV_LIB_BUF_SIZE 1024*64)
set(FTPSRV_LIB_CUSTOM_DEFINES
USE_VFS_SAVE=$<BOOL:FALSE>
USE_VFS_STORAGE=$<BOOL:TRUE>
# disabled as it may conflict with the gamecard menu.
USE_VFS_GC=$<BOOL:FALSE>
USE_VFS_USBHSFS=$<BOOL:FALSE>
VFS_NX_BUFFER_IO=$<BOOL:TRUE>
# let sphaira handle init / closing of the hdd.
USE_VFS_USBHSFS_INIT=$<BOOL:FALSE>
# disable romfs mounting as otherwise we cannot write / modify sphaira.nro
USE_VFS_ROMFS=$<BOOL:FALSE>
FTP_SOCKET_HEADER="${ftpsrv_SOURCE_DIR}/src/platform/nx/socket_nx.h"
)
add_subdirectory(${ftpsrv_SOURCE_DIR} binary_dir)
add_library(ftpsrv_helper
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs_nx.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_none.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_root.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_fs.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_storage.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/utils.c
)
target_link_libraries(ftpsrv_helper PUBLIC ftpsrv)
target_include_directories(ftpsrv_helper PUBLIC ${ftpsrv_SOURCE_DIR}/src/platform)
target_compile_definitions(sphaira PRIVATE ENABLE_FTPSRV)
target_link_libraries(sphaira PRIVATE ftpsrv_helper)
target_sources(sphaira PRIVATE
source/ftpsrv_helper.cpp
source/ui/menus/ftp_menu.cpp
)
endif()
if (ENABLE_LIBHAZE)
FetchContent_Declare(libhaze
GIT_REPOSITORY https://github.com/ITotalJustice/libhaze.git
GIT_TAG 81154c1
)
FetchContent_MakeAvailable(libhaze)
target_compile_definitions(sphaira PRIVATE ENABLE_LIBHAZE)
target_link_libraries(sphaira PRIVATE libhaze)
target_sources(sphaira PRIVATE
source/haze_helper.cpp
source/ui/menus/mtp_menu.cpp
)
endif()
if (ENABLE_DEVOPTAB_HTTP)
target_compile_definitions(sphaira PRIVATE ENABLE_DEVOPTAB_HTTP)
target_sources(sphaira PRIVATE source/utils/devoptab_http.cpp)
endif()
if (ENABLE_DEVOPTAB_NFS)
FetchContent_Declare(libnfs
GIT_REPOSITORY https://github.com/ITotalJustice/libnfs.git
GIT_TAG 65f3e11
)
FetchContent_MakeAvailable(libnfs)
target_compile_definitions(sphaira PRIVATE ENABLE_DEVOPTAB_NFS)
target_link_libraries(sphaira PRIVATE nfs)
target_sources(sphaira PRIVATE source/utils/devoptab_nfs.cpp)
# todo: fix this upstream as nfs should export these folders.
target_include_directories(sphaira PRIVATE
${libnfs_SOURCE_DIR}/include
${libnfs_SOURCE_DIR}/include/nfsc
${libnfs_SOURCE_DIR}/nfs
)
endif()
if (ENABLE_DEVOPTAB_SMB2)
FetchContent_Declare(libsmb2
GIT_REPOSITORY https://github.com/ITotalJustice/libsmb2.git
GIT_TAG 867beea
)
FetchContent_MakeAvailable(libsmb2)
target_compile_definitions(sphaira PRIVATE ENABLE_DEVOPTAB_SMB2)
target_link_libraries(sphaira PRIVATE smb2)
target_sources(sphaira PRIVATE source/utils/devoptab_smb2.cpp)
endif()
if (ENABLE_DEVOPTAB_FTP)
target_compile_definitions(sphaira PRIVATE ENABLE_DEVOPTAB_FTP)
target_sources(sphaira PRIVATE source/utils/devoptab_ftp.cpp)
endif()
if (ENABLE_DEVOPTAB_SFTP)
# set to build from source, otherwise it will link against the older dkp libssh2.
if (1)
set(CRYPTO_BACKEND mbedTLS)
set(ENABLE_ZLIB_COMPRESSION ON)
set(ENABLE_DEBUG_LOGGING OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_TESTING OFF)
set(LINT OFF)
FetchContent_Declare(libssh2
GIT_REPOSITORY https://github.com/libssh2/libssh2.git
# GIT_TAG a0dafb3 # latest commit, works fine, but i'll stick to main release.
GIT_TAG libssh2-1.11.1
)
FetchContent_MakeAvailable(libssh2)
target_link_libraries(sphaira PRIVATE libssh2::libssh2)
else()
include(FindPkgConfig)
pkg_check_modules(LIBSSH2 libssh2 REQUIRED)
target_include_directories(sphaira PRIVATE ${LIBSSH2_INCLUDE_DIRS})
target_link_libraries(sphaira PRIVATE ${LIBSSH2_LIBRARIES})
endif()
target_compile_definitions(sphaira PRIVATE ENABLE_DEVOPTAB_SFTP)
target_sources(sphaira PRIVATE source/utils/devoptab_sftp.cpp)
endif()
if (ENABLE_DEVOPTAB_WEBDAV)
set(PUGIXML_NO_EXCEPTIONS ON)
set(PUGIXML_WCHAR_MODE OFF)
FetchContent_Declare(pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml.git
GIT_TAG v1.15
)
FetchContent_MakeAvailable(pugixml)
target_compile_definitions(sphaira PRIVATE ENABLE_DEVOPTAB_WEBDAV)
target_link_libraries(sphaira PRIVATE pugixml)
target_sources(sphaira PRIVATE source/utils/devoptab_webdav.cpp)
endif()
if (ENABLE_AUDIO_MP3)
FetchContent_Declare(id3v2lib
GIT_REPOSITORY https://github.com/larsbs/id3v2lib.git
GIT_TAG 141ffb8
)
FetchContent_MakeAvailable(id3v2lib)
target_link_libraries(sphaira PRIVATE id3v2lib)
target_compile_definitions(sphaira PRIVATE ENABLE_AUDIO_MP3)
endif()
if (ENABLE_AUDIO_OGG)
target_compile_definitions(sphaira PRIVATE ENABLE_AUDIO_OGG)
endif()
if (ENABLE_AUDIO_WAV)
target_compile_definitions(sphaira PRIVATE ENABLE_AUDIO_WAV)
endif()
if (ENABLE_AUDIO_FLAC)
target_compile_definitions(sphaira PRIVATE ENABLE_AUDIO_FLAC)
endif()
# ztsd
set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_SHARED OFF)
set(ZSTD_BUILD_COMPRESSION OFF)
set(ZSTD_BUILD_COMPRESSION ${ENABLE_NSZ})
set(ZSTD_MULTITHREAD_SUPPORT ${ENABLE_NSZ})
set(ZSTD_BUILD_DECOMPRESSION ON)
set(ZSTD_BUILD_DICTBUILDER OFF)
set(ZSTD_LEGACY_SUPPORT OFF)
set(ZSTD_MULTITHREAD_SUPPORT OFF)
set(ZSTD_BUILD_PROGRAMS OFF)
set(ZSTD_BUILD_TESTS OFF)
# minini
set(MININI_LIB_NAME minIni)
set(MININI_USE_STDIO ON)
set(MININI_USE_NX OFF)
set(MININI_USE_FLOAT OFF)
set(MININI_USE_FLOAT ON)
# nanovg
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(NANOVG_DEBUG ON)
endif()
set(NANOVG_NO_JPEG OFF)
set(NANOVG_NO_PNG OFF)
set(NANOVG_NO_BMP ON)
set(NANOVG_NO_BMP OFF)
set(NANOVG_NO_PSD ON)
set(NANOVG_NO_TGA ON)
set(NANOVG_NO_GIF ON)
@@ -244,6 +545,8 @@ set(NANOVG_NO_HDR ON)
set(NANOVG_NO_PIC ON)
set(NANOVG_NO_PNM ON)
# yyjson
set(YYJSON_INSTALL OFF)
set(YYJSON_DISABLE_READER OFF)
set(YYJSON_DISABLE_WRITER OFF)
set(YYJSON_DISABLE_UTILS ON)
@@ -252,63 +555,23 @@ set(YYJSON_DISABLE_NON_STANDARD ON)
set(YYJSON_DISABLE_UTF8_VALIDATION ON)
set(YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS OFF)
# enable this if you want ntfs and ext4 support, at the cost of a huge final binary size.
set(USBHSFS_GPL OFF)
set(USBHSFS_SXOS_DISABLE ON)
FetchContent_MakeAvailable(
ftpsrv
libhaze
libpulsar
nanovg
stb
minIni
yyjson
zstd
libusbhsfs
libnxtc
nvjpg
dr_libs
)
set(FTPSRV_LIB_BUILD TRUE)
set(FTPSRV_LIB_VFS_CUSTOM ${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs_nx.h)
set(FTPSRV_LIB_PATH_SIZE 0x301)
set(FTPSRV_LIB_SESSIONS 16)
set(FTPSRV_LIB_BUF_SIZE 1024*64)
set(FTPSRV_LIB_CUSTOM_DEFINES
USE_VFS_SAVE=$<BOOL:FALSE>
USE_VFS_STORAGE=$<BOOL:TRUE>
# disabled as it may conflict with the gamecard menu.
USE_VFS_GC=$<BOOL:FALSE>
USE_VFS_USBHSFS=$<BOOL:TRUE>
VFS_NX_BUFFER_IO=$<BOOL:TRUE>
# let sphaira handle init / closing of the hdd.
USE_VFS_USBHSFS_INIT=$<BOOL:FALSE>
# disable romfs mounting as otherwise we cannot write / modify sphaira.nro
USE_VFS_ROMFS=$<BOOL:FALSE>
FTP_SOCKET_HEADER="${ftpsrv_SOURCE_DIR}/src/platform/nx/socket_nx.h"
)
add_subdirectory(${ftpsrv_SOURCE_DIR} binary_dir)
add_library(ftpsrv_helper
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs_nx.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_none.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_root.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_fs.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_storage.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_stdio.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/vfs/vfs_nx_hdd.c
${ftpsrv_SOURCE_DIR}/src/platform/nx/utils.c
)
target_link_libraries(ftpsrv_helper PUBLIC ftpsrv libusbhsfs)
target_include_directories(ftpsrv_helper PUBLIC ${ftpsrv_SOURCE_DIR}/src/platform)
add_library(stb INTERFACE)
target_include_directories(stb INTERFACE ${stb_SOURCE_DIR})
add_library(dr_libs INTERFACE)
target_include_directories(dr_libs INTERFACE ${dr_libs_SOURCE_DIR})
add_library(libnxtc
${libnxtc_SOURCE_DIR}/source/nxtc.c
${libnxtc_SOURCE_DIR}/source/nxtc_log.c
@@ -316,16 +579,6 @@ add_library(libnxtc
)
target_include_directories(libnxtc PUBLIC ${libnxtc_SOURCE_DIR}/include)
if (USE_NVJPG)
add_library(nvjpg
${nvjpg_SOURCE_DIR}/lib/decoder.cpp
${nvjpg_SOURCE_DIR}/lib/image.cpp
${nvjpg_SOURCE_DIR}/lib/surface.cpp
)
target_include_directories(nvjpg PUBLIC ${nvjpg_SOURCE_DIR}/include)
set_target_properties(nvjpg PROPERTIES CXX_STANDARD 26)
endif()
find_package(ZLIB REQUIRED)
find_library(minizip_lib minizip REQUIRED)
find_path(minizip_inc minizip REQUIRED)
@@ -334,10 +587,12 @@ find_package(CURL REQUIRED)
find_path(mbedtls_inc mbedtls REQUIRED)
find_library(mbedcrypto_lib mbedcrypto REQUIRED)
if (NOT USE_NEW_ZSTD)
find_path(zstd_inc zstd.h REQUIRED)
find_library(zstd_lib zstd REQUIRED)
endif()
add_library(fatfs
source/ff16/diskio.c
source/ff16/ff.c
)
target_include_directories(fatfs PUBLIC source/ff16)
set_target_properties(sphaira PROPERTIES
C_STANDARD 23
@@ -347,15 +602,15 @@ set_target_properties(sphaira PROPERTIES
)
target_link_libraries(sphaira PRIVATE
ftpsrv_helper
libhaze
libpulsar
minIni
nanovg
stb
yyjson
# libusbhsfs
libnxtc
fatfs
dr_libs
libzstd_static
${minizip_lib}
ZLIB::ZLIB
@@ -363,24 +618,11 @@ target_link_libraries(sphaira PRIVATE
${mbedcrypto_lib}
)
if (USE_NEW_ZSTD)
message(STATUS "USING UPSTREAM ZSTD")
target_link_libraries(sphaira PRIVATE libzstd_static)
else()
message(STATUS "USING LOCAL ZSTD")
target_link_libraries(sphaira PRIVATE ${zstd_lib})
target_include_directories(sphaira PRIVATE ${zstd_inc})
endif()
if (USE_NVJPG)
target_link_libraries(sphaira PRIVATE nvjpg)
target_compile_definitions(sphaira PRIVATE USE_NVJPG)
endif()
target_include_directories(sphaira PRIVATE
include
${minizip_inc}
${mbedtls_inc}
include/yati/nx/nxdumptool
)
# copy the romfs

View File

@@ -2,13 +2,13 @@
#include "nanovg.h"
#include "nanovg/dk_renderer.hpp"
#include "pulsar.h"
#include "ui/widget.hpp"
#include "ui/notification.hpp"
#include "owo.hpp"
#include "option.hpp"
#include "fs.hpp"
#include "log.hpp"
#include "utils/audio.hpp"
#ifdef USE_NVJPG
#include <nvjpg.hpp>
@@ -18,19 +18,11 @@
#include <string>
#include <span>
#include <optional>
#include <utility>
namespace sphaira {
enum SoundEffect {
SoundEffect_Music,
SoundEffect_Focus,
SoundEffect_Scroll,
SoundEffect_Limit,
SoundEffect_Startup,
SoundEffect_Install,
SoundEffect_Error,
SoundEffect_MAX,
};
using SoundEffect = audio::SoundEffect;
enum class LaunchType {
Normal,
@@ -58,12 +50,19 @@ public:
static void Exit();
static void ExitRestart();
static auto GetVg() -> NVGcontext*;
static void Push(std::shared_ptr<ui::Widget>);
static void Push(std::unique_ptr<ui::Widget>&&);
template<ui::DerivedFromWidget T, typename... Args>
static void Push(Args&&... args) {
Push(std::make_unique<T>(std::forward<Args>(args)...));
}
// pops all widgets above a menu
static void PopToMenu();
// this is thread safe
static void Notify(std::string text, ui::NotifEntry::Side side = ui::NotifEntry::Side::RIGHT);
static void Notify(const std::string& text, ui::NotifEntry::Side side = ui::NotifEntry::Side::RIGHT);
static void Notify(ui::NotifEntry entry);
static void NotifyPop(ui::NotifEntry::Side side = ui::NotifEntry::Side::RIGHT);
static void NotifyClear(ui::NotifEntry::Side side = ui::NotifEntry::Side::RIGHT);
@@ -95,12 +94,14 @@ public:
static auto GetInstallSysmmcEnable() -> bool;
static auto GetInstallEmummcEnable() -> bool;
static auto GetInstallSdEnable() -> bool;
static auto GetInstallPrompt() -> bool;
static auto GetThemeMusicEnable() -> bool;
static auto Get12HourTimeEnable() -> bool;
static auto GetLanguage() -> long;
static auto GetTextScrollSpeed() -> long;
static auto GetNszCompressLevel() -> u8;
static auto GetNszThreadCount() -> u8;
static auto GetNszBlockExponent() -> u8;
static void SetMtpEnable(bool enable);
static void SetFtpEnable(bool enable);
static void SetNxlinkEnable(bool enable);
@@ -125,10 +126,18 @@ public:
static void DisplayThemeOptions(bool left_side = true);
// todo:
static void DisplayNetworkOptions(bool left_side = true);
static void DisplayMiscOptions(bool left_side = true);
static void DisplayMenuOptions(bool left_side = true);
static void DisplayAdvancedOptions(bool left_side = true);
static void DisplayInstallOptions(bool left_side = true);
static void DisplayDumpOptions(bool left_side = true);
static void DisplayFtpOptions(bool left_side = true);
static void DisplayMtpOptions(bool left_side = true);
static void DisplayHddOptions(bool left_side = true);
// helper for sidebar options to toggle install on/off
static void ShowEnableInstallPromptOption(option::OptionBool& option, bool& enable);
// displays an option box to enable installing, shows warning.
static void ShowEnableInstallPrompt();
void Draw();
void Update();
@@ -141,8 +150,15 @@ public:
void LoadTheme(const ThemeMeta& meta);
void CloseTheme();
void CloseThemeBackgroundMusic();
void ScanThemes(const std::string& path);
void ScanThemeEntries();
void LoadAndPlayThemeMusic();
static Result SetDefaultBackgroundMusic(fs::Fs* fs, const fs::FsPath& path);
static void SetBackgroundMusicPause(bool pause);
static Result GetSdSize(s64* free, s64* total);
static Result GetEmmcSize(s64* free, s64* total);
// helper that converts 1.2.3 to a u32 used for comparisons.
static auto GetVersionFromString(const char* str) -> u32;
@@ -256,11 +272,12 @@ public:
PadState m_pad{};
TouchInfo m_touch_info{};
Controller m_controller{};
KeyboardState m_keyboard{};
std::vector<ThemeMeta> m_theme_meta_entries;
Vec2 m_scale{1, 1};
std::vector<std::shared_ptr<ui::Widget>> m_widgets;
std::vector<std::unique_ptr<ui::Widget>> m_widgets;
u32 m_pop_count{};
ui::NotifMananger m_notif_manager{};
@@ -282,10 +299,12 @@ public:
option::OptionBool m_log_enabled{INI_SECTION, "log_enabled", false};
option::OptionBool m_replace_hbmenu{INI_SECTION, "replace_hbmenu", false};
option::OptionString m_default_music{INI_SECTION, "default_music", "/config/sphaira/themes/default_music.bfstm"};
option::OptionString m_theme_path{INI_SECTION, "theme", DEFAULT_THEME_PATH};
option::OptionBool m_theme_music{INI_SECTION, "theme_music", true};
option::OptionBool m_12hour_time{INI_SECTION, "12hour_time", false};
option::OptionBool m_show_ip_addr{INI_SECTION, "show_ip_addr", true};
option::OptionLong m_language{INI_SECTION, "language", 0}; // auto
option::OptionString m_center_menu{INI_SECTION, "center_side_menu", "Homebrew"};
option::OptionString m_left_menu{INI_SECTION, "left_side_menu", "FileBrowser"};
option::OptionString m_right_menu{INI_SECTION, "right_side_menu", "Appstore"};
option::OptionBool m_progress_boost_mode{INI_SECTION, "progress_boost_mode", true};
@@ -294,7 +313,6 @@ public:
option::OptionBool m_install_sysmmc{INI_SECTION, "install_sysmmc", false};
option::OptionBool m_install_emummc{INI_SECTION, "install_emummc", false};
option::OptionBool m_install_sd{INI_SECTION, "install_sd", true};
option::OptionLong m_install_prompt{INI_SECTION, "install_prompt", true};
option::OptionBool m_allow_downgrade{INI_SECTION, "allow_downgrade", false};
option::OptionBool m_skip_if_already_installed{INI_SECTION, "skip_if_already_installed", true};
option::OptionBool m_ticket_only{INI_SECTION, "ticket_only", false};
@@ -303,32 +321,76 @@ public:
option::OptionBool m_skip_addon{INI_SECTION, "skip_addon", false};
option::OptionBool m_skip_data_patch{INI_SECTION, "skip_data_patch", false};
option::OptionBool m_skip_ticket{INI_SECTION, "skip_ticket", false};
option::OptionBool m_skip_nca_hash_verify{INI_SECTION, "skip_nca_hash_verify", false};
option::OptionBool m_skip_rsa_header_fixed_key_verify{INI_SECTION, "skip_rsa_header_fixed_key_verify", false};
option::OptionBool m_skip_rsa_npdm_fixed_key_verify{INI_SECTION, "skip_rsa_npdm_fixed_key_verify", false};
option::OptionBool m_skip_nca_hash_verify{INI_SECTION, "skip_nca_hash_verify", true};
option::OptionBool m_skip_rsa_header_fixed_key_verify{INI_SECTION, "skip_rsa_header_fixed_key_verify", true};
option::OptionBool m_skip_rsa_npdm_fixed_key_verify{INI_SECTION, "skip_rsa_npdm_fixed_key_verify", true};
option::OptionBool m_ignore_distribution_bit{INI_SECTION, "ignore_distribution_bit", false};
option::OptionBool m_convert_to_common_ticket{INI_SECTION, "convert_to_common_ticket", true};
option::OptionBool m_convert_to_standard_crypto{INI_SECTION, "convert_to_standard_crypto", false};
option::OptionBool m_lower_master_key{INI_SECTION, "lower_master_key", false};
option::OptionBool m_lower_system_version{INI_SECTION, "lower_system_version", false};
option::OptionBool m_lower_system_version{INI_SECTION, "lower_system_version", true};
// dump options
option::OptionBool m_dump_app_folder{"dump", "app_folder", true};
option::OptionBool m_dump_append_folder_with_xci{"dump", "append_folder_with_xci", true};
option::OptionBool m_dump_trim_xci{"dump", "trim_xci", false};
option::OptionBool m_dump_label_trim_xci{"dump", "label_trim_xci", false};
option::OptionBool m_dump_usb_transfer_stream{"dump", "usb_transfer_stream", true};
option::OptionBool m_dump_convert_to_common_ticket{"dump", "convert_to_common_ticket", true};
option::OptionLong m_nsz_compress_level{"dump", "nsz_compress_level", 3};
option::OptionLong m_nsz_compress_threads{"dump", "nsz_compress_threads", 3};
option::OptionBool m_nsz_compress_ldm{"dump", "nsz_compress_ldm", true};
option::OptionBool m_nsz_compress_block{"dump", "nsz_compress_block", false};
option::OptionLong m_nsz_compress_block_exponent{"dump", "nsz_compress_block_exponent", 6};
// todo: move this into it's own menu
option::OptionLong m_text_scroll_speed{"accessibility", "text_scroll_speed", 1}; // normal
PLSR_PlayerSoundId m_sound_ids[SoundEffect_MAX]{};
// ftp options.
option::OptionLong m_ftp_port{"ftp", "port", 5000};
option::OptionBool m_ftp_anon{"ftp", "anon", true};
option::OptionString m_ftp_user{"ftp", "user", ""};
option::OptionString m_ftp_pass{"ftp", "pass", ""};
option::OptionBool m_ftp_show_album{"ftp", "show_album", true};
option::OptionBool m_ftp_show_ams_contents{"ftp", "show_ams_contents", false};
option::OptionBool m_ftp_show_bis_storage{"ftp", "show_bis_storage", false};
option::OptionBool m_ftp_show_bis_fs{"ftp", "show_bis_fs", false};
option::OptionBool m_ftp_show_content_system{"ftp", "show_content_system", false};
option::OptionBool m_ftp_show_content_user{"ftp", "show_content_user", false};
option::OptionBool m_ftp_show_content_sd{"ftp", "show_content_sd", false};
// option::OptionBool m_ftp_show_content_sd0{"ftp", "show_content_sd0", false};
// option::OptionBool m_ftp_show_custom_system{"ftp", "show_custom_system", false};
// option::OptionBool m_ftp_show_custom_sd{"ftp", "show_custom_sd", false};
option::OptionBool m_ftp_show_games{"ftp", "show_games", true};
option::OptionBool m_ftp_show_install{"ftp", "show_install", true};
option::OptionBool m_ftp_show_mounts{"ftp", "show_mounts", false};
option::OptionBool m_ftp_show_switch{"ftp", "show_switch", false};
// mtp options.
option::OptionLong m_mtp_vid{"mtp", "vid", 0x057e}; // nintendo (hidden from ui)
option::OptionLong m_mtp_pid{"mtp", "pid", 0x201d}; // switch (hidden from ui)
option::OptionBool m_mtp_allocate_file{"mtp", "allocate_file", true};
option::OptionBool m_mtp_show_album{"mtp", "show_album", true};
option::OptionBool m_mtp_show_content_sd{"mtp", "show_content_sd", false};
option::OptionBool m_mtp_show_content_system{"mtp", "show_content_system", false};
option::OptionBool m_mtp_show_content_user{"mtp", "show_content_user", false};
option::OptionBool m_mtp_show_games{"mtp", "show_games", true};
option::OptionBool m_mtp_show_install{"mtp", "show_install", true};
option::OptionBool m_mtp_show_mounts{"mtp", "show_mounts", false};
option::OptionBool m_mtp_show_speedtest{"mtp", "show_speedtest", false};
std::shared_ptr<fs::FsNativeSd> m_fs{};
audio::SongID m_background_music{};
#ifdef USE_NVJPG
nj::Decoder m_decoder;
#endif
double m_delta_time{};
static constexpr const char* INSTALL_DEPENDS_STR =
"Installing is disabled.\n\n"
"Enable in the options by selecting Menu (Y) -> Advanced -> Install options -> Enable.";
private: // from nanovg decko3d example by adubbz
static constexpr unsigned NumFramebuffers = 2;
static constexpr unsigned StaticCmdSize = 0x1000;

View File

@@ -511,7 +511,22 @@ enum class SphairaResult : Result {
FsNewPathEmpty,
FsLoadingCancelled,
FsBrokenRoot,
FsUnknownStdioError,
FsStdioFailedToSeek,
FsStdioFailedToRead,
FsStdioFailedToWrite,
FsStdioFailedToOpenFile,
FsStdioFailedToCreate,
FsStdioFailedToTruncate,
FsStdioFailedToFlush,
FsStdioFailedToCreateDirectory,
FsStdioFailedToDeleteFile,
FsStdioFailedToDeleteDirectory,
FsStdioFailedToOpenDirectory,
FsStdioFailedToRename,
FsStdioFailedToStat,
FsReadOnly,
FsNotActive,
FsFailedStdioStat,
@@ -537,6 +552,9 @@ enum class SphairaResult : Result {
ZipOpenNewFileInZip,
ZipWriteInFileInZip,
MmzBadLocalHeaderSig,
MmzBadLocalHeaderRead,
FileBrowserFailedUpload,
FileBrowserDirNotDaybreak,
@@ -574,8 +592,10 @@ enum class SphairaResult : Result {
UsbDsBadDeviceSpeed,
NcaBadMagic,
NspBadMagic,
XciBadMagic,
XciSecurePartitionNotFound,
EsBadTitleKeyType,
EsPersonalisedTicketDeviceIdMissmatch,
@@ -594,7 +614,10 @@ enum class SphairaResult : Result {
UsbBadMagic,
UsbBadVersion,
UsbBadCount,
UsbBadBufferAlign,
UsbBadTransferSize,
UsbEmptyTransferSize,
UsbOverflowTransferSize,
UsbBadTotalSize,
UsbUploadBadMagic,
@@ -641,6 +664,17 @@ enum class SphairaResult : Result {
YatiNcmDbCorruptHeader,
// unable to total infos from ncm database.
YatiNcmDbCorruptInfos,
NszFailedCreateCctx,
NszFailedSetCompressionLevel,
NszFailedSetThreadCount,
NszFailedSetLongDistanceMode,
NszFailedResetCctx,
NszFailedCompress2,
NszFailedCompressStream2,
NszTooManyBlocks,
// set when nca finished but not all blocks were handled.
NszMissingBlocks,
};
#define MAKE_SPHAIRA_RESULT_ENUM(x) Result_##x = MAKERESULT(Module_Sphaira, (Result)SphairaResult::x)
@@ -661,6 +695,19 @@ enum : Result {
MAKE_SPHAIRA_RESULT_ENUM(FsLoadingCancelled),
MAKE_SPHAIRA_RESULT_ENUM(FsBrokenRoot),
MAKE_SPHAIRA_RESULT_ENUM(FsUnknownStdioError),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToSeek),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToRead),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToWrite),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToOpenFile),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToCreate),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToTruncate),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToFlush),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToCreateDirectory),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToDeleteFile),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToDeleteDirectory),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToOpenDirectory),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToRename),
MAKE_SPHAIRA_RESULT_ENUM(FsStdioFailedToStat),
MAKE_SPHAIRA_RESULT_ENUM(FsReadOnly),
MAKE_SPHAIRA_RESULT_ENUM(FsNotActive),
MAKE_SPHAIRA_RESULT_ENUM(FsFailedStdioStat),
@@ -681,6 +728,8 @@ enum : Result {
MAKE_SPHAIRA_RESULT_ENUM(ZipOpen2_64),
MAKE_SPHAIRA_RESULT_ENUM(ZipOpenNewFileInZip),
MAKE_SPHAIRA_RESULT_ENUM(ZipWriteInFileInZip),
MAKE_SPHAIRA_RESULT_ENUM(MmzBadLocalHeaderSig),
MAKE_SPHAIRA_RESULT_ENUM(MmzBadLocalHeaderRead),
MAKE_SPHAIRA_RESULT_ENUM(FileBrowserFailedUpload),
MAKE_SPHAIRA_RESULT_ENUM(FileBrowserDirNotDaybreak),
MAKE_SPHAIRA_RESULT_ENUM(AppstoreFailedZipDownload),
@@ -708,8 +757,12 @@ enum : Result {
MAKE_SPHAIRA_RESULT_ENUM(ThemezerFailedToDownloadTheme),
MAKE_SPHAIRA_RESULT_ENUM(MainFailedToDownloadUpdate),
MAKE_SPHAIRA_RESULT_ENUM(UsbDsBadDeviceSpeed),
MAKE_SPHAIRA_RESULT_ENUM(NspBadMagic),
MAKE_SPHAIRA_RESULT_ENUM(XciBadMagic),
MAKE_SPHAIRA_RESULT_ENUM(NcaBadMagic),
MAKE_SPHAIRA_RESULT_ENUM(XciSecurePartitionNotFound),
MAKE_SPHAIRA_RESULT_ENUM(EsBadTitleKeyType),
MAKE_SPHAIRA_RESULT_ENUM(EsPersonalisedTicketDeviceIdMissmatch),
MAKE_SPHAIRA_RESULT_ENUM(EsFailedDecryptPersonalisedTicket),
@@ -719,19 +772,24 @@ enum : Result {
MAKE_SPHAIRA_RESULT_ENUM(EsInvalidTicketFromatVersion),
MAKE_SPHAIRA_RESULT_ENUM(EsInvalidTicketKeyType),
MAKE_SPHAIRA_RESULT_ENUM(EsInvalidTicketKeyRevision),
MAKE_SPHAIRA_RESULT_ENUM(OwoBadArgs),
MAKE_SPHAIRA_RESULT_ENUM(UsbCancelled),
MAKE_SPHAIRA_RESULT_ENUM(UsbBadMagic),
MAKE_SPHAIRA_RESULT_ENUM(UsbBadVersion),
MAKE_SPHAIRA_RESULT_ENUM(UsbBadCount),
MAKE_SPHAIRA_RESULT_ENUM(UsbBadBufferAlign),
MAKE_SPHAIRA_RESULT_ENUM(UsbBadTransferSize),
MAKE_SPHAIRA_RESULT_ENUM(UsbBadTotalSize),
MAKE_SPHAIRA_RESULT_ENUM(UsbEmptyTransferSize),
MAKE_SPHAIRA_RESULT_ENUM(UsbOverflowTransferSize),
MAKE_SPHAIRA_RESULT_ENUM(UsbUploadBadMagic),
MAKE_SPHAIRA_RESULT_ENUM(UsbUploadExit),
MAKE_SPHAIRA_RESULT_ENUM(UsbUploadBadCount),
MAKE_SPHAIRA_RESULT_ENUM(UsbUploadBadTransferSize),
MAKE_SPHAIRA_RESULT_ENUM(UsbUploadBadTotalSize),
MAKE_SPHAIRA_RESULT_ENUM(UsbUploadBadCommand),
MAKE_SPHAIRA_RESULT_ENUM(YatiContainerNotFound),
MAKE_SPHAIRA_RESULT_ENUM(YatiNcaNotFound),
MAKE_SPHAIRA_RESULT_ENUM(YatiInvalidNcaReadSize),
@@ -753,6 +811,16 @@ enum : Result {
MAKE_SPHAIRA_RESULT_ENUM(YatiCertNotFound),
MAKE_SPHAIRA_RESULT_ENUM(YatiNcmDbCorruptHeader),
MAKE_SPHAIRA_RESULT_ENUM(YatiNcmDbCorruptInfos),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedCreateCctx),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedSetCompressionLevel),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedSetThreadCount),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedSetLongDistanceMode),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedResetCctx),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedCompress2),
MAKE_SPHAIRA_RESULT_ENUM(NszFailedCompressStream2),
MAKE_SPHAIRA_RESULT_ENUM(NszTooManyBlocks),
MAKE_SPHAIRA_RESULT_ENUM(NszMissingBlocks),
};
#undef MAKE_SPHAIRA_RESULT_ENUM
@@ -783,21 +851,83 @@ enum : Result {
#define CONCATENATE(s1, s2) CONCATENATE_IMPL(s1, s2)
#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __COUNTER__)
#define ON_SCOPE_EXIT(_f) std::experimental::scope_exit ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){[&] { _f; }};
template<typename Function>
struct ScopeGuard {
ScopeGuard(Function&& function) : m_function(std::forward<Function>(function)) {
}
~ScopeGuard() {
m_function();
}
ScopeGuard(const ScopeGuard&) = delete;
void operator=(const ScopeGuard&) = delete;
private:
const Function m_function;
};
struct ScopedMutex {
ScopedMutex(Mutex* mutex) : m_mutex{mutex} {
mutexLock(m_mutex);
}
~ScopedMutex() {
mutexUnlock(m_mutex);
}
ScopedMutex(const ScopedMutex&) = delete;
void operator=(const ScopedMutex&) = delete;
private:
Mutex* const m_mutex;
};
struct ScopedRMutex {
ScopedRMutex(RMutex* _mutex) : mutex{_mutex} {
rmutexLock(mutex);
}
~ScopedRMutex() {
rmutexUnlock(mutex);
}
ScopedRMutex(const ScopedRMutex&) = delete;
void operator=(const ScopedRMutex&) = delete;
private:
RMutex* const mutex;
};
struct ScopedRwLock {
ScopedRwLock(RwLock* _lock, bool _write) : lock{_lock}, write{_write} {
if (write) {
rwlockWriteLock(lock);
} else {
rwlockReadLock(lock);
}
}
~ScopedRwLock() {
if (write) {
rwlockWriteUnlock(lock);
} else {
rwlockReadUnlock(lock);
}
}
ScopedRwLock(const ScopedRwLock&) = delete;
void operator=(const ScopedRwLock&) = delete;
private:
RwLock* const lock;
bool const write;
};
// #define ON_SCOPE_EXIT(_f) std::experimental::scope_exit ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){[&] { _f; }};
#define ON_SCOPE_EXIT(_f) ScopeGuard ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){[&] { _f; }};
#define SCOPED_MUTEX(_m) ScopedMutex ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){_m}
#define SCOPED_RMUTEX(_m) ScopedRMutex ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){_m}
#define SCOPED_RWLOCK(_m, _write) ScopedRwLock ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){_m, _write}
// #define ON_SCOPE_FAIL(_f) std::experimental::scope_exit ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){[&] { if (R_FAILED(rc)) { _f; } }};
// #define ON_SCOPE_SUCCESS(_f) std::experimental::scope_exit ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_){[&] { if (R_SUCCEEDED(rc)) { _f; } }};
// threading helpers.
#define PRIO_PREEMPTIVE 0x3B
// threading affinity, use with svcSetThreadCoreMask().
#define THREAD_AFFINITY_CORE0 BIT(0)
#define THREAD_AFFINITY_CORE1 BIT(1)
#define THREAD_AFFINITY_CORE2 BIT(2)
#define THREAD_AFFINITY_DEFAULT(core) (BIT(core)|THREAD_AFFINITY_CORE1|THREAD_AFFINITY_CORE2)
#define THREAD_AFFINITY_ALL (THREAD_AFFINITY_CORE0|THREAD_AFFINITY_CORE1|THREAD_AFFINITY_CORE2)
// mutex helpers.
#define SCOPED_MUTEX(mutex) \
mutexLock(mutex); \
ON_SCOPE_EXIT(mutexUnlock(mutex))

View File

@@ -52,7 +52,7 @@ struct Fields {
struct Header {
Header() = default;
Header(std::initializer_list<std::pair<const std::string, std::string>> p) : m_map{p} {}
Header(std::initializer_list<std::pair<const std::string, std::string>>&& p) : m_map{std::forward<decltype(p)>(p)} {}
std::unordered_map<std::string, std::string> m_map;
auto Find(const std::string& key) const {
@@ -91,7 +91,7 @@ struct UserPass {
struct UploadInfo {
UploadInfo() = default;
UploadInfo(const std::string& name) : m_name{name} {}
UploadInfo(const std::string& name, s64 size, OnUploadCallback cb) : m_name{name}, m_size{size}, m_callback{cb} {}
UploadInfo(const std::string& name, s64 size, const OnUploadCallback& cb) : m_name{name}, m_size{size}, m_callback{cb} {}
UploadInfo(const std::string& name, const std::vector<u8>& data) : m_name{name}, m_data{data} {}
std::string m_name{};
std::vector<u8> m_data{};
@@ -142,6 +142,7 @@ struct DownloadEventData {
auto Init() -> bool;
void Exit();
void ExitSignal();
// sync functions
auto ToMemory(const Api& e) -> ApiResult;

View File

@@ -2,33 +2,36 @@
#include "fs.hpp"
#include "location.hpp"
#include "ui/progress_box.hpp"
#include <switch.h>
#include <vector>
#include <memory>
#include <functional>
#include <minizip/ioapi.h>
namespace sphaira::dump {
enum DumpLocationType {
// dump using native fs.
DumpLocationType_SdCard,
// dump to usb pc.
DumpLocationType_Usb,
// dump to usb using tinfoil protocol.
DumpLocationType_UsbS2S,
// speed test, only reads the data, doesn't write anything.
DumpLocationType_DevNull,
// dump to stdio, ideal for custom mount points using devoptab, such as hdd.
DumpLocationType_Stdio,
// dump to custom locations found in locations.ini.
DumpLocationType_Network,
};
enum DumpLocationFlag {
DumpLocationFlag_SdCard = 1 << DumpLocationType_SdCard,
DumpLocationFlag_Usb = 1 << DumpLocationType_Usb,
DumpLocationFlag_UsbS2S = 1 << DumpLocationType_UsbS2S,
DumpLocationFlag_DevNull = 1 << DumpLocationType_DevNull,
DumpLocationFlag_Stdio = 1 << DumpLocationType_Stdio,
DumpLocationFlag_Network = 1 << DumpLocationType_Network,
DumpLocationFlag_All = DumpLocationFlag_SdCard | DumpLocationFlag_UsbS2S | DumpLocationFlag_DevNull | DumpLocationFlag_Stdio | DumpLocationFlag_Network,
DumpLocationFlag_All = DumpLocationFlag_SdCard | DumpLocationFlag_Usb | DumpLocationFlag_UsbS2S | DumpLocationFlag_DevNull | DumpLocationFlag_Stdio,
};
struct DumpEntry {
@@ -38,7 +41,6 @@ struct DumpEntry {
struct DumpLocation {
DumpEntry entry{};
location::Entries network{};
location::StdioEntries stdio{};
};
@@ -48,17 +50,36 @@ struct BaseSource {
virtual auto GetName(const std::string& path) const -> std::string = 0;
virtual auto GetSize(const std::string& path) const -> s64 = 0;
virtual auto GetIcon(const std::string& path) const -> int { return 0; }
Result Read(const std::string& path, void* buf, s64 off, s64 size) {
u64 bytes_read;
return Read(path, buf, off, size, &bytes_read);
}
};
struct WriteSource {
virtual ~WriteSource() = default;
virtual Result Write(const void* buf, s64 off, s64 size) = 0;
virtual Result SetSize(s64 size) = 0;
};
// called after dump has finished.
using OnExit = std::function<void(Result rc)>;
using OnLocation = std::function<void(const DumpLocation& loc)>;
using CustomTransfer = std::function<Result(ui::ProgressBox* pbox, BaseSource* source, WriteSource* writer, const fs::FsPath& path)>;
// prompts the user to select dump location, calls on_loc on success with the selected location.
void DumpGetLocation(const std::string& title, u32 location_flags, OnLocation on_loc);
void DumpGetLocation(const std::string& title, u32 location_flags, const OnLocation& on_loc, const CustomTransfer& custom_transfer = nullptr);
Result Dump(ui::ProgressBox* pbox, const std::shared_ptr<BaseSource>& source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, const CustomTransfer& custom_transfer = nullptr);
// dumps to a fetched location using DumpGetLocation().
void Dump(std::shared_ptr<BaseSource> source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, OnExit on_exit);
void Dump(const std::shared_ptr<BaseSource>& source, const DumpLocation& location, const std::vector<fs::FsPath>& paths, const OnExit& on_exit, const CustomTransfer& custom_transfer = nullptr);
// DumpGetLocation() + Dump() all in one.
void Dump(std::shared_ptr<BaseSource> source, const std::vector<fs::FsPath>& paths, OnExit on_exit = [](Result){}, u32 location_flags = DumpLocationFlag_All);
void Dump(const std::shared_ptr<BaseSource>& source, const std::vector<fs::FsPath>& paths, const OnExit& on_exit = nullptr, u32 location_flags = DumpLocationFlag_All);
void Dump(const std::shared_ptr<BaseSource>& source, const std::vector<fs::FsPath>& paths, const CustomTransfer& custom_transfer, const OnExit& on_exit = nullptr, u32 location_flags = DumpLocationFlag_All);
void FileFuncWriter(WriteSource* writer, zlib_filefunc64_def* funcs);
} // namespace sphaira::dump

View File

@@ -4,12 +4,26 @@
#include <dirent.h>
#include <cstring>
#include <vector>
#include <span>
#include <string>
#include <string_view>
#include <sys/syslimits.h>
#include "defines.hpp"
namespace fs {
enum OpenMode : u32 {
OpenMode_Read = FsOpenMode_Read,
OpenMode_Write = FsOpenMode_Write,
OpenMode_Append = FsOpenMode_Append,
// enables buffering for stdio based files.
OpenMode_EnableBuffer = 1 << 16,
OpenMode_ReadBuffered = OpenMode_Read | OpenMode_EnableBuffer,
OpenMode_WriteBuffered = OpenMode_Write | OpenMode_EnableBuffer,
OpenMode_AppendBuffered = OpenMode_Append | OpenMode_EnableBuffer,
};
struct FsPath {
FsPath() = default;
@@ -44,10 +58,6 @@ struct FsPath {
return s;
}
constexpr auto starts_with(std::string_view str) const -> bool {
return !strncasecmp(s, str.data(), str.length());
}
constexpr auto empty() const {
return s[0] == '\0';
}
@@ -64,6 +74,19 @@ struct FsPath {
s[0] = '\0';
}
constexpr auto starts_with(std::string_view str) const -> bool {
return !strncasecmp(s, str.data(), str.length());
}
constexpr auto ends_with(std::string_view str) const -> bool {
const auto len = length();
if (len < str.length()) {
return false;
}
return !strncasecmp(s + len - str.length(), str.data(), str.length());
}
constexpr operator const char*() const { return s; }
constexpr operator char*() { return s; }
constexpr operator std::string() { return s; }
@@ -129,20 +152,24 @@ struct FsPath {
return *this;
}
static constexpr bool path_equal(std::string_view a, std::string_view b) {
return a.length() == b.length() && !strncasecmp(a.data(), b.data(), a.length());
}
constexpr bool operator==(const FsPath& v) const noexcept {
return !strcasecmp(*this, v);
return path_equal(*this, v);
}
constexpr bool operator==(const char* v) const noexcept {
return !strcasecmp(*this, v);
return path_equal(*this, v);
}
constexpr bool operator==(const std::string& v) const noexcept {
return !strncasecmp(*this, v.data(), v.length());
return path_equal(*this, v);
}
constexpr bool operator==(const std::string_view v) const noexcept {
return !strncasecmp(*this, v.data(), v.length());
return path_equal(*this, v);
}
static consteval bool Test(const auto& str) {
@@ -155,7 +182,7 @@ struct FsPath {
return path[0] == str[0];
}
char s[FS_MAX_PATH]{};
char s[PATH_MAX]{};
};
inline FsPath operator+(const char* v, const FsPath& fp) {
@@ -173,15 +200,41 @@ inline FsPath operator+(const std::string_view& v, const FsPath& fp) {
return r += fp;
}
static_assert(FsPath::Test("abc"));
static_assert(FsPath::Test(std::string_view{"abc"}));
static_assert(FsPath::Test(std::string{"abc"}));
static_assert(FsPath::Test(FsPath{"abc"}));
// Fs seems to be limted to file paths of 255 characters.
// i've disabled this as network mounts will often have very long paths
// that do not have this limit.
// a proper fix would be to return an error if the path is too long and the path
// is native.
struct FsPathReal {
static constexpr inline size_t FS_REAL_MAX_LENGTH = PATH_MAX;
static_assert(FsPath::TestFrom("abc"));
static_assert(FsPath::TestFrom(std::string_view{"abc"}));
static_assert(FsPath::TestFrom(std::string{"abc"}));
static_assert(FsPath::TestFrom(FsPath{"abc"}));
constexpr FsPathReal(const FsPath& str) : FsPathReal{str.s} { }
explicit constexpr FsPathReal(const char* str) {
size_t real = 0;
for (size_t i = 0; str[i]; i++) {
// skip multiple slashes.
if (i && str[i] == '/' && str[i - 1] == '/') {
continue;
}
// save single char.
s[real++] = str[i];
// check if we have exceeded the path.
if (real >= FS_REAL_MAX_LENGTH) {
break;
}
}
// null the end.
s[real] = '\0';
}
constexpr operator const char*() const { return s; }
constexpr operator std::string_view() const { return s; }
char s[PATH_MAX];
};
// fwd
struct Fs;
@@ -198,7 +251,6 @@ struct File {
fs::Fs* m_fs{};
FsFile m_native{};
std::FILE* m_stdio{};
s64 m_stdio_off{};
u32 m_mode{};
};
@@ -218,44 +270,38 @@ struct Dir {
FsPath AppendPath(const fs::FsPath& root_path, const fs::FsPath& file_path);
Result CreateFile(FsFileSystem* fs, const FsPath& path, u64 size = 0, u32 option = 0, bool ignore_read_only = true);
Result CreateDirectory(FsFileSystem* fs, const FsPath& path, bool ignore_read_only = true);
Result CreateFile(FsFileSystem* fs, const FsPathReal& path, u64 size = 0, u32 option = 0, bool ignore_read_only = true);
Result CreateDirectory(FsFileSystem* fs, const FsPathReal& path, bool ignore_read_only = true);
Result CreateDirectoryRecursively(FsFileSystem* fs, const FsPath& path, bool ignore_read_only = true);
Result CreateDirectoryRecursivelyWithPath(FsFileSystem* fs, const FsPath& path, bool ignore_read_only = true);
Result DeleteFile(FsFileSystem* fs, const FsPath& path, bool ignore_read_only = true);
Result DeleteDirectory(FsFileSystem* fs, const FsPath& path, bool ignore_read_only = true);
Result DeleteDirectoryRecursively(FsFileSystem* fs, const FsPath& path, bool ignore_read_only = true);
Result RenameFile(FsFileSystem* fs, const FsPath& src, const FsPath& dst, bool ignore_read_only = true);
Result RenameDirectory(FsFileSystem* fs, const FsPath& src, const FsPath& dst, bool ignore_read_only = true);
Result GetEntryType(FsFileSystem* fs, const FsPath& path, FsDirEntryType* out);
Result GetFileTimeStampRaw(FsFileSystem* fs, const FsPath& path, FsTimeStampRaw *out);
Result SetTimestamp(FsFileSystem* fs, const FsPath& path, const FsTimeStampRaw* ts);
Result DeleteFile(FsFileSystem* fs, const FsPathReal& path, bool ignore_read_only = true);
Result DeleteDirectory(FsFileSystem* fs, const FsPathReal& path, bool ignore_read_only = true);
Result DeleteDirectoryRecursively(FsFileSystem* fs, const FsPathReal& path, bool ignore_read_only = true);
Result RenameFile(FsFileSystem* fs, const FsPathReal& src, const FsPathReal& dst, bool ignore_read_only = true);
Result RenameDirectory(FsFileSystem* fs, const FsPathReal& src, const FsPathReal& dst, bool ignore_read_only = true);
Result GetEntryType(FsFileSystem* fs, const FsPathReal& path, FsDirEntryType* out);
Result GetFileTimeStampRaw(FsFileSystem* fs, const FsPathReal& path, FsTimeStampRaw *out);
Result SetTimestamp(FsFileSystem* fs, const FsPathReal& path, const FsTimeStampRaw* ts);
bool FileExists(FsFileSystem* fs, const FsPath& path);
bool DirExists(FsFileSystem* fs, const FsPath& path);
Result read_entire_file(FsFileSystem* fs, const FsPath& path, std::vector<u8>& out);
Result write_entire_file(FsFileSystem* fs, const FsPath& path, const std::vector<u8>& in, bool ignore_read_only = true);
Result copy_entire_file(FsFileSystem* fs, const FsPath& dst, const FsPath& src, bool ignore_read_only = true);
Result CreateFile(const FsPath& path, u64 size = 0, u32 option = 0, bool ignore_read_only = true);
Result CreateDirectory(const FsPath& path, bool ignore_read_only = true);
Result CreateFile(const FsPathReal& path, u64 size = 0, u32 option = 0, bool ignore_read_only = true);
Result CreateDirectory(const FsPathReal& path, bool ignore_read_only = true);
Result CreateDirectoryRecursively(const FsPath& path, bool ignore_read_only = true);
Result CreateDirectoryRecursivelyWithPath(const FsPath& path, bool ignore_read_only = true);
Result DeleteFile(const FsPath& path, bool ignore_read_only = true);
Result DeleteDirectory(const FsPath& path, bool ignore_read_only = true);
Result DeleteFile(const FsPathReal& path, bool ignore_read_only = true);
Result DeleteDirectory(const FsPathReal& path, bool ignore_read_only = true);
Result DeleteDirectoryRecursively(const FsPath& path, bool ignore_read_only = true);
Result RenameFile(const FsPath& src, const FsPath& dst, bool ignore_read_only = true);
Result RenameDirectory(const FsPath& src, const FsPath& dst, bool ignore_read_only = true);
Result GetEntryType(const FsPath& path, FsDirEntryType* out);
Result GetFileTimeStampRaw(const FsPath& path, FsTimeStampRaw *out);
Result SetTimestamp(const FsPath& path, const FsTimeStampRaw* ts);
Result RenameFile(const FsPathReal& src, const FsPathReal& dst, bool ignore_read_only = true);
Result RenameDirectory(const FsPathReal& src, const FsPathReal& dst, bool ignore_read_only = true);
Result GetEntryType(const FsPathReal& path, FsDirEntryType* out);
Result GetFileTimeStampRaw(const FsPathReal& path, FsTimeStampRaw *out);
Result SetTimestamp(const FsPathReal& path, const FsTimeStampRaw* ts);
bool FileExists(const FsPath& path);
bool DirExists(const FsPath& path);
Result read_entire_file(const FsPath& path, std::vector<u8>& out);
Result write_entire_file(const FsPath& path, const std::vector<u8>& in, bool ignore_read_only = true);
Result copy_entire_file(const FsPath& dst, const FsPath& src, bool ignore_read_only = true);
Result OpenFile(fs::Fs* fs, const fs::FsPath& path, u32 mode, File* f);
Result OpenDirectory(fs::Fs* fs, const fs::FsPath& path, u32 mode, Dir* d);
Result OpenFile(fs::Fs* fs, const FsPathReal& path, u32 mode, File* f);
Result OpenDirectory(fs::Fs* fs, const FsPathReal& path, u32 mode, Dir* d);
// opens dir, fetches count for all entries.
// NOTE: this function will be slow on non-native fs, due to multiple
@@ -272,6 +318,11 @@ Result DirGetEntryCount(fs::Fs* fs, const fs::FsPath& path, s64* file_count, s64
Result FileGetSizeAndTimestamp(fs::Fs* fs, const FsPath& path, FsTimeStampRaw* ts, s64* size);
Result IsDirEmpty(fs::Fs* m_fs, const fs::FsPath& path, bool* out);
// helpers.
Result read_entire_file(Fs* fs, const FsPath& path, std::vector<u8>& out);
Result write_entire_file(Fs* fs, const FsPath& path, std::span<const u8> in, bool ignore_read_only = true);
Result copy_entire_file(Fs* fs, const FsPath& dst, const FsPath& src, bool ignore_read_only = true);
struct Fs {
Fs(bool ignore_read_only = true) : m_ignore_read_only{ignore_read_only} {}
virtual ~Fs() = default;
@@ -292,10 +343,8 @@ struct Fs {
virtual bool FileExists(const FsPath& path) = 0;
virtual bool DirExists(const FsPath& path) = 0;
virtual bool IsNative() const = 0;
virtual bool IsSd() const { return false; }
virtual FsPath Root() const { return "/"; }
virtual Result read_entire_file(const FsPath& path, std::vector<u8>& out) = 0;
virtual Result write_entire_file(const FsPath& path, const std::vector<u8>& in) = 0;
virtual Result copy_entire_file(const FsPath& dst, const FsPath& src) = 0;
Result OpenFile(const fs::FsPath& path, u32 mode, File* f) {
return fs::OpenFile(this, path, mode, f);
@@ -315,6 +364,15 @@ struct Fs {
Result IsDirEmpty(const fs::FsPath& path, bool* out) {
return fs::IsDirEmpty(this, path, out);
}
Result read_entire_file(const FsPath& path, std::vector<u8>& out) {
return fs::read_entire_file(this, path, out);
}
Result write_entire_file(const FsPath& path, std::span<const u8> in) {
return fs::write_entire_file(this, path, in, m_ignore_read_only);
}
Result copy_entire_file(const FsPath& dst, const FsPath& src) {
return fs::copy_entire_file(this, dst, src, m_ignore_read_only);
}
void SetIgnoreReadOnly(bool enable) {
m_ignore_read_only = enable;
@@ -379,15 +437,6 @@ struct FsStdio : Fs {
FsPath Root() const override {
return m_root;
}
Result read_entire_file(const FsPath& path, std::vector<u8>& out) override {
return fs::read_entire_file(path, out);
}
Result write_entire_file(const FsPath& path, const std::vector<u8>& in) override {
return fs::write_entire_file(path, in, m_ignore_read_only);
}
Result copy_entire_file(const FsPath& dst, const FsPath& src) override {
return fs::copy_entire_file(dst, src, m_ignore_read_only);
}
const FsPath m_root;
};
@@ -466,19 +515,10 @@ struct FsNative : Fs {
bool IsNative() const override {
return true;
}
Result read_entire_file(const FsPath& path, std::vector<u8>& out) override {
return fs::read_entire_file(&m_fs, path, out);
}
Result write_entire_file(const FsPath& path, const std::vector<u8>& in) override {
return fs::write_entire_file(&m_fs, path, in, m_ignore_read_only);
}
Result copy_entire_file(const FsPath& dst, const FsPath& src) override {
return fs::copy_entire_file(&m_fs, dst, src, m_ignore_read_only);
}
FsFileSystem m_fs{};
Result m_open_result{};
bool m_own{true};
const bool m_own{true};
};
#if 0
@@ -492,6 +532,8 @@ struct FsNativeSd final : FsNative {
FsNativeSd(bool ignore_read_only = true) : FsNative{fsdevGetDeviceFileSystem("sdmc:"), false, ignore_read_only} {
m_open_result = 0;
}
bool IsSd() const override { return true; }
};
#endif
@@ -533,4 +575,10 @@ struct FsNativeSave final : FsNative {
}
};
struct FsNativeId final : FsNative {
FsNativeId(u64 program_id, FsFileSystemType type, const FsPath& path, FsContentAttributes attr = FsContentAttributes_All) {
m_open_result = fsOpenFileSystemWithId(&m_fs, program_id, type, path, attr);
}
};
} // namespace fs

View File

@@ -6,12 +6,13 @@ namespace sphaira::ftpsrv {
bool Init();
void Exit();
void ExitSignal();
using OnInstallStart = std::function<bool(const char* path)>;
using OnInstallWrite = std::function<bool(const void* buf, size_t size)>;
using OnInstallClose = std::function<void()>;
void InitInstallMode(OnInstallStart on_start, OnInstallWrite on_write, OnInstallClose on_close);
void InitInstallMode(const OnInstallStart& on_start, const OnInstallWrite& on_write, const OnInstallClose& on_close);
void DisableInstallMode();
unsigned GetPort();

View File

@@ -14,6 +14,7 @@ enum class Type {
Md5,
Sha1,
Sha256,
Null,
};
struct BaseSource {
@@ -25,7 +26,7 @@ struct BaseSource {
auto GetTypeStr(Type type) -> const char*;
// returns the hash string.
Result Hash(ui::ProgressBox* pbox, Type type, std::shared_ptr<BaseSource> source, std::string& out);
Result Hash(ui::ProgressBox* pbox, Type type, BaseSource* source, std::string& out);
Result Hash(ui::ProgressBox* pbox, Type type, fs::Fs* fs, const fs::FsPath& path, std::string& out);
Result Hash(ui::ProgressBox* pbox, Type type, std::span<const u8> data, std::string& out);

View File

@@ -2,16 +2,17 @@
#include <functional>
namespace sphaira::haze {
namespace sphaira::libhaze {
bool Init();
bool IsInit();
void Exit();
using OnInstallStart = std::function<bool(const char* path)>;
using OnInstallWrite = std::function<bool(const void* buf, size_t size)>;
using OnInstallClose = std::function<void()>;
void InitInstallMode(OnInstallStart on_start, OnInstallWrite on_write, OnInstallClose on_close);
void InitInstallMode(const OnInstallStart& on_start, const OnInstallWrite& on_write, const OnInstallClose& on_close);
void DisableInstallMode();
} // namespace sphaira::haze
} // namespace sphaira::libhaze

View File

@@ -5,10 +5,21 @@
namespace sphaira::i18n {
enum class WordOrder {
PhraseName, // default: SVO (English, French, German, etc.)
NamePhrase // SOV (Japanese, Korean)
};
bool init(long index);
void exit();
std::string get(std::string_view str);
std::string get(std::string_view str, std::string_view fallback);
WordOrder GetWordOrder();
bool WordOrderLocale();
std::string Reorder(std::string_view phrase, std::string_view name);
} // namespace sphaira::i18n

View File

@@ -3,23 +3,13 @@
#include <string>
#include <vector>
#include <switch.h>
// to import FsEntryFlags.
// todo: this should be part of a smaller header, such as filesystem_types.hpp
#include "ui/menus/filebrowser.hpp"
namespace sphaira::location {
struct Entry {
std::string name{};
std::string url{};
std::string user{};
std::string pass{};
std::string bearer{};
std::string pub_key{};
std::string priv_key{};
u16 port{};
};
using Entries = std::vector<Entry>;
auto Load() -> Entries;
void Add(const Entry& e);
using FsEntryFlag = ui::menu::filebrowser::FsEntryFlag;
// helper for hdd devices.
// this doesn't really belong in this header, however
@@ -29,8 +19,14 @@ struct StdioEntry {
std::string mount{};
// ums0: (USB Flash Disk)
std::string name{};
// set if read-only.
bool write_protect;
// FsEntryFlag
u32 flags{};
// optional dump path inside the mount point.
std::string dump_path{};
// set to hide for filebrowser.
bool fs_hidden{};
// set to hide in dump list.
bool dump_hidden{};
};
using StdioEntries = std::vector<StdioEntry>;

View File

@@ -4,6 +4,7 @@
#include <vector>
#include <span>
#include <switch.h>
#include "fs.hpp"
namespace sphaira::mz {
@@ -20,5 +21,12 @@ struct MzSpan {
void FileFuncMem(MzMem* mem, zlib_filefunc64_def* funcs);
void FileFuncSpan(MzSpan* span, zlib_filefunc64_def* funcs);
void FileFuncStdio(zlib_filefunc64_def* funcs);
void FileFuncNative(zlib_filefunc64_def* funcs);
// minizip takes 18ms to open a zip and 4ms to parse the first file entry.
// this results in a dropped frame.
// this version simply reads the local header + file name in 2 reads,
// which takes 1-2ms.
Result PeekFirstFileName(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& name);
} // namespace sphaira::mz

View File

@@ -9,8 +9,14 @@
namespace sphaira {
struct NroData {
NroStart start;
NroHeader header;
};
struct Hbini {
u64 timestamp{}; // timestamp of last launch
bool hidden{};
};
struct MiniNacp {
@@ -61,7 +67,7 @@ auto nro_parse(const fs::FsPath& path, NroEntry& entry) -> Result;
* nro found.
* this does nothing if nested=false.
*/
auto nro_scan(const fs::FsPath& path, std::vector<NroEntry>& nros, bool hide_spahira, bool nested = true, bool scan_all_dir = true) -> Result;
auto nro_scan(const fs::FsPath& path, std::vector<NroEntry>& nros, bool nested = true, bool scan_all_dir = true) -> Result;
auto nro_get_icon(const fs::FsPath& path, u64 size, u64 offset) -> std::vector<u8>;
auto nro_get_icon(const fs::FsPath& path) -> std::vector<u8>;

View File

@@ -44,6 +44,9 @@ bool nxlinkInitialize(NxlinkCallback callback);
// signal for the event to close and then join the thread.
void nxlinkExit();
// async the exit, call this first and then call exit later to avoid blocking.
void nxlinkSignalExit();
#ifdef __cplusplus
}
#endif

View File

@@ -7,10 +7,11 @@ namespace sphaira::option {
template<typename T>
struct OptionBase {
OptionBase(const std::string& section, const std::string& name, T default_value)
OptionBase(const std::string& section, const std::string& name, T default_value, bool file = true)
: m_section{section}
, m_name{name}
, m_default_value{default_value}
, m_file{file}
{}
auto Get() -> T;
@@ -29,11 +30,13 @@ private:
const std::string m_section;
const std::string m_name;
const T m_default_value;
const bool m_file;
std::optional<T> m_value;
};
using OptionBool = OptionBase<bool>;
using OptionLong = OptionBase<long>;
using OptionFloat = OptionBase<float>;
using OptionString = OptionBase<std::string>;
} // namespace sphaira::option

View File

@@ -2,10 +2,11 @@
#include <switch.h>
#include <string>
#include <sys/syslimits.h>
namespace sphaira::swkbd {
Result ShowText(std::string& out, const char* guide = nullptr, const char* initial = nullptr, s64 len_min = -1, s64 len_max = FS_MAX_PATH);
Result ShowNumPad(s64& out, const char* guide = nullptr, const char* initial = nullptr, s64 len_min = -1, s64 len_max = FS_MAX_PATH);
Result ShowText(std::string& out, const char* header = nullptr, const char* guide = nullptr, const char* initial = nullptr, s64 len_min = -1, s64 len_max = PATH_MAX);
Result ShowNumPad(s64& out, const char* header = nullptr, const char* guide = nullptr, const char* initial = nullptr, s64 len_min = -1, s64 len_max = PATH_MAX);
} // namespace sphaira::swkbd

View File

@@ -15,7 +15,10 @@ enum class Mode {
SingleThreadedIfSmaller,
};
using DecompressWriteCallback = std::function<Result(const void* data, s64 size)>;
using ReadCallback = std::function<Result(void* data, s64 off, s64 size, u64* bytes_read)>;
using DecompressCallback = std::function<Result(void* data, s64 off, s64 size, const DecompressWriteCallback& callback)>;
using WriteCallback = std::function<Result(const void* data, s64 off, s64 size)>;
// used for pull api
@@ -32,11 +35,12 @@ using StartCallback = std::function<Result(PullCallback pull)>;
using StartCallback2 = std::function<Result(StartThreadCallback start, PullCallback pull)>;
// reads data from rfunc into wfunc.
Result Transfer(ui::ProgressBox* pbox, s64 size, ReadCallback rfunc, WriteCallback wfunc, Mode mode = Mode::MultiThreaded);
Result Transfer(ui::ProgressBox* pbox, s64 size, const ReadCallback& rfunc, const WriteCallback& wfunc, Mode mode = Mode::MultiThreaded);
Result Transfer(ui::ProgressBox* pbox, s64 size, const ReadCallback& rfunc, const DecompressCallback& dfunc, const WriteCallback& wfunc, Mode mode = Mode::MultiThreaded);
// reads data from rfunc, pull data from provided pull() callback.
Result TransferPull(ui::ProgressBox* pbox, s64 size, ReadCallback rfunc, StartCallback sfunc, Mode mode = Mode::MultiThreaded);
Result TransferPull(ui::ProgressBox* pbox, s64 size, ReadCallback rfunc, StartCallback2 sfunc, Mode mode = Mode::MultiThreaded);
Result TransferPull(ui::ProgressBox* pbox, s64 size, const ReadCallback& rfunc, const StartCallback& sfunc, Mode mode = Mode::MultiThreaded);
Result TransferPull(ui::ProgressBox* pbox, s64 size, const ReadCallback& rfunc, const StartCallback2& sfunc, Mode mode = Mode::MultiThreaded);
// helper for extract zips.
// this will multi-thread unzip if size >= 512KiB, otherwise it'll single pass.
@@ -50,7 +54,7 @@ using UnzipAllFilter = std::function<bool(const fs::FsPath& name, fs::FsPath& pa
// helper all-in-one unzip function that unzips a zip (either open or path provided).
// the filter function can be used to modify the path and filter out unwanted files.
Result TransferUnzipAll(ui::ProgressBox* pbox, void* zfile, fs::Fs* fs, const fs::FsPath& base_path, UnzipAllFilter filter = nullptr, Mode mode = Mode::SingleThreadedIfSmaller);
Result TransferUnzipAll(ui::ProgressBox* pbox, const fs::FsPath& zip_out, fs::Fs* fs, const fs::FsPath& base_path, UnzipAllFilter filter = nullptr, Mode mode = Mode::SingleThreadedIfSmaller);
Result TransferUnzipAll(ui::ProgressBox* pbox, void* zfile, fs::Fs* fs, const fs::FsPath& base_path, const UnzipAllFilter& filter = nullptr, Mode mode = Mode::SingleThreadedIfSmaller);
Result TransferUnzipAll(ui::ProgressBox* pbox, const fs::FsPath& zip_out, fs::Fs* fs, const fs::FsPath& base_path, const UnzipAllFilter& filter = nullptr, Mode mode = Mode::SingleThreadedIfSmaller);
} // namespace sphaira::thread

View File

@@ -0,0 +1,83 @@
#pragma once
#include "fs.hpp"
#include <optional>
#include <span>
#include <vector>
#include <memory>
#include <functional>
#include <switch.h>
namespace sphaira::title {
constexpr u32 ContentMetaTypeToContentFlag(u8 meta_type) {
if (meta_type & 0x80) {
return 1 << (meta_type - 0x80);
}
return 0;
}
enum ContentFlag {
ContentFlag_Application = ContentMetaTypeToContentFlag(NcmContentMetaType_Application),
ContentFlag_Patch = ContentMetaTypeToContentFlag(NcmContentMetaType_Patch),
ContentFlag_AddOnContent = ContentMetaTypeToContentFlag(NcmContentMetaType_AddOnContent),
ContentFlag_DataPatch = ContentMetaTypeToContentFlag(NcmContentMetaType_DataPatch),
// nca locations where a control.nacp can exist.
ContentFlag_Nacp = ContentFlag_Application | ContentFlag_Patch,
// all of the above.
ContentFlag_All = ContentFlag_Application | ContentFlag_Patch | ContentFlag_AddOnContent | ContentFlag_DataPatch,
};
enum class NacpLoadStatus {
// not yet attempted to be loaded.
None,
// started loading.
Progress,
// loaded, ready to parse.
Loaded,
// failed to load, do not attempt to load again!
Error,
};
struct ThreadResultData {
u64 id{};
std::vector<u8> icon;
NacpLanguageEntry lang{};
NacpLoadStatus status{NacpLoadStatus::None};
};
using MetaEntries = std::vector<NsApplicationContentMetaStatus>;
// starts background thread (ref counted).
Result Init();
// closes the background thread.
void Exit();
// clears cache and empties the result array.
void Clear();
// adds new entry to queue.
void PushAsync(u64 app_id);
void PushAsync(const std::span<const NsApplicationRecord> app_ids);
// gets entry without removing it from the queue.
auto GetAsync(u64 app_id) -> ThreadResultData*;
// single threaded title info fetch.
auto Get(u64 app_id, bool* cached = nullptr) -> ThreadResultData*;
auto GetNcmCs(u8 storage_id) -> NcmContentStorage&;
auto GetNcmDb(u8 storage_id) -> NcmContentMetaDatabase&;
// gets all meta entries for an id.
Result GetMetaEntries(u64 id, MetaEntries& out, u32 flags = ContentFlag_All);
// returns the nca path of a control nca.
Result GetControlPathFromStatus(const NsApplicationContentMetaStatus& status, u64* out_program_id, fs::FsPath* out_path);
// taken from nxdumptool.
void utilsReplaceIllegalCharacters(char *str, bool ascii_only);
// /atmosphere/contents/xxx
auto GetContentsPath(u64 app_id) -> fs::FsPath;
} // namespace sphaira::title

View File

@@ -17,6 +17,7 @@ private:
std::optional<Result> m_code{};
std::string m_message{};
std::string m_code_message{};
std::string m_code_module{};
};
} // namespace sphaira::ui

View File

@@ -10,14 +10,14 @@ struct List final : Object {
GRID,
};
using Callback = std::function<void(NVGcontext* vg, Theme* theme, Vec4 v, s64 index)>;
using Callback = std::function<void(NVGcontext* vg, Theme* theme, const Vec4& v, s64 index)>;
using TouchCallback = std::function<void(bool touch, s64 index)>;
List(s64 row, s64 page, const Vec4& pos, const Vec4& v, const Vec2& pad = {});
void OnUpdate(Controller* controller, TouchInfo* touch, s64 index, s64 count, TouchCallback callback);
void OnUpdate(Controller* controller, TouchInfo* touch, s64 index, s64 count, const TouchCallback& callback);
void Draw(NVGcontext* vg, Theme* theme, s64 count, Callback callback) const;
void Draw(NVGcontext* vg, Theme* theme, s64 count, const Callback& callback) const;
auto SetScrollBarPos(float x, float y, float h) {
m_scrollbar.x = x;
@@ -73,10 +73,10 @@ private:
auto ClampX(float x, s64 count) const -> float;
auto ClampY(float y, s64 count) const -> float;
void OnUpdateHome(Controller* controller, TouchInfo* touch, s64 index, s64 count, TouchCallback callback);
void OnUpdateGrid(Controller* controller, TouchInfo* touch, s64 index, s64 count, TouchCallback callback);
void DrawHome(NVGcontext* vg, Theme* theme, s64 count, Callback callback) const;
void DrawGrid(NVGcontext* vg, Theme* theme, s64 count, Callback callback) const;
void OnUpdateHome(Controller* controller, TouchInfo* touch, s64 index, s64 count, const TouchCallback& callback);
void OnUpdateGrid(Controller* controller, TouchInfo* touch, s64 index, s64 count, const TouchCallback& callback);
void DrawHome(NVGcontext* vg, Theme* theme, s64 count, const Callback& callback) const;
void DrawGrid(NVGcontext* vg, Theme* theme, s64 count, const Callback& callback) const;
private:
const s64 m_row;

View File

@@ -86,14 +86,16 @@ struct EntryMenu final : MenuBase {
private:
struct Option {
Option(const std::string& dt, const std::string& ct, std::function<void(void)> f)
using Callback = std::function<void(void)>;
Option(const std::string& dt, const std::string& ct, const Callback& f)
: display_text{dt}, confirm_text{ct}, func{f} {}
Option(const std::string& dt, std::function<void(void)> f)
Option(const std::string& dt, const Callback& f)
: display_text{dt}, func{f} {}
std::string display_text{};
std::string confirm_text{};
std::function<void(void)> func{};
const std::string display_text;
const std::string confirm_text;
const Callback func{};
};
Entry& m_entry;
@@ -105,9 +107,9 @@ private:
LazyImage m_banner{};
std::unique_ptr<List> m_list{};
std::shared_ptr<ScrollableText> m_details{};
std::shared_ptr<ScrollableText> m_changelog{};
std::shared_ptr<ScrollableText> m_detail_changelog{};
std::unique_ptr<ScrollableText> m_details{};
std::unique_ptr<ScrollableText> m_changelog{};
ScrollableText* m_detail_changelog{};
std::unique_ptr<ScrollableText> m_manifest_list{};
bool m_show_changlog{};

View File

@@ -0,0 +1,19 @@
#pragma once
#include "ui/menus/filebrowser.hpp"
namespace sphaira::ui::menu::filebrowser::picker {
using Callback = std::function<bool(const fs::FsPath& path)>;
struct Menu final : Base {
explicit Menu(const Callback& cb, const std::vector<std::string>& filter = {}, const fs::FsPath& path = {});
private:
void OnClick(FsView* view, const FsEntry& fs_entry, const FileEntry& entry, const fs::FsPath& path) override;
private:
const Callback m_callback;
};
} // namespace sphaira::ui::menu::filebrowser::picker

View File

@@ -7,7 +7,7 @@
namespace sphaira::ui::menu::fileview {
struct Menu final : MenuBase {
Menu(const fs::FsPath& path);
Menu(fs::Fs* fs, const fs::FsPath& path);
auto GetShortTitle() const -> const char* override { return "File"; };
void Update(Controller* controller, TouchInfo* touch) override;
@@ -15,8 +15,8 @@ struct Menu final : MenuBase {
void OnFocusGained() override;
private:
fs::Fs* const m_fs;
const fs::FsPath m_path;
fs::FsNativeSd m_fs{};
fs::File m_file{};
s64 m_file_size{};
s64 m_file_offset{};

View File

@@ -7,17 +7,43 @@
#include "fs.hpp"
#include "option.hpp"
#include "hasher.hpp"
// #include <optional>
#include "nro.hpp"
#include <span>
namespace sphaira::ui::menu::filebrowser {
enum FsOption : u32 {
FsOption_NONE,
// can split screen.
FsOption_CanSplit = BIT(0),
// can selected multiple files.
FsOption_CanSelect = BIT(1),
// shows the option to install.
FsOption_CanInstall = BIT(2),
// loads file assoc.
FsOption_LoadAssoc = BIT(3),
// do not prompt on exit even if not tabbed.
FsOption_DoNotPrompt = BIT(4),
FsOption_Normal = FsOption_LoadAssoc | FsOption_CanInstall | FsOption_CanSplit | FsOption_CanSelect,
FsOption_All = FsOption_DoNotPrompt | FsOption_Normal,
FsOption_Picker = FsOption_NONE,
};
enum FsEntryFlag {
FsEntryFlag_None,
// write protected.
FsEntryFlag_ReadOnly = 1 << 0,
// supports file assoc.
FsEntryFlag_Assoc = 1 << 1,
// this is an sd card, files can be launched from here.
FsEntryFlag_IsSd = 1 << 2, // todo: remove this.
// do not stat files in this entry (faster for network mount).
FsEntryFlag_NoStatFile = 1 << 3,
FsEntryFlag_NoStatDir = 1 << 4,
FsEntryFlag_NoRandomReads = 1 << 5,
FsEntryFlag_NoRandomWrites = 1 << 6,
};
enum class FsType {
@@ -25,6 +51,7 @@ enum class FsType {
ImageNand,
ImageSd,
Stdio,
Custom,
};
enum class SelectedType {
@@ -63,13 +90,33 @@ struct FsEntry {
return flags & FsEntryFlag_Assoc;
}
auto IsSd() const -> bool {
return flags & FsEntryFlag_IsSd;
}
auto IsNoStatFile() const -> bool {
return flags & FsEntryFlag_NoStatFile;
}
auto IsNoStatDir() const -> bool {
return flags & FsEntryFlag_NoStatDir;
}
auto IsNoRandomReads() const -> bool {
return flags & FsEntryFlag_NoRandomReads;
}
auto IsNoRandomWrites() const -> bool {
return flags & FsEntryFlag_NoRandomWrites;
}
auto IsSame(const FsEntry& e) const {
return root == e.root && type == e.type;
}
};
// roughly 1kib in size per entry
struct FileEntry : FsDirectoryEntry {
struct FileEntry final : FsDirectoryEntry {
std::string extension{}; // if any
std::string internal_name{}; // if any
std::string internal_extension{}; // if any
@@ -79,6 +126,7 @@ struct FileEntry : FsDirectoryEntry {
bool checked_extension{}; // did we already search for an ext?
bool checked_internal_extension{}; // did we already search for an ext?
bool selected{}; // is this file selected?
bool done_stat{}; // have we checked file_size / count.
auto IsFile() const -> bool {
return type == FsDirEntryType_File;
@@ -97,6 +145,11 @@ struct FileEntry : FsDirectoryEntry {
}
auto GetExtension() const -> std::string {
if (!checked_extension) {
if (auto ext = std::strrchr(name, '.')) {
return ext+1;
}
}
return extension;
}
@@ -157,13 +210,14 @@ using FsDirCollections = std::vector<FsDirCollection>;
void SignalChange();
struct Menu;
struct Base;
struct FsView final : Widget {
friend class Menu;
friend class Base;
FsView(Menu* menu, ViewSide side);
FsView(Menu* menu, const fs::FsPath& path, const FsEntry& entry, ViewSide side);
FsView(FsView* view, ViewSide side);
FsView(Base* menu, ViewSide side);
FsView(Base* menu, const std::shared_ptr<fs::Fs>& fs, const fs::FsPath& path, const FsEntry& entry, ViewSide side);
~FsView();
void Update(Controller* controller, TouchInfo* touch) override;
@@ -188,7 +242,9 @@ struct FsView final : Widget {
static auto get_collection(fs::Fs* fs, const fs::FsPath& path, const fs::FsPath& parent_name, FsDirCollection& out, bool inc_file, bool inc_dir, bool inc_size) -> Result;
static auto get_collections(fs::Fs* fs, const fs::FsPath& path, const fs::FsPath& parent_name, FsDirCollections& out, bool inc_size = false) -> Result;
private:
// private:
void OnClick();
void SetIndex(s64 index);
void InstallForwarder();
@@ -197,7 +253,7 @@ private:
void ZipFiles(fs::FsPath zip_path);
void UploadFiles();
auto Scan(const fs::FsPath& new_path, bool is_walk_up = false) -> Result;
auto Scan(fs::FsPath new_path, bool is_walk_up = false) -> Result;
auto GetNewPath(const FileEntry& entry) const -> fs::FsPath {
return GetNewPath(m_path, entry.name);
@@ -244,7 +300,7 @@ private:
}
auto IsSd() const -> bool {
return m_fs_entry.type == FsType::Sd;
return m_fs_entry.IsSd();
}
void Sort();
@@ -259,7 +315,7 @@ private:
auto get_collection(const fs::FsPath& path, const fs::FsPath& parent_name, FsDirCollection& out, bool inc_file, bool inc_dir, bool inc_size) -> Result;
auto get_collections(const fs::FsPath& path, const fs::FsPath& parent_name, FsDirCollections& out, bool inc_size = false) -> Result;
void SetFs(const fs::FsPath& new_path, const FsEntry& new_entry);
void SetFs(const std::shared_ptr<fs::Fs>& fs, const fs::FsPath& new_path, const FsEntry& new_entry);
auto GetNative() -> fs::FsNative* {
return (fs::FsNative*)m_fs.get();
@@ -270,11 +326,17 @@ private:
void DisplayOptions();
void DisplayAdvancedOptions();
private:
Menu* m_menu{};
using MountFsFunc = Result(*)(fs::Fs *fs, const fs::FsPath &path, fs::FsPath &out_path);
// using MountFsFunc = std::function<Result(fs::Fs *fs, const fs::FsPath &path, fs::FsPath &out_path)>;
using UmountFsFunc = std::function<void(const fs::FsPath &mount)>;
void MountFileFs(const MountFsFunc& mount_func, const UmountFsFunc& umount_func);
// private:
Base* m_menu{};
ViewSide m_side{};
std::unique_ptr<fs::Fs> m_fs{};
std::shared_ptr<fs::Fs> m_fs{};
FsEntry m_fs_entry{};
fs::FsPath m_path{};
std::vector<FileEntry> m_entries{};
@@ -300,7 +362,7 @@ private:
// contains all selected files for a command, such as copy, delete, cut etc.
struct SelectedStash {
void Add(std::shared_ptr<FsView> view, SelectedType type, const std::vector<FileEntry>& files, const fs::FsPath& path) {
void Add(FsView* view, SelectedType type, const std::vector<FileEntry>& files, const fs::FsPath& path) {
if (files.empty()) {
Reset();
} else {
@@ -335,28 +397,34 @@ struct SelectedStash {
}
// private:
std::shared_ptr<FsView> m_view{};
FsView* m_view{};
std::vector<FileEntry> m_files{};
fs::FsPath m_path{};
SelectedType m_type{SelectedType::None};
};
struct Menu final : MenuBase {
struct Base : MenuBase {
friend class FsView;
Menu(u32 flags);
~Menu();
Base(u32 flags, u32 options);
Base(const std::shared_ptr<fs::Fs>& fs, const FsEntry& fs_entry, const fs::FsPath& path, bool is_custom, u32 flags, u32 options);
void SetFilter(const std::vector<std::string>& filter) {
m_filter = filter;
}
auto GetShortTitle() const -> const char* override { return "Files"; };
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
void OnFocusGained() override;
virtual void OnFocusGained() override;
static auto GetNewPath(const fs::FsPath& root_path, const fs::FsPath& file_path) -> fs::FsPath {
return fs::AppendPath(root_path, file_path);
}
private:
virtual void OnClick(FsView* view, const FsEntry& fs_entry, const FileEntry& entry, const fs::FsPath& path);
protected:
auto IsSplitScreen() const {
return m_split_screen;
}
@@ -386,23 +454,40 @@ private:
void PromptIfShouldExit();
auto CanInstall() const {
return m_options & FsOption_CanInstall;
}
auto CreateFs(const FsEntry& fs_entry) -> std::shared_ptr<fs::Fs>;
private:
void Init(const std::shared_ptr<fs::Fs>& fs, const FsEntry& fs_entry, const fs::FsPath& path, bool is_custom);
protected:
static constexpr inline const char* INI_SECTION = "filebrowser";
std::shared_ptr<FsView> view{};
std::shared_ptr<FsView> view_left{};
std::shared_ptr<FsView> view_right{};
const u32 m_options;
std::shared_ptr<fs::Fs> m_custom_fs{};
FsEntry m_custom_fs_entry{};
FsView* view{};
std::unique_ptr<FsView> view_left{};
std::unique_ptr<FsView> view_right{};
std::vector<FileAssocEntry> m_assoc_entries{};
SelectedStash m_selected{};
// this keeps track of the highlighted file before opening a folder
// if the user presses B to go back to the previous dir
// this vector is popped, then, that entry is checked if it still exists
// if it does, the index becomes that file.
std::vector<LastFile> m_previous_highlighted_file{};
s64 m_index{};
s64 m_selected_count{};
std::vector<std::string> m_filter{};
// local copy of nro entries that is loaded in LoadAssocEntriesPath()
// if homebrew::GetNroEntries() returns nothing, usually due to
// the menu not being loaded.
// this is a bit of a hack to support replacing the homebrew menu tab,
// sphaira wasn't really designed for this.
// however this will work for now, until i add support for additional
// nro scan mounts, at which point this won't scale.
std::vector<NroEntry> m_nro_entries{};
option::OptionLong m_sort{INI_SECTION, "sort", SortType::SortType_Alphabetical};
option::OptionLong m_order{INI_SECTION, "order", OrderType::OrderType_Descending};
@@ -412,8 +497,39 @@ private:
option::OptionBool m_ignore_read_only{INI_SECTION, "ignore_read_only", false};
bool m_loaded_assoc_entries{};
bool m_is_update_folder{};
bool m_split_screen{};
};
struct Menu final : Base {
Menu(u32 flags, u32 options = FsOption_All) : Base{flags, options} {
}
Menu(const std::shared_ptr<fs::Fs>& fs, const FsEntry& fs_entry, const fs::FsPath& path, u32 options = FsOption_All)
: Base{fs, fs_entry, path, true, MenuFlag_None, options} {
}
};
// case insensitive check
auto IsSamePath(std::string_view a, std::string_view b) -> bool;
auto IsExtension(std::string_view ext1, std::string_view ext2) -> bool;
auto IsExtension(std::string_view ext, std::span<const std::string_view> list) -> bool;
struct FsStdioWrapper final : fs::FsStdio {
using OnExit = std::function<void(void)>;
FsStdioWrapper(const fs::FsPath& root, const OnExit& on_exit) : fs::FsStdio{true, root}, m_on_exit{on_exit} {
}
~FsStdioWrapper() {
if (m_on_exit) {
m_on_exit();
}
}
const OnExit m_on_exit;
};
void MountFsHelper(const std::shared_ptr<fs::Fs>& fs, const fs::FsPath& name);
} // namespace sphaira::ui::menu::filebrowser

View File

@@ -2,6 +2,11 @@
#include "ui/menus/grid_menu_base.hpp"
#include "ui/list.hpp"
#include "yati/container/base.hpp"
#include "yati/nx/keys.hpp"
#include "title_info.hpp"
#include "fs.hpp"
#include "option.hpp"
#include <memory>
@@ -10,26 +15,13 @@
namespace sphaira::ui::menu::game {
enum class NacpLoadStatus {
// not yet attempted to be loaded.
None,
// started loading.
Progress,
// loaded, ready to parse.
Loaded,
// failed to load, do not attempt to load again!
Error,
};
struct Entry {
u64 app_id{};
u8 last_event{};
NacpLanguageEntry lang{};
int image{};
bool selected{};
std::shared_ptr<NsApplicationControlData> control{};
u64 jpeg_size{};
NacpLoadStatus status{NacpLoadStatus::None};
title::NacpLoadStatus status{title::NacpLoadStatus::None};
auto GetName() const -> const char* {
return lang.name;
@@ -40,45 +32,6 @@ struct Entry {
}
};
struct ThreadResultData {
u64 id{};
std::shared_ptr<NsApplicationControlData> control{};
u64 jpeg_size{};
NacpLanguageEntry lang{};
NacpLoadStatus status{NacpLoadStatus::None};
};
struct ThreadData {
ThreadData(bool title_cache);
void Run();
void Close();
void Push(u64 id);
void Push(std::span<const Entry> entries);
void Pop(std::vector<ThreadResultData>& out);
auto IsRunning() const -> bool {
return m_running;
}
auto IsTitleCacheEnabled() const {
return m_title_cache;
}
private:
UEvent m_uevent{};
Mutex m_mutex_id{};
Mutex m_mutex_result{};
bool m_title_cache{};
// app_ids pushed to the queue, signal uevent when pushed.
std::vector<u64> m_ids{};
// control data pushed to the queue.
std::vector<ThreadResultData> m_result{};
std::atomic_bool m_running{};
};
enum SortType {
SortType_Updated,
};
@@ -90,6 +43,8 @@ enum OrderType {
using LayoutType = grid::LayoutType;
void SignalChange();
struct Menu final : grid::Menu {
Menu(u32 flags);
~Menu();
@@ -131,7 +86,9 @@ private:
}
void DeleteGames();
void DumpGames(u32 flags);
void ExportOptions(bool to_nsz);
void DumpGames(u32 flags, bool to_nsz);
void CreateSaves(AccountUid uid);
private:
static constexpr inline const char* INI_SECTION = "games";
@@ -144,14 +101,79 @@ private:
bool m_is_reversed{};
bool m_dirty{};
std::unique_ptr<ThreadData> m_thread_data{};
Thread m_thread{};
// use for detection game card removal to force a refresh.
Event m_gc_event{};
FsEventNotifier m_gc_event_notifier{};
option::OptionLong m_sort{INI_SECTION, "sort", SortType::SortType_Updated};
option::OptionLong m_order{INI_SECTION, "order", OrderType::OrderType_Descending};
option::OptionLong m_layout{INI_SECTION, "layout", LayoutType::LayoutType_Grid};
option::OptionBool m_hide_forwarders{INI_SECTION, "hide_forwarders", false};
option::OptionBool m_title_cache{INI_SECTION, "title_cache", true};
};
struct NcmMetaData {
// points to global service, do not close manually!
NcmContentStorage* cs{};
NcmContentMetaDatabase* db{};
u64 app_id{};
NcmContentMetaKey key{};
};
Result GetMetaEntries(const Entry& e, title::MetaEntries& out, u32 flags = title::ContentFlag_All);
Result GetNcmMetaFromMetaStatus(const NsApplicationContentMetaStatus& status, NcmMetaData& out);
void DeleteMetaEntries(u64 app_id, int image, const std::string& name, const title::MetaEntries& entries);
struct TikEntry {
FsRightsId id{};
u8 key_gen{};
std::vector<u8> tik_data{};
std::vector<u8> cert_data{};
};
struct NspEntry {
// application name.
std::string application_name{};
// name of the nsp (name [id][v0][BASE].nsp).
fs::FsPath path{};
// tickets and cert data, will be empty if title key crypto isn't used.
std::vector<TikEntry> tickets{};
// all the collections for this nsp, such as nca's and tickets.
std::vector<yati::container::CollectionEntry> collections{};
// raw nsp data (header, file table and string table).
std::vector<u8> nsp_data{};
// size of the entier nsp.
s64 nsp_size{};
// copy of ncm cs, it is not closed.
NcmContentStorage cs{};
// copy of the icon, if invalid, it will use the default icon.
int icon{};
Result Read(void* buf, s64 off, s64 size, u64* bytes_read);
private:
static auto InRange(s64 off, s64 offset, s64 size) -> bool {
return off < offset + size && off >= offset;
}
static auto ClipSize(s64 off, s64 size, s64 file_size) -> s64 {
return std::min(size, file_size - off);
}
};
struct ContentInfoEntry {
NsApplicationContentMetaStatus status{};
std::vector<NcmContentInfo> content_infos{};
std::vector<NcmRightsId> ncm_rights_id{};
};
auto BuildNspPath(const Entry& e, const NsApplicationContentMetaStatus& status, bool to_nsz = false) -> fs::FsPath;
Result BuildContentEntry(const NsApplicationContentMetaStatus& status, ContentInfoEntry& out, bool to_nsz = false);
Result BuildNspEntry(const Entry& e, const ContentInfoEntry& info, const keys::Keys& keys, NspEntry& out, bool to_nsz = false);
Result BuildNspEntries(Entry& e, const title::MetaEntries& meta_entries, std::vector<NspEntry>& out, bool to_nsz = false);
Result BuildNspEntries(Entry& e, u32 flags, std::vector<NspEntry>& out, bool to_nsz = false);
// dumps the array of nsp entries.
void DumpNsp(const std::vector<NspEntry>& entries, bool to_nsz);
} // namespace sphaira::ui::menu::game

View File

@@ -0,0 +1,111 @@
#pragma once
#include "ui/menus/menu_base.hpp"
#include "ui/menus/game_menu.hpp"
#include "ui/list.hpp"
#include "yati/nx/ncm.hpp"
#include <span>
#include <memory>
namespace sphaira::ui::menu::game::meta {
enum TicketType : u8 {
TicketType_None,
TicketType_Common,
TicketType_Personalised,
TicketType_Missing,
};
struct MiniNacp {
char display_version[0x10];
};
struct MetaEntry {
NsApplicationContentMetaStatus status{};
ncm::ContentMeta content_meta{};
// small version of nacp to speed up loading.
MiniNacp nacp{};
// total size of all ncas.
s64 size{};
// set to the key gen (if possible), only if title key encrypted.
u8 key_gen{};
// set to the ticket type.
u8 ticket_type{TicketType_None};
// set if it has missing ncas.
u8 missing_count{};
// set if selected.
bool selected{};
// set if we have checked the above meta data.
bool checked{};
};
struct Menu final : MenuBase {
Menu(Entry& entry);
~Menu();
auto GetShortTitle() const -> const char* override { return "Meta"; };
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
private:
void SetIndex(s64 index);
void Scan();
void UpdateSubheading();
auto GetSelectedEntries() const {
title::MetaEntries out;
for (auto& e : m_entries) {
if (e.selected) {
out.emplace_back(e.status);
}
}
if (!m_entries.empty() && out.empty()) {
out.emplace_back(m_entries[m_index].status);
}
return out;
}
void ClearSelection() {
for (auto& e : m_entries) {
e.selected = false;
}
m_selected_count = 0;
}
auto GetEntry(u32 index) -> MetaEntry& {
return m_entries[index];
}
auto GetEntry(u32 index) const -> const MetaEntry& {
return m_entries[index];
}
auto GetEntry() -> MetaEntry& {
return GetEntry(m_index);
}
auto GetEntry() const -> const MetaEntry& {
return GetEntry(m_index);
}
void DumpGames(bool to_nsz);
void DeleteGames();
Result ResetRequiredSystemVersion(MetaEntry& entry) const;
Result GetNcmSizeOfMetaStatus(MetaEntry& entry) const;
private:
Entry& m_entry;
std::vector<MetaEntry> m_entries{};
s64 m_index{};
s64 m_selected_count{};
std::unique_ptr<List> m_list{};
bool m_dirty{};
std::vector<FsRightsId> m_common_tickets{};
std::vector<FsRightsId> m_personalised_tickets{};
};
} // namespace sphaira::ui::menu::game::meta

View File

@@ -0,0 +1,92 @@
#pragma once
#include "ui/menus/menu_base.hpp"
#include "ui/menus/game_meta_menu.hpp"
#include "ui/list.hpp"
#include "yati/nx/nca.hpp"
#include "yati/nx/ncm.hpp"
#include <span>
#include <memory>
namespace sphaira::ui::menu::game::meta_nca {
struct NcaEntry {
NcmContentId content_id{};
u64 size{};
u8 content_type{};
// decrypted nca header.
nca::Header header{};
// set if missing.
bool missing{};
// set if selected.
bool selected{};
// set if we have checked the above meta data.
bool checked{};
};
struct Menu final : MenuBase {
Menu(Entry& entry, const meta::MetaEntry& meta_entry);
~Menu();
auto GetShortTitle() const -> const char* override { return "Nca"; };
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
private:
void SetIndex(s64 index);
void Scan();
void UpdateSubheading();
auto GetSelectedEntries() const {
std::vector<NcaEntry> out;
for (auto& e : m_entries) {
if (e.selected && !e.missing) {
out.emplace_back(e);
}
}
if (!m_entries.empty() && out.empty()) {
out.emplace_back(m_entries[m_index]);
}
return out;
}
void ClearSelection() {
for (auto& e : m_entries) {
e.selected = false;
}
m_selected_count = 0;
}
auto GetEntry(u32 index) -> NcaEntry& {
return m_entries[index];
}
auto GetEntry(u32 index) const -> const NcaEntry& {
return m_entries[index];
}
auto GetEntry() -> NcaEntry& {
return GetEntry(m_index);
}
auto GetEntry() const -> const NcaEntry& {
return GetEntry(m_index);
}
void DumpNcas();
Result MountNcaFs();
private:
Entry& m_entry;
const meta::MetaEntry& m_meta_entry;
NcmMetaData m_meta{};
std::vector<NcaEntry> m_entries{};
s64 m_index{};
s64 m_selected_count{};
std::unique_ptr<List> m_list{};
};
} // namespace sphaira::ui::menu::game::meta_nca

View File

@@ -7,7 +7,8 @@
#include <span>
#include <memory>
namespace sphaira::ui::menu::gc {
// todo: pr to libnx
extern "C" {
typedef enum {
FsGameCardPartitionRaw_None = -1,
@@ -15,6 +16,13 @@ typedef enum {
FsGameCardPartitionRaw_Secure = 1,
} FsGameCardPartitionRaw;
Result fsOpenGameCardStorage(FsStorage* out, const FsGameCardHandle* handle, FsGameCardPartitionRaw partition);
Result fsOpenGameCardDetectionEventNotifier(FsEventNotifier* out);
}
namespace sphaira::ui::menu::gc {
////////////////////////////////////////////////
// The below structs are taken from nxdumptool./
////////////////////////////////////////////////
@@ -88,6 +96,33 @@ typedef struct {
static_assert(sizeof(GameCardInitialData) == 0x200);
/// Encrypted using AES-128-CTR with the key and IV/counter from the `GameCardTitleKeyAreaEncryption` section. Assumed to be all zeroes in retail gamecards.
typedef struct {
u8 titlekey[0x10]; ///< Decrypted titlekey from the `GameCardInitialData` section.
u8 reserved[0xCF0];
} GameCardTitleKeyArea;
static_assert(sizeof(GameCardTitleKeyArea) == 0xD00);
/// Encrypted using RSA-2048-OAEP and a private OAEP key from AuthoringTool. Assumed to be all zeroes in retail gamecards.
typedef struct {
u8 titlekey_encryption_key[0x10]; ///< Used as the AES-128-CTR key for the `GameCardTitleKeyArea` section. Randomly generated during XCI creation by AuthoringTool.
u8 titlekey_encryption_iv[0x10]; ///< Used as the AES-128-CTR IV/counter for the `GameCardTitleKeyArea` section. Randomly generated during XCI creation by AuthoringTool.
u8 reserved[0xE0];
} GameCardTitleKeyAreaEncryption;
static_assert(sizeof(GameCardTitleKeyAreaEncryption) == 0x100);
/// Used to secure communications between the Lotus and the inserted gamecard.
/// Supposedly precedes the gamecard header.
typedef struct {
GameCardInitialData initial_data;
GameCardTitleKeyArea titlekey_area;
GameCardTitleKeyAreaEncryption titlekey_area_encryption;
} GameCardKeyArea;
static_assert(sizeof(GameCardKeyArea) == 0x1000);
typedef struct {
u8 maker_code; ///< GameCardUidMakerCode.
u8 version; ///< TODO: determine whether this matches GameCardVersion or not.
@@ -151,8 +186,7 @@ struct ApplicationEntry {
u64 app_id{};
u32 version{};
u8 key_gen{};
std::unique_ptr<NsApplicationControlData> control{};
u64 control_size{};
std::vector<u8> icon;
NacpLanguageEntry lang_entry{};
std::vector<GcCollections> application{};
@@ -199,6 +233,9 @@ private:
void FreeImage();
void OnChangeIndex(s64 new_index);
Result DumpGames(u32 flags);
Result DumpXcz(u32 flags);
Result MountGcFs();
private:
FsDeviceOperator m_dev_op{};
@@ -221,12 +258,12 @@ private:
FsStorage m_storage{};
// size of normal partition.
s64 m_parition_normal_size{};
s64 m_partition_normal_size{};
// size of secure partition.
s64 m_parition_secure_size{};
s64 m_partition_secure_size{};
// used size reported in the xci header.
s64 m_storage_trimmed_size{};
// total size of m_parition_normal_size + m_parition_secure_size.
// total size of m_partition_normal_size + m_partition_secure_size.
s64 m_storage_total_size{};
// reported size via rom_size in the xci header.
s64 m_storage_full_size{};

View File

@@ -32,12 +32,15 @@ struct GhApiAsset {
std::string content_type{};
u64 size{};
u64 download_count{};
std::string updated_at{};
std::string browser_download_url{};
};
struct GhApiEntry {
std::string tag_name{};
std::string name{};
std::string published_at{};
bool prerelease{};
std::vector<GhApiAsset> assets{};
};
@@ -72,4 +75,18 @@ private:
std::unique_ptr<List> m_list{};
};
// creates a popup box on another thread.
void DownloadEntries(const Entry& entry);
// parses the params into entry struct and calls DonwloadEntries
bool Download(const std::string& url, const std::vector<AssetEntry>& assets = {}, const std::string& tag = {}, const std::string& pre_install_message = {}, const std::string& post_install_message = {});
// calls the above function by pushing the asset to an array.
inline bool Download(const std::string& url, const AssetEntry& asset, const std::string& tag = {}, const std::string& pre_install_message = {}, const std::string& post_install_message = {}) {
std::vector<AssetEntry> assets;
assets.emplace_back(asset);
return Download(url, assets, tag, pre_install_message, post_install_message);
}
} // namespace sphaira::ui::menu::gh

View File

@@ -8,6 +8,12 @@
namespace sphaira::ui::menu::homebrew {
enum Filter {
Filter_All,
Filter_HideHidden,
Filter_MAX,
};
enum SortType {
SortType_Updated,
SortType_Alphabetical,
@@ -28,7 +34,7 @@ auto GetNroEntries() -> std::span<const NroEntry>;
void SignalChange();
struct Menu final : grid::Menu {
Menu();
Menu(u32 flags);
~Menu();
auto GetShortTitle() const -> const char* override { return "Apps"; };
@@ -43,6 +49,14 @@ struct Menu final : grid::Menu {
static Result InstallHomebrew(const fs::FsPath& path, const std::vector<u8>& icon);
static Result InstallHomebrewFromPath(const fs::FsPath& path);
auto GetEntry(s64 i) -> NroEntry& {
return m_entries[m_entries_current[i]];
}
auto GetEntry() -> NroEntry& {
return GetEntry(m_index);
}
private:
void SetIndex(s64 index);
void InstallHomebrew();
@@ -51,15 +65,21 @@ private:
void SortAndFindLastFile(bool scan = false);
void FreeEntries();
void OnLayoutChange();
void DisplayOptions();
auto IsStarEnabled() -> bool {
return m_sort.Get() >= SortType_UpdatedStar;
}
Result MountNroFs();
private:
static constexpr inline const char* INI_SECTION = "homebrew";
std::vector<NroEntry> m_entries{};
std::vector<u32> m_entries_index[Filter_MAX]{};
std::span<u32> m_entries_current{};
s64 m_index{}; // where i am in the array
std::unique_ptr<List> m_list{};
bool m_dirty{};
@@ -67,7 +87,7 @@ private:
option::OptionLong m_sort{INI_SECTION, "sort", SortType::SortType_AlphabeticalStar};
option::OptionLong m_order{INI_SECTION, "order", OrderType::OrderType_Descending};
option::OptionLong m_layout{INI_SECTION, "layout", LayoutType::LayoutType_GridDetail};
option::OptionBool m_hide_sphaira{INI_SECTION, "hide_sphaira", false};
option::OptionBool m_show_hidden{INI_SECTION, "show_hidden", false};
};
} // namespace sphaira::ui::menu::homebrew

View File

@@ -0,0 +1,36 @@
#pragma once
#include "ui/widget.hpp"
#include "fs.hpp"
#include <vector>
namespace sphaira::ui::menu::imageview {
struct Menu final : Widget {
Menu(fs::Fs* fs, const fs::FsPath& path);
~Menu();
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
auto IsMenu() const -> bool override {
return true;
}
void UpdateSize();
private:
const fs::FsPath m_path;
int m_image{};
float m_image_width{};
float m_image_height{};
// for zoom, 0.1 - 1.0
float m_zoom{1};
// for pan.
float m_xoff{};
float m_yoff{};
};
} // namespace sphaira::ui::menu::imageview

View File

@@ -35,10 +35,11 @@ private:
std::stop_token m_token{};
std::vector<u8> m_buffer{};
CondVar m_can_read{};
CondVar m_can_write{};
public:
Mutex m_mutex{};
bool m_active{};
std::atomic_bool m_active{};
};
struct Menu : MenuBase {
@@ -55,7 +56,7 @@ protected:
void OnInstallClose();
private:
std::shared_ptr<Stream> m_source{};
std::unique_ptr<Stream> m_source{};
Thread m_thread{};
Mutex m_mutex{};
State m_state{State::None};

View File

@@ -17,7 +17,7 @@ enum class UpdateState {
Error,
};
using MiscMenuFunction = std::function<std::shared_ptr<ui::menu::MenuBase>(u32 flags)>;
using MiscMenuFunction = std::function<std::unique_ptr<MenuBase>(u32 flags)>;
enum MiscMenuFlag : u8 {
// can be set as the rightside menu.
@@ -31,6 +31,7 @@ struct MiscMenuEntry {
const char* title;
MiscMenuFunction func;
u8 flag;
const char* info;
auto IsShortcut() const -> bool {
return flag & MiscMenuFlag_Shortcut;
@@ -41,7 +42,7 @@ struct MiscMenuEntry {
}
};
auto GetMiscMenuEntries() -> std::span<const MiscMenuEntry>;
auto GetMenuMenuEntries() -> std::span<const MiscMenuEntry>;
// this holds 2 menus and allows for switching between them
struct MainMenu final : Widget {
@@ -58,14 +59,14 @@ struct MainMenu final : Widget {
}
private:
void OnLRPress(std::shared_ptr<MenuBase> menu, Button b);
void OnLRPress(MenuBase* menu, Button b);
void AddOnLRPress();
private:
std::shared_ptr<MenuBase> m_centre_menu{};
std::shared_ptr<MenuBase> m_left_menu{};
std::shared_ptr<MenuBase> m_right_menu{};
std::shared_ptr<MenuBase> m_current_menu{};
std::unique_ptr<MenuBase> m_centre_menu{};
std::unique_ptr<MenuBase> m_left_menu{};
std::unique_ptr<MenuBase> m_right_menu{};
MenuBase* m_current_menu{};
std::string m_update_url{};
std::string m_update_version{};

View File

@@ -13,12 +13,14 @@ enum MenuFlag {
struct PolledData {
struct tm tm{};
u32 battery_percetange{};
PsmChargerType charger_type{};
NifmInternetConnectionType type{};
NifmInternetConnectionStatus status{};
u32 strength{};
u32 ip{};
s64 sd_free{1};
s64 sd_total{1};
s64 emmc_free{1};
s64 emmc_total{1};
};
struct MenuBase : Widget {
@@ -33,9 +35,17 @@ struct MenuBase : Widget {
return true;
}
void SetTitle(std::string title);
void SetTitleSubHeading(std::string sub_heading);
void SetSubHeading(std::string sub_heading);
void SetTitle(const std::string& title) {
m_title = title;
}
void SetTitleSubHeading(const std::string& sub_heading) {
m_title_sub_heading = sub_heading;
}
void SetSubHeading(const std::string& sub_heading) {
m_sub_heading = sub_heading;
}
auto GetTitle() const {
return m_title;

View File

@@ -2,6 +2,7 @@
#include "ui/menus/grid_menu_base.hpp"
#include "ui/list.hpp"
#include "title_info.hpp"
#include "fs.hpp"
#include "option.hpp"
#include "dumper.hpp"
@@ -11,25 +12,19 @@
namespace sphaira::ui::menu::save {
enum class NacpLoadStatus {
// not yet attempted to be loaded.
None,
// started loading.
Progress,
// loaded, ready to parse.
Loaded,
// failed to load, do not attempt to load again!
Error,
enum BackupFlag {
BackupFlag_None = 0,
// option to allow the user to set the save file name.
BackupFlag_SetName = 1 << 0,
// set if this is a auto backup (on restore).
BackupFlag_IsAuto = 1 << 1,
};
struct Entry final : FsSaveDataInfo {
NacpLanguageEntry lang{};
int image{};
bool selected{};
std::shared_ptr<NsApplicationControlData> control{};
u64 jpeg_size{};
NacpLoadStatus status{NacpLoadStatus::None};
title::NacpLoadStatus status{title::NacpLoadStatus::None};
auto GetName() const -> const char* {
return lang.name;
@@ -40,37 +35,6 @@ struct Entry final : FsSaveDataInfo {
}
};
struct ThreadResultData {
u64 id{};
std::shared_ptr<NsApplicationControlData> control{};
u64 jpeg_size{};
NacpLanguageEntry lang{};
NacpLoadStatus status{NacpLoadStatus::None};
};
struct ThreadData {
ThreadData();
auto IsRunning() const -> bool;
void Run();
void Close();
void Push(u64 id);
void Push(std::span<const Entry> entries);
void Pop(std::vector<ThreadResultData>& out);
private:
UEvent m_uevent{};
Mutex m_mutex_id{};
Mutex m_mutex_result{};
// app_ids pushed to the queue, signal uevent when pushed.
std::vector<u64> m_ids{};
// control data pushed to the queue.
std::vector<ThreadResultData> m_result{};
std::atomic_bool m_running{};
};
enum SortType {
SortType_Updated,
};
@@ -124,12 +88,17 @@ private:
m_selected_count = 0;
}
void BackupSaves(std::vector<std::reference_wrapper<Entry>>& entries);
void DisplayOptions();
void BackupSaves(std::vector<std::reference_wrapper<Entry>>& entries, u32 flags);
void RestoreSave();
auto BuildSavePath(const Entry& e, bool is_auto) const -> fs::FsPath;
Result RestoreSaveInternal(ProgressBox* pbox, const Entry& e, const fs::FsPath& path) const;
Result BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& location, const Entry& e, bool compressed, bool is_auto = false) const;
auto BuildSavePath(const Entry& e, u32 flags) const -> fs::FsPath;
Result RestoreSaveInternal(ProgressBox* pbox, const Entry& e, const fs::FsPath& path);
Result BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& location, Entry& e, u32 flags);
Result BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& location, std::span<const std::reference_wrapper<Entry>> entries, u32 flags);
Result MountSaveFs();
private:
static constexpr inline const char* INI_SECTION = "saves";
@@ -145,9 +114,6 @@ private:
s64 m_account_index{};
u8 m_data_type{FsSaveDataType_Account};
ThreadData m_thread_data{};
Thread m_thread{};
option::OptionLong m_sort{INI_SECTION, "sort", SortType::SortType_Updated};
option::OptionLong m_order{INI_SECTION, "order", OrderType::OrderType_Descending};
option::OptionLong m_layout{INI_SECTION, "layout", LayoutType::LayoutType_Grid};

View File

@@ -1,3 +1,4 @@
#if 0
#pragma once
#include "ui/menus/menu_base.hpp"
@@ -104,7 +105,7 @@ struct Config {
u32 limit{18};
bool nsfw{false};
void SetQuery(std::string new_query) {
void SetQuery(const std::string& new_query) {
query = new_query;
}
@@ -112,7 +113,7 @@ struct Config {
query.clear();
}
void SetCreator(Creator new_creator) {
void SetCreator(const Creator& new_creator) {
creator = new_creator.id;
}
@@ -138,6 +139,7 @@ struct Menu final : MenuBase {
void Draw(NVGcontext* vg, Theme* theme) override;
void OnFocusGained() override;
private:
void SetIndex(s64 index) {
m_index = index;
if (!m_index) {
@@ -147,7 +149,7 @@ struct Menu final : MenuBase {
void InvalidateAllPages();
void PackListDownload();
void OnPackListDownload();
void DisplayOptions();
private:
static constexpr inline const char* INI_SECTION = "themezer";
@@ -169,6 +171,9 @@ private:
option::OptionLong m_sort{INI_SECTION, "sort", 0};
option::OptionLong m_order{INI_SECTION, "order", 0};
option::OptionBool m_nsfw{INI_SECTION, "nsfw", false};
bool m_checked_for_nro{};
};
} // namespace sphaira::ui::menu::themezer
#endif

View File

@@ -27,19 +27,16 @@ struct Menu final : MenuBase {
auto GetShortTitle() const -> const char* override { return "USB"; };
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
void OnFocusGained() override;
// this should be private
// private:
std::shared_ptr<yati::source::Usb> m_usb_source{};
void ThreadFunction();
private:
std::unique_ptr<yati::source::Usb> m_usb_source{};
bool m_was_mtp_enabled{};
Thread m_thread{};
Mutex m_mutex{};
// the below are shared across threads, lock with the above mutex!
State m_state{State::None};
std::atomic<State> m_state{State::None};
std::vector<std::string> m_names{};
bool m_usb_has_connection{};
};
} // namespace sphaira::ui::menu::usb

View File

@@ -0,0 +1,45 @@
#pragma once
#include "ui/widget.hpp"
#include "ui/scrolling_text.hpp"
#include "fs.hpp"
#include "utils/audio.hpp"
#include <memory>
namespace sphaira::ui::music {
struct Menu final : Widget {
Menu(fs::Fs* fs, const fs::FsPath& path);
~Menu();
void Update(Controller* controller, TouchInfo* touch) override;
void Draw(NVGcontext* vg, Theme* theme) override;
private:
void PauseToggle();
void SeekForward();
void SeekBack();
void IncreaseVolume();
void DecreaseVolume();
private:
audio::SongID m_song{};
audio::Info m_info{};
audio::Meta m_meta{};
// only set if metadata was loaded.
int m_icon{};
ScrollingText m_scroll_title{};
ScrollingText m_scroll_artist{};
ScrollingText m_scroll_album{};
// from movienx
static constexpr Vec4 osd_progress_bar{400.f, 550, 1280.f - (400.f * 2.f), 10.f};
// static constexpr Vec4 osd_progress_bar{300.f, SCREEN_HEIGHT / 2 - 15 / 2, 1280.f - (300.f * 2.f), 10.f};
static constexpr Vec2 osd_time_text_left{osd_progress_bar.x - 12.f, osd_progress_bar.y - 2.f};
static constexpr Vec2 osd_time_text_right{osd_progress_bar.x + osd_progress_bar.w + 12.f, osd_progress_bar.y - 2.f};
static constexpr Vec4 osd_bar_outline{osd_time_text_left.x - 80, osd_progress_bar.y - 30, osd_progress_bar.w + 80 * 2 + 30, osd_progress_bar.h + 30 + 30};
};
} // namespace sphaira::ui::music

View File

@@ -11,8 +11,7 @@ public:
enum class Side { LEFT, RIGHT };
public:
NotifEntry(std::string text, Side side);
~NotifEntry() = default;
NotifEntry(const std::string& text, Side side);
auto Draw(NVGcontext* vg, Theme* theme, float y) -> bool;
auto GetSide() const noexcept { return m_side; }
@@ -22,17 +21,14 @@ private:
void Draw(NVGcontext* vg, Theme* theme) override;
private:
std::string m_text{};
std::string m_text;
Side m_side;
std::size_t m_count{180}; // count down to zero
Side m_side{};
bool m_bounds_measured{};
};
class NotifMananger final : public Object {
public:
NotifMananger() = default;
~NotifMananger() = default;
void Draw(NVGcontext* vg, Theme* theme) override;
void Push(const NotifEntry& entry);
@@ -45,6 +41,7 @@ private:
private:
void Draw(NVGcontext* vg, Theme* theme, Entries& entries);
auto GetEntries(NotifEntry::Side side) -> Entries&;
private:
Entries m_entries_left{};

View File

@@ -6,8 +6,8 @@
namespace sphaira::ui::gfx {
void drawImage(NVGcontext*, float x, float y, float w, float h, int texture, float rounded = 0.F);
void drawImage(NVGcontext*, const Vec4& v, int texture, float rounded = 0.F);
void drawImage(NVGcontext*, float x, float y, float w, float h, int texture, float rounded = 0.F, float alpha = 1.0F);
void drawImage(NVGcontext*, const Vec4& v, int texture, float rounded = 0.F, float alpha = 1.0F);
void dimBackground(NVGcontext*);
@@ -42,6 +42,8 @@ void drawScrollbar2(NVGcontext*, const Theme*, s64 index_off, s64 count, s64 row
void drawAppLable(NVGcontext* vg, const Theme*, ScrollingText& st, float x, float y, float w, const char* name);
void drawSpinner(NVGcontext* vg, const Theme*, float cx, float cy, float r, float t);
void updateHighlightAnimation();
void getHighlightAnimation(float* gradientX, float* gradientY, float* color);

View File

@@ -54,7 +54,7 @@ public:
m_pos = { x, y, w, h };
}
auto SetPos(Vec4 v) noexcept -> void {
auto SetPos(const Vec4& v) noexcept -> void {
m_pos = v;
}

View File

@@ -9,7 +9,7 @@ class OptionBoxEntry final : public Widget {
public:
public:
OptionBoxEntry(const std::string& text, Vec4 pos);
OptionBoxEntry(const std::string& text, const Vec4& pos);
auto Update(Controller* controller, TouchInfo* touch) -> void override {}
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
@@ -32,9 +32,10 @@ public:
using Options = std::vector<Option>;
public:
OptionBox(const std::string& message, const Option& a, Callback cb = [](auto){}, int image = 0); // confirm
OptionBox(const std::string& message, const Option& a, const Option& b, Callback cb, int image = 0); // yesno
OptionBox(const std::string& message, const Option& a, const Option& b, s64 index, Callback cb, int image = 0); // yesno
OptionBox(const std::string& message, const Option& a, const Callback& cb = [](auto){}, int image = 0, bool own_image = false); // confirm
OptionBox(const std::string& message, const Option& a, const Option& b, const Callback& cb, int image = 0, bool own_image = false); // yesno
OptionBox(const std::string& message, const Option& a, const Option& b, s64 index, const Callback& cb, int image = 0, bool own_image = false); // yesno
~OptionBox();
auto Update(Controller* controller, TouchInfo* touch) -> void override;
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
@@ -46,9 +47,10 @@ private:
void SetIndex(s64 index);
private:
std::string m_message{};
Callback m_callback{};
int m_image{};
const std::string m_message;
const Callback m_callback;
const int m_image;
const bool m_own_image;
Vec4 m_spacer_line{};

View File

@@ -13,11 +13,11 @@ public:
using Callback = std::function<void(std::optional<s64>)>;
public:
explicit PopupList(std::string title, Items items, Callback cb, s64 index = 0);
PopupList(std::string title, Items items, Callback cb, std::string index);
PopupList(std::string title, Items items, std::string& index_str_ref, s64& index);
PopupList(std::string title, Items items, std::string& index_ref);
PopupList(std::string title, Items items, s64& index_ref);
explicit PopupList(const std::string& title, const Items& items, const Callback& cb, s64 index = 0);
PopupList(const std::string& title, const Items& items, const Callback& cb, const std::string& index);
PopupList(const std::string& title, const Items& items, std::string& index_str_ref, s64& index);
PopupList(const std::string& title, const Items& items, std::string& index_ref);
PopupList(const std::string& title, const Items& items, s64& index_ref);
auto Update(Controller* controller, TouchInfo* touch) -> void override;
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
@@ -29,12 +29,12 @@ private:
private:
static constexpr Vec2 m_title_pos{70.f, 28.f};
static constexpr Vec4 m_block{280.f, 110.f, 720.f, 60.f};
static constexpr Vec4 m_block{280.f, 110.f, SCREEN_HEIGHT, 60.f};
static constexpr float m_text_xoffset{15.f};
static constexpr float m_line_width{1220.f};
std::string m_title{};
Items m_items{};
const std::string m_title;
const Items m_items;
Callback m_callback{};
s64 m_index{}; // index in list array
s64 m_starting_index{};

View File

@@ -11,14 +11,14 @@ namespace sphaira::ui {
struct ProgressBox;
using ProgressBoxCallback = std::function<Result(ProgressBox*)>;
using ProgressBoxDoneCallback = std::function<void(Result rc)>;
// using CancelCallback = std::function<void()>;
struct ProgressBox final : Widget {
ProgressBox(
int image,
const std::string& action,
const std::string& title,
ProgressBoxCallback callback, ProgressBoxDoneCallback done = [](Result rc){},
int cpuid = 1, int prio = PRIO_PREEMPTIVE, int stack_size = 1024*128
const ProgressBoxCallback& callback, const ProgressBoxDoneCallback& done = nullptr
);
~ProgressBox();
@@ -28,6 +28,8 @@ struct ProgressBox final : Widget {
auto SetActionName(const std::string& action) -> ProgressBox&;
auto SetTitle(const std::string& title) -> ProgressBox&;
auto NewTransfer(const std::string& transfer) -> ProgressBox&;
// zeros the saved offset.
auto ResetTranfser() -> ProgressBox&;
auto UpdateTransfer(s64 offset, s64 size) -> ProgressBox&;
// not const in order to avoid copy by using std::swap
auto SetImage(int image) -> ProgressBox&;
@@ -38,16 +40,15 @@ struct ProgressBox final : Widget {
auto ShouldExit() -> bool;
auto ShouldExitResult() -> Result;
void AddCancelEvent(UEvent* event);
void RemoveCancelEvent(const UEvent* event);
// helper functions
auto CopyFile(fs::Fs* fs_src, fs::Fs* fs_dst, const fs::FsPath& src, const fs::FsPath& dst, bool single_threaded = false) -> Result;
auto CopyFile(fs::Fs* fs, const fs::FsPath& src, const fs::FsPath& dst, bool single_threaded = false) -> Result;
auto CopyFile(const fs::FsPath& src, const fs::FsPath& dst, bool single_threaded = false) -> Result;
void Yield();
auto GetCpuId() const {
return m_cpuid;
}
auto OnDownloadProgressCallback() {
return [this](s64 dltotal, s64 dlnow, s64 ultotal, s64 ulnow){
if (this->ShouldExit()) {
@@ -64,6 +65,11 @@ struct ProgressBox final : Widget {
};
}
// auto-clear = false
auto GetCancelEvent() {
return &m_uevent;
}
private:
void FreeImage();
@@ -75,10 +81,12 @@ public:
};
private:
UEvent m_uevent{};
Mutex m_mutex{};
Thread m_thread{};
ThreadData m_thread_data{};
ProgressBoxDoneCallback m_done{};
std::vector<UEvent*> m_cancel_events{};
// shared data start.
std::string m_action{};
@@ -97,7 +105,6 @@ private:
ScrollingText m_scroll_title{};
ScrollingText m_scroll_transfer{};
int m_cpuid{};
int m_image{};
bool m_own_image{};
};

View File

@@ -2,47 +2,136 @@
#include "ui/widget.hpp"
#include "ui/list.hpp"
#include "ui/scrolling_text.hpp"
#include "option.hpp"
#include <memory>
#include <concepts>
#include <utility>
#include <sys/syslimits.h>
namespace sphaira::ui {
class SidebarEntryBase : public Widget {
public:
SidebarEntryBase(std::string&& title);
virtual auto Draw(NVGcontext* vg, Theme* theme) -> void override;
using DependsCallback = std::function<bool(void)>;
using DependsClickCallback = std::function<void(void)>;
public:
explicit SidebarEntryBase(const std::string& title, const std::string& info);
using Widget::Draw;
virtual void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left);
auto OnFocusGained() noexcept -> void override;
auto OnFocusLost() noexcept -> void override;
void DrawEntry(NVGcontext* vg, Theme* theme, const std::string& left, const std::string& right, bool use_selected);
void Depends(const DependsCallback& callback, const std::string& depends_info, const DependsClickCallback& depends_click = {}) {
m_depends_callback = callback;
m_depends_info = depends_info;
m_depends_click = depends_click;
}
void Depends(bool& value, const std::string& depends_info, const DependsClickCallback& depends_click = {}) {
m_depends_callback = [&value](){ return value; };
m_depends_info = depends_info;
m_depends_click = depends_click;
}
void Depends(option::OptionBool& value, const std::string& depends_info, const DependsClickCallback& depends_click = {}) {
m_depends_callback = [&value](){ return value.Get(); };
m_depends_info = depends_info;
m_depends_click = depends_click;
}
void SetDirty(bool dirty = true) {
m_dirty = dirty;
}
auto IsDirty() const -> bool {
return m_dirty;
}
protected:
std::string m_title;
auto IsEnabled() const -> bool {
if (m_depends_callback) {
return m_depends_callback();
}
return true;
}
void DependsClick() const {
if (m_depends_click) {
m_depends_click();
}
}
protected:
const std::string m_title;
private:
const std::string m_info;
std::string m_depends_info{};
DependsCallback m_depends_callback{};
DependsClickCallback m_depends_click{};
ScrollingText m_scolling_title{};
ScrollingText m_scolling_value{};
bool m_dirty{};
};
template<typename T>
concept DerivedFromSidebarBase = std::is_base_of_v<SidebarEntryBase, T>;
class SidebarEntryBool final : public SidebarEntryBase {
public:
using Callback = std::function<void(bool&)>;
public:
SidebarEntryBool(std::string title, bool option, Callback cb, std::string true_str = "On", std::string false_str = "Off");
SidebarEntryBool(std::string title, bool& option, std::string true_str = "On", std::string false_str = "Off");
explicit SidebarEntryBool(const std::string& title, bool option, const Callback& cb, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, bool& option, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, option::OptionBool& option, const Callback& cb, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, option::OptionBool& option, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
private:
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
bool m_option;
Callback m_callback;
std::string m_true_str;
std::string m_false_str;
};
class SidebarEntrySlider final : public SidebarEntryBase {
public:
using Callback = std::function<void(float&)>;
public:
explicit SidebarEntrySlider(const std::string& title, float value, float min, float max, int steps, const Callback& cb, const std::string& info = "");
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
private:
float m_value;
float m_min;
float m_max;
int m_steps;
Callback m_callback;
float m_duration;
float m_inc;
};
class SidebarEntryCallback final : public SidebarEntryBase {
public:
using Callback = std::function<void()>;
public:
SidebarEntryCallback(std::string title, Callback cb, bool pop_on_click = false);
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
explicit SidebarEntryCallback(const std::string& title, const Callback& cb, const std::string& info);
explicit SidebarEntryCallback(const std::string& title, const Callback& cb, bool pop_on_click = false, const std::string& info = "");
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
private:
Callback m_callback;
bool m_pop_on_click;
const Callback m_callback;
const bool m_pop_on_click;
};
class SidebarEntryArray final : public SidebarEntryBase {
@@ -52,85 +141,144 @@ public:
using Callback = std::function<void(s64& index)>;
public:
explicit SidebarEntryArray(std::string title, Items items, Callback cb, s64 index = 0);
SidebarEntryArray(std::string title, Items items, Callback cb, std::string index);
SidebarEntryArray(std::string title, Items items, std::string& index);
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
auto OnFocusGained() noexcept -> void override;
auto OnFocusLost() noexcept -> void override;
explicit SidebarEntryArray(const std::string& title, const Items& items, const Callback& cb, s64 index = 0, const std::string& info = "");
explicit SidebarEntryArray(const std::string& title, const Items& items, const Callback& cb, const std::string& index, const std::string& info = "");
explicit SidebarEntryArray(const std::string& title, const Items& items, std::string& index, const std::string& info = "");
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
private:
Items m_items;
ListCallback m_list_callback;
Callback m_callback;
const Items m_items;
const Callback m_callback;
s64 m_index;
s64 m_tick{};
float m_text_yoff{};
ListCallback m_list_callback{};
};
template <typename T>
class SidebarEntrySlider final : public SidebarEntryBase {
// single text entry.
// the callback is called when the entry is clicked.
// usually, the within the callback the text will be changed, use SetText().
class SidebarEntryTextBase : public SidebarEntryBase {
public:
SidebarEntrySlider(std::string title, T& value, T min, T max)
: SidebarEntryBase{title}
, m_value{value}
, m_min{min}
, m_max{max} {
using Callback = std::function<void(void)>;
public:
explicit SidebarEntryTextBase(const std::string& title, const std::string& value, const Callback& cb, const std::string& info = "");
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
void SetCallback(const Callback& cb) {
m_callback = cb;
}
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
auto Update(Controller* controller, TouchInfo* touch) -> void override;
auto GetValue() const -> const std::string& {
return m_value;
}
void SetValue(const std::string& value) {
m_value = value;
}
private:
T& m_value;
T m_min;
T m_max;
T m_step{};
Vec4 m_bar{};
Vec4 m_bar_fill{};
std::string m_value;
Callback m_callback;
};
class Sidebar final : public Widget {
class SidebarEntryTextInput final : public SidebarEntryTextBase {
public:
enum class Side { LEFT, RIGHT };
using Items = std::vector<std::shared_ptr<SidebarEntryBase>>;
using Callback = std::function<void(SidebarEntryTextInput* input)>;
public:
Sidebar(std::string title, Side side, Items&& items);
Sidebar(std::string title, Side side);
Sidebar(std::string title, std::string sub, Side side, Items&& items);
Sidebar(std::string title, std::string sub, Side side);
// uses normal keyboard.
explicit SidebarEntryTextInput(const std::string& title, const std::string& value, const std::string& header = {}, const std::string& guide = {}, s64 len_min = -1, s64 len_max = PATH_MAX, const std::string& info = "", const Callback& callback = nullptr);
// uses numpad.
explicit SidebarEntryTextInput(const std::string& title, s64 value, const std::string& header = {}, const std::string& guide = {}, s64 len_min = -1, s64 len_max = PATH_MAX, const std::string& info = "", const Callback& callback = nullptr);
auto GetNumValue() const -> s64 {
return std::stoul(GetValue());
}
void SetNumValue(s64 value) {
SetValue(std::to_string(value));
}
private:
const std::string m_header;
const std::string m_guide;
const s64 m_len_min;
const s64 m_len_max;
const Callback m_callback;
};
class SidebarEntryFilePicker final : public SidebarEntryTextBase {
public:
explicit SidebarEntryFilePicker(const std::string& title, const std::string& value, const std::vector<std::string>& filter, const std::string& info = "");
// extension filter.
void SetFilter(const std::vector<std::string>& filter) {
m_filter = filter;
}
private:
std::vector<std::string> m_filter{};
};
class Sidebar : public Widget {
public:
enum class Side { LEFT, RIGHT };
using Items = std::vector<std::unique_ptr<SidebarEntryBase>>;
using OnExitWhenChangedCallback = std::function<void()>;
public:
explicit Sidebar(const std::string& title, Side side, float width = 450.f);
explicit Sidebar(const std::string& title, const std::string& sub, Side side, float width = 450.f);
~Sidebar();
auto Update(Controller* controller, TouchInfo* touch) -> void override;
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
auto OnFocusGained() noexcept -> void override;
auto OnFocusLost() noexcept -> void override;
void Add(std::shared_ptr<SidebarEntryBase> entry);
auto Add(std::unique_ptr<SidebarEntryBase>&& entry) -> SidebarEntryBase*;
template<DerivedFromSidebarBase T, typename... Args>
auto Add(Args&&... args) -> T* {
return (T*)Add(std::make_unique<T>(std::forward<Args>(args)...));
}
// sets a callback that is called on exit when the any options were changed.
// the change detection isn't perfect, it just checks if the A button was pressed...
void SetOnExitWhenChanged(const OnExitWhenChangedCallback& cb) {
m_on_exit_when_changed = cb;
}
private:
void SetIndex(s64 index);
void SetupButtons();
private:
std::string m_title;
std::string m_sub;
Side m_side;
Items m_items;
const std::string m_title;
const std::string m_sub;
const Side m_side;
Items m_items{};
s64 m_index{};
std::unique_ptr<List> m_list;
std::unique_ptr<List> m_list{};
Vec4 m_top_bar{};
Vec4 m_bottom_bar{};
Vec2 m_title_pos{};
Vec4 m_base_pos{};
OnExitWhenChangedCallback m_on_exit_when_changed{};
static constexpr float m_title_size{28.f};
// static constexpr Vec2 box_size{380.f, 70.f};
static constexpr Vec2 m_box_size{400.f, 70.f};
};
class FormSidebar : public Sidebar {
public:
explicit FormSidebar(const std::string& title) : Sidebar{title, Side::LEFT, 540.f} {
// explicit FormSidebar(const std::string& title) : Sidebar{title, Side::LEFT} {
}
};
} // namespace sphaira::ui

View File

@@ -1,7 +1,6 @@
#pragma once
#include "nanovg.h"
#include "pulsar.h"
#include "fs.hpp"
#include <switch.h>
@@ -56,8 +55,8 @@ struct Vec2 {
struct Vec4 {
constexpr Vec4() = default;
constexpr Vec4(float _x, float _y, float _w, float _h) : x{_x}, y{_y}, w{_w}, h{_h} {}
constexpr Vec4(Vec2 vec0, Vec2 vec1) : x{vec0.x}, y{vec0.y}, w{vec1.x}, h{vec1.y} {}
constexpr Vec4(Vec4 vec0, Vec4 vec1) : x{vec0.x}, y{vec0.y}, w{vec1.w}, h{vec1.h} {}
constexpr Vec4(const Vec2& vec0, const Vec2& vec1) : x{vec0.x}, y{vec0.y}, w{vec1.x}, h{vec1.y} {}
constexpr Vec4(const Vec4& vec0, const Vec4& vec1) : x{vec0.x}, y{vec0.y}, w{vec1.w}, h{vec1.h} {}
float& operator[](std::size_t idx) {
switch (idx) {
@@ -229,6 +228,7 @@ struct ThemeMeta {
struct Theme {
ThemeMeta meta;
ElementEntry elements[ThemeEntryID_MAX];
fs::FsPath music_path;
auto GetColour(ThemeEntryID id) const {
return elements[id].colour;
@@ -274,6 +274,13 @@ enum class Button : u64 {
START = static_cast<u64>(HidNpadButton_Plus),
SELECT = static_cast<u64>(HidNpadButton_Minus),
SL_LEFT = static_cast<u64>(HidNpadButton_LeftSL),
SR_LEFT = static_cast<u64>(HidNpadButton_LeftSR),
SL_RIGHT = static_cast<u64>(HidNpadButton_RightSL),
SR_RIGHT = static_cast<u64>(HidNpadButton_RightSR),
SL_ANY = SL_LEFT | SL_RIGHT,
SR_ANY = SR_LEFT | SR_RIGHT,
// todo:
DPAD_LEFT = static_cast<u64>(HidNpadButton_Left),
DPAD_RIGHT = static_cast<u64>(HidNpadButton_Right),
@@ -284,11 +291,13 @@ enum class Button : u64 {
LS_RIGHT = static_cast<u64>(HidNpadButton_StickLRight),
LS_UP = static_cast<u64>(HidNpadButton_StickLUp),
LS_DOWN = static_cast<u64>(HidNpadButton_StickLDown),
LS_ANY = LS_LEFT | LS_RIGHT | LS_UP | LS_DOWN,
RS_LEFT = static_cast<u64>(HidNpadButton_StickRLeft),
RS_RIGHT = static_cast<u64>(HidNpadButton_StickRRight),
RS_UP = static_cast<u64>(HidNpadButton_StickRUp),
RS_DOWN = static_cast<u64>(HidNpadButton_StickRDown),
RS_ANY = RS_LEFT | RS_RIGHT | RS_UP | RS_DOWN,
ANY_LEFT = static_cast<u64>(HidNpadButton_AnyLeft),
ANY_RIGHT = static_cast<u64>(HidNpadButton_AnyRight),
@@ -332,10 +341,10 @@ struct Action final {
CallbackWithBool
>;
Action(Callback cb) : Action{ActionType::DOWN, "", cb} {}
Action(std::string hint, Callback cb) : Action{ActionType::DOWN, hint, cb} {}
Action(u8 type, Callback cb) : Action{type, "", cb} {}
Action(u8 type, std::string hint, Callback cb) : m_type{type}, m_callback{cb}, m_hint{hint} {}
explicit Action(const Callback& cb) : Action{ActionType::DOWN, "", cb} {}
explicit Action(const std::string& hint, const Callback& cb) : Action{ActionType::DOWN, hint, cb} {}
explicit Action(u8 type, const Callback& cb) : Action{type, "", cb} {}
explicit Action(u8 type, const std::string& hint, const Callback& cb) : m_type{type}, m_callback{cb}, m_hint{hint} {}
auto IsHidden() const noexcept { return m_hint.empty(); }
@@ -357,6 +366,81 @@ struct Action final {
std::string m_hint{};
};
struct GenericHidState {
GenericHidState() {
Reset();
}
void Reset() {
buttons_cur = 0;
buttons_old = 0;
}
u64 GetButtons() const {
return buttons_cur;
}
u64 GetButtonsDown() const {
return buttons_cur & ~buttons_old;
}
u64 GetButtonsUp() const {
return ~buttons_cur & buttons_old;
}
virtual void Update() = 0;
protected:
u64 buttons_cur;
u64 buttons_old;
};
struct KeyboardState final : GenericHidState {
struct MapEntry {
HidKeyboardKey key;
u64 button;
};
using Map = std::span<const MapEntry>;
void Init(Map map) {
m_map = map;
Reset();
}
void Update() override {
buttons_old = buttons_cur;
buttons_cur = 0;
if (!hidGetKeyboardStates(&m_state, 1)) {
return;
}
const auto ctrl = m_state.modifiers & HidKeyboardModifier_Control;
const auto shift = m_state.modifiers & HidKeyboardModifier_Shift;
for (const auto& map : m_map) {
if (hidKeyboardStateGetKey(&m_state, map.key)) {
if (shift && map.button == static_cast<u64>(Button::L)) {
buttons_cur |= static_cast<u64>(Button::L2);
} else if (shift && map.button == static_cast<u64>(Button::R)) {
buttons_cur |= static_cast<u64>(Button::R2);
} else if (ctrl && map.button == static_cast<u64>(Button::L)) {
buttons_cur |= static_cast<u64>(Button::L3);
} else if (ctrl && map.button == static_cast<u64>(Button::R)) {
buttons_cur |= static_cast<u64>(Button::R3);
} else {
buttons_cur |= map.button;
}
}
}
}
private:
Map m_map{};
HidKeyboardState m_state{};
};
struct Controller {
u64 m_kdown{};
u64 m_kheld{};
@@ -388,26 +472,44 @@ struct Controller {
m_kup = 0;
}
void UpdateButtonHeld(u64 buttons) {
void UpdateButtonHeld(u64 buttons, double delta) {
if (m_kdown & buttons) {
m_step = 50;
m_step_max = m_MAX_STEP;
m_step = m_INC_STEP;
m_counter = 0;
m_step_max_counter = 0;
} else if (m_kheld & buttons) {
m_counter += m_step;
m_counter += m_step * delta;
// if we are at the max, ignore the delta and go as fast as the frame rate.
if (m_step_max == m_MAX) {
m_counter = m_MAX;
}
if (m_counter >= m_MAX) {
m_kdown |= m_kheld & buttons;
m_counter = 0;
m_step = std::min(m_step + 50, m_MAX_STEP);
m_step = std::min(m_step + m_INC_STEP, m_step_max);
// slowly speed up until we reach 1 button down per frame.
m_step_max_counter++;
if (m_step_max_counter >= 5) {
m_step_max_counter = 0;
m_step_max = std::min(m_step_max + m_INC_STEP, m_MAX);
}
}
}
}
private:
static constexpr int m_MAX = 1000;
static constexpr int m_MAX_STEP = 250;
int m_step = 50;
int m_counter = 0;
static constexpr double m_MAX = 1000;
static constexpr double m_MAX_STEP = 250;
static constexpr double m_INC_STEP = 50;
double m_step_max = m_MAX_STEP;
double m_step = m_INC_STEP;
double m_counter = 0;
int m_step_max_counter = 0;
};
} // namespace sphaira

View File

@@ -5,15 +5,19 @@
#include <memory>
#include <map>
#include <unordered_map>
#include <concepts>
namespace sphaira::ui {
struct uiButton final : Object {
uiButton(Button button, Action action) : m_button{button}, m_action{action} {}
uiButton(Button button, const std::string& button_str, const std::string& action_str);
uiButton(Button button, const std::string& action_str);
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
Button m_button;
Action m_action;
std::string m_button_str;
std::string m_action_str;
Vec4 m_button_pos{};
Vec4 m_hint_pos{};
};
@@ -44,8 +48,8 @@ struct Widget : public Object {
}
auto HasAction(Button button) const -> bool;
void SetAction(Button button, Action action);
void SetActions(std::same_as<std::pair<Button, Action>> auto ...args) {
void SetAction(Button button, const Action& action);
void SetActions(std::same_as<std::pair<Button, Action>> auto&& ...args) {
const std::array list = {args...};
for (const auto& [button, action] : list) {
SetAction(button, action);
@@ -83,6 +87,8 @@ struct Widget : public Object {
}
auto GetUiButtons() const -> uiButtons;
static void SetupUiButtons(uiButtons& buttons, const Vec2& button_pos = {1220, 675});
static auto GetUiButtons(const Actions& actions, const Vec2& button_pos = {1220, 675}) -> uiButtons;
Actions m_actions{};
Vec2 m_button_pos{1220, 675};
@@ -90,4 +96,7 @@ struct Widget : public Object {
bool m_pop{false};
};
template<typename T>
concept DerivedFromWidget = std::is_base_of_v<Widget, T>;
} // namespace sphaira::ui

View File

@@ -2,7 +2,7 @@
#include <vector>
#include <string>
#include <new>
#include <memory>
#include <switch.h>
namespace sphaira::usb {
@@ -39,43 +39,10 @@ struct Base {
ueventSignal(GetCancelEvent());
}
auto& GetTransferBuffer() {
return m_aligned;
}
auto GetTransferTimeout() const {
return m_transfer_timeout;
}
public:
// custom allocator for std::vector that respects alignment.
// https://en.cppreference.com/w/cpp/named_req/Allocator
template <typename T, std::size_t Align>
struct CustomVectorAllocator {
public:
// https://en.cppreference.com/w/cpp/memory/new/operator_new
auto allocate(std::size_t n) -> T* {
n = (n + (Align - 1)) &~ (Align - 1);
return new(align) T[n];
}
// https://en.cppreference.com/w/cpp/memory/new/operator_delete
auto deallocate(T* p, std::size_t n) noexcept -> void {
// ::operator delete[] (p, n, align);
::operator delete[] (p, align);
}
private:
static constexpr inline std::align_val_t align{Align};
};
template <typename T>
struct PageAllocator : CustomVectorAllocator<T, 0x1000> {
using value_type = T; // used by std::vector
};
using PageAlignedVector = std::vector<u8, PageAllocator<u8>>;
protected:
enum UsbSessionEndpoint {
UsbSessionEndpoint_In = 0,
@@ -90,7 +57,7 @@ protected:
private:
u64 m_transfer_timeout{};
UEvent m_uevent{};
PageAlignedVector m_aligned{};
std::unique_ptr<u8*> m_aligned{};
};
} // namespace sphaira::usb

View File

@@ -1,57 +0,0 @@
#pragma once
#include <switch.h>
namespace sphaira::usb::tinfoil {
enum Magic : u32 {
Magic_List0 = 0x304C5554, // TUL0 (Tinfoil Usb List 0)
Magic_Command0 = 0x30435554, // TUC0 (Tinfoil USB Command 0)
};
enum USBCmdType : u8 {
REQUEST = 0,
RESPONSE = 1
};
enum USBCmdId : u32 {
EXIT = 0,
FILE_RANGE = 1
};
// extension flags for sphaira.
enum USBFlag : u8 {
USBFlag_NONE = 0,
// stream install, does not allow for random access.
// allows the upload to be multi threaded., do not modify!
// the order of the file list must be kept as-is.
USBFlag_STREAM = 1 << 0,
};
struct TUSHeader {
u32 magic; // TUL0 (Tinfoil Usb List 0)
u32 nspListSize;
u8 flags;
u8 padding[0x7];
};
struct NX_PACKED USBCmdHeader {
u32 magic; // TUC0 (Tinfoil USB Command 0)
USBCmdType type;
u8 padding[0x3];
u32 cmdId;
u64 dataSize;
u8 reserved[0xC];
};
struct FileRangeCmdHeader {
u64 size;
u64 offset;
u64 nspNameLen;
u64 padding;
};
static_assert(sizeof(TUSHeader) == 0x10, "TUSHeader must be 0x10!");
static_assert(sizeof(USBCmdHeader) == 0x20, "USBCmdHeader must be 0x20!");
} // namespace sphaira::usb::tinfoil

View File

@@ -0,0 +1,112 @@
#pragma once
#include <switch.h>
#include "defines.hpp"
namespace sphaira::usb::api {
enum : u32 {
MAGIC = 0x53504830,
PACKET_SIZE = 24,
};
enum : u32 {
CMD_QUIT = 0,
CMD_OPEN = 1,
CMD_EXPORT = 1,
};
enum : u32 {
RESULT_OK = 0,
RESULT_ERROR = 1,
};
enum : u32 {
FLAG_NONE = 0,
FLAG_STREAM = 1 << 0,
};
struct UsbPacket {
u32 magic{};
u32 arg2{};
u32 arg3{};
u32 arg4{};
u32 arg5{};
u32 crc32c{}; // crc32 over the above 16 bytes.
protected:
u32 CalculateCrc32c() const {
return crc32cCalculate(this, 20);
}
void GenerateCrc32c() {
crc32c = CalculateCrc32c();
}
Result Verify() const {
R_UNLESS(crc32c == CalculateCrc32c(), 1); // todo: add error code.
R_UNLESS(magic == MAGIC, Result_UsbBadMagic);
R_SUCCEED();
}
};
struct SendPacket : UsbPacket {
static SendPacket Build(u32 cmd, u32 arg3 = 0, u32 arg4 = 0) {
SendPacket packet{MAGIC, cmd, arg3, arg4};
packet.GenerateCrc32c();
return packet;
}
Result Verify() const {
return UsbPacket::Verify();
}
u32 GetCmd() const {
return arg2;
}
};
struct ResultPacket : UsbPacket {
static ResultPacket Build(u32 result, u32 arg3 = 0, u32 arg4 = 0) {
ResultPacket packet{MAGIC, result, arg3, arg4};
packet.GenerateCrc32c();
return packet;
}
Result Verify() const {
R_TRY(UsbPacket::Verify());
R_UNLESS(arg2 == RESULT_OK, 1); // todo: create error code.
R_SUCCEED();
}
};
struct SendDataPacket : UsbPacket {
static SendDataPacket Build(u64 off, u32 size, u32 crc32c) {
SendDataPacket packet{MAGIC, u32(off >> 32), u32(off), size, crc32c};
packet.GenerateCrc32c();
return packet;
}
Result Verify() const {
return UsbPacket::Verify();
}
u64 GetOffset() const {
return (u64(arg2) << 32) | arg3;
}
u32 GetSize() const {
return arg4;
}
u32 GetCrc32c() const {
return arg5;
}
};
static_assert(sizeof(UsbPacket) == PACKET_SIZE);
static_assert(sizeof(SendPacket) == PACKET_SIZE);
static_assert(sizeof(ResultPacket) == PACKET_SIZE);
static_assert(sizeof(SendDataPacket) == PACKET_SIZE);
} // namespace sphaira::usb::api

View File

@@ -0,0 +1,45 @@
#pragma once
#include "usb/usbds.hpp"
#include "usb/usb_api.hpp"
#include <vector>
#include <memory>
#include <string_view>
#include <switch.h>
namespace sphaira::usb::dump {
struct Usb {
Usb(u64 transfer_timeout);
~Usb();
Result Write(const void* buf, u64 off, u32 size);
void SignalCancel();
// waits for connection and then sends file list.
Result IsUsbConnected(u64 timeout);
Result WaitForConnection(std::string_view path, u64 timeout);
// Result OpenFile(u32 index, s64& file_size);
Result CloseFile();
auto GetOpenResult() const {
return m_open_result;
}
auto GetCancelEvent() {
return m_usb->GetCancelEvent();
}
private:
Result SendAndVerify(const void* data, u32 size, u64 timeout, api::ResultPacket* out = nullptr);
Result SendAndVerify(const void* data, u32 size, api::ResultPacket* out = nullptr);
private:
std::unique_ptr<usb::UsbDs> m_usb{};
Result m_open_result{};
bool m_was_connected{};
};
} // namespace sphaira::usb::dumpl

View File

@@ -0,0 +1,47 @@
#pragma once
#include "usb/usbds.hpp"
#include "usb/usb_api.hpp"
#include <string>
#include <vector>
#include <memory>
#include <switch.h>
namespace sphaira::usb::install {
struct Usb {
Usb(u64 transfer_timeout);
~Usb();
Result Read(void* buf, u64 off, u32 size, u64* bytes_read);
u32 GetFlags() const;
void SignalCancel();
// waits for connection and then sends file list.
Result IsUsbConnected(u64 timeout);
Result WaitForConnection(u64 timeout, std::vector<std::string>& names);
Result OpenFile(u32 index, s64& file_size);
Result CloseFile();
auto GetOpenResult() const {
return m_open_result;
}
auto GetCancelEvent() {
return m_usb->GetCancelEvent();
}
private:
Result SendAndVerify(const void* data, u32 size, u64 timeout, api::ResultPacket* out = nullptr);
Result SendAndVerify(const void* data, u32 size, api::ResultPacket* out = nullptr);
private:
std::unique_ptr<usb::UsbDs> m_usb{};
Result m_open_result{};
bool m_was_connected{};
u32 m_flags{};
};
} // namespace sphaira::usb::install

View File

@@ -13,24 +13,38 @@ struct Usb {
Usb(u64 transfer_timeout);
virtual ~Usb();
virtual Result Read(const std::string& path, void* buf, s64 off, s64 size, u64* bytes_read) = 0;
virtual Result Read(void* buf, u64 off, u32 size, u64* bytes_read) = 0;
virtual Result Open(u32 index, s64& out_size, u16& out_flags) = 0;
Result IsUsbConnected(u64 timeout) {
return m_usb->IsUsbConnected(timeout);
}
// waits for connection and then sends file list.
Result WaitForConnection(u64 timeout, u8 flags, std::span<const std::string> names);
Result WaitForConnection(u64 timeout, std::span<const std::string> names);
// polls for command, executes transfer if possible.
// will return Result_Exit if exit command is recieved.
Result PollCommands();
private:
Result FileRangeCmd(u64 data_size);
Result file_transfer_loop();
auto GetOpenResult() const {
return m_open_result;
}
auto GetCancelEvent() {
return m_usb->GetCancelEvent();
}
private:
std::unique_ptr<usb::UsbHs> m_usb;
Result SendResult(u32 result, u32 arg3 = 0, u32 arg4 = 0);
private:
std::unique_ptr<usb::UsbHs> m_usb{};
std::vector<u8> m_buf{};
Result m_open_result{};
bool m_was_connected{};
};
} // namespace sphaira::usb::upload

View File

@@ -2,10 +2,8 @@
#include "base.hpp"
// TODO: remove these when libnx pr is merged.
enum { UsbDeviceSpeed_None = 0x0 };
enum { UsbDeviceSpeed_Low = 0x1 };
Result usbDsGetSpeed(UsbDeviceSpeed *out);
auto GetUsbDsStateStr(UsbState state) -> const char*;
auto GetUsbDsSpeedStr(UsbDeviceSpeed speed) -> const char*;
namespace sphaira::usb {

View File

@@ -0,0 +1,13 @@
#pragma once
#include <switch.h>
#include "location.hpp"
namespace sphaira::usbdvd {
Result MountAll();
void UnmountAll();
bool GetMountPoint(location::StdioEntry& out);
} // namespace sphaira::usbdvd

View File

@@ -0,0 +1,81 @@
#pragma once
#include "fs.hpp"
#include "image.hpp"
#include <string>
#include <memory>
namespace sphaira::audio {
enum class State {
Free, // private use.
Playing, // song is playing.
Paused, // song has paused.
Finished, // song has finished.
Error, // error in playback.
};
struct Progress {
u64 played;
};
struct Info {
u64 sample_count;
u32 sample_rate;
u32 channels;
u32 loop_start;
bool looping;
};
struct Meta {
std::string title{};
std::string album{};
std::string artist{};
std::vector<u8> image{};
};
enum class SoundEffect {
Focus,
Scroll,
Limit,
Startup,
Install,
Error,
MAX,
};
enum Flag {
Flag_None = 0,
// plays the song for ever.
Flag_Loop = 1 << 0,
};
using SongID = void*;
Result Init();
void ExitSignal();
void Exit();
Result PlaySoundEffect(SoundEffect effect);
Result OpenSong(fs::Fs* fs, const fs::FsPath& path, u32 flags, SongID* id);
Result CloseSong(SongID* id);
Result PlaySong(SongID id);
Result PauseSong(SongID id);
Result SeekSong(SongID id, u64 target);
// todo:
// 0.0 -> 2.0.
Result GetVolumeSong(SongID id, float* out);
Result SetVolumeSong(SongID id, float in);
// todo:
Result GetPitchSong(SongID id, float* out);
Result SetPitchSong(SongID id, float in);
Result GetInfo(SongID id, Info* out);
Result GetMeta(SongID id, Meta* out);
Result GetProgress(SongID id, Progress* out_progress, State* out_state);
} // namespace sphaira::audio

View File

@@ -0,0 +1,43 @@
#pragma once
#include "fs.hpp"
#include "yati/source/base.hpp"
#include "location.hpp"
#include <switch.h>
#include <memory>
namespace sphaira::devoptab {
Result MountSaveSystem(u64 id, fs::FsPath& out_path);
Result MountZip(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path);
Result MountNsp(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path);
Result MountXci(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path);
Result MountXciSource(const std::shared_ptr<sphaira::yati::source::Base>& source, s64 size, const fs::FsPath& path, fs::FsPath& out_path);
Result MountNca(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path);
Result MountNcaNcm(NcmContentStorage* cs, const NcmContentId* id, fs::FsPath& out_path);
Result MountBfsar(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path);
Result MountNro(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path);
Result MountVfsAll();
Result MountWebdavAll();
Result MountHttpAll();
Result MountFtpAll();
Result MountSftpAll();
Result MountNfsAll();
Result MountSmb2All();
Result MountFatfsAll();
Result MountGameAll();
Result MountInternalMounts();
Result GetNetworkDevices(location::StdioEntries& out);
void UmountAllNeworkDevices();
void UmountNeworkDevice(const fs::FsPath& mount);
// manually set the array so that we can avoid nullptr access.
// SEE: https://github.com/devkitPro/newlib/issues/35
void FixDkpBug();
void DisplayDevoptabSideBar();
} // namespace sphaira::devoptab

View File

@@ -0,0 +1,227 @@
#pragma once
#include "yati/source/file.hpp"
#include "utils/lru.hpp"
#include "location.hpp"
#include <memory>
#include <optional>
#include <span>
#include <functional>
#include <unordered_map>
#include <curl/curl.h>
namespace sphaira::devoptab::common {
// max entries per devoptab, should be enough.
enum { MAX_ENTRIES = 4 };
struct BufferedDataBase : yati::source::Base {
BufferedDataBase(const std::shared_ptr<yati::source::Base>& _source, u64 _size)
: source{_source}
, capacity{_size} {
}
virtual Result Read(void* buf, s64 off, s64 size, u64* bytes_read) override {
return source->Read(buf, off, size, bytes_read);
}
protected:
std::shared_ptr<yati::source::Base> source;
const u64 capacity;
};
// buffers data in 512k chunks to maximise throughput.
// not suitable if random access >= 512k is common.
// if that is needed, see the LRU cache varient used for fatfs.
struct BufferedData : BufferedDataBase {
BufferedData(const std::shared_ptr<yati::source::Base>& _source, u64 _size, u64 _alloc = 1024 * 512)
: BufferedDataBase{_source, _size} {
m_data.resize(_alloc);
}
virtual Result Read(void* buf, s64 off, s64 size, u64* bytes_read) override;
private:
u64 m_off{};
u64 m_size{};
std::vector<u8> m_data{};
};
struct BufferedFileData {
u8* data{};
u64 off{};
u64 size{};
~BufferedFileData() {
if (data) {
free(data);
}
}
void Allocate(u64 new_size) {
data = (u8*)realloc(data, new_size * sizeof(*data));
off = 0;
size = 0;
}
};
constexpr u64 CACHE_LARGE_ALLOC_SIZE = 1024 * 512;
constexpr u64 CACHE_LARGE_SIZE = 1024 * 16;
struct LruBufferedData : BufferedDataBase {
LruBufferedData(const std::shared_ptr<yati::source::Base>& _source, u64 _size, u32 small = 1024, u32 large = 2)
: BufferedDataBase{_source, _size} {
buffered_small.resize(small);
buffered_large.resize(large);
lru_cache[0].Init(buffered_small);
lru_cache[1].Init(buffered_large);
}
virtual Result Read(void* buf, s64 off, s64 size, u64* bytes_read) override;
private:
utils::Lru<BufferedFileData> lru_cache[2]{};
std::vector<BufferedFileData> buffered_small{}; // 1MiB (usually).
std::vector<BufferedFileData> buffered_large{}; // 1MiB
};
bool fix_path(const char* str, char* out, bool strip_leading_slash = false);
void update_devoptab_for_read_only(devoptab_t* devoptab, bool read_only);
struct PushPullThreadData {
static constexpr size_t MAX_BUFFER_SIZE = 1024 * 64; // 64KB max buffer
explicit PushPullThreadData(CURL* _curl);
virtual ~PushPullThreadData();
Result CreateAndStart();
void Cancel();
bool IsRunning();
// only set curl=true if called from a curl callback.
size_t PullData(char* data, size_t total_size, bool curl = false);
size_t PushData(const char* data, size_t total_size, bool curl = false);
static size_t progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
private:
static void thread_func(void* arg);
public:
CURL* const curl{};
std::vector<char> buffer{};
Mutex mutex{};
CondVar can_push{};
CondVar can_pull{};
long code{};
bool error{};
bool finished{};
bool started{};
private:
Thread thread{};
};
struct MountConfig {
std::string name{};
std::string url{};
std::string user{};
std::string pass{};
std::string dump_path{};
long port{};
long timeout{};
bool read_only{};
bool no_stat_file{true};
bool no_stat_dir{true};
bool fs_hidden{};
bool dump_hidden{};
std::unordered_map<std::string, std::string> extra{};
};
using MountConfigs = std::vector<MountConfig>;
struct PullThreadData final : PushPullThreadData {
using PushPullThreadData::PushPullThreadData;
static size_t pull_thread_callback(char *ptr, size_t size, size_t nmemb, void *userdata);
};
struct PushThreadData final : PushPullThreadData {
using PushPullThreadData::PushPullThreadData;
static size_t push_thread_callback(const char *ptr, size_t size, size_t nmemb, void *userdata);
};
struct MountDevice {
MountDevice(const MountConfig& _config) : config{_config} {}
virtual ~MountDevice() = default;
virtual bool fix_path(const char* str, char* out, bool strip_leading_slash = false) {
return common::fix_path(str, out, strip_leading_slash);
}
virtual bool Mount() = 0;
virtual int devoptab_open(void *fileStruct, const char *path, int flags, int mode) { return -EIO; }
virtual int devoptab_close(void *fd) { return -EIO; }
virtual ssize_t devoptab_read(void *fd, char *ptr, size_t len) { return -EIO; }
virtual ssize_t devoptab_write(void *fd, const char *ptr, size_t len) { return -EIO; }
virtual ssize_t devoptab_seek(void *fd, off_t pos, int dir) { return 0; }
virtual int devoptab_fstat(void *fd, struct stat *st) { return -EIO; }
virtual int devoptab_unlink(const char *path) { return -EIO; }
virtual int devoptab_rename(const char *oldName, const char *newName) { return -EIO; }
virtual int devoptab_mkdir(const char *path, int mode) { return -EIO; }
virtual int devoptab_rmdir(const char *path) { return -EIO; }
virtual int devoptab_diropen(void* fd, const char *path) { return -EIO; }
virtual int devoptab_dirreset(void* fd) { return -EIO; }
virtual int devoptab_dirnext(void* fd, char *filename, struct stat *filestat) { return -EIO; }
virtual int devoptab_dirclose(void* fd) { return -EIO; }
virtual int devoptab_lstat(const char *path, struct stat *st) { return -EIO; }
virtual int devoptab_ftruncate(void *fd, off_t len) { return -EIO; }
virtual int devoptab_statvfs(const char *_path, struct statvfs *buf) { return -EIO; }
virtual int devoptab_fsync(void *fd) { return -EIO; }
virtual int devoptab_utimes(const char *_path, const struct timeval times[2]) { return -EIO; }
const MountConfig config;
};
struct MountCurlDevice : MountDevice {
using MountDevice::MountDevice;
virtual ~MountCurlDevice();
PushThreadData* CreatePushData(CURL* curl, const std::string& url, size_t offset);
PullThreadData* CreatePullData(CURL* curl, const std::string& url, bool append = false);
virtual bool Mount();
virtual void curl_set_common_options(CURL* curl, const std::string& url);
static size_t write_memory_callback(char *ptr, size_t size, size_t nmemb, void *userdata);
static size_t write_data_callback(char *ptr, size_t size, size_t nmemb, void *userdata);
static size_t read_data_callback(char *ptr, size_t size, size_t nmemb, void *userdata);
static std::string html_decode(const std::string_view& str);
static std::string url_decode(const std::string& str);
std::string build_url(const std::string& path, bool is_dir);
protected:
CURL* curl{};
CURL* transfer_curl{};
private:
// path extracted from the url.
std::string m_url_path{};
CURLU* curlu{};
CURLSH* m_curl_share{};
RwLock m_rwlocks[CURL_LOCK_DATA_LAST]{};
bool m_mounted{};
};
void LoadConfigsFromIni(const fs::FsPath& path, MountConfigs& out_configs);
using CreateDeviceCallback = std::function<std::unique_ptr<MountDevice>(const MountConfig& config)>;
Result MountNetworkDevice(const CreateDeviceCallback& create_device, size_t file_size, size_t dir_size, const char* name, bool force_read_only = false);
// same as above but takes in the device and expects the mount name to be set.
bool MountNetworkDevice2(std::unique_ptr<MountDevice>&& device, const MountConfig& config, size_t file_size, size_t dir_size, const char* name, const char* mount_name);
bool MountReadOnlyIndexDevice(const CreateDeviceCallback& create_device, size_t file_size, size_t dir_size, const char* name, fs::FsPath& out_path);
} // namespace sphaira::devoptab::common

View File

@@ -0,0 +1,41 @@
#pragma once
#include "yati/source/base.hpp"
#include <memory>
#include <span>
#include <vector>
#include <string_view>
#include <sys/stat.h>
namespace sphaira::devoptab::romfs {
struct RomfsCollection {
romfs_header header;
std::vector<u8> dir_table;
std::vector<u8> file_table;
u64 offset;
};
struct FileEntry {
const romfs_file* romfs;
u64 offset;
u64 size;
};
struct DirEntry {
const RomfsCollection* romfs_collection;
const romfs_dir* romfs_root; // start of the dir.
u32 romfs_childDir;
u32 romfs_childFile;
};
bool find_file(const RomfsCollection& romfs, std::string_view path, FileEntry& out);
bool find_dir(const RomfsCollection& romfs, std::string_view path, DirEntry& out);
// helper
void dirreset(DirEntry& entry);
bool dirnext(DirEntry& entry, char* filename, struct stat *filestat);
Result LoadRomfsCollection(yati::source::Base* source, u64 offset, RomfsCollection& out);
} // namespace sphaira::devoptab::romfs

View File

@@ -0,0 +1,76 @@
#pragma once
#include <vector>
#include <span>
namespace sphaira::utils {
template<typename T>
struct LinkedList {
T* data;
LinkedList* next;
LinkedList* prev;
};
template<typename T>
struct Lru {
using ListEntry = LinkedList<T>;
// pass span of the data.
void Init(std::span<T> data) {
list_flat_array.clear();
list_flat_array.resize(data.size());
auto list_entry = list_head = list_flat_array.data();
for (size_t i = 0; i < data.size(); i++) {
list_entry = list_flat_array.data() + i;
list_entry->data = data.data() + i;
if (i + 1 < data.size()) {
list_entry->next = &list_flat_array[i + 1];
}
if (i) {
list_entry->prev = &list_flat_array[i - 1];
}
}
list_tail = list_entry->prev->next;
}
// moves entry to the front of the list.
void Update(ListEntry* entry) {
// only update position if we are not the head.
if (list_head != entry) {
entry->prev->next = entry->next;
if (entry->next) {
entry->next->prev = entry->prev;
} else {
list_tail = entry->prev;
}
// update head.
auto head_temp = list_head;
list_head = entry;
list_head->prev = nullptr;
list_head->next = head_temp;
head_temp->prev = list_head;
}
}
// moves last entry (tail) to the front of the list.
auto GetNextFree() {
Update(list_tail);
return list_head->data;
}
auto begin() const { return list_head; }
auto end() const { return list_tail; }
private:
ListEntry* list_head{};
ListEntry* list_tail{};
std::vector<ListEntry> list_flat_array{};
};
} // namespace sphaira::utils

View File

@@ -0,0 +1,23 @@
#pragma once
#include "fs.hpp"
#include "defines.hpp"
#include "dumper.hpp"
#include "ui/progress_box.hpp"
#include "yati/nx/keys.hpp"
#include "yati/nx/nca.hpp"
#include "yati/container/base.hpp"
#include <functional>
namespace sphaira::utils::nsz {
using Collection = yati::container::CollectionEntry;
using Collections = yati::container::Collections;
using NcaReaderCreator = std::function<std::unique_ptr<nca::NcaReader>(const nca::Header& header, const keys::KeyEntry& title_key, const Collection& collection)>;
Result NszExport(ui::ProgressBox* pbox, const NcaReaderCreator& nca_creator, s64& read_offset, s64& write_offset, Collections& collections, const keys::Keys& keys, dump::BaseSource* source, dump::WriteSource* writer, const fs::FsPath& path);
} // namespace sphaira::utils::nsz

View File

@@ -0,0 +1,28 @@
#pragma once
#include "ui/types.hpp"
#include "log.hpp"
namespace sphaira::utils {
struct ScopedTimestampProfile final {
ScopedTimestampProfile(const std::string& name) : m_name{name} {
}
~ScopedTimestampProfile() {
Log();
}
void Log() {
log_write("\t[%s] time taken: %.2fs %.2fms\n", m_name.c_str(), m_ts.GetSecondsD(), m_ts.GetMsD());
}
private:
const std::string m_name;
TimeStamp m_ts{};
};
#define SCOPED_TIMESTAMP(name) sphaira::utils::ScopedTimestampProfile ANONYMOUS_VARIABLE(SCOPE_PROFILE_STATE_){name};
} // namespace sphaira::utils

View File

@@ -0,0 +1,58 @@
#pragma once
#include "defines.hpp"
#include <functional>
#include <atomic>
namespace sphaira::utils {
static inline Result CreateThread(Thread *t, ThreadFunc entry, void *arg, size_t stack_sz = 1024*128, int prio = 0x3B) {
u64 core_mask = 0;
R_TRY(svcGetInfo(&core_mask, InfoType_CoreMask, CUR_PROCESS_HANDLE, 0));
R_TRY(threadCreate(t, entry, arg, nullptr, stack_sz, prio, -2));
R_TRY(svcSetThreadCoreMask(t->handle, -1, core_mask));
R_SUCCEED();
}
struct Async final {
using Callback = std::function<void(void)>;
// core0=main, core1=audio, core2=servers (ftp,mtp,nxlink)
Async(Callback&& callback) : m_callback{std::forward<Callback>(callback)} {
m_running = true;
if (R_FAILED(CreateThread(&m_thread, thread_func, &m_callback))) {
m_running = false;
return;
}
if (R_FAILED(threadStart(&m_thread))) {
threadClose(&m_thread);
m_running = false;
}
}
~Async() {
WaitForExit();
}
void WaitForExit() {
if (m_running) {
threadWaitForExit(&m_thread);
threadClose(&m_thread);
m_running = false;
}
}
private:
static void thread_func(void* arg) {
(*static_cast<Callback*>(arg))();
}
private:
Callback m_callback;
Thread m_thread{};
std::atomic_bool m_running{};
};
} // namespace sphaira::utils

View File

@@ -0,0 +1,32 @@
#pragma once
#include "ui/types.hpp"
namespace sphaira::utils {
struct HashStr {
char str[0x21];
};
HashStr hexIdToStr(FsRightsId id);
HashStr hexIdToStr(NcmRightsId id);
HashStr hexIdToStr(NcmContentId id);
template<typename T>
constexpr inline T AlignUp(T value, T align) {
return (value + (align - 1)) &~ (align - 1);
}
template<typename T>
constexpr inline T AlignDown(T value, T align) {
return value &~ (align - 1);
}
// formats size to 1.23 MB in 1024 base.
// only uses 32 bytes so its SSO optimised, not need to cache.
std::string formatSizeStorage(u64 size);
// formats size to 1.23 MB in 1000 base (used for progress bars).
std::string formatSizeNetwork(u64 size);
} // namespace sphaira::utils

View File

@@ -29,7 +29,7 @@ using Collections = std::vector<CollectionEntry>;
struct Base {
using Source = source::Base;
Base(std::shared_ptr<Source> source) : m_source{source} { }
Base(Source* source) : m_source{source} { }
virtual ~Base() = default;
virtual Result GetCollections(Collections& out) = 0;
auto GetSource() const {
@@ -37,7 +37,7 @@ struct Base {
}
protected:
std::shared_ptr<Source> m_source;
Source* m_source;
};
} // namespace sphaira::yati::container

View File

@@ -9,9 +9,10 @@ namespace sphaira::yati::container {
struct Nsp final : Base {
using Base::Base;
Result GetCollections(Collections& out) override;
Result GetCollections(Collections& out, s64 off);
// builds nsp meta data and the size of the entier nsp.
static auto Build(std::span<CollectionEntry> collections, s64& size) -> std::vector<u8>;
static auto Build(std::span<const CollectionEntry> collections, s64& size) -> std::vector<u8>;
};
} // namespace sphaira::yati::container

View File

@@ -8,8 +8,63 @@
namespace sphaira::yati::container {
struct Xci final : Base {
struct Hfs0Header {
u32 magic;
u32 total_files;
u32 string_table_size;
u32 padding;
};
struct Hfs0FileTableEntry {
u64 data_offset;
u64 data_size;
u32 name_offset;
u32 hash_size;
u64 padding;
u8 hash[0x20];
};
struct Hfs0 {
Hfs0Header header{};
std::vector<Hfs0FileTableEntry> file_table{};
std::vector<std::string> string_table{};
s64 data_offset{};
auto GetHfs0Size() const {
return sizeof(header) + file_table.size() * sizeof(Hfs0FileTableEntry) + header.string_table_size;
}
auto GetHfs0Data() const -> std::vector<u8>;
};
struct Partition {
// name of the partition.
std::string name;
// offset of this hfs0.
s64 hfs0_offset;
s64 hfs0_size;
Hfs0 hfs0;
// all the collections for this partition, may be empty.
Collections collections;
};
struct Root {
// offset of this hfs0.
s64 hfs0_offset;
Hfs0 hfs0;
std::vector<Partition> partitions;
};
using Partitions = std::vector<Partition>;
using Base::Base;
Result GetCollections(Collections& out) override;
Result GetRoot(Root& out);
private:
Result Hfs0GetPartition(source::Base* source, s64 off, Hfs0& out);
Result ReadPartitionFromHfs0(source::Base* source, const Hfs0& root, u32 index, Partition& out);
};
} // namespace sphaira::yati::container

View File

@@ -54,4 +54,15 @@ static inline void cryptoAes128Xts(const void* in, void* out, const u8* key, u64
Aes128Xts(key, is_encryptor).Run(out, in, sector, sector_size, data_size);
}
static inline void UpdateCtr(u8* counter, u64 offset) {
const u64 swp = __bswap64(offset >> 4);
std::memcpy(&counter[0x8], &swp, 0x8);
}
static inline void SetCtr(u8* counter, u64 ctr, u64 offset = 0) {
const u64 swp = __bswap64(ctr);
std::memcpy(&counter[0x0], &swp, 0x8);
UpdateCtr(counter, offset);
}
} // namespace sphaira::crypto

View File

@@ -201,6 +201,29 @@ Result EncryptTitleKey(keys::KeyEntry& out, u8 key_gen, const keys::Keys& keys);
Result ShouldPatchTicket(const TicketData& data, std::span<const u8> ticket, std::span<const u8> cert_chain, bool patch_personalised, bool& should_patch);
Result ShouldPatchTicket(std::span<const u8> ticket, std::span<const u8> cert_chain, bool patch_personalised, bool& should_patch);
Result PatchTicket(std::vector<u8>& ticket, std::span<const u8> cert_chain, u8 key_gen, const keys::Keys& keys, bool patch_personalised);
// cert chain may be modified if the ticket is converted to common ticket.
Result PatchTicket(std::vector<u8>& ticket, std::vector<u8>& cert_chain, u8 key_gen, const keys::Keys& keys, bool patch_personalised);
// fills out with the list of common / personalised rights ids.
Result GetCommonTickets(std::vector<FsRightsId>& out);
Result GetPersonalisedTickets(std::vector<FsRightsId>& out);
// checks if the rights id is found in common / personalised.
Result IsRightsIdCommon(const FsRightsId& id, bool* out);
Result IsRightsIdPersonalised(const FsRightsId& id, bool* out);
// helper for the above if the db has already been parsed.
bool IsRightsIdValid(const FsRightsId& id);
bool IsRightsIdFound(const FsRightsId& id, std::span<const FsRightsId> ids);
// wrapper around ipc.
Result GetCommonTicketAndCertificate(const FsRightsId& rights_id, std::vector<u8>& tik_out, std::vector<u8>& cert_out);
// fetches data from system es save.
Result GetPersonalisedTicketData(u64 *size_out, void *tik_data, u64 tik_size, const FsRightsId* rightsId);
Result GetPersonalisedTicketAndCertificate(const FsRightsId& rights_id, std::vector<u8>& tik_out, std::vector<u8>& cert_out);
// fills out with the decrypted title key.
Result GetTitleKeyDecrypted(const FsRightsId& rights_id, u8 key_gen, const keys::Keys& keys, keys::KeyEntry& out);
Result GetTitleKeyDecrypted(std::span<const u8> ticket, const FsRightsId& rights_id, u8 key_gen, const keys::Keys& keys, keys::KeyEntry& out);
} // namespace sphaira::es

View File

@@ -3,8 +3,11 @@
#include "fs.hpp"
#include "keys.hpp"
#include "ncm.hpp"
#include "yati/source/base.hpp"
#include <switch.h>
#include <vector>
#include <memory>
namespace sphaira::nca {
@@ -15,7 +18,7 @@ namespace sphaira::nca {
#define NCA_SECTOR_SIZE 0x200
#define NCA_XTS_SECTION_SIZE 0xC00
#define NCA_SECTION_TOTAL 0x4
#define NCA_MEDIA_REAL(x)((x * 0x200))
#define NCA_MEDIA_REAL(x)((u64(x) * 0x200))
#define NCA_PROGRAM_LOGO_OFFSET 0x8000
#define NCA_META_CNMT_OFFSET 0xC20
@@ -94,6 +97,22 @@ struct SectionTableEntry {
u32 media_end_offset; // divided by 0x200.
u8 _0x8[0x4]; // unknown.
u8 _0xC[0x4]; // unknown.
auto IsValid() const -> bool {
return media_start_offset && media_end_offset;
}
auto GetOffset() const -> u64 {
return NCA_MEDIA_REAL(media_start_offset);
}
auto GetOffsetEnd() const -> u64 {
return NCA_MEDIA_REAL(media_end_offset);
}
auto GetSize() const -> u64 {
return GetOffsetEnd() - GetOffset();
}
};
struct LayerRegion {
@@ -139,6 +158,55 @@ static_assert(sizeof(HierarchicalSha256Data) == 0xF8);
static_assert(sizeof(IntegrityMetaInfo) == 0xF8);
static_assert(sizeof(HierarchicalSha256Data) == sizeof(IntegrityMetaInfo));
struct BucketTreeHeader {
u32 magic; // BKTR
u32 version;
u32 count;
u8 _0xC[0x4];
};
struct PatchInfo {
u64 indirect_offset;
u64 indirect_size;
BucketTreeHeader indirect_header;
u64 aes_ctr_offset;
u64 aes_ctr_size;
BucketTreeHeader aes_ctr_header;
};
static_assert(sizeof(PatchInfo) == 0x40);
struct CompressionInfo {
u64 table_offset;
u64 table_size;
BucketTreeHeader table_header;
u8 _0x20[0x8];
};
static_assert(sizeof(CompressionInfo) == 0x28);
struct BktrEntry {
u8 _0x0[0x4];
u32 count;
u64 size;
u64 offsets[0x3FF0 / sizeof(u64)];
};
static_assert(sizeof(BktrEntry) == 0x4000);
struct NX_PACKED BktrRelocationEntry {
u64 patched_addr;
u64 source_addr;
u32 flag;
};
static_assert(sizeof(BktrRelocationEntry) == 0x14);
struct BktrRelocationBucket {
u8 _0x0[0x4];
u32 count;
u64 end_offset;
BktrRelocationEntry entries[0x3FF0 / sizeof(BktrRelocationEntry)];
u8 _[0x3FF0 % sizeof(BktrRelocationEntry)];
};
static_assert(sizeof(BktrRelocationBucket) == 0x4000);
struct FsHeader {
u16 version; // always 2.
u8 fs_type; // see FileSystemType.
@@ -152,12 +220,16 @@ struct FsHeader {
IntegrityMetaInfo integrity_meta_info; // used for romfs
} hash_data;
u8 patch_info[0x40];
PatchInfo patch_info;
u64 section_ctr;
u8 spares_info[0x30];
u8 compression_info[0x28];
CompressionInfo compression_info;
u8 meta_data_hash_data_info[0x30];
u8 reserved[0x30];
auto IsValid() const -> bool {
return version == 2;
}
};
static_assert(sizeof(FsHeader) == 0x200);
static_assert(sizeof(FsHeader::hash_data) == 0xF8);
@@ -181,7 +253,15 @@ struct Header {
u64 size;
u64 program_id;
u32 context_id;
u32 sdk_version;
union {
u32 sdk_version;
struct {
u8 sdk_revision;
u8 sdk_micro;
u8 sdk_minor;
u8 sdk_major;
};
};
u8 key_gen; // see KeyGeneration.
u8 sig_key_gen;
u8 _0x222[0xE]; // empty.
@@ -195,6 +275,10 @@ struct Header {
FsHeader fs_header[NCA_SECTION_TOTAL];
auto IsValid() const -> bool {
return magic == NCA3_MAGIC;
}
auto GetKeyGeneration() const -> u8 {
if (old_key_gen < key_gen) {
return key_gen;
@@ -212,9 +296,25 @@ struct Header {
key_gen = key_generation;
}
}
auto GetSectionCount() const -> u8 {
u8 count = 0;
for (u32 i = 0; i < NCA_SECTION_TOTAL; i++) {
if (!fs_header[i].IsValid() || !fs_table[i].IsValid()) {
break;
}
count++;
}
return count;
}
};
static_assert(sizeof(Header) == 0xC00);
auto GetContentTypeStr(u8 content_type) -> const char*;
auto GetDistributionTypeStr(u8 distribution_type) -> const char*;
Result DecryptHeader(const void* in, const keys::Keys& keys, Header& out);
Result DecryptKeak(const keys::Keys& keys, Header& header);
Result EncryptKeak(const keys::Keys& keys, Header& header, u8 key_generation);
Result VerifyFixedKey(const Header& header);
@@ -225,4 +325,52 @@ Result ParseControl(const fs::FsPath& path, u64 program_id, void* nacp_out = nul
auto GetKeyGenStr(u8 key_gen) -> const char*;
// finds and decrypts the title key, also decrypts header key area if needed.
Result GetDecryptedTitleKey(Header& header, const keys::Keys& keys, keys::KeyEntry& out);
// same as above but also checks the path for ticket.
Result GetDecryptedTitleKey(fs::Fs* fs, const fs::FsPath& path, Header& header, const keys::Keys& keys, keys::KeyEntry& out);
// helpers.
struct DecyptedData : yati::source::Base {
DecyptedData(u64 align, const std::shared_ptr<yati::source::Base>& source);
Result Read(void *_buf, s64 _off, s64 _size, u64* _bytes_read) override;
virtual Result SetCtr(u64 ctr) = 0;
private:
virtual Result Decrypt(void* buf, s64 off, s64 size) = 0;
private:
std::shared_ptr<yati::source::Base> m_source;
const u64 m_align;
};
// todo: add support for xts sections.
struct DecyptedDataCtr final : DecyptedData {
DecyptedDataCtr(const void* key, u64 ctr, const std::shared_ptr<yati::source::Base>& source);
Result SetCtr(u64 ctr) override;
private:
Result Decrypt(void* buf, s64 off, s64 size) override;
private:
Aes128CtrContext m_ctx{};
u8 m_ctr[AES_BLOCK_SIZE]{};
};
struct NcaReader final : yati::source::Base {
NcaReader(const nca::Header& decrypted_header, const void* key, u64 size, const std::shared_ptr<yati::source::Base>& source);
Result Read(void *_buf, s64 off, s64 size, u64* bytes_read) override;
Result ReadEncrypted(void *_buf, s64 off, s64 size, u64* bytes_read);
private:
Result ReadInternal(void *_buf, s64 off, s64 size, u64* bytes_read, bool decrypt);
private:
const nca::Header m_header;
const u64 m_capacity;
std::shared_ptr<yati::source::Base> m_source;
std::unique_ptr<DecyptedData> m_decryptor{};
u8 m_key[0x10]{};
};
} // namespace sphaira::nca

View File

@@ -1,6 +1,10 @@
#pragma once
#include "fs.hpp"
#include "yati/source/base.hpp"
#include <switch.h>
#include <vector>
namespace sphaira::ncm {
@@ -31,10 +35,19 @@ union ExtendedHeader {
NcmDataPatchMetaExtendedHeader data_patch;
};
struct ContentMeta {
NcmContentMetaHeader header;
ExtendedHeader extened;
};
auto GetMetaTypeStr(u8 meta_type) -> const char*;
auto GetContentTypeStr(u8 content_type) -> const char*;
auto GetStorageIdStr(u8 storage_id) -> const char*;
auto GetMetaTypeShortStr(u8 meta_type) -> const char*;
auto GetReadableMetaTypeStr(u8 meta_type) -> const char*;
auto GetReadableStorageIdStr(u8 storage_id) -> const char*;
auto GetAppId(u8 meta_type, u64 id) -> u64;
auto GetAppId(const NcmContentMetaKey& key) -> u64;
auto GetAppId(const PackagedContentMeta& meta) -> u64;
@@ -44,4 +57,42 @@ auto GetContentIdFromStr(const char* str) -> NcmContentId;
Result Delete(NcmContentStorage* cs, const NcmContentId *content_id);
Result Register(NcmContentStorage* cs, const NcmContentId *content_id, const NcmPlaceHolderId *placeholder_id);
// fills out with the content header, which includes the normal and extended header.
Result GetContentMeta(NcmContentMetaDatabase *db, const NcmContentMetaKey *key, ContentMeta& out);
// fills out will a list of all content infos tied to the key.
Result GetContentInfos(NcmContentMetaDatabase *db, const NcmContentMetaKey *key, std::vector<NcmContentInfo>& out);
// same as above but accepts the ncm header rather than fetching it.
Result GetContentInfos(NcmContentMetaDatabase *db, const NcmContentMetaKey *key, const NcmContentMetaHeader& header, std::vector<NcmContentInfo>& out);
// removes key from ncm, including ncas and setting the db.
Result DeleteKey(NcmContentStorage* cs, NcmContentMetaDatabase *db, const NcmContentMetaKey *key);
// sets the required system version.
Result SetRequiredSystemVersion(NcmContentMetaDatabase *db, const NcmContentMetaKey *key, u32 version);
// returns true if type is application or update.
static constexpr inline bool HasRequiredSystemVersion(u8 meta_type) {
return meta_type == NcmContentMetaType_Application || meta_type == NcmContentMetaType_Patch;
}
static constexpr inline bool HasRequiredSystemVersion(const NcmContentMetaKey *key) {
return HasRequiredSystemVersion(key->type);
}
// fills program id and out path of the control nca.
Result GetFsPathFromContentId(NcmContentStorage* cs, const NcmContentMetaKey& key, const NcmContentId& id, u64* out_program_id, fs::FsPath* out_path);
// helper for reading nca from ncm.
struct NcmSource final : yati::source::Base {
NcmSource(NcmContentStorage* cs, const NcmContentId* id);
Result Read(void* buf, s64 off, s64 size, u64* bytes_read) override;
Result GetSize(s64* size);
private:
NcmContentStorage m_cs;
NcmContentId m_id;
s64 m_size{};
};
} // namespace sphaira::ncm

Some files were not shown because too many files have changed in this diff Show More