...
 
Commits (113)
image: devkitpro/devkita64:latest
stages:
- package
- create image
package:
stage: package
before_script:
- dkp-pacman -Syy
- dkp-pacman -S --noconfirm devkitARM
- export DEVKITPRO=/opt/devkitpro
- export DEVKITARM=/opt/devkitpro/devkitARM
script:
- make -j10
- make install
- rm -rf libnx/
- mv /opt/devkitpro/libnx libnx/
artifacts:
name: libnx
paths:
- libnx/
docker image:
stage: create image
script:
- "curl -X POST -F token=$TOKEN_DOCKER_IMAGE -F ref=master https://git.m4xw.net/api/v4/projects/103/trigger/pipeline"
when: on_success
only:
- master
nightly image:
stage: create image
script:
- "curl -X POST -F token=$TOKEN_DOCKER_IMAGE -F ref=develop https://git.m4xw.net/api/v4/projects/103/trigger/pipeline"
when: on_success
only:
- develop
- cicd/updates
This diff is collapsed.
......@@ -9,7 +9,7 @@ endif
include $(DEVKITPRO)/devkitA64/base_rules
export LIBNX_MAJOR := 2
export LIBNX_MINOR := 2
export LIBNX_MINOR := 5
export LIBNX_PATCH := 0
......@@ -33,7 +33,7 @@ INCLUDES := include external/bsd/include
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
CFLAGS := -g -Wall -Werror \
CFLAGS := -g -Wall \
-ffunction-sections \
-fdata-sections \
$(ARCH) \
......@@ -122,7 +122,7 @@ debug:
lib/libnx.a : lib release $(SOURCES) $(INCLUDES)
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2" \
BUILD_CFLAGS="-DNDEBUG=1 -O3 -ffast-math" \
DEPSDIR=$(CURDIR)/release \
--no-print-directory -C release \
-f $(CURDIR)/Makefile
......
......@@ -85,12 +85,14 @@ extern "C" {
#include "switch/services/ncm.h"
#include "switch/services/psc.h"
#include "switch/services/caps.h"
#include "switch/services/capsu.h"
#include "switch/services/capssc.h"
#include "switch/services/capssu.h"
#include "switch/services/nfc.h"
#include "switch/services/wlaninf.h"
#include "switch/services/pctl.h"
#include "switch/services/pdm.h"
#include "switch/services/grc.h"
#include "switch/display/binder.h"
#include "switch/display/parcel.h"
......@@ -110,6 +112,7 @@ extern "C" {
#include "switch/audio/driver.h"
#include "switch/applets/libapplet.h"
#include "switch/applets/album_la.h"
#include "switch/applets/pctlauth.h"
#include "switch/applets/error.h"
#include "switch/applets/swkbd.h"
......
/**
* @file album_la.h
* @brief Wrapper for using the Album LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Arg type values pushed for the applet input storage, stored as an u8.
typedef enum {
AlbumLaArg_ShowAlbumFiles = 0, ///< ShowAlbumFiles. Only displays AlbumFiles associated with the title which launched the Album applet, with the filter button disabled.
AlbumLaArg_ShowAllAlbumFiles = 1, ///< ShowAllAlbumFiles. Displays all AlbumFiles, with filtering allowed.
AlbumLaArg_ShowAllAlbumFilesForHomeMenu = 2, ///< ShowAllAlbumFilesForHomeMenu. Similar to ::AlbumLaArg_ShowAllAlbumFiles.
} AlbumLaArg;
/**
* @brief Launches the applet with ::AlbumLaArg_ShowAlbumFiles and playStartupSound=false.
*/
Result albumLaShowAlbumFiles(void);
/**
* @brief Launches the applet with ::AlbumLaArg_ShowAllAlbumFiles and playStartupSound=false.
*/
Result albumLaShowAllAlbumFiles(void);
/**
* @brief Launches the applet with ::AlbumLaArg_ShowAllAlbumFilesForHomeMenu and playStartupSound=true.
*/
Result albumLaShowAllAlbumFilesForHomeMenu(void);
......@@ -10,14 +10,14 @@
/// CommonArguments
typedef struct {
u32 CommonArgs_version;
u32 CommonArgs_size;
u32 CommonArgs_version; ///< \ref libappletArgsCreate sets this to 1, and \ref libappletArgsPop requires value 1. v0 is not supported.
u32 CommonArgs_size; ///< Size of this struct.
u32 LaVersion; ///< LibraryApplet API version
u32 LaVersion; ///< LibraryApplet API version.
s32 ExpectedThemeColor; ///< Set to the output from \ref appletGetThemeColorType by \ref libappletArgsCreate.
u8 PlayStartupSound; ///< bool flag, default is false.
u8 pad[7];
u64 tick;
u8 pad[7]; ///< Padding.
u64 tick; ///< System tick. Set to the output from \ref armGetSystemTick during \ref libappletArgsPush.
} LibAppletArgs;
/**
......@@ -58,6 +58,12 @@ Result libappletReadStorage(AppletStorage* s, void* buffer, size_t size, size_t
*/
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h);
/**
* @brief Uses \ref appletPopInData and reads it to the specified LibAppletArgs. The LibAppletArgs is validated, an error is thrown when invalid.
* @param[out] a LibAppletArgs struct.
*/
Result libappletArgsPop(LibAppletArgs* a);
/**
* @brief Creates a storage using the input buffer which is pushed to the AppletHolder via \ref appletHolderPushInData.
* @param h AppletHolder object.
......@@ -76,7 +82,13 @@ Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size);
Result libappletPopOutData(AppletHolder *h, void* buffer, size_t size, size_t *transfer_size);
/**
* @brief Starts the applet and waits for it to finish, then checks the \ref LibAppletExitReason.
* @brief Sets whether \ref libappletStart uses \ref appletHolderJump.
* @param flag Flag. Value true should not be used unless running as AppletType_LibraryApplet.
*/
void libappletSetJumpFlag(bool flag);
/**
* @brief If the flag from \ref libappletSetJumpFlag is set, this just uses \ref appletHolderJump. Otherwise, starts the applet and waits for it to finish, then checks the \ref LibAppletExitReason.
* @note Uses \ref appletHolderStart and \ref appletHolderJoin.
* @param h AppletHolder object.
*/
......
......@@ -39,7 +39,7 @@ enum {
typedef enum {
SwkbdTextDrawType_Line = 0, ///< The text will be displayed on a line. Also enables displaying the Header and Sub text.
SwkbdTextDrawType_Box = 1, ///< The text will be displayed in a box.
SwkbdTextDrawType_DownloadCode = 2, ///< Used by \ref swkbdConfigMakePresetDownloadCode on 5.0.0+. Enables using \ref SwkbdArgV7 unk_x3e0.
SwkbdTextDrawType_DownloadCode = 2, ///< Used by \ref swkbdConfigMakePresetDownloadCode on [5.0.0+]. Enables using \ref SwkbdArgV7 unk_x3e0.
} SwkbdTextDrawType;
/// SwkbdInline Interactive input storage request ID.
......@@ -182,7 +182,7 @@ typedef struct {
typedef struct {
u32 unk_x0;
u8 mode; ///< See \ref SwkbdInlineMode. (u8 bool)
u8 unk_x5; ///< Only set on 5.0.0+.
u8 unk_x5; ///< Only set on [5.0.0+].
u8 pad[2];
} SwkbdInitializeArg;
......@@ -217,7 +217,7 @@ typedef struct {
u16 inputText[0x3f4/2]; ///< Flags bitmask 0x8.
u8 utf8Mode; ///< Flags bitmask 0x20.
u8 unk_x45d;
u8 enableBackspace; ///< Flags bitmask 0x8000. Only available with 5.0.0+.
u8 enableBackspace; ///< Flags bitmask 0x8000. Only available with [5.0.0+].
u8 unk_x45f[3];
u8 keytopAsFloating; ///< Flags bitmask 0x200.
u8 footerScalable; ///< Flags bitmask 0x100.
......@@ -237,7 +237,7 @@ typedef struct {
float balloonScale; ///< Flags bitmask 0x200.
float unk_x48c;
u8 unk_x490[0xc];
u8 seGroup; ///< Flags bitmask: enable=0x2000, disable=0x4000. Only available with 5.0.0+.
u8 seGroup; ///< Flags bitmask: enable=0x2000, disable=0x4000. Only available with [5.0.0+].
u8 triggerFlag; ///< [6.0.0+] Enables using the trigger field when set.
u8 trigger; ///< [6.0.0+] Trigger
u8 pad_x49f;
......@@ -363,7 +363,7 @@ void swkbdConfigMakePresetUserName(SwkbdConfig* c);
/**
* @brief Clears the args in the SwkbdConfig struct and initializes it with the DownloadCode Preset.
* @note Do not use this before \ref swkbdCreate.
* @note Uses the following: swkbdConfigSetType() with \ref SwkbdType_Normal (\ref SwkbdType_QWERTY on 5.0.0+), swkbdConfigSetKeySetDisableBitmask() with SwkbdKeyDisableBitmask_DownloadCode, swkbdConfigSetInitialCursorPos() with value 1, and swkbdConfigSetBlurBackground() with value 1. 5.0.0+: swkbdConfigSetStringLenMax() with value 16, swkbdConfigSetStringLenMaxExt() with value 1, and swkbdConfigSetTextDrawType() with SwkbdTextDrawType_DownloadCode. Uses swkbdConfigSetTextGrouping() for [0-2] with: 0x3, 0x7, and 0xb.
* @note Uses the following: swkbdConfigSetType() with \ref SwkbdType_Normal (\ref SwkbdType_QWERTY on [5.0.0+]), swkbdConfigSetKeySetDisableBitmask() with SwkbdKeyDisableBitmask_DownloadCode, swkbdConfigSetInitialCursorPos() with value 1, and swkbdConfigSetBlurBackground() with value 1. [5.0.0+]: swkbdConfigSetStringLenMax() with value 16, swkbdConfigSetStringLenMaxExt() with value 1, and swkbdConfigSetTextDrawType() with SwkbdTextDrawType_DownloadCode. Uses swkbdConfigSetTextGrouping() for [0-2] with: 0x3, 0x7, and 0xb.
* @param c SwkbdConfig struct.
*/
void swkbdConfigMakePresetDownloadCode(SwkbdConfig* c);
......
......@@ -8,6 +8,7 @@
#include "../types.h"
/// PcmFormat
typedef enum {
PcmFormat_Invalid = 0,
PcmFormat_Int8 = 1,
......@@ -18,6 +19,7 @@ typedef enum {
PcmFormat_Adpcm = 6,
} PcmFormat;
/// AudioDeviceName
typedef struct {
char name[0x100];
} AudioDeviceName;
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/sm.h"
#define BINDER_FIRST_CALL_TRANSACTION 0x1
typedef struct {
bool created : 1;
bool initialized : 1;
bool has_transact_auto : 1;
s32 id;
size_t ipc_buffer_size;
bool created : 1;
bool initialized : 1;
bool has_transact_auto : 1;
s32 id;
size_t ipc_buffer_size;
Service* relay;
} Binder;
// Note: binderClose will not close the session_handle provided to binderCreate.
void binderCreate(Binder* b, s32 id);
void binderClose(Binder* b);
Result binderInitSession(Binder* b);
Result binderInitSession(Binder* b, Service* relay);
Result binderTransactParcel(
Binder* b, u32 code,
......
......@@ -58,10 +58,11 @@ NWindow* nwindowGetDefault(void);
/**
* @brief Creates a \ref NWindow.
* @param[out] nw Output \ref NWindow structure.
* @param[in] binder_session Service object for the Android IGraphicBufferProducer binder session.
* @param[in] binder_id Android IGraphicBufferProducer binder session ID.
* @param[in] producer_controlled_by_app Specifies whether the producer is controlled by the application.
*/
Result nwindowCreate(NWindow* nw, s32 binder_id, bool producer_controlled_by_app);
Result nwindowCreate(NWindow* nw, Service* binder_session, s32 binder_id, bool producer_controlled_by_app);
/**
* @brief Creates a \ref NWindow operating on a \ref ViLayer.
......
......@@ -10,7 +10,7 @@
/// JIT implementation type.
typedef enum {
JitType_CodeMemory, ///< JIT supported using svcSetProcessMemoryPermission
JitType_JitMemory, ///< JIT supported using 4.0.0+ code-memory syscalls (this isn't usable on 5.0.0+ so JitType_CodeMemory is used instead).
JitType_JitMemory, ///< JIT supported using [4.0.0+] code-memory syscalls (this isn't usable on [5.0.0+] so JitType_CodeMemory is used instead).
} JitType;
/// JIT buffer object.
......
......@@ -157,18 +157,18 @@ typedef enum {
InfoType_DebuggerAttached = 8, ///< Whether current process is being debugged.
InfoType_ResourceLimit = 9, ///< Current process's resource limit handle.
InfoType_IdleTickCount = 10, ///< Number of idle ticks on CPU.
InfoType_RandomEntropy = 11, ///< 2.0.0+ Random entropy for current process.
InfoType_AslrRegionAddress = 12, ///< 2.0.0+ Base of the process's address space.
InfoType_AslrRegionSize = 13, ///< 2.0.0+ Size of the process's address space.
InfoType_StackRegionAddress = 14, ///< 2.0.0+ Base of the Stack memory region.
InfoType_StackRegionSize = 15, ///< 2.0.0+ Size of the Stack memory region.
InfoType_SystemResourceSizeTotal = 16, ///< 3.0.0+ Total memory allocated for process memory management.
InfoType_SystemResourceSizeUsed = 17, ///< 3.0.0+ Amount of memory currently used by process memory management.
InfoType_TitleId = 18, ///< 3.0.0+ Title ID for the process.
InfoType_InitialProcessIdRange = 19, ///< 4.0.0-4.1.0 Min/max initial process IDs.
InfoType_UserExceptionContextAddress = 20, ///< 5.0.0+ Address of the process's exception context (for break).
InfoType_TotalNonSystemMemorySize = 21, ///< 6.0.0+ Total amount of memory available for process, excluding that for process memory management.
InfoType_UsedNonSystemMemorySize = 22, ///< 6.0.0+ Amount of memory used by process, excluding that for process memory management.
InfoType_RandomEntropy = 11, ///< [2.0.0+] Random entropy for current process.
InfoType_AslrRegionAddress = 12, ///< [2.0.0+] Base of the process's address space.
InfoType_AslrRegionSize = 13, ///< [2.0.0+] Size of the process's address space.
InfoType_StackRegionAddress = 14, ///< [2.0.0+] Base of the Stack memory region.
InfoType_StackRegionSize = 15, ///< [2.0.0+] Size of the Stack memory region.
InfoType_SystemResourceSizeTotal = 16, ///< [3.0.0+] Total memory allocated for process memory management.
InfoType_SystemResourceSizeUsed = 17, ///< [3.0.0+] Amount of memory currently used by process memory management.
InfoType_TitleId = 18, ///< [3.0.0+] Title ID for the process.
InfoType_InitialProcessIdRange = 19, ///< [4.0.0-4.1.0] Min/max initial process IDs.
InfoType_UserExceptionContextAddress = 20, ///< [5.0.0+] Address of the process's exception context (for break).
InfoType_TotalNonSystemMemorySize = 21, ///< [6.0.0+] Total amount of memory available for process, excluding that for process memory management.
InfoType_UsedNonSystemMemorySize = 22, ///< [6.0.0+] Amount of memory used by process, excluding that for process memory management.
InfoType_ThreadTickCount = 0xF0000002, ///< Number of ticks spent on thread.
} InfoType;
......@@ -593,7 +593,7 @@ void NORETURN svcReturnFromException(Result res);
* @remark The full list of property IDs can be found on the <a href="https://switchbrew.org/wiki/SVC#svcGetInfo">switchbrew.org wiki</a>.
* @note Syscall number 0x29.
*/
Result svcGetInfo(u64* out, u64 id0, Handle handle, u64 id1);
Result svcGetInfo(u64* out, u32 id0, Handle handle, u64 id1);
///@}
......@@ -928,7 +928,7 @@ Result svcGetDebugEvent(u8* event_out, Handle debug);
* @return Result code.
* @note Syscall number 0x64.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning Only exists on 3.0.0+. For older versions use \ref svcLegacyContinueDebugEvent.
* @warning Only exists on [3.0.0+]. For older versions use \ref svcLegacyContinueDebugEvent.
*/
Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tids);
......@@ -937,7 +937,7 @@ Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tid
* @return Result code.
* @note Syscall number 0x64.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning Only exists on 1.0.0-2.3.0. For newer versions use \ref svcContinueDebugEvent.
* @warning Only exists on [1.0.0-2.3.0]. For newer versions use \ref svcContinueDebugEvent.
*/
Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID);
......
......@@ -12,38 +12,57 @@ typedef struct {
char author[0x100];
} NacpLanguageEntry;
/// ns ApplicationControlProperty
typedef struct {
NacpLanguageEntry lang[16];
u8 x3000_unk[0x24];////Normally all-zero?
u32 x3024_unk;
u32 x3028_unk;
u32 x302C_unk;
u32 x3030_unk;
u32 x3034_unk;
u64 titleID0;
u8 x3040_unk[0x20];
u8 isbn[0x25];
u8 startupUserAccount;
u8 userAccountSwitchLock;
u8 addOnContentRegistrationType;
u32 applicationAttribute;
u32 supportedLanguages;
u32 parentalControl;
u8 screenshot;
u8 videoCaptureMode;
u8 dataLossConfirmation;
u8 playLogPolicy;
u64 presenceGroupId;
s8 ratingAge[0x20];
char version[0x10];
u64 titleID_DlcBase;
u64 titleID1;
u32 x3080_unk;
u32 x3084_unk;
u32 x3088_unk;
u8 x308C_unk[0x24];//zeros?
u64 titleID2;
u64 titleIDs[7];//"Array of application titleIDs, normally the same as the above app-titleIDs. Only set for game-updates?"
u32 x30F0_unk;
u32 x30F4_unk;
u64 titleID3;//"Application titleID. Only set for game-updates?"
char bcatPassphrase[0x40];
u8 x3140_unk[0xEC0];//Normally all-zero?
u64 addOnContentBaseId;
u64 saveDataOwnerId;
u64 userAccountSaveDataSize;
u64 userAccountSaveDataJournalSize;
u64 deviceSaveDataSize;
u64 deviceSaveDataJournalSize;
u64 bcatDeliveryCacheStorageSize;
u64 applicationErrorCodeCategory;
u64 localCommunicationIds[0x08];
u8 logoType;
u8 logoHandling;
u8 runtimeAddOnContentInstall;
u8 reserved_x30F3[0x03];
u8 crashReport;
u8 hdcp;
u64 pseudoDeviceIdSeed;
char bcatPassphrase[0x41];
u8 reserved_x3141;
u8 reserved_x3142[0x06];
u64 userAccountSaveDataMaxSize;
u64 userAccountSaveDataMaxJournalSize;
u64 deviceSaveDataMaxSize;
u64 deviceSaveDataMaxJournalSize;
u64 temporaryStorageSize;
u64 cacheStorageSize;
u64 cacheStorageJournalSize;
u64 cacheStorageAndJournalMaxSize;
u64 cacheStorageMaxIndex;
u64 playLogQueryableApplicationId[0x10];
u8 playLogQueryCapability;
u8 repairFlag;
u8 programIndex;
u8 requiredNetworkServiceLicenseOnLaunch;
u8 reserved_x3214[0xDEC];
} NacpStruct;
/// Get the NacpLanguageEntry from the input nacp corresponding to the current system language (this may fallback to other languages when needed). Output langentry is NULL if none found / content of entry is empty.
......
......@@ -34,6 +34,8 @@ enum {
EntryType_ProcessHandle=10, ///< Provides the process handle.
EntryType_LastLoadResult=11, ///< Provides the last load result.
EntryType_RandomSeed=14, ///< Provides random data used to seed the pseudo-random number generator.
EntryType_UserIdStorage=15, ///< Provides persistent storage for the preselected user id.
EntryType_HosVersion=16, ///< Provides the currently running Horizon OS version.
};
enum {
......@@ -51,6 +53,11 @@ typedef void NORETURN (*LoaderReturnFn)(int result_code);
*/
void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr);
/// Returns information text about the loader, if present.
const char* envGetLoaderInfo(void);
/// Returns the size of the loader information text.
u64 envGetLoaderInfoSize(void);
/// Retrieves the handle to the main thread.
Handle envGetMainThreadHandle(void);
/// Returns true if the application is running as NSO, otherwise NRO.
......@@ -105,3 +112,6 @@ bool envHasRandomSeed(void);
* @param out Pointer to a u64[2] buffer which will contain the random seed on return.
*/
void envGetRandomSeed(u64 out[2]);
/// Returns a pointer to the user id storage area (if present).
u128* envGetUserIdStorage(void);
......@@ -10,6 +10,7 @@
#define ACC_USER_LIST_SIZE 8
/// Profile
typedef struct {
Service s;
} AccountProfile;
......@@ -46,9 +47,8 @@ Result accountGetUserCount(s32* user_count);
*/
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total);
/// Get the userID for the currently active user. The output userID is only valid when the output account_selected==1, otherwise no user is currently selected.
/// An user is only selected when the user-account selection applet was used to select an user at least once before.
Result accountGetActiveUser(u128 *userID, bool *account_selected);
/// Get the userID for the last opened user. The output userID is only valid when the output account_selected==1.
Result accountGetLastOpenedUser(u128 *userID, bool *account_selected);
/// Get an AccountProfile for the specified userID.
Result accountGetProfile(AccountProfile* out, u128 userID);
......@@ -64,6 +64,7 @@ Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, s
void accountProfileClose(AccountProfile* profile);
/// Gets the userID which was selected by the profile-selector applet (if any), prior to launching the currently running Application title. This can only be used once under the current process, under an Application title.
/// Gets the userID which was selected by the profile-selector applet (if any), prior to launching the currently running Application title.
/// This gets the cached PreselectedUser loaded during accountInitialize, when PreselectedUser is available.
Result accountGetPreselectedUser(u128 *userID);
This diff is collapsed.
......@@ -16,7 +16,7 @@
/// Configuration structure for bsdInitalize
typedef struct {
u32 version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0.
u32 version; ///< Observed 1 on [2.0.0+] LibAppletWeb, 2 on [3.0.0+].
u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed).
u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed).
......
......@@ -7,19 +7,158 @@
#pragma once
#include "../types.h"
#include "../services/sm.h"
#include "../services/acc.h"
/// ImageOrientation
typedef enum {
AlbumImageOrientation_Unknown0 = 0, ///< Unknown. Default.
AlbumImageOrientation_Unknown1 = 1, ///< Unknown.
AlbumImageOrientation_Unknown2 = 2, ///< Unknown.
AlbumImageOrientation_Unknown3 = 3, ///< Unknown.
} AlbumImageOrientation;
/// AlbumReportOption
typedef enum {
AlbumReportOption_Disable = 0, ///< Don't display the screenshot-taken Overlay-applet notification.
AlbumReportOption_Enable = 1, ///< Display the screenshot-taken Overlay notification.
} AlbumReportOption;
/// ContentType
typedef enum {
CapsContentType_Screenshot = 0, ///< Album screenshots.
CapsContentType_Movie = 1, ///< Album videos.
CapsContentType_ExtraMovie = 3, ///< Videos recorded by the current Application host title via \ref grcCreateMovieMaker.
} CapsContentType;
/// ScreenShotAttribute
typedef struct {
u32 unk_x0;
u8 unk_x4[0x3c];
u32 unk_x0; ///< Always set to 0 by official sw.
u32 orientation; ///< \ref AlbumImageOrientation
u32 unk_x8; ///< Always set to 0 by official sw.
u32 unk_xc; ///< Always set to 1 by official sw.
u8 unk_x10[0x30]; ///< Always set to 0 by official sw.
} CapsScreenShotAttribute;
/// ScreenShotAttributeForApplication. Only unk_x0 is used by official sw.
typedef struct {
u32 unk_x0; ///< Unknown.
u8 unk_x4; ///< Unknown.
u8 unk_x5; ///< Unknown.
u8 unk_x6; ///< Unknown.
u8 pad; ///< Padding.
u32 unk_x8; ///< Unknown.
u32 unk_xc; ///< Unknown.
u32 unk_x10; ///< Unknown.
u32 unk_x14; ///< Unknown.
u32 unk_x18; ///< Unknown.
u32 unk_x1c; ///< Unknown.
u16 unk_x20; ///< Unknown.
u16 unk_x22; ///< Unknown.
u16 unk_x24; ///< Unknown.
u16 unk_x26; ///< Unknown.
u8 reserved[0x18]; ///< Always zero.
} CapsScreenShotAttributeForApplication;
/// ScreenShotDecodeOption
typedef struct {
u8 unk_x0[0x20]; ///< Unknown. Set to all-zero by official sw.
} CapsScreenShotDecodeOption;
/// AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYYYMMDDHHMMSSII".
typedef struct {
u16 year; ///< Year.
u8 month; ///< Month.
u8 day; ///< Day of the month.
u8 hour; ///< Hour.
u8 minute; ///< Minute.
u8 second; ///< Second.
u8 id; ///< Unique ID for when there's multiple Album files with the same timestamp.
} CapsAlbumFileDateTime;
/// AlbumEntryId
typedef struct {
u64 titleID; ///< titleID.
CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
u8 unk_x10; ///< Unknown.
u8 unk_x11; ///< Unknown.
u8 pad[6]; ///< Padding?
} CapsAlbumEntryId;
/// AlbumEntry
typedef struct {
u8 unk_x0[0x20];
u8 unk_x0[0x8]; ///< Unknown.
CapsAlbumEntryId id; ///< \ref CapsAlbumEntryId
} CapsAlbumEntry;
/// ApplicationAlbumEntry
typedef struct {
u8 unk_x0[0x20];
union {
u8 data[0x20]; ///< Data.
struct {
u8 unk_x0[0x20]; ///< Unknown.
} v0; ///< Pre-7.0.0
struct {
u8 unk_x0[0x8]; ///< Unknown.
u8 unk_x8[0x8]; ///< Unknown.
CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
u8 unk_x18[0x8]; ///< Unknown.
} v1; ///< [7.0.0+]
};
} CapsApplicationAlbumEntry;
/// ApplicationAlbumFileEntry
typedef struct {
CapsApplicationAlbumEntry entry; ///< \ref CapsApplicationAlbumEntry
CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
u64 unk_x28; ///< Unknown.
} CapsApplicationAlbumFileEntry;
/// ApplicationData
typedef struct {
u8 userdata[0x400]; ///< UserData.
u32 size; ///< UserData size.
} CapsApplicationData;
/// UserIdList
typedef struct {
union { u128 userIDs[ACC_USER_LIST_SIZE]; } PACKED; ///< userIDs.
u8 count; ///< Total userIDs.
u8 pad[7]; ///< Padding.
} CapsUserIdList;
/// LoadAlbumScreenShotImageOutputForApplication
typedef struct {
s64 width; ///< Width. Official sw copies this to a s32 output field.
s64 height; ///< Height. Official sw copies this to a s32 output field.
CapsScreenShotAttributeForApplication attr; ///< \ref CapsScreenShotAttributeForApplication
CapsApplicationData appdata; ///< \ref CapsApplicationData
u8 reserved[0xac]; ///< Unused.
} CapsLoadAlbumScreenShotImageOutputForApplication;
/// Gets the ShimLibraryVersion.
u64 capsGetShimLibraryVersion(void);
/// Gets the default start_datetime.
static inline CapsAlbumFileDateTime capsGetDefaultStartDateTime(void) {
return (CapsAlbumFileDateTime){.year = 1970, .month = 1, .day = 1};
}
/// Gets the default end_datetime.
static inline CapsAlbumFileDateTime capsGetDefaultEndDateTime(void) {
return (CapsAlbumFileDateTime){.year = 3000, .month = 1, .day = 1};
}
/// Convert a \ref CapsApplicationAlbumFileEntry to \ref CapsApplicationAlbumEntry.
static inline void capsConvertApplicationAlbumFileEntryToApplicationAlbumEntry(CapsApplicationAlbumEntry *out, CapsApplicationAlbumFileEntry *in) {
*out = in->entry;
}
/// Convert a \ref CapsApplicationAlbumEntry to \ref CapsApplicationAlbumFileEntry. Should only be used on [7.0.0+].
static inline void capsConvertApplicationAlbumEntryToApplicationAlbumFileEntry(CapsApplicationAlbumFileEntry *out, CapsApplicationAlbumEntry *in) {
out->entry = *in;
out->datetime = in->v1.datetime;
out->unk_x28 = 0;
}
......@@ -9,14 +9,18 @@
#include "../services/sm.h"
#include "../services/caps.h"
/// Initialize caps:sc. Only available on 2.0.0+.
/// Initialize caps:sc. Only available on [2.0.0+].
Result capsscInitialize(void);
/// Exit caps:sc.
void capsscExit(void);
/// Gets the Service for caps:sc.
Service* capsscGetServiceSession(void);
/**
* @brief This takes a screenshot, with the screenshot being written into the output buffer.
* @note Not available with 5.0.0+ (stubbed).
* @note Not available with [5.0.0+] (stubbed).
* @note buffer_index and buffer_count correspond to buffers with size 0x384000(1280*720*4). These must not be negative.
* @param buf Output buffer containing the RGBA8 image.
* @param size Size of buf, should be 0x384000(1280*720*4) * buffer_count.
......@@ -27,5 +31,5 @@ Service* capsscGetServiceSession(void);
* @param buffer_index Starting image buffer index. Must be < buffer_count.
* @param timeout Timeout in nanoseconds. A default value of 100000000 can be used.
*/
Result capsscCaptureScreenshot(void* buf, size_t size, u32 inval, u64 width, u64 height, s64 buffer_count, s64 buffer_index, u64 timeout);
Result capsscCaptureRawImageWithTimeout(void* buf, size_t size, u32 inval, u64 width, u64 height, s64 buffer_count, s64 buffer_index, u64 timeout);
......@@ -9,14 +9,85 @@
#include "../services/sm.h"
#include "../services/caps.h"
/// Initialize caps:su. Only available on 4.0.0+.
/// Initialize caps:su. Only available on [4.0.0+].
Result capssuInitialize(void);
/// Exit caps:su.
void capssuExit(void);
/// Gets the Service for caps:su.
Service* capssuGetServiceSession(void);
/// Same as \ref capssuSaveScreenShotEx0, except this uses an all-zero CapsScreenShotAttribute where the first u32 is set to attr_val. attr_val can be zero.
Result capssuSaveScreenShot(const void* buffer, size_t size, u32 unk, u32 attr_val, CapsApplicationAlbumEntry *out);
/**
* @brief This is a wrapper for \ref capssuSaveScreenShotEx0.
* @note This uses an all-zero \ref CapsScreenShotAttribute with orientation = input orientation, and unk_xc = 1.
* @param[in] buffer RGBA8 1280x720 image buffer.
* @param[in] size Size of the buffer.
* @param[in] reportoption \ref AlbumReportOption
* @param[in] orientation \ref AlbumImageOrientation
* @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL.
*/
Result capssuSaveScreenShot(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, CapsApplicationAlbumEntry *out);
/**
* @brief Similar to \ref capssuSaveScreenShot, except this is a wrapper for \ref capssuSaveScreenShotEx1.
* @note This uses an all-zero \ref CapsScreenShotAttribute with orientation = input orientation, and unk_xc = 1.
* @note Only available on [8.0.0+].
* @param[in] buffer RGBA8 1280x720 image data buffer.
* @param[in] size Size of the buffer.
* @param[in] reportoption \ref AlbumReportOption
* @param[in] orientation \ref AlbumImageOrientation
* @param[in] userdata Input UserData buffer. If NULL, the \ref CapsApplicationData will be empty.
* @param[in] userdata_size Input UserData size, must be within bounds for CapsApplicationData::userdata. If 0, the \ref CapsApplicationData will be empty.
* @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL.
*/
Result capssuSaveScreenShotWithUserData(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, const void* userdata, size_t userdata_size, CapsApplicationAlbumEntry *out);
/**
* @brief Similar to \ref capssuSaveScreenShot, except this is a wrapper for \ref capssuSaveScreenShotEx2.
* @note This uses an all-zero \ref CapsScreenShotAttribute with orientation = input orientation, and unk_xc = 1.
* @note Only available on [6.0.0+].
* @param[in] buffer RGBA8 1280x720 image data buffer.
* @param[in] size Size of the buffer.
* @param[in] reportoption \ref AlbumReportOption
* @param[in] orientation \ref AlbumImageOrientation
* @param[in] userIDs Input array of account userIDs. If NULL, the \ref CapsUserIdList will be empty.
* @param[in] userID_count Size of the userID array in entries, must be within bounds for CapsUserIdList::userIDs. If 0, the \ref CapsUserIdList will be empty.
* @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL.
*/
Result capssuSaveScreenShotWithUserIds(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, const u128* userIDs, size_t userID_count, CapsApplicationAlbumEntry *out);
/**
* @brief Saves an Album screenshot using the specified gfx data in the buffer, with the specified \ref CapsScreenShotAttribute.
* @param[in] buffer RGBA8 1280x720 image data buffer.
* @param[in] size Size of the buffer, must be at least 0x384000.
* @param[in] attr \ref CapsScreenShotAttribute
* @param[in] reportoption \ref AlbumReportOption
* @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL.
*/
Result capssuSaveScreenShotEx0(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsApplicationAlbumEntry *out);
/// Saves an Album screenshot using the specified gfx data in buffer (1280x720 RGBA8), size must be at least 0x384000. unk can be zero.
Result capssuSaveScreenShotEx0(const void* buffer, size_t size, CapsScreenShotAttribute *attr, u32 unk, CapsApplicationAlbumEntry *out);
/**
* @brief Same as \ref capssuSaveScreenShotEx0, except this allows specifying the \ref CapsApplicationData.
* @note Only available on [8.0.0+].
* @param[in] buffer RGBA8 1280x720 image data buffer.
* @param[in] size Size of the buffer, must be at least 0x384000.
* @param[in] attr \ref CapsScreenShotAttribute
* @param[in] reportoption \ref AlbumReportOption
* @param[in] appdata \ref CapsApplicationData
* @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL.
*/
Result capssuSaveScreenShotEx1(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsApplicationData *appdata, CapsApplicationAlbumEntry *out);
/**
* @brief Same as \ref capssuSaveScreenShotEx0, except this allows specifying the \ref CapsUserIdList.
* @note Only available on [6.0.0+].
* @param[in] buffer RGBA8 1280x720 image data buffer.
* @param[in] size Size of the buffer, must be at least 0x384000.
* @param[in] attr \ref CapsScreenShotAttribute
* @param[in] reportoption \ref AlbumReportOption
* @param[in] list \ref CapsUserIdList
* @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL.
*/
Result capssuSaveScreenShotEx2(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsUserIdList *list, CapsApplicationAlbumEntry *out);
/**
* @file capsu.h
* @brief Application Album (caps:u) service IPC wrapper.
* This is only usable with AlbumFiles associated with the current Application host title.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
#include "../services/caps.h"
/// Initialize caps:u. Only available on [5.0.0+].
Result capsuInitialize(void);
/// Exit caps:u.
void capsuExit(void);
/// Gets the Service for caps:u.
Service* capsuGetServiceSession(void);
/// Gets the Service for IAlbumAccessorApplicationSession, only initialized after \ref capsuOpenAlbumMovieStream (unaffected by using \ref capsuCloseAlbumMovieStream).
Service* capsuGetServiceSession_Accessor(void);
/**
* @brief Gets a listing of \ref CapsApplicationAlbumFileEntry.
* @note On [6.0.0+] this uses GetAlbumFileList1AafeAruidDeprecated, otherwise this uses GetAlbumFileList0AafeAruidDeprecated.
* @note This is an old version of \ref capsuGetAlbumFileList3.
* @param[out] entries Output array of \ref CapsApplicationAlbumFileEntry.
* @param[in] count Max size of the output array in entries.
* @param[in] type \ref CapsContentType
* @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[out] total_entries Total output entries.
*/
Result capsuGetAlbumFileListDeprecated1(CapsApplicationAlbumFileEntry *entries, size_t count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, u64 *total_entries);
/**
* @brief Gets a listing of \ref CapsApplicationAlbumFileEntry, where the AlbumFile has an UserId which matches the input one. See also \ref capssuSaveScreenShotWithUserIds.
* @note Only available on [6.0.0+].
* @note This is an old version of \ref capsuGetAlbumFileList4.
* @param[out] entries Output array of \ref CapsApplicationAlbumFileEntry.
* @param[in] count Max size of the output array in entries.
* @param[in] type \ref CapsContentType
* @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[in] userID userID.
* @param[out] total_entries Total output entries.
*/
Result capsuGetAlbumFileListDeprecated2(CapsApplicationAlbumFileEntry *entries, size_t count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, u128 userID, u64 *total_entries);
/**
* @brief Gets a listing of \ref CapsApplicationAlbumEntry.
* @note Only available on [7.0.0+], on prior sysvers use \ref capsuGetAlbumFileListDeprecated1 instead.
* @param[out] entries Output array of \ref CapsApplicationAlbumEntry.
* @param[in] count Max size of the output array in entries.
* @param[in] type \ref CapsContentType
* @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[out] total_entries Total output entries.
*/
Result capsuGetAlbumFileList3(CapsApplicationAlbumEntry *entries, size_t count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, u64 *total_entries);
/**
* @brief Gets a listing of \ref CapsApplicationAlbumEntry, where the AlbumFile has an UserId which matches the input one. See also \ref capssuSaveScreenShotWithUserIds.
* @note Only available on [7.0.0+], on prior sysvers use \ref capsuGetAlbumFileListDeprecated2 instead.
* @param[out] entries Output array of \ref CapsApplicationAlbumEntry.
* @param[in] count Max size of the output array in entries.
* @param[in] type \ref CapsContentType
* @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used.
* @param[in] userID userID.
* @param[out] total_entries Total output entries.
*/
Result capsuGetAlbumFileList4(CapsApplicationAlbumEntry *entries, size_t count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, u128 userID, u64 *total_entries);
/**
* @brief Deletes the specified AlbumFile.
* @param[in] type \ref CapsContentType, must match ::CapsContentType_ExtraMovie.
* @param[in] entry \ref CapsApplicationAlbumFileEntry
*/
Result capsuDeleteAlbumFile(CapsContentType type, const CapsApplicationAlbumFileEntry *entry);
/**
* @brief Gets the filesize for the entire specified AlbumFile.
* @param[in] entry \ref CapsApplicationAlbumFileEntry
* @param[out] size Output filesize.
*/
Result capsuGetAlbumFileSize(const CapsApplicationAlbumFileEntry *entry, u64 *size);
/**
* @brief Load the ScreenShotImage for the specified AlbumFile.
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[out] attr \ref CapsScreenShotAttributeForApplication
* @param[out] userdata Output buffer containing the UserData. Optional, can be NULL. This buffer is cleared to 0 using userdata_maxsize, prior to doing the memcpy.
* @param[in] userdata_maxsize Max size of the userdata buffer. Optional, can be 0.
* @param[out] userdata_size Userdata size field, clamped to max size sizeof(CapsApplicationData::userdata) when needed.
* @param[out] image RGBA8 image output buffer.
* @param[out] image_size Image buffer size, should be at least large enough for RGBA8 1280x720.
* @param[out] workbuf Work buffer, cleared to 0 by the cmd before it returns.
* @param[out] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
* @param[in] entry \ref CapsApplicationAlbumFileEntry
* @param[in] option \ref CapsScreenShotDecodeOption
*/
Result capsuLoadAlbumScreenShotImage(s32 *width, s32 *height, CapsScreenShotAttributeForApplication *attr, void* userdata, size_t userdata_maxsize, u32 *userdata_size, void* image, size_t image_size, void* workbuf, size_t workbuf_size, const CapsApplicationAlbumFileEntry *entry, const CapsScreenShotDecodeOption *option);
/**
* @brief Load the ScreenShotThumbnailImage for the specified AlbumFile.
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[out] attr \ref CapsScreenShotAttributeForApplication
* @param[out] userdata Output buffer containing the UserData. Optional, can be NULL. This buffer is cleared to 0 using userdata_maxsize, prior to doing the memcpy.
* @param[in] userdata_maxsize Max size of the userdata buffer. Optional, can be 0.
* @param[out] userdata_size Userdata size field, clamped to max size sizeof(CapsApplicationData::userdata) when needed.
* @param[out] image RGBA8 image output buffer.
* @param[out] image_size Image buffer size, should be at least large enough for RGBA8 320x180.
* @param[out] workbuf Work buffer, cleared to 0 by the cmd before it returns.
* @param[out] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
* @param[in] entry \ref CapsApplicationAlbumFileEntry
* @param[in] option \ref CapsScreenShotDecodeOption
*/
Result capsuLoadAlbumScreenShotThumbnailImage(s32 *width, s32 *height, CapsScreenShotAttributeForApplication *attr, void* userdata, size_t userdata_maxsize, u32 *userdata_size, void* image, size_t image_size, void* workbuf, size_t workbuf_size, const CapsApplicationAlbumFileEntry *entry, const CapsScreenShotDecodeOption *option);
/**
* @brief PrecheckToCreateContents. Official sw only uses this with ::CapsContentType_ExtraMovie.
* @param[in] type \ref CapsContentType
* @param[in] unk Unknown.
*/
Result capsuPrecheckToCreateContents(CapsContentType type, u64 unk);
/**
* @brief Opens an AlbumMovieStream.
* @note This opens IAlbumAccessorApplicationSession if not previously opened, it's closed during \ref capsuExit.
* @note Up to 4 streams can be open at the same time. Multiple streams can be open at the same time for the same \ref CapsApplicationAlbumFileEntry.
* @param[out] stream Stream handle.
* @param[in] entry \ref CapsApplicationAlbumFileEntry
*/
Result capsuOpenAlbumMovieStream(u64 *stream, const CapsApplicationAlbumFileEntry *entry);
/**
* @brief Closes an AlbumMovieStream.
* @param[in] stream Stream handle.
*/
Result capsuCloseAlbumMovieStream(u64 stream);
/**
* @brief Gets the data size of an AlbumMovieStream.
* @param[in] stream Stream handle.
* @param[out] size Size of the actual MP4, without the JPEG at the end.
*/
Result capsuGetAlbumMovieStreamSize(u64 stream, u64 *size);
/**
* @brief Reads data from an AlbumMovieStream.
* @note offset(+size) must not be negative. offset and size must be aligned to 0x40000-bytes.
* @note When offset(+size) goes beyond the size from \ref capsuGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size.
* @param[in] stream Stream handle.
* @param[in] offset Offset.
* @param[out] Output data buffer.
* @param[in] size Data buffer size.
* @param[out] actual_size Actual read size.
*/
Result capsuReadAlbumMovieStream(u64 stream, s64 offset, void* buffer, size_t size, u64 *actual_size);
/**
* @brief Gets the BrokenReason for an AlbumMovieStream.
* @note Official sw doesn't use this.
* @param[in] stream Stream handle.
*/
Result capsuGetAlbumMovieStreamBrokenReason(u64 stream);
......@@ -11,7 +11,7 @@
typedef enum {
FatalType_ErrorReportAndErrorScreen = 0,
FatalType_ErrorReport = 1,
FatalType_ErrorScreen = 2 ///< Only available with 3.0.0+. If specified, FatalType_ErrorReportAndErrorScreen will be used instead on pre-3.0.0.
FatalType_ErrorScreen = 2 ///< Only available with [3.0.0+]. If specified, FatalType_ErrorReportAndErrorScreen will be used instead on pre-3.0.0.
} FatalType;
/// Struct for fatal Cpu context, 64-bit.
......
......@@ -77,13 +77,26 @@ typedef struct
u64 unk_x38; ///< 0 for SystemSaveData/SaveData.
} FsSave;
/// SaveDataExtraData Struct
typedef struct {
FsSave save; ///< Save struct.
u64 ownerId; ///< Title id of the owner of this save data. 0 for SystemSaveData.
u64 timestamp; ///< POSIX timestamp.
u32 flags; ///< Save data flags. See \ref FsSaveDataFlags.
u32 unk_x54; ///< Normally 0. Possibly unused?
s64 dataSize; ///< Usable save data size.
s64 journalSize; ///< Journal size of the save data.
u64 commitId; ///< Id of the latest commit.
u8 unused[0x190]; ///< Uninitialized.
} FsSaveDataExtraData;
/// SaveCreate Struct
typedef struct {
u64 size; ///< Size of the save data.
u64 journalSize; ///< Journal size of the save data.
s64 size; ///< Size of the save data.
s64 journalSize; ///< Journal size of the save data.
u64 blockSize; ///< Block size of the save data.
u64 ownerId; ///< Title id of the owner of this save data. 0 for SystemSaveData.
u32 flags; ///< Save data flags.
u32 flags; ///< Save data flags. See \ref FsSaveDataFlags.
u8 saveDataSpaceId; ///< See \ref FsSaveDataSpaceId.
u8 unk; ///< 0 for SystemSaveData.
u8 padding[0x1A]; ///< Uninitialized for SystemSaveData.
......@@ -166,6 +179,12 @@ typedef enum
FS_CONTENTSTORAGEID_SdCard = 2,
} FsContentStorageId;
typedef enum
{
FsCustomStorageId_NandUser = 0,
FsCustomStorageId_SdCard = 1,
} FsCustomStorageId;
typedef enum
{
FsSaveDataSpaceId_NandSystem = 0,
......@@ -186,12 +205,25 @@ typedef enum
FsSaveDataType_CacheStorage = 5, ///< [3.0.0+]
} FsSaveDataType;
/// SaveDataFlags
typedef enum {
FsSaveDataFlags_SurviveFactoryReset = BIT(0),
FsSaveDataFlags_SurviveFactoryResetForRefurbishment = BIT(1),
FsSaveDataFlags_SurviveFactoryResetWithoutUserSaveData = BIT(2),
} FsSaveDataFlags;
typedef enum {
FsGameCardAttribute_AutoBoot = (1 << 0), ///< Causes the cartridge to automatically start on bootup
FsGameCardAttribute_ForceError = (1 << 1), ///< Causes NS to throw an error on attempt to load the cartridge
FsGameCardAttribute_Repair = (1 << 2), ///< Indicates that this gamecard is a repair tool.
} FsGameCardAttribute;
typedef enum {
FsGameCardPartiton_Update = 0,
FsGameCardPartiton_Normal = 1,
FsGameCardPartiton_Secure = 2,
} FsGameCardPartiton;
typedef struct {
u32 value;
} FsGameCardHandle;
......@@ -242,6 +274,11 @@ Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSave* save, const Fs
Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID);
Result fsIsExFatSupported(bool* out);
Result fsOpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handle, FsGameCardPartiton partition);
Result fsReadSaveDataFileSystemExtraDataBySaveDataSpaceId(void* buf, size_t len, FsSaveDataSpaceId saveDataSpaceId, u64 saveID);
Result fsReadSaveDataFileSystemExtraData(void* buf, size_t len, u64 saveID);
Result fsWriteSaveDataFileSystemExtraData(const void* buf, size_t len, FsSaveDataSpaceId saveDataSpaceId, u64 saveID);
Result fsExtendSaveDataFileSystem(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, s64 dataSize, s64 journalSize); /// [3.0.0+]
/// Do not call this directly, see fs_dev.h.
Result fsMountSdcard(FsFileSystem* out);
......@@ -250,6 +287,7 @@ Result fsMountSaveData(FsFileSystem* out, u8 inval, FsSave *save);
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, FsSave *save);
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 saveDataSpaceId);
Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id);
Result fsOpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); /// [7.0.0+]
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, FsStorageId storageId);
Result fsOpenDeviceOperator(FsDeviceOperator* out);
......@@ -262,6 +300,9 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id);
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id);
Result fsDisableAutoSaveDataCreation(void);
Result fsSetGlobalAccessLogMode(u32 mode);
Result fsGetGlobalAccessLogMode(u32* out_mode);
// todo: Rest of commands here
// Wrapper(s) for fsCreateSaveDataFileSystemBySystemSaveDataId.
......@@ -295,8 +336,8 @@ typedef enum
/// Mount requested filesystem type from content file
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); /// same as calling fsOpenFileSystemWithId with 0 as titleId
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// works on all firmwares, titleId is ignored on 1.0.0
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// 2.0.0+, like OpenFileSystemWithId but without content path.
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// works on all firmwares, titleId is ignored on [1.0.0]
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// [2.0.0+], like OpenFileSystemWithId but without content path.
// IFileSystem
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
......@@ -312,9 +353,9 @@ Result fsFsOpenDirectory(FsFileSystem* fs, const char* path, int flags, FsDir* o
Result fsFsCommit(FsFileSystem* fs);
Result fsFsGetFreeSpace(FsFileSystem* fs, const char* path, u64* out);
Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, u64* out);
Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out);/// 3.0.0+
Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path);/// 3.0.0+
Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryType query_type);/// 4.0.0+
Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); /// [3.0.0+]
Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); /// [3.0.0+]
Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryType query_type); /// [4.0.0+]
void fsFsClose(FsFileSystem* fs);
/// Uses \ref fsFsQueryEntry to set the archive bit on the specified absolute directory path.
......@@ -327,7 +368,7 @@ Result fsFileWrite(FsFile* f, u64 off, const void* buf, size_t len, u32 option);
Result fsFileFlush(FsFile* f);
Result fsFileSetSize(FsFile* f, u64 sz);
Result fsFileGetSize(FsFile* f, u64* out);
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// 4.0.0+
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// [4.0.0+]
void fsFileClose(FsFile* f);
// IDirectory
......@@ -341,7 +382,7 @@ Result fsStorageWrite(FsStorage* s, u64 off, const void* buf, size_t len);
Result fsStorageFlush(FsStorage* s);
Result fsStorageSetSize(FsStorage* s, u64 sz);
Result fsStorageGetSize(FsStorage* s, u64* out);
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// 4.0.0+
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// [4.0.0+]
void fsStorageClose(FsStorage* s);
// ISaveDataInfoReader
......
/**
* @file grc.h
* @brief GRC Game Recording (grc:*) service IPC wrapper.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
#include "../services/caps.h"
#include "../kernel/event.h"
#include "../kernel/tmem.h"
#include "../display/native_window.h"
/// Stream type values for \ref grcdRead.
typedef enum {
GrcStream_Video = 0, ///< Video stream with H.264 NAL units. Official sw uses buffer size 0x32000.
GrcStream_Audio = 1, ///< Audio stream with PcmFormat_Int16, 2 channels, and samplerate = 48000Hz. Official sw uses buffer size 0x1000.
} GrcStream;
/// GameMovieTrimmer
typedef struct {
Service s; ///< IGameMovieTrimmer
TransferMemory tmem; ///< TransferMemory
} GrcGameMovieTrimmer;
/// IMovieMaker
typedef struct {
Service a; ///< applet IMovieMaker
Service s; ///< grc IMovieMaker
Service video_proxy; ///< IHOSBinderDriver VideoProxy
Event recording_event; ///< Output Event from GetOffscreenLayerRecordingFinishReadyEvent with autoclear=false.
Event audio_event; ///< Output Event from GetOffscreenLayerAudioEncodeReadyEvent with autoclear=false.
TransferMemory tmem; ///< TransferMemory
NWindow win; ///< \ref NWindow
u64 layer_handle; ///< LayerHandle
bool layer_open; ///< Whether OpenOffscreenLayer was used successfully, indicating that CloseOffscreenLayer should be used during \ref grcMovieMakerClose.
bool started_flag; ///< Whether \ref grcMovieMakerStart was used successfully. This is also used by \ref grcMovieMakerAbort.
} GrcMovieMaker;
/// GameMovieId
typedef struct {
CapsAlbumEntryId album_id; ///< \ref CapsAlbumEntryId
u8 reserved[0x28]; ///< Unused, always zero.
} GrcGameMovieId;
/// OffscreenRecordingParameter
typedef struct {
u8 unk_x0[0x10]; ///< Unknown. Default value is 0.
u32 unk_x10; ///< Unknown. Must match value 0x103, which is the default value.
s32 video_bitrate; ///< VideoBitRate, 0 is invalid. Default value is 8000000.
s32 video_width; ///< VideoWidth, must match 1280 or 1920. Default value is 1280.
s32 video_height; ///< VideoHeight, must match 720 or 1080. Default value is 720.
s32 video_framerate; ///< VideoFrameRate, must match 30 or 60. Default value is 30.
s32 video_keyFrameInterval; ///< VideoKeyFrameInterval, 0 is invalid. Default value is 30.
s32 audio_bitrate; ///< AudioBitRate. Default value is 128000 ([5.0.0-5.1.0] 1536000).
s32 audio_samplerate; ///< AudioSampleRate, 0 is invalid. Default value is 48000.
s32 audio_channel_count; ///< AudioChannelCount. Must match 2, which is the default value.
s32 audio_sample_format; ///< \ref PcmFormat AudioSampleFormat. Must match PcmFormat_Int16, which is the default value.
s32 video_imageOrientation; ///< \ref AlbumImageOrientation VideoImageOrientation. Default value is ::AlbumImageOrientation_Unknown0.
u8 unk_x3c[0x44]; ///< Unknown. Default value is 0.
} GrcOffscreenRecordingParameter;
/// Default size for \ref grcCreateMovieMaker, this is the size used by official sw.
#define GRC_MOVIEMAKER_WORKMEMORY_SIZE_DEFAULT 0x6000000
///@name Trimming
///@{
/**
* @brief Creates a \ref GrcGameMovieTrimmer using \ref appletCreateGameMovieTrimmer, uses the cmds from it to trim the specified video, then closes it.
* @note See \ref appletCreateGameMovieTrimmer for the requirements for using this.
* @note This will block until video trimming finishes.
* @param[out] dst_movieid \ref GrcGameMovieId for the output video.
* @param[in] src_movieid \ref GrcGameMovieId for the input video.
* @param[in] tmem_size TransferMemory size. Official sw uses size 0x2000000.
* @param[in] thumbnail Optional, can be NULL. RGBA8 1280x720 thumbnail image data.
* @param[in] start Start timestamp in 0.5s units.
* @param[in] end End timestamp in 0.5s units.
*/
Result grcTrimGameMovie(GrcGameMovieId *dst_movieid, const GrcGameMovieId *src_movieid, size_t tmem_size, const void* thumbnail, s32 start, s32 end);
///@}
///@name IMovieMaker
///@{
/**
* @brief Creates a \ref GrcOffscreenRecordingParameter with the default values, see \ref GrcOffscreenRecordingParameter for the default values.
* @param[out] param \ref GrcOffscreenRecordingParameter
*/
void grcCreateOffscreenRecordingParameter(GrcOffscreenRecordingParameter *param);
/**
* @brief Creates a \ref GrcMovieMaker using \ref appletCreateMovieMaker, and does the required initialization.
* @note See \ref appletCreateMovieMaker for the requirements for using this.
* @param[out] m \ref GrcMovieMaker
* @param[in] size TransferMemory WorkMemory size. See \ref GRC_MOVIEMAKER_WORKMEMORY_SIZE_DEFAULT.
*/
Result grcCreateMovieMaker(GrcMovieMaker *m, size_t size);
/**
* @brief Closes a \ref GrcMovieMaker.
* @note This also uses \ref grcMovieMakerAbort.
* @param m \ref GrcMovieMaker
*/
void grcMovieMakerClose(GrcMovieMaker *m);
/**
* @brief Gets the \ref NWindow for the specified MovieMaker.
* @param m \ref GrcMovieMaker
*/
static inline NWindow* grcMovieMakerGetNWindow(GrcMovieMaker *m) {
return &m->win;
}
/**
* @brief Starts recording with the specified MovieMaker and \ref GrcOffscreenRecordingParameter.
* @param m \ref GrcMovieMaker
* @param[in] param \ref GrcOffscreenRecordingParameter
*/
Result grcMovieMakerStart(GrcMovieMaker *m, const GrcOffscreenRecordingParameter *param);
/**
* @brief Aborts recording with the specified MovieMaker.
* @note This is used automatically by \ref grcMovieMakerClose.
* @note This will throw an error if \ref grcMovieMakerStart was not used previously, with the flag used for this being cleared afterwards on success.
* @param m \ref GrcMovieMaker
*/
Result grcMovieMakerAbort(GrcMovieMaker *m);
/**
* @brief Finishes recording with the specified MovieMaker.
* @note This automatically uses \ref grcMovieMakerAbort on error.
* @note The recorded video will not be accessible via the Album-applet since it's stored separately from other Album data.
* @param m \ref GrcMovieMaker
* @param width Width for the thumbnail, must be 1280.
* @param height Height for the thumbnail, must be 720.
* @param[in] userdata UserData input buffer for the JPEG thumbnail. Optional, can be NULL.
* @param[in] userdata_size Size of the UserData input buffer. Optional, can be 0. Must be <=0x400.
* @param[in] thumbnail RGBA8 image buffer containing the thumbnail. Optional, can be NULL.
* @param[in] thumbnail_size Size of the thumbnail buffer. Optional, can be 0.
* @param[out] entry Output \ref CapsApplicationAlbumEntry for the recorded video. Optional, can be NULL. Only available on [7.0.0+], if this is not NULL on pre-7.0.0 an error is thrown.
*/
Result grcMovieMakerFinish(GrcMovieMaker *m, s32 width, s32 height, const void* userdata, size_t userdata_size, const void* thumbnail, size_t thumbnail_size, CapsApplicationAlbumEntry *entry);
/**
* @brief Gets the recording error with the specified MovieMaker.
* @param m \ref GrcMovieMaker
*/
Result grcMovieMakerGetError(GrcMovieMaker *m);
/**
* @brief Encodes audio sample data with the specified MovieMaker.
* @note This waits on the event and uses the cmd repeatedly until the entire input buffer is handled.
* @note If you don't use this the recorded video will be missing audio.
* @param m \ref GrcMovieMaker
* @param[in] buffer Audio buffer.
* @param[in] size Size of the buffer.
*/
Result grcMovieMakerEncodeAudioSample(GrcMovieMaker *m, const void* buffer, size_t size);
///@}
///@name grc:d
///@{
/// Initialize grc:d.
Result grcdInitialize(void);
/// Exit grc:d.
void grcdExit(void);
/// Gets the Service for grc:d.
Service* grcdGetServiceSession(void);
/// Begins streaming. This must not be called more than once, even from a different service session: otherwise the sysmodule will assert.
Result grcdBegin(void);
/**
* @brief Reads a stream, from the video recording being done of the currently running game title.
* @note This will block until data is available. This will hang if there is no game title running which has video capture enabled.
* @param[in] stream \ref GrcStream
* @param[out] buffer Output buffer.
* @param[in] size Max size of the output buffer.
* @param[out] unk Unknown.
* @param[out] data_size Actual output data size.
* @param[out] timestamp Timestamp?
*/
Result grcdRead(GrcStream stream, void* buffer, size_t size, u32 *unk, u32 *data_size, u64 *timestamp);
///@}
......@@ -222,6 +222,9 @@ typedef enum
TYPE_JOYCON_PAIR = BIT(2),
TYPE_JOYCON_LEFT = BIT(3),
TYPE_JOYCON_RIGHT = BIT(4),
TYPE_SYSTEM_EXT = BIT(29),
TYPE_SYSTEM = BIT(30),
} HidControllerType;
typedef enum
......@@ -240,6 +243,7 @@ typedef enum
COLORS_NONEXISTENT = BIT(1),
} HidControllerColorDescription;
/// HidControllerKeys
typedef enum
{
KEY_A = BIT(0), ///< A
......@@ -327,6 +331,52 @@ typedef enum
HidJoyHoldType_Horizontal = 1, ///< Joy-Con held horizontally with HID state orientation adjustment, see \ref HidControllerLayoutType.
} HidJoyHoldType;
/// DeviceType
typedef enum {
HidDeviceTypeBits_FullKey = BIT(0), ///< Pro Controller and Gc controller.
HidDeviceTypeBits_Unknown1 = BIT(1), ///< Unknown.
HidDeviceTypeBits_HandheldLeft = BIT(2), ///< Joy-Con/Famicom/NES left controller in handheld mode.
HidDeviceTypeBits_HandheldRight = BIT(3), ///< Joy-Con/Famicom/NES right controller in handheld mode.
HidDeviceTypeBits_JoyLeft = BIT(4), ///< Joy-Con left controller.
HidDeviceTypeBits_JoyRight = BIT(5), ///< Joy-Con right controller.
HidDeviceTypeBits_Palma = BIT(6), ///< Poké Ball Plus controller.
HidDeviceTypeBits_LarkLeftHVC = BIT(7), ///< Famicom left controller.
HidDeviceTypeBits_LarkRightHVC = BIT(8), ///< Famicom right controller (with microphone).
HidDeviceTypeBits_LarkLeftNES = BIT(9), ///< NES left controller.
HidDeviceTypeBits_LarkRightNES = BIT(10), ///< NES right controller.
HidDeviceTypeBits_SystemExt = BIT(15), ///< Generic external controller.
HidDeviceTypeBits_System = BIT(31), ///< Generic controller.
} HidDeviceTypeBits;
/// Internal DeviceType for [9.0.0+]. Converted to/from the pre-9.0.0 version of this by the hiddbg funcs.
typedef enum {
HidDeviceType_JoyRight1 = 1, ///< ::HidDeviceTypeBits_JoyRight
HidDeviceType_JoyLeft2 = 2, ///< ::HidDeviceTypeBits_JoyLeft
HidDeviceType_FullKey3 = 3, ///< ::HidDeviceTypeBits_FullKey
HidDeviceType_JoyLeft4 = 4, ///< ::HidDeviceTypeBits_JoyLeft
HidDeviceType_JoyRight5 = 5, ///< ::HidDeviceTypeBits_JoyRight
HidDeviceType_FullKey6 = 6, ///< ::HidDeviceTypeBits_FullKey
HidDeviceType_LarkLeftHVC = 7, ///< ::HidDeviceTypeBits_LarkLeftHVC
HidDeviceType_LarkRightHVC = 8, ///< ::HidDeviceTypeBits_LarkRightHVC
HidDeviceType_LarkLeftNES = 9, ///< ::HidDeviceTypeBits_LarkLeftNES
HidDeviceType_LarkRightNES = 10, ///< ::HidDeviceTypeBits_LarkRightNES
HidDeviceType_Palma = 12, ///< [9.0.0+] ::HidDeviceTypeBits_Palma
HidDeviceType_FullKey13 = 13, ///< ::HidDeviceTypeBits_FullKey
HidDeviceType_FullKey15 = 15, ///< ::HidDeviceTypeBits_FullKey
HidDeviceType_System19 = 19, ///< ::HidDeviceTypeBits_System with HidControllerType |= TYPE_PROCONTROLLER.
HidDeviceType_System20 = 20, ///< ::HidDeviceTypeBits_System with HidControllerType |= TYPE_JOYCON_PAIR.
HidDeviceType_System21 = 21, ///< ::HidDeviceTypeBits_System with HidControllerType |= TYPE_JOYCON_PAIR.
} HidDeviceType;
/// NpadInterfaceType
typedef enum
{
NpadInterfaceType_Bluetooth = 1, ///< Bluetooth.
NpadInterfaceType_Rail = 2, ///< Rail.
NpadInterfaceType_USB = 3, ///< USB.
NpadInterfaceType_Unknown4 = 4, ///< Unknown.
} HidNpadInterfaceType;
typedef struct touchPosition
{
u32 id;
......@@ -666,7 +716,7 @@ HidControllerType hidGetControllerType(HidControllerID id);
void hidGetControllerColors(HidControllerID id, HidControllerColors *colors);
bool hidIsControllerConnected(HidControllerID id);
/// Gets the DeviceType for the specified controller.
/// Gets the \ref HidDeviceTypeBits for the specified controller.
u32 hidGetControllerDeviceType(HidControllerID id);
/// Gets the flags for the specified controller.
......@@ -705,13 +755,16 @@ u32 hidSixAxisSensorValuesRead(SixAxisSensorValues *values, HidControllerID id,
/// Returns 0 when CONTROLLER_PLAYER_1 is connected, otherwise returns 1 for handheld-mode.
bool hidGetHandheldMode(void);
/// Sets which controller types are supported. This is automatically called with all types in \ref hidInitialize.
Result hidSetSupportedNpadStyleSet(HidControllerType type);
/// Gets which controller types are supported.
Result hidGetSupportedNpadStyleSet(HidControllerType *type);
/// This is automatically called with CONTROLLER_PLAYER_{1-8} and CONTROLLER_HANDHELD in \ref hidInitialize.
/// count must be <=10. Each entry in buf must be CONTROLLER_PLAYER_{1-8} or CONTROLLER_HANDHELD.
Result hidSetSupportedNpadIdType(HidControllerID *buf, size_t count);
/// Sets which controller types are supported. This is automatically called with all types in \ref hidInitialize.
Result hidSetSupportedNpadStyleSet(HidControllerType type);
/// Gets an event with the specified autoclear for the input controller.
/// The user *must* close the event when finished with it / before the app exits.
/// This is signaled when the \ref hidGetControllerType output is updated for the controller.
......@@ -786,3 +839,7 @@ Result hidGetSevenSixAxisSensorFusionStrength(float *strength);
/// Resets the timestamp for the SevenSixAxisSensor. Only available on [6.0.0+].
Result hidResetSevenSixAxisSensorTimestamp(void);
/// Gets the \ref HidNpadInterfaceType for the specified controller.
/// Only available on [4.0.0+].
Result hidGetNpadInterfaceType(HidControllerID id, u8 *out);
This diff is collapsed.
......@@ -47,6 +47,13 @@ Result hidsysActivateHomeButton(void);
Result hidsysActivateSleepButton(void);
Result hidsysActivateCaptureButton(void);
/**
* @brief Gets the SupportedNpadStyleSet for the CallerApplet. applet must be initialized in order to use this (uses \ref appletGetAppletResourceUserIdOfCallerApplet).
* @note Only available on [6.0.0+].
* @param[out] out \ref HidControllerType
*/
Result hidsysGetSupportedNpadStyleSetOfCallerApplet(HidControllerType *out);
/**
* @brief Gets the UniquePadIds for the specified controller.
* @note Only available on [3.0.0+].
......