Compare commits

..

No commits in common. "master" and "v2.0.0" have entirely different histories.

343 changed files with 22884 additions and 76104 deletions

34
.doozer.json Normal file
View File

@ -0,0 +1,34 @@
{
"targets": {
"lib": {
"buildenv": "docker:devkitpro/devkita64",
"buildcmd": [
"sudo -E make -j${PARALLEL} -C nx install"
]
},
"docs": {
// Only invoke docs target when building from master branch
"branch": "master",
"buildenv": "xenial-amd64",
"builddeps": [
"doxygen"
],
"buildcmd": [
"cd nx", "doxygen"
],
"artifacts": [{
"source": "nx/docs/html",
"destination": {
"type": "git",
"branch": "gh-pages"
}
}]
}
}
}

View File

@ -1,22 +0,0 @@
name: Build libnx
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Test build
runs-on: ubuntu-latest
container:
image: 'devkitpro/devkita64'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: build
run: make -C nx -j$(nproc)

View File

@ -1,39 +0,0 @@
name: Build documentation
on:
push:
tags: [ v* ]
jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Get current tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- name: Set up Doxygen
run: sudo apt-get install -y doxygen
- name: Display Doxygen version
run: echo "Doxygen version $(doxygen -v)"
- name: Build documentation
run: |
cd nx
LIBNX_VERSION=${{ steps.vars.outputs.tag }} doxygen Doxyfile
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: nx/docs/html
CLEAN: true
SINGLE_COMMIT: true

3
.gitignore vendored
View File

@ -8,10 +8,7 @@
*.pfs0
Thumbs.db
.*/
!.github/
debug/
release/
lib/
docs/
compile_commands.json
.clangd

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
# Nintendo Switch AArch64-only userland library.
Based on libctru.
![Build status](https://github.com/switchbrew/libnx/actions/workflows/build.yaml/badge.svg)
[![Build status](https://doozer.io/badge/switchbrew/libnx/buildstatus/master)](https://doozer.io/switchbrew/libnx)
# Install instructions
See [Switchbrew](https://switchbrew.org/wiki/Setting_up_Development_Environment).

View File

@ -38,7 +38,7 @@ PROJECT_NAME = "libnx"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "$(LIBNX_VERSION)"
PROJECT_NUMBER = "$(TRAVIS_TAG)"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -8,6 +8,13 @@ endif
include $(DEVKITPRO)/devkitA64/base_rules
export LIBNX_MAJOR := 2
export LIBNX_MINOR := 0
export LIBNX_PATCH := 0
VERSION := $(LIBNX_MAJOR).$(LIBNX_MINOR).$(LIBNX_PATCH)
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
@ -17,14 +24,14 @@ include $(DEVKITPRO)/devkitA64/base_rules
#---------------------------------------------------------------------------------
TARGET := nx
#BUILD := build
SOURCES := source/arm source/kernel source/sf source/services source/crypto source/nvidia source/nvidia/ioctl source/display source/audio source/applets source/runtime source/runtime/devices source/runtime/util source/runtime/util/utf
SOURCES := source/arm source/kernel source/services source/nvidia source/nvidia/ioctl source/display source/audio source/applets source/runtime source/runtime/devices source/runtime/util/utf
DATA := data
INCLUDES := include external/bsd/include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
CFLAGS := -g -Wall -Werror \
-ffunction-sections \
@ -32,7 +39,7 @@ CFLAGS := -g -Wall -Werror \
$(ARCH) \
$(BUILD_CFLAGS)
CFLAGS += $(INCLUDE) -D__SWITCH__ -DLIBNX_NO_DEPRECATION
CFLAGS += $(INCLUDE) -DSWITCH
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
@ -88,14 +95,17 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
#---------------------------------------------------------------------------------
all: lib/libnx.a lib/libnxd.a
install: lib/libnx.a lib/libnxd.a
@mkdir -p $(DESTDIR)$(DEVKITPRO)/libnx
@cp -v default_icon.jpg switch_rules switch.ld switch.specs $(DESTDIR)$(DEVKITPRO)/libnx/
@cp -rv include lib $(DESTDIR)$(DEVKITPRO)/libnx/
@cp -rv external/bsd/include $(DESTDIR)$(DEVKITPRO)/libnx/
dist-bin: all
@tar --exclude=*~ -cjf libnx-$(VERSION).tar.bz2 include lib default_icon.jpg switch_rules switch.ld switch.specs -C external/bsd include
dist-src:
@tar -cjf libnx-`git describe --tags | sed 's/^v//'`.tar.bz2 include source data external Makefile default_icon.jpg switch_rules switch.ld switch.specs
@tar --exclude=*~ -cjf libnx-src-$(VERSION).tar.bz2 include source data external Makefile default_icon.jpg switch_rules switch.ld switch.specs
dist: dist-src dist-bin
install: dist-bin
mkdir -p $(DESTDIR)$(DEVKITPRO)/libnx
bzip2 -cd libnx-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/libnx
#dox:
# @doxygen Doxyfile

View File

@ -373,8 +373,7 @@ struct ifreq {
struct sockaddr ifr_dstaddr; /* other end of p-to-p link */
struct sockaddr ifr_broadaddr; /* broadcast address */
struct ifreq_buffer ifr_buffer; /* user supplied buffer with its length */
short ifr_flags; /* flags (low 16 bits) */
short ifr_flagshigh; /* flags (high 16 bits) */
short ifr_flags[2]; /* flags (low 16 bits) */
short ifr_index; /* interface index */
int ifr_jid; /* jail/vnet */
int ifr_metric; /* metric */

View File

@ -437,35 +437,8 @@ struct cmsghdr {
/* followed by u_char cmsg_data[]; */
};
#define _ALIGNBYTES (sizeof(long) - 1)
#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
/* given pointer to struct cmsghdr, return pointer to data */
#define CMSG_DATA(cmsg) \
((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr)))
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
#define CMSG_NXTHDR(mhdr, cmsg) \
(((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
_ALIGN(sizeof(struct cmsghdr)) > \
((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \
(struct cmsghdr *)NULL : \
(struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
/*
* RFC 2292 requires to check msg_controllen, in case that the kernel returns
* an empty list for some reasons.
*/
#define CMSG_FIRSTHDR(mhdr) \
((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
(struct cmsghdr *)(mhdr)->msg_control : \
(struct cmsghdr *)NULL)
/* Length of the contents of a control message of length len */
#define CMSG_LEN(len) (_ALIGN(sizeof(struct cmsghdr)) + (len))
/* Length of the space taken up by a padded control message of length len */
#define CMSG_SPACE(len) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(len))
// socket credential stuff, we don't need this
// cmsg macros, uses some obscure macro
/* "Socket"-level control message types: */
#define SCM_RIGHTS 0x01 /* access rights (array of int) */

View File

@ -0,0 +1,33 @@
#pragma once
#include "../switch/types.h"
#include "../switch/result.h"
#include "../switch/kernel/mutex.h"
#include "../switch/kernel/condvar.h"
#include "../switch/kernel/thread.h"
#define TSS_DTOR_ITERATIONS 1
typedef struct {
Thread thr;
int rc;
} __thrd_t;
typedef CondVar cnd_t;
typedef __thrd_t* thrd_t;
typedef u32 tss_t;
#define _MTX_INITIALIZER_NP {mtx_plain, {0}}
typedef struct mtx_t {
int type;
union {
Mutex mutex;
RMutex rmutex;
};
} mtx_t;
#define ONCE_FLAG_INIT {0,_MTX_INITIALIZER_NP,0}
typedef struct once_flag_t {
int status;
mtx_t mutex;
cnd_t cond;
} once_flag;

View File

@ -17,6 +17,7 @@ extern "C" {
#include "switch/arm/tls.h"
#include "switch/arm/cache.h"
#include "switch/arm/atomics.h"
#include "switch/arm/counter.h"
#include "switch/kernel/svc.h"
@ -25,7 +26,6 @@ extern "C" {
#include "switch/kernel/shmem.h"
#include "switch/kernel/mutex.h"
#include "switch/kernel/event.h"
#include "switch/kernel/levent.h"
#include "switch/kernel/uevent.h"
#include "switch/kernel/utimer.h"
#include "switch/kernel/rwlock.h"
@ -36,14 +36,9 @@ extern "C" {
#include "switch/kernel/detect.h"
#include "switch/kernel/random.h"
#include "switch/kernel/jit.h"
#include "switch/kernel/ipc.h"
#include "switch/kernel/barrier.h"
#include "switch/sf/hipc.h"
#include "switch/sf/cmif.h"
#include "switch/sf/service.h"
#include "switch/sf/sessionmgr.h"
#include "switch/sf/tipc.h"
#include "switch/services/sm.h"
#include "switch/services/smm.h"
#include "switch/services/fs.h"
@ -52,11 +47,8 @@ extern "C" {
#include "switch/services/acc.h"
#include "switch/services/apm.h"
#include "switch/services/applet.h"
#include "switch/services/async.h"
#include "switch/services/audctl.h"
#include "switch/services/audin.h"
#include "switch/services/audout.h"
#include "switch/services/audrec.h"
#include "switch/services/audren.h"
#include "switch/services/auddev.h"
#include "switch/services/hwopus.h"
@ -64,74 +56,33 @@ extern "C" {
#include "switch/services/lbl.h"
#include "switch/services/i2c.h"
#include "switch/services/gpio.h"
#include "switch/services/uart.h"
#include "switch/services/bpc.h"
#include "switch/services/pcv.h"
#include "switch/services/clkrst.h"
#include "switch/services/fan.h"
#include "switch/services/pgl.h"
#include "switch/services/psm.h"
#include "switch/services/spsm.h"
//#include "switch/services/bsd.h" Use <sys/socket.h> instead
//#include "switch/services/sfdnsres.h" Use <netdb.h> instead
//#include "switch/services/htcs.h"
//#include "switch/services/bsd.h" Use switch/runtime/devices/socket.h instead
#include "switch/services/fatal.h"
#include "switch/services/time.h"
#include "switch/services/usb.h"
#include "switch/services/usbds.h"
#include "switch/services/usbhs.h"
#include "switch/services/hid.h"
#include "switch/services/hidbus.h"
#include "switch/services/hiddbg.h"
#include "switch/services/hidsys.h"
#include "switch/services/irs.h"
#include "switch/services/pl.h"
#include "switch/services/vi.h"
#include "switch/services/nv.h"
#include "switch/services/nifm.h"
#include "switch/services/nim.h"
#include "switch/services/ns.h"
#include "switch/services/ldr.h"
#include "switch/services/ro.h"
#include "switch/services/tc.h"
#include "switch/services/ts.h"
#include "switch/services/pm.h"
#include "switch/services/set.h"
#include "switch/services/ssl.h"
#include "switch/services/lr.h"
#include "switch/services/bt.h"
#include "switch/services/btdrv.h"
#include "switch/services/btm.h"
#include "switch/services/btmu.h"
#include "switch/services/btmsys.h"
#include "switch/services/spl.h"
#include "switch/services/ncm.h"
#include "switch/services/psc.h"
#include "switch/services/caps.h"
#include "switch/services/capsa.h"
#include "switch/services/capsc.h"
#include "switch/services/capsdc.h"
#include "switch/services/capsu.h"
#include "switch/services/capssc.h"
#include "switch/services/capssu.h"
#include "switch/services/capmtp.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/services/friends.h"
#include "switch/services/notif.h"
#include "switch/services/mii.h"
#include "switch/services/miiimg.h"
#include "switch/services/ldn.h"
#include "switch/services/lp2p.h"
#include "switch/services/news.h"
#include "switch/services/ins.h"
#include "switch/services/ectx.h"
#include "switch/services/avm.h"
#include "switch/services/mm.h"
#include "switch/display/gfx.h"
#include "switch/display/binder.h"
#include "switch/display/parcel.h"
#include "switch/display/buffer_producer.h"
@ -150,26 +101,10 @@ extern "C" {
#include "switch/audio/driver.h"
#include "switch/applets/libapplet.h"
#include "switch/applets/album_la.h"
#include "switch/applets/friends_la.h"
#include "switch/applets/hid_la.h"
#include "switch/applets/mii_la.h"
#include "switch/applets/nfp_la.h"
#include "switch/applets/nifm_la.h"
#include "switch/applets/pctlauth.h"
#include "switch/applets/psel.h"
#include "switch/applets/error.h"
#include "switch/applets/swkbd.h"
#include "switch/applets/web.h"
#include "switch/runtime/env.h"
#include "switch/runtime/hosversion.h"
#include "switch/runtime/diag.h"
#include "switch/runtime/nxlink.h"
#include "switch/runtime/resolver.h"
#include "switch/runtime/pad.h"
#include "switch/runtime/ringcon.h"
#include "switch/runtime/btdev.h"
#include "switch/runtime/util/utf.h"
@ -179,18 +114,6 @@ extern "C" {
#include "switch/runtime/devices/romfs_dev.h"
#include "switch/runtime/devices/socket.h"
#include "switch/crypto/aes.h"
#include "switch/crypto/aes_cbc.h"
#include "switch/crypto/aes_ctr.h"
#include "switch/crypto/aes_xts.h"
#include "switch/crypto/cmac.h"
#include "switch/crypto/sha256.h"
#include "switch/crypto/sha1.h"
#include "switch/crypto/hmac.h"
#include "switch/crypto/crc.h"
#ifdef __cplusplus
}
#endif

View File

@ -1,31 +0,0 @@
/**
* @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 application 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);

View File

@ -1,314 +0,0 @@
/**
* @file error.h
* @brief Wrapper for using the error LibraryApplet.
* @author StuntHacks, yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/set.h"
/// Error type for ErrorCommonHeader.type.
typedef enum {
ErrorType_Normal = 0, ///< Normal
ErrorType_System = 1, ///< System
ErrorType_Application = 2, ///< Application
ErrorType_Eula = 3, ///< EULA
ErrorType_Pctl = 4, ///< Parental Controls
ErrorType_Record = 5, ///< Record
ErrorType_SystemUpdateEula = 8, ///< SystemUpdateEula
} ErrorType;
/// Stores error-codes which are displayed as XXXX-XXXX, low for the former and desc for the latter.
typedef struct {
u32 low; ///< The module portion of the error, normally this should be set to module + 2000.
u32 desc; ///< The error description.
} ErrorCode;
/// Error type for ErrorContext.type
typedef enum {
ErrorContextType_None = 0, ///< None
ErrorContextType_Http = 1, ///< Http
ErrorContextType_FileSystem = 2, ///< FileSystem
ErrorContextType_WebMediaPlayer = 3, ///< WebMediaPlayer
ErrorContextType_LocalContentShare = 4, ///< LocalContentShare
} ErrorContextType;
/// Error context.
typedef struct {
u8 type; ///< Type, see \ref ErrorContextType.
u8 pad[7]; ///< Padding
u8 data[0x1f4]; ///< Data
Result res; ///< Result
} ErrorContext;
/// Common header for the start of the arg storage.
typedef struct {
u8 type; ///< Type, see \ref ErrorType.
u8 jumpFlag; ///< When clear, this indicates WithoutJump.
u8 unk_x2[3]; ///< Unknown
u8 contextFlag; ///< When set with ::ErrorType_Normal, indicates that an additional storage is pushed for \ref ErrorResultBacktrace. [4.0.0+] Otherwise, when set indicates that an additional storage is pushed for \ref ErrorContext.
u8 resultFlag; ///< ErrorCommonArg: When clear, errorCode is used, otherwise the applet generates the error-code from res.
u8 contextFlag2; ///< Similar to contextFlag except for ErrorCommonArg, indicating \ref ErrorContext is used.
} ErrorCommonHeader;
/// Common error arg data.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
ErrorCode errorCode; ///< \ref ErrorCode
Result res; ///< Result
} ErrorCommonArg;
/// Error arg data for certain errors with module PCTL.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
Result res; ///< Result
} ErrorPctlArg;
/// ResultBacktrace
typedef struct {
s32 count; ///< Total entries in the backtrace array.
Result backtrace[0x20]; ///< Result backtrace.
} ErrorResultBacktrace;
/// Error arg data for EULA.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
SetRegion regionCode; ///< \ref SetRegion
} ErrorEulaArg;
/// Additional input storage data for \ref errorSystemUpdateEulaShow.
typedef struct {
u8 data[0x20000]; ///< data
} ErrorEulaData;
/// Error arg data for Record.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
ErrorCode errorCode; ///< \ref ErrorCode
u64 timestamp; ///< POSIX timestamp.
} ErrorRecordArg;
/// SystemErrorArg
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
ErrorCode errorCode; ///< \ref ErrorCode
u64 languageCode; ///< See set.h.
char dialogMessage[0x800]; ///< UTF-8 Dialog message.
char fullscreenMessage[0x800]; ///< UTF-8 Fullscreen message (displayed when the user clicks on "Details").
} ErrorSystemArg;
/// Error system config.
typedef struct {
ErrorSystemArg arg; ///< Arg data.
ErrorContext ctx; ///< Optional error context.
} ErrorSystemConfig;
/// ApplicationErrorArg
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
u32 errorNumber; ///< Raw decimal error number which is displayed in the dialog.
u64 languageCode; ///< See set.h.
char dialogMessage[0x800]; ///< UTF-8 Dialog message.
char fullscreenMessage[0x800]; ///< UTF-8 Fullscreen message (displayed when the user clicks on "Details").
} NX_PACKED ErrorApplicationArg;
/// Error application config.
typedef struct {
ErrorApplicationArg arg; ///< Arg data.
} ErrorApplicationConfig;
/**
* @brief Creates an \ref ErrorCode.
* @param low The module portion of the error, normally this should be set to module + 2000.
* @param desc The error description.
*/
static inline ErrorCode errorCodeCreate(u32 low, u32 desc) {
return (ErrorCode){low, desc};
}
/**
* @brief Creates an \ref ErrorCode with the input Result. Wrapper for \ref errorCodeCreate.
* @param res Input Result.
*/
static inline ErrorCode errorCodeCreateResult(Result res) {
return errorCodeCreate(2000 + R_MODULE(res), R_DESCRIPTION(res));
}
/**
* @brief Creates an invalid \ref ErrorCode.
*/
static inline ErrorCode errorCodeCreateInvalid(void) {
return (ErrorCode){0};
}
/**
* @brief Checks whether the input ErrorCode is valid.
* @param errorCode \ref ErrorCode
*/
static inline bool errorCodeIsValid(ErrorCode errorCode) {
return errorCode.low!=0;
}
/**
* @brief Launches the applet for displaying the specified Result.
* @param res Result
* @param jumpFlag Jump flag, normally this is true.
* @param ctx Optional \ref ErrorContext, can be NULL. Unused when jumpFlag=false. Ignored on pre-4.0.0, since it's only available for [4.0.0+].
* @note Sets the following fields: jumpFlag and contextFlag2. Uses ::ErrorType_Normal normally.
* @note For module=PCTL errors with desc 100-119 this sets uses ::ErrorType_Pctl, in which case the applet will display the following special dialog: "This software is restricted by Parental Controls".
* @note If the input Result is 0xC8A2, the applet will display a special dialog regarding the current application requiring a software update, with buttons "Later" and "Restart".
* @note [3.0.0+] If the input Result is 0xCAA2, the applet will display a special dialog related to DLC version.
* @warning This applet creates an error report that is logged in the system, when not handling the above special dialogs. Proceed at your own risk!
*/
Result errorResultShow(Result res, bool jumpFlag, const ErrorContext* ctx);
/**
* @brief Launches the applet for displaying the specified ErrorCode.
* @param errorCode \ref ErrorCode
* @param jumpFlag Jump flag, normally this is true.
* @param ctx Optional \ref ErrorContext, can be NULL. Unused when jumpFlag=false. Ignored on pre-4.0.0, since it's only available for [4.0.0+].
* @note Sets the following fields: jumpFlag and contextFlag2. resultFlag=1. Uses ::ErrorType_Normal.
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorCodeShow(ErrorCode errorCode, bool jumpFlag, const ErrorContext* ctx);
/**
* @brief Creates an ErrorResultBacktrace struct.
* @param backtrace \ref ErrorResultBacktrace struct.
* @param count Total number of entries.
* @param entries Input array of Result.
*/
Result errorResultBacktraceCreate(ErrorResultBacktrace* backtrace, s32 count, const Result* entries);
/**
* @brief Launches the applet for \ref ErrorResultBacktrace.
* @param backtrace ErrorResultBacktrace struct.
* @param res Result
* @note Sets the following fields: jumpFlag=1, contextFlag=1, and uses ::ErrorType_Normal.
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorResultBacktraceShow(Result res, const ErrorResultBacktrace* backtrace);
/**
* @brief Launches the applet for displaying the EULA.
* @param RegionCode \ref SetRegion
* @note Sets the following fields: jumpFlag=1, regionCode, and uses ::ErrorType_Eula.
*/
Result errorEulaShow(SetRegion RegionCode);
/**
* @brief Launches the applet for displaying the system-update EULA.
* @param RegionCode \ref SetRegion
* @param eula EULA data. Address must be 0x1000-byte aligned.
* @note Sets the following fields: jumpFlag=1, regionCode, and uses ::ErrorType_SystemUpdateEula.
*/
Result errorSystemUpdateEulaShow(SetRegion RegionCode, const ErrorEulaData* eula);
/**
* @brief Launches the applet for displaying an error full-screen, using the specified ErrorCode and timestamp.
* @param errorCode \ref ErrorCode
* @param timestamp POSIX timestamp.
* @note Sets the following fields: jumpFlag=1, errorCode, timestamp, and uses ::ErrorType_Record.
* @note The applet does not log an error report for this. error*RecordShow is used by qlaunch for displaying previously logged error reports.
*/
Result errorCodeRecordShow(ErrorCode errorCode, u64 timestamp);
/**
* @brief Launches the applet for displaying an error full-screen, using the specified Result and timestamp.
* @param res Result
* @param timestamp POSIX timestamp.
* @note Wrapper for \ref errorCodeRecordShow, see \ref errorCodeRecordShow notes.
*/
static inline Result errorResultRecordShow(Result res, u64 timestamp) {
return errorCodeRecordShow(errorCodeCreateResult(res), timestamp);
}
/**
* @brief Creates an ErrorSystemConfig struct.
* @param c ErrorSystemConfig struct.
* @param dialog_message UTF-8 dialog message.
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details". Optional, can be NULL (which disables displaying Details).
* @note Sets the following fields: {strings}, and uses ::ErrorType_System. The rest are cleared.
* @note On pre-5.0.0 this will initialize languageCode by using: setInitialize(), setMakeLanguageCode(SetLanguage_ENUS, ...), and setExit(). This is needed since an empty languageCode wasn't supported until [5.0.0+] (which would also use SetLanguage_ENUS).
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorSystemCreate(ErrorSystemConfig* c, const char* dialog_message, const char* fullscreen_message);
/**
* @brief Launches the applet with the specified config.
* @param c ErrorSystemConfig struct.
*/
Result errorSystemShow(ErrorSystemConfig* c);
/**
* @brief Sets the error code.
* @param c ErrorSystemConfig struct.
* @param errorCode \ref ErrorCode
*/
static inline void errorSystemSetCode(ErrorSystemConfig* c, ErrorCode errorCode) {
c->arg.errorCode = errorCode;
}
/**
* @brief Sets the error code, using the input Result. Wrapper for \ref errorSystemSetCode.
* @param c ErrorSystemConfig struct.
* @param res The Result to set.
*/
static inline void errorSystemSetResult(ErrorSystemConfig* c, Result res) {
errorSystemSetCode(c, errorCodeCreateResult(res));
}
/**
* @brief Sets the LanguageCode.
* @param c ErrorSystemConfig struct.
* @param LanguageCode LanguageCode, see set.h.
*/
static inline void errorSystemSetLanguageCode(ErrorSystemConfig* c, u64 LanguageCode) {
c->arg.languageCode = LanguageCode;
}
/**
* @brief Sets the ErrorContext.
* @note Only available on [4.0.0+], on older versions this will return without setting the context.
* @param c ErrorSystemConfig struct.
* @param ctx ErrorContext, NULL to clear it.
*/
void errorSystemSetContext(ErrorSystemConfig* c, const ErrorContext* ctx);
/**
* @brief Creates an ErrorApplicationConfig struct.
* @param c ErrorApplicationConfig struct.
* @param dialog_message UTF-8 dialog message.
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details". Optional, can be NULL (which disables displaying Details).
* @note Sets the following fields: jumpFlag=1, {strings}, and uses ::ErrorType_Application. The rest are cleared.
* @note On pre-5.0.0 this will initialize languageCode by using: setInitialize(), setMakeLanguageCode(SetLanguage_ENUS, ...), and setExit(). This is needed since an empty languageCode wasn't supported until [5.0.0+] (which would also use SetLanguage_ENUS).
* @note With [10.0.0+] this must only be used when running under an Application, since otherwise the applet will trigger a fatalerr.
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorApplicationCreate(ErrorApplicationConfig* c, const char* dialog_message, const char* fullscreen_message);
/**
* @brief Launches the applet with the specified config.
* @param c ErrorApplicationConfig struct.
*/
Result errorApplicationShow(ErrorApplicationConfig* c);
/**
* @brief Sets the error code number.
* @param c ErrorApplicationConfig struct.
* @param errorNumber Error code number. Raw decimal error number which is displayed in the dialog.
*/
static inline void errorApplicationSetNumber(ErrorApplicationConfig* c, u32 errorNumber) {
c->arg.errorNumber = errorNumber;
}
/**
* @brief Sets the LanguageCode.
* @param c ErrorApplicationConfig struct.
* @param LanguageCode LanguageCode, see set.h.
*/
static inline void errorApplicationSetLanguageCode(ErrorApplicationConfig* c, u64 LanguageCode) {
c->arg.languageCode = LanguageCode;
}

View File

@ -1,172 +0,0 @@
/**
* @file friends_la.h
* @brief Wrapper for using the MyPage (friends) LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/acc.h"
#include "../services/friends.h"
/// Arg type values used with \ref FriendsLaArg.
typedef enum {
FriendsLaArgType_ShowFriendList = 0, ///< ShowFriendList. Launches the applet with the "Friend List" menu initially selected.
FriendsLaArgType_ShowUserDetailInfo = 1, ///< ShowUserDetailInfo
FriendsLaArgType_StartSendingFriendRequest = 2, ///< StartSendingFriendRequest
FriendsLaArgType_ShowMethodsOfSendingFriendRequest = 3, ///< ShowMethodsOfSendingFriendRequest. Launches the applet with the "Add Friend" menu initially selected.
FriendsLaArgType_StartFacedFriendRequest = 4, ///< StartFacedFriendRequest. Launches the applet where the "Search for Local Users" menu is initially shown. Returning from this menu will exit the applet.
FriendsLaArgType_ShowReceivedFriendRequestList = 5, ///< ShowReceivedFriendRequestList. Launches the applet where the "Received Friend Requests" menu is initially shown. Returning from this menu will exit the applet.
FriendsLaArgType_ShowBlockedUserList = 6, ///< ShowBlockedUserList. Launches the applet where the "Blocked-User List" menu is initially shown. Returning from this menu will exit the applet.
FriendsLaArgType_ShowMyProfile = 7, ///< ShowMyProfile. Launches the applet with the "Profile" menu initially selected. ShowMyProfileForHomeMenu is identical to this except for playStartupSound=true.
FriendsLaArgType_StartFriendInvitation = 8, ///< [9.0.0+] StartFriendInvitation. Launches the applet for sending online-play invites to friends, where the friends are selected via the UI.
FriendsLaArgType_StartSendingFriendInvitation = 9, ///< [9.0.0+] StartSendingFriendInvitation.
FriendsLaArgType_ShowReceivedInvitationDetail = 10, ///< [9.0.0+] ShowReceivedInvitationDetail.
} FriendsLaArgType;
/// Header for the arg struct.
typedef struct {
u32 type; ///< \ref FriendsLaArgType
u32 pad; ///< Padding.
AccountUid uid; ///< \ref AccountUid
} FriendsLaArgHeader;
/// Common data for the arg struct, for the pre-9.0.0 types.
/// This is only set for ::FriendsLaArgType_ShowUserDetailInfo/::FriendsLaArgType_StartSendingFriendRequest, for everything else this is cleared.
typedef struct {
AccountNetworkServiceAccountId id; ///< \ref AccountNetworkServiceAccountId for the other account.
FriendsInAppScreenName first_inAppScreenName; ///< First InAppScreenName.
FriendsInAppScreenName second_inAppScreenName; ///< Second InAppScreenName.
} FriendsLaArgCommonData;
/// Arg struct pushed for the applet input storage, for pre-9.0.0.
typedef struct {
FriendsLaArgHeader hdr; ///< \ref FriendsLaArgHeader
FriendsLaArgCommonData data; ///< \ref FriendsLaArgCommonData
} FriendsLaArgV1;
/// Arg struct pushed for the applet input storage, for [9.0.0+].
typedef struct {
FriendsLaArgHeader hdr; ///< \ref FriendsLaArgHeader
union {
u8 raw[0x1090]; ///< Raw data.
FriendsLaArgCommonData common; ///< \ref FriendsLaArgCommonData
struct {
s32 id_count; ///< \ref AccountNetworkServiceAccountId count, must be 1-15.
u32 pad; ///< Padding.
u64 userdata_size; ///< User-data size, must be <=0x400.
u8 userdata[0x400]; ///< Arbitrary user-data, see above size.
FriendsFriendInvitationGameModeDescription desc; ///< \ref FriendsFriendInvitationGameModeDescription
} start_friend_invitation; ///< Data for ::FriendsLaArgType_StartFriendInvitation.
struct {
s32 id_count; ///< \ref AccountNetworkServiceAccountId count, must be 1-15.
u32 pad; ///< Padding.
AccountNetworkServiceAccountId id_list[16]; ///< \ref AccountNetworkServiceAccountId list, see above count.
u64 userdata_size; ///< User-data size, must be <=0x400.
u8 userdata[0x400]; ///< Arbitrary user-data, see above size.
FriendsFriendInvitationGameModeDescription desc; ///< \ref FriendsFriendInvitationGameModeDescription
} start_sending_friend_invitation; ///< Data for ::FriendsLaArgType_StartSendingFriendInvitation.
struct {
FriendsFriendInvitationId invitation_id; ///< \ref FriendsFriendInvitationId
FriendsFriendInvitationGroupId invitation_group_id; ///< \ref FriendsFriendInvitationGroupId
} show_received_invitation_detail; ///< Data for ::FriendsLaArgType_ShowReceivedInvitationDetail.
} data; ///< Data for each \ref FriendsLaArgType.
} FriendsLaArg;
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowFriendList, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowFriendList(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowUserDetailInfo, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
* @param[in] id \ref AccountNetworkServiceAccountId for the user to show UserDetailInfo for.
* @param[in] first_inAppScreenName First \ref FriendsInAppScreenName.
* @param[in] second_inAppScreenName Second \ref FriendsInAppScreenName.
*/
Result friendsLaShowUserDetailInfo(AccountUid uid, AccountNetworkServiceAccountId id, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartSendingFriendRequest, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
* @param[in] uid \ref AccountUid
* @param[in] id \ref AccountNetworkServiceAccountId to send the friend request to.
* @param[in] first_inAppScreenName First \ref FriendsInAppScreenName.
* @param[in] second_inAppScreenName Second \ref FriendsInAppScreenName.
*/
Result friendsLaStartSendingFriendRequest(AccountUid uid, AccountNetworkServiceAccountId id, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowMethodsOfSendingFriendRequest, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowMethodsOfSendingFriendRequest(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartFacedFriendRequest, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaStartFacedFriendRequest(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowReceivedFriendRequestList, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowReceivedFriendRequestList(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowBlockedUserList, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowBlockedUserList(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowMyProfile, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowMyProfile(AccountUid uid);
/**
* @brief Same as \ref friendsLaShowMyProfile except with playStartupSound=true.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowMyProfileForHomeMenu(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartFriendInvitation, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
* @note Only available on [9.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] id_count \ref AccountNetworkServiceAccountId count, must be 1-15. Number of friends to invite.
* @param[in] desc \ref FriendsFriendInvitationGameModeDescription
* @param[in] userdata Arbitrary user-data. Can be NULL.
* @param[in] userdata_size User-data size, must be <=0x400. Can be 0 if userdata is NULL.
*/
Result friendsLaStartFriendInvitation(AccountUid uid, s32 id_count, const FriendsFriendInvitationGameModeDescription *desc, const void* userdata, u64 userdata_size);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartSendingFriendInvitation, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
* @note Only available on [9.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] id_list \ref AccountNetworkServiceAccountId list.
* @param[in] id_count Size of the id_list array in entries, must be 1-15. Number of friends to invite.
* @param[in] desc \ref FriendsFriendInvitationGameModeDescription
* @param[in] userdata Arbitrary user-data. Can be NULL.
* @param[in] userdata_size User-data size, must be <=0x400. Can be 0 if userdata is NULL.
*/
Result friendsLaStartSendingFriendInvitation(AccountUid uid, const AccountNetworkServiceAccountId *id_list, s32 id_count, const FriendsFriendInvitationGameModeDescription *desc, const void* userdata, u64 userdata_size);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowReceivedInvitationDetail, the specified input, and playStartupSound=false.
* @note Only available on [9.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] invitation_id \ref FriendsFriendInvitationId
* @param[in] invitation_group_id \ref FriendsFriendInvitationGroupId
*/
Result friendsLaShowReceivedInvitationDetail(AccountUid uid, FriendsFriendInvitationId invitation_id, FriendsFriendInvitationGroupId invitation_group_id);

View File

@ -1,175 +0,0 @@
/**
* @file hid_la.h
* @brief Wrapper for using the controller LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/hid.h"
/// Mode values for HidLaControllerSupportArgPrivate::mode.
typedef enum {
HidLaControllerSupportMode_ShowControllerSupport = 0, ///< ShowControllerSupport
HidLaControllerSupportMode_ShowControllerStrapGuide = 1, ///< [3.0.0+] ShowControllerStrapGuide
HidLaControllerSupportMode_ShowControllerFirmwareUpdate = 2, ///< [3.0.0+] ShowControllerFirmwareUpdate
HidLaControllerSupportMode_ShowControllerKeyRemappingForSystem = 4, ///< [11.0.0+] ShowControllerKeyRemappingForSystem
} HidLaControllerSupportMode;
/// ControllerSupportCaller
typedef enum {
HidLaControllerSupportCaller_Application = 0, ///< Application, this is the default.
HidLaControllerSupportCaller_System = 1, ///< System. Skips the firmware-update confirmation dialog. This has the same affect as using the controller-update option from qlaunch System Settings.
} HidLaControllerSupportCaller;
/// ControllerSupportArgPrivate
typedef struct {
u32 private_size; ///< Size of this ControllerSupportArgPrivate struct.
u32 arg_size; ///< Size of the storage following this one (\ref HidLaControllerSupportArg or \ref HidLaControllerFirmwareUpdateArg).
u8 flag0; ///< Flag0
u8 flag1; ///< Flag1
u8 mode; ///< \ref HidLaControllerSupportMode
u8 controller_support_caller; ///< \ref HidLaControllerSupportCaller. Always zero except with \ref hidLaShowControllerFirmwareUpdateForSystem, which sets this to the input param.
u32 npad_style_set; ///< Output from \ref hidGetSupportedNpadStyleSet. With ShowControllerSupportForSystem on pre-3.0.0 this is value 0.
u32 npad_joy_hold_type; ///< Output from \ref hidGetNpadJoyHoldType. With ShowControllerSupportForSystem on pre-3.0.0 this is value 1.
} HidLaControllerSupportArgPrivate;
/// Common header used by HidLaControllerSupportArg*.
/// max_supported_players is 4 on pre-8.0.0, 8 on [8.0.0+]. player_count_min and player_count_max are overriden with value 4 when larger than value 4, during conversion handling for \ref HidLaControllerSupportArg on pre-8.0.0.
typedef struct {
s8 player_count_min; ///< playerCountMin. Must be >=0 and <=max_supported_players.
s8 player_count_max; ///< playerCountMax. Must be >=1 and <=max_supported_players.
u8 enable_take_over_connection; ///< enableTakeOverConnection, non-zero to enable. Disconnects the controllers when not enabled.
u8 enable_left_justify; ///< enableLeftJustify, non-zero to enable.
u8 enable_permit_joy_dual; ///< enablePermitJoyDual, non-zero to enable.
u8 enable_single_mode; ///< enableSingleMode, non-zero to enable. Enables using a single player in handheld-mode, dual-mode, or single-mode (player_count_* are overridden). Using handheld-mode is not allowed if this is not enabled.
u8 enable_identification_color; ///< When non-zero enables using identification_color.
} HidLaControllerSupportArgHeader;
/// Identification color used by HidLaControllerSupportArg*. When HidLaControllerSupportArgHeader::enable_identification_color is set this controls the color of the UI player box outline.
typedef struct {
u8 r; ///< Red color component.
u8 g; ///< Green color component.
u8 b; ///< Blue color component.
u8 a; ///< Alpha color component.
} HidLaControllerSupportArgColor;
/// ControllerSupportArg for [1.0.0+].
typedef struct {
HidLaControllerSupportArgHeader hdr; ///< \ref HidLaControllerSupportArgHeader
HidLaControllerSupportArgColor identification_color[4]; ///< \ref HidLaControllerSupportArgColor for each player, see HidLaControllerSupportArgHeader::enable_identification_color.
u8 enable_explain_text; ///< Enables using the ExplainText data when non-zero.
char explain_text[4][0x81]; ///< ExplainText for each player, NUL-terminated UTF-8 strings.
} HidLaControllerSupportArgV3;
/// ControllerSupportArg for [8.0.0+], converted to \ref HidLaControllerSupportArgV3 on pre-8.0.0.
typedef struct {
HidLaControllerSupportArgHeader hdr; ///< \ref HidLaControllerSupportArgHeader
HidLaControllerSupportArgColor identification_color[8]; ///< \ref HidLaControllerSupportArgColor for each player, see HidLaControllerSupportArgHeader::enable_identification_color.
u8 enable_explain_text; ///< Enables using the ExplainText data when non-zero.
char explain_text[8][0x81]; ///< ExplainText for each player, NUL-terminated UTF-8 strings.
} HidLaControllerSupportArg;
/// ControllerFirmwareUpdateArg
typedef struct {
u8 enable_force_update; ///< enableForceUpdate, non-zero to enable. Default is 0. Forces a firmware update when enabled, without an UI option to skip it.
u8 pad[3]; ///< Padding.
} HidLaControllerFirmwareUpdateArg;
/// ControllerKeyRemappingArg
typedef struct {
u64 unk_x0; ///< Unknown
u32 unk_x8; ///< Unknown
u8 pad[0x4]; ///< Padding
} HidLaControllerKeyRemappingArg;
/// ControllerSupportResultInfo. First 8-bytes from the applet output storage.
typedef struct {
s8 player_count; ///< playerCount.
u8 pad[3]; ///< Padding.
u32 selected_id; ///< \ref HidNpadIdType, selectedId.
} HidLaControllerSupportResultInfo;
/// Struct for the applet output storage.
typedef struct {
HidLaControllerSupportResultInfo info; ///< \ref HidLaControllerSupportResultInfo
u32 res; ///< Output res value.
} HidLaControllerSupportResultInfoInternal;
/**
* @brief Initializes a \ref HidLaControllerSupportArg with the defaults.
* @note This clears the arg, then does: HidLaControllerSupportArgHeader::player_count_min = 0, HidLaControllerSupportArgHeader::player_count_max = 4, HidLaControllerSupportArgHeader::enable_take_over_connection = 1, HidLaControllerSupportArgHeader::enable_left_justify = 1, and HidLaControllerSupportArgHeader::enable_permit_joy_dual = 1.
* @note If preferred, you can also memset \ref HidLaControllerSupportArg manually and initialize it yourself.
* @param[out] arg \ref HidLaControllerSupportArg
*/
void hidLaCreateControllerSupportArg(HidLaControllerSupportArg *arg);
/**
* @brief Initializes a \ref HidLaControllerFirmwareUpdateArg with the defaults.
* @note This just uses memset() with the arg.
* @param[out] arg \ref HidLaControllerFirmwareUpdateArg
*/
void hidLaCreateControllerFirmwareUpdateArg(HidLaControllerFirmwareUpdateArg *arg);
/**
* @brief Initializes a \ref HidLaControllerKeyRemappingArg with the defaults.
* @note This just uses memset() with the arg.
* @param[out] arg \ref HidLaControllerKeyRemappingArg
*/
void hidLaCreateControllerKeyRemappingArg(HidLaControllerKeyRemappingArg *arg);
/**
* @brief Sets the ExplainText for the specified player and \ref HidLaControllerSupportArg.
* @note This string is displayed in the UI box for the player.
* @note HidLaControllerSupportArg::enable_explain_text must be set, otherwise this ExplainText is ignored.
* @param arg \ref HidLaControllerSupportArg
* @param[in] str Input ExplainText UTF-8 string, max length is 0x80 excluding NUL-terminator.
+ @oaram[in] id Player controller, must be <8.
*/
Result hidLaSetExplainText(HidLaControllerSupportArg *arg, const char *str, HidNpadIdType id);
/**
* @brief Launches the applet for ControllerSupport.
* @note This seems to only display the applet UI when doing so is actually needed? This doesn't apply to \ref hidLaShowControllerSupportForSystem.
* @param[out] result_info \ref HidLaControllerSupportResultInfo. Optional, can be NULL.
* @param[in] arg \ref HidLaControllerSupportArg
*/
Result hidLaShowControllerSupport(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg);
/**
* @brief Launches the applet for ControllerStrapGuide.
* @note Only available on [3.0.0+].
*/
Result hidLaShowControllerStrapGuide(void);
/**
* @brief Launches the applet for ControllerFirmwareUpdate.
* @note Only available on [3.0.0+].
* @param[in] arg \ref HidLaControllerFirmwareUpdateArg
*/
Result hidLaShowControllerFirmwareUpdate(const HidLaControllerFirmwareUpdateArg *arg);
/**
* @brief This is the system version of \ref hidLaShowControllerSupport.
* @param[out] result_info \ref HidLaControllerSupportResultInfo. Optional, can be NULL.
* @param[in] arg \ref HidLaControllerSupportArg
* @param[in] flag Input flag. When true, the applet displays the menu as if launched by qlaunch.
*/
Result hidLaShowControllerSupportForSystem(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg, bool flag);
/**
* @brief This is the system version of \ref hidLaShowControllerFirmwareUpdate.
* @note Only available on [3.0.0+].
* @param[in] arg \ref HidLaControllerFirmwareUpdateArg
* @param[in] caller \ref HidLaControllerSupportCaller
*/
Result hidLaShowControllerFirmwareUpdateForSystem(const HidLaControllerFirmwareUpdateArg *arg, HidLaControllerSupportCaller caller);
/**
* @brief Launches the applet for ControllerKeyRemappingForSystem.
* @note Only available on [11.0.0+].
* @param[in] arg \ref HidLaControllerKeyRemappingArg
* @param[in] caller \ref HidLaControllerSupportCaller
*/
Result hidLaShowControllerKeyRemappingForSystem(const HidLaControllerKeyRemappingArg *arg, HidLaControllerSupportCaller caller);

View File

@ -7,18 +7,17 @@
#pragma once
#include "../types.h"
#include "../services/applet.h"
#include "../services/acc.h"
/// CommonArguments
typedef struct {
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 CommonArgs_version;
u32 CommonArgs_size;
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]; ///< Padding.
u64 tick; ///< System tick. Set to the output from \ref armGetSystemTick during \ref libappletArgsPush.
u8 pad[7];
u64 tick;
} LibAppletArgs;
/**
@ -35,23 +34,6 @@ void libappletArgsCreate(LibAppletArgs* a, u32 version);
*/
void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag);
/**
* @brief Creates an AppletStorage with the specified size and writes the buffer contents to that storage at offset 0.
* @param[out] s Storage object.
* @param buffer Input buffer.
* @param size Size to write.
*/
Result libappletCreateWriteStorage(AppletStorage* s, const void* buffer, size_t size);
/**
* @brief Reads data from offset 0 from the specified storage into the buffer. If the storage-size is smaller than the size param, the storage-size is used instead.
* @param s Storage object.
* @param buffer Output buffer.
* @param size Size to read.
* @param transfer_size Optional output size field for the actual size used for the read, can be NULL.
*/
Result libappletReadStorage(AppletStorage* s, void* buffer, size_t size, size_t *transfer_size);
/**
* @brief Sets the tick field in LibAppletArgs, then creates a storage with it which is pushed to the AppletHolder via \ref appletHolderPushInData.
* @param a LibAppletArgs struct.
@ -59,12 +41,6 @@ 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.
@ -73,40 +49,6 @@ Result libappletArgsPop(LibAppletArgs* a);
*/
Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size);
/**
* @brief Pops a storage via \ref appletHolderPopOutData, uses \ref libappletReadStorage, then closes the storage.
* @param h AppletHolder object.
* @param buffer Output buffer.
* @param size Size to read.
* @param transfer_size Optional output size field for the actual size used for the read, can be NULL.
*/
Result libappletPopOutData(AppletHolder *h, void* buffer, size_t size, size_t *transfer_size);
/**
* @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.
*/
Result libappletStart(AppletHolder *h);
/**
* @brief Creates a LibraryApplet with the specified input storage data, uses \ref libappletStart, and reads the output storage reply data via \ref libappletPopOutData.
* @param id \ref AppletId
* @param commonargs \ref LibAppletArgs struct.
* @param arg Input storage data buffer. Optional, can be NULL.
* @param arg_size Size of the arg buffer.
* @param reply Output storage data buffer. Optional, can be NULL.
* @param reply_size Size to read for the reply buffer.
* @param out_reply_size Actual read reply data size, see \ref libappletPopOutData.
*/
Result libappletLaunch(AppletId id, LibAppletArgs *commonargs, const void* arg, size_t arg_size, void* reply, size_t reply_size, size_t *out_reply_size);
/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
/// Returns to the main Home Menu, equivalent to pressing the HOME button.
Result libappletRequestHomeMenu(void);
@ -115,22 +57,3 @@ Result libappletRequestHomeMenu(void);
/// Equivalent to entering "System Update" under System Settings. When leaving this, it returns to the main Home Menu.
Result libappletRequestJumpToSystemUpdate(void);
/**
* @brief Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
* @note Only available on [11.0.0+].
* @param[in] application_id ApplicationId
* @param[in] uid \ref AccountUid
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size.
* @param[in] sender LaunchApplicationRequestSender
*/
Result libappletRequestToLaunchApplication(u64 application_id, AccountUid uid, const void* buffer, size_t size, u32 sender);
/**
* @brief Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
* @note Only available on [11.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] application_id Optional ApplicationId, can be 0.
*/
Result libappletRequestJumpToStory(AccountUid uid, u64 application_id);

View File

@ -1,101 +0,0 @@
/**
* @file mii_la.h
* @brief Wrapper for using the MiiEdit LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/mii.h"
/// AppletMode
typedef enum {
MiiLaAppletMode_ShowMiiEdit = 0, ///< ShowMiiEdit
MiiLaAppletMode_AppendMii = 1, ///< AppendMii
MiiLaAppletMode_AppendMiiImage = 2, ///< AppendMiiImage
MiiLaAppletMode_UpdateMiiImage = 3, ///< UpdateMiiImage
MiiLaAppletMode_CreateMii = 4, ///< [10.2.0+] CreateMii
MiiLaAppletMode_EditMii = 5, ///< [10.2.0+] EditMii
} MiiLaAppletMode;
/// AppletInput
typedef struct {
s32 version; ///< Version
u32 mode; ///< \ref MiiLaAppletMode
s32 special_key_code; ///< \ref MiiSpecialKeyCode
union {
Uuid valid_uuid_array[8]; ///< ValidUuidArray. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_AppendMiiImage / ::NfpLaMiiLaAppletMode_UpdateMiiImage.
struct {
MiiCharInfo char_info; ///< \ref MiiCharInfo
u8 unused_x64[0x28]; ///< Unused
} char_info;
};
Uuid used_uuid; ///< UsedUuid. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_UpdateMiiImage.
u8 unk_x9C[0x64]; ///< Unused
} MiiLaAppletInput;
/// AppletOutput
typedef struct {
u32 res; ///< Result: 0 = Success, 1 = Cancel.
s32 index; ///< Index. Only set when Result is Success, where \ref MiiLaAppletMode isn't ::NfpLaMiiLaAppletMode_ShowMiiEdit.
u8 unk_x8[0x18]; ///< Unused
} MiiLaAppletOutput;
/// AppletOutputForCharInfoEditing
typedef struct {
u32 res; ///< MiiLaAppletOutput::res
MiiCharInfo char_info; ///< \ref MiiCharInfo
u8 unused[0x24]; ///< Unused
} MiiLaAppletOutputForCharInfoEditing;
/**
* @brief Launches the applet for ShowMiiEdit.
* @param[in] special_key_code \ref MiiSpecialKeyCode
*/
Result miiLaShowMiiEdit(MiiSpecialKeyCode special_key_code);
/**
* @brief Launches the applet for AppendMii.
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[out] index Output Index.
*/
Result miiLaAppendMii(MiiSpecialKeyCode special_key_code, s32 *index);
/**
* @brief Launches the applet for AppendMiiImage.
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[in] valid_uuid_array Input array of Uuid.
* @param[in] count Total entries for the valid_uuid_array. Must be 0-8.
* @param[out] index Output Index.
*/
Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index);
/**
* @brief Launches the applet for UpdateMiiImage.
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[in] valid_uuid_array Input array of Uuid.
* @param[in] count Total entries for the valid_uuid_array. Must be 0-8.
* @param[in] used_uuid UsedUuid
* @param[out] index Output Index.
*/
Result miiLaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index);
/**
* @brief Launches the applet for CreateMii.
* @note This creates a Mii and returns it, without saving it in the database.
* @note Only available on [10.2.0+].
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[out] out_char \ref MiiCharInfo
*/
Result miiLaCreateMii(MiiSpecialKeyCode special_key_code, MiiCharInfo *out_char);
/**
* @brief Launches the applet for EditMii.
* @note This edits the specified Mii and returns it, without saving it in the database.
* @note Only available on [10.2.0+].
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[in] in_char \ref MiiCharInfo
* @param[out] out_char \ref MiiCharInfo
*/
Result miiLaEditMii(MiiSpecialKeyCode special_key_code, const MiiCharInfo *in_char, MiiCharInfo *out_char);

View File

@ -1,89 +0,0 @@
/**
* @file nfp_la.h
* @brief Wrapper for using the cabinet (amiibo) LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/nfc.h"
/// Values for NfpLaStartParamForAmiiboSettings::type.
typedef enum {
NfpLaStartParamTypeForAmiiboSettings_NicknameAndOwnerSettings = 0, ///< NicknameAndOwnerSettings
NfpLaStartParamTypeForAmiiboSettings_GameDataEraser = 1, ///< GameDataEraser
NfpLaStartParamTypeForAmiiboSettings_Restorer = 2, ///< Restorer
NfpLaStartParamTypeForAmiiboSettings_Formatter = 3, ///< Formatter
} NfpLaStartParamTypeForAmiiboSettings;
/// AmiiboSettingsStartParam
typedef struct {
u8 unk_x0[0x8]; ///< Unknown
u8 unk_x8[0x20]; ///< Unknown
u8 unk_x28; ///< Unknown
} NfpLaAmiiboSettingsStartParam;
/// StartParamForAmiiboSettings
typedef struct {
u8 unk_x0; ///< Unknown
u8 type; ///< \ref NfpLaStartParamTypeForAmiiboSettings
u8 flags; ///< Flags
u8 unk_x3; ///< NfpLaAmiiboSettingsStartParam::unk_x28
u8 unk_x4[0x8]; ///< NfpLaAmiiboSettingsStartParam::unk_x0
NfpTagInfo tag_info; ///< \ref NfpTagInfo, only enabled when flags bit1 is set.
NfpRegisterInfo register_info; ///< \ref NfpRegisterInfo, only enabled when flags bit2 is set.
u8 unk_x164[0x20]; ///< NfpLaAmiiboSettingsStartParam::unk_x8
u8 unk_x184[0x24]; ///< Unknown
} NfpLaStartParamForAmiiboSettings;
/// ReturnValueForAmiiboSettings
typedef struct {
u8 flags; ///< 0 = error, non-zero = success.
u8 pad[3]; ///< Padding
NfcDeviceHandle handle; ///< \ref NfcDeviceHandle
NfpTagInfo tag_info; ///< \ref NfpTagInfo
NfpRegisterInfo register_info; ///< \ref NfpRegisterInfo, only available when flags bit2 is set.
u8 unk_x164[0x24]; ///< Unknown
} NfpLaReturnValueForAmiiboSettings;
/**
* @brief Launches the applet for NicknameAndOwnerSettings.
* @note Official sw does not expose functionality for using input/output \ref NfpTagInfo at the same time.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[in] in_tag_info \ref NfpTagInfo. Optional, can be NULL. If specified, this must match the scanned amiibo.
* @param[in] in_reg_info \ref NfpRegisterInfo. Optional, can be NULL. If specified, this sets the \ref NfpRegisterInfo which will be used for writing, with an option for the user to change it.
* @param[out] out_tag_info \ref NfpTagInfo. Optional, can be NULL.
* @param[out] handle \ref NfcDeviceHandle
* @param[out] reg_info_flag Flag indicating whether the data for out_reg_info is set. Optional, can be NULL.
* @param[out] out_reg_info \ref NfpRegisterInfo, see reg_info_flag. Optional, can be NULL.
*/
Result nfpLaStartNicknameAndOwnerSettings(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, const NfpRegisterInfo *in_reg_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle, bool *reg_info_flag, NfpRegisterInfo *out_reg_info);
/**
* @brief Launches the applet for GameDataEraser.
* @note Official sw does not expose functionality for using input/output \ref NfpTagInfo at the same time.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[in] in_tag_info \ref NfpTagInfo. Optional, can be NULL. If specified, this must match the scanned amiibo.
* @param[out] out_tag_info \ref NfpTagInfo. Optional, can be NULL.
* @param[out] handle \ref NfcDeviceHandle
*/
Result nfpLaStartGameDataEraser(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle);
/**
* @brief Launches the applet for Restorer.
* @note Official sw does not expose functionality for using input/output \ref NfpTagInfo at the same time.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[in] in_tag_info \ref NfpTagInfo. Optional, can be NULL. If specified, this must match the scanned amiibo.
* @param[out] out_tag_info \ref NfpTagInfo. Optional, can be NULL.
* @param[out] handle \ref NfcDeviceHandle
*/
Result nfpLaStartRestorer(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle);
/**
* @brief Launches the applet for Formatter.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[out] out_tag_info \ref NfpTagInfo
* @param[out] handle \ref NfcDeviceHandle
*/
Result nfpLaStartFormatter(const NfpLaAmiiboSettingsStartParam *in_param, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle);

View File

@ -1,16 +0,0 @@
/**
* @file nifm_la.h
* @brief Wrapper for using the nifm LibraryApplet (the launched applet varies).
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/nifm.h"
/**
* @brief Uses \ref nifmGetResult, then on failure launches the applet.
* @param r \ref NifmRequest
*/
Result nifmLaHandleNetworkRequestResult(NifmRequest* r);

View File

@ -1,58 +0,0 @@
/**
* @file pctlauth.h
* @brief Wrapper for using the Parental Controls authentication LibraryApplet. This applet is used by qlaunch.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Type values for PctlAuthArg::type.
typedef enum {
PctlAuthType_Show = 0, ///< ShowParentalAuthentication
PctlAuthType_RegisterPasscode = 1, ///< RegisterParentalPasscode
PctlAuthType_ChangePasscode = 2, ///< ChangeParentalPasscode
} PctlAuthType;
/// Input arg storage for the applet.
typedef struct {
u32 unk_x0; ///< Always set to 0 by the user-process.
PctlAuthType type; ///< \ref PctlAuthType
u8 arg0; ///< Arg0
u8 arg1; ///< Arg1
u8 arg2; ///< Arg2
u8 pad; ///< Padding
} PctlAuthArg;
/**
* @brief Launches the applet.
* @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled.
* @param flag Input flag. false = temporarily disable Parental Controls. true = validate the input PIN.
*/
Result pctlauthShow(bool flag);
/**
* @brief Launches the applet. Only available with [4.0.0+].
* @param arg0 Value for PctlAuthArg.arg0.
* @param arg1 Value for PctlAuthArg.arg1.
* @param arg2 Value for PctlAuthArg.arg2.
*/
Result pctlauthShowEx(u8 arg0, u8 arg1, u8 arg2);
/**
* @brief Just calls: pctlauthShowEx(1, 0, 1). Launches the applet for checking the PIN, used when changing system-settings.
* @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled.
*/
Result pctlauthShowForConfiguration(void);
/**
* @brief Launches the applet for registering the Parental Controls PIN.
*/
Result pctlauthRegisterPasscode(void);
/**
* @brief Launches the applet for changing the Parental Controls PIN.
* @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled.
*/
Result pctlauthChangePasscode(void);

View File

@ -1,210 +0,0 @@
/**
* @file psel.h
* @brief Wrapper for using the playerSelect (user selection) LibraryApplet.
* @author XorTroll, yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/acc.h"
/// playerSelect UI modes.
typedef enum {
PselUiMode_UserSelector = 0, ///< UserSelector
PselUiMode_UserCreator = 1, ///< UserCreator
PselUiMode_EnsureNetworkServiceAccountAvailable = 2, ///< EnsureNetworkServiceAccountAvailable
PselUiMode_UserIconEditor = 3, ///< UserIconEditor
PselUiMode_UserNicknameEditor = 4, ///< UserNicknameEditor
PselUiMode_UserCreatorForStarter = 5, ///< UserCreatorForStarter
PselUiMode_NintendoAccountAuthorizationRequestContext = 6, ///< NintendoAccountAuthorizationRequestContext
PselUiMode_IntroduceExternalNetworkServiceAccount = 7, ///< IntroduceExternalNetworkServiceAccount
PselUiMode_IntroduceExternalNetworkServiceAccountForRegistration = 8, ///< [6.0.0+] IntroduceExternalNetworkServiceAccountForRegistration
PselUiMode_NintendoAccountNnidLinker = 9, ///< [6.0.0+] NintendoAccountNnidLinker
PselUiMode_LicenseRequirementsForNetworkService = 10, ///< [6.0.0+] LicenseRequirementsForNetworkService
PselUiMode_LicenseRequirementsForNetworkServiceWithUserContextImpl = 11, ///< [7.0.0+] LicenseRequirementsForNetworkServiceWithUserContextImpl
PselUiMode_UserCreatorForImmediateNaLoginTest = 12, ///< [7.0.0+] UserCreatorForImmediateNaLoginTest
PselUiMode_UserQualificationPromoter = 13, ///< [13.0.0+] UserQualificationPromoter
} PselUiMode;
/// UI message text to display with ::PselUiMode_UserSelector. Invalid values are handled as ::PselUserSelectionPurpose_General.
typedef enum {
PselUserSelectionPurpose_General = 0, ///< "Select a user."
PselUserSelectionPurpose_GameCardRegistration = 1, ///< [2.0.0+] "Who will receive the points?"
PselUserSelectionPurpose_EShopLaunch = 2, ///< [2.0.0+] "Who is using Nintendo eShop?"
PselUserSelectionPurpose_EShopItemShow = 3, ///< [2.0.0+] "Who is making this purchase?"
PselUserSelectionPurpose_PicturePost = 4, ///< [2.0.0+] "Who is posting?"
PselUserSelectionPurpose_NintendoAccountLinkage = 5, ///< [2.0.0+] "Select a user to link to a Nintendo Account."
PselUserSelectionPurpose_SettingsUpdate = 6, ///< [2.0.0+] "Change settings for which user?"
PselUserSelectionPurpose_SaveDataDeletion = 7, ///< [2.0.0+] "Format data for which user?"
PselUserSelectionPurpose_UserMigration = 8, ///< [4.0.0+] "Which user will be transferred to another console?"
PselUserSelectionPurpose_SaveDataTransfer = 9, ///< [8.0.0+] "Send save data for which user?"
} PselUserSelectionPurpose;
/// NintendoAccountStartupDialogType
typedef enum {
PselNintendoAccountStartupDialogType_LoginAndCreate = 0, ///< LoginAndCreate
PselNintendoAccountStartupDialogType_Login = 1, ///< Login
PselNintendoAccountStartupDialogType_Create = 2, ///< Create
} PselNintendoAccountStartupDialogType;
/// Base UI settings for playerSelect.
typedef struct {
u32 mode; ///< \ref PselUiMode
u32 pad; ///< Padding.
AccountUid invalid_uid_list[ACC_USER_LIST_SIZE]; ///< List of \ref AccountUid. TODO: This is only correct for ::PselUiMode_UserSelector, for other modes this is a single uid, followed by mode-specific data (if any).
u64 application_id; ///< ApplicationId with \ref pselShowUserSelectorForLauncher.
u8 is_network_service_account_required; ///< PselUserSelectionSettings::is_network_service_account_required.
u8 is_skip_enabled; ///< PselUserSelectionSettings::is_skip_enabled
u8 unk_x92; ///< Set to value 1 by \ref pselShowUserSelectorForSystem / \ref pselShowUserSelectorForLauncher.
u8 is_permitted; ///< isPermitted. With ::PselUiMode_UserSelector: enables the option to create a new user. Set to the output from \ref accountIsUserRegistrationRequestPermitted with pselShowUserSelector*. When not set, a dialog will be displayed when the user attempts to create an user.
u8 show_skip_button; ///< PselUserSelectionSettings::show_skip_button
u8 additional_select; ///< PselUserSelectionSettings::additional_select
u8 unk_x96; ///< [2.0.0+] Set to PselUserSelectionSettingsForSystemService::enable_user_creation_button. \ref pselShowUserSelectorForLauncher / \ref pselShowUserSelector sets this to value 1.
u8 unk_x97; ///< [6.0.0+] Set to PselUserSelectionSettings::is_unqualified_user_selectable ^ 1.
} PselUiSettingsV1;
/// UI settings for versions starting with 0x10000.
typedef struct {
PselUiSettingsV1 settings; ///< \ref PselUiSettingsV1
u32 unk_x98; ///< [2.0.0+] Set to PselUserSelectionSettingsForSystemService::purpose.
u8 unk_x9c[0x4]; ///< Unknown.
} PselUiSettings;
/// UserSelectionSettings
typedef struct {
AccountUid invalid_uid_list[ACC_USER_LIST_SIZE]; ///< invalidUidList.
u8 is_skip_enabled; ///< isSkipEnabled. When set, the first user in invalid_uid_list must not be set, and additional_select must be 0. When enabled \ref accountTrySelectUserWithoutInteraction will be used to select the user, in this case the applet will only be launched if \ref accountTrySelectUserWithoutInteraction doesn't return an user.
u8 is_network_service_account_required; ///< isNetworkServiceAccountRequired. Whether the user needs to be linked to a Nintendo account.
u8 show_skip_button; ///< showSkipButton. Enables the option to skip user selection with a button.
u8 additional_select; ///< additionalSelect.
u8 is_unqualified_user_selectable; ///< [6.0.0+] isUnqualifiedUserSelectable
} PselUserSelectionSettings;
/// [2.0.0+] UserSelectionSettingsForSystemService
typedef struct {
u32 purpose; ///< \ref PselUserSelectionPurpose
u8 enable_user_creation_button; ///< Enables the user-creation button when set. Whether user-creation when pressing the button is actually allowed is controlled by PselUiSettingsV1::is_permitted.
u8 pad[0x3]; ///< Padding.
} PselUserSelectionSettingsForSystemService;
/// Return data sent after execution.
typedef struct {
Result res; ///< Result.
AccountUid user_id; ///< Selected \ref AccountUid.
} PselUiReturnArg;
/**
* @brief Creates a new UI config for the playerSelect applet with the specified mode.
* @param ui PseluiSettings struct.
* @param mode playerSelect UI mode.
*/
Result pselUiCreate(PselUiSettings *ui, PselUiMode mode);
/**
* @brief Adds an user to the user list of the applet.
* @param ui PselUiSettings struct.
* @param[in] user_id user ID.
* @note The users will be treated as invalid users for user selection mode, and as the input user for other modes.
*/
void pselUiAddUser(PselUiSettings *ui, AccountUid user_id);
/**
* @brief Sets whether users can be created in the applet.
* @param ui PselUiSettings struct.
* @param flag Flag value.
* @note Only used for ::PselUiMode_SelectUser.
*/
NX_CONSTEXPR void pselUiSetAllowUserCreation(PselUiSettings *ui, bool flag) {
if(ui->settings.mode == PselUiMode_UserSelector) {
ui->settings.is_permitted = flag!=0;
}
}
/**
* @brief Sets whether users need to be linked to a Nintendo account.
* @param ui PselUiSettings struct.
* @param flag Flag value.
*/
NX_CONSTEXPR void pselUiSetNetworkServiceRequired(PselUiSettings *ui, bool flag) {
ui->settings.is_network_service_account_required = flag;
}
/**
* @brief Sets whether selection can be skipped with a button.
* @param ui PselUiSettings struct.
* @param flag Flag value.
*/
NX_CONSTEXPR void pselUiSetSkipButtonEnabled(PselUiSettings *ui, bool flag) {
ui->settings.show_skip_button = flag!=0;
}
/**
* @brief Shows the applet with the specified UI settings.
* @param ui PselUiSettings struct.
* @param out_user Selected user ID.
* @note If user skips (see \ref pselUiSetSkipEnabled) this will return successfully but the output ID will be 0.
*/
Result pselUiShow(PselUiSettings *ui, AccountUid *out_user);
/**
* @brief This is the System version of \ref pselShowUserSelector.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. See also the docs for PselUserSelectionSettings::is_skip_enabled.
* @param[out] out_user Returned selected user ID.
* @param[in] settings \ref PselUserSelectionSettings
* @param[in] settings_system [2.0.0+] \ref PselUserSelectionSettingsForSystemService, ignored on prior versions.
*/
Result pselShowUserSelectorForSystem(AccountUid *out_user, const PselUserSelectionSettings *settings, const PselUserSelectionSettingsForSystemService *settings_system);
/**
* @brief This is the Launcher version of \ref pselShowUserSelector.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. See also the docs for PselUserSelectionSettings::is_skip_enabled.
* @param[out] out_user Returned selected user ID.
* @param[in] settings \ref PselUserSelectionSettings
* @param[in] application_id ApplicationId
*/
Result pselShowUserSelectorForLauncher(AccountUid *out_user, const PselUserSelectionSettings *settings, u64 application_id);
/**
* @brief Shows the applet to select a user.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. See also the docs for PselUserSelectionSettings::is_skip_enabled.
* @param[out] out_user Returned selected user ID.
* @param[in] settings \ref PselUserSelectionSettings
*/
Result pselShowUserSelector(AccountUid *out_user, const PselUserSelectionSettings *settings);
/**
* @brief Shows the applet to create a user.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. If the output flag is 0, an error will be thrown.
*/
Result pselShowUserCreator(void);
/**
* @brief Shows the applet to change a user's icon.
* @param[in] user Input user ID.
*/
Result pselShowUserIconEditor(AccountUid user);
/**
* @brief Shows the applet to change a user's nickname.
* @param[in] user Input user ID.
*/
Result pselShowUserNicknameEditor(AccountUid user);
/**
* @brief Shows the applet to create a user. Used by the starter applet during system setup.
*/
Result pselShowUserCreatorForStarter(void);
/**
* @brief Shows the applet for Nintendo Account Nnid linking.
* @note Only available on [6.0.0+].
* @param[in] user Input user ID.
*/
Result pselShowNintendoAccountNnidLinker(AccountUid user);
/**
* @brief Shows the applet for UserQualificationPromoter.
* @note Only available on [13.0.0+].
* @param[in] user Input user ID.
*/
Result pselShowUserQualificationPromoter(AccountUid user);

View File

@ -8,7 +8,6 @@
#include "../types.h"
#include "../services/applet.h"
/// Output result returned by \ref SwkbdTextCheckCb.
typedef enum {
SwkbdTextCheckResult_OK = 0, ///< Success, valid string.
SwkbdTextCheckResult_Bad = 1, ///< Failure, invalid string. Error message is displayed in a message-box, pressing OK will return to swkbd again.
@ -16,21 +15,13 @@ typedef enum {
SwkbdTextCheckResult_Silent = 3, ///< Failure, invalid string. With value 3 and above, swkbd will silently not accept the string, without displaying any error.
} SwkbdTextCheckResult;
/// Type of keyboard.
typedef enum {
SwkbdType_Normal = 0, ///< Normal keyboard.
SwkbdType_NumPad = 1, ///< Number pad. The buttons at the bottom left/right are only available when they're set by \ref swkbdConfigSetLeftOptionalSymbolKey / \ref swkbdConfigSetRightOptionalSymbolKey.
SwkbdType_QWERTY = 2, ///< QWERTY (and variants) keyboard only.
SwkbdType_Unknown3 = 3, ///< The same as SwkbdType_Normal keyboard.
SwkbdType_Latin = 4, ///< All Latin like languages keyboard only (without CJK keyboard).
SwkbdType_ZhHans = 5, ///< Chinese Simplified keyboard only.
SwkbdType_ZhHant = 6, ///< Chinese Traditional keyboard only.
SwkbdType_Korean = 7, ///< Korean keyboard only.
SwkbdType_All = 8, ///< All language keyboards.
SwkbdType_Unknown9 = 9, ///< Unknown
SwkbdType_Normal = 0, ///< Normal keyboard.
SwkbdType_NumPad = 1, ///< Number pad. The buttons at the bottom left/right are only available when they're set by \ref swkbdConfigSetLeftOptionalSymbolKey / \ref swkbdConfigSetRightOptionalSymbolKey.
SwkbdType_QWERTY = 2, ///< QWERTY (and variants) keyboard only.
} SwkbdType;
/// Bitmask for SwkbdArgCommon::keySetDisableBitmask. This disables keys on the keyboard when the corresponding bit(s) are set.
/// Bitmask for \ref SwkbdArgV0 keySetDisableBitmask. This disables keys on the keyboard when the corresponding bit(s) are set.
enum {
SwkbdKeyDisableBitmask_Space = BIT(1), ///< Disable space-bar.
SwkbdKeyDisableBitmask_At = BIT(2), ///< Disable '@'.
@ -42,81 +33,14 @@ enum {
SwkbdKeyDisableBitmask_UserName = BIT(8), ///< Used for \ref swkbdConfigMakePresetUserName. Disables '@', '%', and '\'.
};
/// Value for SwkbdArgCommon::textDrawType. Only applies when stringLenMax is 1..32, otherwise swkbd will only use SwkbdTextDrawType_Box.
/// Value for \ref SwkbdArgV0 textDrawType. Only applies when stringLenMax is 1..32, otherwise swkbd will only use SwkbdTextDrawType_Box.
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.
typedef enum {
SwkbdRequestCommand_Finalize = 0x4,
SwkbdRequestCommand_SetUserWordInfo = 0x6,
SwkbdRequestCommand_SetCustomizeDic = 0x7,
SwkbdRequestCommand_Calc = 0xA,
SwkbdRequestCommand_SetCustomizedDictionaries = 0xB,
SwkbdRequestCommand_UnsetCustomizedDictionaries = 0xC,
SwkbdRequestCommand_SetChangedStringV2Flag = 0xD,
SwkbdRequestCommand_SetMovedCursorV2Flag = 0xE,
} SwkbdRequestCommand;
/// SwkbdInline Interactive output storage reply ID.
typedef enum {
SwkbdReplyType_FinishedInitialize = 0x0,
SwkbdReplyType_ChangedString = 0x2,
SwkbdReplyType_MovedCursor = 0x3,
SwkbdReplyType_MovedTab = 0x4,
SwkbdReplyType_DecidedEnter = 0x5,
SwkbdReplyType_DecidedCancel = 0x6,
SwkbdReplyType_ChangedStringUtf8 = 0x7,
SwkbdReplyType_MovedCursorUtf8 = 0x8,
SwkbdReplyType_DecidedEnterUtf8 = 0x9,
SwkbdReplyType_UnsetCustomizeDic = 0xA,
SwkbdReplyType_ReleasedUserWordInfo = 0xB,
SwkbdReplyType_UnsetCustomizedDictionaries = 0xC,
SwkbdReplyType_ChangedStringV2 = 0xD,
SwkbdReplyType_MovedCursorV2 = 0xE,
SwkbdReplyType_ChangedStringUtf8V2 = 0xF,
SwkbdReplyType_MovedCursorUtf8V2 = 0x10,
} SwkbdReplyType;
/// SwkbdInline State
typedef enum {
SwkbdState_Inactive = 0x0, ///< Default state from \ref swkbdInlineCreate, before a state is set by \ref swkbdInlineUpdate when a reply is received. Also indicates that the applet is no longer running.
SwkbdState_Initialized = 0x1, ///< Applet is initialized but hidden.
SwkbdState_Appearing = 0x2, ///< Applet is appearing.
SwkbdState_Shown = 0x3, ///< Applet is fully shown and ready to accept text input.
SwkbdState_Disappearing = 0x4, ///< The user pressed the ok or cancel button, causing the applet to disappear.
SwkbdState_Unknown5 = 0x5,
SwkbdState_Unknown6 = 0x6,
} SwkbdState;
/// Value for \ref SwkbdInitializeArg mode. Controls the LibAppletMode when launching the applet.
typedef enum {
SwkbdInlineMode_UserDisplay = 0, ///< LibAppletMode_BackgroundIndirect. This is the default. The user-process must handle displaying the swkbd gfx on the screen, by loading the image with \ref swkbdInlineGetImage.
SwkbdInlineMode_AppletDisplay = 1, ///< LibAppletMode_Background. The applet will handle displaying gfx on the screen.
} SwkbdInlineMode;
/// TextCheck callback set by \ref swkbdConfigSetTextCheckCallback, for validating the input string when the swkbd ok-button is pressed. This buffer contains an UTF-8 string. This callback should validate the input string, then return a \ref SwkbdTextCheckResult indicating success/failure. On failure, this function must write an error message to the tmp_string buffer, which will then be displayed by swkbd.
typedef SwkbdTextCheckResult (*SwkbdTextCheckCb)(char* tmp_string, size_t tmp_string_size);
/// User dictionary word.
typedef struct {
u8 unk_x0[0x64];
} SwkbdDictWord;
/// Input data for SwkbdInline request SetCustomizeDic.
typedef struct {
u8 unk_x0[0x70];
} SwkbdCustomizeDicInfo;
typedef struct {
void* buffer; ///< 0x1000-byte aligned buffer.
u32 buffer_size; ///< 0x1000-byte aligned buffer size.
u64 entries[0x18];
u16 total_entries;
} NX_PACKED SwkbdCustomizedDictionarySet;
typedef SwkbdTextCheckResult (*SwkbdTextCheckCb)(char* tmp_string, size_t tmp_string_size); /// TextCheck callback set by \ref swkbdConfigSetTextCheckCallback, for validating the input string when the swkbd ok-button is pressed. This buffer contains an UTF-8 string. This callback should validate the input string, then return a \ref SwkbdTextCheckResult indicating success/failure. On failure, this function must write an error message to the tmp_string buffer, which will then be displayed by swkbd.
/// Base swkbd arg struct.
typedef struct {
@ -133,7 +57,7 @@ typedef struct {
u16 guideText[514/2];
u16 pad_x3aa;
u32 stringLenMax; ///< When non-zero, specifies the max string length. When the input is too long, swkbd will stop accepting more input until text is deleted via the B button (Backspace). See also \ref SwkbdTextDrawType.
u32 stringLenMin; ///< When non-zero, specifies the min string length. When the input is too short, swkbd will display an icon and disable the ok-button.
u32 stringLenMaxExt; ///< When non-zero, specifies the max string length. When the input is too long, swkbd will display an icon and disable the ok-button.
u32 passwordFlag; ///< Use password: 0 = disable, 1 = enable.
SwkbdTextDrawType textDrawType; ///< See \ref SwkbdTextDrawType.
u16 returnButtonFlag; ///< Controls whether the Return button is enabled, for newlines input. 0 = disabled, non-zero = enabled.
@ -144,33 +68,16 @@ typedef struct {
u32 userDicOffset;
s32 userDicEntries;
u8 textCheckFlag;
} SwkbdArgCommon;
typedef struct {
SwkbdArgCommon arg;
u8 pad_x3d1[7];
SwkbdTextCheckCb textCheckCb; ///< This really doesn't belong in a struct sent to another process, but official sw does this.
SwkbdTextCheckCb textCheckCb; ///< This really doesn't belong in a struct sent to another process, but official sw does this.
} SwkbdArgV0;
/// Arg struct for version 0x30007+.
typedef struct {
SwkbdArgV0 arg;
u32 textGrouping[8]; ///< When set and enabled via \ref SwkbdTextDrawType, controls displayed text grouping (inserts spaces, without affecting output string).
u32 unk_x3e0[8]; ///< When set and enabled via \ref SwkbdTextDrawType, controls displayed text grouping (inserts spaces, without affecting output string).
} SwkbdArgV7;
/// Arg struct for version 0x6000B+.
typedef struct {
SwkbdArgCommon arg;
u8 pad_x3d1[3];
u32 textGrouping[8]; ///< Same as SwkbdArgV7::textGrouping.
u64 entries[0x18]; ///< This is SwkbdCustomizedDictionarySet::entries.
u8 total_entries; ///< This is SwkbdCustomizedDictionarySet::total_entries.
u8 unkFlag; ///< [8.0.0+]
u8 pad_x4b6[0xD];
u8 trigger; ///< [8.0.0+]
u8 pad_x4c4[4];
} SwkbdArgVB;
typedef struct {
SwkbdArgV7 arg;
@ -178,168 +85,13 @@ typedef struct {
size_t workbuf_size;
s32 max_dictwords;
SwkbdCustomizedDictionarySet customizedDictionarySet;
u8 unkFlag;
u8 trigger;
u32 version;
} SwkbdConfig;
/// Rect
/// User dictionary word.
typedef struct {
s16 x; ///< X
s16 y; ///< Y
s16 width; ///< Width
s16 height; ///< Height
} SwkbdRect;
/// InitializeArg for SwkbdInline.
typedef struct {
u32 unk_x0;
u8 mode; ///< See \ref SwkbdInlineMode. (u8 bool)
u8 unk_x5; ///< Only set on [5.0.0+].
u8 pad[2];
} SwkbdInitializeArg;
typedef struct {
SwkbdType type; ///< See \ref SwkbdType.
u16 okButtonText[9];
u16 leftButtonText;
u16 rightButtonText;
u8 dicFlag; ///< Enables dictionary usage when non-zero (including the system dictionary).
u8 unk_x1b;
u32 keySetDisableBitmask; ///< See SwkbdKeyDisableBitmask_*.
s32 stringLenMax; ///< When non-negative and non-zero, specifies the max string length. When the input is too long, swkbd will stop accepting more input until text is deleted via the B button (Backspace).
s32 stringLenMin; ///< When non-negative and non-zero, specifies the min string length. When the input is too short, swkbd will display an icon and disable the ok-button.
u8 returnButtonFlag; ///< Controls whether the Return button is enabled, for newlines input. 0 = disabled, non-zero = enabled.
u8 unk_x29; ///< [10.0.0+] When value 1-2, \ref swkbdInlineAppear / \ref swkbdInlineAppearEx will set keytopAsFloating=0 and footerScalable=1.
u8 unk_x2a;
u8 unk_x2b;
u32 flags; ///< Bitmask 0x4: unknown.
u8 unk_x30;
u8 unk_x31[0x17];
} SwkbdAppearArg;
typedef struct {
u32 unk_x0;
u16 size; ///< Size of this struct.
u8 unk_x6;
u8 unk_x7;
u64 flags;
SwkbdInitializeArg initArg; ///< Flags bitmask 0x1.
float volume; ///< Flags bitmask 0x2.
s32 cursorPos; ///< Flags bitmask 0x10.
SwkbdAppearArg appearArg;
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 unk_x45f[3];
u8 keytopAsFloating; ///< Flags bitmask 0x200.
u8 footerScalable; ///< Flags bitmask 0x100.
u8 alphaEnabledInInputMode; ///< Flags bitmask 0x100.
u8 inputModeFadeType; ///< Flags bitmask 0x100.
u8 disableTouch; ///< Flags bitmask 0x200.
u8 disableHardwareKeyboard; ///< Flags bitmask 0x800.
u8 unk_x468[5];
u8 unk_x46d;
u8 unk_x46e;
u8 unk_x46f;
float keytopScaleX; ///< Flags bitmask 0x200.
float keytopScaleY; ///< Flags bitmask 0x200.
float keytopTranslateX; ///< Flags bitmask 0x200.
float keytopTranslateY; ///< Flags bitmask 0x200.
float keytopBgAlpha; ///< Flags bitmask 0x100.
float footerBgAlpha; ///< Flags bitmask 0x100.
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 triggerFlag; ///< [6.0.0+] Enables using the trigger field when set.
u8 trigger; ///< [6.0.0+] Trigger
u8 pad_x49f;
} SwkbdInlineCalcArg;
/// Struct data for SwkbdInline Interactive reply storage ChangedString*, at the end following the string.
typedef struct {
u32 stringLen; ///< String length in characters, without NUL-terminator.
s32 dicStartCursorPos; ///< Starting cursorPos for the current dictionary word in the current text string. -1 for none.
s32 dicEndCursorPos; ///< Ending cursorPos for the current dictionary word in the current text string. -1 for none.
s32 cursorPos; ///< Cursor position.
} SwkbdChangedStringArg;
/// Struct data for SwkbdInline Interactive reply storage MovedCursor*, at the end following the string.
typedef struct {
u32 stringLen; ///< String length in characters, without NUL-terminator.
s32 cursorPos; ///< Cursor position.
} SwkbdMovedCursorArg;
/// Struct data for SwkbdInline Interactive reply storage MovedTab*, at the end following the string.
typedef struct {
u32 unk_x0;
u32 unk_x4;
} SwkbdMovedTabArg;
/// Struct data for SwkbdInline Interactive reply storage DecidedEnter*, at the end following the string.
typedef struct {
u32 stringLen; ///< String length in characters, without NUL-terminator.
} SwkbdDecidedEnterArg;
/// This callback is used by \ref swkbdInlineUpdate when handling ChangedString* replies (text changed by the user or by \ref swkbdInlineSetInputText).
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdChangedStringCb)(const char* str, SwkbdChangedStringArg* arg);
/// This callback is used by \ref swkbdInlineUpdate when handling ChangedString*V2 replies (text changed by the user or by \ref swkbdInlineSetInputText).
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdChangedStringV2Cb)(const char* str, SwkbdChangedStringArg* arg, bool flag);
/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor* replies.
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdMovedCursorCb)(const char* str, SwkbdMovedCursorArg* arg);
/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor*V2 replies.
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdMovedCursorV2Cb)(const char* str, SwkbdMovedCursorArg* arg, bool flag);
/// This callback is used by \ref swkbdInlineUpdate when handling MovedTab* replies.
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdMovedTabCb)(const char* str, SwkbdMovedTabArg* arg);
/// This callback is used by \ref swkbdInlineUpdate when handling DecidedEnter* replies (when the final text was submitted via the button).
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdDecidedEnterCb)(const char* str, SwkbdDecidedEnterArg* arg);
/// InlineKeyboard
typedef struct {
u32 version;
AppletHolder holder;
SwkbdInlineCalcArg calcArg;
bool directionalButtonAssignFlag;
SwkbdState state;
bool dicCustomInitialized;
bool customizedDictionariesInitialized;
AppletStorage dicStorage;
bool wordInfoInitialized;
AppletStorage wordInfoStorage;
u8* interactive_tmpbuf;
size_t interactive_tmpbuf_size;
char* interactive_strbuf;
size_t interactive_strbuf_size;
VoidFn finishedInitializeCb;
VoidFn decidedCancelCb;
SwkbdChangedStringCb changedStringCb;
SwkbdChangedStringV2Cb changedStringV2Cb;
SwkbdMovedCursorCb movedCursorCb;
SwkbdMovedCursorV2Cb movedCursorV2Cb;
SwkbdMovedTabCb movedTabCb;
SwkbdDecidedEnterCb decidedEnterCb;
VoidFn releasedUserWordInfoCb;
} SwkbdInline;
u8 unk_x0[0x64];
} SwkbdDictWord;
/**
* @brief Creates a SwkbdConfig struct.
@ -357,7 +109,7 @@ void swkbdClose(SwkbdConfig* c);
/**
* @brief Clears the args in the SwkbdConfig struct and initializes it with the Default Preset.
* @note Do not use this before \ref swkbdCreate.
* @note Uses the following: swkbdConfigSetType() with \ref SwkbdType_QWERTY, swkbdConfigSetInitialCursorPos() with value 1, swkbdConfigSetReturnButtonFlag() with value 1, and swkbdConfigSetBlurBackground() with value 1. Pre-5.0.0: swkbdConfigSetTextDrawType() with \ref SwkbdTextDrawType_Box.
* @note Sets the following fields: type = \ref SwkbdType_QWERTY, initialCursorPos = 1, returnButtonFlag = 1, blurBackground = 1. Pre-5.0.0: textDrawType = SwkbdTextDrawType_Box.
* @param c SwkbdConfig struct.
*/
void swkbdConfigMakePresetDefault(SwkbdConfig* c);
@ -365,7 +117,7 @@ void swkbdConfigMakePresetDefault(SwkbdConfig* c);
/**
* @brief Clears the args in the SwkbdConfig struct and initializes it with the Password Preset.
* @note Do not use this before \ref swkbdCreate.
* @note Uses the following: swkbdConfigSetType() with \ref SwkbdType_QWERTY, swkbdConfigSetInitialCursorPos() with value 1, swkbdConfigSetPasswordFlag() with value 1, and swkbdConfigSetBlurBackground() with value 1.
* @note Sets the following fields: type = \ref SwkbdType_QWERTY, initialCursorPos = 1, passwordFlag = 1, blurBackground = 1.
* @param c SwkbdConfig struct.
*/
void swkbdConfigMakePresetPassword(SwkbdConfig* c);
@ -373,7 +125,7 @@ void swkbdConfigMakePresetPassword(SwkbdConfig* c);
/**
* @brief Clears the args in the SwkbdConfig struct and initializes it with the UserName Preset.
* @note Do not use this before \ref swkbdCreate.
* @note Uses the following: swkbdConfigSetType() with \ref SwkbdType_Normal, swkbdConfigSetKeySetDisableBitmask() with SwkbdKeyDisableBitmask_UserName, swkbdConfigSetInitialCursorPos() with value 1, and swkbdConfigSetBlurBackground() with value 1.
* @note Sets the following fields: type = \ref SwkbdType_Normal, keySetDisableBitmask = SwkbdKeyDisableBitmask_UserName, initialCursorPos = 1, blurBackground = 1.
* @param c SwkbdConfig struct.
*/
void swkbdConfigMakePresetUserName(SwkbdConfig* c);
@ -381,7 +133,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, swkbdConfigSetStringLenMin() with value 1, and swkbdConfigSetTextDrawType() with SwkbdTextDrawType_DownloadCode. Uses swkbdConfigSetTextGrouping() for [0-2] with: 0x3, 0x7, and 0xb.
* @note Sets the following fields: type = \ref SwkbdType_Normal (\ref SwkbdType_QWERTY on 5.0.0+), keySetDisableBitmask = SwkbdKeyDisableBitmask_DownloadCode, initialCursorPos = 1, blurBackground = 1. 5.0.0+: stringLenMax = 16, stringLenMaxExt = 1, textDrawType = SwkbdTextDrawType_DownloadCode. unk_x3e0[0-2] = 0x3, 0x7, and 0xb.
* @param c SwkbdConfig struct.
*/
void swkbdConfigMakePresetDownloadCode(SwkbdConfig* c);
@ -409,7 +161,7 @@ void swkbdConfigSetRightOptionalSymbolKey(SwkbdConfig* c, const char* str);
/**
* @brief Sets the Header text. The default is "".
* @note See SwkbdArgCommon::stringLenMax.
* @note See \ref SwkbdArgV0 stringLenMax.
* @param c SwkbdConfig struct.
* @param str UTF-8 input string.
*/
@ -417,7 +169,7 @@ void swkbdConfigSetHeaderText(SwkbdConfig* c, const char* str);
/**
* @brief Sets the Sub text. The default is "".
* @note See SwkbdArgCommon::stringLenMax.
* @note See \ref SwkbdArgV0 stringLenMax.
* @param c SwkbdConfig struct.
* @param str UTF-8 input string.
*/
@ -446,14 +198,6 @@ void swkbdConfigSetInitialText(SwkbdConfig* c, const char* str);
*/
void swkbdConfigSetDictionary(SwkbdConfig* c, const SwkbdDictWord *input, s32 entries);
/**
* @brief Sets the CustomizedDictionaries.
* @note Only available on [6.0.0+].
* @param c SwkbdConfig struct.
* @param dic Input \ref SwkbdCustomizedDictionarySet
*/
Result swkbdConfigSetCustomizedDictionaries(SwkbdConfig* c, const SwkbdCustomizedDictionarySet *dic);
/**
* @brief Sets the TextCheck callback.
* @param c SwkbdConfig struct.
@ -461,122 +205,6 @@ Result swkbdConfigSetCustomizedDictionaries(SwkbdConfig* c, const SwkbdCustomize
*/
void swkbdConfigSetTextCheckCallback(SwkbdConfig* c, SwkbdTextCheckCb cb);
/**
* @brief Sets SwkbdArgCommon::SwkbdType.
* @param c SwkbdConfig struct.
* @param type \ref SwkbdType
*/
static inline void swkbdConfigSetType(SwkbdConfig* c, SwkbdType type) {
c->arg.arg.arg.type = type;
}
/**
* @brief Sets SwkbdArgCommon::dicFlag.
* @param c SwkbdConfig struct.
* @param flag Flag
*/
static inline void swkbdConfigSetDicFlag(SwkbdConfig* c, u8 flag) {
c->arg.arg.arg.dicFlag = flag;
}
/**
* @brief Sets SwkbdArgCommon::keySetDisableBitmask.
* @param c SwkbdConfig struct.
* @param keySetDisableBitmask keySetDisableBitmask
*/
static inline void swkbdConfigSetKeySetDisableBitmask(SwkbdConfig* c, u32 keySetDisableBitmask) {
c->arg.arg.arg.keySetDisableBitmask = keySetDisableBitmask;
}
/**
* @brief Sets SwkbdArgCommon::initialCursorPos.
* @param c SwkbdConfig struct.
* @param initialCursorPos initialCursorPos
*/
static inline void swkbdConfigSetInitialCursorPos(SwkbdConfig* c, u32 initialCursorPos) {
c->arg.arg.arg.initialCursorPos = initialCursorPos;
}
/**
* @brief Sets SwkbdArgCommon::stringLenMax.
* @param c SwkbdConfig struct.
* @param stringLenMax stringLenMax
*/
static inline void swkbdConfigSetStringLenMax(SwkbdConfig* c, u32 stringLenMax) {
c->arg.arg.arg.stringLenMax = stringLenMax;
}
/**
* @brief Sets SwkbdArgCommon::stringLenMin.
* @param c SwkbdConfig struct.
* @param stringLenMin stringLenMin
*/
static inline void swkbdConfigSetStringLenMin(SwkbdConfig* c, u32 stringLenMin) {
c->arg.arg.arg.stringLenMin = stringLenMin;
}
/**
* @brief Sets SwkbdArgCommon::passwordFlag.
* @param c SwkbdConfig struct.
* @param flag Flag
*/
static inline void swkbdConfigSetPasswordFlag(SwkbdConfig* c, u32 flag) {
c->arg.arg.arg.passwordFlag = flag;
}
/**
* @brief Sets SwkbdArgCommon::textDrawType.
* @param c SwkbdConfig struct.
* @param textDrawType \ref SwkbdTextDrawType
*/
static inline void swkbdConfigSetTextDrawType(SwkbdConfig* c, SwkbdTextDrawType textDrawType) {
c->arg.arg.arg.textDrawType = textDrawType;
}
/**
* @brief Sets SwkbdArgCommon::returnButtonFlag.
* @param c SwkbdConfig struct.
* @param flag Flag
*/
static inline void swkbdConfigSetReturnButtonFlag(SwkbdConfig* c, u16 flag) {
c->arg.arg.arg.returnButtonFlag = flag;
}
/**
* @brief Sets SwkbdArgCommon::blurBackground.
* @param c SwkbdConfig struct.
* @param blurBackground blurBackground
*/
static inline void swkbdConfigSetBlurBackground(SwkbdConfig* c, u8 blurBackground) {
c->arg.arg.arg.blurBackground = blurBackground;
}
/**
* @brief Sets SwkbdArgV7::textGrouping.
* @param index Array index.
* @param value Value to write.
*/
static inline void swkbdConfigSetTextGrouping(SwkbdConfig* c, u32 index, u32 value) {
if (index >= sizeof(c->arg.textGrouping)/sizeof(u32)) return;
c->arg.textGrouping[index] = value;
}
/**
* @brief Sets SwkbdConfig::unkFlag, default is 0. Copied to SwkbdArgVB::unkFlag with [8.0.0+].
* @param flag Flag
*/
static inline void swkbdConfigSetUnkFlag(SwkbdConfig* c, u8 flag) {
c->unkFlag = flag;
}
/**
* @brief Sets SwkbdConfig::trigger, default is 0. Copied to SwkbdArgVB::trigger with [8.0.0+].
* @param trigger Trigger
*/
static inline void swkbdConfigSetTrigger(SwkbdConfig* c, u8 trigger) {
c->trigger = trigger;
}
/**
* @brief Launch swkbd with the specified config. This will return once swkbd is finished running.
* @note The string buffer is also used for the buffer passed to the \ref SwkbdTextCheckCb, when it's set. Hence, in that case this buffer should be large enough to handle TextCheck string input/output. The size passed to the callback is the same size passed here, -1.
@ -586,442 +214,3 @@ static inline void swkbdConfigSetTrigger(SwkbdConfig* c, u8 trigger) {
*/
Result swkbdShow(SwkbdConfig* c, char* out_string, size_t out_string_size);
/**
* @brief Creates a SwkbdInline object. Only available on [2.0.0+].
* @note This is essentially an asynchronous version of the regular swkbd.
* @note This calls \ref swkbdInlineSetUtf8Mode internally with flag=true.
* @param s SwkbdInline object.
*/
Result swkbdInlineCreate(SwkbdInline* s);
/**
* @brief Closes a SwkbdInline object. If the applet is running, this will tell the applet to exit, then wait for the applet to exit + applet exit handling.
* @param s SwkbdInline object.
*/
Result swkbdInlineClose(SwkbdInline* s);
/**
* @brief Does setup for \ref SwkbdInitializeArg and launches the applet with the SwkbdInline object.
* @note The initArg is cleared, and on [5.0.0+] unk_x5 is set to 1.
* @param s SwkbdInline object.
*/
Result swkbdInlineLaunch(SwkbdInline* s);
/**
* @brief Same as \ref swkbdInlineLaunch, except mode and unk_x5 for \ref SwkbdInitializeArg are set to the input params.
* @param s SwkbdInline object.
* @param mode Value for SwkbdInitializeArg::mode.
* @param unk_x5 Value for SwkbdInitializeArg::unk_x5.
*/
Result swkbdInlineLaunchForLibraryApplet(SwkbdInline* s, u8 mode, u8 unk_x5);
/**
* @brief GetWindowSize
* @param[out] width Output width.
* @param[out] height Output height.
*/
NX_CONSTEXPR void swkbdInlineGetWindowSize(s32 *width, s32 *height) {
*width = 1280;
*height = 720;
}
/**
* @brief GetImageMemoryRequirement
* @note Wrapper for \ref viGetIndirectLayerImageRequiredMemoryInfo.
* @param[out] out_size Output size.
* @param[out] out_alignment Output alignment.
*/
Result swkbdInlineGetImageMemoryRequirement(u64 *out_size, u64 *out_alignment);
/**
* @brief GetImage
* @note Only available with ::SwkbdInlineMode_UserDisplay.
* @note For width/height, see \ref swkbdInlineGetWindowSize.
* @param s SwkbdInline object.
* @param[out] buffer Output RGBA8 image buffer, this must use the alignment from \ref swkbdInlineGetImageMemoryRequirement.
* @param[in] size Output buffer size, this must match the size from \ref swkbdInlineGetImageMemoryRequirement.
* @param[out] data_available Whether data is available.
*/
Result swkbdInlineGetImage(SwkbdInline* s, void* buffer, u64 size, bool *data_available);
/**
* @brief Gets the image max height, relative to the bottom of the screen.
* @param s SwkbdInline object.
*/
s32 swkbdInlineGetMaxHeight(SwkbdInline* s);
/**
* @brief Gets the MiniaturizedHeight, relative to the bottom of the screen.
* @param s SwkbdInline object.
*/
s32 swkbdInlineGetMiniaturizedHeight(SwkbdInline* s);
/**
* @brief GetTouchRectangles. Returns number of valid Rects: 1 for only keytop, 2 for keytop/footer.
* @param s SwkbdInline object.
* @param[out] keytop \ref SwkbdRect for keytop. Optional, can be NULL.
* @param[out] footer \ref SwkbdRect for footer. Optional, can be NULL.
*/
s32 swkbdInlineGetTouchRectangles(SwkbdInline* s, SwkbdRect *keytop, SwkbdRect *footer);
/**
* @brief Gets whether the input x/y are within the output from \ref swkbdInlineGetTouchRectangles.
* @param s SwkbdInline object.
* @param[out] x X
* @param[out] y Y
*/
bool swkbdInlineIsUsedTouchPointByKeyboard(SwkbdInline* s, s32 x, s32 y);
/**
* @brief Handles updating SwkbdInline state, this should be called periodically.
* @note Handles applet exit if needed, and also sends the \ref SwkbdInlineCalcArg to the applet if needed. Hence, this should be called at some point after writing to \ref SwkbdInlineCalcArg.
* @note Handles applet Interactive storage output when needed.
* @param s SwkbdInline object.
* @param out_state Optional output \ref SwkbdState.
*/
Result swkbdInlineUpdate(SwkbdInline* s, SwkbdState* out_state);
/**
* @brief Sets the FinishedInitialize callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
* @param cb Callback
*/
void swkbdInlineSetFinishedInitializeCallback(SwkbdInline* s, VoidFn cb);
/**
* @brief Sets the DecidedCancel callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
* @param cb Callback
*/
void swkbdInlineSetDecidedCancelCallback(SwkbdInline* s, VoidFn cb);
/**
* @brief Sets the ChangedString callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note This clears the callback set by \ref swkbdInlineSetChangedStringV2Callback.
* @note This should be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdChangedStringCb Callback
*/
void swkbdInlineSetChangedStringCallback(SwkbdInline* s, SwkbdChangedStringCb cb);
/**
* @brief Sets the ChangedStringV2 callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note Only available with [8.0.0+].
* @note This must be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdChangedStringV2Cb Callback
*/
void swkbdInlineSetChangedStringV2Callback(SwkbdInline* s, SwkbdChangedStringV2Cb cb);
/**
* @brief Sets the MovedCursor callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note This clears the callback set by \ref swkbdInlineSetMovedCursorV2Callback.
* @note This should be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdMovedCursorCb Callback
*/
void swkbdInlineSetMovedCursorCallback(SwkbdInline* s, SwkbdMovedCursorCb cb);
/**
* @brief Sets the MovedCursorV2 callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note Only available with [8.0.0+].
* @note This must be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdMovedCursorV2Cb Callback
*/
void swkbdInlineSetMovedCursorV2Callback(SwkbdInline* s, SwkbdMovedCursorV2Cb cb);
/**
* @brief Sets the MovedTab callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
* @param cb \ref SwkbdMovedTabCb Callback
*/
void swkbdInlineSetMovedTabCallback(SwkbdInline* s, SwkbdMovedTabCb cb);
/**
* @brief Sets the DecidedEnter callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
* @param cb \ref SwkbdDecidedEnterCb Callback
*/
void swkbdInlineSetDecidedEnterCallback(SwkbdInline* s, SwkbdDecidedEnterCb cb);
/**
* @brief Sets the ReleasedUserWordInfo callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
* @param cb Callback
*/
void swkbdInlineSetReleasedUserWordInfoCallback(SwkbdInline* s, VoidFn cb);
/**
* @brief Appear the kbd and set \ref SwkbdAppearArg.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Wrapper for \ref swkbdInlineAppearEx, with trigger=0.
* @param s SwkbdInline object.
* @param arg Input SwkbdAppearArg.
*/
void swkbdInlineAppear(SwkbdInline* s, const SwkbdAppearArg* arg);
/**
* @brief Appear the kbd and set \ref SwkbdAppearArg.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param arg Input SwkbdAppearArg.
* @param trigger Trigger, default is 0. Requires [6.0.0+], on eariler versions this will always use value 0 internally.
*/
void swkbdInlineAppearEx(SwkbdInline* s, const SwkbdAppearArg* arg, u8 trigger);
/**
* @brief Disappear the kbd.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
*/
void swkbdInlineDisappear(SwkbdInline* s);
/**
* @brief Creates a \ref SwkbdAppearArg which can then be passed to \ref swkbdInlineAppear. arg is initialized with the defaults, with type being set to the input type.
* @param arg Output \ref SwkbdAppearArg.
* @param type \ref SwkbdType type
*/
void swkbdInlineMakeAppearArg(SwkbdAppearArg* arg, SwkbdType type);
/**
* @brief Sets okButtonText for the specified SwkbdAppearArg, which was previously initialized with \ref swkbdInlineMakeAppearArg.
* @param arg \ref SwkbdAppearArg
* @param str Input UTF-8 string for the Ok button text, this can be empty/NULL to use the default.
*/
void swkbdInlineAppearArgSetOkButtonText(SwkbdAppearArg* arg, const char* str);
/**
* @brief Sets the LeftButtonText, for \ref SwkbdType_NumPad. The default is "". Equivalent to \ref swkbdConfigSetLeftOptionalSymbolKey.
* @param arg \ref SwkbdAppearArg, previously initialized by \ref swkbdInlineMakeAppearArg.
* @param str UTF-8 input string.
*/
void swkbdInlineAppearArgSetLeftButtonText(SwkbdAppearArg* arg, const char* str);
/**
* @brief Sets the RightButtonText, for \ref SwkbdType_NumPad. The default is "". Equivalent to \ref swkbdConfigSetRightOptionalSymbolKey.
* @param arg \ref SwkbdAppearArg, previously initialized by \ref swkbdInlineMakeAppearArg.
* @param str UTF-8 input string.
*/
void swkbdInlineAppearArgSetRightButtonText(SwkbdAppearArg* arg, const char* str);
/**
* @brief Sets the stringLenMax for the specified SwkbdAppearArg, which was previously initialized with \ref swkbdInlineMakeAppearArg.
* @param arg \ref SwkbdAppearArg
* @param stringLenMax Max string length
*/
static inline void swkbdInlineAppearArgSetStringLenMax(SwkbdAppearArg* arg, s32 stringLenMax) {
arg->stringLenMax = stringLenMax;
}
/**
* @brief Sets the stringLenMin for the specified SwkbdAppearArg, which was previously initialized with \ref swkbdInlineMakeAppearArg.
* @param arg \ref SwkbdAppearArg
* @param stringLenMin Min string length
*/
static inline void swkbdInlineAppearArgSetStringLenMin(SwkbdAppearArg* arg, s32 stringLenMin) {
arg->stringLenMin = stringLenMin;
}
/**
* @brief Sets the audio volume.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param volume Volume
*/
void swkbdInlineSetVolume(SwkbdInline* s, float volume);
/**
* @brief Sets the current input text string. Overrides the entire user input string if the user previously entered any text.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note This will not affect the cursor position, see \ref swkbdInlineSetCursorPos for that.
* @param s SwkbdInline object.
* @param str UTF-8 input string.
*/
void swkbdInlineSetInputText(SwkbdInline* s, const char* str);
/**
* @brief Sets the cursor character position in the string.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param pos Position
*/
void swkbdInlineSetCursorPos(SwkbdInline* s, s32 pos);
/**
* @brief Sets the UserWordInfo.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized. Can't be used if this was already used previously.
* @note The specified buffer must not be used after this, until \ref swkbdInlineClose is used.
* @note \ref swkbdInlineUpdate must be called at some point afterwards.
* @note If input==NULL or total_entries==0, this will just call \ref swkbdInlineUnsetUserWordInfo internally.
* @param s SwkbdInline object.
* @param input Input data.
* @param entries Total entries in the buffer.
*/
Result swkbdInlineSetUserWordInfo(SwkbdInline* s, const SwkbdDictWord *input, s32 entries);
/**
* @brief Request UnsetUserWordInfo.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized.
* @param s SwkbdInline object.
*/
Result swkbdInlineUnsetUserWordInfo(SwkbdInline* s);
/**
* @brief Sets the utf8Mode.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Automatically used internally by \ref swkbdInlineCreate.
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetUtf8Mode(SwkbdInline* s, bool flag);
/**
* @brief Sets the CustomizeDic.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized. Can't be used if this or \ref swkbdInlineSetCustomizedDictionaries was already used previously.
* @note The specified buffer must not be used after this, until \ref swkbdInlineClose is used. However, it will also become available once \ref swkbdInlineUpdate handles SwkbdReplyType_UnsetCustomizeDic internally.
* @param s SwkbdInline object.
* @param buffer 0x1000-byte aligned buffer.
* @param size 0x1000-byte aligned buffer size.
* @param info Input \ref SwkbdCustomizeDicInfo
*/
Result swkbdInlineSetCustomizeDic(SwkbdInline* s, void* buffer, size_t size, SwkbdCustomizeDicInfo *info);
/**
* @brief Request UnsetCustomizeDic.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized.
* @param s SwkbdInline object.
*/
void swkbdInlineUnsetCustomizeDic(SwkbdInline* s);
/**
* @brief Sets the CustomizedDictionaries.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized. Can't be used if this or \ref swkbdInlineSetCustomizeDic was already used previously.
* @note The specified buffer in dic must not be used after this, until \ref swkbdInlineClose is used. However, it will also become available once \ref swkbdInlineUpdate handles SwkbdReplyType_UnsetCustomizedDictionaries internally.
* @note Only available on [6.0.0+].
* @param s SwkbdInline object.
* @param dic Input \ref SwkbdCustomizedDictionarySet
*/
Result swkbdInlineSetCustomizedDictionaries(SwkbdInline* s, const SwkbdCustomizedDictionarySet *dic);
/**
* @brief Request UnsetCustomizedDictionaries.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized.
* @note Only available on [6.0.0+].
* @param s SwkbdInline object.
*/
Result swkbdInlineUnsetCustomizedDictionaries(SwkbdInline* s);
/**
* @brief Sets InputModeFadeType.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param type Type
*/
void swkbdInlineSetInputModeFadeType(SwkbdInline* s, u8 type);
/**
* @brief Sets AlphaEnabledInInputMode.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetAlphaEnabledInInputMode(SwkbdInline* s, bool flag);
/**
* @brief Sets KeytopBgAlpha.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param alpha Alpha, clamped to range 0.0f..1.0f.
*/
void swkbdInlineSetKeytopBgAlpha(SwkbdInline* s, float alpha);
/**
* @brief Sets FooterBgAlpha.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param alpha Alpha, clamped to range 0.0f..1.0f.
*/
void swkbdInlineSetFooterBgAlpha(SwkbdInline* s, float alpha);
/**
* @brief Sets gfx scaling. Configures KeytopScale* and BalloonScale based on the input value.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note The BalloonScale is not updated when \ref SwkbdState is above ::SwkbdState_Initialized.
* @param s SwkbdInline object.
* @param scale Scale
*/
void swkbdInlineSetKeytopScale(SwkbdInline* s, float scale);
/**
* @brief Sets gfx translation for the displayed swkbd image position.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param x X
* @param y Y
*/
void swkbdInlineSetKeytopTranslate(SwkbdInline* s, float x, float y);
/**
* @brief Sets KeytopAsFloating.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Not available when \ref SwkbdState is above ::SwkbdState_Initialized.
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetKeytopAsFloating(SwkbdInline* s, bool flag);
/**
* @brief Sets FooterScalable.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetFooterScalable(SwkbdInline* s, bool flag);
/**
* @brief Sets whether touch is enabled. The default is enabled.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetTouchFlag(SwkbdInline* s, bool flag);
/**
* @brief Sets whether Hardware-keyboard is enabled. The default is enabled.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetHardwareKeyboardFlag(SwkbdInline* s, bool flag);
/**
* @brief Sets whether DirectionalButtonAssign is enabled. The default is disabled.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Only available on [4.0.0+].
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetDirectionalButtonAssignFlag(SwkbdInline* s, bool flag);
/**
* @brief Sets whether the specified SeGroup (sound effect) is enabled. The default is enabled.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect. If called again with a different seGroup, \ref swkbdInlineUpdate must be called prior to calling this again.
* @note Only available on [5.0.0+].
* @param s SwkbdInline object.
* @param seGroup SeGroup
* @param flag Flag
*/
void swkbdInlineSetSeGroup(SwkbdInline* s, u8 seGroup, bool flag);
/**
* @brief Sets whether the backspace button is enabled. The default is enabled.
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
* @note Only available on [5.0.0+].
* @param s SwkbdInline object.
* @param flag Flag
*/
void swkbdInlineSetBackspaceFlag(SwkbdInline* s, bool flag);

View File

@ -1,862 +0,0 @@
/**
* @file web.h
* @brief Wrapper for using the web LibraryApplets. See also: https://switchbrew.org/wiki/Internet_Browser
* @author p-sam, yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/applet.h"
#include "../services/caps.h"
#include "../services/acc.h"
#include "../kernel/mutex.h"
/// This indicates the type of web-applet.
typedef enum {
WebShimKind_Shop = 1,
WebShimKind_Login = 2,
WebShimKind_Offline = 3,
WebShimKind_Share = 4,
WebShimKind_Web = 5,
WebShimKind_Wifi = 6,
WebShimKind_Lobby = 7,
} WebShimKind;
/// ExitReason
typedef enum {
WebExitReason_ExitButton = 0x0, ///< User pressed the X button to exit.
WebExitReason_BackButton = 0x1, ///< User pressed the B button to exit, on the initial page.
WebExitReason_Requested = 0x2, ///< The applet exited since \ref webConfigRequestExit was used.
WebExitReason_LastUrl = 0x3, ///< The applet exited due to LastUrl handling, see \ref webReplyGetLastUrl.
WebExitReason_ErrorDialog = 0x7, ///< The applet exited after displaying an error dialog.
WebExitReason_UnknownE = 0xE, ///< Unknown
} WebExitReason;
/// Button values for \ref webConfigSetBootFooterButtonVisible.
typedef enum {
WebFooterButtonId_None = 0, ///< None, for empty \ref WebBootFooterButtonEntry. Invalid for \ref webConfigSetBootFooterButtonVisible input.
WebFooterButtonId_Type1 = 1, ///< Unknown button Id 1.
WebFooterButtonId_Type2 = 2, ///< Unknown button Id 2.
WebFooterButtonId_Type3 = 3, ///< Unknown button Id 3.
WebFooterButtonId_Type4 = 4, ///< Unknown button Id 4.
WebFooterButtonId_Type5 = 5, ///< Unknown button Id 5.
WebFooterButtonId_Type6 = 6, ///< Unknown button Id 6.
WebFooterButtonId_Max, ///< Values starting with this are invalid.
} WebFooterButtonId;
/// WebSessionBootMode
typedef enum {
WebSessionBootMode_AllForeground = 0, ///< AllForeground. This is the default.
WebSessionBootMode_AllForegroundInitiallyHidden = 1, ///< AllForegroundInitiallyHidden
} WebSessionBootMode;
/// WebSessionSendMessageKind
typedef enum {
WebSessionSendMessageKind_BrowserEngineContent = 0x0, ///< BrowserEngine Content
WebSessionSendMessageKind_SystemMessageAppear = 0x100, ///< SystemMessage Appear
WebSessionSendMessageKind_Ack = 0x1000, ///< Ack
} WebSessionSendMessageKind;
/// WebSessionReceiveMessageKind
typedef enum {
WebSessionReceiveMessageKind_BrowserEngineContent = 0x0, ///< BrowserEngine Content
WebSessionReceiveMessageKind_AckBrowserEngine = 0x1000, ///< Ack BrowserEngine
WebSessionReceiveMessageKind_AckSystemMessage = 0x1001, ///< Ack SystemMessage
} WebSessionReceiveMessageKind;
/// Struct for the WebWifi applet input storage.
typedef struct {
u32 unk_x0; ///< Official sw sets this to 0 with appletStorageWrite, separately from the rest of the config struct.
char conntest_url[0x100]; ///< Connection-test URL.
char initial_url[0x400]; ///< Initial URL navigated to by the applet.
Uuid uuid; ///< NIFM Network UUID. Only used by the applet when conntest_url is set.
u32 rev; ///< Input value for nifm cmd SetRequirementByRevision. Only used by the applet when conntest_url is set.
} WebWifiPageArg;
/// Struct for the WebWifi applet output storage.
typedef struct {
u32 unk_x0; ///< Unknown.
Result res; ///< Result
} WebWifiReturnValue;
/// Config for WebWifi.
typedef struct {
WebWifiPageArg arg; ///< Arg data.
} WebWifiConfig;
/// TLV storage, starts with \ref WebArgHeader followed by \ref WebArgTLV entries.
typedef struct {
u8 data[0x2000]; ///< Raw TLV data storage.
} WebCommonTLVStorage;
/// Common struct for the applet output storage, for non-TLV-storage.
typedef struct {
WebExitReason exitReason; ///< ExitReason
u32 pad; ///< Padding
char lastUrl[0x1000]; ///< LastUrl string
u64 lastUrlSize; ///< Size of LastUrl, including NUL-terminator.
} NX_PACKED WebCommonReturnValue;
/// Header struct at offset 0 in the web Arg storage (non-webWifi).
typedef struct {
u16 total_entries; ///< Total \ref WebArgTLV entries following this struct.
u16 pad; ///< Padding
WebShimKind shimKind; ///< ShimKind
} NX_PACKED WebArgHeader;
/// Web TLV used in the web Arg storage.
typedef struct {
u16 type; ///< Type of this arg.
u16 size; ///< Size of the arg data following this struct.
u8 pad[4]; ///< Padding
} NX_PACKED WebArgTLV;
/// Config struct for web applets, non-WebWifi.
typedef struct {
WebCommonTLVStorage arg; ///< TLV storage.
AppletId appletid; ///< AppletId
u32 version; ///< CommonArgs applet version.
AppletHolder holder; ///< AppletHolder
} WebCommonConfig;
/// Common container struct for applets' reply data, from the output storage.
typedef struct {
bool type; ///< Type of reply: false = ret, true = storage.
WebShimKind shimKind; ///< ShimKind
WebCommonReturnValue ret; ///< Reply data for reply=false.
WebCommonTLVStorage storage; ///< Reply data for reply=true.
} WebCommonReply;
/// Entry data for ::WebArgType_BootFooterButton.
typedef struct {
WebFooterButtonId id;
u8 visible;
u16 unk_x5;
u8 unk_x7;
} NX_PACKED WebBootFooterButtonEntry;
/// StorageHandleQueue
typedef struct {
s32 read_pos;
s32 write_pos;
s32 max_storages;
bool is_full;
AppletStorage storages[0x10];
} WebSessionStorageHandleQueue;
/// WebSession
typedef struct {
Mutex mutex;
WebCommonConfig *config;
struct {
u32 count;
u32 cur_size;
} queue[2];
WebSessionStorageHandleQueue storage_queue;
} WebSession;
/// SessionMessageHeader
typedef struct {
u32 kind; ///< Message Kind (\ref WebSessionSendMessageKind / \ref WebSessionReceiveMessageKind)
u32 size; ///< Data size following the header.
u8 reserved[0x8]; ///< Unused
} WebSessionMessageHeader;
/// Types for \ref WebArgTLV, input storage.
typedef enum {
WebArgType_Url = 0x1, ///< [1.0.0+] String, size 0xC00. Initial URL.
WebArgType_CallbackUrl = 0x3, ///< [1.0.0+] String, size 0x400.
WebArgType_CallbackableUrl = 0x4, ///< [1.0.0+] String, size 0x400.
WebArgType_ApplicationId = 0x5, ///< [1.0.0+] Offline-applet, u64 ApplicationId
WebArgType_DocumentPath = 0x6, ///< [1.0.0+] Offline-applet, string with size 0xC00.
WebArgType_DocumentKind = 0x7, ///< [1.0.0+] Offline-applet, u32 enum \WebDocumentKind.
WebArgType_SystemDataId = 0x8, ///< [1.0.0+] Offline-applet, u64 SystemDataId
WebArgType_ShareStartPage = 0x9, ///< [1.0.0+] u32 enum \WebShareStartPage
WebArgType_Whitelist = 0xA, ///< [1.0.0+] String, size 0x1000.
WebArgType_NewsFlag = 0xB, ///< [1.0.0+] u8 bool
WebArgType_UnknownC = 0xC, ///< [1.0.0+] u8
WebArgType_UnknownD = 0xD, ///< [1.0.0+] u8
WebArgType_Uid = 0xE, ///< [1.0.0+] \ref AccountUid, controls which user-specific savedata to mount.
WebArgType_AlbumEntry0 = 0xF, ///< [1.0.0+] Share-applet caps AlbumEntry, entry 0.
WebArgType_ScreenShot = 0x10, ///< [1.0.0+] u8 bool
WebArgType_EcClientCert = 0x11, ///< [1.0.0+] u8 bool
WebArgType_Unknown12 = 0x12, ///< [1.0.0+] u8
WebArgType_PlayReport = 0x13, ///< [1.0.0+] u8 bool
WebArgType_Unknown14 = 0x14, ///< [1.0.0+] u8
WebArgType_Unknown15 = 0x15, ///< [1.0.0+] u8
WebArgType_BootDisplayKind = 0x17, ///< [1.0.0+] u32 enum \ref WebBootDisplayKind
WebArgType_BackgroundKind = 0x18, ///< [1.0.0+] u32 enum \ref WebBackgroundKind
WebArgType_Footer = 0x19, ///< [1.0.0+] u8 bool
WebArgType_Pointer = 0x1A, ///< [1.0.0+] u8 bool
WebArgType_LeftStickMode = 0x1B, ///< [1.0.0+] u32 enum \ref WebLeftStickMode
WebArgType_KeyRepeatFrame0 = 0x1C, ///< [1.0.0+] s32 KeyRepeatFrame, first param
WebArgType_KeyRepeatFrame1 = 0x1D, ///< [1.0.0+] s32 KeyRepeatFrame, second param
WebArgType_BootAsMediaPlayerInverted = 0x1E, ///< [1.0.0+] u8 bool. With News on [3.0.0+] this is set after BootAsMediaPlayer with the value inverted.
WebArgType_DisplayUrlKind = 0x1F, ///< [1.0.0+] u8 bool, DisplayUrlKind (value = (input_enumval==0x1)).
WebArgType_BootAsMediaPlayer = 0x21, ///< [2.0.0+] u8 bool
WebArgType_ShopJump = 0x22, ///< [2.0.0+] u8 bool
WebArgType_MediaPlayerUserGestureRestriction = 0x23, ///< [2.0.0-5.1.0] u8 bool
WebArgType_MediaAutoPlay = 0x23, ///< [6.0.0+] u8 bool
WebArgType_LobbyParameter = 0x24, ///< [2.0.0+] String, size 0x100.
WebArgType_ApplicationAlbumEntry = 0x26, ///< [3.0.0+] Share-applet caps ApplicationAlbumEntry
WebArgType_JsExtension = 0x27, ///< [3.0.0+] u8 bool
WebArgType_AdditionalCommentText = 0x28, ///< [4.0.0+] String, size 0x100. Share-applet AdditionalCommentText.
WebArgType_TouchEnabledOnContents = 0x29, ///< [4.0.0+] u8 bool
WebArgType_UserAgentAdditionalString = 0x2A, ///< [4.0.0+] String, size 0x80.
WebArgType_AdditionalMediaData0 = 0x2B, ///< [4.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 0. If the user-input size is less than 0x10, the remaining data used for the TLV is cleared.
WebArgType_MediaPlayerAutoClose = 0x2C, ///< [4.0.0+] u8 bool
WebArgType_PageCache = 0x2D, ///< [4.0.0+] u8 bool
WebArgType_WebAudio = 0x2E, ///< [4.0.0+] u8 bool
WebArgType_2F = 0x2F, ///< [5.0.0+] u8
WebArgType_YouTubeVideoFlag = 0x31, ///< [5.0.0+] u8 bool Indicates that the built-in whitelist for YouTubeVideo should be used.
WebArgType_FooterFixedKind = 0x32, ///< [5.0.0+] u32 enum \ref WebFooterFixedKind
WebArgType_PageFade = 0x33, ///< [5.0.0+] u8 bool
WebArgType_MediaCreatorApplicationRatingAge = 0x34, ///< [5.0.0+] Share-applet 0x20-byte s8 array, MediaCreatorApplicationRatingAge.
WebArgType_BootLoadingIcon = 0x35, ///< [5.0.0+] u8 bool
WebArgType_PageScrollIndicator = 0x36, ///< [5.0.0+] u8 bool
WebArgType_MediaPlayerSpeedControl = 0x37, ///< [6.0.0+] u8 bool
WebArgType_AlbumEntry1 = 0x38, ///< [6.0.0+] Share-applet caps AlbumEntry, entry 1.
WebArgType_AlbumEntry2 = 0x39, ///< [6.0.0+] Share-applet caps AlbumEntry, entry 2.
WebArgType_AlbumEntry3 = 0x3A, ///< [6.0.0+] Share-applet caps AlbumEntry, entry 3.
WebArgType_AdditionalMediaData1 = 0x3B, ///< [6.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 1.
WebArgType_AdditionalMediaData2 = 0x3C, ///< [6.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 2.
WebArgType_AdditionalMediaData3 = 0x3D, ///< [6.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 3.
WebArgType_BootFooterButton = 0x3E, ///< [6.0.0+] Array of \ref WebBootFooterButtonEntry with 0x10 entries.
WebArgType_OverrideWebAudioVolume = 0x3F, ///< [6.0.0+] float
WebArgType_OverrideMediaAudioVolume = 0x40, ///< [6.0.0+] float
WebArgType_SessionBootMode = 0x41, ///< [7.0.0+] u32 enum \ref WebSessionBootMode
WebArgType_SessionFlag = 0x42, ///< [7.0.0+] u8 bool, enables using WebSession when set.
WebArgType_MediaPlayerUi = 0x43, ///< [8.0.0+] u8 bool
WebArgType_TransferMemory = 0x44, ///< [11.0.0+] u8 bool
} WebArgType;
/// Types for \ref WebArgTLV, output storage.
typedef enum {
WebReplyType_ExitReason = 0x1, ///< [3.0.0+] u32 ExitReason
WebReplyType_LastUrl = 0x2, ///< [3.0.0+] string
WebReplyType_LastUrlSize = 0x3, ///< [3.0.0+] u64
WebReplyType_SharePostResult = 0x4, ///< [3.0.0+] u32 SharePostResult
WebReplyType_PostServiceName = 0x5, ///< [3.0.0+] string
WebReplyType_PostServiceNameSize = 0x6, ///< [3.0.0+] u64
WebReplyType_PostId = 0x7, ///< [3.0.0+] string
WebReplyType_PostIdSize = 0x8, ///< [3.0.0+] u64
WebReplyType_MediaPlayerAutoClosedByCompletion = 0x9, ///< [8.0.0+] u8 bool
} WebReplyType;
/// This controls the kind of content to mount with Offline-applet.
typedef enum {
WebDocumentKind_OfflineHtmlPage = 0x1, ///< Use the HtmlDocument NCA content from the application.
WebDocumentKind_ApplicationLegalInformation = 0x2, ///< Use the LegalInformation NCA content from the application.
WebDocumentKind_SystemDataPage = 0x3, ///< Use the Data NCA content from the specified SystemData, see also: https://switchbrew.org/wiki/Title_list#System_Data_Archives
} WebDocumentKind;
/// This controls the initial page for ShareApplet, used by \ref webShareCreate.
typedef enum {
WebShareStartPage_Default = 0, ///< The default "/" page.
WebShareStartPage_Settings = 1, ///< The "/settings/" page.
} WebShareStartPage;
/// Kind values for \ref webConfigSetBootDisplayKind. Controls the background color while displaying the loading screen during applet boot. Also controls the BackgroundKind when value is non-zero.
typedef enum {
WebBootDisplayKind_Default = 0, ///< Default. BackgroundKind is controlled by \ref WebBackgroundKind.
WebBootDisplayKind_White = 1, ///< White background. Used by \ref webOfflineCreate for docKind ::WebDocumentKind_ApplicationLegalInformation/::WebDocumentKind_SystemDataPage.
WebBootDisplayKind_Black = 2, ///< Black background.
WebBootDisplayKind_Unknown3 = 3, ///< Unknown. Used by \ref webShareCreate.
WebBootDisplayKind_Unknown4 = 4, ///< Unknown. Used by \ref webLobbyCreate.
} WebBootDisplayKind;
/// Kind values for \ref webConfigSetBackgroundKind. Controls the background color while displaying the loading screen during applet boot. Only used when \ref WebBootDisplayKind is ::WebBootDisplayKind_Default. If the applet was not launched by an Application, the applet will only use WebBackgroundKind_Default.
typedef enum {
WebBackgroundKind_Default = 0, ///< Default. Same as ::WebBootDisplayKind_White/::WebBootDisplayKind_Black, determined via ::WebArgType_BootAsMediaPlayer.
WebBackgroundKind_Unknown1 = 1, ///< Unknown. Same as ::WebBootDisplayKind_Unknown3.
WebBackgroundKind_Unknown2 = 2, ///< Unknown. Same as ::WebBootDisplayKind_Unknown4. Used by \ref webLobbyCreate.
} WebBackgroundKind;
/// Mode values for \ref webConfigSetLeftStickMode. Controls the initial mode, this can be toggled by the user via the pressing the left-stick button. If the Pointer flag is set to false (\ref webConfigSetPointer), only ::WebLeftStickMode_Cursor will be used and mode toggle by the user is disabled (input value ignored).
typedef enum {
WebLeftStickMode_Pointer = 0, ///< The user can directly control the pointer via the left-stick.
WebLeftStickMode_Cursor = 1, ///< The user can only select elements on the page via the left-stick.
} WebLeftStickMode;
/// Kind values for \ref webConfigSetFooterFixedKind. Controls UI footer display behaviour.
typedef enum {
WebFooterFixedKind_Default = 0, ///< Default. Footer is hidden while scrolling.
WebFooterFixedKind_Always = 1, ///< Footer is always displayed regardless of scrolling.
WebFooterFixedKind_Hidden = 2, ///< Footer is hidden regardless of scrolling.
} WebFooterFixedKind;
/**
* @brief Creates the config for WifiWebAuthApplet. This is the captive portal applet.
* @param config WebWifiConfig object.
* @param conntest_url URL used for the connection-test requests. When empty/NULL the applet will test the connection with nifm and throw an error on failure.
* @param initial_url Initial URL navigated to by the applet.
* @param uuid NIFM Network UUID, for nifm cmd SetNetworkProfileId. Value 0 can be used. Only used by the applet when conntest_url is set.
* @param rev Input value for nifm cmd SetRequirementByRevision. Value 0 can be used. Only used by the applet when conntest_url is set.
*/
void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char* initial_url, Uuid uuid, u32 rev);
/**
* @brief Launches WifiWebAuthApplet with the specified config and waits for it to exit.
* @param config WebWifiConfig object.
* @param out Optional output applet reply data, can be NULL.
*/
Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out);
/**
* @brief Creates the config for WebApplet. This applet uses an URL whitelist loaded from the user-process host Application, which is only loaded when running under an Application.
* @note Sets ::WebArgType_UnknownD, and ::WebArgType_Unknown12 on pre-3.0.0, to value 1.
* @param config WebCommonConfig object.
* @param url Initial URL navigated to by the applet.
*/
Result webPageCreate(WebCommonConfig* config, const char* url);
/**
* @brief Creates the config for WebApplet. This is based on \ref webPageCreate, for News. Hence other functions referencing \ref webPageCreate also apply to this.
* @note The domain from the input URL is automatically whitelisted, in addition to any already loaded whitelist.
* @note Sets ::WebArgType_UnknownD to value 1, and sets ::WebArgType_NewsFlag to true. Also uses \ref webConfigSetEcClientCert and \ref webConfigSetShopJump with flag=true.
* @param config WebCommonConfig object.
* @param url Initial URL navigated to by the applet.
*/
Result webNewsCreate(WebCommonConfig* config, const char* url);
/**
* @brief Creates the config for WebApplet. This is based on \ref webPageCreate, for YouTubeVideo. Hence other functions referencing \ref webPageCreate also apply to this. This uses a whitelist which essentially only allows youtube embed/ URLs (without mounting content from the host Application).
* @note This is only available on [5.0.0+].
* @note Sets ::WebArgType_UnknownD to value 1, and sets ::WebArgType_YouTubeVideoFlag to true. Also uses \ref webConfigSetBootAsMediaPlayer with flag=true.
* @param config WebCommonConfig object.
* @param url Initial URL navigated to by the applet.
*/
Result webYouTubeVideoCreate(WebCommonConfig* config, const char* url);
/**
* @brief Creates the config for Offline-applet. This applet uses data loaded from content.
* @note Uses \ref webConfigSetLeftStickMode with ::WebLeftStickMode_Cursor and sets ::WebArgType_BootAsMediaPlayerInverted to false. Uses \ref webConfigSetPointer with flag = docKind == ::WebDocumentKind_OfflineHtmlPage.
* @note For docKind ::WebDocumentKind_ApplicationLegalInformation / ::WebDocumentKind_SystemDataPage, uses \ref webConfigSetFooter with flag=true and \ref webConfigSetBackgroundKind with ::WebBackgroundKind_Default.
* @note For docKind ::WebDocumentKind_SystemDataPage, uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_White.
* @note Sets ::WebArgType_Unknown14/::WebArgType_Unknown15 to value 1. With docKind ::WebDocumentKind_ApplicationLegalInformation, uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_White.
* @note Sets ::WebArgType_UnknownC to value 1.
* @note With docKind ::WebDocumentKind_ApplicationLegalInformation, uses \ref webConfigSetEcClientCert with flag=true.
* @note With docKind ::WebDocumentKind_OfflineHtmlPage on pre-3.0.0, sets ::WebArgType_Unknown12 to value 1.
* @note Lastly, sets the TLVs as needed for the input params.
* @param config WebCommonConfig object.
* @param docKind \ref WebDocumentKind
* @param id Id to load the content from. With docKind = ::WebDocumentKind_OfflineHtmlPage, id=0 should be used to specify the user-process application (non-zero is ignored with this docKind).
* @param docPath Initial document path in RomFS, without the leading '/'. For ::WebDocumentKind_OfflineHtmlPage, this is relative to "html-document/" in RomFS. For the other docKind values, this is relative to "/" in RomFS. This path must contain ".htdocs/".
*/
Result webOfflineCreate(WebCommonConfig* config, WebDocumentKind docKind, u64 id, const char* docPath);
/**
* @brief Creates the config for ShareApplet. This applet is for social media posting/settings.
* @note If a non-zero uid isn't set with \ref webConfigSetUid prior to using \ref webConfigShow, the applet will launch the profile-selector applet to select an account.
* @note An error will be displayed if neither \ref webConfigSetAlbumEntry, nor \ref webConfigSetApplicationAlbumEntry, nor \ref webConfigAddAlbumEntryAndMediaData are used prior to using \ref webConfigShow, with ::WebShareStartPage_Default.
* @note Uses \ref webConfigSetLeftStickMode with ::WebLeftStickMode_Cursor, \ref webConfigSetUid with uid=0, \ref webConfigSetDisplayUrlKind with kind=true, and sets ::WebArgType_Unknown14/::WebArgType_Unknown15 to value 1. Uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_Unknown3.
* @param config WebCommonConfig object.
* @param page \ref WebShareStartPage
*/
Result webShareCreate(WebCommonConfig* config, WebShareStartPage page);
/**
* @brief Creates the config for LobbyApplet. This applet is for "Nintendo Switch Online Lounge".
* @note Only available on [2.0.0+].
* @note If a non-zero uid isn't set with \ref webConfigSetUid prior to using \ref webConfigShow, the applet will launch the profile-selector applet to select an account.
* @note Uses \ref webConfigSetLeftStickMode with ::WebLeftStickMode_Cursor, \ref webConfigSetPointer with flag=false on [3.0.0+], \ref webConfigSetUid with uid=0, and sets ::WebArgType_Unknown14/::WebArgType_Unknown15 to value 1. Uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_Unknown4, \ref webConfigSetBackgroundKind with ::WebBackgroundKind_Unknown2, and sets ::WebArgType_BootAsMediaPlayerInverted to false.
* @param config WebCommonConfig object.
*/
Result webLobbyCreate(WebCommonConfig* config);
/**
* @brief Sets the CallbackUrl. See also \ref webReplyGetLastUrl.
* @note With Offline-applet for LastUrl handling, it compares the domain with "localhost" instead.
* @note Only available with config created by \ref webPageCreate or with Share-applet.
* @param config WebCommonConfig object.
* @param url URL
*/
Result webConfigSetCallbackUrl(WebCommonConfig* config, const char* url);
/**
* @brief Sets the CallbackableUrl.
* @note Only available with config created by \ref webPageCreate.
* @param config WebCommonConfig object.
* @param url URL
*/
Result webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url);
/**
* @brief Sets the whitelist.
* @note Only available with config created by \ref webPageCreate.
* @note If the whitelist isn't formatted properly, the applet will exit briefly after the applet is launched.
* @param config WebCommonConfig object.
* @param whitelist Whitelist string, each line is a regex for each whitelisted URL.
*/
Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist);
/**
* @brief Sets the account uid. Controls which user-specific savedata to mount.
* @note Only available with config created by \ref webPageCreate, \ref webLobbyCreate, or with Share-applet.
* @note Used automatically by \ref webShareCreate and \ref webLobbyCreate with uid=0.
* @param config WebCommonConfig object.
* @param uid \ref AccountUid
*/
Result webConfigSetUid(WebCommonConfig* config, AccountUid uid);
/**
* @brief Sets the Share CapsAlbumEntry.
* @note Only available with config created by \ref webShareCreate.
* @param config WebCommonConfig object.
* @param entry \ref CapsAlbumEntry
*/
Result webConfigSetAlbumEntry(WebCommonConfig* config, const CapsAlbumEntry *entry);
/**
* @brief Sets the ScreenShot flag, which controls whether screen-shot capture is allowed.
* @note Only available with config created by \ref webPageCreate.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetScreenShot(WebCommonConfig* config, bool flag);
/**
* @brief Sets the EcClientCert flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate.
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @note Used automatically by \ref webNewsCreate with flag=true.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether PlayReport is enabled.
* @note Only available with config created by \ref webOfflineCreate.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPlayReport(WebCommonConfig* config, bool flag);
/**
* @brief Sets the BootDisplayKind.
* @note Only available with config created by \ref webOfflineCreate, \ref webShareCreate, \ref webPageCreate, or \ref webLobbyCreate..
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @note Used automatically by \ref webShareCreate with kind=::WebBootDisplayKind_Unknown3.
* @note Used automatically by \ref webLobbyCreate with kind=::WebBootDisplayKind_Unknown4.
* @param config WebCommonConfig object.
* @param kind \ref WebBootDisplayKind
*/
Result webConfigSetBootDisplayKind(WebCommonConfig* config, WebBootDisplayKind kind);
/**
* @brief Sets the BackgroundKind.
* @note Only available with config created by \ref webOfflineCreate, \ref webPageCreate, or \ref webLobbyCreate.
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @note Used automatically by \ref webLobbyCreate with kind=2.
* @param config WebCommonConfig object.
* @param kind \ref WebBackgroundKind
*/
Result webConfigSetBackgroundKind(WebCommonConfig* config, WebBackgroundKind kind);
/**
* @brief Sets the whether the UI footer is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate.
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetFooter(WebCommonConfig* config, bool flag);
/**
* @brief Sets the whether the Pointer is enabled. See also \ref WebLeftStickMode.
* @note Only available with config created by \ref webOfflineCreate, \ref webPageCreate, or \ref webLobbyCreate.
* @note Used automatically by \ref webOfflineCreate.
* @note Used automatically by \ref webLobbyCreate with flag=false on [3.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPointer(WebCommonConfig* config, bool flag);
/**
* @brief Sets the LeftStickMode.
* @note Only available with config created by \ref webOfflineCreate, \ref webShareCreate, \ref webPageCreate, or \ref webLobbyCreate.
* @note Used automatically by \ref webOfflineCreate, \ref webShareCreate, and \ref webLobbyCreate with ::WebLeftStickMode_Cursor.
* @param config WebCommonConfig object.
* @param mode Mode, different enums for Web and Offline.
*/
Result webConfigSetLeftStickMode(WebCommonConfig* config, WebLeftStickMode mode);
/**
* @brief Sets the KeyRepeatFrame.
* @note Only available with config created by \ref webOfflineCreate.
* @param config WebCommonConfig object.
* @param inval0 First input param.
* @param inval1 Second input param.
*/
Result webConfigSetKeyRepeatFrame(WebCommonConfig* config, s32 inval0, s32 inval1);
/**
* @brief Sets the DisplayUrlKind.
* @note Only available with config created by \ref webShareCreate or \ref webPageCreate.
* @param config WebCommonConfig object.
* @note Used automatically by \ref webShareCreate with kind=true.
* @param kind Kind
*/
Result webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind);
/**
* @brief Sets the BootAsMediaPlayer flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [2.0.0+].
* @note With config created by \ref webNewsCreate on [3.0.0+], this also sets ::WebArgType_BootAsMediaPlayerInverted to !flag.
* @param config WebCommonConfig object.
* @param flag Flag. true = BootAsMediaPlayer, false = BootAsWebPage.
*/
Result webConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag);
/**
* @brief Sets the ShopJump flag.
* @note Only available with config created by \ref webPageCreate on [2.0.0+].
* @note Used automatically by \ref webNewsCreate with flag=true.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetShopJump(WebCommonConfig* config, bool flag);
/**
* @brief Sets the MediaPlayerUserGestureRestriction flag.
* @note Only available with config created by \ref webPageCreate on [2.0.0-5.1.0].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerUserGestureRestriction(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether MediaAutoPlay is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaAutoPlay(WebCommonConfig* config, bool flag);
/**
* @brief Sets the LobbyParameter.
* @note Only available with config created by \ref webLobbyCreate.
* @param config WebCommonConfig object.
* @param str String
*/
Result webConfigSetLobbyParameter(WebCommonConfig* config, const char* str);
/**
* @brief Sets the Share CapsApplicationAlbumEntry.
* @note Only available with config created by \ref webShareCreate on [3.0.0+].
* @param config WebCommonConfig object.
* @param entry \ref CapsApplicationAlbumEntry, see also capssu.h.
*/
Result webConfigSetApplicationAlbumEntry(WebCommonConfig* config, CapsApplicationAlbumEntry *entry);
/**
* @brief Sets whether JsExtension is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [3.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetJsExtension(WebCommonConfig* config, bool flag);
/**
* @brief Sets the Share AdditionalCommentText.
* @note Only available with config created by \ref webShareCreate on [4.0.0+].
* @param config WebCommonConfig object.
* @param str String
*/
Result webConfigSetAdditionalCommentText(WebCommonConfig* config, const char* str);
/**
* @brief Sets the TouchEnabledOnContents flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetTouchEnabledOnContents(WebCommonConfig* config, bool flag);
/**
* @brief Sets the UserAgentAdditionalString. " " followed by this string are appended to the normal User-Agent string.
* @note Only available with config created by \ref webPageCreate on [4.0.0+].
* @param config WebCommonConfig object.
* @param str String
*/
Result webConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char* str);
/**
* @brief Sets the Share AdditionalMediaData.
* @note Only available with config created by \ref webShareCreate on [4.0.0+].
* @param config WebCommonConfig object.
* @param data Input data
* @param size Size of the input data, max size is 0x10.
*/
Result webConfigSetAdditionalMediaData(WebCommonConfig* config, const u8* data, size_t size);
/**
* @brief Sets the MediaPlayerAutoClose flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerAutoClose(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether PageCache is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPageCache(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether WebAudio is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetWebAudio(WebCommonConfig* config, bool flag);
/**
* @brief Sets the FooterFixedKind.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [5.0.0+].
* @param config WebCommonConfig object.
* @param kind \ref WebFooterFixedKind
*/
Result webConfigSetFooterFixedKind(WebCommonConfig* config, WebFooterFixedKind kind);
/**
* @brief Sets the PageFade flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [5.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPageFade(WebCommonConfig* config, bool flag);
/**
* @brief Sets the Share MediaCreatorApplicationRatingAge.
* @note Only available with config created by \ref webShareCreate on [5.0.0+].
* @param config WebCommonConfig object.
* @param data 0x20-byte input data
*/
Result webConfigSetMediaCreatorApplicationRatingAge(WebCommonConfig* config, const s8 *data);
/**
* @brief Sets the BootLoadingIcon flag.
* @note Only available with config created by \ref webOfflineCreate on [5.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetBootLoadingIcon(WebCommonConfig* config, bool flag);
/**
* @brief Sets the PageScrollIndicator flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [5.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether MediaPlayerSpeedControl is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerSpeedControl(WebCommonConfig* config, bool flag);
/**
* @brief Adds a pair of Share CapsAlbumEntry + optionally AdditionalMediaData. This can be used up to 4 times, for setting multiple pairs.
* @note Only available with config created by \ref webShareCreate on [6.0.0+].
* @param config WebCommonConfig object.
* @param entry \ref CapsAlbumEntry
* @param data Input data for AdditionalMediaData. Optional, can be NULL.
* @param size Size of the input data, max size is 0x10. Optional, can be 0.
*/
Result webConfigAddAlbumEntryAndMediaData(WebCommonConfig* config, const CapsAlbumEntry *entry, const u8* data, size_t size);
/**
* @brief Sets whether the specified BootFooterButton is visible.
* @note Only available with config created by \ref webOfflineCreate on [6.0.0+].
* @param config WebCommonConfig object.
* @param button \ref WebFooterButtonId
* @param visible Visible flag.
*/
Result webConfigSetBootFooterButtonVisible(WebCommonConfig* config, WebFooterButtonId button, bool visible);
/**
* @brief Sets OverrideWebAudioVolume.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param value Value
*/
Result webConfigSetOverrideWebAudioVolume(WebCommonConfig* config, float value);
/**
* @brief Sets OverrideMediaAudioVolume.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param value Value
*/
Result webConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value);
/**
* @brief Sets \ref WebSessionBootMode.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [7.0.0+].
* @param config WebCommonConfig object.
* @param mode \ref WebSessionBootMode
*/
Result webConfigSetBootMode(WebCommonConfig* config, WebSessionBootMode mode);
/**
* @brief Sets whether MediaPlayerUi is enabled.
* @note Only available with config created by \ref webOfflineCreate on [8.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerUi(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether TransferMemory is enabled.
* @note Only available with config created by \ref webPageCreate on [11.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetTransferMemory(WebCommonConfig* config, bool flag);
/**
* @brief Launches the {web applet} with the specified config and waits for it to exit.
* @param config WebCommonConfig object.
* @param out Optional output applet reply data, can be NULL.
*/
Result webConfigShow(WebCommonConfig* config, WebCommonReply *out);
/**
* @brief Request the applet to exit after \ref webConfigShow was used, while the applet is still running. This is for use from another thread.
* @param config WebCommonConfig object.
*/
Result webConfigRequestExit(WebCommonConfig* config);
/**
* @brief Gets the ExitReason from the specified reply.
* @param reply WebCommonReply object.
* @param exitReason Output \ref WebExitReason
*/
Result webReplyGetExitReason(WebCommonReply *reply, WebExitReason *exitReason);
/**
* @brief Gets the LastUrl from the specified reply. When the applet loads a page where the beginning of the URL matches the URL from \ref webConfigSetCallbackUrl, the applet will exit and set LastUrl to that URL (exit doesn't occur when \ref webConfigSetCallbackableUrl was used).
* @note This is only available with ::WebExitReason_LastUrl (string is empty otherwise).
* @note If you want to allocate a string buffer on heap, you can call this with outstr=NULL/outstr_maxsize=0 to get the out_size, then call it again with the allocated buffer.
* @param reply WebCommonReply object.
* @param outstr Output string buffer. If NULL, the string is not loaded.
* @param outstr_maxsize Size of the buffer, including NUL-terminator. If outstr is set, this size must be >1. The size used for the actual string-copy is this size-1, to make sure the output is NUL-terminated (the entire buffer is cleared first).
* @param out_size Output string length including NUL-terminator, for the original input string in the reply loaded from a separate size field.
*/
Result webReplyGetLastUrl(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the SharePostResult from the specified reply.
* @note Only available with reply data from ShareApplet on [3.0.0+].
* @param reply WebCommonReply object.
* @param sharePostResult Output sharePostResult
*/
Result webReplyGetSharePostResult(WebCommonReply *reply, u32 *sharePostResult);
/**
* @brief Gets the PostServiceName from the specified reply.
* @note Only available with reply data from ShareApplet on [3.0.0+].
* @note If you want to allocate a string buffer on heap, you can call this with outstr=NULL/outstr_maxsize=0 to get the out_size, then call it again with the allocated buffer.
* @param reply WebCommonReply object.
* @param outstr Output string buffer. If NULL, the string is not loaded.
* @param outstr_maxsize Size of the buffer, including NUL-terminator. If outstr is set, this size must be >1. The size used for the actual string-copy is this size-1, to make sure the output is NUL-terminated (the entire buffer is cleared first).
* @param out_size Output string length including NUL-terminator, for the original input string in the reply loaded from a separate size field.
*/
Result webReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the PostId from the specified reply.
* @note Only available with reply data from ShareApplet on [3.0.0+].
* @note If you want to allocate a string buffer on heap, you can call this with outstr=NULL/outstr_maxsize=0 to get the out_size, then call it again with the allocated buffer.
* @param reply WebCommonReply object.
* @param outstr Output string buffer. If NULL, the string is not loaded.
* @param outstr_maxsize Size of the buffer, including NUL-terminator. If outstr is set, this size must be >1. The size used for the actual string-copy is this size-1, to make sure the output is NUL-terminated (the entire buffer is cleared first).
* @param out_size Output string length including NUL-terminator, for the original input string in the reply loaded from a separate size field.
*/
Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the MediaPlayerAutoClosedByCompletion flag from the specified reply.
* @note Only available with reply data from Web on [8.0.0+].
* @param reply WebCommonReply object.
* @param flag Output flag
*/
Result webReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag);
/**
* @brief Creates a \ref WebSession object.
* @param s \ref WebSession
* @param config WebCommonConfig object.
*/
void webSessionCreate(WebSession *s, WebCommonConfig* config);
/**
* @brief Closes a \ref WebSession object.
* @param s \ref WebSession
*/
void webSessionClose(WebSession *s);
/**
* @brief Launches the applet for \ref WebSession.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [7.0.0+].
* @note Do not use \ref webConfigShow when using WebSession.
* @param s \ref WebSession
* @param[out] out_event Output Event with autoclear=false, from \ref appletHolderGetExitEvent. Optional, can be NULL.
*/
Result webSessionStart(WebSession *s, Event **out_event);
/**
* @brief Waits for the applet to exit.
* @note This must be used before \ref webSessionClose, when \ref webSessionStart was used successfully.
* @param s \ref WebSession
* @param out Optional output applet reply data, can be NULL.
*/
Result webSessionWaitForExit(WebSession *s, WebCommonReply *out);
/**
* @brief Request the applet to exit.
* @note Use this instead of \ref webConfigRequestExit, when using WebSession.
* @param s \ref WebSession
*/
Result webSessionRequestExit(WebSession *s);
/**
* @brief Request the applet to Appear, this is only needed with ::WebSessionBootMode_AllForegroundInitiallyHidden.
* @note This should not be used before \ref webSessionStart.
* @param s \ref WebSession
* @param[out] flag Whether the message was sent successfully.
*/
Result webSessionAppear(WebSession *s, bool *flag);
/**
* @brief TrySendContentMessage
* @note This should not be used before \ref webSessionStart.
* @note The JS-side for this is only available when JsExtension is enabled via \ref webConfigSetJsExtension.
* @note The JS-side may ignore this if it's sent too soon after the applet launches.
* @param s \ref WebSession
* @param[in] content Input content NUL-terminated string.
* @param[in] size Size of content.
* @param[out] flag Whether the message was sent successfully.
*/
Result webSessionTrySendContentMessage(WebSession *s, const char *content, u32 size, bool *flag);
/**
* @brief TryReceiveContentMessage
* @note This should not be used before \ref webSessionStart.
* @note The JS-side for this is only available when JsExtension is enabled via \ref webConfigSetJsExtension.
* @param s \ref WebSession
* @param[out] content Output content string, always NUL-terminated.
* @param[in] size Max size of content.
* @param[out] out_size Original content size, prior to being clamped to the specified size param.
* @param[out] flag Whether the message was received successfully.
*/
Result webSessionTryReceiveContentMessage(WebSession *s, char *content, u64 size, u64 *out_size, bool *flag);

View File

@ -0,0 +1,18 @@
#pragma once
#include "../types.h"
static inline u32 atomicIncrement32(u32* p) {
return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST);
}
static inline u32 atomicDecrement32(u32* p) {
return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST);
}
static inline u64 atomicIncrement64(u64* p) {
return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST);
}
static inline u64 atomicDecrement64(u64* p) {
return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST);
}

View File

@ -8,7 +8,6 @@
#include "../types.h"
/// PcmFormat
typedef enum {
PcmFormat_Invalid = 0,
PcmFormat_Int8 = 1,
@ -19,7 +18,6 @@ typedef enum {
PcmFormat_Adpcm = 6,
} PcmFormat;
/// AudioDeviceName
typedef struct {
char name[0x100];
} AudioDeviceName;

View File

@ -62,7 +62,6 @@ struct AudioDriverWaveBuf {
bool audrvVoiceInit(AudioDriver* d, int id, int num_channels, PcmFormat format, int sample_rate);
void audrvVoiceDrop(AudioDriver* d, int id);
void audrvVoiceStop(AudioDriver* d, int id);
bool audrvVoiceIsPaused(AudioDriver* d, int id);
bool audrvVoiceIsPlaying(AudioDriver* d, int id);
bool audrvVoiceAddWaveBuf(AudioDriver* d, int id, AudioDriverWaveBuf* wavebuf);
u32 audrvVoiceGetWaveBufSeq(AudioDriver* d, int id);

View File

@ -1,74 +0,0 @@
/**
* @file aes.h
* @brief Hardware accelerated AES-ECB implementation.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#ifndef AES_BLOCK_SIZE
#define AES_BLOCK_SIZE 0x10
#endif
#ifndef AES_128_KEY_SIZE
#define AES_128_KEY_SIZE 0x10
#endif
#ifndef AES_128_U32_PER_KEY
#define AES_128_U32_PER_KEY (AES_128_KEY_SIZE / sizeof(u32))
#endif
#ifndef AES_128_NUM_ROUNDS
#define AES_128_NUM_ROUNDS 10
#endif
#ifndef AES_192_KEY_SIZE
#define AES_192_KEY_SIZE 0x18
#endif
#ifndef AES_192_U32_PER_KEY
#define AES_192_U32_PER_KEY (AES_192_KEY_SIZE / sizeof(u32))
#endif
#ifndef AES_192_NUM_ROUNDS
#define AES_192_NUM_ROUNDS 12
#endif
#ifndef AES_256_KEY_SIZE
#define AES_256_KEY_SIZE 0x20
#endif
#ifndef AES_256_U32_PER_KEY
#define AES_256_U32_PER_KEY (AES_256_KEY_SIZE / sizeof(u32))
#endif
#ifndef AES_256_NUM_ROUNDS
#define AES_256_NUM_ROUNDS 14
#endif
/// Context for AES-128 operations.
typedef struct {
u8 round_keys[AES_128_NUM_ROUNDS+1][AES_BLOCK_SIZE];
} Aes128Context;
/// Context for AES-192 operations.
typedef struct {
u8 round_keys[AES_192_NUM_ROUNDS+1][AES_BLOCK_SIZE];
} Aes192Context;
/// Context for AES-256 operations.
typedef struct {
u8 round_keys[AES_256_NUM_ROUNDS+1][AES_BLOCK_SIZE];
} Aes256Context;
/// Initialize a 128-bit AES context.
void aes128ContextCreate(Aes128Context *out, const void *key, bool is_encryptor);
/// Encrypt using an AES context (Requires is_encryptor when initializing)
void aes128EncryptBlock(const Aes128Context *ctx, void *dst, const void *src);
/// Decrypt using an AES context (Requires !is_encryptor when initializing)
void aes128DecryptBlock(const Aes128Context *ctx, void *dst, const void *src);
/// Initialize a 192-bit AES context.
void aes192ContextCreate(Aes192Context *out, const void *key, bool is_encryptor);
/// Encrypt using an AES context (Requires is_encryptor when initializing)
void aes192EncryptBlock(const Aes192Context *ctx, void *dst, const void *src);
/// Decrypt using an AES context (Requires !is_encryptor when initializing)
void aes192DecryptBlock(const Aes192Context *ctx, void *dst, const void *src);
/// Initialize a 256-bit AES context.
void aes256ContextCreate(Aes256Context *out, const void *key, bool is_encryptor);
/// Encrypt using an AES context (Requires is_encryptor when initializing)
void aes256EncryptBlock(const Aes256Context *ctx, void *dst, const void *src);
/// Decrypt using an AES context (Requires !is_encryptor when initializing)
void aes256DecryptBlock(const Aes256Context *ctx, void *dst, const void *src);

View File

@ -1,49 +0,0 @@
/**
* @file aes_cbc.h
* @brief Hardware accelerated AES-CBC implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 CBC.
typedef struct {
Aes128Context aes_ctx;
u8 iv[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes128CbcContext;
/// Context for AES-192 CBC.
typedef struct {
Aes192Context aes_ctx;
u8 iv[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes192CbcContext;
/// Context for AES-256 CBC.
typedef struct {
Aes256Context aes_ctx;
u8 iv[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes256CbcContext;
/// 128-bit CBC API.
void aes128CbcContextCreate(Aes128CbcContext *out, const void *key, const void *iv, bool is_encryptor);
void aes128CbcContextResetIv(Aes128CbcContext *ctx, const void *iv);
size_t aes128CbcEncrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size);
size_t aes128CbcDecrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size);
/// 192-bit CBC API.
void aes192CbcContextCreate(Aes192CbcContext *out, const void *key, const void *iv, bool is_encryptor);
void aes192CbcContextResetIv(Aes192CbcContext *ctx, const void *iv);
size_t aes192CbcEncrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size);
size_t aes192CbcDecrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size);
/// 256-bit CBC API.
void aes256CbcContextCreate(Aes256CbcContext *out, const void *key, const void *iv, bool is_encryptor);
void aes256CbcContextResetIv(Aes256CbcContext *ctx, const void *iv);
size_t aes256CbcEncrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size);
size_t aes256CbcDecrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size);

View File

@ -1,46 +0,0 @@
/**
* @file aes_ctr.h
* @brief Hardware accelerated AES-CTR implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 CTR.
typedef struct {
Aes128Context aes_ctx;
u8 ctr[AES_BLOCK_SIZE];
u8 enc_ctr_buffer[AES_BLOCK_SIZE];
size_t buffer_offset;
} Aes128CtrContext;
/// Context for AES-192 CTR.
typedef struct {
Aes192Context aes_ctx;
u8 ctr[AES_BLOCK_SIZE];
u8 enc_ctr_buffer[AES_BLOCK_SIZE];
size_t buffer_offset;
} Aes192CtrContext;
/// Context for AES-256 CTR.
typedef struct {
Aes256Context aes_ctx;
u8 ctr[AES_BLOCK_SIZE];
u8 enc_ctr_buffer[AES_BLOCK_SIZE];
size_t buffer_offset;
} Aes256CtrContext;
/// 128-bit CTR API.
void aes128CtrContextCreate(Aes128CtrContext *out, const void *key, const void *ctr);
void aes128CtrContextResetCtr(Aes128CtrContext *ctx, const void *ctr);
void aes128CtrCrypt(Aes128CtrContext *ctx, void *dst, const void *src, size_t size);
/// 192-bit CTR API.
void aes192CtrContextCreate(Aes192CtrContext *out, const void *key, const void *ctr);
void aes192CtrContextResetCtr(Aes192CtrContext *ctx, const void *ctr);
void aes192CtrCrypt(Aes192CtrContext *ctx, void *dst, const void *src, size_t size);
/// 256-bit CTR API.
void aes256CtrContextCreate(Aes256CtrContext *out, const void *key, const void *ctr);
void aes256CtrContextResetCtr(Aes256CtrContext *ctx, const void *ctr);
void aes256CtrCrypt(Aes256CtrContext *ctx, void *dst, const void *src, size_t size);

View File

@ -1,55 +0,0 @@
/**
* @file aes_xts.h
* @brief Hardware accelerated AES-XTS implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 XTS.
typedef struct {
Aes128Context aes_ctx;
Aes128Context tweak_ctx;
u8 tweak[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes128XtsContext;
/// Context for AES-192 XTS.
typedef struct {
Aes192Context aes_ctx;
Aes192Context tweak_ctx;
u8 tweak[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes192XtsContext;
/// Context for AES-256 XTS.
typedef struct {
Aes256Context aes_ctx;
Aes256Context tweak_ctx;
u8 tweak[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes256XtsContext;
/// 128-bit XTS API.
void aes128XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
void aes128XtsContextResetTweak(Aes128XtsContext *ctx, const void *tweak);
void aes128XtsContextResetSector(Aes128XtsContext *ctx, uint64_t sector, bool is_nintendo);
size_t aes128XtsEncrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size);
size_t aes128XtsDecrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size);
/// 192-bit XTS API.
void aes192XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
void aes192XtsContextResetTweak(Aes192XtsContext *ctx, const void *tweak);
void aes192XtsContextResetSector(Aes192XtsContext *ctx, uint64_t sector, bool is_nintendo);
size_t aes192XtsEncrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size);
size_t aes192XtsDecrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size);
/// 256-bit XTS API.
void aes256XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
void aes256XtsContextResetTweak(Aes256XtsContext *ctx, const void *tweak);
void aes256XtsContextResetSector(Aes256XtsContext *ctx, uint64_t sector, bool is_nintendo);
size_t aes256XtsEncrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size);
size_t aes256XtsDecrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size);

View File

@ -1,67 +0,0 @@
/**
* @file cmac.h
* @brief Hardware accelerated AES-CMAC implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 CMAC.
typedef struct {
Aes128Context ctx;
u8 subkey[AES_BLOCK_SIZE];
u8 mac[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
bool finalized;
} Aes128CmacContext;
/// Context for AES-192 CMAC.
typedef struct {
Aes192Context ctx;
u8 subkey[AES_BLOCK_SIZE];
u8 mac[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
bool finalized;
} Aes192CmacContext;
/// Context for AES-256 CMAC.
typedef struct {
Aes256Context ctx;
u8 subkey[AES_BLOCK_SIZE];
u8 mac[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
bool finalized;
} Aes256CmacContext;
/// Initialize an AES-128-CMAC context.
void cmacAes128ContextCreate(Aes128CmacContext *out, const void *key);
/// Updates AES-128-CMAC context with data to hash
void cmacAes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void cmacAes128ContextGetMac(Aes128CmacContext *ctx, void *dst);
/// Simple all-in-one AES-128-CMAC calculator.
void cmacAes128CalculateMac(void *dst, const void *key, const void *src, size_t size);
/// Initialize an AES-192-CMAC context.
void cmacAes192ContextCreate(Aes192CmacContext *out, const void *key);
/// Updates AES-192-CMAC context with data to hash
void cmacAes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void cmacAes192ContextGetMac(Aes192CmacContext *ctx, void *dst);
/// Simple all-in-one AES-192-CMAC calculator.
void cmacAes192CalculateMac(void *dst, const void *key, const void *src, size_t size);
/// Initialize an AES-256-CMAC context.
void cmacAes256ContextCreate(Aes256CmacContext *out, const void *key);
/// Updates AES-256-CMAC context with data to hash
void cmacAes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void cmacAes256ContextGetMac(Aes256CmacContext *ctx, void *dst);
/// Simple all-in-one AES-256-CMAC calculator.
void cmacAes256CalculateMac(void *dst, const void *key, const void *src, size_t size);

View File

@ -1,86 +0,0 @@
/**
* @file crc.h
* @brief Hardware accelerated CRC32 implementation.
* @copyright libnx Authors
*/
#pragma once
#include <arm_acle.h>
#include "../types.h"
#define _CRC_ALIGN(sz, insn) \
do { \
if (((uintptr_t)src_u8 & sizeof(sz)) && (u64)len >= sizeof(sz)) { \
crc = __crc32##insn(crc, *((const sz *)src_u8)); \
src_u8 += sizeof(sz); \
len -= sizeof(sz); \
} \
} while (0)
#define _CRC_REMAINDER(sz, insn) \
do { \
if (len & sizeof(sz)) { \
crc = __crc32##insn(crc, *((const sz *)src_u8)); \
src_u8 += sizeof(sz); \
} \
} while (0)
/// Calculate a CRC32 over data using a seed.
/// Can be used to calculate a CRC32 in chunks using an initial seed of zero for the first chunk.
static inline u32 crc32CalculateWithSeed(u32 seed, const void *src, size_t size) {
const u8 *src_u8 = (const u8 *)src;
u32 crc = ~seed;
s64 len = size;
_CRC_ALIGN(u8, b);
_CRC_ALIGN(u16, h);
_CRC_ALIGN(u32, w);
while ((len -= sizeof(u64)) >= 0) {
crc = __crc32d(crc, *((const u64 *)src_u8));
src_u8 += sizeof(u64);
}
_CRC_REMAINDER(u32, w);
_CRC_REMAINDER(u16, h);
_CRC_REMAINDER(u8, b);
return ~crc;
}
/// Calculate a CRC32 over data.
static inline u32 crc32Calculate(const void *src, size_t size) {
return crc32CalculateWithSeed(0, src, size);
}
/// Calculate a CRC32C over data using a seed.
/// Can be used to calculate a CRC32C in chunks using an initial seed of zero for the first chunk.
static inline u32 crc32cCalculateWithSeed(u32 seed, const void *src, size_t size) {
const u8 *src_u8 = (const u8 *)src;
u32 crc = ~seed;
s64 len = size;
_CRC_ALIGN(u8, cb);
_CRC_ALIGN(u16, ch);
_CRC_ALIGN(u32, cw);
while ((len -= sizeof(u64)) >= 0) {
crc = __crc32cd(crc, *((const u64 *)src_u8));
src_u8 += sizeof(u64);
}
_CRC_REMAINDER(u32, cw);
_CRC_REMAINDER(u16, ch);
_CRC_REMAINDER(u8, cb);
return ~crc;
}
/// Calculate a CRC32C over data.
static inline u32 crc32cCalculate(const void *src, size_t size) {
return crc32cCalculateWithSeed(0, src, size);
}
#undef _CRC_REMAINDER
#undef _CRC_ALIGN

View File

@ -1,51 +0,0 @@
/**
* @file hmac.h
* @brief Hardware accelerated HMAC-SHA(1, 256) implementation.
* @copyright libnx Authors
*/
#pragma once
#include "sha1.h"
#include "sha256.h"
/// Context for HMAC-SHA1 operations.
typedef struct {
Sha1Context sha_ctx;
u32 key[SHA1_BLOCK_SIZE / sizeof(u32)];
u32 mac[SHA1_HASH_SIZE / sizeof(u32)];
bool finalized;
} HmacSha1Context;
/// Context for HMAC-SHA256 operations.
typedef struct {
Sha256Context sha_ctx;
u32 key[SHA256_BLOCK_SIZE / sizeof(u32)];
u32 mac[SHA256_HASH_SIZE / sizeof(u32)];
bool finalized;
} HmacSha256Context;
#ifndef HMAC_SHA1_KEY_MAX
#define HMAC_SHA1_KEY_MAX (sizeof(((HmacSha1Context *)NULL)->key))
#endif
#ifndef HMAC_SHA256_KEY_MAX
#define HMAC_SHA256_KEY_MAX (sizeof(((HmacSha256Context *)NULL)->key))
#endif
/// Initialize a HMAC-SHA256 context.
void hmacSha256ContextCreate(HmacSha256Context *out, const void *key, size_t key_size);
/// Updates HMAC-SHA256 context with data to hash
void hmacSha256ContextUpdate(HmacSha256Context *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void hmacSha256ContextGetMac(HmacSha256Context *ctx, void *dst);
/// Simple all-in-one HMAC-SHA256 calculator.
void hmacSha256CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size);
/// Initialize a HMAC-SHA1 context.
void hmacSha1ContextCreate(HmacSha1Context *out, const void *key, size_t key_size);
/// Updates HMAC-SHA1 context with data to hash
void hmacSha1ContextUpdate(HmacSha1Context *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void hmacSha1ContextGetMac(HmacSha1Context *ctx, void *dst);
/// Simple all-in-one HMAC-SHA1 calculator.
void hmacSha1CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size);

View File

@ -1,34 +0,0 @@
/**
* @file sha1.h
* @brief Hardware accelerated SHA1 implementation.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#ifndef SHA1_HASH_SIZE
#define SHA1_HASH_SIZE 0x14
#endif
#ifndef SHA1_BLOCK_SIZE
#define SHA1_BLOCK_SIZE 0x40
#endif
/// Context for SHA1 operations.
typedef struct {
u32 intermediate_hash[SHA1_HASH_SIZE / sizeof(u32)];
u8 buffer[SHA1_BLOCK_SIZE];
u64 bits_consumed;
size_t num_buffered;
bool finalized;
} Sha1Context;
/// Initialize a SHA1 context.
void sha1ContextCreate(Sha1Context *out);
/// Updates SHA1 context with data to hash
void sha1ContextUpdate(Sha1Context *ctx, const void *src, size_t size);
/// Gets the context's output hash, finalizes the context.
void sha1ContextGetHash(Sha1Context *ctx, void *dst);
/// Simple all-in-one SHA1 calculator.
void sha1CalculateHash(void *dst, const void *src, size_t size);

View File

@ -1,35 +0,0 @@
/**
* @file sha256.h
* @brief Hardware accelerated SHA256 implementation.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#ifndef SHA256_HASH_SIZE
#define SHA256_HASH_SIZE 0x20
#endif
#ifndef SHA256_BLOCK_SIZE
#define SHA256_BLOCK_SIZE 0x40
#endif
/// Context for SHA256 operations.
typedef struct {
u32 intermediate_hash[SHA256_HASH_SIZE / sizeof(u32)];
u8 buffer[SHA256_BLOCK_SIZE];
u64 bits_consumed;
size_t num_buffered;
bool finalized;
} Sha256Context;
/// Initialize a SHA256 context.
void sha256ContextCreate(Sha256Context *out);
/// Updates SHA256 context with data to hash
void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size);
/// Gets the context's output hash, finalizes the context.
void sha256ContextGetHash(Sha256Context *ctx, void *dst);
/// Simple all-in-one SHA256 calculator.
void sha256CalculateHash(void *dst, const void *src, size_t size);

View File

@ -1,23 +1,22 @@
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../sf/service.h"
#define BINDER_FIRST_CALL_TRANSACTION 0x1
typedef struct {
bool created;
bool initialized;
s32 id;
size_t dummy;
Service* relay;
bool created : 1;
bool initialized : 1;
bool has_transact_auto : 1;
s32 id;
size_t ipc_buffer_size;
} 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, Service* relay);
Result binderInitSession(Binder* b);
Result binderTransactParcel(
Binder* b, u32 code,

View File

@ -11,7 +11,7 @@ typedef struct {
} BqRect;
typedef struct {
struct { s64 timestamp; } NX_PACKED;
struct { s64 timestamp; } PACKED;
s32 isAutoTimestamp;
BqRect crop;
s32 scalingMode;

View File

@ -0,0 +1,152 @@
/**
* @file gfx.h
* @brief Deprecated graphics API, use \ref NWindow and \ref Framebuffer instead.
* @deprecated Use \ref NWindow and \ref Framebuffer instead.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../nvidia/fence.h"
/// GfxMode set by \ref gfxSetMode. The default is GfxMode_LinearDouble. Note that the text-console (see console.h) sets this to GfxMode_TiledDouble.
/// \deprecated Use \ref framebufferMakeLinear instead.
typedef enum
{
GfxMode_TiledDouble, ///< Double-buffering with raw tiled (block-linear) framebuffer.
GfxMode_LinearDouble ///< Double-buffering with linear framebuffer, which is transferred to the actual framebuffer by \ref gfxFlushBuffers().
} GfxMode;
/**
* @brief Initializes the deprecated graphics subsystem.
* @warning Do not use \ref viInitialize when using this function.
* @deprecated Use \ref nwindowGetDefault and \ref framebufferCreate instead.
*/
__attribute__((deprecated))
Result gfxInitDefault(void);
/**
* @brief Uninitializes the deprecated graphics subsystem.
* @warning Do not use \ref viExit when using this function.
* @deprecated Use \ref framebufferClose instead.
*/
__attribute__((deprecated))
void gfxExit(void);
/**
* @brief Sets the resolution to be used when initializing the deprecated graphics subsystem.
* @param[in] width Horizontal resolution, in pixels.
* @param[in] height Vertical resolution, in pixels.
* @note The default resolution is 720p.
* @note This can only be used before calling \ref gfxInitDefault, this will use \ref fatalSimple otherwise. If the input is 0, the default resolution will be used during \ref gfxInitDefault. This sets the maximum resolution for the framebuffer, used during \ref gfxInitDefault. This is also used as the current resolution when crop isn't set. The width/height are reset to the default when \ref gfxExit is used.
* @note Normally you should only use this when you need a maximum resolution larger than the default, see above.
* @note The width and height are aligned to 4.
* @deprecated Use \ref nwindowSetDimensions instead.
*/
__attribute__((deprecated))
void gfxInitResolution(u32 width, u32 height);
/// Wrapper for \ref gfxInitResolution with resolution=1080p. Use this if you want to support 1080p or >720p in docked-mode.
/// \deprecated Use \ref nwindowSetDimensions instead.
__attribute__((deprecated))
void gfxInitResolutionDefault(void);
/// Configure framebuffer crop, by default crop is all-zero. Use all-zero input to reset to default. \ref gfxExit resets this to the default.
/// When the input is invalid this returns without changing the crop data, this includes the input values being larger than the framebuf width/height.
/// This will update the display width/height returned by \ref gfxGetFramebuffer, with that width/height being reset to the default when required.
/// \ref gfxGetFramebufferDisplayOffset uses absolute x/y, it will not adjust for non-zero crop left/top.
/// When used during frame-drawing, this should be called before \ref gfxGetFramebuffer.
/// The right and bottom params are aligned to 4.
/// \deprecated Use \ref nwindowSetCrop instead.
__attribute__((deprecated))
void gfxConfigureCrop(s32 left, s32 top, s32 right, s32 bottom);
/// Wrapper for \ref gfxConfigureCrop. Use this to set the resolution, within the bounds of the maximum resolution. Use all-zero input to reset to default.
/// \deprecated Use \ref nwindowSetCrop instead.
__attribute__((deprecated))
void gfxConfigureResolution(s32 width, s32 height);
/// If enabled, \ref gfxConfigureResolution will be used with the input resolution for the current OperationMode. Then \ref gfxConfigureResolution will automatically be used with the specified resolution each time OperationMode changes.
/// \deprecated No replacement. Manually query the current OperationMode and use \ref nwindowSetCrop instead.
__attribute__((deprecated))
void gfxConfigureAutoResolution(bool enable, s32 handheld_width, s32 handheld_height, s32 docked_width, s32 docked_height);
/// Wrapper for \ref gfxConfigureAutoResolution. handheld_resolution=720p, docked_resolution={all-zero for using current maximum resolution}.
/// \deprecated No replacement. Manually query the current OperationMode and use \ref nwindowSetCrop instead.
__attribute__((deprecated))
void gfxConfigureAutoResolutionDefault(bool enable);
/// Waits for vertical sync.
/// \deprecated No replacement. Waiting for vertical sync is neither necessary nor desirable with the system's compositor.
__attribute__((deprecated))
void gfxWaitForVsync(void);
/// Appends one or more fences that the display service will wait on before rendering the current framebuffer. Note that only up to 4 fences can be submitted.
/// \deprecated Use \ref nwindowQueueBuffer parameter \p fence instead.
__attribute__((deprecated))
void gfxAppendFence(NvMultiFence* mf);
/// Swaps the framebuffers.
/// \deprecated Use \ref framebufferBegin and \ref framebufferEnd, or \ref nwindowDequeueBuffer and \ref nwindowQueueBuffer instead.
__attribute__((deprecated))
void gfxSwapBuffers(void);
/// Get the specified framebuffer nvmap handle where index specifies the buffer number beginning with the back buffer, with optional output ptr for the offset in the buffer.
/// \deprecated No replacement.
__attribute__((deprecated))
u32 gfxGetFramebufferHandle(u32 index, u32* offset);
/// Get the current framebuffer address, with optional output ptrs for the display framebuffer width/height. The display width/height is adjusted by \ref gfxConfigureCrop and \ref gfxConfigureResolution.
/// \deprecated Check return value of \ref framebufferBegin instead.
__attribute__((deprecated))
u8* gfxGetFramebuffer(u32* width, u32* height);
/// Get the framebuffer width/height without crop.
/// \deprecated Use \ref nwindowGetDimensions instead.
__attribute__((deprecated))
void gfxGetFramebufferResolution(u32* width, u32* height);
/// Use this to get the actual byte-size of the framebuffer for use with memset/etc.
/// \deprecated No replacement.
__attribute__((deprecated))
size_t gfxGetFramebufferSize(void);
/// Use this to get the actual byte-pitch of the framebuffer for use with memset/etc.
/// \deprecated Use \ref framebufferBegin parameter \p out_stride instead.
__attribute__((deprecated))
u32 gfxGetFramebufferPitch(void);
/// Sets the \ref GfxMode.
/// \deprecated Use \ref framebufferMakeLinear instead.
__attribute__((deprecated))
void gfxSetMode(GfxMode mode);
/// Configures transform. See the NATIVE_WINDOW_TRANSFORM_* enums in buffer_producer.h. The default is 0.
/// \deprecated Use \ref nwindowSetTransform instead.
__attribute__((deprecated))
void gfxConfigureTransform(u32 transform);
/// Flushes the framebuffer in the data cache. When \ref GfxMode is GfxMode_LinearDouble, this also transfers the linear-framebuffer to the actual framebuffer.
/// \deprecated No replacement and no need to flush data cache manually when using \ref Framebuffer.
__attribute__((deprecated))
void gfxFlushBuffers(void);
/// Use this to get the pixel-offset in the framebuffer. Returned value is in pixels, not bytes.
/// This implements tegra blocklinear, with hard-coded constants etc.
/// Do not use this when \ref GfxMode is GfxMode_LinearDouble.
/// \deprecated No replacement. Use linear mode (\ref framebufferMakeLinear), or manually implement Tegra block linear layout with 16Bx2 sector ordering.
__attribute__((deprecated))
static inline u32 gfxGetFramebufferDisplayOffset(u32 x, u32 y) {
u32 tmp_pos;
extern size_t g_gfx_framebuf_aligned_width;
//if (x >= g_gfx_framebuf_width || y >= g_gfx_framebuf_display_height) return (gfxGetFramebufferSize()-4)/4;//Return the last pixel-offset in the buffer, the data located here is not displayed due to alignment. (Disabled for perf)
tmp_pos = ((y & 127) / 16) + (x/16*8) + ((y/16/8)*(g_gfx_framebuf_aligned_width/16*8));
tmp_pos *= 16*16 * 4;
tmp_pos += ((y%16)/8)*512 + ((x%16)/8)*256 + ((y%8)/2)*64 + ((x%8)/4)*32 + (y%2)*16 + (x%4)*4;//This line is a modified version of code from the Tegra X1 datasheet.
return tmp_pos / 4;
}

View File

@ -58,11 +58,10 @@ 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, Service* binder_session, s32 binder_id, bool producer_controlled_by_app);
Result nwindowCreate(NWindow* nw, s32 binder_id, bool producer_controlled_by_app);
/**
* @brief Creates a \ref NWindow operating on a \ref ViLayer.

View File

@ -1,5 +1,5 @@
/**
* @file display/types.h
* @file types.h
* @brief Definitions for Android-related types and enumerations.
* @copyright libnx Authors
*/

View File

@ -5,15 +5,15 @@
* @copyright libnx Authors
*/
#pragma once
#include "mutex.h"
#include "condvar.h"
#include "semaphore.h"
/// Barrier structure.
typedef struct Barrier {
u64 count; ///< Number of threads to reach the barrier.
u64 total; ///< Number of threads to wait on.
Mutex mutex;
CondVar condvar;
u64 count; ///< Number of threads to reach the barrier.
u64 thread_total; ///< Number of threads to wait on.
Semaphore throttle; ///< Semaphore to make sure threads release to scheduler one at a time.
Semaphore lock; ///< Semaphore to lock barrier to prevent multiple operations by threads at once.
Semaphore thread_wait; ///< Semaphore to force a thread to wait if count < thread_total.
} Barrier;
/**

View File

@ -40,7 +40,7 @@ Result condvarWaitTimeout(CondVar* c, Mutex* m, u64 timeout);
*/
static inline Result condvarWait(CondVar* c, Mutex* m)
{
return condvarWaitTimeout(c, m, UINT64_MAX);
return condvarWaitTimeout(c, m, U64_MAX);
}
/**
@ -51,8 +51,7 @@ static inline Result condvarWait(CondVar* c, Mutex* m)
*/
static inline Result condvarWake(CondVar* c, int num)
{
svcSignalProcessWideKey(c, num);
return 0;
return svcSignalProcessWideKey(c, num);
}
/**

View File

@ -1,24 +1,21 @@
/**
* @file detect.h
* @brief Kernel capability detection
* @brief Kernel version detection
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
#include "svc.h"
/// Returns true if the kernel version is equal to or above 2.0.0.
bool kernelAbove200(void);
/// Returns true if the kernel version is equal to or above 3.0.0.
bool kernelAbove300(void);
/// Returns true if the kernel version is equal to or above 4.0.0.
bool kernelAbove400(void);
/// Returns true if the kernel version is equal to or above 5.0.0.
bool kernelAbove500(void);
/// Returns true if the kernel version is equal to or above 6.0.0.
bool kernelAbove600(void);
/// Returns true if the process has a debugger attached.
NX_INLINE bool detectDebugger(void) {
u64 tmp = 0;
Result rc = svcGetInfo(&tmp, InfoType_DebuggerAttached, INVALID_HANDLE, 0);
return R_SUCCEEDED(rc) && tmp != 0;
}
/// Returns true if the underlying kernel is Mesosphère.
NX_INLINE bool detectMesosphere(void) {
u64 dummy = 0;
Result rc = svcGetInfo(&dummy, 65000, INVALID_HANDLE, 0); // InfoType_MesosphereMeta
return R_SUCCEEDED(rc);
}
bool detectDebugger(void);

View File

@ -1,19 +1,13 @@
/**
* @file event.h
* @brief Kernel-mode event synchronization primitive.
* @author plutoo
* @copyright libnx Authors
*/
// Copyright 2018 plutoo
#pragma once
#include "../types.h"
#include "../result.h"
#include "wait.h"
/// Kernel-mode event structure.
typedef struct {
Handle revent; ///< Read-only event handle
Handle wevent; ///< Write-only event handle
bool autoclear; ///< Autoclear flag
Handle revent;
Handle wevent;
bool autoclear;
} Event;
/// Creates a \ref Waiter for a kernel-mode event.
@ -25,60 +19,16 @@ static inline Waiter waiterForEvent(Event* t)
return wait_obj;
}
/**
* @brief Creates a kernel-mode event.
* @param[out] t Pointer to \ref Event structure.
* @param[in] autoclear Autoclear flag.
* @return Result code.
* @warning This is a privileged operation; in normal circumstances applications shouldn't use this function.
*/
Result eventCreate(Event* t, bool autoclear);
/**
* @brief Loads a kernel-mode event obtained from IPC.
* @param[out] t Pointer to \ref Event structure.
* @param[in] handle Read-only event handle.
* @param[in] autoclear Autoclear flag.
*/
void eventLoadRemote(Event* t, Handle handle, bool autoclear);
/**
* @brief Closes a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
*/
void eventClose(Event* t);
/**
* @brief Returns whether an \ref Event is initialized.
* @param[in] t Pointer to \ref Event structure.
* @return Initialization status.
*/
/// Returns whether the Event is initialized.
static inline bool eventActive(Event* t)
{
return t->revent != INVALID_HANDLE;
}
/**
* @brief Waits on a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @param[in] timeout Timeout in nanoseconds (pass UINT64_MAX to wait indefinitely).
* @return Result code.
*/
Result eventWait(Event* t, u64 timeout);
/**
* @brief Signals a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @return Result code.
* @note This function only works for events initialized with \ref eventCreate, it doesn't work with events initialized with \ref eventLoadRemote.
* @warning This is a privileged operation; in normal circumstances applications shouldn't use this function.
*/
Result eventFire(Event* t);
/**
* @brief Clears a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @return Result code.
* @note This function shouldn't be used on autoclear events.
*/
Result eventClear(Event* t);

View File

@ -0,0 +1,757 @@
/**
* @file ipc.h
* @brief Inter-process communication handling
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../result.h"
#include "../arm/tls.h"
#include "../kernel/svc.h"
/// IPC input header magic
#define SFCI_MAGIC 0x49434653
/// IPC output header magic
#define SFCO_MAGIC 0x4f434653
/// IPC invalid object ID
#define IPC_INVALID_OBJECT_ID UINT32_MAX
///@name IPC request building
///@{
/// IPC command (request) structure.
#define IPC_MAX_BUFFERS 8
#define IPC_MAX_OBJECTS 8
typedef enum {
BufferType_Normal=0, ///< Regular buffer.
BufferType_Type1=1, ///< Allows ProcessMemory and shared TransferMemory.
BufferType_Invalid=2,
BufferType_Type3=3 ///< Same as Type1 except remote process is not allowed to use device-mapping.
} BufferType;
typedef enum {
BufferDirection_Send=0,
BufferDirection_Recv=1,
BufferDirection_Exch=2,
} BufferDirection;
typedef enum {
IpcCommandType_Invalid = 0,
IpcCommandType_LegacyRequest = 1,
IpcCommandType_Close = 2,
IpcCommandType_LegacyControl = 3,
IpcCommandType_Request = 4,
IpcCommandType_Control = 5,
IpcCommandType_RequestWithContext = 6,
IpcCommandType_ControlWithContext = 7,
} IpcCommandType;
typedef enum {
DomainMessageType_Invalid = 0,
DomainMessageType_SendMessage = 1,
DomainMessageType_Close = 2,
} DomainMessageType;
/// IPC domain message header.
typedef struct {
u8 Type;
u8 NumObjectIds;
u16 Length;
u32 ThisObjectId;
u32 Pad[2];
} DomainMessageHeader;
/// IPC domain response header.
typedef struct {
u32 NumObjectIds;
u32 Pad[3];
} DomainResponseHeader;
typedef struct {
size_t NumSend; // A
size_t NumRecv; // B
size_t NumExch; // W
const void* Buffers[IPC_MAX_BUFFERS];
size_t BufferSizes[IPC_MAX_BUFFERS];
BufferType BufferTypes[IPC_MAX_BUFFERS];
size_t NumStaticIn; // X
size_t NumStaticOut; // C
const void* Statics[IPC_MAX_BUFFERS];
size_t StaticSizes[IPC_MAX_BUFFERS];
u8 StaticIndices[IPC_MAX_BUFFERS];
bool SendPid;
size_t NumHandlesCopy;
size_t NumHandlesMove;
Handle Handles[IPC_MAX_OBJECTS];
size_t NumObjectIds;
u32 ObjectIds[IPC_MAX_OBJECTS];
} IpcCommand;
/**
* @brief Initializes an IPC command structure.
* @param cmd IPC command structure.
*/
static inline void ipcInitialize(IpcCommand* cmd) {
*cmd = (IpcCommand){0};
}
/// IPC buffer descriptor.
typedef struct {
u32 Size; ///< Size of the buffer.
u32 Addr; ///< Lower 32-bits of the address of the buffer
u32 Packed; ///< Packed data (including higher bits of the address)
} IpcBufferDescriptor;
/// IPC static send-buffer descriptor.
typedef struct {
u32 Packed; ///< Packed data (including higher bits of the address)
u32 Addr; ///< Lower 32-bits of the address
} IpcStaticSendDescriptor;
/// IPC static receive-buffer descriptor.
typedef struct {
u32 Addr; ///< Lower 32-bits of the address of the buffer
u32 Packed; ///< Packed data (including higher bits of the address)
} IpcStaticRecvDescriptor;
/**
* @brief Adds a buffer to an IPC command structure.
* @param cmd IPC command structure.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param type Buffer type.
*/
static inline void ipcAddSendBuffer(IpcCommand* cmd, const void* buffer, size_t size, BufferType type) {
size_t off = cmd->NumSend;
cmd->Buffers[off] = buffer;
cmd->BufferSizes[off] = size;
cmd->BufferTypes[off] = type;
cmd->NumSend++;
}
/**
* @brief Adds a receive-buffer to an IPC command structure.
* @param cmd IPC command structure.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param type Buffer type.
*/
static inline void ipcAddRecvBuffer(IpcCommand* cmd, void* buffer, size_t size, BufferType type) {
size_t off = cmd->NumSend + cmd->NumRecv;
cmd->Buffers[off] = buffer;
cmd->BufferSizes[off] = size;
cmd->BufferTypes[off] = type;
cmd->NumRecv++;
}
/**
* @brief Adds an exchange-buffer to an IPC command structure.
* @param cmd IPC command structure.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param type Buffer type.
*/
static inline void ipcAddExchBuffer(IpcCommand* cmd, void* buffer, size_t size, BufferType type) {
size_t off = cmd->NumSend + cmd->NumRecv + cmd->NumExch;
cmd->Buffers[off] = buffer;
cmd->BufferSizes[off] = size;
cmd->BufferTypes[off] = type;
cmd->NumExch++;
}
/**
* @brief Adds a static-buffer to an IPC command structure.
* @param cmd IPC command structure.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param index Index of buffer.
*/
static inline void ipcAddSendStatic(IpcCommand* cmd, const void* buffer, size_t size, u8 index) {
size_t off = cmd->NumStaticIn;
cmd->Statics[off] = buffer;
cmd->StaticSizes[off] = size;
cmd->StaticIndices[off] = index;
cmd->NumStaticIn++;
}
/**
* @brief Adds a static-receive-buffer to an IPC command structure.
* @param cmd IPC command structure.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param index Index of buffer.
*/
static inline void ipcAddRecvStatic(IpcCommand* cmd, void* buffer, size_t size, u8 index) {
size_t off = cmd->NumStaticIn + cmd->NumStaticOut;
cmd->Statics[off] = buffer;
cmd->StaticSizes[off] = size;
cmd->StaticIndices[off] = index;
cmd->NumStaticOut++;
}
/**
* @brief Adds a smart-buffer (buffer + static-buffer pair) to an IPC command structure.
* @param cmd IPC command structure.
* @param ipc_buffer_size IPC buffer size.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param index Index of buffer.
*/
static inline void ipcAddSendSmart(IpcCommand* cmd, size_t ipc_buffer_size, const void* buffer, size_t size, u8 index) {
if (ipc_buffer_size != 0 && size <= ipc_buffer_size) {
ipcAddSendBuffer(cmd, NULL, 0, BufferType_Normal);
ipcAddSendStatic(cmd, buffer, size, index);
} else {
ipcAddSendBuffer(cmd, buffer, size, BufferType_Normal);
ipcAddSendStatic(cmd, NULL, 0, index);
}
}
/**
* @brief Adds a smart-receive-buffer (buffer + static-receive-buffer pair) to an IPC command structure.
* @param cmd IPC command structure.
* @param ipc_buffer_size IPC buffer size.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param index Index of buffer.
*/
static inline void ipcAddRecvSmart(IpcCommand* cmd, size_t ipc_buffer_size, void* buffer, size_t size, u8 index) {
if (ipc_buffer_size != 0 && size <= ipc_buffer_size) {
ipcAddRecvBuffer(cmd, NULL, 0, BufferType_Normal);
ipcAddRecvStatic(cmd, buffer, size, index);
} else {
ipcAddRecvBuffer(cmd, buffer, size, BufferType_Normal);
ipcAddRecvStatic(cmd, NULL, 0, index);
}
}
/**
* @brief Tags an IPC command structure to send the PID.
* @param cmd IPC command structure.
*/
static inline void ipcSendPid(IpcCommand* cmd) {
cmd->SendPid = true;
}
/**
* @brief Adds a copy-handle to be sent through an IPC command structure.
* @param cmd IPC command structure.
* @param h Handle to send.
* @remark The receiving process gets a copy of the handle.
*/
static inline void ipcSendHandleCopy(IpcCommand* cmd, Handle h) {
cmd->Handles[cmd->NumHandlesCopy++] = h;
}
/**
* @brief Adds a move-handle to be sent through an IPC command structure.
* @param cmd IPC command structure.
* @param h Handle to send.
* @remark The sending process loses ownership of the handle, which is transferred to the receiving process.
*/
static inline void ipcSendHandleMove(IpcCommand* cmd, Handle h) {
cmd->Handles[cmd->NumHandlesCopy + cmd->NumHandlesMove++] = h;
}
/**
* @brief Prepares the header of an IPC command structure.
* @param cmd IPC command structure.
* @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request
* @return Pointer to the raw embedded data structure in the request, ready to be filled out.
*/
static inline void* ipcPrepareHeader(IpcCommand* cmd, size_t sizeof_raw) {
u32* buf = (u32*)armGetTls();
size_t i;
*buf++ = IpcCommandType_Request | (cmd->NumStaticIn << 16) | (cmd->NumSend << 20) | (cmd->NumRecv << 24) | (cmd->NumExch << 28);
u32* fill_in_size_later = buf;
if (cmd->NumStaticOut > 0) {
*buf = (cmd->NumStaticOut + 2) << 10;
}
else {
*buf = 0;
}
if (cmd->SendPid || cmd->NumHandlesCopy > 0 || cmd->NumHandlesMove > 0) {
*buf++ |= 0x80000000;
*buf++ = (!!cmd->SendPid) | (cmd->NumHandlesCopy << 1) | (cmd->NumHandlesMove << 5);
if (cmd->SendPid)
buf += 2;
for (i=0; i<(cmd->NumHandlesCopy + cmd->NumHandlesMove); i++)
*buf++ = cmd->Handles[i];
}
else {
buf++;
}
for (i=0; i<cmd->NumStaticIn; i++, buf+=2) {
IpcStaticSendDescriptor* desc = (IpcStaticSendDescriptor*) buf;
uintptr_t ptr = (uintptr_t) cmd->Statics[i];
desc->Addr = ptr;
desc->Packed = cmd->StaticIndices[i] | (cmd->StaticSizes[i] << 16) |
(((ptr >> 32) & 15) << 12) | (((ptr >> 36) & 15) << 6);
}
for (i=0; i<(cmd->NumSend + cmd->NumRecv + cmd->NumExch); i++, buf+=3) {
IpcBufferDescriptor* desc = (IpcBufferDescriptor*) buf;
desc->Size = cmd->BufferSizes[i];
uintptr_t ptr = (uintptr_t) cmd->Buffers[i];
desc->Addr = ptr;
desc->Packed = cmd->BufferTypes[i] |
(((ptr >> 32) & 15) << 28) | ((ptr >> 36) << 2);
}
u32 padding = ((16 - (((uintptr_t) buf) & 15)) & 15) / 4;
u32* raw = (u32*) (buf + padding);
size_t raw_size = (sizeof_raw/4) + 4;
buf += raw_size;
u16* buf_u16 = (u16*) buf;
for (i=0; i<cmd->NumStaticOut; i++) {
size_t off = cmd->NumStaticIn + i;
size_t sz = (uintptr_t) cmd->StaticSizes[off];
buf_u16[i] = (sz > 0xFFFF) ? 0 : sz;
}
size_t u16s_size = ((2*cmd->NumStaticOut) + 3)/4;
buf += u16s_size;
raw_size += u16s_size;
*fill_in_size_later |= raw_size;
for (i=0; i<cmd->NumStaticOut; i++, buf+=2) {
IpcStaticRecvDescriptor* desc = (IpcStaticRecvDescriptor*) buf;
size_t off = cmd->NumStaticIn + i;
uintptr_t ptr = (uintptr_t) cmd->Statics[off];
desc->Addr = ptr;
desc->Packed = (ptr >> 32) | (cmd->StaticSizes[off] << 16);
}
return (void*) raw;
}
/**
* @brief Dispatches an IPC request.
* @param session IPC session handle.
* @return Result code.
*/
static inline Result ipcDispatch(Handle session) {
return svcSendSyncRequest(session);
}
///@}
///@name IPC response parsing
///@{
/// IPC parsed command (response) structure.
typedef struct {
IpcCommandType CommandType; ///< Type of the command
bool HasPid; ///< true if the 'Pid' field is filled out.
u64 Pid; ///< PID included in the response (only if HasPid is true)
size_t NumHandles; ///< Number of handles copied.
Handle Handles[IPC_MAX_OBJECTS]; ///< Handles.
bool WasHandleCopied[IPC_MAX_OBJECTS]; ///< true if the handle was moved, false if it was copied.
bool IsDomainRequest; ///< true if the the message is a Domain message.
DomainMessageType InMessageType; ///< Type of the domain message.
u32 InMessageLength; ///< Size of rawdata (for domain messages).
u32 InThisObjectId; ///< Object ID to call the command on (for domain messages).
size_t InNumObjectIds; ///< Number of object IDs (for domain messages).
u32 InObjectIds[IPC_MAX_OBJECTS]; ///< Object IDs (for domain messages).
bool IsDomainResponse; ///< true if the the message is a Domain response.
size_t OutNumObjectIds; ///< Number of object IDs (for domain responses).
u32 OutObjectIds[IPC_MAX_OBJECTS]; ///< Object IDs (for domain responses).
size_t NumBuffers; ///< Number of buffers in the response.
void* Buffers[IPC_MAX_BUFFERS]; ///< Pointers to the buffers.
size_t BufferSizes[IPC_MAX_BUFFERS]; ///< Sizes of the buffers.
BufferType BufferTypes[IPC_MAX_BUFFERS]; ///< Types of the buffers.
BufferDirection BufferDirections[IPC_MAX_BUFFERS]; ///< Direction of each buffer.
size_t NumStatics; ///< Number of statics in the response.
void* Statics[IPC_MAX_BUFFERS]; ///< Pointers to the statics.
size_t StaticSizes[IPC_MAX_BUFFERS]; ///< Sizes of the statics.
u8 StaticIndices[IPC_MAX_BUFFERS]; ///< Indices of the statics.
size_t NumStaticsOut; ///< Number of output statics available in the response.
void* Raw; ///< Pointer to the raw embedded data structure in the response.
void* RawWithoutPadding; ///< Pointer to the raw embedded data structure, without padding.
size_t RawSize; ///< Size of the raw embedded data.
} IpcParsedCommand;
/**
* @brief Parse an IPC command response into an IPC parsed command structure.
* @param IPC parsed command structure to fill in.
* @return Result code.
*/
static inline Result ipcParse(IpcParsedCommand* r) {
u32* buf = (u32*)armGetTls();
u32 ctrl0 = *buf++;
u32 ctrl1 = *buf++;
size_t i;
r->IsDomainRequest = false;
r->IsDomainResponse = false;
r->CommandType = (IpcCommandType) (ctrl0 & 0xffff);
r->HasPid = false;
r->RawSize = (ctrl1 & 0x1ff) * 4;
r->NumHandles = 0;
r->NumStaticsOut = (ctrl1 >> 10) & 15;
if (r->NumStaticsOut >> 1) r->NumStaticsOut--; // Value 2 -> Single descriptor
if (r->NumStaticsOut >> 1) r->NumStaticsOut--; // Value 3+ -> (Value - 2) descriptors
if (ctrl1 & 0x80000000) {
u32 ctrl2 = *buf++;
if (ctrl2 & 1) {
r->HasPid = true;
r->Pid = *buf++;
r->Pid |= ((u64)(*buf++)) << 32;
}
size_t num_handles_copy = ((ctrl2 >> 1) & 15);
size_t num_handles_move = ((ctrl2 >> 5) & 15);
size_t num_handles = num_handles_copy + num_handles_move;
u32* buf_after_handles = buf + num_handles;
if (num_handles > IPC_MAX_OBJECTS)
num_handles = IPC_MAX_OBJECTS;
for (i=0; i<num_handles; i++)
{
r->Handles[i] = *(buf+i);
r->WasHandleCopied[i] = (i < num_handles_copy);
}
r->NumHandles = num_handles;
buf = buf_after_handles;
}
size_t num_statics = (ctrl0 >> 16) & 15;
u32* buf_after_statics = buf + num_statics*2;
if (num_statics > IPC_MAX_BUFFERS)
num_statics = IPC_MAX_BUFFERS;
for (i=0; i<num_statics; i++, buf+=2) {
IpcStaticSendDescriptor* desc = (IpcStaticSendDescriptor*) buf;
u64 packed = (u64) desc->Packed;
r->Statics[i] = (void*) (desc->Addr | (((packed >> 12) & 15) << 32) | (((packed >> 6) & 15) << 36));
r->StaticSizes[i] = packed >> 16;
r->StaticIndices[i] = packed & 63;
}
r->NumStatics = num_statics;
buf = buf_after_statics;
size_t num_bufs_send = (ctrl0 >> 20) & 15;
size_t num_bufs_recv = (ctrl0 >> 24) & 15;
size_t num_bufs_exch = (ctrl0 >> 28) & 15;
size_t num_bufs = num_bufs_send + num_bufs_recv + num_bufs_exch;
r->Raw = (void*)(((uintptr_t)(buf + num_bufs*3) + 15) &~ 15);
r->RawWithoutPadding = (void*)((uintptr_t)(buf + num_bufs*3));
if (num_bufs > IPC_MAX_BUFFERS)
num_bufs = IPC_MAX_BUFFERS;
for (i=0; i<num_bufs; i++, buf+=3) {
IpcBufferDescriptor* desc = (IpcBufferDescriptor*) buf;
u64 packed = (u64) desc->Packed;
r->Buffers[i] = (void*) (desc->Addr | ((packed >> 28) << 32) | (((packed >> 2) & 15) << 36));
r->BufferSizes[i] = desc->Size;
r->BufferTypes[i] = (BufferType) (packed & 3);
if (i < num_bufs_send)
r->BufferDirections[i] = BufferDirection_Send;
else if (i < (num_bufs_send + num_bufs_recv))
r->BufferDirections[i] = BufferDirection_Recv;
else
r->BufferDirections[i] = BufferDirection_Exch;
}
r->NumBuffers = num_bufs;
return 0;
}
/**
* @brief Queries the size of an IPC pointer buffer.
* @param session IPC session handle.
* @param size Output variable in which to store the size.
* @return Result code.
*/
static inline Result ipcQueryPointerBufferSize(Handle session, size_t *size) {
u32* buf = (u32*)armGetTls();
buf[0] = IpcCommandType_Control;
buf[1] = 8;
buf[2] = 0;
buf[3] = 0;
buf[4] = SFCI_MAGIC;
buf[5] = 0;
buf[6] = 3;
buf[7] = 0;
Result rc = ipcDispatch(session);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct ipcQueryPointerBufferSizeResponse {
u64 magic;
u64 result;
u32 size;
} *raw = (struct ipcQueryPointerBufferSizeResponse*)r.Raw;
rc = raw->result;
if (R_SUCCEEDED(rc)) {
*size = raw->size & 0xffff;
}
}
return rc;
}
/**
* @brief Closes the IPC session with proper clean up.
* @param session IPC session handle.
* @return Result code.
*/
static inline Result ipcCloseSession(Handle session) {
u32* buf = (u32*)armGetTls();
buf[0] = IpcCommandType_Close;
buf[1] = 0;
return ipcDispatch(session);
}
/**
* @brief Clones an IPC session.
* @param session IPC session handle.
* @param unk Unknown.
* @param new_session_out Output cloned IPC session handle.
* @return Result code.
*/
static inline Result ipcCloneSession(Handle session, u32 unk, Handle* new_session_out) {
u32* buf = (u32*)armGetTls();
buf[0] = IpcCommandType_Control;
buf[1] = 9;
buf[2] = 0;
buf[3] = 0;
buf[4] = SFCI_MAGIC;
buf[5] = 0;
buf[6] = 4;
buf[7] = 0;
buf[8] = unk;
Result rc = ipcDispatch(session);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct ipcCloneSessionResponse {
u64 magic;
u64 result;
} *raw = (struct ipcCloneSessionResponse*)r.Raw;
rc = raw->result;
if (R_SUCCEEDED(rc) && new_session_out) {
*new_session_out = r.Handles[0];
}
}
return rc;
}
///@}
///@name IPC domain handling
///@{
/**
* @brief Converts an IPC session handle into a domain.
* @param session IPC session handle.
* @param object_id_out Output variable in which to store the object ID.
* @return Result code.
*/
static inline Result ipcConvertSessionToDomain(Handle session, u32* object_id_out) {
u32* buf = (u32*)armGetTls();
buf[0] = IpcCommandType_Control;
buf[1] = 8;
buf[4] = SFCI_MAGIC;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
Result rc = ipcDispatch(session);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct ipcConvertSessionToDomainResponse {
u64 magic;
u64 result;
u32 object_id;
} *raw = (struct ipcConvertSessionToDomainResponse*)r.Raw;
rc = raw->result;
if (R_SUCCEEDED(rc)) {
*object_id_out = raw->object_id;
}
}
return rc;
}
/**
* @brief Adds an object ID to be sent through an IPC domain command structure.
* @param cmd IPC domain command structure.
* @param object_id Object ID to send.
*/
static inline void ipcSendObjectId(IpcCommand* cmd, u32 object_id) {
cmd->ObjectIds[cmd->NumObjectIds++] = object_id;
}
/**
* @brief Prepares the header of an IPC command structure (domain version).
* @param cmd IPC command structure.
* @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request
* @oaram object_id Domain object ID.
* @return Pointer to the raw embedded data structure in the request, ready to be filled out.
*/
static inline void* ipcPrepareHeaderForDomain(IpcCommand* cmd, size_t sizeof_raw, u32 object_id) {
void* raw = ipcPrepareHeader(cmd, sizeof_raw + sizeof(DomainMessageHeader) + cmd->NumObjectIds*sizeof(u32));
DomainMessageHeader* hdr = (DomainMessageHeader*) raw;
u32 *object_ids = (u32*)(((uintptr_t) raw) + sizeof(DomainMessageHeader) + sizeof_raw);
hdr->Type = DomainMessageType_SendMessage;
hdr->NumObjectIds = (u8)cmd->NumObjectIds;
hdr->Length = sizeof_raw;
hdr->ThisObjectId = object_id;
hdr->Pad[0] = hdr->Pad[1] = 0;
for(size_t i = 0; i < cmd->NumObjectIds; i++)
object_ids[i] = cmd->ObjectIds[i];
return (void*)(((uintptr_t) raw) + sizeof(DomainMessageHeader));
}
/**
* @brief Parse an IPC command request into an IPC parsed command structure (domain version).
* @param IPC parsed command structure to fill in.
* @return Result code.
*/
static inline Result ipcParseDomainRequest(IpcParsedCommand* r) {
Result rc = ipcParse(r);
DomainMessageHeader *hdr;
u32 *object_ids;
if(R_FAILED(rc))
return rc;
hdr = (DomainMessageHeader*) r->Raw;
object_ids = (u32*)(((uintptr_t) hdr) + sizeof(DomainMessageHeader) + hdr->Length);
r->Raw = (void*)(((uintptr_t) r->Raw) + sizeof(DomainMessageHeader));
r->IsDomainRequest = true;
r->InMessageType = (DomainMessageType)(hdr->Type);
switch (r->InMessageType) {
case DomainMessageType_SendMessage:
case DomainMessageType_Close:
break;
default:
return MAKERESULT(Module_Libnx, LibnxError_DomainMessageUnknownType);
}
r->InThisObjectId = hdr->ThisObjectId;
r->InNumObjectIds = hdr->NumObjectIds > 8 ? 8 : hdr->NumObjectIds;
if ((uintptr_t)object_ids + sizeof(u32) * r->InNumObjectIds - (uintptr_t)armGetTls() >= 0x100) {
return MAKERESULT(Module_Libnx, LibnxError_DomainMessageTooManyObjectIds);
}
for(size_t i = 0; i < r->InNumObjectIds; i++)
r->InObjectIds[i] = object_ids[i];
return rc;
}
/**
* @brief Parse an IPC command response into an IPC parsed command structure (domain version).
* @param IPC parsed command structure to fill in.
* @return Result code.
*/
static inline Result ipcParseDomainResponse(IpcParsedCommand* r, size_t sizeof_raw) {
Result rc = ipcParse(r);
DomainResponseHeader *hdr;
u32 *object_ids;
if(R_FAILED(rc))
return rc;
hdr = (DomainResponseHeader*) r->Raw;
r->Raw = (void*)(((uintptr_t) r->Raw) + sizeof(DomainResponseHeader));
object_ids = (u32*)(((uintptr_t) r->Raw) + sizeof_raw);//Official sw doesn't align this.
r->IsDomainResponse = true;
r->OutNumObjectIds = hdr->NumObjectIds > 8 ? 8 : hdr->NumObjectIds;
if ((uintptr_t)object_ids + sizeof(u32) * r->OutNumObjectIds - (uintptr_t)armGetTls() >= 0x100) {
return MAKERESULT(Module_Libnx, LibnxError_DomainMessageTooManyObjectIds);
}
for(size_t i = 0; i < r->OutNumObjectIds; i++)
r->OutObjectIds[i] = object_ids[i];
return rc;
}
/**
* @brief Closes a domain object by ID.
* @param session IPC session handle.
* @param object_id ID of the object to close.
* @return Result code.
*/
static inline Result ipcCloseObjectById(Handle session, u32 object_id) {
IpcCommand c;
DomainMessageHeader* hdr;
ipcInitialize(&c);
hdr = (DomainMessageHeader*)ipcPrepareHeader(&c, sizeof(DomainMessageHeader));
hdr->Type = DomainMessageType_Close;
hdr->NumObjectIds = 0;
hdr->Length = 0;
hdr->ThisObjectId = object_id;
hdr->Pad[0] = hdr->Pad[1] = 0;
return ipcDispatch(session); // this command has no associated response
}
///@}

View File

@ -6,12 +6,11 @@
*/
#pragma once
#include "../types.h"
#include "virtmem.h"
/// JIT implementation type.
typedef enum {
JitType_SetProcessMemoryPermission, ///< JIT supported using svcSetProcessMemoryPermission
JitType_CodeMemory, ///< JIT supported using [4.0.0+] CodeMemory syscalls
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;
/// JIT buffer object.
@ -22,10 +21,7 @@ typedef struct {
void* rx_addr;
void* rw_addr;
bool is_executable;
union {
Handle handle;
VirtmemReservation* rv;
};
Handle handle;
} Jit;
/**
@ -62,15 +58,11 @@ Result jitClose(Jit* j);
* @param j JIT buffer.
* @return Pointer to alias of the JIT buffer that can be written to.
*/
NX_CONSTEXPR void* jitGetRwAddr(Jit* j) {
return j->rw_addr;
}
void* jitGetRwAddr(Jit* j);
/**
* @brief Gets the address of the executable memory alias of a JIT buffer.
* @param j JIT buffer.
* @return Pointer to alias of the JIT buffer that can be executed.
*/
NX_CONSTEXPR void* jitGetRxAddr(Jit* j) {
return j->rx_addr;
}
void* jitGetRxAddr(Jit* j);

View File

@ -1,54 +0,0 @@
/**
* @file levent.h
* @brief Light event synchronization primitive [4.0.0+]
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
#include "svc.h"
/// User-mode light event structure.
typedef struct LEvent {
u32 counter;
bool autoclear;
} LEvent;
/**
* @brief Initializes a user-mode light event.
* @param[out] le Pointer to \ref LEvent structure.
* @param[in] signaled Whether the event starts off in signaled state.
* @param[in] autoclear Autoclear flag.
*/
NX_CONSTEXPR void leventInit(LEvent* le, bool signaled, bool autoclear) {
le->counter = signaled ? 2 : 0;
le->autoclear = autoclear;
}
/**
* @brief Waits on a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
* @param[in] timeout_ns Timeout in nanoseconds (pass UINT64_MAX to wait indefinitely).
* @return true if wait succeeded, false if wait timed out.
*/
bool leventWait(LEvent* le, u64 timeout_ns);
/**
* @brief Polls a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
* @return true if event is signaled, false otherwise.
*/
bool leventTryWait(LEvent* le);
/**
* @brief Signals a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
*/
void leventSignal(LEvent* le);
/**
* @brief Clears a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
*/
void leventClear(LEvent* le);

View File

@ -20,7 +20,7 @@ typedef _LOCK_RECURSIVE_T RMutex;
*/
static inline void mutexInit(Mutex* m)
{
*m = INVALID_HANDLE;
*m = 0;
}
/**
@ -42,13 +42,6 @@ bool mutexTryLock(Mutex* m);
*/
void mutexUnlock(Mutex* m);
/**
* @brief Gets whether the current thread owns the mutex.
* @param m Mutex object.
* @return 1 if the mutex is locked by the current thread, and 0 otherwise.
*/
bool mutexIsLockedByCurrentThread(const Mutex* m);
/**
* @brief Initializes a recursive mutex.
* @param m Recursive mutex object.

View File

@ -1,23 +1,17 @@
/**
* @file rwlock.h
* @brief Read/write lock synchronization primitive.
* @author plutoo, SciresM
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../kernel/mutex.h"
#include "../kernel/condvar.h"
/// Read/write lock structure.
typedef struct {
Mutex mutex;
CondVar condvar_reader_wait;
CondVar condvar_writer_wait;
u32 read_lock_count;
u32 read_waiter_count;
u32 write_lock_count;
u32 write_waiter_count;
u32 write_owner_tag;
RMutex r;
RMutex g;
u64 b;
} RwLock;
/**
@ -32,13 +26,6 @@ void rwlockInit(RwLock* r);
*/
void rwlockReadLock(RwLock* r);
/**
* @brief Attempts to lock the read/write lock for reading without waiting.
* @param r Read/write lock object.
* @return 1 if the mutex has been acquired successfully, and 0 on contention.
*/
bool rwlockTryReadLock(RwLock* r);
/**
* @brief Unlocks the read/write lock for reading.
* @param r Read/write lock object.
@ -51,30 +38,8 @@ void rwlockReadUnlock(RwLock* r);
*/
void rwlockWriteLock(RwLock* r);
/**
* @brief Attempts to lock the read/write lock for writing without waiting.
* @param r Read/write lock object.
* @return 1 if the mutex has been acquired successfully, and 0 on contention.
*/
bool rwlockTryWriteLock(RwLock* r);
/**
* @brief Unlocks the read/write lock for writing.
* @param r Read/write lock object.
*/
void rwlockWriteUnlock(RwLock* r);
/**
* @brief Checks if the write lock is held by the current thread.
* @param r Read/write lock object.
* @return 1 if the current hold holds the write lock, and 0 if it does not.
*/
bool rwlockIsWriteLockHeldByCurrentThread(RwLock* r);
/**
* @brief Checks if the read/write lock is owned by the current thread.
* @param r Read/write lock object.
* @return 1 if the current hold holds the write lock or if it holds read locks acquired
* while it held the write lock, and 0 if it does not.
*/
bool rwlockIsOwnedByCurrentThread(RwLock* r);

View File

@ -40,8 +40,6 @@ typedef enum {
MemType_KernelStack=0x13, ///< Mapped in kernel during \ref svcCreateThread.
MemType_CodeReadOnly=0x14, ///< Mapped in kernel during \ref svcControlCodeMemory.
MemType_CodeWritable=0x15, ///< Mapped in kernel during \ref svcControlCodeMemory.
MemType_Coverage=0x16, ///< Not available.
MemType_Insecure=0x17, ///< Mapped in kernel during \ref svcMapInsecurePhysicalMemory.
} MemoryType;
/// Memory state bitmasks.
@ -69,11 +67,10 @@ typedef enum {
/// Memory attribute bitmasks.
typedef enum {
MemAttr_IsBorrowed=BIT(0), ///< Is borrowed memory.
MemAttr_IsIpcMapped=BIT(1), ///< Is IPC mapped (when IpcRefCount > 0).
MemAttr_IsDeviceMapped=BIT(2), ///< Is device mapped (when DeviceRefCount > 0).
MemAttr_IsUncached=BIT(3), ///< Is uncached.
MemAttr_IsPermissionLocked=BIT(4), ///< Is permission locked.
MemAttr_IsBorrowed=BIT(0), ///< Is borrowed memory.
MemAttr_IsIpcMapped=BIT(1), ///< Is IPC mapped (when IpcRefCount > 0).
MemAttr_IsDeviceMapped=BIT(2), ///< Is device mapped (when DeviceRefCount > 0).
MemAttr_IsUncached=BIT(3), ///< Is uncached.
} MemoryAttribute;
/// Memory permission bitmasks.
@ -94,36 +91,15 @@ typedef struct {
u32 type; ///< Memory type (see lower 8 bits of \ref MemoryState).
u32 attr; ///< Memory attributes (see \ref MemoryAttribute).
u32 perm; ///< Memory permissions (see \ref Permission).
u32 ipc_refcount; ///< IPC reference count.
u32 device_refcount; ///< Device reference count.
u32 ipc_refcount; ///< IPC reference count.
u32 padding; ///< Padding.
} MemoryInfo;
/// Physical memory information structure.
typedef struct {
u64 physical_address; ///< Physical address.
u64 virtual_address; ///< Virtual address.
u64 size; ///< Size.
} PhysicalMemoryInfo;
/// Secure monitor arguments.
typedef struct {
u64 X[8]; ///< Values of X0 through X7.
} NX_PACKED SecmonArgs;
/// Break reasons
typedef enum {
BreakReason_Panic = 0,
BreakReason_Assert = 1,
BreakReason_User = 2,
BreakReason_PreLoadDll = 3,
BreakReason_PostLoadDll = 4,
BreakReason_PreUnloadDll = 5,
BreakReason_PostUnloadDll = 6,
BreakReason_CppException = 7,
BreakReason_NotificationOnlyFlag = 0x80000000,
} BreakReason;
} PACKED SecmonArgs;
/// Code memory mapping operations
typedef enum {
@ -142,12 +118,6 @@ typedef enum {
LimitableResource_Sessions=4, ///<How many sessions can a process own.
} LimitableResource;
/// Thread Activity.
typedef enum {
ThreadActivity_Runnable = 0, ///< Thread can run.
ThreadActivity_Paused = 1, ///< Thread is paused.
} ThreadActivity;
/// Process Information.
typedef enum {
ProcessInfoType_ProcessState=0, ///<What state is a process in.
@ -165,12 +135,6 @@ typedef enum {
ProcessState_DebugSuspended=7, ///<Process execution suspended by debugger.
} ProcessState;
/// Process Activity.
typedef enum {
ProcessActivity_Runnable = 0, ///< Process can run.
ProcessActivity_Paused = 1, ///< Process is paused.
} ProcessActivity;
/// Debug Thread Parameters.
typedef enum {
DebugThreadParam_ActualPriority=0,
@ -180,125 +144,15 @@ typedef enum {
DebugThreadParam_CoreMask=4,
} DebugThreadParam;
/// GetInfo IDs.
typedef enum {
InfoType_CoreMask = 0, ///< Bitmask of allowed Core IDs.
InfoType_PriorityMask = 1, ///< Bitmask of allowed Thread Priorities.
InfoType_AliasRegionAddress = 2, ///< Base of the Alias memory region.
InfoType_AliasRegionSize = 3, ///< Size of the Alias memory region.
InfoType_HeapRegionAddress = 4, ///< Base of the Heap memory region.
InfoType_HeapRegionSize = 5, ///< Size of the Heap memory region.
InfoType_TotalMemorySize = 6, ///< Total amount of memory available for process.
InfoType_UsedMemorySize = 7, ///< Amount of memory currently used by process.
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_ProgramId = 18, ///< [3.0.0+] Program 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_IsApplication = 23, ///< [9.0.0+] Whether the specified process is an Application.
InfoType_FreeThreadCount = 24, ///< [11.0.0+] The number of free threads available to the process's resource limit.
InfoType_ThreadTickCount = 25, ///< [13.0.0+] Number of ticks spent on thread.
InfoType_IsSvcPermitted = 26, ///< [14.0.0+] Does process have access to SVC (only usable with \ref svcSynchronizePreemptionState at present).
InfoType_IoRegionHint = 27, ///< [16.0.0+] Low bits of the physical address for a KIoRegion.
InfoType_AliasRegionExtraSize = 28, ///< [18.0.0+] Extra size added to the reserved region.
InfoType_TransferMemoryHint = 34, ///< [19.0.0+] Low bits of the process address for a KTransferMemory.
InfoType_ThreadTickCountDeprecated = 0xF0000002, ///< [1.0.0-12.1.0] Number of ticks spent on thread.
} InfoType;
/// GetSystemInfo IDs.
typedef enum {
SystemInfoType_TotalPhysicalMemorySize = 0, ///< Total amount of DRAM available to system.
SystemInfoType_UsedPhysicalMemorySize = 1, ///< Current amount of DRAM used by system.
SystemInfoType_InitialProcessIdRange = 2, ///< Min/max initial process IDs.
} SystemInfoType;
/// GetInfo Idle/Thread Tick Count Sub IDs.
typedef enum {
TickCountInfo_Core0 = 0, ///< Tick count on core 0.
TickCountInfo_Core1 = 1, ///< Tick count on core 1.
TickCountInfo_Core2 = 2, ///< Tick count on core 2.
TickCountInfo_Core3 = 3, ///< Tick count on core 3.
TickCountInfo_Total = UINT64_MAX, ///< Tick count on all cores.
} TickCountInfo;
/// GetInfo InitialProcessIdRange Sub IDs.
typedef enum {
InitialProcessIdRangeInfo_Minimum = 0, ///< Lowest initial process ID.
InitialProcessIdRangeInfo_Maximum = 1, ///< Highest initial process ID.
} InitialProcessIdRangeInfo;
/// GetSystemInfo PhysicalMemory Sub IDs.
typedef enum {
PhysicalMemorySystemInfo_Application = 0, ///< Memory allocated for application usage.
PhysicalMemorySystemInfo_Applet = 1, ///< Memory allocated for applet usage.
PhysicalMemorySystemInfo_System = 2, ///< Memory allocated for system usage.
PhysicalMemorySystemInfo_SystemUnsafe = 3, ///< Memory allocated for unsafe system usage (accessible to devices).
} PhysicalMemorySystemInfo;
/// SleepThread yield types.
typedef enum {
YieldType_WithoutCoreMigration = 0l, ///< Yields to another thread on the same core.
YieldType_WithCoreMigration = -1l, ///< Yields to another thread (possibly on a different core).
YieldType_ToAnyThread = -2l, ///< Yields and performs forced load-balancing.
} YieldType;
/// SignalToAddress behaviors.
typedef enum {
SignalType_Signal = 0, ///< Signals the address.
SignalType_SignalAndIncrementIfEqual = 1, ///< Signals the address and increments its value if equal to argument.
SignalType_SignalAndModifyBasedOnWaitingThreadCountIfEqual = 2, ///< Signals the address and updates its value if equal to argument.
} SignalType;
/// WaitForAddress behaviors.
typedef enum {
ArbitrationType_WaitIfLessThan = 0, ///< Wait if the 32-bit value is less than argument.
ArbitrationType_DecrementAndWaitIfLessThan = 1, ///< Decrement the 32-bit value and wait if it is less than argument.
ArbitrationType_WaitIfEqual = 2, ///< Wait if the 32-bit value is equal to argument.
ArbitrationType_WaitIfEqual64 = 3, ///< [19.0.0+] Wait if the 64-bit value is equal to argument.
} ArbitrationType;
/// Context of a scheduled thread.
typedef struct {
u64 fp; ///< Frame Pointer for the thread.
u64 sp; ///< Stack Pointer for the thread.
u64 lr; ///< Link Register for the thread.
u64 pc; ///< Program Counter for the thread.
} LastThreadContext;
/// Memory mapping type.
typedef enum {
MemoryMapping_IoRegister = 0, ///< Mapping IO registers.
MemoryMapping_Uncached = 1, ///< Mapping normal memory without cache.
MemoryMapping_Memory = 2, ///< Mapping normal memory.
} MemoryMapping;
/// Io Pools.
typedef enum {
IoPoolType_PcieA2 = 0, ///< Physical address range 0x12000000-0x1FFFFFFF
} IoPoolType;
///@name Memory management
///@{
/**
* @brief Set the process heap to a given size. It can both extend and shrink the heap.
* @param[out] out_addr Variable to which write the address of the heap (which is randomized and fixed by the kernel)
* @param[in] size Size of the heap, must be a multiple of 0x200000 and [2.0.0+] less than 0x18000000.
* @param[in] size Size of the heap, must be a multiple of 0x2000000 and [2.0.0+] less than 0x18000000.
* @return Result code.
* @note Syscall number 0x01.
* @note Syscall number 0x00.
*/
Result svcSetHeapSize(void** out_addr, u64 size);
@ -310,7 +164,7 @@ Result svcSetHeapSize(void** out_addr, u64 size);
* @return Result code.
* @remark Perm_X is not allowed. Setting write-only is not allowed either (Perm_W).
* This can be used to move back and forth between Perm_None, Perm_R and Perm_Rw.
* @note Syscall number 0x02.
* @note Syscall number 0x01.
*/
Result svcSetMemoryPermission(void* addr, u64 size, u32 perm);
@ -322,7 +176,7 @@ Result svcSetMemoryPermission(void* addr, u64 size, u32 perm);
* @param[in] val1 State1
* @return Result code.
* @remark See <a href="https://switchbrew.org/wiki/SVC#svcSetMemoryAttribute">switchbrew.org Wiki</a> for more details.
* @note Syscall number 0x03.
* @note Syscall number 0x02.
*/
Result svcSetMemoryAttribute(void* addr, u64 size, u32 val0, u32 val1);
@ -350,7 +204,7 @@ Result svcUnmapMemory(void* dst_addr, void* src_addr, u64 size);
/**
* @brief Query information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address.
* @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in.
* @param[out] pageinfo Page information which will be filled in.
* @param[out] page_info Page information which will be filled in.
* @param[in] addr Address to query.
* @return Result code.
* @note Syscall number 0x06.
@ -367,7 +221,7 @@ Result svcQueryMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, u64 addr);
* @note Syscall number 0x07.
*/
void NX_NORETURN svcExitProcess(void);
void NORETURN svcExitProcess(void);
/**
* @brief Creates a thread.
@ -387,21 +241,21 @@ Result svcStartThread(Handle handle);
* @brief Exits the current thread.
* @note Syscall number 0x0A.
*/
void NX_NORETURN svcExitThread(void);
void NORETURN svcExitThread(void);
/**
* @brief Sleeps the current thread for the specified amount of time.
* @param[in] nano Number of nanoseconds to sleep, or \ref YieldType for yield.
* @return Result code.
* @note Syscall number 0x0B.
*/
void svcSleepThread(s64 nano);
Result svcSleepThread(u64 nano);
/**
* @brief Gets a thread's priority.
* @return Result code.
* @note Syscall number 0x0C.
*/
Result svcGetThreadPriority(s32* priority, Handle handle);
Result svcGetThreadPriority(u32* priority, Handle handle);
/**
* @brief Sets a thread's priority.
@ -415,7 +269,7 @@ Result svcSetThreadPriority(Handle handle, u32 priority);
* @return Result code.
* @note Syscall number 0x0E.
*/
Result svcGetThreadCoreMask(s32* preferred_core, u64* affinity_mask, Handle handle);
Result svcGetThreadCoreMask(s32* preferred_core, u32* affinity_mask, Handle handle);
/**
* @brief Sets a thread's core mask.
@ -557,9 +411,10 @@ Result svcWaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u6
/**
* @brief Performs a condition variable wake-up operation in userspace.
* @return Result code.
* @note Syscall number 0x1D.
*/
void svcSignalProcessWideKey(u32* key, s32 num);
Result svcSignalProcessWideKey(u32* key, s32 num);
///@}
@ -585,13 +440,6 @@ u64 svcGetSystemTick(void);
*/
Result svcConnectToNamedPort(Handle* session, const char* name);
/**
* @brief Sends a light IPC synchronization request to a session.
* @return Result code.
* @note Syscall number 0x20.
*/
Result svcSendSyncRequestLight(Handle session);
/**
* @brief Sends an IPC synchronization request to a session.
* @return Result code.
@ -640,14 +488,14 @@ Result svcGetThreadId(u64 *threadID, Handle handle);
///@{
/**
* @brief Breaks execution.
* @param[in] breakReason Break reason (see \ref BreakReason).
* @param[in] address Address of the buffer to pass to the debugger.
* @param[in] size Size of the buffer to pass to the debugger.
* @brief Breaks execution. Panic.
* @param[in] breakReason Break reason.
* @param[in] inval1 First break parameter.
* @param[in] inval2 Second break parameter.
* @return Result code.
* @note Syscall number 0x26.
*/
Result svcBreak(u32 breakReason, uintptr_t address, uintptr_t size);
Result svcBreak(u32 breakReason, u64 inval1, u64 inval2);
///@}
@ -673,7 +521,7 @@ Result svcOutputDebugString(const char *str, u64 size);
* @param[in] res Result code.
* @note Syscall number 0x28.
*/
void NX_NORETURN svcReturnFromException(Result res);
void NORETURN svcReturnFromException(Result res);
/**
* @brief Retrieves information about the system, or a certain kernel object.
@ -685,29 +533,7 @@ void NX_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, u32 id0, Handle handle, u64 id1);
///@}
///@name Cache Management
///@{
/**
* @brief Flushes the entire data cache (by set/way).
* @note Syscall number 0x2A.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning This syscall is dangerous, and should not be used.
*/
void svcFlushEntireDataCache(void);
/**
* @brief Flushes data cache for a virtual address range.
* @param[in] address Address of region to flush.
* @param[in] size Size of region to flush.
* @remark armDCacheFlush should be used instead of this syscall whenever possible.
* @note Syscall number 0x2B.
*/
Result svcFlushDataCache(void *address, size_t size);
Result svcGetInfo(u64* out, u64 id0, Handle handle, u64 id1);
///@}
@ -718,6 +544,7 @@ Result svcFlushDataCache(void *address, size_t size);
* @brief Maps new heap memory at the desired address. [3.0.0+]
* @return Result code.
* @note Syscall number 0x2C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapPhysicalMemory(void *address, u64 size);
@ -725,35 +552,9 @@ Result svcMapPhysicalMemory(void *address, u64 size);
* @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+]
* @return Result code.
* @note Syscall number 0x2D.
*/
Result svcUnmapPhysicalMemory(void *address, u64 size);
///@}
///@name Process and thread management
///@{
/**
* @brief Gets information about a thread that will be scheduled in the future. [5.0.0+]
* @param[out] out_context Output \ref LastThreadContext for the thread that will be scheduled.
* @param[out] out_thread_id Output thread id for the thread that will be scheduled.
* @param[in] debug Debug handle.
* @param[in] ns Nanoseconds in the future to get scheduled thread at.
* @return Result code.
* @note Syscall number 0x2E.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetDebugFutureThreadInfo(LastThreadContext *out_context, u64 *out_thread_id, Handle debug, s64 ns);
/**
* @brief Gets information about the previously-scheduled thread.
* @param[out] out_context Output \ref LastThreadContext for the previously scheduled thread.
* @param[out] out_tls_address Output tls address for the previously scheduled thread.
* @param[out] out_flags Output flags for the previously scheduled thread.
* @return Result code.
* @note Syscall number 0x2F.
*/
Result svcGetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags);
Result svcUnmapPhysicalMemory(void *address, u64 size);
///@}
@ -766,7 +567,7 @@ Result svcGetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address
* @note Syscall number 0x30.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetResourceLimitLimitValue(s64 *out, Handle reslimit_h, LimitableResource which);
Result svcGetResourceLimitLimitValue(u64 *out, Handle reslimit_h, LimitableResource which);
/**
* @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
@ -774,7 +575,7 @@ Result svcGetResourceLimitLimitValue(s64 *out, Handle reslimit_h, LimitableResou
* @note Syscall number 0x31.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetResourceLimitCurrentValue(s64 *out, Handle reslimit_h, LimitableResource which);
Result svcGetResourceLimitCurrentValue(u64 *out, Handle reslimit_h, LimitableResource which);
///@}
@ -786,7 +587,7 @@ Result svcGetResourceLimitCurrentValue(s64 *out, Handle reslimit_h, LimitableRes
* @return Result code.
* @note Syscall number 0x32.
*/
Result svcSetThreadActivity(Handle thread, ThreadActivity paused);
Result svcSetThreadActivity(Handle thread, bool paused);
/**
* @brief Dumps the registers of a thread paused by @ref svcSetThreadActivity (register groups: all).
@ -800,110 +601,6 @@ Result svcGetThreadContext3(ThreadContext* ctx, Handle thread);
///@}
///@name Synchronization
///@{
/**
* @brief Arbitrates an address depending on type and value. [4.0.0+]
* @param[in] address Address to arbitrate.
* @param[in] arb_type \ref ArbitrationType to use.
* @param[in] value Value to arbitrate on.
* @param[in] timeout Maximum time in nanoseconds to wait.
* @return Result code.
* @note Syscall number 0x34.
*/
Result svcWaitForAddress(void *address, u32 arb_type, s64 value, s64 timeout);
/**
* @brief Signals (and updates) an address depending on type and value. [4.0.0+]
* @param[in] address Address to arbitrate.
* @param[in] signal_type \ref SignalType to use.
* @param[in] value Value to arbitrate on.
* @param[in] count Number of waiting threads to signal.
* @return Result code.
* @note Syscall number 0x35.
*/
Result svcSignalToAddress(void *address, u32 signal_type, s32 value, s32 count);
///@}
///@name Miscellaneous
///@{
/**
* @brief Sets thread preemption state (used during abort/panic). [8.0.0+]
* @note Syscall number 0x36.
*/
void svcSynchronizePreemptionState(void);
///@}
///@name Resource Limit Management
///@{
/**
* @brief Gets the peak value a LimitableResource has had, for a Resource Limit handle. [11.0.0+]
* @return Result code.
* @note Syscall number 0x37.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetResourceLimitPeakValue(s64 *out, Handle reslimit_h, LimitableResource which);
///@}
///@name Memory Management
///@{
/**
* @brief Creates an IO Pool. [13.0.0+]
* @return Result code.
* @note Syscall number 0x39.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcCreateIoPool(Handle *out_handle, u32 pool_type);
/**
* @brief Creates an IO Region. [13.0.0+]
* @return Result code.
* @note Syscall number 0x3A.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcCreateIoRegion(Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm);
///@}
///@name Debugging
///@{
/**
* @brief Causes the kernel to dump debug information. [1.0.0-3.0.2]
* @param[in] dump_info_type Type of information to dump.
* @param[in] arg0 Argument to the debugging operation.
* @note Syscall number 0x3C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcDumpInfo(u32 dump_info_type, u64 arg0);
/**
* @brief Performs a debugging operation on the kernel. [4.0.0+]
* @param[in] kern_debug_type Type of debugging operation to perform.
* @param[in] arg0 First argument to the debugging operation.
* @param[in] arg1 Second argument to the debugging operation.
* @param[in] arg2 Third argument to the debugging operation.
* @note Syscall number 0x3C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcKernelDebug(u32 kern_debug_type, u64 arg0, u64 arg1, u64 arg2);
/**
* @brief Performs a debugging operation on the kernel. [4.0.0+]
* @param[in] kern_trace_state Type of tracing the kernel should perform.
* @note Syscall number 0x3D.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcChangeKernelTraceState(u32 kern_trace_state);
///@}
\
///@name Inter-process communication (IPC)
///@{
@ -923,15 +620,6 @@ Result svcCreateSession(Handle *server_handle, Handle *client_handle, u32 unk0,
*/
Result svcAcceptSession(Handle *session_handle, Handle port_handle);
/**
* @brief Performs light IPC input/output.
* @return Result code.
* @param[in] handle Server or port handle to act on.
* @note Syscall number 0x42.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcReplyAndReceiveLight(Handle handle);
/**
* @brief Performs IPC input/output.
* @return Result code.
@ -966,22 +654,6 @@ Result svcCreateEvent(Handle* server_handle, Handle* client_handle);
///@name Memory management
///@{
/**
* @brief Maps an IO Region. [13.0.0+]
* @return Result code.
* @note Syscall number 0x46.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapIoRegion(Handle io_region_h, void *address, u64 size, u32 perm);
/**
* @brief Undoes the effects of \ref svcMapIoRegion. [13.0.0+]
* @return Result code.
* @note Syscall number 0x47.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcUnmapIoRegion(Handle io_region_h, void *address, u64 size);
/**
* @brief Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. [5.0.0+]
* @return Result code.
@ -1030,18 +702,6 @@ Result svcControlCodeMemory(Handle code_handle, CodeMapOperation op, void* dst_a
///@}
///@name Power Management
///@{
/**
* @brief Causes the system to enter deep sleep.
* @note Syscall number 0x4D.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcSleepSystem(void);
///@}
///@name Device memory-mapped I/O (MMIO)
///@{
@ -1055,19 +715,6 @@ Result svcReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal);
///@}
///@name Process and thread management
///@{
/**
* @brief Configures the pause/unpause status of a process.
* @return Result code.
* @note Syscall number 0x4F.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcSetProcessActivity(Handle process, ProcessActivity paused);
///@}
///@name Inter-process memory sharing
///@{
@ -1114,25 +761,15 @@ Result svcCreateInterruptEvent(Handle* handle, u64 irqNum, u32 flag);
* @note Syscall number 0x54.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcQueryPhysicalAddress(PhysicalMemoryInfo *out, u64 virtaddr);
Result svcQueryPhysicalAddress(u64 out[3], u64 virtaddr);
/**
* @brief Returns a virtual address mapped to a given IO range.
* @return Result code.
* @note Syscall number 0x55.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning Only exists on [10.0.0+]. For older versions use \ref svcLegacyQueryIoMapping.
*/
Result svcQueryMemoryMapping(u64* virtaddr, u64* out_size, u64 physaddr, u64 size);
/**
* @brief Returns a virtual address mapped to a given IO range.
* @return Result code.
* @note Syscall number 0x55.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning Only exists on [1.0.0-9.2.0]. For newer versions use \ref svcQueryMemoryMapping.
*/
Result svcLegacyQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size);
Result svcQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size);
///@}
@ -1170,7 +807,7 @@ Result svcDetachDeviceAddressSpace(u64 device, Handle handle);
* @note Syscall number 0x59.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option);
Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm);
/**
* @brief Maps an attached device address space to an userspace address.
@ -1179,16 +816,7 @@ Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 ma
* @note Syscall number 0x5A.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option);
/**
* @brief Maps an attached device address space to an userspace address. [1.0.0-12.1.0]
* @return Result code.
* @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set.
* @note Syscall number 0x5B.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapDeviceAddressSpace(u64 *out_mapped_size, Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm);
Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm);
/**
* @brief Unmaps an attached device address space from an userspace address.
@ -1200,38 +828,6 @@ Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_add
///@}
///@name Cache Management
///@{
/**
* @brief Invalidates data cache for a virtual address range within a process.
* @param[in] address Address of region to invalidate.
* @param[in] size Size of region to invalidate.
* @note Syscall number 0x5D.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcInvalidateProcessDataCache(Handle process, uintptr_t address, size_t size);
/**
* @brief Stores data cache for a virtual address range within a process.
* @param[in] address Address of region to store.
* @param[in] size Size of region to store.
* @note Syscall number 0x5E.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcStoreProcessDataCache(Handle process, uintptr_t address, size_t size);
/**
* @brief Flushes data cache for a virtual address range within a process.
* @param[in] address Address of region to flush.
* @param[in] size Size of region to flush.
* @note Syscall number 0x5F.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcFlushProcessDataCache(Handle process, uintptr_t address, size_t size);
///@}
///@name Debugging
///@{
@ -1265,14 +861,14 @@ Result svcTerminateDebugProcess(Handle debug);
* @note Syscall number 0x63.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetDebugEvent(void* event_out, Handle debug);
Result svcGetDebugEvent(u8* event_out, Handle debug);
/**
* @brief Continues a debugging session.
* @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 svcContinueDebugEventPre300.
*/
Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tids);
@ -1281,7 +877,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);
@ -1290,7 +886,7 @@ Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID);
* @return Result code.
* @param[out] ctx Output thread context (register dump).
* @param[in] debug Debug handle.
* @param[in] threadID ID of the thread to dump the context of.
* @param[in] threadId ID of the thread to dump the context of.
* @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
* @note Syscall number 0x67.
* @warning Official kernel will not dump any CPU GPR if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException).
@ -1302,7 +898,7 @@ Result svcGetDebugThreadContext(ThreadContext* ctx, Handle debug, u64 threadID,
* @brief Gets the context (dump the registers) of a thread in a debugging session.
* @return Result code.
* @param[in] debug Debug handle.
* @param[in] threadID ID of the thread to set the context of.
* @param[in] threadId ID of the thread to set the context of.
* @param[in] ctx Input thread context (register dump).
* @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
* @note Syscall number 0x68.
@ -1322,7 +918,7 @@ Result svcSetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext*
* @note Syscall number 0x65.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids);
Result svcGetProcessList(u32 *num_out, u64 *pids_out, u32 max_pids);
/**
* @brief Retrieves a list of all threads for a debug handle (or zero).
@ -1330,7 +926,7 @@ Result svcGetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids);
* @note Syscall number 0x66.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetThreadList(s32 *num_out, u64 *tids_out, u32 max_tids, Handle debug);
Result svcGetThreadList(u32 *num_out, u64 *tids_out, u32 max_tids, Handle debug);
///@}
@ -1361,14 +957,6 @@ Result svcReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size)
*/
Result svcWriteDebugProcessMemory(Handle debug, const void* buffer, u64 addr, u64 size);
/**
* @brief Sets one of the hardware breakpoints.
* @return Result code.
* @note Syscall number 0x6C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcSetHardwareBreakPoint(u32 which, u64 flags, u64 value);
/**
* @brief Gets parameters from a thread in a debugging session.
* @return Result code.
@ -1468,18 +1056,6 @@ Result svcMapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
*/
Result svcUnmapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
/**
* @brief Equivalent to \ref svcQueryMemory, for another process.
* @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in.
* @param[out] pageinfo Page information which will be filled in.
* @param[in] proc Process handle.
* @param[in] addr Address to query.
* @return Result code.
* @note Syscall number 0x76.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcQueryProcessMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, Handle proc, u64 addr);
/**
* @brief Maps normal heap in a certain process as executable code (used when loading NROs).
* @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE).
@ -1515,7 +1091,7 @@ Result svcUnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size);
* @note Syscall number 0x79.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcCreateProcess(Handle* out, const void* proc_info, const u32* caps, u64 cap_num);
Result svcCreateProcess(Handle* out, void* proc_info, u32* caps, u64 cap_num);
/**
* @brief Starts executing a freshly created process.
@ -1539,7 +1115,7 @@ Result svcTerminateProcess(Handle proc);
* @note Syscall number 0x7C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetProcessInfo(s64 *out, Handle proc, ProcessInfoType which);
Result svcGetProcessInfo(u64 *out, Handle proc, ProcessInfoType which);
///@}
@ -1570,28 +1146,10 @@ Result svcSetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u
/**
* @brief Calls a secure monitor function (TrustZone, EL3).
* @param regs Arguments to pass to the secure monitor.
* @return Return value from the secure monitor.
* @note Syscall number 0x7F.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcCallSecureMonitor(SecmonArgs* regs);
u64 svcCallSecureMonitor(SecmonArgs* regs);
///@}
///@name Memory management
///@{
/**
* @brief Maps new insecure memory at the desired address. [15.0.0+]
* @return Result code.
* @note Syscall number 0x90.
*/
Result svcMapInsecurePhysicalMemory(void *address, u64 size);
/**
* @brief Undoes the effects of \ref svcMapInsecureMemory. [15.0.0+]
* @return Result code.
* @note Syscall number 0x91.
*/
Result svcUnmapInsecurePhysicalMemory(void *address, u64 size);
///@}

View File

@ -10,15 +10,11 @@
#include "wait.h"
/// Thread information structure.
typedef struct Thread {
Handle handle; ///< Thread handle.
bool owns_stack_mem; ///< Whether the stack memory is automatically allocated.
void* stack_mem; ///< Pointer to stack memory.
void* stack_mirror; ///< Pointer to stack memory mirror.
size_t stack_sz; ///< Stack size.
void** tls_array;
struct Thread* next;
struct Thread** prev_next;
typedef struct {
Handle handle; ///< Thread handle.
void* stack_mem; ///< Pointer to stack memory.
void* stack_mirror; ///< Pointer to stack memory mirror.
size_t stack_sz; ///< Stack size.
} Thread;
/// Creates a \ref Waiter for a \ref Thread.
@ -32,15 +28,14 @@ static inline Waiter waiterForThread(Thread* t)
* @param t Thread information structure which will be filled in.
* @param entry Entrypoint of the thread.
* @param arg Argument to pass to the entrypoint.
* @param stack_mem Memory to use as backing for stack/tls/reent. Must be page-aligned. NULL argument means to allocate new memory.
* @param stack_sz If stack_mem is NULL, size to use for stack. If stack_mem is non-NULL, size to use for stack + reent + tls (must be page-aligned).
* @param stack_sz Stack size (rounded up to page alignment).
* @param prio Thread priority (0x00~0x3F); 0x2C is the usual priority of the main thread, 0x3B is a special priority on cores 0..2 that enables preemptive multithreading (0x3F on core 3).
* @param cpuid ID of the core on which to create the thread (0~3); or -2 to use the default core for the current process.
* @return Result code.
*/
Result threadCreate(
Thread* t, ThreadFunc entry, void* arg, void *stack_mem, size_t stack_sz,
int prio, int cpuid);
Thread* t, ThreadFunc entry, void* arg, size_t stack_sz, int prio,
int cpuid);
/**
* @brief Starts the execution of a thread.
@ -49,11 +44,6 @@ Result threadCreate(
*/
Result threadStart(Thread* t);
/**
* @brief Exits the current thread immediately.
*/
void NX_NORETURN threadExit(void);
/**
* @brief Waits for a thread to finish executing.
* @param t Thread information structure.
@ -91,41 +81,8 @@ Result threadResume(Thread* t);
*/
Result threadDumpContext(ThreadContext* ctx, Thread* t);
/**
* @brief Gets a pointer to the current thread structure.
* @return Thread information structure.
*/
Thread *threadGetSelf(void);
/**
* @brief Gets the raw handle to the current thread.
* @return The current thread's handle.
*/
Handle threadGetCurHandle(void);
/**
* @brief Allocates a TLS slot.
* @param destructor Function to run automatically when a thread exits.
* @return TLS slot ID on success, or a negative value on failure.
*/
s32 threadTlsAlloc(void (* destructor)(void*));
/**
* @brief Retrieves the value stored in a TLS slot.
* @param slot_id TLS slot ID.
* @return Value.
*/
void* threadTlsGet(s32 slot_id);
/**
* @brief Stores the specified value into a TLS slot.
* @param slot_id TLS slot ID.
* @param value Value.
*/
void threadTlsSet(s32 slot_id, void* value);
/**
* @brief Frees a TLS slot.
* @param slot_id TLS slot ID.
*/
void threadTlsFree(s32 slot_id);

View File

@ -72,21 +72,6 @@ static inline void* tmemGetAddr(TransferMemory* t){
return t->map_addr;
}
/**
* @brief Closes handle of a transfer memory object.
* @param t Transfer memory information structure.
* @return Result code.
*/
Result tmemCloseHandle(TransferMemory* t);
/**
* @brief Waits until source backing memory permissions match perm.
* @param t Transfer memory information structure.
* @param perm Permissions which the source backing memory is expected to have before return.
* @return Result code.
*/
Result tmemWaitForPermission(TransferMemory* t, Permission perm);
/**
* @brief Frees up resources used by a transfer memory object, unmapping and closing handles, etc.
* @param t Transfer memory information structure.

View File

@ -28,7 +28,7 @@ static inline Waiter waiterForUEvent(UEvent* e)
/**
* @brief Creates a user-mode event.
* @param[out] e UEvent object.
* @param[in] auto_clear Whether to automatically clear the event.
* @param[in] bool auto_clear Whether to automatically clear the event.
* @note It is safe to wait on this event with several threads simultaneously.
* @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees.
*/

View File

@ -7,55 +7,30 @@
#pragma once
#include "../types.h"
/// Address space reservation type (see \ref virtmemAddReservation)
typedef struct VirtmemReservation VirtmemReservation;
/// Locks the virtual memory manager mutex.
void virtmemLock(void);
/// Unlocks the virtual memory manager mutex.
void virtmemUnlock(void);
/**
* @brief Finds a random slice of free general purpose address space.
* @param size Desired size of the slice (rounded up to page alignment).
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
* @brief Reserves a slice of general purpose address space.
* @param size The size of the slice of address space that will be reserved (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
*/
void* virtmemFindAslr(size_t size, size_t guard_size);
void* virtmemReserve(size_t size);
/**
* @brief Finds a random slice of free stack address space.
* @param size Desired size of the slice (rounded up to page alignment).
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
*/
void* virtmemFindStack(size_t size, size_t guard_size);
/**
* @brief Finds a random slice of free code memory address space.
* @param size Desired size of the slice (rounded up to page alignment).
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
*/
void* virtmemFindCodeMemory(size_t size, size_t guard_size);
/**
* @brief Reserves a range of memory address space.
* @param mem Pointer to the address space slice.
* @brief Relinquishes a slice of address space reserved with virtmemReserve (currently no-op).
* @param addr Pointer to the slice.
* @param size Size of the slice.
* @return Pointer to a reservation object, or NULL on failure.
* @remark This function is intended to be used in lieu of a memory map operation when the memory won't be mapped straight away.
* @note The virtual memory manager mutex must be held during the find-and-reserve process (see \ref virtmemLock and \ref virtmemUnlock).
*/
VirtmemReservation* virtmemAddReservation(void* mem, size_t size);
void virtmemFree(void* addr, size_t size);
/**
* @brief Releases a memory address space reservation.
* @param rv Reservation to release.
* @note The virtual memory manager mutex must be held before calling this function (see \ref virtmemLock and \ref virtmemUnlock).
* @brief Reserves a slice of address space inside the stack memory mapping region (for use with svcMapMemory).
* @param size The size of the slice of address space that will be reserved (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
*/
void virtmemRemoveReservation(VirtmemReservation* rv);
void* virtmemReserveStack(size_t size);
/**
* @brief Relinquishes a slice of address space reserved with virtmemReserveStack (currently no-op).
* @param addr Pointer to the slice.
* @param size Size of the slice.
*/
void virtmemFreeStack(void* addr, size_t size);

View File

@ -12,83 +12,40 @@ typedef struct {
char author[0x100];
} NacpLanguageEntry;
/// ApplicationNeighborDetectionGroupConfiguration
typedef struct {
u64 group_id; ///< GroupId
u8 key[0x10];
} NacpApplicationNeighborDetectionGroupConfiguration;
NacpLanguageEntry lang[16];
/// NeighborDetectionClientConfiguration
typedef struct {
NacpApplicationNeighborDetectionGroupConfiguration send_group_configuration; ///< SendGroupConfiguration
NacpApplicationNeighborDetectionGroupConfiguration receivable_group_configurations[0x10]; ///< ReceivableGroupConfigurations
} NacpNeighborDetectionClientConfiguration;
u8 x3000_unk[0x24];////Normally all-zero?
u32 x3024_unk;
u32 x3028_unk;
u32 x302C_unk;
u32 x3030_unk;
u32 x3034_unk;
u64 titleID0;
/// ApplicationJitConfiguration
typedef struct {
u64 flags; ///< Flags
u64 memory_size; ///< MemorySize
} NacpApplicationJitConfiguration;
u8 x3040_unk[0x20];
char version[0x10];
/// ns ApplicationControlProperty
typedef struct {
NacpLanguageEntry lang[16]; ///< \ref NacpLanguageEntry
u8 isbn[0x25]; ///< Isbn
u8 startup_user_account; ///< StartupUserAccount
u8 user_account_switch_lock; ///< UserAccountSwitchLock
u8 add_on_content_registration_type; ///< AddOnContentRegistrationType
u32 attribute_flag; ///< AttributeFlag
u32 supported_language_flag; ///< SupportedLanguageFlag
u32 parental_control_flag; ///< ParentalControlFlag
u8 screenshot; ///< Screenshot
u8 video_capture; ///< VideoCapture
u8 data_loss_confirmation; ///< DataLossConfirmation
u8 play_log_policy; ///< PlayLogPolicy
u64 presence_group_id; ///< PresenceGroupId
s8 rating_age[0x20]; ///< RatingAge
char display_version[0x10]; ///< DisplayVersion
u64 add_on_content_base_id; ///< AddOnContentBaseId
u64 save_data_owner_id; ///< SaveDataOwnerId
u64 user_account_save_data_size; ///< UserAccountSaveDataSize
u64 user_account_save_data_journal_size; ///< UserAccountSaveDataJournalSize
u64 device_save_data_size; ///< DeviceSaveDataSize
u64 device_save_data_journal_size; ///< DeviceSaveDataJournalSize
u64 bcat_delivery_cache_storage_size; ///< BcatDeliveryCacheStorageSize
u64 application_error_code_category; ///< ApplicationErrorCodeCategory
u64 local_communication_id[0x8]; ///< LocalCommunicationId
u8 logo_type; ///< LogoType
u8 logo_handling; ///< LogoHandling
u8 runtime_add_on_content_install; ///< RuntimeAddOnContentInstall
u8 runtime_parameter_delivery; ///< RuntimeParameterDelivery
u8 reserved_x30f4[0x2]; ///< Reserved
u8 crash_report; ///< CrashReport
u8 hdcp; ///< Hdcp
u64 pseudo_device_id_seed; ///< SeedForPseudoDeviceId
char bcat_passphrase[0x41]; ///< BcatPassphrase
u8 startup_user_account_option; ///< StartupUserAccountOption
u8 reserved_for_user_account_save_data_operation[0x6]; ///< ReservedForUserAccountSaveDataOperation
u64 user_account_save_data_size_max; ///< UserAccountSaveDataSizeMax
u64 user_account_save_data_journal_size_max; ///< UserAccountSaveDataJournalSizeMax
u64 device_save_data_size_max; ///< DeviceSaveDataSizeMax
u64 device_save_data_journal_size_max; ///< DeviceSaveDataJournalSizeMax
u64 temporary_storage_size; ///< TemporaryStorageSize
u64 cache_storage_size; ///< CacheStorageSize
u64 cache_storage_journal_size; ///< CacheStorageJournalSize
u64 cache_storage_data_and_journal_size_max; ///< CacheStorageDataAndJournalSizeMax
u16 cache_storage_index_max; ///< CacheStorageIndexMax
u8 reserved_x318a[0x6]; ///< Reserved
u64 play_log_queryable_application_id[0x10]; ///< PlayLogQueryableApplicationId
u8 play_log_query_capability; ///< PlayLogQueryCapability
u8 repair_flag; ///< RepairFlag
u8 program_index; ///< ProgramIndex
u8 required_network_service_license_on_launch; ///< RequiredNetworkServiceLicenseOnLaunchFlag
u32 reserved_x3214; ///< Reserved
NacpNeighborDetectionClientConfiguration neighbor_detection_client_configuration; ///< NeighborDetectionClientConfiguration
NacpApplicationJitConfiguration jit_configuration; ///< JitConfiguration
u8 reserved_x33c0[0xc40]; ///< Reserved
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?
} 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.
/// If you're using ns you may want to use \ref nsGetApplicationDesiredLanguage instead.
Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry);

View File

@ -10,7 +10,6 @@ typedef struct {
Result nvFenceInit(void);
void nvFenceExit(void);
u32 nvFenceGetFd(void);
Result nvFenceWait(NvFence* f, s32 timeout_us);

View File

@ -7,10 +7,3 @@ void nvGpuExit(void);
const nvioctl_gpu_characteristics* nvGpuGetCharacteristics(void);
u32 nvGpuGetZcullCtxSize(void);
const nvioctl_zcull_info* nvGpuGetZcullInfo(void);
const u32* nvGpuGetTpcMasks(u32 *num_masks_out);
Result nvGpuZbcGetActiveSlotMask(u32 *out_slot, u32 *out_mask);
Result nvGpuZbcAddColor(const u32 color_l2[4], const u32 color_ds[4], u32 format);
Result nvGpuZbcAddDepth(float depth);
Result nvGpuGetTimestamp(u64 *ts);

View File

@ -18,14 +18,13 @@ typedef struct NvGpuChannel
u32 num_entries;
} NvGpuChannel;
Result nvGpuChannelCreate(NvGpuChannel* c, struct NvAddressSpace* as, NvChannelPriority prio);
Result nvGpuChannelCreate(NvGpuChannel* c, struct NvAddressSpace* as);
void nvGpuChannelClose(NvGpuChannel* c);
Result nvGpuChannelZcullBind(NvGpuChannel* c, iova_t iova);
Result nvGpuChannelAppendEntry(NvGpuChannel* c, iova_t start, size_t num_cmds, u32 flags, u32 flush_threshold);
Result nvGpuChannelKickoff(NvGpuChannel* c);
Result nvGpuChannelGetErrorNotification(NvGpuChannel* c, NvNotification* notif);
Result nvGpuChannelGetErrorInfo(NvGpuChannel* c, NvError* error);
Result nvGpuChannelGetErrorNotification(NvGpuChannel* c, NvError* error);
static inline u32 nvGpuChannelGetSyncpointId(NvGpuChannel* c)
{

View File

@ -44,29 +44,6 @@
#define __nv_out
#define __nv_inout
typedef struct {
u32 width_align_pixels; // 0x20 (32)
u32 height_align_pixels; // 0x20 (32)
u32 pixel_squares_by_aliquots; // 0x400 (1024)
u32 aliquot_total; // 0x800 (2048)
u32 region_byte_multiplier; // 0x20 (32)
u32 region_header_size; // 0x20 (32)
u32 subregion_header_size; // 0xC0 (192)
u32 subregion_width_align_pixels; // 0x20 (32)
u32 subregion_height_align_pixels; // 0x40 (64)
u32 subregion_count; // 0x10 (16)
} nvioctl_zcull_info;
typedef struct {
u32 color_ds[4];
u32 color_l2[4];
u32 depth;
u32 ref_cnt;
u32 format;
u32 type;
u32 size;
} nvioctl_zbc_entry;
typedef struct {
u32 arch; // 0x120 (NVGPU_GPU_ARCH_GM200)
u32 impl; // 0xB (NVGPU_GPU_IMPL_GM20B)
@ -113,14 +90,9 @@ typedef struct {
} nvioctl_va_region;
typedef struct {
u32 slot; // always 0x07 (?)
u32 mask;
} nvioctl_zbc_slot_mask;
typedef struct {
u64 timestamp;
u64 reserved;
} nvioctl_gpu_time;
u32 mask; // always 0x07
u32 flush; // active flush bit field
} nvioctl_l2_state;
typedef struct {
u32 id;
@ -134,45 +106,6 @@ typedef struct {
};
} nvioctl_gpfifo_entry;
typedef struct {
u32 mem;
u32 offset;
u32 words;
} nvioctl_cmdbuf;
typedef struct {
u32 cmdbuf_mem;
u32 cmdbuf_offset;
u32 target;
u32 target_offset;
} nvioctl_reloc;
typedef struct {
u32 shift;
} nvioctl_reloc_shift;
typedef struct {
u32 syncpt_id;
u32 syncpt_incrs;
u32 waitbase_id; // Always -1
u32 next; //< Next valid incr index, or -1
u32 prev; //< Previous valid incr index, or -1
} nvioctl_syncpt_incr;
typedef struct {
u32 handle;
u32 iova;
} nvioctl_command_buffer_map;
typedef struct {
u32 rate;
u32 moduleid;
} nvioctl_clk_rate;
#define NVGPU_ZBC_TYPE_INVALID 0
#define NVGPU_ZBC_TYPE_COLOR 1
#define NVGPU_ZBC_TYPE_DEPTH 2
// Used with nvioctlNvmap_Param().
typedef enum nvioctl_map_param {
NvMapParam_Size = 1,
@ -221,26 +154,21 @@ typedef enum {
} NvMapBufferFlags;
typedef enum {
NvNotificationType_FifoErrorIdleTimeout=8,
NvNotificationType_GrErrorSwNotify=13,
NvNotificationType_GrSemaphoreTimeout=24,
NvNotificationType_GrIllegalNotify=25,
NvNotificationType_FifoErrorMmuErrFlt=31,
NvNotificationType_PbdmaError=32,
NvNotificationType_ResetChannelVerifError=43,
NvNotificationType_PbdmaPushbufferCrcMismatch=80
} NvNotificationType;
NvErrorType_FifoErrorIdleTimeout=8,
NvErrorType_GrErrorSwNotify=13,
NvErrorType_GrSemaphoreTimeout=24,
NvErrorType_GrIllegalNotify=25,
NvErrorType_FifoErrorMmuErrFlt=31,
NvErrorType_PbdmaError=32,
NvErrorType_ResetChannelVerifError=43,
NvErrorType_PbdmaPushbufferCrcMismatch=80
} NvErrorType;
typedef struct {
u64 timestamp;
u32 info32; // see NvNotificationType
u16 info16;
u64 tickstamp;
u32 error_type;
u16 unk16;
u16 status; // always -1
} NvNotification;
typedef struct {
u32 type;
u32 info[31];
} NvError;
Result nvioctlNvhostCtrl_SyncptRead(u32 fd, u32 id, u32* out);
@ -253,13 +181,10 @@ Result nvioctlNvhostCtrl_EventRegister(u32 fd, u32 event_id);
Result nvioctlNvhostCtrl_EventUnregister(u32 fd, u32 event_id);
Result nvioctlNvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out);
Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, nvioctl_zcull_info *out);
Result nvioctlNvhostCtrlGpu_ZbcSetTable(u32 fd, const u32 color_ds[4], const u32 color_l2[4], u32 depth, u32 format, u32 type);
Result nvioctlNvhostCtrlGpu_ZbcQueryTable(u32 fd, u32 index, nvioctl_zbc_entry *out);
Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, u32 out[40>>2]);
Result nvioctlNvhostCtrlGpu_GetCharacteristics(u32 fd, nvioctl_gpu_characteristics *out);
Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, void *buffer, size_t size);
Result nvioctlNvhostCtrlGpu_ZbcGetActiveSlotMask(u32 fd, nvioctl_zbc_slot_mask *out);
Result nvioctlNvhostCtrlGpu_GetGpuTime(u32 fd, nvioctl_gpu_time *out);
Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, u32 inval, u32 out[24>>2]);
Result nvioctlNvhostCtrlGpu_GetL2State(u32 fd, nvioctl_l2_state *out);
Result nvioctlNvhostAsGpu_BindChannel(u32 fd, u32 channel_fd);
Result nvioctlNvhostAsGpu_AllocSpace(u32 fd, u32 pages, u32 page_size, u32 flags, u64 align_or_offset, u64 *offset);
@ -282,17 +207,8 @@ Result nvioctlChannel_KickoffPb(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_e
Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags, u64* id_out);
Result nvioctlChannel_ZCullBind(u32 fd, u64 gpu_va, u32 mode);
Result nvioctlChannel_SetErrorNotifier(u32 fd, u32 enable);
Result nvioctlChannel_GetErrorInfo(u32 fd, NvError* out);
Result nvioctlChannel_GetErrorNotification(u32 fd, NvNotification* out);
Result nvioctlChannel_GetErrorNotification(u32 fd, NvError* out);
Result nvioctlChannel_SetPriority(u32 fd, u32 priority);
Result nvioctlChannel_SetTimeout(u32 fd, u32 timeout);
Result nvioctlChannel_AllocGpfifoEx2(u32 fd, u32 num_entries, u32 flags, u32 unk0, u32 unk1, u32 unk2, u32 unk3, nvioctl_fence *fence_out);
Result nvioctlChannel_SetUserData(u32 fd, void* addr);
Result nvioctlChannel_Submit(u32 fd, const nvioctl_cmdbuf *cmdbufs, u32 num_cmdbufs, const nvioctl_reloc *relocs, const nvioctl_reloc_shift *reloc_shifts, u32 num_relocs,
const nvioctl_syncpt_incr *syncpt_incrs, u32 num_syncpt_incrs, nvioctl_fence *fences, u32 num_fences);
Result nvioctlChannel_GetSyncpt(u32 fd, u32 module_id, u32 *syncpt);
Result nvioctlChannel_GetModuleClockRate(u32 fd, u32 module_id, u32 *freq);
Result nvioctlChannel_SetModuleClockRate(u32 fd, u32 module_id, u32 freq);
Result nvioctlChannel_MapCommandBuffer(u32 fd, nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed);
Result nvioctlChannel_UnmapCommandBuffer(u32 fd, const nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed);
Result nvioctlChannel_SetSubmitTimeout(u32 fd, u32 timeout);

View File

@ -253,11 +253,8 @@ typedef enum {
typedef enum {
NvColorFormat_Unspecified = 0x0000000000UL,
NvColorFormat_NonColor8 = 0x0009200408UL,
NvColorFormat_NonColor16 = 0x0009200A10UL,
NvColorFormat_NonColor24 = 0x0009201A18UL,
NvColorFormat_NonColor32 = 0x0009201C20UL,
NvColorFormat_X4C4 = 0x0009210508UL,
NvColorFormat_A4L4 = 0x0100490508UL,
NvColorFormat_X4C4 = 0x0009200A10UL,
NvColorFormat_NonColor32 = 0x0100490508UL,
NvColorFormat_A8L8 = 0x0100490E10UL,
NvColorFormat_Float_A16L16 = 0x0100495D20UL,
NvColorFormat_A1B5G5R5 = 0x0100531410UL,

View File

@ -123,9 +123,6 @@ enum {
LibnxError_NvinfoFailedToInitialize,
LibnxError_NvbufFailedToInitialize,
LibnxError_LibAppletBadExit,
LibnxError_InvalidCmifOutHeader,
LibnxError_ShouldNotHappen,
LibnxError_Timeout,
};
/// libnx binder error codes

View File

@ -1,445 +0,0 @@
/**
* @file btdev.h
* @brief Wrapper around the bt/btmu services for using bluetooth BLE.
* @note Only available on [5.0.0+].
* @note See also: https://switchbrew.org/wiki/BTM_services
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/btdrv_types.h"
/// GattAttribute
typedef struct {
u8 type; ///< Type
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
u16 handle; ///< Handle
u32 connection_handle; ///< ConnectionHandle
} BtdevGattAttribute;
/// GattService
typedef struct {
BtdevGattAttribute attr; ///< \ref BtdevGattAttribute
u16 instance_id; ///< InstanceId
u16 end_group_handle; ///< EndGroupHandle
bool primary_service; ///< PrimaryService
} BtdevGattService;
/// GattCharacteristic
typedef struct {
BtdevGattAttribute attr; ///< \ref BtdevGattAttribute
u16 instance_id; ///< InstanceId
u8 properties; ///< Properties
u64 value_size; ///< Size of value.
u8 value[0x200]; ///< Value
} BtdevGattCharacteristic;
/// GattDescriptor
typedef struct {
BtdevGattAttribute attr; ///< \ref BtdevGattAttribute
u64 value_size; ///< Size of value.
u8 value[0x200]; ///< Value
} BtdevGattDescriptor;
/// Initialize bt/btmu.
Result btdevInitialize(void);
/// Exit bt/btmu.
void btdevExit(void);
/// Compares two \ref BtdrvGattAttributeUuid, returning whether these match.
bool btdevGattAttributeUuidIsSame(const BtdrvGattAttributeUuid *a, const BtdrvGattAttributeUuid *b);
/// Wrapper for \ref btmuAcquireBleScanEvent.
Result btdevAcquireBleScanEvent(Event* out_event);
/// Wrapper for \ref btmuGetBleScanFilterParameter.
Result btdevGetBleScanParameter(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out);
/// Wrapper for \ref btmuGetBleScanFilterParameter2.
Result btdevGetBleScanParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out);
/// Wrapper for \ref btdevStartBleScanGeneral.
Result btdevStartBleScanGeneral(BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuStopBleScanForGeneral.
Result btdevStopBleScanGeneral(void);
/**
* @brief Wrapper for \ref btmuGetBleScanResultsForGeneral and \ref btmuGetBleScanResultsForSmartDevice.
* @param[out] results Output array of \ref BtdrvBleScanResult.
* @param[in] count Size of the results array in entries.
* @param[out] total_out Total output entries.
*/
Result btdevGetBleScanResult(BtdrvBleScanResult *results, u8 count, u8 *total_out);
/// Wrapper for \ref btmuStartBleScanForPaired.
Result btdevEnableBleAutoConnection(BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuStopBleScanForPaired.
Result btdevDisableBleAutoConnection(void);
/// Wrapper for \ref btmuStartBleScanForSmartDevice.
Result btdevStartBleScanSmartDevice(const BtdrvGattAttributeUuid *uuid);
/// Wrapper for \ref btmuStopBleScanForSmartDevice.
Result btdevStopBleScanSmartDevice(void);
/// Wrapper for \ref btmuAcquireBleConnectionEvent.
Result btdevAcquireBleConnectionStateChangedEvent(Event* out_event);
/// Wrapper for \ref btmuBleConnect.
Result btdevConnectToGattServer(BtdrvAddress addr);
/// Wrapper for \ref btmuBleDisconnect.
Result btdevDisconnectFromGattServer(u32 connection_handle);
/// Wrapper for \ref btmuBleGetConnectionState.
Result btdevGetBleConnectionInfoList(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out);
/// Wrapper for \ref btmuAcquireBleServiceDiscoveryEvent.
Result btdevAcquireBleServiceDiscoveryEvent(Event* out_event);
/**
* @brief Wrapper for \ref btmuGetGattServices.
* @param[in] connection_handle ConnectionHandle
* @param[out] services Output array of \ref BtdevGattService.
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGetGattServices(u32 connection_handle, BtdevGattService *services, u8 count, u8 *total_out);
/**
* @brief Wrapper for \ref btmuGetGattService.
* @param[in] connection_handle ConnectionHandle
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] service \ref BtdevGattService
* @param[out] flag Whether a \ref BtdevGattService was returned.
*/
Result btdevGetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtdevGattService *service, bool *flag);
/// Wrapper for \ref btmuAcquireBlePairingEvent.
Result btdevAcquireBlePairingEvent(Event* out_event);
/// Wrapper for \ref btmuBlePairDevice.
Result btdevPairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuBleUnPairDevice.
Result btdevUnpairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuBleUnPairDevice2.
Result btdevUnpairGattServer2(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuBleGetPairedDevices.
Result btdevGetPairedGattServerAddress(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out);
/// Wrapper for \ref btmuAcquireBleMtuConfigEvent.
Result btdevAcquireBleMtuConfigEvent(Event* out_event);
/**
* @brief Wrapper for \ref btmuConfigureBleMtu.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] mtu MTU, must be 0x18-0x200.
*/
Result btdevConfigureBleMtu(u32 connection_handle, u16 mtu);
/// Wrapper for \ref btmuGetBleMtu.
Result btdevGetBleMtu(u32 connection_handle, u16 *out);
/// Wrapper for \ref btRegisterBleEvent.
Result btdevAcquireBleGattOperationEvent(Event* out_event);
/**
* @brief Wrapper for \ref btmuRegisterBleGattDataPath.
* @param[in] uuid \ref BtdrvGattAttributeUuid
*/
Result btdevRegisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid);
/**
* @brief Wrapper for \ref btmuUnregisterBleGattDataPath.
* @param[in] uuid \ref BtdrvGattAttributeUuid
*/
Result btdevUnregisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid);
/**
* @brief Wrapper for \ref btGetLeEventInfo.
* @param[out] out \ref BtdrvBleClientGattOperationInfo
*/
Result btdevGetGattOperationResult(BtdrvBleClientGattOperationInfo *out);
/**
* @brief Wrapper for \ref btLeClientReadCharacteristic.
* @note An error is thrown if the properties from \ref btdevGattCharacteristicGetProperties don't allow using this.
* @param c \ref BtdevGattCharacteristic
*/
Result btdevReadGattCharacteristic(BtdevGattCharacteristic *c);
/**
* @brief Wrapper for \ref btLeClientWriteCharacteristic.
* @note An error is thrown if the properties from \ref btdevGattCharacteristicGetProperties don't allow using this.
* @note This uses the Value from \ref btdevGattCharacteristicSetValue.
* @param c \ref BtdevGattCharacteristic
*/
Result btdevWriteGattCharacteristic(BtdevGattCharacteristic *c);
/**
* @brief Wrapper for \ref btLeClientRegisterNotification / \ref btLeClientDeregisterNotification.
* @note An error is thrown if the properties from \ref btdevGattCharacteristicGetProperties don't allow using this.
* @param c \ref BtdevGattCharacteristic
* @param[in] flag Whether to enable/disable, controls which func to call.
*/
Result btdevEnableGattCharacteristicNotification(BtdevGattCharacteristic *c, bool flag);
/**
* @brief Wrapper for \ref btLeClientReadDescriptor.
* @param d \ref BtdevGattDescriptor
*/
Result btdevReadGattDescriptor(BtdevGattDescriptor *d);
/**
* @brief Wrapper for \ref btLeClientWriteDescriptor.
* @note This uses the Value from \ref btdevGattDescriptorSetValue.
* @param d \ref BtdevGattDescriptor
*/
Result btdevWriteGattDescriptor(BtdevGattDescriptor *d);
///@name GattAttribute
///@{
/**
* @brief Creates a \ref BtdevGattAttribute object. This is intended for internal use.
* @param a \ref BtdevGattAttribute
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
*/
void btdevGattAttributeCreate(BtdevGattAttribute *a, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle);
/**
* @brief Gets the Type.
* @param a \ref BtdevGattAttribute
*/
NX_CONSTEXPR u8 btdevGattAttributeGetType(BtdevGattAttribute *a) {
return a->type;
}
/**
* @brief Gets the Uuid.
* @param a \ref BtdevGattAttribute
* @param[out] out \ref BtdrvGattAttributeUuid
*/
NX_CONSTEXPR void btdevGattAttributeGetUuid(BtdevGattAttribute *a, BtdrvGattAttributeUuid *out) {
*out = a->uuid;
}
/**
* @brief Gets the Handle.
* @param a \ref BtdevGattAttribute
*/
NX_CONSTEXPR u16 btdevGattAttributeGetHandle(BtdevGattAttribute *a) {
return a->handle;
}
/**
* @brief Gets the ConnectionHandle.
* @param a \ref BtdevGattAttribute
*/
NX_CONSTEXPR u32 btdevGattAttributeGetConnectionHandle(BtdevGattAttribute *a) {
return a->connection_handle;
}
///@}
///@name GattService
///@{
/**
* @brief Creates a \ref BtdevGattService object. This is intended for internal use.
* @param s \ref BtdevGattService
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
* @param[in] instance_id InstanceId
* @param[in] end_group_handle EndGroupHandle
* @param[in] primary_service PrimaryService
*/
void btdevGattServiceCreate(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u16 end_group_handle, bool primary_service);
/**
* @brief Gets the InstanceId.
* @param s \ref BtdevGattService
*/
NX_CONSTEXPR u16 btdevGattServiceGetInstanceId(BtdevGattService *s) {
return s->instance_id;
}
/**
* @brief Gets the EndGroupHandle.
* @param s \ref BtdevGattService
*/
NX_CONSTEXPR u16 btdevGattServiceGetEndGroupHandle(BtdevGattService *s) {
return s->end_group_handle;
}
/**
* @brief Gets whether this is the PrimaryService.
* @param s \ref BtdevGattService
*/
NX_CONSTEXPR u16 btdevGattServiceIsPrimaryService(BtdevGattService *s) {
return s->primary_service;
}
/**
* @brief Wrapper for \ref btmuGetGattIncludedServices.
* @param s \ref BtdevGattService
* @param[out] services Output array of \ref BtdevGattService.
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGattServiceGetIncludedServices(BtdevGattService *s, BtdevGattService *services, u8 count, u8 *total_out);
/**
* @brief Wrapper for \ref btmuGetGattCharacteristics.
* @param s \ref BtdevGattService
* @param[out] characteristics Output array of \ref BtdevGattCharacteristic.
* @param[in] count Size of the characteristics array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGattServiceGetCharacteristics(BtdevGattService *s, BtdevGattCharacteristic *characteristics, u8 count, u8 *total_out);
/**
* @brief Same as \ref btdevGattServiceGetCharacteristics except this only returns the \ref BtdevGattCharacteristic which contains a matching \ref BtdrvGattAttributeUuid.
* @param s \ref BtdevGattService
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] characteristic \ref BtdevGattCharacteristic
* @param[out] flag Whether a \ref BtdevGattService was returned.
*/
Result btdevGattServiceGetCharacteristic(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, BtdevGattCharacteristic *characteristic, bool *flag);
///@}
///@name GattCharacteristic
///@{
/**
* @brief Creates a \ref BtdevGattCharacteristic object. This is intended for internal use.
* @param c \ref BtdevGattCharacteristic
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
* @param[in] instance_id InstanceId
* @param[in] properties Properties
*/
void btdevGattCharacteristicCreate(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u8 properties);
/**
* @brief Gets the InstanceId.
* @param c \ref BtdevGattCharacteristic
*/
NX_CONSTEXPR u16 btdevGattCharacteristicGetInstanceId(BtdevGattCharacteristic *c) {
return c->instance_id;
}
/**
* @brief Gets the Properties.
* @param c \ref BtdevGattCharacteristic
*/
NX_CONSTEXPR u8 btdevGattCharacteristicGetProperties(BtdevGattCharacteristic *c) {
return c->properties;
}
/**
* @brief Wrapper for \ref btmuGetBelongingGattService.
* @note Gets the \ref BtdevGattService which belongs to this object.
* @param c \ref BtdevGattCharacteristic.
* @param[out] service \ref BtdevGattService
*/
Result btdevGattCharacteristicGetService(BtdevGattCharacteristic *c, BtdevGattService *service);
/**
* @brief Wrapper for \ref btmuGetGattDescriptors.
* @note Gets the descriptors which belongs to this object.
* @param c \ref BtdevGattCharacteristic
* @param[out] descriptors Output array of \ref BtdevGattDescriptor.
* @param[in] count Size of the descriptors array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGattCharacteristicGetDescriptors(BtdevGattCharacteristic *c, BtdevGattDescriptor *descriptors, u8 count, u8 *total_out);
/**
* @brief Same as \ref btdevGattCharacteristicGetDescriptors except this only returns a \ref BtdevGattDescriptor which contains a matching \ref BtdrvGattAttributeUuid.
* @param c \ref BtdevGattCharacteristic
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] descriptor \ref BtdevGattDescriptor
* @param[out] flag Whether a \ref BtdevGattDescriptor was returned.
*/
Result btdevGattCharacteristicGetDescriptor(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, BtdevGattDescriptor *descriptor, bool *flag);
/**
* @brief Sets the Value in the object.
* @note See also \ref btdevWriteGattCharacteristic.
* @param c \ref BtdevGattCharacteristic
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, max is 0x200.
*/
void btdevGattCharacteristicSetValue(BtdevGattCharacteristic *c, const void* buffer, size_t size);
/**
* @brief Gets the Value in the object, returns the copied value size.
* @param c \ref BtdevGattCharacteristic
* @param[out] buffer Output buffer.
* @param[in] size Output buffer size, max is 0x200.
*/
u64 btdevGattCharacteristicGetValue(BtdevGattCharacteristic *c, void* buffer, size_t size);
///@}
///@name GattDescriptor
///@{
/**
* @brief Creates a \ref BtdevGattDescriptor object. This is intended for internal use.
* @param d \ref BtdevGattDescriptor
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
*/
void btdevGattDescriptorCreate(BtdevGattDescriptor *d, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle);
/**
* @brief Wrapper for \ref btmuGetBelongingGattService.
* @note Gets the \ref BtdevGattService which belongs to this object.
* @param d \ref BtdevGattDescriptor
* @param[out] service \ref BtdevGattService
*/
Result btdevGattDescriptorGetService(BtdevGattDescriptor *d, BtdevGattService *service);
/**
* @brief Wrapper for \ref btmuGetGattCharacteristics.
* @note Gets the \ref BtdevGattCharacteristic which belongs to this object.
* @param d \ref BtdevGattDescriptor
* @param[out] characteristic \ref BtdevGattCharacteristic
*/
Result btdevGattDescriptorGetCharacteristic(BtdevGattDescriptor *d, BtdevGattCharacteristic *characteristic);
/**
* @brief Sets the Value in the object.
* @note See also \ref btdevWriteGattDescriptor.
* @param d \ref BtdevGattDescriptor
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, max is 0x200.
*/
void btdevGattDescriptorSetValue(BtdevGattDescriptor *d, const void* buffer, size_t size);
/**
* @brief Gets the Value in the object, returns the copied value size.
* @param d \ref BtdevGattDescriptor
* @param[out] buffer Output buffer.
* @param[in] size Output buffer size, max is 0x200.
*/
u64 btdevGattDescriptorGetValue(BtdevGattDescriptor *d, void* buffer, size_t size);
///@}

View File

@ -103,8 +103,8 @@ struct PrintConsole
int windowHeight; ///< Window height in characters
int tabSize; ///< Size of a tab
u16 fg; ///< Foreground color
u16 bg; ///< Background color
int fg; ///< Foreground color
int bg; ///< Background color
int flags; ///< Reverse/bright flags
bool consoleInitialised; ///< True if the console is initialized
@ -119,14 +119,13 @@ struct PrintConsole
#define CONSOLE_COLOR_REVERSE (1<<6) ///< Reversed color text
#define CONSOLE_CONCEAL (1<<7) ///< Concealed text
#define CONSOLE_CROSSED_OUT (1<<8) ///< Crossed out text
#define CONSOLE_FG_CUSTOM (1<<9) ///< Foreground custom color
#define CONSOLE_BG_CUSTOM (1<<10) ///< Background custom color
/// Console debug devices supported by libnx.
typedef enum {
debugDevice_NULL, ///< Swallows prints to stderr
debugDevice_SVC, ///< Outputs stderr debug statements using svcOutputDebugString, which can then be captured by interactive debuggers
debugDevice_CONSOLE, ///< Directs stderr debug statements to Switch console window
debugDevice_3DMOO = debugDevice_SVC,
} debugDevice;
/**

View File

@ -19,48 +19,14 @@ typedef struct
FsDir fd; ///< File descriptor
ssize_t index; ///< Current entry index
size_t size; ///< Current batch size
FsDirectoryEntry entry_data[32]; ///< Temporary storage for reading entries
} fsdev_dir_t;
/// Retrieves a pointer to temporary stage for reading entries
NX_CONSTEXPR FsDirectoryEntry* fsdevDirGetEntries(fsdev_dir_t *dir)
{
return (FsDirectoryEntry*)(void*)(dir+1);
}
/// Initializes and mounts the sdmc device if accessible.
/// Initializes and mounts the sdmc device if accessible. Also initializes current working directory to point to the folder containing the path to the executable (argv[0]), if it is provided by the environment.
Result fsdevMountSdmc(void);
/// Mounts the specified SaveData.
Result fsdevMountSaveData(const char *name, u64 application_id, AccountUid uid);
/// Mounts the specified SaveData as ReadOnly.
/// Only available on [2.0.0+].
Result fsdevMountSaveDataReadOnly(const char *name, u64 application_id, AccountUid uid);
/// Mounts the specified BcatSaveData.
Result fsdevMountBcatSaveData(const char *name, u64 application_id);
/// Mounts the specified DeviceSaveData.
Result fsdevMountDeviceSaveData(const char *name, u64 application_id);
/// Mounts the TemporaryStorage for the current process.
/// Only available on [3.0.0+].
Result fsdevMountTemporaryStorage(const char *name);
/// Mounts the specified CacheStorage.
/// Only available on [3.0.0+].
Result fsdevMountCacheStorage(const char *name, u64 application_id, u16 save_data_index);
/// Mounts the specified SystemSaveData.
Result fsdevMountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid);
/// Mounts the specified SystemBcatSaveData.
/// Only available on [4.0.0+].
Result fsdevMountSystemBcatSaveData(const char *name, u64 system_save_data_id);
/// Mounts the input fs with the specified device name. fsdev will handle closing the fs when required, including when fsdevMountDevice() fails.
/// Returns -1 when any errors occur.
/// Input device name string shouldn't exceed 31 characters, and shouldn't have a trailing colon.
int fsdevMountDevice(const char *name, FsFileSystem fs);
/// Unmounts the specified device.
@ -73,23 +39,11 @@ Result fsdevCommitDevice(const char *name);
/// Returns the FsFileSystem for the specified device. Returns NULL when the specified device isn't found.
FsFileSystem* fsdevGetDeviceFileSystem(const char *name);
/// Writes the FS-path to outpath (which has buffer size FS_MAX_PATH), for the input path (as used in stdio). The FsFileSystem is also written to device when not NULL.
int fsdevTranslatePath(const char *path, FsFileSystem** device, char *outpath);
/// Returns the FsFileSystem for the default device (SD card), if mounted. Used internally by romfs_dev.
FsFileSystem* fsdevGetDefaultFileSystem(void);
/// This calls fsFsSetConcatenationFileAttribute on the filesystem specified by the input path (as used in stdio).
Result fsdevSetConcatenationFileAttribute(const char *path);
// Uses \ref fsFsIsValidSignedSystemPartitionOnSdCard with the specified device.
Result fsdevIsValidSignedSystemPartitionOnSdCard(const char *name, bool *out);
/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio).
Result fsdevCreateFile(const char* path, size_t size, u32 flags);
/// Recursively deletes the directory specified by the input path (as used in stdio).
Result fsdevDeleteDirectoryRecursively(const char *path);
/// This calls fsFsSetArchiveBit on the filesystem specified by the input absolute path.
Result fsdevSetArchiveBit(const char *path);
/// Unmounts all devices and cleans up any resources used by the FS driver.
Result fsdevUnmountAll(void);
/// Retrieves the last native result code generated during a failed fsdev operation.
Result fsdevGetLastResult(void);

View File

@ -10,7 +10,6 @@
#include "../../types.h"
#include "../../services/fs.h"
#include "../../services/ncm_types.h"
/// RomFS header.
typedef struct
@ -51,72 +50,49 @@ typedef struct
uint8_t name[]; ///< Name. (UTF-8)
} romfs_file;
struct romfs_mount;
/**
* @brief Mounts the Application's RomFS.
* @param name Device mount name.
* @remark This function is intended to be used to access one's own RomFS.
* If the application is running as NRO, it mounts the embedded RomFS section inside the NRO.
* If on the other hand it's an NSO, it behaves identically to \ref romfsMountFromCurrentProcess.
* @param mount Output mount handle
*/
Result romfsMountSelf(const char *name);
Result romfsMount(struct romfs_mount **mount);
static inline Result romfsInit(void)
{
return romfsMount(NULL);
}
/**
* @brief Mounts RomFS from an open file.
* @param file FsFile of the RomFS image.
* @param offset Offset of the RomFS within the file.
* @param name Device mount name.
* @param mount Output mount handle
*/
Result romfsMountFromFile(FsFile file, u64 offset, const char *name);
Result romfsMountFromFile(FsFile file, u64 offset, struct romfs_mount **mount);
static inline Result romfsInitFromFile(FsFile file, u64 offset)
{
return romfsMountFromFile(file, offset, NULL);
}
/**
* @brief Mounts RomFS from an open storage.
* @param storage FsStorage of the RomFS image.
* @param offset Offset of the RomFS within the storage.
* @param name Device mount name.
* @param mount Output mount handle
*/
Result romfsMountFromStorage(FsStorage storage, u64 offset, const char *name);
Result romfsMountFromStorage(FsStorage storage, u64 offset, struct romfs_mount **mount);
static inline Result romfsInitFromStorage(FsStorage storage, u64 offset)
{
return romfsMountFromStorage(storage, offset, NULL);
}
/**
* @brief Mounts RomFS using the current process host program RomFS.
* @param name Device mount name.
*/
Result romfsMountFromCurrentProcess(const char *name);
/**
* @brief Mounts RomFS of a running program.
* @note Permission needs to be set in the NPDM.
* @param program_id ProgramId to mount.
* @param name Device mount name.
*/
Result romfsMountDataStorageFromProgram(u64 program_id, const char *name);
/**
* @brief Mounts RomFS from a file path in a mounted fsdev device.
* @param path File path.
* @param offset Offset of the RomFS within the file.
* @param name Device mount name.
*/
Result romfsMountFromFsdev(const char *path, u64 offset, const char *name);
/**
* @brief Mounts RomFS from SystemData.
* @param dataId SystemDataId to mount.
* @param storageId Storage ID to mount from.
* @param name Device mount name.
*/
Result romfsMountFromDataArchive(u64 dataId, NcmStorageId storageId, const char *name);
/// Bind the RomFS mount
Result romfsBind(struct romfs_mount *mount);
/// Unmounts the RomFS device.
Result romfsUnmount(const char *name);
/// Wrapper for \ref romfsMountSelf with the default "romfs" device name.
static inline Result romfsInit(void)
{
return romfsMountSelf("romfs");
}
/// Wrapper for \ref romfsUnmount with the default "romfs" device name.
Result romfsUnmount(struct romfs_mount *mount);
static inline Result romfsExit(void)
{
return romfsUnmount("romfs");
return romfsUnmount(NULL);
}

View File

@ -1,17 +1,12 @@
#pragma once
#include "../../types.h"
/// BSD service type used by the socket driver.
typedef enum {
BsdServiceType_User = BIT(0), ///< Uses bsd:u (default).
BsdServiceType_System = BIT(1), ///< Uses bsd:s.
BsdServiceType_Auto = BsdServiceType_User | BsdServiceType_System, ///< Tries to use bsd:s first, and if that fails uses bsd:u (official software behavior).
} BsdServiceType;
/// Configuration structure for socketInitalize
typedef struct {
u32 bsdsockets_version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.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 receive buffer (initial or fixed).
u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed).
u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value.
u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value.
@ -20,8 +15,10 @@ typedef struct {
u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8).
u32 num_bsd_sessions; ///< Number of BSD service sessions (typically 3).
BsdServiceType bsd_service_type; ///< BSD service type (typically \ref BsdServiceType_User).
size_t serialized_out_addrinfos_max_size; ///< For getaddrinfo.
size_t serialized_out_hostent_max_size; ///< For gethostbyname/gethostbyaddr.
bool bypass_nsd; ///< For name gethostbyname/getaddrinfo: bypass the Name Server Daemon.
int dns_timeout; ///< For DNS requests: timeout or 0.
} SocketInitConfig;
/// Fetch the default configuration for the socket driver.
@ -29,30 +26,14 @@ const SocketInitConfig *socketGetDefaultInitConfig(void);
/// Initalize the socket driver.
Result socketInitialize(const SocketInitConfig *config);
/// Fetch the last bsd:u/s Switch result code (thread-local).
Result socketGetLastResult(void);
Result socketGetLastBsdResult(void);
/// Fetch the last sfdnsres Switch result code (thread-local).
Result socketGetLastSfdnsresResult(void);
/// Deinitialize the socket driver.
void socketExit(void);
/// Initalize the socket driver using the default configuration.
NX_INLINE Result socketInitializeDefault(void) {
return socketInitialize(NULL);
static inline Result socketInitializeDefault(void) {
return socketInitialize(socketGetDefaultInitConfig());
}
/// Wrapper for \ref sslConnectionSetSocketDescriptor. Returns the output sockfd on success and -1 on error. errno==ENOENT indicates that no sockfd was returned, this error must be ignored.
int socketSslConnectionSetSocketDescriptor(SslConnection *c, int sockfd);
/// Wrapper for \ref sslConnectionGetSocketDescriptor. Returns the output sockfd on success and -1 on error.
int socketSslConnectionGetSocketDescriptor(SslConnection *c);
#ifdef _SOCKLEN_T_DECLARED
struct sockaddr;
/// Wrapper for \ref sslConnectionSetDtlsSocketDescriptor. Returns the output sockfd on success and -1 on error. errno==ENOENT indicates that no sockfd was returned, this error must be ignored.
int socketSslConnectionSetDtlsSocketDescriptor(SslConnection *c, int sockfd, const struct sockaddr *addr, socklen_t addrlen);
#endif
/// Wrapper for \ref nifmRequestRegisterSocketDescriptor. Returns 0 on success and -1 on error.
int socketNifmRequestRegisterSocketDescriptor(NifmRequest* r, int sockfd);
/// Wrapper for \ref nifmRequestUnregisterSocketDescriptor. Returns 0 on success and -1 on error.
int socketNifmRequestUnregisterSocketDescriptor(NifmRequest* r, int sockfd);

View File

@ -18,7 +18,7 @@ typedef struct {
Result usbCommsInitialize(void);
/// Initializes usbComms with a specific number of interfaces.
Result usbCommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos, u16 idVendor, u16 idProduct);
Result usbCommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos);
/// Exits usbComms.
void usbCommsExit(void);
@ -26,9 +26,6 @@ void usbCommsExit(void);
/// Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferred size. By default (false) the latter is used.
void usbCommsSetErrorHandling(bool flag);
///@name Synchronous API
///@{
/// Read data with the default interface.
size_t usbCommsRead(void* buffer, size_t size);
@ -40,31 +37,3 @@ size_t usbCommsReadEx(void* buffer, size_t size, u32 interface);
/// Same as usbCommsWrite except with the specified interface.
size_t usbCommsWriteEx(const void* buffer, size_t size, u32 interface);
///@}
///@name Asynchronous API
///@{
/// Retrieve event used for read completion with the given interface.
Event *usbCommsGetReadCompletionEvent(u32 interface);
/// Start an asynchronous read. The completion event will be signaled when the read completes.
/// The buffer must be page-aligned and no larger than one page.
Result usbCommsReadAsync(void *buffer, size_t size, u32 *urbId, u32 interface);
/// Complete an asynchronous read, clearing the completion event, and return the amount of data which was read.
Result usbCommsGetReadResult(u32 urbId, u32 *transferredSize, u32 interface);
/// Retrieve event used for write completion with the given interface.
Event *usbCommsGetWriteCompletionEvent(u32 interface);
/// Start an asynchronous write. The completion event will be signaled when the write completes.
/// The buffer must be page-aligned and no larger than one page.
Result usbCommsWriteAsync(void *buffer, size_t size, u32 *urbId, u32 interface);
/// Complete an asynchronous write, clearing the completion event, and return the amount of data which was written.
Result usbCommsGetWriteResult(u32 urbId, u32 *transferredSize, u32 interface);
///@}

View File

@ -1,15 +0,0 @@
/**
* @file diag.h
* @brief Debugging and diagnostics utilities
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
/**
* @brief Aborts program execution with a result code.
* @param[in] res Result code.
*/
void NX_NORETURN diagAbortWithResult(Result res);

View File

@ -6,7 +6,6 @@
*/
#pragma once
#include "../types.h"
#include "../services/acc.h"
/// Structure representing an entry in the homebrew environment configuration.
typedef struct {
@ -28,16 +27,13 @@ enum {
EntryType_OverrideHeap=3, ///< Provides heap override information.
EntryType_OverrideService=4, ///< Provides service override information.
EntryType_Argv=5, ///< Provides argv.
EntryType_SyscallAvailableHint=6, ///< Provides syscall availability hints (SVCs 0x00..0x7F).
EntryType_SyscallAvailableHint=6, ///< Provides syscall availability hints.
EntryType_AppletType=7, ///< Provides APT applet type.
EntryType_AppletWorkaround=8, ///< Indicates that APT is broken and should not be used.
EntryType_Reserved9=9, ///< Unused/reserved entry type, formerly used by StdioSockets.
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.
EntryType_SyscallAvailableHint2=17, ///< Provides syscall availability hints (SVCs 0x80..0xBF).
};
enum {
@ -45,7 +41,7 @@ enum {
};
/// Loader return function.
typedef void NX_NORETURN (*LoaderReturnFn)(int result_code);
typedef void NORETURN (*LoaderReturnFn)(int result_code);
/**
* @brief Parses the homebrew loader environment block (internally called).
@ -55,11 +51,6 @@ typedef void NX_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.
@ -82,7 +73,7 @@ void* envGetArgv(void);
* @param svc Syscall number to test.
* @returns true if the syscall is available.
*/
bool envIsSyscallHinted(unsigned svc);
bool envIsSyscallHinted(u8 svc);
/// Returns the handle to the running homebrew process.
Handle envGetOwnProcessHandle(void);
@ -114,6 +105,3 @@ 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).
AccountUid* envGetUserIdStorage(void);

View File

@ -1,45 +0,0 @@
/**
* @file hosversion.h
* @brief Horizon OS (HOS) version detection utilities.
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Builds a HOS version value from its constituent components.
#define MAKEHOSVERSION(_major,_minor,_micro) (((u32)(_major) << 16) | ((u32)(_minor) << 8) | (u32)(_micro))
/// Extracts the major number from a HOS version value.
#define HOSVER_MAJOR(_version) (((_version) >> 16) & 0xFF)
/// Extracts the minor number from a HOS version value.
#define HOSVER_MINOR(_version) (((_version) >> 8) & 0xFF)
/// Extracts the micro number from a HOS version value.
#define HOSVER_MICRO(_version) ( (_version) & 0xFF)
/// Returns the current HOS version that was previously set with \ref hosversionSet. If version initialization fails during startup (such as in the case set:sys is not available), this function returns zero.
u32 hosversionGet(void);
/// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup with the version info obtained with \ref setsysGetFirmwareVersion.
void hosversionSet(u32 version);
/// Returns whether the current HOS version is augmented by running the Atmosphère custom firmware.
bool hosversionIsAtmosphere(void);
/// Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) {
return hosversionGet() >= MAKEHOSVERSION(major,minor,micro);
}
/// Returns true if the current HOS version is earlier than the specified major/minor/micro version.
static inline bool hosversionBefore(u8 major, u8 minor, u8 micro) {
return !hosversionAtLeast(major, minor, micro);
}
/// Returns true if the current HOS version is between the two specified major versions, i.e. [major1, major2).
static inline bool hosversionBetween(u8 major1, u8 major2) {
u32 ver = hosversionGet();
return ver >= MAKEHOSVERSION(major1,0,0) && ver < MAKEHOSVERSION(major2,0,0);
}

View File

@ -1,35 +1,10 @@
/**
* @file nxlink.h
* @brief Netloader (nxlink) utilities
* @author WinterMute
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
struct in_addr;
/// Address of the host connected through nxlink
extern struct in_addr __nxlink_host;
#define NXLINK_SERVER_PORT 28280 ///< nxlink TCP server port
#define NXLINK_CLIENT_PORT 28771 ///< nxlink TCP client port
#define NXLINK_SERVER_PORT 28280
#define NXLINK_CLIENT_PORT 28771
/**
* @brief Connects to the nxlink host, setting up an output stream.
* @param[in] redirStdout Whether to redirect stdout to nxlink output.
* @param[in] redirStderr Whether to redirect stderr to nxlink output.
* @return Socket fd on success, negative number on failure.
* @note The socket should be closed with close() during application cleanup.
*/
int nxlinkConnectToHost(bool redirStdout, bool redirStderr);
/// Same as \ref nxlinkConnectToHost but redirecting both stdout/stderr.
NX_INLINE int nxlinkStdio(void) {
return nxlinkConnectToHost(true, true);
}
/// Same as \ref nxlinkConnectToHost but redirecting only stderr.
NX_INLINE int nxlinkStdioForDebug(void) {
return nxlinkConnectToHost(false, true);
}
int nxlinkStdio(void);

View File

@ -1,224 +0,0 @@
/**
* @file pad.h
* @brief Simple wrapper for the HID Npad API.
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/hid.h"
/// Mask including all existing controller IDs.
#define PAD_ANY_ID_MASK 0x1000100FFUL
/// Pad state object.
typedef struct {
u8 id_mask;
u8 active_id_mask;
bool read_handheld;
bool active_handheld;
u32 style_set;
u32 attributes;
u64 buttons_cur;
u64 buttons_old;
HidAnalogStickState sticks[2];
u32 gc_triggers[2];
} PadState;
/// Pad button repeater state object.
typedef struct {
u64 button_mask;
s32 counter;
u16 delay;
u16 repeat;
} PadRepeater;
/**
* @brief Configures the input layout supported by the application.
* @param[in] max_players The maximum supported number of players (1 to 8).
* @param[in] style_set Bitfield of supported controller styles (see \ref HidNpadStyleTag).
*/
void padConfigureInput(u32 max_players, u32 style_set);
/**
* @brief Initializes a \ref PadState object to read input from one or more controller input sources.
* @param[in] _pad Pointer to \ref PadState.
* @remarks This is a variadic macro, pass the \ref HidNpadIdType value of each controller to add to the set.
*/
#define padInitialize(_pad, ...) ({ \
const HidNpadIdType _pad_ids[] = { __VA_ARGS__ }; \
u64 _pad_mask = 0; \
for (unsigned _pad_i = 0; _pad_i < (sizeof(_pad_ids)/sizeof(_pad_ids[0])); ++_pad_i) \
_pad_mask |= 1UL << (_pad_ids[_pad_i]); \
padInitializeWithMask((_pad), _pad_mask); \
})
/**
* @brief Same as \ref padInitialize, but taking a bitfield of controller IDs directly.
* @param[in] pad Pointer to \ref PadState.
* @param[in] mask Bitfield of controller IDs (each bit's position indicates a different \ref HidNpadIdType value).
*/
void padInitializeWithMask(PadState* pad, u64 mask);
/**
* @brief Same as \ref padInitialize, but including every single controller input source.
* @param[in] pad Pointer to \ref PadState.
* @remark Use this function if you want to accept input from any controller.
*/
NX_INLINE void padInitializeAny(PadState* pad) {
padInitializeWithMask(pad, PAD_ANY_ID_MASK);
}
/**
* @brief Same as \ref padInitialize, but including \ref HidNpadIdType_No1 and \ref HidNpadIdType_Handheld.
* @param[in] pad Pointer to \ref PadState.
* @remark Use this function if you just want to accept input for a single-player application.
*/
NX_INLINE void padInitializeDefault(PadState* pad) {
padInitialize(pad, HidNpadIdType_No1, HidNpadIdType_Handheld);
}
/**
* @brief Updates pad state by reading from the controller input sources specified during initialization.
* @param[in] pad Pointer to \ref PadState.
*/
void padUpdate(PadState* pad);
/**
* @brief Retrieves whether \ref HidNpadIdType_Handheld is an active input source (i.e. it was possible to read from it).
* @param[in] pad Pointer to \ref PadState.
* @return Boolean value.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR bool padIsHandheld(const PadState* pad) {
return pad->active_handheld;
}
/**
* @brief Retrieves whether the specified controller is an active input source (i.e. it was possible to read from it).
* @param[in] pad Pointer to \ref PadState.
* @param[in] id ID of the controller input source (see \ref HidNpadIdType)
* @return Boolean value.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR bool padIsNpadActive(const PadState* pad, HidNpadIdType id) {
if (id <= HidNpadIdType_No8)
return pad->active_id_mask & BIT(id);
else if (id == HidNpadIdType_Handheld)
return pad->active_handheld;
else
return false;
}
/**
* @brief Retrieves the set of input styles supported by the selected controller input sources.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadStyleTag.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u32 padGetStyleSet(const PadState* pad) {
return pad->style_set;
}
/**
* @brief Retrieves the set of attributes reported by the system for the selected controller input sources.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadAttribute.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u32 padGetAttributes(const PadState* pad) {
return pad->attributes;
}
/**
* @brief Retrieves whether any of the selected controller input sources is connected.
* @param[in] pad Pointer to \ref PadState.
* @return Boolean value.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR bool padIsConnected(const PadState* pad) {
return pad->attributes & HidNpadAttribute_IsConnected;
}
/**
* @brief Retrieves the current set of pressed buttons across all selected controller input sources.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadButton.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u64 padGetButtons(const PadState* pad) {
return pad->buttons_cur;
}
/**
* @brief Retrieves the set of buttons that are newly pressed.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadButton.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u64 padGetButtonsDown(const PadState* pad) {
return ~pad->buttons_old & pad->buttons_cur;
}
/**
* @brief Retrieves the set of buttons that are newly released.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadButton.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u64 padGetButtonsUp(const PadState* pad) {
return pad->buttons_old & ~pad->buttons_cur;
}
/**
* @brief Retrieves the position of an analog stick in a controller.
* @param[in] pad Pointer to \ref PadState.
* @param[in] i ID of the analog stick to read (0=left, 1=right).
* @return \ref HidAnalogStickState.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR HidAnalogStickState padGetStickPos(const PadState* pad, unsigned i) {
return pad->sticks[i];
}
/**
* @brief Retrieves the position of an analog trigger in a GameCube controller.
* @param[in] pad Pointer to \ref PadState.
* @param[in] i ID of the analog trigger to read (0=left, 1=right).
* @return Analog trigger position (range is 0 to 0x7fff).
* @remark \ref padUpdate must have been previously called.
* @remark \ref HidNpadStyleTag_NpadGc must have been previously configured as a supported style in \ref padConfigureInput for GC trigger data to be readable.
*/
NX_CONSTEXPR u32 padGetGcTriggerPos(const PadState* pad, unsigned i) {
return pad->gc_triggers[i];
}
/**
* @brief Initializes a \ref PadRepeater object with the specified settings.
* @param[in] r Pointer to \ref PadRepeater.
* @param[in] delay Number of input updates between button presses being first detected and them being considered for repeat.
* @param[in] repeat Number of input updates between autogenerated repeat button presses.
*/
NX_CONSTEXPR void padRepeaterInitialize(PadRepeater* r, u16 delay, u16 repeat) {
r->button_mask = 0;
r->counter = 0;
r->delay = delay;
r->repeat = repeat;
}
/**
* @brief Updates pad repeat state.
* @param[in] r Pointer to \ref PadRepeater.
* @param[in] button_mask Bitfield of currently pressed \ref HidNpadButton that will be considered for repeat.
*/
void padRepeaterUpdate(PadRepeater* r, u64 button_mask);
/**
* @brief Retrieves the set of buttons that are being repeated according to the parameters specified in \ref padRepeaterInitialize.
* @param[in] r Pointer to \ref PadRepeater.
* @return Bitfield of \ref HidNpadButton.
* @remark It is suggested to bitwise-OR the return value of this function with that of \ref padGetButtonsDown.
*/
NX_CONSTEXPR u64 padRepeaterGetButtons(const PadRepeater* r) {
return r->counter == 0 ? r->button_mask : 0;
}

View File

@ -1,29 +0,0 @@
#pragma once
#include "../types.h"
/// Fetches the last resolver Switch result code of the current thread.
Result resolverGetLastResult(void);
/// Retrieves a handle used to cancel the next resolver command on the current thread.
u32 resolverGetCancelHandle(void);
/// Retrieves whether service discovery is enabled for resolver commands on the current thread.
bool resolverGetEnableServiceDiscovery(void);
/// [5.0.0+] Retrieves whether the DNS cache is used to resolve queries on the current thread (not implemented).
bool resolverGetEnableDnsCache(void);
/// Enables or disables service discovery for the current thread.
void resolverSetEnableServiceDiscovery(bool enable);
/// [5.0.0+] Enables or disables the usage of the DNS cache on the current thread (not implemented).
void resolverSetEnableDnsCache(bool enable);
/// Cancels a previous resolver command (handle obtained with \ref resolverGetCancelHandle prior to calling the command).
Result resolverCancel(u32 handle);
/// [5.0.0+] Removes a hostname from the DNS cache (not implemented).
Result resolverRemoveHostnameFromCache(const char* hostname);
/// [5.0.0+] Removes an IP address from the DNS cache (not implemented).
Result resolverRemoveIpAddressFromCache(u32 ip);

View File

@ -1,257 +0,0 @@
/**
* @file ringcon.h
* @brief Wrapper for using the Ring-Con attached to a Joy-Con, with hidbus. See also: https://switchbrew.org/wiki/Ring-Con
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/hidbus.h"
#define RINGCON_CAL_MAGIC -0x3502 // 0xCAFE
/// Whether the output data is valid.
typedef enum {
RingConDataValid_Ok = 0, ///< Valid.
RingConDataValid_CRC = 1, ///< Bad CRC.
RingConDataValid_Cal = 2, ///< Only used with \ref ringconReadUserCal. Calibration is needed via \ref ringconUpdateUserCal.
} RingConDataValid;
typedef enum {
RingConErrorFlag_BadUserCalUpdate = 0, ///< The output from \ref ringconReadUserCal doesn't match the input used with \ref ringconWriteUserCal, or the \ref RingConDataValid is not ::RingConDataValid_Ok.
RingConErrorFlag_BadFlag = 4, ///< The output flag from \ref ringconCmdx00020105 when successful is invalid.
RingConErrorFlag_BadUserCal = 5, ///< BadUserCal
RingConErrorFlag_BadManuCal = 6, ///< BadManuCal
} RingConErrorFlag;
/// Ring-Con firmware version.
typedef struct {
u8 fw_main_ver; ///< Main firmware version.
u8 fw_sub_ver; ///< Sub firmware version.
} RingConFwVersion;
/// Ring-Con manufacturer calibration.
typedef struct {
s16 os_max; ///< (manu_)os_max
s16 hk_max; ///< (manu_)hk_max
s16 zero_min; ///< (manu_)zero_min
s16 zero_max; ///< (manu_)zero_max
} RingConManuCal;
/// Ring-Con user calibration.
typedef struct {
s16 os_max; ///< (user_)os_max
s16 hk_max; ///< (user_)hk_max
s16 zero; ///< (user_)zero
RingConDataValid data_valid; ///< \ref RingConDataValid
} RingConUserCal;
/// Polling data extracted from \ref HidbusJoyPollingReceivedData.
typedef struct {
s16 data; ///< Sensor state data.
u64 sampling_number; ///< SamplingNumber
} RingConPollingData;
/// Ring-Con state object.
typedef struct {
bool bus_initialized;
HidbusBusHandle handle;
void* workbuf;
size_t workbuf_size;
u64 polling_last_sampling_number;
u32 error_flags;
u64 id_l, id_h;
RingConFwVersion fw_ver;
u32 flag;
s16 unk_cal;
s32 total_push_count;
RingConManuCal manu_cal;
RingConUserCal user_cal;
} RingCon;
/**
* @brief Creates a \ref RingCon object, and handles the various initialization for it.
* @param c \ref RingCon
* @param[in] id \ref HidNpadIdType. A Ring-Con must be attached to this controller.
*/
Result ringconCreate(RingCon *c, HidNpadIdType id);
/**
* @brief Close a \ref RingCon.
* @param c \ref RingCon
*/
void ringconClose(RingCon *c);
/**
* @brief Gets the error flags field.
* @param c \ref RingCon
*/
NX_CONSTEXPR u32 ringconGetErrorFlags(RingCon *c) {
return c->error_flags;
}
/**
* @brief Gets the value of an error flag, set by \ref ringconSetErrorFlag.
* @param c \ref RingCon
* @param[in] flag \ref RingConErrorFlag
*/
NX_CONSTEXPR bool ringconGetErrorFlag(RingCon *c, RingConErrorFlag flag) {
return (c->error_flags & BIT(flag)) != 0;
}
/**
* @brief Gets the \ref RingConFwVersion previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out \ref RingConFwVersion
*/
NX_CONSTEXPR RingConFwVersion ringconGetFwVersion(RingCon *c) {
return c->fw_ver;
}
/**
* @brief Gets the Id previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] id_l Id low.
* @param[out] id_h Id high.
*/
NX_CONSTEXPR void ringconGetId(RingCon *c, u64 *id_l, u64 *id_h) {
*id_l = c->id_l;
*id_h = c->id_h;
}
/**
* @brief Gets the unk_cal previously loaded by \ref ringconCreate with \ref ringconReadUnkCal. Only valid when the output flag from \ref ringconCmdx00020105 is valid.
* @param c \ref RingCon
*/
NX_CONSTEXPR s16 ringconGetUnkCal(RingCon *c) {
return c->unk_cal;
}
/**
* @brief Gets the total-push-count previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out total_push_count
*/
NX_CONSTEXPR s32 ringconGetTotalPushCount(RingCon *c) {
return c->total_push_count;
}
/**
* @brief Gets the \ref RingConManuCal previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out \ref RingConManuCal
*/
NX_CONSTEXPR void ringconGetManuCal(RingCon *c, RingConManuCal *out) {
*out = c->manu_cal;
}
/**
* @brief Gets the \ref RingConUserCal previously loaded by \ref ringconCreate.
* @note The Ring-Con UserCal doesn't seem to be calibrated normally?
* @param c \ref RingCon
* @param[out] out \ref RingConUserCal
*/
NX_CONSTEXPR void ringconGetUserCal(RingCon *c, RingConUserCal *out) {
*out = c->user_cal;
}
/**
* @brief Updates the \ref RingConUserCal.
* @note The input \ref RingConUserCal is used with \ref ringconWriteUserCal, and the output from \ref ringconReadUserCal is verified with the input \ref RingConUserCal. This does not update the \ref RingConUserCal returned by \ref ringconGetUserCal.
* @note The Ring-Con UserCal doesn't seem to be calibrated normally?
* @param c \ref RingCon
* @param[in] cal \ref RingConUserCal
*/
Result ringconUpdateUserCal(RingCon *c, RingConUserCal cal);
/**
* @brief Reads the \ref RingConFwVersion.
* @note This is used internally by \ref ringconCreate. Normally you should use \ref ringconGetFwVersion instead.
* @param c \ref RingCon
* @param[out] out \ref RingConFwVersion
*/
Result ringconReadFwVersion(RingCon *c, RingConFwVersion *out);
/**
* @brief Reads the Id.
* @note This is used internally by \ref ringconCreate. Normally you should use \ref ringconGetId instead.
* @param c \ref RingCon
* @param[out] id_l Id low.
* @param[out] id_h Id high.
*/
Result ringconReadId(RingCon *c, u64 *id_l, u64 *id_h);
/**
* @brief Gets the \ref RingConPollingData. Only returns entries which are new since the last time this was called (or if not previously called, all available entries up to count).
* @param c \ref RingCon
* @param[out] out Output array of \ref RingConPollingData. Entry order is newest -> oldest.
* @param[in] count Total size of the out array in entries, max value is 0x9.
* @param[out] total_out Total output entries.
*/
Result ringconGetPollingData(RingCon *c, RingConPollingData *out, s32 count, s32 *total_out);
/**
* @brief Uses cmd 0x00020105.
* @note Used internally by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out Output value.
*/
Result ringconCmdx00020105(RingCon *c, u32 *out);
/**
* @brief Reads the \ref RingConManuCal.
* @note Used internally by \ref ringconCreate and \ref ringconReadUnkCal.
* @param c \ref RingCon
* @param[out] out \ref RingConManuCal
*/
Result ringconReadManuCal(RingCon *c, RingConManuCal *out);
/**
* @brief Gets the unknown value derived from the output of cmd 0x00020504 and \ref ringconReadManuCal.
* @note Used internally by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out Output value.
*/
Result ringconReadUnkCal(RingCon *c, s16 *out);
/**
* @brief Reads the \ref RingConUserCal.
* @note Used internally by \ref ringconCreate and \ref ringconUpdateUserCal.
* @param c \ref RingCon
* @param[out] out \ref RingConUserCal
*/
Result ringconReadUserCal(RingCon *c, RingConUserCal *out);
/**
* @brief Reads the rep-count for Multitask Mode.
* @param c \ref RingCon
* @param[out] out Output value. Official sw using this clamps the output to range 0-500.
* @param[out] data_valid \ref RingConDataValid
*/
Result ringconReadRepCount(RingCon *c, s32 *out, RingConDataValid *data_valid);
/**
* @brief Reads the total-push-count, for Multitask Mode.
* @note Used internally by \ref ringconCreate. Normally \ref ringconGetTotalPushCount should be used instead.
* @param c \ref RingCon
* @param[out] out Output value.
* @param[out] data_valid \ref RingConDataValid
*/
Result ringconReadTotalPushCount(RingCon *c, s32 *out, RingConDataValid *data_valid);
/**
* @brief This resets the value returned by \ref ringconReadRepCount to 0.
* @param c \ref RingCon
*/
Result ringconResetRepCount(RingCon *c);
/**
* @brief Writes the \ref RingConUserCal.
* @note Used internally by \ref ringconUpdateUserCal.
* @param c \ref RingCon
* @param[in] cal \ref RingConUserCal
*/
Result ringconWriteUserCal(RingCon *c, RingConUserCal cal);

View File

@ -6,101 +6,64 @@
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
#include "sm.h"
#define ACC_USER_LIST_SIZE 8
typedef enum {
AccountServiceType_Application = 0, ///< Initializes acc:u0.
AccountServiceType_System = 1, ///< Initializes acc:u1.
AccountServiceType_Administrator = 2, ///< Initializes acc:su.
} AccountServiceType;
/// Profile
typedef struct {
Service s; ///< IProfile
Service s;
} AccountProfile;
/// Account UserId.
typedef struct {
u64 uid[2]; ///< UserId. All-zero is invalid / Uid not set. See also \ref accountUidIsValid.
} AccountUid;
/// UserData
typedef struct {
u32 unk_x0; ///< Unknown.
u32 iconID; ///< Icon ID. 0 = Mii, the rest are character icon IDs.
u8 iconBackgroundColorID; ///< Profile icon background color ID
u8 unk_x9[0x7]; ///< Unknown.
u8 miiID[0x10]; ///< Some ID related to the Mii? All zeros when a character icon is used.
typedef struct
{
u32 unk_x0;
u32 iconID; ///< Icon ID. 0 = Mii, the rest are character icon IDs.
u8 iconBackgroundColorID; ///< Profile icon background color ID
u8 unk_x9[0x7];
u8 miiID[0x10]; ///< Some ID related to the Mii? All zeros when a character icon is used.
u8 unk_x20[0x60]; ///< Usually zeros?
} AccountUserData;
} PACKED AccountUserData;
/// ProfileBase
typedef struct {
AccountUid uid; ///< \ref AccountUid
typedef struct
{
u128 userID;
u64 lastEditTimestamp; ///< POSIX UTC timestamp, for the last account edit.
char nickname[0x20]; ///< UTF-8 Nickname.
} AccountProfileBase;
char username[0x20]; ///< UTF-8 Username.
} PACKED AccountProfileBase;
/// NetworkServiceAccountId
typedef struct {
u64 id; ///< Id.
} AccountNetworkServiceAccountId;
/// Initialize account.
Result accountInitialize(AccountServiceType service_type);
/// Exit account.
Result accountInitialize(void);
void accountExit(void);
Service* accountGetService(void);
/// Gets the Service object for the actual account service session.
Service* accountGetServiceSession(void);
/// Get the total number of user profiles.
/// Get the total number of user profiles
Result accountGetUserCount(s32* user_count);
/**
* @brief Get a list of all userIds. The returned list will never be larger than ACC_USER_LIST_SIZE.
* @param uids Pointer to array of userIds.
* @param max_uids Maximum number of userIds to return.
* @param actual_total The actual total number of userIds found.
* @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE.
* @param userIDs Pointer to array of user IDs.
* @param max_userIDs Maximum number of user IDs to return.
* @param actual_total The actual total number of user IDs found.
*/
Result accountListAllUsers(AccountUid* uids, s32 max_uids, s32 *actual_total);
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total);
/// Get the userId for the last opened user.
Result accountGetLastOpenedUser(AccountUid *uid);
/// 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 an AccountProfile for the specified userId.
Result accountGetProfile(AccountProfile* out, AccountUid uid);
/// IsUserRegistrationRequestPermitted
Result accountIsUserRegistrationRequestPermitted(bool *out);
/// TrySelectUserWithoutInteraction
Result accountTrySelectUserWithoutInteraction(AccountUid *uid, bool is_network_service_account_required);
/// Close the AccountProfile.
void accountProfileClose(AccountProfile* profile);
/// Get an AccountProfile for the specified userID.
Result accountGetProfile(AccountProfile* out, u128 userID);
/// Get \ref AccountUserData and \ref AccountProfileBase for the specified profile, userdata is optional (can be NULL).
Result accountProfileGet(AccountProfile* profile, AccountUserData* userdata, AccountProfileBase* profilebase);
/// Get the icon image size.
Result accountProfileGetImageSize(AccountProfile* profile, u32* image_size);
Result accountProfileGetImageSize(AccountProfile* profile, size_t* image_size);
/// Load the JPEG profile icon, valid for both Miis and character icons. The output image_size is the same as the one from \ref accountProfileGetImageSize.
Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, u32* image_size);
Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, size_t* image_size);
/// Gets the userId which was selected by the profile-selector applet (if any), prior to launching the currently running Application.
/// This gets the cached PreselectedUser loaded during accountInitialize, when PreselectedUser is available.
Result accountGetPreselectedUser(AccountUid *uid);
void accountProfileClose(AccountProfile* profile);
/**
* @brief Checks whether the specified \ref AccountUid is valid/set (non-zero).
* @param[in] Uid \ref AccountUid
*/
NX_CONSTEXPR bool accountUidIsValid(const AccountUid *Uid) {
return Uid->uid[0]!=0 || Uid->uid[1]!=0;
}
/// 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.
Result accountGetPreselectedUser(u128 *userID);

View File

@ -1,55 +1,16 @@
/**
* @file apm.h
* @brief Performance management (apm) service IPC wrapper. This is used internally by applet with __nx_applet_PerformanceConfiguration, however if you prefer non-init/exit can be used manually. See also: https://switchbrew.org/wiki/PTM_services#apm:am
* @brief Performance management (apm) service IPC wrapper.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
/// PerformanceMode
typedef enum {
ApmPerformanceMode_Invalid = -1, ///< Invalid
ApmPerformanceMode_Normal = 0, ///< Normal
ApmPerformanceMode_Boost = 1, ///< Boost
} ApmPerformanceMode;
/// These are used internally by applet.
/// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates.
typedef enum {
ApmCpuBoostMode_Normal = 0, ///< Default, boost-mode disabled.
ApmCpuBoostMode_FastLoad = 1, ///< Boost CPU. Additionally, throttle GPU to minimum. Use performance configurations 0x92220009 (Docked) and 0x9222000A (Handheld), or 0x9222000B and 0x9222000C.
ApmCpuBoostMode_Type2 = 2, ///< Conserve power. Only throttle GPU to minimum. Use performance configurations 0x9222000B and 0x9222000C.
} ApmCpuBoostMode;
/// Initialize apm. Used automatically by \ref appletInitialize with AppletType_Application.
Result apmInitialize(void);
/// Exit apm. Used automatically by \ref appletExit with AppletType_Application.
void apmExit(void);
/// Gets the Service object for the actual apm service session.
Service* apmGetServiceSession(void);
/// Gets the Service object for ISession.
Service* apmGetServiceSession_Session(void);
/**
* @brief Gets the current ApmPerformanceMode.
* @param[out] out_performanceMode ApmPerformanceMode
*/
Result apmGetPerformanceMode(ApmPerformanceMode* out_performanceMode);
/**
* @brief Sets the PerformanceConfiguration for the specified PerformanceMode.
* @param[in] PerformanceMode \ref ApmPerformanceMode
* @param[in] PerformanceConfiguration PerformanceConfiguration
*/
Result apmSetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 PerformanceConfiguration);
/**
* @brief Gets the PerformanceConfiguration for the specified PerformanceMode.
* @param[in] PerformanceMode \ref ApmPerformanceMode
* @param[out] PerformanceConfiguration PerformanceConfiguration
*/
Result apmGetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 *PerformanceConfiguration);
Result apmSetPerformanceConfiguration(u32 PerformanceMode, u32 PerformanceConfiguration);
Result apmGetPerformanceConfiguration(u32 PerformanceMode, u32 *PerformanceConfiguration);

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +0,0 @@
/**
* @file async.h
* @brief NS/NIM IAsync* IPC wrapper.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
#include "../applets/error.h"
#include "../kernel/event.h"
/// AsyncValue
typedef struct {
Service s; ///< IAsyncValue
Event event; ///< Event with autoclear=false.
} AsyncValue;
/// AsyncResult
typedef struct {
Service s; ///< IAsyncResult
Event event; ///< Event with autoclear=false.
} AsyncResult;
///@name IAsyncValue
///@{
/**
* @brief Close a \ref AsyncValue.
* @note When the object is initialized, this uses \ref asyncValueCancel then \ref asyncValueWait with timeout=UINT64_MAX.
* @param a \ref AsyncValue
*/
void asyncValueClose(AsyncValue *a);
/**
* @brief Waits for the async operation to finish using the specified timeout.
* @param a \ref AsyncValue
* @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout.
*/
Result asyncValueWait(AsyncValue *a, u64 timeout);
/**
* @brief Gets the value size.
* @param a \ref AsyncValue
* @param[out] size Output size.
*/
Result asyncValueGetSize(AsyncValue *a, u64 *size);
/**
* @brief Gets the value.
* @note Prior to using the cmd, this uses \ref asyncResultWait with timeout=UINT64_MAX.
* @param a \ref AsyncValue
* @param[out] buffer Output buffer.
* @param[in] size Output buffer size.
*/
Result asyncValueGet(AsyncValue *a, void* buffer, size_t size);
/**
* @brief Cancels the async operation.
* @note Used automatically by \ref asyncValueClose.
* @param a \ref AsyncValue
*/
Result asyncValueCancel(AsyncValue *a);
/**
* @brief Gets the \ref ErrorContext.
* @note Only available on [4.0.0+].
* @param a \ref AsyncValue
* @param[out] context \ref ErrorContext
*/
Result asyncValueGetErrorContext(AsyncValue *a, ErrorContext *context);
///@}
///@name IAsyncResult
///@{
/**
* @brief Close a \ref AsyncResult.
* @note When the object is initialized, this uses \ref asyncResultCancel then \ref asyncResultWait with timeout=UINT64_MAX.
* @param a \ref AsyncResult
*/
void asyncResultClose(AsyncResult *a);
/**
* @brief Waits for the async operation to finish using the specified timeout.
* @param a \ref AsyncResult
* @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout.
*/
Result asyncResultWait(AsyncResult *a, u64 timeout);
/**
* @brief Gets the Result.
* @note Prior to using the cmd, this uses \ref asyncResultWait with timeout=UINT64_MAX.
* @param a \ref AsyncResult
*/
Result asyncResultGet(AsyncResult *a);
/**
* @brief Cancels the async operation.
* @note Used automatically by \ref asyncResultClose.
* @param a \ref AsyncResult
*/
Result asyncResultCancel(AsyncResult *a);
/**
* @brief Gets the \ref ErrorContext.
* @note Only available on [4.0.0+].
* @param a \ref AsyncResult
* @param[out] context \ref ErrorContext
*/
Result asyncResultGetErrorContext(AsyncResult *a, ErrorContext *context);
///@}

View File

@ -1,70 +0,0 @@
/**
* @file audctl.h
* @brief Audio Control IPC wrapper.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../audio/audio.h"
#include "../sf/service.h"
#include "../kernel/event.h"
typedef enum {
AudioTarget_Invalid = 0,
AudioTarget_Speaker = 1,
AudioTarget_Headphone = 2,
AudioTarget_Tv = 3,
AudioTarget_UsbOutputDevice = 4,
AudioTarget_Bluetooth = 5,
} AudioTarget;
typedef enum {
AudioOutputMode_Invalid = 0,
AudioOutputMode_Pcm1ch = 1,
AudioOutputMode_Pcm2ch = 2,
AudioOutputMode_Pcm6ch = 3,
AudioOutputMode_PcmAuto = 4,
} AudioOutputMode;
typedef enum {
AudioForceMutePolicy_Disable = 0,
AudioForceMutePolicy_SpeakerMuteOnHeadphoneUnplugged = 1,
} AudioForceMutePolicy;
typedef enum {
AudioHeadphoneOutputLevelMode_Normal = 0,
AudioHeadphoneOutputLevelMode_HighPower = 1,
} AudioHeadphoneOutputLevelMode;
Result audctlInitialize(void);
void audctlExit(void);
Service* audctlGetServiceSession(void);
Result audctlGetTargetVolume(s32* volume_out, AudioTarget target);
Result audctlSetTargetVolume(AudioTarget target, s32 volume);
Result audctlGetTargetVolumeMin(s32* volume_out);
Result audctlGetTargetVolumeMax(s32* volume_out);
Result audctlIsTargetMute(bool* mute_out, AudioTarget target);
Result audctlSetTargetMute(AudioTarget target, bool mute);
Result audctlIsTargetConnected(bool* connected_out, AudioTarget target); ///< [1.0.0-17.0.1]
Result audctlSetDefaultTarget(AudioTarget target, u64 fade_in_ns, u64 fade_out_ns);
Result audctlGetDefaultTarget(AudioTarget* target_out);
Result audctlGetAudioOutputMode(AudioOutputMode* mode_out, AudioTarget target);
Result audctlSetAudioOutputMode(AudioTarget target, AudioOutputMode mode);
Result audctlSetForceMutePolicy(AudioForceMutePolicy policy); ///< [1.0.0-13.2.1]
Result audctlGetForceMutePolicy(AudioForceMutePolicy* policy_out); ///< [1.0.0-13.2.1]
Result audctlGetOutputModeSetting(AudioOutputMode* mode_out, AudioTarget target);
Result audctlSetOutputModeSetting(AudioTarget target, AudioOutputMode mode);
Result audctlSetOutputTarget(AudioTarget target);
Result audctlSetInputTargetForceEnabled(bool enable);
Result audctlSetHeadphoneOutputLevelMode(AudioHeadphoneOutputLevelMode mode); ///< [3.0.0+]
Result audctlGetHeadphoneOutputLevelMode(AudioHeadphoneOutputLevelMode* mode_out); ///< [3.0.0+]
Result audctlAcquireAudioVolumeUpdateEventForPlayReport(Event* event_out); ///< [3.0.0-13.2.1]
Result audctlAcquireAudioOutputDeviceUpdateEventForPlayReport(Event* event_out); ///< [3.0.0-13.2.1]
Result audctlGetAudioOutputTargetForPlayReport(AudioTarget* target_out); ///< [3.0.0+]
Result audctlNotifyHeadphoneVolumeWarningDisplayedEvent(void); ///< [3.0.0+]
Result audctlSetSystemOutputMasterVolume(float volume); ///< [4.0.0+]
Result audctlGetSystemOutputMasterVolume(float* volume_out); ///< [4.0.0+]
Result audctlGetActiveOutputTarget(AudioTarget* target);

View File

@ -1,25 +1,17 @@
/**
* @file auddev.h
* @brief IAudioDevice IPC wrapper.
* @brief Audio device.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../audio/audio.h"
#include "../sf/service.h"
/// Initialize IAudioDevice.
Result auddevInitialize(void);
/// Exit IAudioDevice.
void auddevExit(void);
/// Gets the Service object for IAudioDevice.
Service* auddevGetServiceSession(void);
Result auddevListAudioDeviceName(AudioDeviceName *DeviceNames, s32 max_names, s32 *total_names);
Result auddevSetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float volume);
Result auddevGetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float *volume);
Result auddevGetActiveAudioDeviceName(AudioDeviceName *DeviceName);

View File

@ -6,9 +6,7 @@
*/
#pragma once
#include "../types.h"
#include "../audio/audio.h"
#include "../sf/service.h"
typedef enum {
AudioInState_Started = 0,
@ -27,27 +25,15 @@ struct AudioInBuffer
u64 data_offset; ///< Offset of data inside the buffer. (Unused?)
};
/// Initialize audin.
Result audinInitialize(void);
/// Exit audin.
void audinExit(void);
/// Gets the Service object for the actual audin service session.
Service* audinGetServiceSession(void);
/// Gets the Service object for IAudioIn.
Service* audinGetServiceSession_AudioIn(void);
Result audinListAudioIns(char *DeviceNames, s32 count, u32 *DeviceNamesCount);
Result audinListAudioIns(char *DeviceNames, u32 *DeviceNamesCount);
Result audinOpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State);
Result audinGetAudioInState(AudioInState *State);
Result audinStartAudioIn(void);
Result audinStopAudioIn(void);
/// Submits an \ref AudioInBuffer for capturing.
Result audinAppendAudioInBuffer(AudioInBuffer *Buffer);
Result audinGetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount);
Result audinContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer);
@ -63,7 +49,7 @@ Result audinCaptureBuffer(AudioInBuffer *source, AudioInBuffer **released);
* @brief Waits for audio capture to finish.
* @param released AudioInBuffer to receive the first captured buffer after being released.
* @param released_count Pointer to receive the number of captured buffers.
* @param timeout Timeout value, use UINT64_MAX to wait until all finished.
* @param timeout Timeout value, use U64_MAX to wait until all finished.
*/
Result audinWaitCaptureFinish(AudioInBuffer **released, u32* released_count, u64 timeout);

View File

@ -6,9 +6,7 @@
*/
#pragma once
#include "../types.h"
#include "../audio/audio.h"
#include "../sf/service.h"
typedef enum {
AudioOutState_Started = 0,
@ -27,41 +25,18 @@ struct AudioOutBuffer
u64 data_offset; ///< Offset of data inside the buffer. (Unused?)
};
/// Initialize audout.
Result audoutInitialize(void);
/// Exit audout.
void audoutExit(void);
/// Gets the Service object for the actual audout service session.
Service* audoutGetServiceSession(void);
/// Gets the Service object for IAudioOut.
Service* audoutGetServiceSession_AudioOut(void);
Result audoutListAudioOuts(char *DeviceNames, s32 count, u32 *DeviceNamesCount);
Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount);
Result audoutOpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State);
Result audoutGetAudioOutState(AudioOutState *State);
Result audoutStartAudioOut(void);
Result audoutStopAudioOut(void);
/// Submits an \ref AudioOutBuffer for playing.
Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer);
Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount);
Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer);
/// Only available with [4.0.0+].
Result audoutGetAudioOutBufferCount(u32 *count);
/// Only available with [4.0.0+].
Result audoutGetAudioOutPlayedSampleCount(u64 *count);
/// Only available with [4.0.0+].
Result audoutFlushAudioOutBuffers(bool *flushed);
/// Only available with [6.0.0+].
Result audoutSetAudioOutVolume(float volume);
/// Only available with [6.0.0+].
Result audoutGetAudioOutVolume(float *volume);
/**
* @brief Submits an audio sample data buffer for playing and waits for it to finish playing.
* @brief Uses \ref audoutAppendAudioOutBuffer and \ref audoutWaitPlayFinish internally.
@ -74,7 +49,7 @@ Result audoutPlayBuffer(AudioOutBuffer *source, AudioOutBuffer **released);
* @brief Waits for audio playback to finish.
* @param released AudioOutBuffer to receive the first played buffer after being released.
* @param released_count Pointer to receive the number of played buffers.
* @param timeout Timeout value, use UINT64_MAX to wait until all finished.
* @param timeout Timeout value, use U64_MAX to wait until all finished.
*/
Result audoutWaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout);

View File

@ -1,50 +0,0 @@
/**
* @file audrec.h
* @brief Audio Recorder IPC wrapper.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../audio/audio.h"
#include "../sf/service.h"
#include "../kernel/event.h"
typedef struct {
u64 released_ns;
u64 next_buffer_ptr;
u64 sample_buffer_ptr;
u64 sample_buffer_capacity;
u64 data_size;
u64 data_offset;
} FinalOutputRecorderBuffer;
typedef struct {
u32 sample_rate;
u32 channel_count;
} FinalOutputRecorderParameter;
typedef struct {
u32 sample_rate;
u32 channel_count;
u32 sample_format;
u32 state;
} FinalOutputRecorderParameterInternal;
typedef struct {
Service s;
} AudrecRecorder;
Result audrecInitialize(void);
void audrecExit(void);
Service* audrecGetServiceSession(void);
Result audrecOpenFinalOutputRecorder(AudrecRecorder* recorder_out, FinalOutputRecorderParameter* param_in, u64 aruid, FinalOutputRecorderParameterInternal* param_out);
Result audrecRecorderStart(AudrecRecorder* recorder);
Result audrecRecorderStop(AudrecRecorder* recorder);
Result audrecRecorderRegisterBufferEvent(AudrecRecorder* recorder, Event* out_event);
Result audrecRecorderAppendFinalOutputRecorderBuffer(AudrecRecorder* recorder, u64 buffer_client_ptr, FinalOutputRecorderBuffer* param);
Result audrecRecorderGetReleasedFinalOutputRecorderBuffers(AudrecRecorder* recorder, u64* out_buffers, u64* inout_count, u64* out_released);
void audrecRecorderClose(AudrecRecorder* recorder);

View File

@ -6,9 +6,13 @@
*/
#pragma once
#include "../types.h"
#include "../audio/audio.h"
#include "../sf/service.h"
#if __cplusplus >= 201402L
#define AUDREN_CONSTEXPR constexpr
#else
#define AUDREN_CONSTEXPR static inline
#endif
#define AUDREN_TIMER_FREQ_HZ 200.0f
#define AUDREN_TIMER_PERIOD_MS 5.0f
@ -282,12 +286,12 @@ static inline u32 audrenGetRevision(void)
return g_audrenRevision;
}
NX_CONSTEXPR int audrenGetMemPoolCount(const AudioRendererConfig* config)
AUDREN_CONSTEXPR int audrenGetMemPoolCount(const AudioRendererConfig* config)
{
return config->num_effects + 4 * config->num_voices;
}
NX_CONSTEXPR size_t audrenGetInputParamSize(const AudioRendererConfig* config)
AUDREN_CONSTEXPR size_t audrenGetInputParamSize(const AudioRendererConfig* config)
{
size_t size = 0;
size += sizeof(AudioRendererUpdateDataHeader);
@ -302,7 +306,7 @@ NX_CONSTEXPR size_t audrenGetInputParamSize(const AudioRendererConfig* config)
return size;
}
NX_CONSTEXPR size_t audrenGetOutputParamSize(const AudioRendererConfig* config)
AUDREN_CONSTEXPR size_t audrenGetOutputParamSize(const AudioRendererConfig* config)
{
size_t size = 0;
size += sizeof(AudioRendererUpdateDataHeader);
@ -315,15 +319,8 @@ NX_CONSTEXPR size_t audrenGetOutputParamSize(const AudioRendererConfig* config)
return size;
}
/// Initialize audren.
Result audrenInitialize(const AudioRendererConfig* config);
/// Exit audren.
void audrenExit(void);
/// Gets the Service object for IAudioRenderer.
Service* audrenGetServiceSession_AudioRenderer(void);
void audrenWaitFrame(void);
Result audrenGetState(u32* out_state);
Result audrenRequestUpdateAudioRenderer(const void* in_param_buf, size_t in_param_buf_size, void* out_param_buf, size_t out_param_buf_size, void* perf_buf, size_t perf_buf_size);

View File

@ -1,45 +0,0 @@
/**
* @file avm.h
* @brief AVM services IPC wrapper. Only available on [6.0.0+].
* @author Behemoth
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
typedef struct {
u64 application_id;
u32 version;
u32 required;
} AvmVersionListEntry;
typedef struct {
u64 application_id;
u32 version;
} AvmRequiredVersionEntry;
typedef struct {
Service s;
} AvmVersionListImporter;
Result avmInitialize(void);
void avmExit(void);
Service *avmGetServiceSession(void);
Result avmGetHighestAvailableVersion(u64 id_1, u64 id_2, u32 *version);
Result avmGetHighestRequiredVersion(u64 id_1, u64 id_2, u32 *version);
Result avmGetVersionListEntry(u64 application_id, AvmVersionListEntry *entry);
Result avmGetVersionListImporter(AvmVersionListImporter *out);
Result avmGetLaunchRequiredVersion(u64 application_id, u32 *version);
Result avmUpgradeLaunchRequiredVersion(u64 application_id, u32 version);
Result avmPushLaunchVersion(u64 application_id, u32 version);
Result avmListVersionList(AvmVersionListEntry *buffer, size_t count, u32 *out);
Result avmListRequiredVersion(AvmRequiredVersionEntry *buffer, size_t count, u32 *out);
void avmVersionListImporterClose(AvmVersionListImporter *srv);
Result avmVersionListImporterSetTimestamp(AvmVersionListImporter *srv, u64 timestamp);
Result avmVersionListImporterSetData(AvmVersionListImporter *srv, const AvmVersionListEntry *entries, u32 count);
Result avmVersionListImporterFlush(AvmVersionListImporter *srv);

View File

@ -6,23 +6,15 @@
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
typedef enum {
BpcSleepButtonState_Held = 0,
BpcSleepButtonState_Released = 1,
} BpcSleepButtonState;
/// Initialize bpc.
Result bpcInitialize(void);
/// Exit bpc.
void bpcExit(void);
/// Gets the Service object for the actual bpc service session.
Service* bpcGetServiceSession(void);
Result bpcShutdownSystem(void);
Result bpcRebootSystem(void);
Result bpcGetSleepButtonState(BpcSleepButtonState *out); ///< [2.0.0-13.2.1]
Result bpcGetPowerButton(bool* out_is_pushed); ///< [6.0.0+]
Result bpcGetSleepButtonState(BpcSleepButtonState *out);

View File

@ -1,6 +1,6 @@
/**
* @file bsd.h
* @brief BSD sockets (bsd:u/s) service IPC wrapper. Please use the standard <sys/socket.h> interface instead.
* @brief BSD sockets (bsd:u/s) service IPC wrapper. Please use socket.c instead.
* @author plutoo
* @author TuxSH
* @copyright libnx Authors
@ -12,17 +12,13 @@
#include "../types.h"
#include "../kernel/tmem.h"
#include "../sf/service.h"
/// Configuration structure for bsdInitalize
typedef struct {
u32 version; ///< Observed 1 on [2.0.0+] LibAppletWeb, 2 on [3.0.0+].
void *tmem_buffer; ///< User-provided buffer to use as backing for transfer memory. If NULL, a buffer will be allocated automatically. Must be large enough and page-aligned.
size_t tmem_buffer_size; ///< Size of the user-provided transfer memory backing buffer. Must be large enough and page-aligned.
u32 version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.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 receive buffer (initial or fixed).
u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed).
u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value.
u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value.
@ -37,17 +33,11 @@ extern __thread int g_bsdErrno; ///< Last errno, per-thread
/// Fetch the default configuration for bsdInitialize.
const BsdInitConfig *bsdGetDefaultInitConfig(void);
/// Initialize the BSD service.
Result bsdInitialize(const BsdInitConfig *config, u32 num_sessions, u32 service_type);
/// Exit the BSD service.
Result bsdInitialize(const BsdInitConfig *config);
/// Deinitialize the BSD service.
void bsdExit(void);
/// Gets the Service object for the actual BSD service session.
Service* bsdGetServiceSession(void);
/// Creates a socket.
int bsdSocket(int domain, int type, int protocol);
/// Like @ref bsdSocket but the newly created socket is immediately shut down.
int bsdSocketExempt(int domain, int type, int protocol);
@ -78,7 +68,10 @@ ssize_t bsdRead(int fd, void *buf, size_t count);
int bsdClose(int fd);
/// Duplicate a socket (bsd:s).
int bsdDuplicateSocket(int sockfd);
int bsdRecvMMsg(int sockfd, void *buf, size_t size, unsigned int vlen, int flags, struct timespec *timeout);
int bsdSendMMsg(int sockfd, void *buf, size_t size, unsigned int vlen, int flags);
// TODO: Reverse-engineer GetResourceStatistics.
// TODO: Reverse-engineer GetResourceStatistics. Implement sendmmsg/recvmmsg (custom (un)serialization)
/// Initialize the BSD service using the default configuration.
static inline Result bsdInitializeDefault(void) {
return bsdInitialize(bsdGetDefaultInitConfig());
}

View File

@ -1,132 +0,0 @@
/**
* @file bt.h
* @brief Bluetooth user (bt) service IPC wrapper.
* @note See also btdev.
* @author yellows8, ndeadly
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/btdrv.h"
#include "../sf/service.h"
/// Initialize bt. Only available on [5.0.0+].
Result btInitialize(void);
/// Exit bt.
void btExit(void);
/// Gets the Service object for the actual bt service session.
Service* btGetServiceSession(void);
/**
* @brief LeClientReadCharacteristic
* @note This is essentially the same as \ref btdrvReadGattCharacteristic.
* @param[in] connection_handle ConnectionHandle
* @param[in] is_primary Is a primary service or not
* @param[in] serv_id Service GATT ID \ref BtdrvGattId
* @param[in] char_id Characteristic GATT ID \ref BtdrvGattId
* @param[in] auth_req \ref BtdrvGattAuthReqType
*/
Result btLeClientReadCharacteristic(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, u8 auth_req);
/**
* @brief LeClientReadDescriptor
* @note This is essentially the same as \ref btdrvReadGattDescriptor.
* @param[in] connection_handle ConnectionHandle
* @param[in] is_primary Is a primary service or not
* @param[in] serv_id Service GATT ID \ref BtdrvGattId
* @param[in] char_id Characteristic GATT ID \ref BtdrvGattId
* @param[in] desc_id Descriptor GATT ID \ref BtdrvGattId
* @param[in] auth_req \ref BtdrvGattAuthReqType
*/
Result btLeClientReadDescriptor(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, u8 auth_req);
/**
* @brief LeClientWriteCharacteristic
* @note This is essentially the same as \ref btdrvWriteGattCharacteristic.
* @param[in] connection_handle ConnectionHandle
* @param[in] is_primary Is a primary service or not
* @param[in] serv_id Service GATT ID \ref BtdrvGattId
* @param[in] char_id Characteristic GATT ID \ref BtdrvGattId
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, must be <=0x258.
* @param[in] auth_req \ref BtdrvGattAuthReqType
* @param[in] with_response Whether to use Write-With-Response write type or not
*/
Result btLeClientWriteCharacteristic(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, const void* buffer, size_t size, u8 auth_req, bool with_response);
/**
* @brief LeClientWriteDescriptor
* @note This is essentially the same as \ref btdrvWriteGattDescriptor.
* @param[in] connection_handle ConnectionHandle
* @param[in] is_primary Is a primary service or not
* @param[in] serv_id Service GATT ID \ref BtdrvGattId
* @param[in] char_id Characteristic GATT ID \ref BtdrvGattId
* @param[in] desc_id Descriptor GATT ID \ref BtdrvGattId
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, must be <=0x258.
* @param[in] auth_req \ref BtdrvGattAuthReqType
*/
Result btLeClientWriteDescriptor(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, const void* buffer, size_t size, u8 auth_req);
/**
* @brief LeClientRegisterNotification
* @note This is essentially the same as \ref btdrvRegisterGattNotification.
* @param[in] connection_handle ConnectionHandle
* @param[in] is_primary Is a primary service or not
* @param[in] serv_id Service GATT ID \ref BtdrvGattId
* @param[in] char_id Characteristic GATT ID \ref BtdrvGattId
*/
Result btLeClientRegisterNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id);
/**
* @brief LeClientDeregisterNotification
* @note This is essentially the same as \ref btdrvUnregisterGattNotification.
* @param[in] connection_handle ConnectionHandle
* @param[in] is_primary Is a primary service or not
* @param[in] serv_id Service GATT ID \ref BtdrvGattId
* @param[in] char_id Characteristic GATT ID \ref BtdrvGattId
*/
Result btLeClientDeregisterNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id);
/**
* @brief SetLeResponse
* @param[in] server_if Server interface ID
* @param[in] serv_uuid Service UUID \ref BtdrvGattAttributeUuid
* @param[in] char_uuid Characteristic UUID \ref BtdrvGattAttributeUuid
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, must be <=0x258.
*/
Result btSetLeResponse(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *char_uuid, const void* buffer, size_t size);
/**
* @brief LeSendIndication
* @param[in] server_if Server interface ID
* @param[in] serv_uuid Service UUID \ref BtdrvGattAttributeUuid
* @param[in] char_uuid Characteristic UUID \ref BtdrvGattAttributeUuid
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, clamped to max size 0x258.
* @param[in] noconfirm Whether no confirmation is required (notification) or not (indication)
*/
Result btLeSendIndication(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *char_uuid, const void* buffer, size_t size, bool noconfirm);
/**
* @brief GetLeEventInfo
* @note This is identical to \ref btdrvGetLeHidEventInfo except different state is used.
* @note The state used by this is reset after writing the data to output.
* @param[in] buffer Output buffer. 0x400-bytes from state is written here. See \ref BtdrvLeEventInfo.
* @param[in] size Output buffer size.
* @param[out] type Output BtdrvBleEventType.
*/
Result btGetLeEventInfo(void* buffer, size_t size, BtdrvBleEventType *type);
/**
* @brief RegisterBleEvent
* @note This is identical to \ref btdrvRegisterBleHidEvent except different state is used.
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btRegisterBleEvent(Event* out_event);

File diff suppressed because it is too large Load Diff

View File

@ -1,917 +0,0 @@
/**
* @file btdrv_ids.h
* @brief Bluetooth SIG assigned number definitions (see https://www.bluetooth.com/specifications/assigned-numbers/).
* @author ndeadly
* @copyright libnx Authors
*/
#pragma once
/// Extract \ref BtdrvAppearanceCategoryType from \ref BtdrvAppearanceType.
#define APPEARANCE_CATEGORY(x) ((x & 0xFFC0) >> 6)
/// AdType
typedef enum {
BtdrvAdType_Flags = 0x01, ///< Flags
BtdrvAdType_ServiceClassUuid16ListIncomplete = 0x02, ///< Incomplete List of 16-bit Service Class UUIDs
BtdrvAdType_ServiceClassUuid16ListComplete = 0x03, ///< Complete List of 16-bit Service Class UUIDs
BtdrvAdType_ServiceClassUuid32ListIncomplete = 0x04, ///< Incomplete List of 32-bit Service Class UUIDs
BtdrvAdType_ServiceClassUuid32ListComplete = 0x05, ///< Complete List of 32-bit Service Class UUIDs
BtdrvAdType_ServiceClassUuid128ListIncomplete = 0x06, ///< Incomplete List of 128-bit Service Class UUIDs
BtdrvAdType_ServiceClassUuid128ListComplete = 0x07, ///< Complete List of 128-bit Service Class UUIDs
BtdrvAdType_ShortenedLocalName = 0x08, ///< Shortened Local Name
BtdrvAdType_CompleteLocalName = 0x09, ///< Complete Local Name
BtdrvAdType_TxPowerLevel = 0x0A, ///< Tx Power Level
BtdrvAdType_ClassOfDevice = 0x0D, ///< Class of Device
BtdrvAdType_SimplePairingHashC192 = 0x0E, ///< Simple Pairing Hash C-192
BtdrvAdType_SimplePairingRandomizerR192 = 0x0F, ///< Simple Pairing Randomizer R-192
BtdrvAdType_DeviceId = 0x10, ///< Device ID
BtdrvAdType_SecurityManagerTkValue = 0x10, ///< Security Manager TK Value
BtdrvAdType_SecurityManagerOutOfBandFlags = 0x11, ///< Security Manager Out of Band Flags
BtdrvAdType_PeripheralConnectionIntervalRange = 0x12, ///< Peripheral Connection Interval Range
BtdrvAdType_ServiceSolicitationUuid16List = 0x14, ///< List of 16-bit Service Solicitation UUIDs
BtdrvAdType_ServiceSolicitationUuid128List = 0x15, ///< List of 128-bit Service Solicitation UUIDs
BtdrvAdType_ServiceDataUuid16 = 0x16, ///< Service Data - 16-bit UUID
BtdrvAdType_PublicTargetAddress = 0x17, ///< Public Target Address
BtdrvAdType_RandomTargetAddress = 0x18, ///< Random Target Address
BtdrvAdType_Appearance = 0x19, ///< Appearance
BtdrvAdType_AdvertisingInterval = 0x1A, ///< Advertising Interval
BtdrvAdType_LeBluetoothDeviceAddress = 0x1B, ///< LE Bluetooth Device Address
BtdrvAdType_LeRole = 0x1C, ///< LE Role
BtdrvAdType_SimplePairingHashC256 = 0x1D, ///< Simple Pairing Hash C-256
BtdrvAdType_SimplePairingRandomizerR256 = 0x1E, ///< Simple Pairing Randomizer R-256
BtdrvAdType_ServiceSolicitationUuid32List = 0x1F, ///< List of 32-bit Service Solicitation UUIDs
BtdrvAdType_ServiceDataUuid32 = 0x20, ///< Service Data - 32-bit UUID
BtdrvAdType_ServiceDataUuid128 = 0x21, ///< Service Data - 128-bit UUID
BtdrvAdType_LeSecureConnectionsConfirmationValue = 0x22, ///< LE Secure Connections Confirmation Value
BtdrvAdType_LeSecureConnectionsRandomValue = 0x23, ///< LE Secure Connections Random Value
BtdrvAdType_Uri = 0x24, ///< URI
BtdrvAdType_IndoorPositioning = 0x25, ///< Indoor Positioning
BtdrvAdType_TransportDiscoveryData = 0x26, ///< Transport Discovery Data
BtdrvAdType_LeSupportedFeatures = 0x27, ///< LE Supported Features
BtdrvAdType_ChannelMapUpdateIndication = 0x28, ///< Channel Map Update Indication
BtdrvAdType_PbAdv = 0x29, ///< PB-ADV
BtdrvAdType_MeshMessage = 0x2A, ///< Mesh Message
BtdrvAdType_MeshBeacon = 0x2B, ///< Mesh Beacon
BtdrvAdType_Biginfo = 0x2C, ///< BIGInfo
BtdrvAdType_BroadcastCode = 0x2D, ///< Broadcast_Code
BtdrvAdType_ResolvableSetIdentifier = 0x2E, ///< Resolvable Set Identifier
BtdrvAdType_AdvertisingIntervalLong = 0x2F, ///< Advertising Interval - long
BtdrvAdType_BroadcastName = 0x30, ///< Broadcast_Name
BtdrvAdType_EncryptedAdvertisingData = 0x31, ///< Encrypted Advertising Data
BtdrvAdType_PeriodicAdvertisingResponseTimingInformation = 0x32, ///< Periodic Advertising Response Timing Information
BtdrvAdType_ElectronicShelfLabel = 0x34, ///< Electronic Shelf Label
BtdrvAdType_3DInformationData = 0x3D, ///< 3D Information Data
BtdrvAdType_ManufacturerSpecificData = 0xFF, ///< Manufacturer Specific Data
} BtdrvAdType;
/// AppearanceCategoryType
typedef enum {
BtdrvAppearanceCategoryType_Unknown = 0x000, ///< Unknown
BtdrvAppearanceCategoryType_Phone = 0x001, ///< Phone
BtdrvAppearanceCategoryType_Computer = 0x002, ///< Computer
BtdrvAppearanceCategoryType_Watch = 0x003, ///< Watch
BtdrvAppearanceCategoryType_Clock = 0x004, ///< Clock
BtdrvAppearanceCategoryType_Display = 0x005, ///< Display
BtdrvAppearanceCategoryType_RemoteControl = 0x006, ///< Remote Control
BtdrvAppearanceCategoryType_EyeGlasses = 0x007, ///< Eye-glasses
BtdrvAppearanceCategoryType_Tag = 0x008, ///< Tag
BtdrvAppearanceCategoryType_Keyring = 0x009, ///< Keyring
BtdrvAppearanceCategoryType_MediaPlayer = 0x00A, ///< Media Player
BtdrvAppearanceCategoryType_BarcodeScanner = 0x00B, ///< Barcode Scanner
BtdrvAppearanceCategoryType_Thermometer = 0x00C, ///< Thermometer
BtdrvAppearanceCategoryType_HeartRateSensor = 0x00D, ///< Heart Rate Sensor
BtdrvAppearanceCategoryType_BloodPressure = 0x00E, ///< Blood Pressure
BtdrvAppearanceCategoryType_HumanInterfaceDevice = 0x00F, ///< Human Interface Device
BtdrvAppearanceCategoryType_GlucoseMeter = 0x010, ///< Glucose Meter
BtdrvAppearanceCategoryType_RunningWalkingSensor = 0x011, ///< Running Walking Sensor
BtdrvAppearanceCategoryType_Cycling = 0x012, ///< Cycling
BtdrvAppearanceCategoryType_ControlDevice = 0x013, ///< Control Device
BtdrvAppearanceCategoryType_NetworkDevice = 0x014, ///< Network Device
BtdrvAppearanceCategoryType_Sensor = 0x015, ///< Sensor
BtdrvAppearanceCategoryType_LightFixtures = 0x016, ///< Light Fixtures
BtdrvAppearanceCategoryType_Fan = 0x017, ///< Fan
BtdrvAppearanceCategoryType_Hvac = 0x018, ///< HVAC
BtdrvAppearanceCategoryType_AirConditioning = 0x019, ///< Air Conditioning
BtdrvAppearanceCategoryType_Humidifier = 0x01A, ///< Humidifier
BtdrvAppearanceCategoryType_Heating = 0x01B, ///< Heating
BtdrvAppearanceCategoryType_AccessControl = 0x01C, ///< Access Control
BtdrvAppearanceCategoryType_MotorizedDevice = 0x01D, ///< Motorized Device
BtdrvAppearanceCategoryType_PowerDevice = 0x01E, ///< Power Device
BtdrvAppearanceCategoryType_LightSource = 0x01F, ///< Light Source
BtdrvAppearanceCategoryType_WindowCovering = 0x020, ///< Window Covering
BtdrvAppearanceCategoryType_AudioSink = 0x021, ///< Audio Sink
BtdrvAppearanceCategoryType_AudioSource = 0x022, ///< Audio Source
BtdrvAppearanceCategoryType_MotorizedVehicle = 0x023, ///< Motorized Vehicle
BtdrvAppearanceCategoryType_DomesticAppliance = 0x024, ///< Domestic Appliance
BtdrvAppearanceCategoryType_WearableAudioDevice = 0x025, ///< Wearable Audio Device
BtdrvAppearanceCategoryType_Aircraft = 0x026, ///< Aircraft
BtdrvAppearanceCategoryType_AvEquipment = 0x027, ///< AV Equipment
BtdrvAppearanceCategoryType_DisplayEquipment = 0x028, ///< Display Equipment
BtdrvAppearanceCategoryType_HearingAid = 0x029, ///< Hearing aid
BtdrvAppearanceCategoryType_Gaming = 0x02A, ///< Gaming
BtdrvAppearanceCategoryType_PulseOximeter = 0x031, ///< Pulse Oximeter
BtdrvAppearanceCategoryType_WeightScale = 0x032, ///< Weight Scale
BtdrvAppearanceCategoryType_PersonalMobilityDevice = 0x033, ///< Personal Mobility Device
BtdrvAppearanceCategoryType_ContinuousGlucoseMonitor = 0x034, ///< Continuous Glucose Monitor
BtdrvAppearanceCategoryType_InsulinPump = 0x035, ///< Insulin Pump
BtdrvAppearanceCategoryType_MedicationDelivery = 0x036, ///< Medication Delivery
BtdrvAppearanceCategoryType_Spirometer = 0x037, ///< Spirometer
BtdrvAppearanceCategoryType_OutdoorSportsActivity = 0x051, ///< Outdoor Sports Activity
} BtdrvAppearanceCategoryType;
/// AppearanceType
typedef enum {
BtdrvAppearanceType_DesktopWorkstation = 0x0081, ///< Desktop Workstation
BtdrvAppearanceType_ServerClassComputer = 0x0082, ///< Server-class Computer
BtdrvAppearanceType_Laptop = 0x0083, ///< Laptop
BtdrvAppearanceType_HandheldPcPdaClamshell = 0x0084, ///< Handheld PC/PDA (clamshell)
BtdrvAppearanceType_PalmSizePcPda = 0x0085, ///< Palm-size PC/PDA
BtdrvAppearanceType_WearableComputerWatchSize = 0x0086, ///< Wearable computer (watch size)
BtdrvAppearanceType_Tablet = 0x0087, ///< Tablet
BtdrvAppearanceType_DockingStation = 0x0088, ///< Docking Station
BtdrvAppearanceType_AllInOne = 0x0089, ///< All in One
BtdrvAppearanceType_BladeServer = 0x008A, ///< Blade Server
BtdrvAppearanceType_Convertible = 0x008B, ///< Convertible
BtdrvAppearanceType_Detachable = 0x008C, ///< Detachable
BtdrvAppearanceType_IotGateway = 0x008D, ///< IoT Gateway
BtdrvAppearanceType_MiniPc = 0x008E, ///< Mini PC
BtdrvAppearanceType_StickPc = 0x008F, ///< Stick PC
BtdrvAppearanceType_SportsWatch = 0x00C1, ///< Sports Watch
BtdrvAppearanceType_Smartwatch = 0x00C2, ///< Smartwatch
BtdrvAppearanceType_EarThermometer = 0x0301, ///< Ear Thermometer
BtdrvAppearanceType_HeartRateBelt = 0x0341, ///< Heart Rate Belt
BtdrvAppearanceType_ArmBloodPressure = 0x0381, ///< Arm Blood Pressure
BtdrvAppearanceType_WristBloodPressure = 0x0382, ///< Wrist Blood Pressure
BtdrvAppearanceType_Keyboard = 0x03C1, ///< Keyboard
BtdrvAppearanceType_Mouse = 0x03C2, ///< Mouse
BtdrvAppearanceType_Joystick = 0x03C3, ///< Joystick
BtdrvAppearanceType_Gamepad = 0x03C4, ///< Gamepad
BtdrvAppearanceType_DigitizerTablet = 0x03C5, ///< Digitizer Tablet
BtdrvAppearanceType_CardReader = 0x03C6, ///< Card Reader
BtdrvAppearanceType_DigitalPen = 0x03C7, ///< Digital Pen
BtdrvAppearanceType_BarcodeScanner = 0x03C8, ///< Barcode Scanner
BtdrvAppearanceType_Touchpad = 0x03C9, ///< Touchpad
BtdrvAppearanceType_PresentationRemote = 0x03CA, ///< Presentation Remote
BtdrvAppearanceType_InShoeRunningWalkingSensor = 0x0441, ///< In-Shoe Running Walking Sensor
BtdrvAppearanceType_OnShoeRunningWalkingSensor = 0x0442, ///< On-Shoe Running Walking Sensor
BtdrvAppearanceType_OnHipRunningWalkingSensor = 0x0443, ///< On-Hip Running Walking Sensor
BtdrvAppearanceType_CyclingComputer = 0x0481, ///< Cycling Computer
BtdrvAppearanceType_SpeedSensor = 0x0482, ///< Speed Sensor
BtdrvAppearanceType_CadenceSensor = 0x0483, ///< Cadence Sensor
BtdrvAppearanceType_PowerSensor = 0x0484, ///< Power Sensor
BtdrvAppearanceType_SpeedAndCadenceSensor = 0x0485, ///< Speed and Cadence Sensor
BtdrvAppearanceType_Switch = 0x04C1, ///< Switch
BtdrvAppearanceType_MultiSwitch = 0x04C2, ///< Multi-switch
BtdrvAppearanceType_Button = 0x04C3, ///< Button
BtdrvAppearanceType_Slider = 0x04C4, ///< Slider
BtdrvAppearanceType_RotarySwitch = 0x04C5, ///< Rotary Switch
BtdrvAppearanceType_TouchPanel = 0x04C6, ///< Touch Panel
BtdrvAppearanceType_SingleSwitch = 0x04C7, ///< Single Switch
BtdrvAppearanceType_DoubleSwitch = 0x04C8, ///< Double Switch
BtdrvAppearanceType_TripleSwitch = 0x04C9, ///< Triple Switch
BtdrvAppearanceType_BatterySwitch = 0x04CA, ///< Battery Switch
BtdrvAppearanceType_EnergyHarvestingSwitch = 0x04CB, ///< Energy Harvesting Switch
BtdrvAppearanceType_PushButton = 0x04CC, ///< Push Button
BtdrvAppearanceType_AccessPoint = 0x0501, ///< Access Point
BtdrvAppearanceType_MeshDevice = 0x0502, ///< Mesh Device
BtdrvAppearanceType_MeshNetworkProxy = 0x0503, ///< Mesh Network Proxy
BtdrvAppearanceType_MotionSensor = 0x0541, ///< Motion Sensor
BtdrvAppearanceType_AirQualitySensor = 0x0542, ///< Air quality Sensor
BtdrvAppearanceType_TemperatureSensor = 0x0543, ///< Temperature Sensor
BtdrvAppearanceType_HumiditySensor = 0x0544, ///< Humidity Sensor
BtdrvAppearanceType_LeakSensor = 0x0545, ///< Leak Sensor
BtdrvAppearanceType_SmokeSensor = 0x0546, ///< Smoke Sensor
BtdrvAppearanceType_OccupancySensor = 0x0547, ///< Occupancy Sensor
BtdrvAppearanceType_ContactSensor = 0x0548, ///< Contact Sensor
BtdrvAppearanceType_CarbonMonoxideSensor = 0x0549, ///< Carbon Monoxide Sensor
BtdrvAppearanceType_CarbonDioxideSensor = 0x054A, ///< Carbon Dioxide Sensor
BtdrvAppearanceType_AmbientLightSensor = 0x054B, ///< Ambient Light Sensor
BtdrvAppearanceType_EnergySensor = 0x054C, ///< Energy Sensor
BtdrvAppearanceType_ColorLightSensor = 0x054D, ///< Color Light Sensor
BtdrvAppearanceType_RainSensor = 0x054E, ///< Rain Sensor
BtdrvAppearanceType_FireSensor = 0x054F, ///< Fire Sensor
BtdrvAppearanceType_WindSensor = 0x0550, ///< Wind Sensor
BtdrvAppearanceType_ProximitySensor = 0x0551, ///< Proximity Sensor
BtdrvAppearanceType_MultiSensor = 0x0552, ///< Multi-Sensor
BtdrvAppearanceType_FlushMountedSensor = 0x0553, ///< Flush Mounted Sensor
BtdrvAppearanceType_CeilingMountedSensor = 0x0554, ///< Ceiling Mounted Sensor
BtdrvAppearanceType_WallMountedSensor = 0x0555, ///< Wall Mounted Sensor
BtdrvAppearanceType_Multisensor = 0x0556, ///< Multisensor
BtdrvAppearanceType_EnergyMeter = 0x0557, ///< Energy Meter
BtdrvAppearanceType_FlameDetector = 0x0558, ///< Flame Detector
BtdrvAppearanceType_VehicleTirePressureSensor = 0x0559, ///< Vehicle Tire Pressure Sensor
BtdrvAppearanceType_WallLight = 0x0581, ///< Wall Light
BtdrvAppearanceType_CeilingLight = 0x0582, ///< Ceiling Light
BtdrvAppearanceType_FloorLight = 0x0583, ///< Floor Light
BtdrvAppearanceType_CabinetLight = 0x0584, ///< Cabinet Light
BtdrvAppearanceType_DeskLight = 0x0585, ///< Desk Light
BtdrvAppearanceType_TrofferLight = 0x0586, ///< Troffer Light
BtdrvAppearanceType_PendantLight = 0x0587, ///< Pendant Light
BtdrvAppearanceType_InGroundLight = 0x0588, ///< In-ground Light
BtdrvAppearanceType_FloodLight = 0x0589, ///< Flood Light
BtdrvAppearanceType_UnderwaterLight = 0x058A, ///< Underwater Light
BtdrvAppearanceType_BollardWithLight = 0x058B, ///< Bollard with Light
BtdrvAppearanceType_PathwayLight = 0x058C, ///< Pathway Light
BtdrvAppearanceType_GardenLight = 0x058D, ///< Garden Light
BtdrvAppearanceType_PoleTopLight = 0x058E, ///< Pole-top Light
BtdrvAppearanceType_Spotlight = 0x058F, ///< Spotlight
BtdrvAppearanceType_LinearLight = 0x0590, ///< Linear Light
BtdrvAppearanceType_StreetLight = 0x0591, ///< Street Light
BtdrvAppearanceType_ShelvesLight = 0x0592, ///< Shelves Light
BtdrvAppearanceType_BayLight = 0x0593, ///< Bay Light
BtdrvAppearanceType_EmergencyExitLight = 0x0594, ///< Emergency Exit Light
BtdrvAppearanceType_LightController = 0x0595, ///< Light Controller
BtdrvAppearanceType_LightDriver = 0x0596, ///< Light Driver
BtdrvAppearanceType_Bulb = 0x0597, ///< Bulb
BtdrvAppearanceType_LowBayLight = 0x0598, ///< Low-bay Light
BtdrvAppearanceType_HighBayLight = 0x0599, ///< High-bay Light
BtdrvAppearanceType_CeilingFan = 0x05C1, ///< Ceiling Fan
BtdrvAppearanceType_AxialFan = 0x05C2, ///< Axial Fan
BtdrvAppearanceType_ExhaustFan = 0x05C3, ///< Exhaust Fan
BtdrvAppearanceType_PedestalFan = 0x05C4, ///< Pedestal Fan
BtdrvAppearanceType_DeskFan = 0x05C5, ///< Desk Fan
BtdrvAppearanceType_WallFan = 0x05C6, ///< Wall Fan
BtdrvAppearanceType_Thermostat = 0x0601, ///< Thermostat
BtdrvAppearanceType_Humidifier = 0x0602, ///< Humidifier
BtdrvAppearanceType_DeHumidifier = 0x0603, ///< De-humidifier
BtdrvAppearanceType_Heater = 0x0604, ///< Heater
BtdrvAppearanceType_HvacRadiator = 0x0605, ///< HVAC Radiator
BtdrvAppearanceType_HvacBoiler = 0x0606, ///< HVAC Boiler
BtdrvAppearanceType_HvacHeatPump = 0x0607, ///< HVAC Heat Pump
BtdrvAppearanceType_HvacInfraredHeater = 0x0608, ///< HVAC Infrared Heater
BtdrvAppearanceType_HvacRadiantPanelHeater = 0x0609, ///< HVAC Radiant Panel Heater
BtdrvAppearanceType_HvacFanHeater = 0x060A, ///< HVAC Fan Heater
BtdrvAppearanceType_HvacAirCurtain = 0x060B, ///< HVAC Air Curtain
BtdrvAppearanceType_HeatingRadiator = 0x06C1, ///< Heating Radiator
BtdrvAppearanceType_HeatingBoiler = 0x06C2, ///< Heating Boiler
BtdrvAppearanceType_HeatingHeatPump = 0x06C3, ///< Heating Heat Pump
BtdrvAppearanceType_HeatingInfraredHeater = 0x06C4, ///< Heating Infrared Heater
BtdrvAppearanceType_HeatingRadiantPanelHeater = 0x06C5, ///< Heating Radiant Panel Heater
BtdrvAppearanceType_HeatingFanHeater = 0x06C6, ///< Heating Fan Heater
BtdrvAppearanceType_HeatingAirCurtain = 0x06C7, ///< Heating Air Curtain
BtdrvAppearanceType_AccessDoor = 0x0701, ///< Access Door
BtdrvAppearanceType_GarageDoor = 0x0702, ///< Garage Door
BtdrvAppearanceType_EmergencyExitDoor = 0x0703, ///< Emergency Exit Door
BtdrvAppearanceType_AccessLock = 0x0704, ///< Access Lock
BtdrvAppearanceType_Elevator = 0x0705, ///< Elevator
BtdrvAppearanceType_Window = 0x0706, ///< Window
BtdrvAppearanceType_EntranceGate = 0x0707, ///< Entrance Gate
BtdrvAppearanceType_DoorLock = 0x0708, ///< Door Lock
BtdrvAppearanceType_Locker = 0x0709, ///< Locker
BtdrvAppearanceType_MotorizedGate = 0x0741, ///< Motorized Gate
BtdrvAppearanceType_Awning = 0x0742, ///< Awning
BtdrvAppearanceType_BlindsOrShades = 0x0743, ///< Blinds or Shades
BtdrvAppearanceType_Curtains = 0x0744, ///< Curtains
BtdrvAppearanceType_Screen = 0x0745, ///< Screen
BtdrvAppearanceType_PowerOutlet = 0x0781, ///< Power Outlet
BtdrvAppearanceType_PowerStrip = 0x0782, ///< Power Strip
BtdrvAppearanceType_Plug = 0x0783, ///< Plug
BtdrvAppearanceType_PowerSupply = 0x0784, ///< Power Supply
BtdrvAppearanceType_LedDriver = 0x0785, ///< LED Driver
BtdrvAppearanceType_FluorescentLampGear = 0x0786, ///< Fluorescent Lamp Gear
BtdrvAppearanceType_HidLampGear = 0x0787, ///< HID Lamp Gear
BtdrvAppearanceType_ChargeCase = 0x0788, ///< Charge Case
BtdrvAppearanceType_PowerBank = 0x0789, ///< Power Bank
BtdrvAppearanceType_IncandescentLightBulb = 0x07C1, ///< Incandescent Light Bulb
BtdrvAppearanceType_LedLamp = 0x07C2, ///< LED Lamp
BtdrvAppearanceType_HidLamp = 0x07C3, ///< HID Lamp
BtdrvAppearanceType_FluorescentLamp = 0x07C4, ///< Fluorescent Lamp
BtdrvAppearanceType_LedArray = 0x07C5, ///< LED Array
BtdrvAppearanceType_MultiColorLedArray = 0x07C6, ///< Multi-Color LED Array
BtdrvAppearanceType_LowVoltageHalogen = 0x07C7, ///< Low voltage halogen
BtdrvAppearanceType_OrganicLightEmittingDiodeOled = 0x07C8, ///< Organic light emitting diode (OLED)
BtdrvAppearanceType_WindowShades = 0x0801, ///< Window Shades
BtdrvAppearanceType_WindowBlinds = 0x0802, ///< Window Blinds
BtdrvAppearanceType_WindowAwning = 0x0803, ///< Window Awning
BtdrvAppearanceType_WindowCurtain = 0x0804, ///< Window Curtain
BtdrvAppearanceType_ExteriorShutter = 0x0805, ///< Exterior Shutter
BtdrvAppearanceType_ExteriorScreen = 0x0806, ///< Exterior Screen
BtdrvAppearanceType_StandaloneSpeaker = 0x0841, ///< Standalone Speaker
BtdrvAppearanceType_Soundbar = 0x0842, ///< Soundbar
BtdrvAppearanceType_BookshelfSpeaker = 0x0843, ///< Bookshelf Speaker
BtdrvAppearanceType_StandmountedSpeaker = 0x0844, ///< Standmounted Speaker
BtdrvAppearanceType_Speakerphone = 0x0845, ///< Speakerphone
BtdrvAppearanceType_Microphone = 0x0881, ///< Microphone
BtdrvAppearanceType_Alarm = 0x0882, ///< Alarm
BtdrvAppearanceType_Bell = 0x0883, ///< Bell
BtdrvAppearanceType_Horn = 0x0884, ///< Horn
BtdrvAppearanceType_BroadcastingDevice = 0x0885, ///< Broadcasting Device
BtdrvAppearanceType_ServiceDesk = 0x0886, ///< Service Desk
BtdrvAppearanceType_Kiosk = 0x0887, ///< Kiosk
BtdrvAppearanceType_BroadcastingRoom = 0x0888, ///< Broadcasting Room
BtdrvAppearanceType_Auditorium = 0x0889, ///< Auditorium
BtdrvAppearanceType_Car = 0x08C1, ///< Car
BtdrvAppearanceType_LargeGoodsVehicle = 0x08C2, ///< Large Goods Vehicle
BtdrvAppearanceType_2WheeledVehicle = 0x08C3, ///< 2-Wheeled Vehicle
BtdrvAppearanceType_Motorbike = 0x08C4, ///< Motorbike
BtdrvAppearanceType_Scooter = 0x08C5, ///< Scooter
BtdrvAppearanceType_Moped = 0x08C6, ///< Moped
BtdrvAppearanceType_3WheeledVehicle = 0x08C7, ///< 3-Wheeled Vehicle
BtdrvAppearanceType_LightVehicle = 0x08C8, ///< Light Vehicle
BtdrvAppearanceType_QuadBike = 0x08C9, ///< Quad Bike
BtdrvAppearanceType_Minibus = 0x08CA, ///< Minibus
BtdrvAppearanceType_Bus = 0x08CB, ///< Bus
BtdrvAppearanceType_Trolley = 0x08CC, ///< Trolley
BtdrvAppearanceType_AgriculturalVehicle = 0x08CD, ///< Agricultural Vehicle
BtdrvAppearanceType_CamperCaravan = 0x08CE, ///< Camper / Caravan
BtdrvAppearanceType_RecreationalVehicleMotorHome = 0x08CF, ///< Recreational Vehicle / Motor Home
BtdrvAppearanceType_Refrigerator = 0x0901, ///< Refrigerator
BtdrvAppearanceType_Freezer = 0x0902, ///< Freezer
BtdrvAppearanceType_Oven = 0x0903, ///< Oven
BtdrvAppearanceType_Microwave = 0x0904, ///< Microwave
BtdrvAppearanceType_Toaster = 0x0905, ///< Toaster
BtdrvAppearanceType_WashingMachine = 0x0906, ///< Washing Machine
BtdrvAppearanceType_Dryer = 0x0907, ///< Dryer
BtdrvAppearanceType_CoffeeMaker = 0x0908, ///< Coffee maker
BtdrvAppearanceType_ClothesIron = 0x0909, ///< Clothes iron
BtdrvAppearanceType_CurlingIron = 0x090A, ///< Curling iron
BtdrvAppearanceType_HairDryer = 0x090B, ///< Hair dryer
BtdrvAppearanceType_VacuumCleaner = 0x090C, ///< Vacuum cleaner
BtdrvAppearanceType_RoboticVacuumCleaner = 0x090D, ///< Robotic vacuum cleaner
BtdrvAppearanceType_RiceCooker = 0x090E, ///< Rice cooker
BtdrvAppearanceType_ClothesSteamer = 0x090F, ///< Clothes steamer
BtdrvAppearanceType_Earbud = 0x0941, ///< Earbud
BtdrvAppearanceType_Headset = 0x0942, ///< Headset
BtdrvAppearanceType_Headphones = 0x0943, ///< Headphones
BtdrvAppearanceType_NeckBand = 0x0944, ///< Neck Band
BtdrvAppearanceType_LightAircraft = 0x0981, ///< Light Aircraft
BtdrvAppearanceType_Microlight = 0x0982, ///< Microlight
BtdrvAppearanceType_Paraglider = 0x0983, ///< Paraglider
BtdrvAppearanceType_LargePassengerAircraft = 0x0984, ///< Large Passenger Aircraft
BtdrvAppearanceType_Amplifier = 0x09C1, ///< Amplifier
BtdrvAppearanceType_Receiver = 0x09C2, ///< Receiver
BtdrvAppearanceType_Radio = 0x09C3, ///< Radio
BtdrvAppearanceType_Tuner = 0x09C4, ///< Tuner
BtdrvAppearanceType_Turntable = 0x09C5, ///< Turntable
BtdrvAppearanceType_CdPlayer = 0x09C6, ///< CD Player
BtdrvAppearanceType_DvdPlayer = 0x09C7, ///< DVD Player
BtdrvAppearanceType_BlurayPlayer = 0x09C8, ///< Bluray Player
BtdrvAppearanceType_OpticalDiscPlayer = 0x09C9, ///< Optical Disc Player
BtdrvAppearanceType_SetTopBox = 0x09CA, ///< Set-Top Box
BtdrvAppearanceType_Television = 0x0A01, ///< Television
BtdrvAppearanceType_Monitor = 0x0A02, ///< Monitor
BtdrvAppearanceType_Projector = 0x0A03, ///< Projector
BtdrvAppearanceType_InEarHearingAid = 0x0A41, ///< In-ear hearing aid
BtdrvAppearanceType_BehindEarHearingAid = 0x0A42, ///< Behind-ear hearing aid
BtdrvAppearanceType_CochlearImplant = 0x0A43, ///< Cochlear Implant
BtdrvAppearanceType_HomeVideoGameConsole = 0x0A81, ///< Home Video Game Console
BtdrvAppearanceType_PortableHandheldConsole = 0x0A82, ///< Portable handheld console
BtdrvAppearanceType_FingertipPulseOximeter = 0x0C41, ///< Fingertip Pulse Oximeter
BtdrvAppearanceType_WristWornPulseOximeter = 0x0C42, ///< Wrist Worn Pulse Oximeter
BtdrvAppearanceType_PoweredWheelchair = 0x0CC1, ///< Powered Wheelchair
BtdrvAppearanceType_MobilityScooter = 0x0CC2, ///< Mobility Scooter
BtdrvAppearanceType_InsulinPumpDurablePump = 0x0D41, ///< Insulin Pump, durable pump
BtdrvAppearanceType_InsulinPumpPatchPump = 0x0D44, ///< Insulin Pump, patch pump
BtdrvAppearanceType_InsulinPen = 0x0D48, ///< Insulin Pen
BtdrvAppearanceType_HandheldSpirometer = 0x0DC1, ///< Handheld Spirometer
BtdrvAppearanceType_LocationDisplay = 0x1441, ///< Location Display
BtdrvAppearanceType_LocationAndNavigationDisplay = 0x1442, ///< Location and Navigation Display
BtdrvAppearanceType_LocationPod = 0x1443, ///< Location Pod
BtdrvAppearanceType_LocationAndNavigationPod = 0x1444, ///< Location and Navigation Pod
} BtdrvAppearanceType;
/// GattServiceUuidType
typedef enum {
BtdrvGattServiceUuidType_GenericAccess = 0x1800, ///< Generic Access
BtdrvGattServiceUuidType_GenericAttribute = 0x1801, ///< Generic Attribute
BtdrvGattServiceUuidType_ImmediateAlert = 0x1802, ///< Immediate Alert
BtdrvGattServiceUuidType_LinkLoss = 0x1803, ///< Link Loss
BtdrvGattServiceUuidType_TxPower = 0x1804, ///< Tx Power
BtdrvGattServiceUuidType_CurrentTime = 0x1805, ///< Current Time
BtdrvGattServiceUuidType_ReferenceTimeUpdate = 0x1806, ///< Reference Time Update
BtdrvGattServiceUuidType_NextDstChange = 0x1807, ///< Next DST Change
BtdrvGattServiceUuidType_Glucose = 0x1808, ///< Glucose
BtdrvGattServiceUuidType_HealthThermometer = 0x1809, ///< Health Thermometer
BtdrvGattServiceUuidType_DeviceInformation = 0x180A, ///< Device Information
BtdrvGattServiceUuidType_HeartRate = 0x180D, ///< Heart Rate
BtdrvGattServiceUuidType_PhoneAlertStatus = 0x180E, ///< Phone Alert Status
BtdrvGattServiceUuidType_Battery = 0x180F, ///< Battery
BtdrvGattServiceUuidType_BloodPressure = 0x1810, ///< Blood Pressure
BtdrvGattServiceUuidType_AlertNotification = 0x1811, ///< Alert Notification
BtdrvGattServiceUuidType_HumanInterfaceDevice = 0x1812, ///< Human Interface Device
BtdrvGattServiceUuidType_ScanParameters = 0x1813, ///< Scan Parameters
BtdrvGattServiceUuidType_RunningSpeedAndCadence = 0x1814, ///< Running Speed and Cadence
BtdrvGattServiceUuidType_AutomationIo = 0x1815, ///< Automation IO
BtdrvGattServiceUuidType_CyclingSpeedAndCadence = 0x1816, ///< Cycling Speed and Cadence
BtdrvGattServiceUuidType_CyclingPower = 0x1818, ///< Cycling Power
BtdrvGattServiceUuidType_LocationAndNavigation = 0x1819, ///< Location and Navigation
BtdrvGattServiceUuidType_EnvironmentalSensing = 0x181A, ///< Environmental Sensing
BtdrvGattServiceUuidType_BodyComposition = 0x181B, ///< Body Composition
BtdrvGattServiceUuidType_UserData = 0x181C, ///< User Data
BtdrvGattServiceUuidType_WeightScale = 0x181D, ///< Weight Scale
BtdrvGattServiceUuidType_BondManagement = 0x181E, ///< Bond Management
BtdrvGattServiceUuidType_ContinuousGlucoseMonitoring = 0x181F, ///< Continuous Glucose Monitoring
BtdrvGattServiceUuidType_InternetProtocolSupport = 0x1820, ///< Internet Protocol Support
BtdrvGattServiceUuidType_IndoorPositioning = 0x1821, ///< Indoor Positioning
BtdrvGattServiceUuidType_PulseOximeter = 0x1822, ///< Pulse Oximeter
BtdrvGattServiceUuidType_HttpProxy = 0x1823, ///< HTTP Proxy
BtdrvGattServiceUuidType_TransportDiscovery = 0x1824, ///< Transport Discovery
BtdrvGattServiceUuidType_ObjectTransfer = 0x1825, ///< Object Transfer
BtdrvGattServiceUuidType_FitnessMachine = 0x1826, ///< Fitness Machine
BtdrvGattServiceUuidType_MeshProvisioning = 0x1827, ///< Mesh Provisioning
BtdrvGattServiceUuidType_MeshProxy = 0x1828, ///< Mesh Proxy
BtdrvGattServiceUuidType_ReconnectionConfiguration = 0x1829, ///< Reconnection Configuration
BtdrvGattServiceUuidType_InsulinDelivery = 0x183A, ///< Insulin Delivery
BtdrvGattServiceUuidType_BinarySensor = 0x183B, ///< Binary Sensor
BtdrvGattServiceUuidType_EmergencyConfiguration = 0x183C, ///< Emergency Configuration
BtdrvGattServiceUuidType_AuthorizationControl = 0x183D, ///< Authorization Control
BtdrvGattServiceUuidType_PhysicalActivityMonitor = 0x183E, ///< Physical Activity Monitor
BtdrvGattServiceUuidType_ElapsedTime = 0x183F, ///< Elapsed Time
BtdrvGattServiceUuidType_GenericHealthSensor = 0x1840, ///< Generic Health Sensor
BtdrvGattServiceUuidType_AudioInputControl = 0x1843, ///< Audio Input Control
BtdrvGattServiceUuidType_VolumeControl = 0x1844, ///< Volume Control
BtdrvGattServiceUuidType_VolumeOffsetControl = 0x1845, ///< Volume Offset Control
BtdrvGattServiceUuidType_CoordinatedSetIdentification = 0x1846, ///< Coordinated Set Identification
BtdrvGattServiceUuidType_DeviceTime = 0x1847, ///< Device Time
BtdrvGattServiceUuidType_MediaControl = 0x1848, ///< Media Control
BtdrvGattServiceUuidType_GenericMediaControl = 0x1849, ///< Generic Media Control
BtdrvGattServiceUuidType_ConstantToneExtension = 0x184A, ///< Constant Tone Extension
BtdrvGattServiceUuidType_TelephoneBearer = 0x184B, ///< Telephone Bearer
BtdrvGattServiceUuidType_GenericTelephoneBearer = 0x184C, ///< Generic Telephone Bearer
BtdrvGattServiceUuidType_MicrophoneControl = 0x184D, ///< Microphone Control
BtdrvGattServiceUuidType_AudioStreamControl = 0x184E, ///< Audio Stream Control
BtdrvGattServiceUuidType_BroadcastAudioScan = 0x184F, ///< Broadcast Audio Scan
BtdrvGattServiceUuidType_PublishedAudioCapabilities = 0x1850, ///< Published Audio Capabilities
BtdrvGattServiceUuidType_BasicAudioAnnouncement = 0x1851, ///< Basic Audio Announcement
BtdrvGattServiceUuidType_BroadcastAudioAnnouncement = 0x1852, ///< Broadcast Audio Announcement
BtdrvGattServiceUuidType_CommonAudio = 0x1853, ///< Common Audio
BtdrvGattServiceUuidType_HearingAccess = 0x1854, ///< Hearing Access
BtdrvGattServiceUuidType_TelephonyAndMediaAudio = 0x1855, ///< Telephony and Media Audio
BtdrvGattServiceUuidType_PublicBroadcastAnnouncement = 0x1856, ///< Public Broadcast Announcement
BtdrvGattServiceUuidType_ElectronicShelfLabel = 0x1857, ///< Electronic Shelf Label
} BtdrvGattServiceUuidType;
/// GattCharacteristicUuidType
typedef enum {
BtdrvGattCharacteristicUuidType_DeviceName = 0x2A00, ///< Device Name
BtdrvGattCharacteristicUuidType_Appearance = 0x2A01, ///< Appearance
BtdrvGattCharacteristicUuidType_PeripheralPrivacyFlag = 0x2A02, ///< Peripheral Privacy Flag
BtdrvGattCharacteristicUuidType_ReconnectionAddress = 0x2A03, ///< Reconnection Address
BtdrvGattCharacteristicUuidType_PeripheralPreferredConnectionParameters = 0x2A04, ///< Peripheral Preferred Connection Parameters
BtdrvGattCharacteristicUuidType_ServiceChanged = 0x2A05, ///< Service Changed
BtdrvGattCharacteristicUuidType_AlertLevel = 0x2A06, ///< Alert Level
BtdrvGattCharacteristicUuidType_TxPowerLevel = 0x2A07, ///< Tx Power Level
BtdrvGattCharacteristicUuidType_DateTime = 0x2A08, ///< Date Time
BtdrvGattCharacteristicUuidType_DayOfWeek = 0x2A09, ///< Day of Week
BtdrvGattCharacteristicUuidType_DayDateTime = 0x2A0A, ///< Day Date Time
BtdrvGattCharacteristicUuidType_ExactTime256 = 0x2A0C, ///< Exact Time 256
BtdrvGattCharacteristicUuidType_DstOffset = 0x2A0D, ///< DST Offset
BtdrvGattCharacteristicUuidType_TimeZone = 0x2A0E, ///< Time Zone
BtdrvGattCharacteristicUuidType_LocalTimeInformation = 0x2A0F, ///< Local Time Information
BtdrvGattCharacteristicUuidType_TimeWithDst = 0x2A11, ///< Time with DST
BtdrvGattCharacteristicUuidType_TimeAccuracy = 0x2A12, ///< Time Accuracy
BtdrvGattCharacteristicUuidType_TimeSource = 0x2A13, ///< Time Source
BtdrvGattCharacteristicUuidType_ReferenceTimeInformation = 0x2A14, ///< Reference Time Information
BtdrvGattCharacteristicUuidType_TimeUpdateControlPoint = 0x2A16, ///< Time Update Control Point
BtdrvGattCharacteristicUuidType_TimeUpdateState = 0x2A17, ///< Time Update State
BtdrvGattCharacteristicUuidType_GlucoseMeasurement = 0x2A18, ///< Glucose Measurement
BtdrvGattCharacteristicUuidType_BatteryLevel = 0x2A19, ///< Battery Level
BtdrvGattCharacteristicUuidType_TemperatureMeasurement = 0x2A1C, ///< Temperature Measurement
BtdrvGattCharacteristicUuidType_TemperatureType = 0x2A1D, ///< Temperature Type
BtdrvGattCharacteristicUuidType_IntermediateTemperature = 0x2A1E, ///< Intermediate Temperature
BtdrvGattCharacteristicUuidType_MeasurementInterval = 0x2A21, ///< Measurement Interval
BtdrvGattCharacteristicUuidType_BootKeyboardInputReport = 0x2A22, ///< Boot Keyboard Input Report
BtdrvGattCharacteristicUuidType_SystemId = 0x2A23, ///< System ID
BtdrvGattCharacteristicUuidType_ModelNumberString = 0x2A24, ///< Model Number String
BtdrvGattCharacteristicUuidType_SerialNumberString = 0x2A25, ///< Serial Number String
BtdrvGattCharacteristicUuidType_FirmwareRevisionString = 0x2A26, ///< Firmware Revision String
BtdrvGattCharacteristicUuidType_HardwareRevisionString = 0x2A27, ///< Hardware Revision String
BtdrvGattCharacteristicUuidType_SoftwareRevisionString = 0x2A28, ///< Software Revision String
BtdrvGattCharacteristicUuidType_ManufacturerNameString = 0x2A29, ///< Manufacturer Name String
BtdrvGattCharacteristicUuidType_IeeeRegulatoryCertificationDataList = 0x2A2A, ///< IEEE 11073-20601 Regulatory Certification Data List
BtdrvGattCharacteristicUuidType_CurrentTime = 0x2A2B, ///< Current Time
BtdrvGattCharacteristicUuidType_MagneticDeclination = 0x2A2C, ///< Magnetic Declination
BtdrvGattCharacteristicUuidType_ScanRefresh = 0x2A31, ///< Scan Refresh
BtdrvGattCharacteristicUuidType_BootKeyboardOutputReport = 0x2A32, ///< Boot Keyboard Output Report
BtdrvGattCharacteristicUuidType_BootMouseInputReport = 0x2A33, ///< Boot Mouse Input Report
BtdrvGattCharacteristicUuidType_GlucoseMeasurementContext = 0x2A34, ///< Glucose Measurement Context
BtdrvGattCharacteristicUuidType_BloodPressureMeasurement = 0x2A35, ///< Blood Pressure Measurement
BtdrvGattCharacteristicUuidType_IntermediateCuffPressure = 0x2A36, ///< Intermediate Cuff Pressure
BtdrvGattCharacteristicUuidType_HeartRateMeasurement = 0x2A37, ///< Heart Rate Measurement
BtdrvGattCharacteristicUuidType_BodySensorLocation = 0x2A38, ///< Body Sensor Location
BtdrvGattCharacteristicUuidType_HeartRateControlPoint = 0x2A39, ///< Heart Rate Control Point
BtdrvGattCharacteristicUuidType_AlertStatus = 0x2A3F, ///< Alert Status
BtdrvGattCharacteristicUuidType_RingerControlPoint = 0x2A40, ///< Ringer Control Point
BtdrvGattCharacteristicUuidType_RingerSetting = 0x2A41, ///< Ringer Setting
BtdrvGattCharacteristicUuidType_AlertCategoryIdBitMask = 0x2A42, ///< Alert Category ID Bit Mask
BtdrvGattCharacteristicUuidType_AlertCategoryId = 0x2A43, ///< Alert Category ID
BtdrvGattCharacteristicUuidType_AlertNotificationControlPoint = 0x2A44, ///< Alert Notification Control Point
BtdrvGattCharacteristicUuidType_UnreadAlertStatus = 0x2A45, ///< Unread Alert Status
BtdrvGattCharacteristicUuidType_NewAlert = 0x2A46, ///< New Alert
BtdrvGattCharacteristicUuidType_SupportedNewAlertCategory = 0x2A47, ///< Supported New Alert Category
BtdrvGattCharacteristicUuidType_SupportedUnreadAlertCategory = 0x2A48, ///< Supported Unread Alert Category
BtdrvGattCharacteristicUuidType_BloodPressureFeature = 0x2A49, ///< Blood Pressure Feature
BtdrvGattCharacteristicUuidType_HidInformation = 0x2A4A, ///< HID Information
BtdrvGattCharacteristicUuidType_ReportMap = 0x2A4B, ///< Report Map
BtdrvGattCharacteristicUuidType_HidControlPoint = 0x2A4C, ///< HID Control Point
BtdrvGattCharacteristicUuidType_Report = 0x2A4D, ///< Report
BtdrvGattCharacteristicUuidType_ProtocolMode = 0x2A4E, ///< Protocol Mode
BtdrvGattCharacteristicUuidType_ScanIntervalWindow = 0x2A4F, ///< Scan Interval Window
BtdrvGattCharacteristicUuidType_PnpId = 0x2A50, ///< PnP ID
BtdrvGattCharacteristicUuidType_GlucoseFeature = 0x2A51, ///< Glucose Feature
BtdrvGattCharacteristicUuidType_RecordAccessControlPoint = 0x2A52, ///< Record Access Control Point
BtdrvGattCharacteristicUuidType_RscMeasurement = 0x2A53, ///< RSC Measurement
BtdrvGattCharacteristicUuidType_RscFeature = 0x2A54, ///< RSC Feature
BtdrvGattCharacteristicUuidType_ScControlPoint = 0x2A55, ///< SC Control Point
BtdrvGattCharacteristicUuidType_Aggregate = 0x2A5A, ///< Aggregate
BtdrvGattCharacteristicUuidType_CscMeasurement = 0x2A5B, ///< CSC Measurement
BtdrvGattCharacteristicUuidType_CscFeature = 0x2A5C, ///< CSC Feature
BtdrvGattCharacteristicUuidType_SensorLocation = 0x2A5D, ///< Sensor Location
BtdrvGattCharacteristicUuidType_PlxSpotCheckMeasurement = 0x2A5E, ///< PLX Spot-Check Measurement
BtdrvGattCharacteristicUuidType_PlxContinuousMeasurement = 0x2A5F, ///< PLX Continuous Measurement
BtdrvGattCharacteristicUuidType_PlxFeatures = 0x2A60, ///< PLX Features
BtdrvGattCharacteristicUuidType_CyclingPowerMeasurement = 0x2A63, ///< Cycling Power Measurement
BtdrvGattCharacteristicUuidType_CyclingPowerVector = 0x2A64, ///< Cycling Power Vector
BtdrvGattCharacteristicUuidType_CyclingPowerFeature = 0x2A65, ///< Cycling Power Feature
BtdrvGattCharacteristicUuidType_CyclingPowerControlPoint = 0x2A66, ///< Cycling Power Control Point
BtdrvGattCharacteristicUuidType_LocationAndSpeed = 0x2A67, ///< Location and Speed
BtdrvGattCharacteristicUuidType_Navigation = 0x2A68, ///< Navigation
BtdrvGattCharacteristicUuidType_PositionQuality = 0x2A69, ///< Position Quality
BtdrvGattCharacteristicUuidType_LnFeature = 0x2A6A, ///< LN Feature
BtdrvGattCharacteristicUuidType_LnControlPoint = 0x2A6B, ///< LN Control Point
BtdrvGattCharacteristicUuidType_Elevation = 0x2A6C, ///< Elevation
BtdrvGattCharacteristicUuidType_Pressure = 0x2A6D, ///< Pressure
BtdrvGattCharacteristicUuidType_Temperature = 0x2A6E, ///< Temperature
BtdrvGattCharacteristicUuidType_Humidity = 0x2A6F, ///< Humidity
BtdrvGattCharacteristicUuidType_TrueWindSpeed = 0x2A70, ///< True Wind Speed
BtdrvGattCharacteristicUuidType_TrueWindDirection = 0x2A71, ///< True Wind Direction
BtdrvGattCharacteristicUuidType_ApparentWindSpeed = 0x2A72, ///< Apparent Wind Speed
BtdrvGattCharacteristicUuidType_ApparentWindDirection = 0x2A73, ///< Apparent Wind Direction
BtdrvGattCharacteristicUuidType_GustFactor = 0x2A74, ///< Gust Factor
BtdrvGattCharacteristicUuidType_PollenConcentration = 0x2A75, ///< Pollen Concentration
BtdrvGattCharacteristicUuidType_UvIndex = 0x2A76, ///< UV Index
BtdrvGattCharacteristicUuidType_Irradiance = 0x2A77, ///< Irradiance
BtdrvGattCharacteristicUuidType_Rainfall = 0x2A78, ///< Rainfall
BtdrvGattCharacteristicUuidType_WindChill = 0x2A79, ///< Wind Chill
BtdrvGattCharacteristicUuidType_HeatIndex = 0x2A7A, ///< Heat Index
BtdrvGattCharacteristicUuidType_DewPoint = 0x2A7B, ///< Dew Point
BtdrvGattCharacteristicUuidType_DescriptorValueChanged = 0x2A7D, ///< Descriptor Value Changed
BtdrvGattCharacteristicUuidType_AerobicHeartRateLowerLimit = 0x2A7E, ///< Aerobic Heart Rate Lower Limit
BtdrvGattCharacteristicUuidType_AerobicThreshold = 0x2A7F, ///< Aerobic Threshold
BtdrvGattCharacteristicUuidType_Age = 0x2A80, ///< Age
BtdrvGattCharacteristicUuidType_AnaerobicHeartRateLowerLimit = 0x2A81, ///< Anaerobic Heart Rate Lower Limit
BtdrvGattCharacteristicUuidType_AnaerobicHeartRateUpperLimit = 0x2A82, ///< Anaerobic Heart Rate Upper Limit
BtdrvGattCharacteristicUuidType_AnaerobicThreshold = 0x2A83, ///< Anaerobic Threshold
BtdrvGattCharacteristicUuidType_AerobicHeartRateUpperLimit = 0x2A84, ///< Aerobic Heart Rate Upper Limit
BtdrvGattCharacteristicUuidType_DateOfBirth = 0x2A85, ///< Date of Birth
BtdrvGattCharacteristicUuidType_DateOfThresholdAssessment = 0x2A86, ///< Date of Threshold Assessment
BtdrvGattCharacteristicUuidType_EmailAddress = 0x2A87, ///< Email Address
BtdrvGattCharacteristicUuidType_FatBurnHeartRateLowerLimit = 0x2A88, ///< Fat Burn Heart Rate Lower Limit
BtdrvGattCharacteristicUuidType_FatBurnHeartRateUpperLimit = 0x2A89, ///< Fat Burn Heart Rate Upper Limit
BtdrvGattCharacteristicUuidType_FirstName = 0x2A8A, ///< First Name
BtdrvGattCharacteristicUuidType_FiveZoneHeartRateLimits = 0x2A8B, ///< Five Zone Heart Rate Limits
BtdrvGattCharacteristicUuidType_Gender = 0x2A8C, ///< Gender
BtdrvGattCharacteristicUuidType_HeartRateMax = 0x2A8D, ///< Heart Rate Max
BtdrvGattCharacteristicUuidType_Height = 0x2A8E, ///< Height
BtdrvGattCharacteristicUuidType_HipCircumference = 0x2A8F, ///< Hip Circumference
BtdrvGattCharacteristicUuidType_LastName = 0x2A90, ///< Last Name
BtdrvGattCharacteristicUuidType_MaximumRecommendedHeartRate = 0x2A91, ///< Maximum Recommended Heart Rate
BtdrvGattCharacteristicUuidType_RestingHeartRate = 0x2A92, ///< Resting Heart Rate
BtdrvGattCharacteristicUuidType_SportTypeForAerobicAndAnaerobicThresholds = 0x2A93, ///< Sport Type for Aerobic and Anaerobic Thresholds
BtdrvGattCharacteristicUuidType_ThreeZoneHeartRateLimits = 0x2A94, ///< Three Zone Heart Rate Limits
BtdrvGattCharacteristicUuidType_TwoZoneHeartRateLimits = 0x2A95, ///< Two Zone Heart Rate Limits
BtdrvGattCharacteristicUuidType_Vo2Max = 0x2A96, ///< VO2 Max
BtdrvGattCharacteristicUuidType_WaistCircumference = 0x2A97, ///< Waist Circumference
BtdrvGattCharacteristicUuidType_Weight = 0x2A98, ///< Weight
BtdrvGattCharacteristicUuidType_DatabaseChangeIncrement = 0x2A99, ///< Database Change Increment
BtdrvGattCharacteristicUuidType_UserIndex = 0x2A9A, ///< User Index
BtdrvGattCharacteristicUuidType_BodyCompositionFeature = 0x2A9B, ///< Body Composition Feature
BtdrvGattCharacteristicUuidType_BodyCompositionMeasurement = 0x2A9C, ///< Body Composition Measurement
BtdrvGattCharacteristicUuidType_WeightMeasurement = 0x2A9D, ///< Weight Measurement
BtdrvGattCharacteristicUuidType_WeightScaleFeature = 0x2A9E, ///< Weight Scale Feature
BtdrvGattCharacteristicUuidType_UserControlPoint = 0x2A9F, ///< User Control Point
BtdrvGattCharacteristicUuidType_MagneticFluxDensity2D = 0x2AA0, ///< Magnetic Flux Density - 2D
BtdrvGattCharacteristicUuidType_MagneticFluxDensity3D = 0x2AA1, ///< Magnetic Flux Density - 3D
BtdrvGattCharacteristicUuidType_Language = 0x2AA2, ///< Language
BtdrvGattCharacteristicUuidType_BarometricPressureTrend = 0x2AA3, ///< Barometric Pressure Trend
BtdrvGattCharacteristicUuidType_BondManagementControlPoint = 0x2AA4, ///< Bond Management Control Point
BtdrvGattCharacteristicUuidType_BondManagementFeature = 0x2AA5, ///< Bond Management Feature
BtdrvGattCharacteristicUuidType_CentralAddressResolution = 0x2AA6, ///< Central Address Resolution
BtdrvGattCharacteristicUuidType_CgmMeasurement = 0x2AA7, ///< CGM Measurement
BtdrvGattCharacteristicUuidType_CgmFeature = 0x2AA8, ///< CGM Feature
BtdrvGattCharacteristicUuidType_CgmStatus = 0x2AA9, ///< CGM Status
BtdrvGattCharacteristicUuidType_CgmSessionStartTime = 0x2AAA, ///< CGM Session Start Time
BtdrvGattCharacteristicUuidType_CgmSessionRunTime = 0x2AAB, ///< CGM Session Run Time
BtdrvGattCharacteristicUuidType_CgmSpecificOpsControlPoint = 0x2AAC, ///< CGM Specific Ops Control Point
BtdrvGattCharacteristicUuidType_IndoorPositioningConfiguration = 0x2AAD, ///< Indoor Positioning Configuration
BtdrvGattCharacteristicUuidType_Latitude = 0x2AAE, ///< Latitude
BtdrvGattCharacteristicUuidType_Longitude = 0x2AAF, ///< Longitude
BtdrvGattCharacteristicUuidType_LocalNorthCoordinate = 0x2AB0, ///< Local North Coordinate
BtdrvGattCharacteristicUuidType_LocalEastCoordinate = 0x2AB1, ///< Local East Coordinate
BtdrvGattCharacteristicUuidType_FloorNumber = 0x2AB2, ///< Floor Number
BtdrvGattCharacteristicUuidType_Altitude = 0x2AB3, ///< Altitude
BtdrvGattCharacteristicUuidType_Uncertainty = 0x2AB4, ///< Uncertainty
BtdrvGattCharacteristicUuidType_LocationName = 0x2AB5, ///< Location Name
BtdrvGattCharacteristicUuidType_Uri = 0x2AB6, ///< URI
BtdrvGattCharacteristicUuidType_HttpHeaders = 0x2AB7, ///< HTTP Headers
BtdrvGattCharacteristicUuidType_HttpStatusCode = 0x2AB8, ///< HTTP Status Code
BtdrvGattCharacteristicUuidType_HttpEntityBody = 0x2AB9, ///< HTTP Entity Body
BtdrvGattCharacteristicUuidType_HttpControlPoint = 0x2ABA, ///< HTTP Control Point
BtdrvGattCharacteristicUuidType_HttpsSecurity = 0x2ABB, ///< HTTPS Security
BtdrvGattCharacteristicUuidType_TdsControlPoint = 0x2ABC, ///< TDS Control Point
BtdrvGattCharacteristicUuidType_OtsFeature = 0x2ABD, ///< OTS Feature
BtdrvGattCharacteristicUuidType_ObjectName = 0x2ABE, ///< Object Name
BtdrvGattCharacteristicUuidType_ObjectType = 0x2ABF, ///< Object Type
BtdrvGattCharacteristicUuidType_ObjectSize = 0x2AC0, ///< Object Size
BtdrvGattCharacteristicUuidType_ObjectFirstCreated = 0x2AC1, ///< Object First-Created
BtdrvGattCharacteristicUuidType_ObjectLastModified = 0x2AC2, ///< Object Last-Modified
BtdrvGattCharacteristicUuidType_ObjectId = 0x2AC3, ///< Object ID
BtdrvGattCharacteristicUuidType_ObjectProperties = 0x2AC4, ///< Object Properties
BtdrvGattCharacteristicUuidType_ObjectActionControlPoint = 0x2AC5, ///< Object Action Control Point
BtdrvGattCharacteristicUuidType_ObjectListControlPoint = 0x2AC6, ///< Object List Control Point
BtdrvGattCharacteristicUuidType_ObjectListFilter = 0x2AC7, ///< Object List Filter
BtdrvGattCharacteristicUuidType_ObjectChanged = 0x2AC8, ///< Object Changed
BtdrvGattCharacteristicUuidType_ResolvablePrivateAddressOnly = 0x2AC9, ///< Resolvable Private Address Only
BtdrvGattCharacteristicUuidType_FitnessMachineFeature = 0x2ACC, ///< Fitness Machine Feature
BtdrvGattCharacteristicUuidType_TreadmillData = 0x2ACD, ///< Treadmill Data
BtdrvGattCharacteristicUuidType_CrossTrainerData = 0x2ACE, ///< Cross Trainer Data
BtdrvGattCharacteristicUuidType_StepClimberData = 0x2ACF, ///< Step Climber Data
BtdrvGattCharacteristicUuidType_StairClimberData = 0x2AD0, ///< Stair Climber Data
BtdrvGattCharacteristicUuidType_RowerData = 0x2AD1, ///< Rower Data
BtdrvGattCharacteristicUuidType_IndoorBikeData = 0x2AD2, ///< Indoor Bike Data
BtdrvGattCharacteristicUuidType_TrainingStatus = 0x2AD3, ///< Training Status
BtdrvGattCharacteristicUuidType_SupportedSpeedRange = 0x2AD4, ///< Supported Speed Range
BtdrvGattCharacteristicUuidType_SupportedInclinationRange = 0x2AD5, ///< Supported Inclination Range
BtdrvGattCharacteristicUuidType_SupportedResistanceLevelRange = 0x2AD6, ///< Supported Resistance Level Range
BtdrvGattCharacteristicUuidType_SupportedHeartRateRange = 0x2AD7, ///< Supported Heart Rate Range
BtdrvGattCharacteristicUuidType_SupportedPowerRange = 0x2AD8, ///< Supported Power Range
BtdrvGattCharacteristicUuidType_FitnessMachineControlPoint = 0x2AD9, ///< Fitness Machine Control Point
BtdrvGattCharacteristicUuidType_FitnessMachineStatus = 0x2ADA, ///< Fitness Machine Status
BtdrvGattCharacteristicUuidType_MeshProvisioningDataIn = 0x2ADB, ///< Mesh Provisioning Data In
BtdrvGattCharacteristicUuidType_MeshProvisioningDataOut = 0x2ADC, ///< Mesh Provisioning Data Out
BtdrvGattCharacteristicUuidType_MeshProxyDataIn = 0x2ADD, ///< Mesh Proxy Data In
BtdrvGattCharacteristicUuidType_MeshProxyDataOut = 0x2ADE, ///< Mesh Proxy Data Out
BtdrvGattCharacteristicUuidType_AverageCurrent = 0x2AE0, ///< Average Current
BtdrvGattCharacteristicUuidType_AverageVoltage = 0x2AE1, ///< Average Voltage
BtdrvGattCharacteristicUuidType_Boolean = 0x2AE2, ///< Boolean
BtdrvGattCharacteristicUuidType_ChromaticDistanceFromPlanckian = 0x2AE3, ///< Chromatic Distance from Planckian
BtdrvGattCharacteristicUuidType_ChromaticityCoordinates = 0x2AE4, ///< Chromaticity Coordinates
BtdrvGattCharacteristicUuidType_ChromaticityInCctAndDuvValues = 0x2AE5, ///< Chromaticity in CCT and Duv Values
BtdrvGattCharacteristicUuidType_ChromaticityTolerance = 0x2AE6, ///< Chromaticity Tolerance
BtdrvGattCharacteristicUuidType_CieColorRenderingIndex = 0x2AE7, ///< CIE 13.3-1995 Color Rendering Index
BtdrvGattCharacteristicUuidType_Coefficient = 0x2AE8, ///< Coefficient
BtdrvGattCharacteristicUuidType_CorrelatedColorTemperature = 0x2AE9, ///< Correlated Color Temperature
BtdrvGattCharacteristicUuidType_Count16 = 0x2AEA, ///< Count 16
BtdrvGattCharacteristicUuidType_Count24 = 0x2AEB, ///< Count 24
BtdrvGattCharacteristicUuidType_CountryCode = 0x2AEC, ///< Country Code
BtdrvGattCharacteristicUuidType_DateUtc = 0x2AED, ///< Date UTC
BtdrvGattCharacteristicUuidType_ElectricCurrent = 0x2AEE, ///< Electric Current
BtdrvGattCharacteristicUuidType_ElectricCurrentRange = 0x2AEF, ///< Electric Current Range
BtdrvGattCharacteristicUuidType_ElectricCurrentSpecification = 0x2AF0, ///< Electric Current Specification
BtdrvGattCharacteristicUuidType_ElectricCurrentStatistics = 0x2AF1, ///< Electric Current Statistics
BtdrvGattCharacteristicUuidType_Energy = 0x2AF2, ///< Energy
BtdrvGattCharacteristicUuidType_EnergyInAPeriodOfDay = 0x2AF3, ///< Energy in a Period of Day
BtdrvGattCharacteristicUuidType_EventStatistics = 0x2AF4, ///< Event Statistics
BtdrvGattCharacteristicUuidType_FixedString16 = 0x2AF5, ///< Fixed String 16
BtdrvGattCharacteristicUuidType_FixedString24 = 0x2AF6, ///< Fixed String 24
BtdrvGattCharacteristicUuidType_FixedString36 = 0x2AF7, ///< Fixed String 36
BtdrvGattCharacteristicUuidType_FixedString8 = 0x2AF8, ///< Fixed String 8
BtdrvGattCharacteristicUuidType_GenericLevel = 0x2AF9, ///< Generic Level
BtdrvGattCharacteristicUuidType_GlobalTradeItemNumber = 0x2AFA, ///< Global Trade Item Number
BtdrvGattCharacteristicUuidType_Illuminance = 0x2AFB, ///< Illuminance
BtdrvGattCharacteristicUuidType_LuminousEfficacy = 0x2AFC, ///< Luminous Efficacy
BtdrvGattCharacteristicUuidType_LuminousEnergy = 0x2AFD, ///< Luminous Energy
BtdrvGattCharacteristicUuidType_LuminousExposure = 0x2AFE, ///< Luminous Exposure
BtdrvGattCharacteristicUuidType_LuminousFlux = 0x2AFF, ///< Luminous Flux
BtdrvGattCharacteristicUuidType_LuminousFluxRange = 0x2B00, ///< Luminous Flux Range
BtdrvGattCharacteristicUuidType_LuminousIntensity = 0x2B01, ///< Luminous Intensity
BtdrvGattCharacteristicUuidType_MassFlow = 0x2B02, ///< Mass Flow
BtdrvGattCharacteristicUuidType_PerceivedLightness = 0x2B03, ///< Perceived Lightness
BtdrvGattCharacteristicUuidType_Percentage8 = 0x2B04, ///< Percentage 8
BtdrvGattCharacteristicUuidType_Power = 0x2B05, ///< Power
BtdrvGattCharacteristicUuidType_PowerSpecification = 0x2B06, ///< Power Specification
BtdrvGattCharacteristicUuidType_RelativeRuntimeInACurrentRange = 0x2B07, ///< Relative Runtime in a Current Range
BtdrvGattCharacteristicUuidType_RelativeRuntimeInAGenericLevelRange = 0x2B08, ///< Relative Runtime in a Generic Level Range
BtdrvGattCharacteristicUuidType_RelativeValueInAVoltageRange = 0x2B09, ///< Relative Value in a Voltage Range
BtdrvGattCharacteristicUuidType_RelativeValueInAnIlluminanceRange = 0x2B0A, ///< Relative Value in an Illuminance Range
BtdrvGattCharacteristicUuidType_RelativeValueInAPeriodOfDay = 0x2B0B, ///< Relative Value in a Period of Day
BtdrvGattCharacteristicUuidType_RelativeValueInATemperatureRange = 0x2B0C, ///< Relative Value in a Temperature Range
BtdrvGattCharacteristicUuidType_Temperature8 = 0x2B0D, ///< Temperature 8
BtdrvGattCharacteristicUuidType_Temperature8InAPeriodOfDay = 0x2B0E, ///< Temperature 8 in a Period of Day
BtdrvGattCharacteristicUuidType_Temperature8Statistics = 0x2B0F, ///< Temperature 8 Statistics
BtdrvGattCharacteristicUuidType_TemperatureRange = 0x2B10, ///< Temperature Range
BtdrvGattCharacteristicUuidType_TemperatureStatistics = 0x2B11, ///< Temperature Statistics
BtdrvGattCharacteristicUuidType_TimeDecihour8 = 0x2B12, ///< Time Decihour 8
BtdrvGattCharacteristicUuidType_TimeExponential8 = 0x2B13, ///< Time Exponential 8
BtdrvGattCharacteristicUuidType_TimeHour24 = 0x2B14, ///< Time Hour 24
BtdrvGattCharacteristicUuidType_TimeMillisecond24 = 0x2B15, ///< Time Millisecond 24
BtdrvGattCharacteristicUuidType_TimeSecond16 = 0x2B16, ///< Time Second 16
BtdrvGattCharacteristicUuidType_TimeSecond8 = 0x2B17, ///< Time Second 8
BtdrvGattCharacteristicUuidType_Voltage = 0x2B18, ///< Voltage
BtdrvGattCharacteristicUuidType_VoltageSpecification = 0x2B19, ///< Voltage Specification
BtdrvGattCharacteristicUuidType_VoltageStatistics = 0x2B1A, ///< Voltage Statistics
BtdrvGattCharacteristicUuidType_VolumeFlow = 0x2B1B, ///< Volume Flow
BtdrvGattCharacteristicUuidType_ChromaticityCoordinate = 0x2B1C, ///< Chromaticity Coordinate
BtdrvGattCharacteristicUuidType_RcFeature = 0x2B1D, ///< RC Feature
BtdrvGattCharacteristicUuidType_RcSettings = 0x2B1E, ///< RC Settings
BtdrvGattCharacteristicUuidType_ReconnectionConfigurationControlPoint = 0x2B1F, ///< Reconnection Configuration Control Point
BtdrvGattCharacteristicUuidType_IddStatusChanged = 0x2B20, ///< IDD Status Changed
BtdrvGattCharacteristicUuidType_IddStatus = 0x2B21, ///< IDD Status
BtdrvGattCharacteristicUuidType_IddAnnunciationStatus = 0x2B22, ///< IDD Annunciation Status
BtdrvGattCharacteristicUuidType_IddFeatures = 0x2B23, ///< IDD Features
BtdrvGattCharacteristicUuidType_IddStatusReaderControlPoint = 0x2B24, ///< IDD Status Reader Control Point
BtdrvGattCharacteristicUuidType_IddCommandControlPoint = 0x2B25, ///< IDD Command Control Point
BtdrvGattCharacteristicUuidType_IddCommandData = 0x2B26, ///< IDD Command Data
BtdrvGattCharacteristicUuidType_IddRecordAccessControlPoint = 0x2B27, ///< IDD Record Access Control Point
BtdrvGattCharacteristicUuidType_IddHistoryData = 0x2B28, ///< IDD History Data
BtdrvGattCharacteristicUuidType_ClientSupportedFeatures = 0x2B29, ///< Client Supported Features
BtdrvGattCharacteristicUuidType_DatabaseHash = 0x2B2A, ///< Database Hash
BtdrvGattCharacteristicUuidType_BssControlPoint = 0x2B2B, ///< BSS Control Point
BtdrvGattCharacteristicUuidType_BssResponse = 0x2B2C, ///< BSS Response
BtdrvGattCharacteristicUuidType_EmergencyId = 0x2B2D, ///< Emergency ID
BtdrvGattCharacteristicUuidType_EmergencyText = 0x2B2E, ///< Emergency Text
BtdrvGattCharacteristicUuidType_AcsStatus = 0x2B2F, ///< ACS Status
BtdrvGattCharacteristicUuidType_AcsDataIn = 0x2B30, ///< ACS Data In
BtdrvGattCharacteristicUuidType_AcsDataOutNotify = 0x2B31, ///< ACS Data Out Notify
BtdrvGattCharacteristicUuidType_AcsDataOutIndicate = 0x2B32, ///< ACS Data Out Indicate
BtdrvGattCharacteristicUuidType_AcsControlPoint = 0x2B33, ///< ACS Control Point
BtdrvGattCharacteristicUuidType_EnhancedBloodPressureMeasurement = 0x2B34, ///< Enhanced Blood Pressure Measurement
BtdrvGattCharacteristicUuidType_EnhancedIntermediateCuffPressure = 0x2B35, ///< Enhanced Intermediate Cuff Pressure
BtdrvGattCharacteristicUuidType_BloodPressureRecord = 0x2B36, ///< Blood Pressure Record
BtdrvGattCharacteristicUuidType_RegisteredUser = 0x2B37, ///< Registered User
BtdrvGattCharacteristicUuidType_BrEdrHandoverData = 0x2B38, ///< BR-EDR Handover Data
BtdrvGattCharacteristicUuidType_BluetoothSigData = 0x2B39, ///< Bluetooth SIG Data
BtdrvGattCharacteristicUuidType_ServerSupportedFeatures = 0x2B3A, ///< Server Supported Features
BtdrvGattCharacteristicUuidType_PhysicalActivityMonitorFeatures = 0x2B3B, ///< Physical Activity Monitor Features
BtdrvGattCharacteristicUuidType_GeneralActivityInstantaneousData = 0x2B3C, ///< General Activity Instantaneous Data
BtdrvGattCharacteristicUuidType_GeneralActivitySummaryData = 0x2B3D, ///< General Activity Summary Data
BtdrvGattCharacteristicUuidType_CardiorespiratoryActivityInstantaneousData = 0x2B3E, ///< CardioRespiratory Activity Instantaneous Data
BtdrvGattCharacteristicUuidType_CardiorespiratoryActivitySummaryData = 0x2B3F, ///< CardioRespiratory Activity Summary Data
BtdrvGattCharacteristicUuidType_StepCounterActivitySummaryData = 0x2B40, ///< Step Counter Activity Summary Data
BtdrvGattCharacteristicUuidType_SleepActivityInstantaneousData = 0x2B41, ///< Sleep Activity Instantaneous Data
BtdrvGattCharacteristicUuidType_SleepActivitySummaryData = 0x2B42, ///< Sleep Activity Summary Data
BtdrvGattCharacteristicUuidType_PhysicalActivityMonitorControlPoint = 0x2B43, ///< Physical Activity Monitor Control Point
BtdrvGattCharacteristicUuidType_ActivityCurrentSession = 0x2B44, ///< Activity Current Session
BtdrvGattCharacteristicUuidType_PhysicalActivitySessionDescriptor = 0x2B45, ///< Physical Activity Session Descriptor
BtdrvGattCharacteristicUuidType_PreferredUnits = 0x2B46, ///< Preferred Units
BtdrvGattCharacteristicUuidType_HighResolutionHeight = 0x2B47, ///< High Resolution Height
BtdrvGattCharacteristicUuidType_MiddleName = 0x2B48, ///< Middle Name
BtdrvGattCharacteristicUuidType_StrideLength = 0x2B49, ///< Stride Length
BtdrvGattCharacteristicUuidType_Handedness = 0x2B4A, ///< Handedness
BtdrvGattCharacteristicUuidType_DeviceWearingPosition = 0x2B4B, ///< Device Wearing Position
BtdrvGattCharacteristicUuidType_FourZoneHeartRateLimits = 0x2B4C, ///< Four Zone Heart Rate Limits
BtdrvGattCharacteristicUuidType_HighIntensityExerciseThreshold = 0x2B4D, ///< High Intensity Exercise Threshold
BtdrvGattCharacteristicUuidType_ActivityGoal = 0x2B4E, ///< Activity Goal
BtdrvGattCharacteristicUuidType_SedentaryIntervalNotification = 0x2B4F, ///< Sedentary Interval Notification
BtdrvGattCharacteristicUuidType_CaloricIntake = 0x2B50, ///< Caloric Intake
BtdrvGattCharacteristicUuidType_TmapRole = 0x2B51, ///< TMAP Role
BtdrvGattCharacteristicUuidType_AudioInputState = 0x2B77, ///< Audio Input State
BtdrvGattCharacteristicUuidType_GainSettingsAttribute = 0x2B78, ///< Gain Settings Attribute
BtdrvGattCharacteristicUuidType_AudioInputType = 0x2B79, ///< Audio Input Type
BtdrvGattCharacteristicUuidType_AudioInputStatus = 0x2B7A, ///< Audio Input Status
BtdrvGattCharacteristicUuidType_AudioInputControlPoint = 0x2B7B, ///< Audio Input Control Point
BtdrvGattCharacteristicUuidType_AudioInputDescription = 0x2B7C, ///< Audio Input Description
BtdrvGattCharacteristicUuidType_VolumeState = 0x2B7D, ///< Volume State
BtdrvGattCharacteristicUuidType_VolumeControlPoint = 0x2B7E, ///< Volume Control Point
BtdrvGattCharacteristicUuidType_VolumeFlags = 0x2B7F, ///< Volume Flags
BtdrvGattCharacteristicUuidType_VolumeOffsetState = 0x2B80, ///< Volume Offset State
BtdrvGattCharacteristicUuidType_AudioLocation = 0x2B81, ///< Audio Location
BtdrvGattCharacteristicUuidType_VolumeOffsetControlPoint = 0x2B82, ///< Volume Offset Control Point
BtdrvGattCharacteristicUuidType_AudioOutputDescription = 0x2B83, ///< Audio Output Description
BtdrvGattCharacteristicUuidType_SetIdentityResolvingKey = 0x2B84, ///< Set Identity Resolving Key
BtdrvGattCharacteristicUuidType_CoordinatedSetSize = 0x2B85, ///< Coordinated Set Size
BtdrvGattCharacteristicUuidType_SetMemberLock = 0x2B86, ///< Set Member Lock
BtdrvGattCharacteristicUuidType_SetMemberRank = 0x2B87, ///< Set Member Rank
BtdrvGattCharacteristicUuidType_EncryptedDataKeyMaterial = 0x2B88, ///< Encrypted Data Key Material
BtdrvGattCharacteristicUuidType_ApparentEnergy32 = 0x2B89, ///< Apparent Energy 32
BtdrvGattCharacteristicUuidType_ApparentPower = 0x2B8A, ///< Apparent Power
BtdrvGattCharacteristicUuidType_LiveHealthObservations = 0x2B8B, ///< Live Health Observations
BtdrvGattCharacteristicUuidType_CoTextsubscript2Concentration = 0x2B8C, ///< CO\textsubscript{2} Concentration
BtdrvGattCharacteristicUuidType_CosineOfTheAngle = 0x2B8D, ///< Cosine of the Angle
BtdrvGattCharacteristicUuidType_DeviceTimeFeature = 0x2B8E, ///< Device Time Feature
BtdrvGattCharacteristicUuidType_DeviceTimeParameters = 0x2B8F, ///< Device Time Parameters
BtdrvGattCharacteristicUuidType_DeviceTime = 0x2B90, ///< Device Time
BtdrvGattCharacteristicUuidType_DeviceTimeControlPoint = 0x2B91, ///< Device Time Control Point
BtdrvGattCharacteristicUuidType_TimeChangeLogData = 0x2B92, ///< Time Change Log Data
BtdrvGattCharacteristicUuidType_MediaPlayerName = 0x2B93, ///< Media Player Name
BtdrvGattCharacteristicUuidType_MediaPlayerIconObjectId = 0x2B94, ///< Media Player Icon Object ID
BtdrvGattCharacteristicUuidType_MediaPlayerIconUrl = 0x2B95, ///< Media Player Icon URL
BtdrvGattCharacteristicUuidType_TrackChanged = 0x2B96, ///< Track Changed
BtdrvGattCharacteristicUuidType_TrackTitle = 0x2B97, ///< Track Title
BtdrvGattCharacteristicUuidType_TrackDuration = 0x2B98, ///< Track Duration
BtdrvGattCharacteristicUuidType_TrackPosition = 0x2B99, ///< Track Position
BtdrvGattCharacteristicUuidType_PlaybackSpeed = 0x2B9A, ///< Playback Speed
BtdrvGattCharacteristicUuidType_SeekingSpeed = 0x2B9B, ///< Seeking Speed
BtdrvGattCharacteristicUuidType_CurrentTrackSegmentsObjectId = 0x2B9C, ///< Current Track Segments Object ID
BtdrvGattCharacteristicUuidType_CurrentTrackObjectId = 0x2B9D, ///< Current Track Object ID
BtdrvGattCharacteristicUuidType_NextTrackObjectId = 0x2B9E, ///< Next Track Object ID
BtdrvGattCharacteristicUuidType_ParentGroupObjectId = 0x2B9F, ///< Parent Group Object ID
BtdrvGattCharacteristicUuidType_CurrentGroupObjectId = 0x2BA0, ///< Current Group Object ID
BtdrvGattCharacteristicUuidType_PlayingOrder = 0x2BA1, ///< Playing Order
BtdrvGattCharacteristicUuidType_PlayingOrdersSupported = 0x2BA2, ///< Playing Orders Supported
BtdrvGattCharacteristicUuidType_MediaState = 0x2BA3, ///< Media State
BtdrvGattCharacteristicUuidType_MediaControlPoint = 0x2BA4, ///< Media Control Point
BtdrvGattCharacteristicUuidType_MediaControlPointOpcodesSupported = 0x2BA5, ///< Media Control Point Opcodes Supported
BtdrvGattCharacteristicUuidType_SearchResultsObjectId = 0x2BA6, ///< Search Results Object ID
BtdrvGattCharacteristicUuidType_SearchControlPoint = 0x2BA7, ///< Search Control Point
BtdrvGattCharacteristicUuidType_Energy32 = 0x2BA8, ///< Energy 32
BtdrvGattCharacteristicUuidType_MediaPlayerIconObjectType = 0x2BA9, ///< Media Player Icon Object Type
BtdrvGattCharacteristicUuidType_TrackSegmentsObjectType = 0x2BAA, ///< Track Segments Object Type
BtdrvGattCharacteristicUuidType_TrackObjectType = 0x2BAB, ///< Track Object Type
BtdrvGattCharacteristicUuidType_GroupObjectType = 0x2BAC, ///< Group Object Type
BtdrvGattCharacteristicUuidType_ConstantToneExtensionEnable = 0x2BAD, ///< Constant Tone Extension Enable
BtdrvGattCharacteristicUuidType_AdvertisingConstantToneExtensionMinimumLength = 0x2BAE, ///< Advertising Constant Tone Extension Minimum Length
BtdrvGattCharacteristicUuidType_AdvertisingConstantToneExtensionMinimumTransmitCount = 0x2BAF, ///< Advertising Constant Tone Extension Minimum Transmit Count
BtdrvGattCharacteristicUuidType_AdvertisingConstantToneExtensionTransmitDuration = 0x2BB0, ///< Advertising Constant Tone Extension Transmit Duration
BtdrvGattCharacteristicUuidType_AdvertisingConstantToneExtensionInterval = 0x2BB1, ///< Advertising Constant Tone Extension Interval
BtdrvGattCharacteristicUuidType_AdvertisingConstantToneExtensionPhy = 0x2BB2, ///< Advertising Constant Tone Extension PHY
BtdrvGattCharacteristicUuidType_BearerProviderName = 0x2BB3, ///< Bearer Provider Name
BtdrvGattCharacteristicUuidType_BearerUci = 0x2BB4, ///< Bearer UCI
BtdrvGattCharacteristicUuidType_BearerTechnology = 0x2BB5, ///< Bearer Technology
BtdrvGattCharacteristicUuidType_BearerUriSchemesSupportedList = 0x2BB6, ///< Bearer URI Schemes Supported List
BtdrvGattCharacteristicUuidType_BearerSignalStrength = 0x2BB7, ///< Bearer Signal Strength
BtdrvGattCharacteristicUuidType_BearerSignalStrengthReportingInterval = 0x2BB8, ///< Bearer Signal Strength Reporting Interval
BtdrvGattCharacteristicUuidType_BearerListCurrentCalls = 0x2BB9, ///< Bearer List Current Calls
BtdrvGattCharacteristicUuidType_ContentControlId = 0x2BBA, ///< Content Control ID
BtdrvGattCharacteristicUuidType_StatusFlags = 0x2BBB, ///< Status Flags
BtdrvGattCharacteristicUuidType_IncomingCallTargetBearerUri = 0x2BBC, ///< Incoming Call Target Bearer URI
BtdrvGattCharacteristicUuidType_CallState = 0x2BBD, ///< Call State
BtdrvGattCharacteristicUuidType_CallControlPoint = 0x2BBE, ///< Call Control Point
BtdrvGattCharacteristicUuidType_CallControlPointOptionalOpcodes = 0x2BBF, ///< Call Control Point Optional Opcodes
BtdrvGattCharacteristicUuidType_TerminationReason = 0x2BC0, ///< Termination Reason
BtdrvGattCharacteristicUuidType_IncomingCall = 0x2BC1, ///< Incoming Call
BtdrvGattCharacteristicUuidType_CallFriendlyName = 0x2BC2, ///< Call Friendly Name
BtdrvGattCharacteristicUuidType_Mute = 0x2BC3, ///< Mute
BtdrvGattCharacteristicUuidType_SinkAse = 0x2BC4, ///< Sink ASE
BtdrvGattCharacteristicUuidType_SourceAse = 0x2BC5, ///< Source ASE
BtdrvGattCharacteristicUuidType_AseControlPoint = 0x2BC6, ///< ASE Control Point
BtdrvGattCharacteristicUuidType_BroadcastAudioScanControlPoint = 0x2BC7, ///< Broadcast Audio Scan Control Point
BtdrvGattCharacteristicUuidType_BroadcastReceiveState = 0x2BC8, ///< Broadcast Receive State
BtdrvGattCharacteristicUuidType_SinkPac = 0x2BC9, ///< Sink PAC
BtdrvGattCharacteristicUuidType_SinkAudioLocations = 0x2BCA, ///< Sink Audio Locations
BtdrvGattCharacteristicUuidType_SourcePac = 0x2BCB, ///< Source PAC
BtdrvGattCharacteristicUuidType_SourceAudioLocations = 0x2BCC, ///< Source Audio Locations
BtdrvGattCharacteristicUuidType_AvailableAudioContexts = 0x2BCD, ///< Available Audio Contexts
BtdrvGattCharacteristicUuidType_SupportedAudioContexts = 0x2BCE, ///< Supported Audio Contexts
BtdrvGattCharacteristicUuidType_AmmoniaConcentration = 0x2BCF, ///< Ammonia Concentration
BtdrvGattCharacteristicUuidType_CarbonMonoxideConcentration = 0x2BD0, ///< Carbon Monoxide Concentration
BtdrvGattCharacteristicUuidType_MethaneConcentration = 0x2BD1, ///< Methane Concentration
BtdrvGattCharacteristicUuidType_NitrogenDioxideConcentration = 0x2BD2, ///< Nitrogen Dioxide Concentration
BtdrvGattCharacteristicUuidType_NonMethaneVolatileOrganicCompoundsConcentration = 0x2BD3, ///< Non-Methane Volatile Organic Compounds Concentration
BtdrvGattCharacteristicUuidType_OzoneConcentration = 0x2BD4, ///< Ozone Concentration
BtdrvGattCharacteristicUuidType_ParticulateMatterPm1Concentration = 0x2BD5, ///< Particulate Matter - PM1 Concentration
BtdrvGattCharacteristicUuidType_ParticulateMatterPm25Concentration = 0x2BD6, ///< Particulate Matter - PM2.5 Concentration
BtdrvGattCharacteristicUuidType_ParticulateMatterPm10Concentration = 0x2BD7, ///< Particulate Matter - PM10 Concentration
BtdrvGattCharacteristicUuidType_SulfurDioxideConcentration = 0x2BD8, ///< Sulfur Dioxide Concentration
BtdrvGattCharacteristicUuidType_SulfurHexafluorideConcentration = 0x2BD9, ///< Sulfur Hexafluoride Concentration
BtdrvGattCharacteristicUuidType_HearingAidFeatures = 0x2BDA, ///< Hearing Aid Features
BtdrvGattCharacteristicUuidType_HearingAidPresetControlPoint = 0x2BDB, ///< Hearing Aid Preset Control Point
BtdrvGattCharacteristicUuidType_ActivePresetIndex = 0x2BDC, ///< Active Preset Index
BtdrvGattCharacteristicUuidType_StoredHealthObservations = 0x2BDD, ///< Stored Health Observations
BtdrvGattCharacteristicUuidType_FixedString64 = 0x2BDE, ///< Fixed String 64
BtdrvGattCharacteristicUuidType_HighTemperature = 0x2BDF, ///< High Temperature
BtdrvGattCharacteristicUuidType_HighVoltage = 0x2BE0, ///< High Voltage
BtdrvGattCharacteristicUuidType_LightDistribution = 0x2BE1, ///< Light Distribution
BtdrvGattCharacteristicUuidType_LightOutput = 0x2BE2, ///< Light Output
BtdrvGattCharacteristicUuidType_LightSourceType = 0x2BE3, ///< Light Source Type
BtdrvGattCharacteristicUuidType_Noise = 0x2BE4, ///< Noise
BtdrvGattCharacteristicUuidType_RelativeRuntimeInACorrelatedColorTemperatureRange = 0x2BE5, ///< Relative Runtime in a Correlated Color Temperature Range
BtdrvGattCharacteristicUuidType_TimeSecond32 = 0x2BE6, ///< Time Second 32
BtdrvGattCharacteristicUuidType_VocConcentration = 0x2BE7, ///< VOC Concentration
BtdrvGattCharacteristicUuidType_VoltageFrequency = 0x2BE8, ///< Voltage Frequency
BtdrvGattCharacteristicUuidType_BatteryCriticalStatus = 0x2BE9, ///< Battery Critical Status
BtdrvGattCharacteristicUuidType_BatteryHealthStatus = 0x2BEA, ///< Battery Health Status
BtdrvGattCharacteristicUuidType_BatteryHealthInformation = 0x2BEB, ///< Battery Health Information
BtdrvGattCharacteristicUuidType_BatteryInformation = 0x2BEC, ///< Battery Information
BtdrvGattCharacteristicUuidType_BatteryLevelStatus = 0x2BED, ///< Battery Level Status
BtdrvGattCharacteristicUuidType_BatteryTimeStatus = 0x2BEE, ///< Battery Time Status
BtdrvGattCharacteristicUuidType_EstimatedServiceDate = 0x2BEF, ///< Estimated Service Date
BtdrvGattCharacteristicUuidType_BatteryEnergyStatus = 0x2BF0, ///< Battery Energy Status
BtdrvGattCharacteristicUuidType_ObservationScheduleChanged = 0x2BF1, ///< Observation Schedule Changed
BtdrvGattCharacteristicUuidType_CurrentElapsedTime = 0x2BF2, ///< Current Elapsed Time
BtdrvGattCharacteristicUuidType_HealthSensorFeatures = 0x2BF3, ///< Health Sensor Features
BtdrvGattCharacteristicUuidType_GhsControlPoint = 0x2BF4, ///< GHS Control Point
BtdrvGattCharacteristicUuidType_LeGattSecurityLevels = 0x2BF5, ///< LE GATT Security Levels
BtdrvGattCharacteristicUuidType_EslAddress = 0x2BF6, ///< ESL Address
BtdrvGattCharacteristicUuidType_ApSyncKeyMaterial = 0x2BF7, ///< AP Sync Key Material
BtdrvGattCharacteristicUuidType_EslResponseKeyMaterial = 0x2BF8, ///< ESL Response Key Material
BtdrvGattCharacteristicUuidType_EslCurrentAbsoluteTime = 0x2BF9, ///< ESL Current Absolute Time
BtdrvGattCharacteristicUuidType_EslDisplayInformation = 0x2BFA, ///< ESL Display Information
BtdrvGattCharacteristicUuidType_EslImageInformation = 0x2BFB, ///< ESL Image Information
BtdrvGattCharacteristicUuidType_EslSensorInformation = 0x2BFC, ///< ESL Sensor Information
BtdrvGattCharacteristicUuidType_EslLedInformation = 0x2BFD, ///< ESL LED Information
BtdrvGattCharacteristicUuidType_EslControlPoint = 0x2BFE, ///< ESL Control Point
BtdrvGattCharacteristicUuidType_UdiForMedicalDevices = 0x2BFF, ///< UDI for Medical Devices
} BtdrvGattCharacteristicUuidType;
/// GattDescriptorUuidType
typedef enum {
BtdrvGattDescriptorUuidType_CharacteristicExtendedProperties = 0x2900, ///< Characteristic Extended Properties
BtdrvGattDescriptorUuidType_CharacteristicUserDescription = 0x2901, ///< Characteristic User Description
BtdrvGattDescriptorUuidType_ClientCharacteristicConfiguration = 0x2902, ///< Client Characteristic Configuration
BtdrvGattDescriptorUuidType_ServerCharacteristicConfiguration = 0x2903, ///< Server Characteristic Configuration
BtdrvGattDescriptorUuidType_CharacteristicPresentationFormat = 0x2904, ///< Characteristic Presentation Format
BtdrvGattDescriptorUuidType_CharacteristicAggregateFormat = 0x2905, ///< Characteristic Aggregate Format
BtdrvGattDescriptorUuidType_ValidRange = 0x2906, ///< Valid Range
BtdrvGattDescriptorUuidType_ExternalReportReference = 0x2907, ///< External Report Reference
BtdrvGattDescriptorUuidType_ReportReference = 0x2908, ///< Report Reference
BtdrvGattDescriptorUuidType_NumberOfDigitals = 0x2909, ///< Number of Digitals
BtdrvGattDescriptorUuidType_ValueTriggerSetting = 0x290A, ///< Value Trigger Setting
BtdrvGattDescriptorUuidType_EnvironmentalSensingConfiguration = 0x290B, ///< Environmental Sensing Configuration
BtdrvGattDescriptorUuidType_EnvironmentalSensingMeasurement = 0x290C, ///< Environmental Sensing Measurement
BtdrvGattDescriptorUuidType_EnvironmentalSensingTriggerSetting = 0x290D, ///< Environmental Sensing Trigger Setting
BtdrvGattDescriptorUuidType_TimeTriggerSetting = 0x290E, ///< Time Trigger Setting
BtdrvGattDescriptorUuidType_CompleteBrEdrTransportBlockData = 0x290F, ///< Complete BR-EDR Transport Block Data
BtdrvGattDescriptorUuidType_ObservationSchedule = 0x2910, ///< Observation Schedule
BtdrvGattDescriptorUuidType_ValidRangeAndAccuracy = 0x2911, ///< Valid Range and Accuracy
} BtdrvGattDescriptorUuidType;

View File

@ -1,455 +0,0 @@
/**
* @file btdrv_types.h
* @brief Bluetooth driver (btdrv) service types (see btdrv.h for the rest).
* @author yellows8, ndeadly
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "btdrv_ids.h"
/// BluetoothPropertyType [1.0.0-11.0.1]
typedef enum {
BtdrvBluetoothPropertyType_Name = 1, ///< Name. String, max length 0xF8 excluding NUL-terminator.
BtdrvBluetoothPropertyType_Address = 2, ///< \ref BtdrvAddress
BtdrvBluetoothPropertyType_Unknown3 = 3, ///< Only available with \ref btdrvSetAdapterProperty. Unknown, \ref BtdrvAddress.
BtdrvBluetoothPropertyType_ClassOfDevice = 5, ///< 3-bytes, Class of Device.
BtdrvBluetoothPropertyType_FeatureSet = 6, ///< 1-byte, FeatureSet. The default is value 0x68.
} BtdrvBluetoothPropertyType;
/// AdapterPropertyType [12.0.0+]
typedef enum {
BtdrvAdapterPropertyType_Address = 0, ///< \ref BtdrvAddress
BtdrvAdapterPropertyType_Name = 1, ///< Name. String, max length 0xF8 excluding NUL-terminator.
BtdrvAdapterPropertyType_ClassOfDevice = 2, ///< 3-bytes, Class of Device.
BtdrvAdapterPropertyType_Unknown3 = 3, ///< Only available with \ref btdrvSetAdapterProperty. Unknown, \ref BtdrvAddress.
} BtdrvAdapterPropertyType;
/// EventType
typedef enum {
///< BtdrvEventType_* should be used on [12.0.0+]
BtdrvEventType_InquiryDevice = 0, ///< Device found during Inquiry.
BtdrvEventType_InquiryStatus = 1, ///< Inquiry status changed.
BtdrvEventType_PairingPinCodeRequest = 2, ///< Pairing PIN code request.
BtdrvEventType_SspRequest = 3, ///< SSP confirm request / SSP passkey notification.
BtdrvEventType_Connection = 4, ///< Connection
BtdrvEventType_Tsi = 5, ///< SetTsi (\ref btdrvSetTsi)
BtdrvEventType_BurstMode = 6, ///< SetBurstMode (\ref btdrvEnableBurstMode)
BtdrvEventType_SetZeroRetransmission = 7, ///< \ref btdrvSetZeroRetransmission
BtdrvEventType_PendingConnections = 8, ///< \ref btdrvGetPendingConnections
BtdrvEventType_MoveToSecondaryPiconet = 9, ///< \ref btdrvMoveToSecondaryPiconet
BtdrvEventType_BluetoothCrash = 10, ///< BluetoothCrash
///< BtdrvEventTypeOld_* should be used on [1.0.0-11.0.1]
BtdrvEventTypeOld_Unknown0 = 0, ///< Unused
BtdrvEventTypeOld_InquiryDevice = 3, ///< Device found during Inquiry.
BtdrvEventTypeOld_InquiryStatus = 4, ///< Inquiry status changed.
BtdrvEventTypeOld_PairingPinCodeRequest = 5, ///< Pairing PIN code request.
BtdrvEventTypeOld_SspRequest = 6, ///< SSP confirm request / SSP passkey notification.
BtdrvEventTypeOld_Connection = 7, ///< Connection
BtdrvEventTypeOld_BluetoothCrash = 13, ///< BluetoothCrash
} BtdrvEventType;
/// BtdrvInquiryStatus
typedef enum {
BtdrvInquiryStatus_Stopped = 0, ///< Inquiry stopped.
BtdrvInquiryStatus_Started = 1, ///< Inquiry started.
} BtdrvInquiryStatus;
/// ConnectionEventType
typedef enum {
BtdrvConnectionEventType_Status = 0, ///< BtdrvEventInfo::connection::status
BtdrvConnectionEventType_SspConfirmRequest = 1, ///< SSP confirm request.
BtdrvConnectionEventType_Suspended = 2, ///< ACL Link is now Suspended.
} BtdrvConnectionEventType;
/// ExtEventType [1.0.0-11.0.1]
typedef enum {
BtdrvExtEventType_SetTsi = 0, ///< SetTsi (\ref btdrvSetTsi)
BtdrvExtEventType_ExitTsi = 1, ///< ExitTsi (\ref btdrvSetTsi)
BtdrvExtEventType_SetBurstMode = 2, ///< SetBurstMode (\ref btdrvEnableBurstMode)
BtdrvExtEventType_ExitBurstMode = 3, ///< ExitBurstMode (\ref btdrvEnableBurstMode)
BtdrvExtEventType_SetZeroRetransmission = 4, ///< \ref btdrvSetZeroRetransmission
BtdrvExtEventType_PendingConnections = 5, ///< \ref btdrvGetPendingConnections
BtdrvExtEventType_MoveToSecondaryPiconet = 6, ///< \ref btdrvMoveToSecondaryPiconet
} BtdrvExtEventType;
/// BluetoothHhReportType
/// Bit0-1 directly control the HID bluetooth transaction report-type value.
/// Bit2-3: these directly control the Parameter Reserved field for SetReport, for GetReport these control the Parameter Reserved and Size bits.
typedef enum {
BtdrvBluetoothHhReportType_Other = 0, ///< Other
BtdrvBluetoothHhReportType_Input = 1, ///< Input
BtdrvBluetoothHhReportType_Output = 2, ///< Output
BtdrvBluetoothHhReportType_Feature = 3, ///< Feature
} BtdrvBluetoothHhReportType;
/// HidEventType
typedef enum {
///< BtdrvHidEventType_* should be used on [12.0.0+]
BtdrvHidEventType_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventType_Data = 1, ///< DATA report on the Interrupt channel.
BtdrvHidEventType_SetReport = 2, ///< Response to SET_REPORT.
BtdrvHidEventType_GetReport = 3, ///< Response to GET_REPORT.
///< BtdrvHidEventTypeOld_* should be used on [1.0.0-11.0.1]
BtdrvHidEventTypeOld_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventTypeOld_Data = 4, ///< DATA report on the Interrupt channel.
BtdrvHidEventTypeOld_Ext = 7, ///< Response for extensions. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventTypeOld_SetReport = 8, ///< Response to SET_REPORT.
BtdrvHidEventTypeOld_GetReport = 9, ///< Response to GET_REPORT.
} BtdrvHidEventType;
/// HidConnectionStatus [12.0.0+]
typedef enum {
///< BtdrvHidConnectionStatus_* should be used on [12.0.0+]
BtdrvHidConnectionStatus_Closed = 0,
BtdrvHidConnectionStatus_Opened = 1,
BtdrvHidConnectionStatus_Failed = 2,
///< BtdrvHidConnectionStatusOld_* should be used on [1.0.0-11.0.1]
BtdrvHidConnectionStatusOld_Opened = 0,
BtdrvHidConnectionStatusOld_Closed = 2,
BtdrvHidConnectionStatusOld_Failed = 8,
} BtdrvHidConnectionStatus;
/// This determines the u16 data to write into a CircularBuffer.
typedef enum {
BtdrvFatalReason_Invalid = 0, ///< Only for \ref BtdrvEventInfo: invalid.
BtdrvFatalReason_Unknown1 = 1, ///< Can only be triggered by \ref btdrvEmulateBluetoothCrash, not triggered by the sysmodule otherwise.
BtdrvFatalReason_CommandTimeout = 2, ///< HCI command timeout.
BtdrvFatalReason_HardwareError = 3, ///< HCI event HCI_Hardware_Error occurred.
BtdrvFatalReason_Enable = 7, ///< Only for \ref BtdrvEventInfo: triggered after enabling bluetooth, depending on the value of a global state field.
BtdrvFatalReason_Audio = 9, ///< [12.0.0+] Only for \ref BtdrvEventInfo: triggered by Audio cmds in some cases.
} BtdrvFatalReason;
/// BleEventType
typedef enum {
BtdrvBleEventType_ClientRegistration = 0, ///< GATT client registration.
BtdrvBleEventType_ServerRegistration = 1, ///< GATT server registration.
BtdrvBleEventType_ConnectionUpdate = 2, ///< Connection update.
BtdrvBleEventType_PreferredConnectionParameters = 3, ///< Preferred connection parameters.
BtdrvBleEventType_ClientConnection = 4, ///< GATT client connection.
BtdrvBleEventType_ServerConnection = 5, ///< GATT server connection.
BtdrvBleEventType_ScanResult = 6, ///< Scan result.
BtdrvBleEventType_ScanFilter = 7, ///< Scan filter status.
BtdrvBleEventType_ClientNotify = 8, ///< GATT client notify.
BtdrvBleEventType_ClientCacheSave = 9, ///< GATT client cache save.
BtdrvBleEventType_ClientCacheLoad = 10, ///< GATT client cache load.
BtdrvBleEventType_ClientConfigureMtu = 11, ///< GATT client configure MTU.
BtdrvBleEventType_ServerAddAttribute = 12, ///< GATT server add attribute.
BtdrvBleEventType_ServerAttributeOperation = 13, ///< GATT server attribute operation.
} BtdrvBleEventType;
/// GattAttributeType
typedef enum {
BtdrvGattAttributeType_IncludedService = 0, ///< Included service
BtdrvGattAttributeType_Characteristic = 1, ///< Characteristic
BtdrvGattAttributeType_Descriptor = 2, ///< Descriptor
BtdrvGattAttributeType_Service = 3, ///< Service
} BtdrvGattAttributeType;
/// GattAttributePermission
typedef enum {
BtdrvGattAttributePermission_Read = BIT(0),
BtdrvGattAttributePermission_ReadEncrypted = BIT(1),
BtdrvGattAttributePermission_ReadEncryptedMitm = BIT(2),
BtdrvGattAttributePermission_Write = BIT(4),
BtdrvGattAttributePermission_WriteEncrypted = BIT(5),
BtdrvGattAttributePermission_WriteEncryptedMitm = BIT(6),
BtdrvGattAttributePermission_WriteSigned = BIT(7),
BtdrvGattAttributePermission_WriteSignedMitm = BIT(8),
BtdrvGattAttributePermission_ReadAllowed = BtdrvGattAttributePermission_Read | BtdrvGattAttributePermission_ReadEncrypted | BtdrvGattAttributePermission_ReadEncryptedMitm,
BtdrvGattAttributePermission_ReadAuthRequired = BtdrvGattAttributePermission_ReadEncrypted,
BtdrvGattAttributePermission_ReadMitmRequired = BtdrvGattAttributePermission_ReadEncryptedMitm,
BtdrvGattAttributePermission_ReadEncryptedRequired = BtdrvGattAttributePermission_ReadEncrypted | BtdrvGattAttributePermission_ReadEncryptedMitm,
BtdrvGattAttributePermission_WriteAllowed = BtdrvGattAttributePermission_Write | BtdrvGattAttributePermission_WriteEncrypted | BtdrvGattAttributePermission_WriteEncryptedMitm | BtdrvGattAttributePermission_WriteSigned | BtdrvGattAttributePermission_WriteSignedMitm,
BtdrvGattAttributePermission_WriteAuthRequired = BtdrvGattAttributePermission_WriteEncrypted | BtdrvGattAttributePermission_WriteSigned,
BtdrvGattAttributePermission_WriteMitmRequired = BtdrvGattAttributePermission_WriteEncryptedMitm | BtdrvGattAttributePermission_WriteSignedMitm,
BtdrvGattAttributePermission_WriteEncryptedRequired = BtdrvGattAttributePermission_WriteEncrypted | BtdrvGattAttributePermission_WriteEncryptedMitm,
BtdrvGattAttributePermission_WriteSignedRequired = BtdrvGattAttributePermission_WriteSigned | BtdrvGattAttributePermission_WriteSignedMitm,
} BtdrvGattAttributePermission;
/// GattCharacteristicProperty
typedef enum {
BtdrvGattCharacteristicProperty_Broadcast = BIT(0),
BtdrvGattCharacteristicProperty_Read = BIT(1),
BtdrvGattCharacteristicProperty_WriteNoResponse = BIT(2),
BtdrvGattCharacteristicProperty_Write = BIT(3),
BtdrvGattCharacteristicProperty_Notify = BIT(4),
BtdrvGattCharacteristicProperty_Indicate = BIT(5),
BtdrvGattCharacteristicProperty_Authentication = BIT(6),
BtdrvGattCharacteristicProperty_ExtendedProperties = BIT(7),
} BtdrvGattCharacteristicProperty;
/// GattAuthReqType
typedef enum {
BtdrvGattAuthReqType_None = 0,
BtdrvGattAuthReqType_NoMitm = 1,
BtdrvGattAuthReqType_Mitm = 2,
BtdrvGattAuthReqType_SignedNoMitm = 3,
BtdrvGattAuthReqType_SignedMitm = 4,
} BtdrvGattAuthReqType;
/// BtdrvBleAdBit
typedef enum {
BtdrvBleAdBit_DeviceName = BIT(0),
BtdrvBleAdBit_Flags = BIT(1),
BtdrvBleAdBit_Manufacturer = BIT(2),
BtdrvBleAdBit_TxPower = BIT(3),
BtdrvBleAdBit_Service32 = BIT(4),
BtdrvBleAdBit_IntRange = BIT(5),
BtdrvBleAdBit_Service = BIT(6),
BtdrvBleAdBit_ServiceSol = BIT(7),
BtdrvBleAdBit_ServiceData = BIT(8),
BtdrvBleAdBit_SignData = BIT(9),
BtdrvBleAdBit_Service128Sol = BIT(10),
BtdrvBleAdBit_Appearance = BIT(11),
BtdrvBleAdBit_PublicAddress = BIT(12),
BtdrvBleAdBit_RandomAddress = BIT(13),
BtdrvBleAdBit_Service32Sol = BIT(14),
BtdrvBleAdBit_Proprietary = BIT(15),
BtdrvBleAdBit_Service128 = BIT(16),
} BtdrvBleAdBit;
/// BtdrvBleAdFlag
typedef enum {
BtdrvBleAdFlag_None = 0,
BtdrvBleAdFlag_LimitedDiscovery = BIT(0),
BtdrvBleAdFlag_GeneralDiscovery = BIT(1),
BtdrvBleAdFlag_BrEdrNotSupported = BIT(2),
BtdrvBleAdFlag_DualModeControllerSupport = BIT(3),
BtdrvBleAdFlag_DualModeHostSupport = BIT(4),
} BtdrvBleAdFlag;
/// AudioEventType
typedef enum {
BtdrvAudioEventType_None = 0, ///< None
BtdrvAudioEventType_Connection = 1, ///< Connection
} BtdrvAudioEventType;
/// AudioOutState
typedef enum {
BtdrvAudioOutState_Stopped = 0, ///< Stopped
BtdrvAudioOutState_Started = 1, ///< Started
} BtdrvAudioOutState;
/// AudioCodec
typedef enum {
BtdrvAudioCodec_Pcm = 0, ///< Raw PCM
} BtdrvAudioCodec;
/// Address
typedef struct {
u8 address[0x6]; ///< Address
} BtdrvAddress;
/// ClassOfDevice
typedef struct {
u8 class_of_device[0x3]; ///< ClassOfDevice
} BtdrvClassOfDevice;
/// AdapterProperty [1.0.0-11.0.1]
typedef struct {
BtdrvAddress addr; ///< Same as the data for ::BtdrvBluetoothPropertyType_Address.
BtdrvClassOfDevice class_of_device; ///< Same as the data for ::BtdrvBluetoothPropertyType_ClassOfDevice.
char name[0xF9]; ///< Same as the data for ::BtdrvBluetoothPropertyType_Name (last byte is not initialized).
u8 feature_set; ///< Set to hard-coded value 0x68 (same as the data for ::BtdrvBluetoothPropertyType_FeatureSet).
} BtdrvAdapterPropertyOld;
/// AdapterProperty [12.0.0+]
typedef struct {
u8 type; ///< \ref BtdrvAdapterPropertyType
u8 size; ///< Data size.
u8 data[0x100]; ///< Data (above size), as specified by the type.
} BtdrvAdapterProperty;
/// AdapterPropertySet [12.0.0+]
typedef struct {
BtdrvAddress addr; ///< Same as the data for ::BtdrvBluetoothPropertyType_Address.
BtdrvClassOfDevice class_of_device; ///< Same as the data for ::BtdrvBluetoothPropertyType_ClassOfDevice.
char name[0xF9]; ///< Same as the data for ::BtdrvBluetoothPropertyType_Name.
} BtdrvAdapterPropertySet;
/// BluetoothPinCode [1.0.0-11.0.1]
typedef struct {
char code[0x10]; ///< PinCode
} BtdrvBluetoothPinCode;
/// BtdrvPinCode [12.0.0+]
typedef struct {
char code[0x10]; ///< PinCode
u8 length; ///< Length
} BtdrvPinCode;
/// HidData [1.0.0-8.1.1]
typedef struct {
u16 size; ///< Size of data.
u8 data[0x280]; ///< Data
} BtdrvHidData;
/// HidReport [9.0.0+].
typedef struct {
u16 size; ///< Size of data.
u8 data[0x2BC]; ///< Data
} BtdrvHidReport;
/// PlrStatistics
typedef struct {
u8 unk_x0[0x84]; ///< Unknown
} BtdrvPlrStatistics;
/// PlrList
typedef struct {
u8 unk_x0[0xA4]; ///< Unknown
} BtdrvPlrList;
/// ChannelMapList
typedef struct {
u8 unk_x0[0x88]; ///< Unknown
} BtdrvChannelMapList;
/// GattAttributeUuid
typedef struct {
u32 size; ///< UUID size, must be 0x2, 0x4, or 0x10.
u8 uuid[0x10]; ///< UUID with the above size.
} BtdrvGattAttributeUuid;
/// GattId
typedef struct {
u8 instance_id; ///< InstanceId
u8 pad[3]; ///< Padding
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
} BtdrvGattId;
/// GattAttribute
typedef struct {
BtdrvGattId id; ///< \ref BtdrvGattId
u16 type; ///< \ref BtdrvGattAttributeType
u16 handle;
u16 group_end_handle;
u8 property; ///< Only used when type is characteristic. \ref BtdrvGattCharacteristicProperty
bool is_primary; ///< Only used when type is service
} BtdrvGattAttribute;
/// LeConnectionParams [5.0.0-8.1.1]
typedef struct {
BtdrvAddress addr; ///< \ref BtdrvAddress
u16 min_conn_interval; ///< Minimum connection interval
u16 max_conn_interval; ///< Maximum connection interval
u16 scan_interval; ///< Scan interval
u16 scan_window; ///< Scan window
u16 slave_latency; ///< Slave latency
u16 supervision_tout; ///< Connection supervision timeout multiplier
u8 preference; ///< Unused
u8 pad; ///< Padding
} BtdrvLeConnectionParams;
/// BleConnectionParameter [9.0.0+]
typedef struct {
u16 min_conn_interval; ///< Minimum connection interval
u16 max_conn_interval; ///< Maximum connection interval
u16 scan_interval; ///< Scan interval
u16 scan_window; ///< Scan window
u16 slave_latency; ///< Slave latency
u16 supervision_tout; ///< Connection supervision timeout multiplier
} BtdrvBleConnectionParameter;
/// BtdrvBleAdvertisePacketData
typedef struct {
u32 adv_data_mask; ///< Bitmask of following AD data to be included in advertising packets \ref BtdrvBleAdBit
u8 flag; ///< AD flag value to be advertised \ref BtdrvBleAdFlag. Included with BtdrvBleAdBit_Flags
u8 manu_data_len; ///< Size of manu_data below
u8 manu_data[0x1F]; ///< Manufacturer-specific data to be advertised. Included with BtdrvBleAdBit_Manufacturer
u8 pad[1]; ///< Padding
u16 appearance_data; ///< Device appearance data to be advertised \ref BtdrvAppearanceType. Included with BtdrvBleAdBit_Appearance
u8 num_service; ///< Number of services in uuid_val array below
u8 pad2[3]; ///< Padding
BtdrvGattAttributeUuid uuid_val[0x6]; ///< Array of 16-bit UUIDs to be advertised \ref BtdrvGattAttributeUuid. Included with BtdrvBleAdBit_Service
u8 service_data_len; ///< Size of service_data below
u8 pad3[1]; ///< Padding
u16 service_data_uuid; ///< 16-bit UUID of service_data below
u8 service_data[0x1F]; ///< Service data to be advertised. Included with BtdrvBleAdBit_ServiceData
bool is_scan_rsp; ///< Whether this is an inquiry scan response or advertising data
u8 tx_power; ///< Inquiry transmit power to be advertised. Included with BtdrvBleAdBit_TxPower
u8 pad4[3]; ///< Padding
} BtdrvBleAdvertisePacketData;
/// BleAdvertisement
typedef struct {
u8 size; ///< Size of data below.
u8 type; ///< \ref BtdrvAdType
u8 data[0x1D]; ///< Advertisement data
} BtdrvBleAdvertisement;
/// BleAdvertiseFilter
typedef struct {
u8 index; ///< Filter index
BtdrvBleAdvertisement adv; ///< \ref BtdrvBleAdvertisement
u8 mask[0x1D]; ///< Mask for advertisement data above
u8 mask_size; ///< Size of mask above.
} BtdrvBleAdvertiseFilter;
/// BleAdvertisePacketParameter
typedef struct {
u16 company_id;
u8 pattern_data[6];
} BtdrvBleAdvertisePacketParameter;
/// BleScanResult
typedef struct {
u8 unk_x0; ///< Unknown
BtdrvAddress addr; ///< \ref BtdrvAddress
u8 unk_x7[0x139]; ///< Unknown
s32 count; ///< Unknown
s32 unk_x144; ///< Unknown
} BtdrvBleScanResult;
/// BleConnectionInfo
typedef struct {
u32 connection_handle; ///< ConnectionHandle, 0xFFFFFFFF ([5.0.0-5.0.2] 0xFFFF) is invalid.
BtdrvAddress addr; ///< \ref BtdrvAddress
u8 pad[2]; ///< Padding
} BtdrvBleConnectionInfo;
/// LeEventInfo
typedef struct {
u32 unk_x0; ///< Unknown
u32 unk_x4; ///< Unknown
u8 unk_x8; ///< Unknown
u8 pad[3]; ///< Padding
BtdrvGattAttributeUuid uuid0; ///< \ref BtdrvGattAttributeUuid
BtdrvGattAttributeUuid uuid1; ///< \ref BtdrvGattAttributeUuid
BtdrvGattAttributeUuid uuid2; ///< \ref BtdrvGattAttributeUuid
u16 size; ///< Size of the below data.
u8 data[0x3B6]; ///< Data.
} BtdrvLeEventInfo;
/// BleClientGattOperationInfo
typedef struct {
u8 unk_x0; ///< Converted from BtdrvLeEventInfo::unk_x0.
u8 pad[3]; ///< Padding
u32 unk_x4; ///< BtdrvLeEventInfo::unk_x4
u8 unk_x8; ///< BtdrvLeEventInfo::unk_x8
u8 pad2[3]; ///< Padding
BtdrvGattAttributeUuid uuid0; ///< BtdrvLeEventInfo::uuid0
BtdrvGattAttributeUuid uuid1; ///< BtdrvLeEventInfo::uuid1
BtdrvGattAttributeUuid uuid2; ///< BtdrvLeEventInfo::uuid2
u64 size; ///< BtdrvLeEventInfo::size
u8 data[0x200]; ///< BtdrvLeEventInfo::data
} BtdrvBleClientGattOperationInfo;
/// PcmParameter
typedef struct {
u32 unk_x0; ///< Must be 0-3. Controls number of channels: 0 = mono, non-zero = stereo.
s32 sample_rate; ///< Sample rate. Must be one of the following: 16000, 32000, 44100, 48000.
u32 bits_per_sample; ///< Bits per sample. Must be 8 or 16.
} BtdrvPcmParameter;
/// AudioControlButtonState
typedef struct {
u8 unk_x0[0x10]; ///< Unknown
} BtdrvAudioControlButtonState;

View File

@ -1,491 +0,0 @@
/**
* @file btm.h
* @brief btm service IPC wrapper.
* @note See also: https://switchbrew.org/wiki/BTM_services
* @author yellows8
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/btdrv_types.h"
#include "../services/btm_types.h"
#include "../sf/service.h"
/// Initialize btm.
Result btmInitialize(void);
/// Exit btm.
void btmExit(void);
/// Gets the Service object for the actual btm service session.
Service* btmGetServiceSession(void);
/**
* @brief GetState
* @param[out] out \ref BtmState
*/
Result btmGetState(BtmState *out);
/**
* @brief GetHostDeviceProperty
* @param[out] out \ref BtmHostDeviceProperty
*/
Result btmGetHostDeviceProperty(BtmHostDeviceProperty *out);
/**
* @brief AcquireDeviceConditionEvent
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireDeviceConditionEvent(Event* out_event);
/**
* @brief GetDeviceCondition [1.0.0-12.1.0]
* @param[out] out \ref BtmDeviceCondition
*/
Result btmLegacyGetDeviceCondition(BtmDeviceCondition *out);
/**
* @brief GetDeviceCondition [13.0.0+]
* @param[in] profile \ref BtmProfile, when not ::BtmProfile_None entries are only returned which match this profile.
* @param[out] out \ref BtmConnectedDeviceV13
* @param[in] count Size of the out array in entries.
* @param[out] total_out Total output entries.
*/
Result btmGetDeviceCondition(BtmProfile profile, BtmConnectedDeviceV13 *out, size_t count, s32 *total_out);
/**
* @brief SetBurstMode
* @param[in] addr \ref BtdrvAddress
* @param[in] flag Flag
*/
Result btmSetBurstMode(BtdrvAddress addr, bool flag);
/**
* @brief SetSlotMode
* @param[in] list \ref BtmDeviceSlotModeList
*/
Result btmSetSlotMode(const BtmDeviceSlotModeList *list);
/**
* @brief SetBluetoothMode
* @note Only available on pre-9.0.0.
* @param[in] mode \ref BtmBluetoothMode
*/
Result btmSetBluetoothMode(BtmBluetoothMode mode);
/**
* @brief SetWlanMode
* @param[in] mode \ref BtmWlanMode
*/
Result btmSetWlanMode(BtmWlanMode mode);
/**
* @brief AcquireDeviceInfoEvent
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireDeviceInfoEvent(Event* out_event);
/**
* @brief GetDeviceInfo [1.0.0-12.1.0]
* @param[out] out \ref BtmDeviceInfoList
*/
Result btmLegacyGetDeviceInfo(BtmDeviceInfoList *out);
/**
* @brief GetDeviceInfo [13.0.0+]
* @param[in] profile \ref BtmProfile, when not ::BtmProfile_None entries are only returned which match this profile.
* @param[out] out \ref BtmDeviceInfoV13
* @param[in] count Size of the out array in entries.
* @param[out] total_out Total output entries.
*/
Result btmGetDeviceInfo(BtmProfile profile, BtmDeviceInfoV13 *out, size_t count, s32 *total_out);
/**
* @brief AddDeviceInfo
* @param[in] info \ref BtmDeviceInfo
*/
Result btmAddDeviceInfo(const BtmDeviceInfo *info);
/**
* @brief RemoveDeviceInfo
* @param[in] addr \ref BtdrvAddress
*/
Result btmRemoveDeviceInfo(BtdrvAddress addr);
/**
* @brief IncreaseDeviceInfoOrder
* @param[in] addr \ref BtdrvAddress
*/
Result btmIncreaseDeviceInfoOrder(BtdrvAddress addr);
/**
* @brief LlrNotify
* @param[in] addr \ref BtdrvAddress
* @param[in] unk [9.0.0+] Unknown
*/
Result btmLlrNotify(BtdrvAddress addr, s32 unk);
/**
* @brief EnableRadio
*/
Result btmEnableRadio(void);
/**
* @brief DisableRadio
*/
Result btmDisableRadio(void);
/**
* @brief HidDisconnect
* @param[in] addr \ref BtdrvAddress
*/
Result btmHidDisconnect(BtdrvAddress addr);
/**
* @brief HidSetRetransmissionMode
* @param[in] addr \ref BtdrvAddress
* @param[in] list \ref BtmZeroRetransmissionList
*/
Result btmHidSetRetransmissionMode(BtdrvAddress addr, const BtmZeroRetransmissionList *list);
/**
* @brief AcquireAwakeReqEvent
* @note Only available on [2.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireAwakeReqEvent(Event* out_event);
/**
* @brief AcquireLlrStateEvent
* @note Only available on [4.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireLlrStateEvent(Event* out_event);
/**
* @brief IsLlrStarted
* @note Only available on [4.0.0+].
* @param[out] out Output flag.
*/
Result btmIsLlrStarted(bool *out);
/**
* @brief EnableSlotSaving
* @note Only available on [4.0.0+].
* @param[in] flag Flag
*/
Result btmEnableSlotSaving(bool flag);
/**
* @brief ProtectDeviceInfo
* @note Only available on [5.0.0+].
* @param[in] addr \ref BtdrvAddress
* @param[in] flag Flag
*/
Result btmProtectDeviceInfo(BtdrvAddress addr, bool flag);
/**
* @brief AcquireBleScanEvent
* @note Only available on [5.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireBleScanEvent(Event* out_event);
/**
* @brief GetBleScanParameterGeneral
* @note Only available on [5.1.0+].
* @param[in] parameter_id Must be value 0x1 or 0xFFFF.
* @param[out] out \ref BtdrvBleAdvertisePacketParameter
*/
Result btmGetBleScanParameterGeneral(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out);
/**
* @brief GetBleScanParameterSmartDevice
* @note Only available on [5.1.0+].
* @param[in] parameter_id Must be value 0x2.
* @param[out] out \ref BtdrvGattAttributeUuid. The first 4-bytes is always 0.
*/
Result btmGetBleScanParameterSmartDevice(u16 parameter_id, BtdrvGattAttributeUuid *out);
/**
* @brief StartBleScanForGeneral
* @note Only available on [5.1.0+].
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmStartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param);
/**
* @brief StopBleScanForGeneral
* @note Only available on [5.1.0+].
*/
Result btmStopBleScanForGeneral(void);
/**
* @brief GetBleScanResultsForGeneral
* @note Only available on [5.1.0+].
* @param[out] results Output array of \ref BtdrvBleScanResult.
* @param[in] count Size of the results array in entries. The max is 10.
* @param[out] total_out Total output entries.
*/
Result btmGetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out);
/**
* @brief StartBleScanForPaired
* @note Only available on [5.1.0+].
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmStartBleScanForPaired(BtdrvBleAdvertisePacketParameter param);
/**
* @brief StopBleScanForPaired
* @note Only available on [5.1.0+].
*/
Result btmStopBleScanForPaired(void);
/**
* @brief StartBleScanForSmartDevice
* @note Only available on [5.1.0+].
* @param[in] uuid \ref BtdrvGattAttributeUuid
*/
Result btmStartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid);
/**
* @brief StopBleScanForSmartDevice
* @note Only available on [5.1.0+].
*/
Result btmStopBleScanForSmartDevice(void);
/**
* @brief GetBleScanResultsForSmartDevice
* @note Only available on [5.1.0+].
* @param[out] results Output array of \ref BtdrvBleScanResult.
* @param[in] count Size of the results array in entries. The max is 10.
* @param[out] total_out Total output entries.
*/
Result btmGetBleScanResultsForSmartDevice(BtdrvBleScanResult *results, u8 count, u8 *total_out);
/**
* @brief AcquireBleConnectionEvent
* @note Only available on [5.1.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireBleConnectionEvent(Event* out_event);
/**
* @brief BleConnect
* @note Only available on [5.0.0+].
* @note The \ref BtdrvAddress must not be already connected. A maximum of 4 devices can be connected.
* @param[in] addr \ref BtdrvAddress
*/
Result btmBleConnect(BtdrvAddress addr);
/**
* @brief BleOverrideConnection
* @note Only available on [5.1.0+].
* @param[in] id Same as \ref btmBleDisconnect.
*/
Result btmBleOverrideConnection(u32 id);
/**
* @brief BleDisconnect
* @note Only available on [5.0.0+].
* @param[in] connection_handle This must match a BtdrvBleConnectionInfo::id from \ref btmBleGetConnectionState. [5.1.0+] 0xFFFFFFFF is invalid.
*/
Result btmBleDisconnect(u32 connection_handle);
/**
* @brief BleGetConnectionState
* @note Only available on [5.0.0+].
* @param[out] info Output array of \ref BtdrvBleConnectionInfo.
* @param[in] count Size of the info array in entries. Other cmds which use this internally use count=4.
* @param[out] total_out Total output entries.
*/
Result btmBleGetConnectionState(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out);
/**
* @brief BleGetGattClientConditionList
* @note Only available on [5.0.0+].
* @param[out] list \ref BtmGattClientConditionList
*/
Result btmBleGetGattClientConditionList(BtmGattClientConditionList *list);
/**
* @brief AcquireBlePairingEvent
* @note Only available on [5.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireBlePairingEvent(Event* out_event);
/**
* @brief BlePairDevice
* @note Only available on [5.1.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmBlePairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/**
* @brief BleUnpairDeviceOnBoth
* @note Only available on [5.1.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmBleUnpairDeviceOnBoth(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/**
* @brief BleUnPairDevice
* @note Only available on [5.1.0+].
* @param[in] addr \ref BtdrvAddress
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmBleUnPairDevice(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param);
/**
* @brief BleGetPairedAddresses
* @note Only available on [5.1.0+].
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
* @param[out] addrs Output array of \ref BtdrvAddress.
* @param[in] count Size of the addrs array in entries.
* @param[out] total_out Total output entries. The max is 10.
*/
Result btmBleGetPairedAddresses(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out);
/**
* @brief AcquireBleServiceDiscoveryEvent
* @note Only available on [5.1.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireBleServiceDiscoveryEvent(Event* out_event);
/**
* @brief GetGattServices
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[out] services Output array of \ref BtmGattService.
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btmGetGattServices(u32 connection_handle, BtmGattService *services, u8 count, u8 *total_out);
/**
* @brief Same as \ref btmGetGattServices except this only returns the \ref BtmGattService which matches the input \ref BtdrvGattAttributeUuid.
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] service \ref BtmGattService
* @param[out] flag Whether a \ref BtmGattService was returned.
*/
Result btmGetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtmGattService *service, bool *flag);
/**
* @brief Same as \ref btmGetGattServices except this only returns \ref BtmGattService entries where various checks pass with u16 fields.
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] service_handle ServiceHandle
* @param[out] services \ref BtmGattService
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] out Output value.
*/
Result btmGetGattIncludedServices(u32 connection_handle, u16 service_handle, BtmGattService *services, u8 count, u8 *out);
/**
* @brief This is similar to \ref btmGetGattIncludedServices except this only returns 1 \ref BtmGattService.
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] attribute_handle AttributeHandle
* @param[out] service \ref BtmGattService
* @param[out] flag Whether a \ref BtmGattService was returned.
*/
Result btmGetBelongingService(u32 connection_handle, u16 attribute_handle, BtmGattService *service, bool *flag);
/**
* @brief GetGattCharacteristics
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] service_handle This controls which \ref BtmGattCharacteristic entries to return.
* @param[out] characteristics \ref BtmGattCharacteristic
* @param[in] count Size of the characteristics array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btmGetGattCharacteristics(u32 connection_handle, u16 service_handle, BtmGattCharacteristic *characteristics, u8 count, u8 *total_out);
/**
* @brief GetGattDescriptors
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] char_handle Characteristic handle. This controls which \ref BtmGattDescriptor entries to return.
* @param[out] descriptors \ref BtmGattDescriptor
* @param[in] count Size of the descriptors array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btmGetGattDescriptors(u32 connection_handle, u16 char_handle, BtmGattDescriptor *descriptors, u8 count, u8 *total_out);
/**
* @brief AcquireBleMtuConfigEvent
* @note Only available on [5.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmAcquireBleMtuConfigEvent(Event* out_event);
/**
* @brief ConfigureBleMtu
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[in] mtu MTU
*/
Result btmConfigureBleMtu(u32 connection_handle, u16 mtu);
/**
* @brief GetBleMtu
* @note Only available on [5.0.0+].
* @param[in] connection_handle Same as \ref btmBleDisconnect.
* @param[out] out Output MTU.
*/
Result btmGetBleMtu(u32 connection_handle, u16 *out);
/**
* @brief RegisterBleGattDataPath
* @note Only available on [5.0.0+].
* @param[in] path \ref BtmBleDataPath
*/
Result btmRegisterBleGattDataPath(const BtmBleDataPath *path);
/**
* @brief UnregisterBleGattDataPath
* @note Only available on [5.0.0+].
* @param[in] path \ref BtmBleDataPath
*/
Result btmUnregisterBleGattDataPath(const BtmBleDataPath *path);
/**
* @brief RegisterAppletResourceUserId
* @note Only available on [5.0.0+].
* @param[in] AppletResourceUserId AppletResourceUserId
* @param[in] unk Unknown
*/
Result btmRegisterAppletResourceUserId(u64 AppletResourceUserId, u32 unk);
/**
* @brief UnregisterAppletResourceUserId
* @note Only available on [5.0.0+].
* @param[in] AppletResourceUserId AppletResourceUserId
*/
Result btmUnregisterAppletResourceUserId(u64 AppletResourceUserId);
/**
* @brief SetAppletResourceUserId
* @note Only available on [5.0.0+].
* @param[in] AppletResourceUserId AppletResourceUserId
*/
Result btmSetAppletResourceUserId(u64 AppletResourceUserId);

View File

@ -1,305 +0,0 @@
/**
* @file btm_types.h
* @brief btm service types.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// BtmState
typedef enum {
BtmState_NotInitialized = 0, ///< NotInitialized
BtmState_RadioOff = 1, ///< RadioOff
BtmState_MinorSlept = 2, ///< MinorSlept
BtmState_RadioOffMinorSlept = 3, ///< RadioOffMinorSlept
BtmState_Slept = 4, ///< Slept
BtmState_RadioOffSlept = 5, ///< RadioOffSlept
BtmState_Initialized = 6, ///< Initialized
BtmState_Working = 7, ///< Working
} BtmState;
/// BluetoothMode
typedef enum {
BtmBluetoothMode_Dynamic2Slot = 0, ///< Dynamic2Slot
BtmBluetoothMode_StaticJoy = 1, ///< StaticJoy
} BtmBluetoothMode;
/// WlanMode
typedef enum {
BtmWlanMode_Local4 = 0, ///< Local4
BtmWlanMode_Local8 = 1, ///< Local8
BtmWlanMode_None = 2, ///< None
} BtmWlanMode;
/// TsiMode
typedef enum {
BtmTsiMode_0Fd3Td3Si10 = 0, ///< 0Fd3Td3Si10
BtmTsiMode_1Fd1Td1Si5 = 1, ///< 1Fd1Td1Si5
BtmTsiMode_2Fd1Td3Si10 = 2, ///< 2Fd1Td3Si10
BtmTsiMode_3Fd1Td5Si15 = 3, ///< 3Fd1Td5Si15
BtmTsiMode_4Fd3Td1Si10 = 4, ///< 4Fd3Td1Si10
BtmTsiMode_5Fd3Td3Si15 = 5, ///< 5Fd3Td3Si15
BtmTsiMode_6Fd5Td1Si15 = 6, ///< 6Fd5Td1Si15
BtmTsiMode_7Fd1Td3Si15 = 7, ///< 7Fd1Td3Si15
BtmTsiMode_8Fd3Td1Si15 = 8, ///< 8Fd3Td1Si15
BtmTsiMode_9Fd1Td1Si10 = 9, ///< 9Fd1Td1Si10
BtmTsiMode_10Fd1Td1Si15 = 10, ///< 10Fd1Td1Si15
BtmTsiMode_Active = 255, ///< Active
} BtmTsiMode;
/// SlotMode
typedef enum {
BtmSlotMode_2 = 0, ///< 2
BtmSlotMode_4 = 1, ///< 4
BtmSlotMode_6 = 2, ///< 6
BtmSlotMode_Active = 3, ///< Active
} BtmSlotMode;
/// Profile
typedef enum {
BtmProfile_None = 0, ///< None
BtmProfile_Hid = 1, ///< Hid
BtmProfile_Audio = 2, ///< [13.0.0+] Audio
} BtmProfile;
/// BdName
typedef struct {
char name[0x20]; ///< Name string.
} BtmBdName;
/// ClassOfDevice
typedef struct {
u8 class_of_device[0x3]; ///< ClassOfDevice
} BtmClassOfDevice;
/// LinkKey
typedef struct {
u8 link_key[0x10]; ///< LinkKey
} BtmLinkKey;
/// HidDeviceInfo
typedef struct {
u16 vid; ///< Vid
u16 pid; ///< Pid
} BtmHidDeviceInfo;
/// HostDeviceProperty
typedef struct {
union {
struct {
BtdrvAddress addr; ///< Same as BtdrvAdapterProperty::addr.
BtmClassOfDevice class_of_device; ///< Same as BtdrvAdapterProperty::class_of_device.
BtmBdName name; ///< Same as BtdrvAdapterProperty::name (except the last byte which is always zero).
u8 feature_set; ///< Same as BtdrvAdapterProperty::feature_set.
} v1; ///< [1.0.0-12.1.0]
struct {
BtdrvAddress addr; ///< Same as BtdrvAdapterProperty::addr.
BtmClassOfDevice class_of_device; ///< Same as BtdrvAdapterProperty::class_of_device.
char name[0xF9]; ///< Same as BtdrvAdapterProperty::name (except the last byte which is always zero).
u8 feature_set; ///< Same as BtdrvAdapterProperty::feature_set.
} v13; ///< [13.0.0+]
};
} BtmHostDeviceProperty;
/// BtmConnectedDevice [1.0.0-12.1.0]
typedef struct {
BtdrvAddress address;
u8 pad[2];
u32 unk_x8;
char name[0x20];
u8 unk_x2C[0x1C];
u16 vid;
u16 pid;
u8 unk_x4C[0x20];
} BtmConnectedDeviceV1;
/// BtmConnectedDevice [13.0.0+]
typedef struct {
BtdrvAddress address;
u8 pad[2];
u32 profile; ///< \ref BtmProfile
u8 unk_xC[0x40];
char name[0x20];
u8 unk_x6C[0xD9];
u8 pad2[3];
} BtmConnectedDeviceV13;
/// DeviceCondition [1.0.0-5.0.2]
typedef struct {
u32 unk_x0;
u32 unk_x4;
u8 unk_x8;
u8 unk_x9;
u8 max_count;
u8 connected_count;
BtmConnectedDeviceV1 devices[8];
} BtmDeviceConditionV100;
/// DeviceCondition [5.1.0-7.0.1]
typedef struct {
u32 unk_x0;
u32 unk_x4;
u8 unk_x8;
u8 unk_x9[2];
u8 max_count;
u8 connected_count;
u8 pad[3];
BtmConnectedDeviceV1 devices[8];
} BtmDeviceConditionV510;
/// DeviceCondition [8.0.0-8.1.1]
typedef struct {
u32 unk_x0;
u32 unk_x4;
u8 unk_x8;
u8 unk_x9;
u8 max_count;
u8 connected_count;
BtmConnectedDeviceV1 devices[8];
} BtmDeviceConditionV800;
/// DeviceCondition [9.0.0-12.1.0]
typedef struct {
u32 unk_x0;
u8 unk_x4;
u8 unk_x5;
u8 max_count;
u8 connected_count;
BtmConnectedDeviceV1 devices[8];
} BtmDeviceConditionV900;
/// DeviceCondition [1.0.0-12.1.0]
typedef union {
BtmDeviceConditionV100 v100;
BtmDeviceConditionV510 v510;
BtmDeviceConditionV800 v800;
BtmDeviceConditionV900 v900;
} BtmDeviceCondition;
/// DeviceSlotMode
typedef struct {
BtdrvAddress addr; ///< \ref BtdrvAddress
u8 reserved[2]; ///< Reserved
u32 slot_mode; ///< \ref BtmSlotMode
} BtmDeviceSlotMode;
/// DeviceSlotModeList
typedef struct {
u8 device_count; ///< DeviceCount
u8 reserved[3]; ///< Reserved
BtmDeviceSlotMode devices[8]; ///< Array of \ref BtmDeviceSlotMode with the above count.
} BtmDeviceSlotModeList;
/// DeviceInfo [1.0.0-12.1.0]
typedef struct {
BtdrvAddress addr; ///< \ref BtdrvAddress
BtmClassOfDevice class_of_device; ///< ClassOfDevice
BtmBdName name; ///< BdName
BtmLinkKey link_key; ///< LinkKey
u8 reserved[3]; ///< Reserved
u32 profile; ///< \ref BtmProfile
union {
u8 data[0x4]; ///< Empty (Profile = None)
BtmHidDeviceInfo hid_device_info; ///< \ref BtmHidDeviceInfo (Profile = Hid)
} profile_info;
u8 reserved2[0x1C]; ///< Reserved
} BtmDeviceInfoV1;
/// DeviceInfo [13.0.0+]
typedef struct {
BtdrvAddress addr; ///< \ref BtdrvAddress
BtmClassOfDevice class_of_device; ///< ClassOfDevice
BtmLinkKey link_key; ///< LinkKey
u8 reserved[3]; ///< Reserved
u32 profile; ///< \ref BtmProfile
union {
u8 data[0x4]; ///< Empty (Profile = None)
BtmHidDeviceInfo hid_device_info; ///< \ref BtmHidDeviceInfo (Profile = Hid)
} profile_info;
u8 reserved2[0x1C]; ///< Reserved
char name[0xF9]; ///< Name
u8 pad[3]; ///< Padding
} BtmDeviceInfoV13;
/// DeviceInfo [1.0.0-13.0.0]
typedef union {
BtmDeviceInfoV1 v1;
BtmDeviceInfoV13 v13;
} BtmDeviceInfo;
/// DeviceInfoList
typedef struct {
u8 device_count; ///< DeviceCount
u8 reserved[3]; ///< Reserved
BtmDeviceInfoV1 devices[10]; ///< Array of \ref BtmDeviceInfoV1 with the above count.
} BtmDeviceInfoList;
/// DeviceProperty
typedef struct {
BtdrvAddress addr; ///< \ref BtdrvAddress
BtmClassOfDevice class_of_device; ///< ClassOfDevice
BtmBdName name; ///< BdName
} BtmDeviceProperty;
/// DevicePropertyList
typedef struct {
u8 device_count; ///< DeviceCount
BtmDeviceProperty devices[15]; ///< Array of \ref BtmDeviceProperty.
} BtmDevicePropertyList;
/// ZeroRetransmissionList
typedef struct {
u8 enabled_report_id_count; ///< EnabledReportIdCount
u8 enabled_report_id[0x10]; ///< Array of EnabledReportId.
} BtmZeroRetransmissionList;
/// GattClientConditionList
typedef struct {
u8 unk_x0[0x74]; ///< Unknown
} BtmGattClientConditionList;
/// GattService
typedef struct {
u8 unk_x0[0x4]; ///< Unknown
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
u16 handle; ///< Handle
u8 unk_x1A[0x2]; ///< Unknown
u16 instance_id; ///< InstanceId
u16 end_group_handle; ///< EndGroupHandle
u8 primary_service; ///< PrimaryService
u8 pad[3]; ///< Padding
} BtmGattService;
/// GattCharacteristic
typedef struct {
u8 unk_x0[0x4]; ///< Unknown
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
u16 handle; ///< Handle
u8 unk_x1A[0x2]; ///< Unknown
u16 instance_id; ///< InstanceId
u8 properties; ///< Properties
u8 unk_x1F[0x5]; ///< Unknown
} BtmGattCharacteristic;
/// GattDescriptor
typedef struct {
u8 unk_x0[0x4]; ///< Unknown
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
u16 handle; ///< Handle
u8 unk_x1A[0x6]; ///< Unknown
} BtmGattDescriptor;
/// BleDataPath
typedef struct {
u8 unk_x0; ///< Unknown
u8 pad[3]; ///< Padding
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
} BtmBleDataPath;
/// AudioDevice
typedef struct {
BtdrvAddress addr; ///< Device address
char name[0xF9]; ///< Device name
} BtmAudioDevice;

View File

@ -1,185 +0,0 @@
/**
* @file btmsys.h
* @brief btm:sys (btm system) service IPC wrapper.
* @author yellows8
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/btdrv_types.h"
#include "../services/btm_types.h"
#include "../sf/service.h"
/// Initialize btm:sys.
Result btmsysInitialize(void);
/// Exit btm:sys.
void btmsysExit(void);
/// Gets the Service object for the actual btm:sys service session. This object must be closed by the user once finished using cmds with this.
Result btmsysGetServiceSession(Service* srv_out);
/// Gets the Service object for IBtmSystemCore.
Service* btmsysGetServiceSession_IBtmSystemCore(void);
/**
* @brief StartGamepadPairing
*/
Result btmsysStartGamepadPairing(void);
/**
* @brief CancelGamepadPairing
*/
Result btmsysCancelGamepadPairing(void);
/**
* @brief ClearGamepadPairingDatabase
*/
Result btmsysClearGamepadPairingDatabase(void);
/**
* @brief GetPairedGamepadCount
* @param[out] out Output count.
*/
Result btmsysGetPairedGamepadCount(u8 *out);
/**
* @brief EnableRadio
*/
Result btmsysEnableRadio(void);
/**
* @brief DisableRadio
*/
Result btmsysDisableRadio(void);
/**
* @brief GetRadioOnOff
* @param[out] out Output flag.
*/
Result btmsysGetRadioOnOff(bool *out);
/**
* @brief AcquireRadioEvent
* @note Only available on [3.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmsysAcquireRadioEvent(Event* out_event);
/**
* @brief AcquireGamepadPairingEvent
* @note Only available on [3.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmsysAcquireGamepadPairingEvent(Event* out_event);
/**
* @brief IsGamepadPairingStarted
* @note Only available on [3.0.0+].
* @param[out] out Output flag.
*/
Result btmsysIsGamepadPairingStarted(bool *out);
/**
* @brief StartAudioDeviceDiscovery
* @note Only available on [13.0.0+].
*/
Result btmsysStartAudioDeviceDiscovery(void);
/**
* @brief StopAudioDeviceDiscovery
* @note Only available on [13.0.0+].
*/
Result btmsysStopAudioDeviceDiscovery(void);
/**
* @brief IsDiscoveryingAudioDevice
* @note Only available on [13.0.0+].
* @param[out] out Output flag.
*/
Result btmsysIsDiscoveryingAudioDevice(bool *out);
/**
* @brief GetDiscoveredAudioDevice
* @note Only available on [13.0.0+].
* @param[out] out Output array of \ref BtmAudioDevice.
* @param[in] count Size of the out array in entries. The max is 15.
* @param[out] total_out Total output entries.
*/
Result btmsysGetDiscoveredAudioDevice(BtmAudioDevice *out, s32 count, s32 *total_out);
/**
* @brief AcquireAudioDeviceConnectionEvent
* @note Only available on [13.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmsysAcquireAudioDeviceConnectionEvent(Event* out_event);
/**
* @brief ConnectAudioDevice
* @note Only available on [13.0.0+].
* @param[in] addr \ref BtdrvAddress
*/
Result btmsysConnectAudioDevice(BtdrvAddress addr);
/**
* @brief IsConnectingAudioDevice
* @note Only available on [13.0.0+].
* @param[out] out Output flag.
*/
Result btmsysIsConnectingAudioDevice(bool *out);
/**
* @brief GetConnectedAudioDevices
* @note Only available on [13.0.0+].
* @param[out] out Output array of \ref BtmAudioDevice.
* @param[in] count Size of the out array in entries. The max is 8.
* @param[out] total_out Total output entries.
*/
Result btmsysGetConnectedAudioDevices(BtmAudioDevice *out, s32 count, s32 *total_out);
/**
* @brief DisconnectAudioDevice
* @note Only available on [13.0.0+].
* @param[in] addr \ref BtdrvAddress
*/
Result btmsysDisconnectAudioDevice(BtdrvAddress addr);
/**
* @brief AcquirePairedAudioDeviceInfoChangedEvent
* @note Only available on [13.0.0+].
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmsysAcquirePairedAudioDeviceInfoChangedEvent(Event* out_event);
/**
* @brief GetPairedAudioDevices
* @note Only available on [13.0.0+].
* @param[out] out Output array of \ref BtmAudioDevice.
* @param[in] count Size of the out array in entries. The max is 10.
* @param[out] total_out Total output entries.
*/
Result btmsysGetPairedAudioDevices(BtmAudioDevice *out, s32 count, s32 *total_out);
/**
* @brief RemoveAudioDevicePairing
* @note Only available on [13.0.0+].
* @param[in] addr \ref BtdrvAddress
*/
Result btmsysRemoveAudioDevicePairing(BtdrvAddress addr);
/**
* @brief RequestAudioDeviceConnectionRejection
* @note Only available on [13.0.0+].
*/
Result btmsysRequestAudioDeviceConnectionRejection(void);
/**
* @brief CancelAudioDeviceConnectionRejection
* @note Only available on [13.0.0+].
*/
Result btmsysCancelAudioDeviceConnectionRejection(void);

View File

@ -1,290 +0,0 @@
/**
* @file btmu.h
* @brief btm:u (btm user) service IPC wrapper.
* @note Only available on [5.0.0+].
* @note See also btdev.
* @note See also: https://switchbrew.org/wiki/BTM_services
* @author yellows8
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/btdrv_types.h"
#include "../services/btm.h"
#include "../sf/service.h"
/// Initialize btm:u.
Result btmuInitialize(void);
/// Exit btm:u.
void btmuExit(void);
/// Gets the Service object for the actual btm:u service session. This object must be closed by the user once finished using cmds with this.
Result btmuGetServiceSession(Service* srv_out);
/// Gets the Service object for IBtmUserCore.
Service* btmuGetServiceSession_IBtmUserCore(void);
/**
* @brief AcquireBleScanEvent
* @note This is similar to \ref btmAcquireBleScanEvent.
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmuAcquireBleScanEvent(Event* out_event);
/**
* @brief GetBleScanFilterParameter
* @note This is the same as \ref btmGetBleScanParameterGeneral.
* @param[in] parameter_id Must be value 0x1 or 0xFFFF.
* @param[out] out \ref BtdrvBleAdvertisePacketParameter
*/
Result btmuGetBleScanFilterParameter(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out);
/**
* @brief GetBleScanFilterParameter2
* @note This is the same as \ref btmGetBleScanParameterSmartDevice.
* @param[in] parameter_id Must be value 0x2.
* @param[out] out \ref BtdrvGattAttributeUuid. The first 4-bytes is always 0.
*/
Result btmuGetBleScanFilterParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out);
/**
* @brief StartBleScanForGeneral
* @note This is similar to \ref btmStartBleScanForGeneral.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmuStartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param);
/**
* @brief StopBleScanForGeneral
* @note This is similar to \ref btmStopBleScanForGeneral.
*/
Result btmuStopBleScanForGeneral(void);
/**
* @brief GetBleScanResultsForGeneral
* @note This is similar to \ref btmGetBleScanResultsForGeneral.
* @param[out] results Output array of \ref BtdrvBleScanResult.
* @param[in] count Size of the results array in entries. The max is 10.
* @param[out] total_out Total output entries.
*/
Result btmuGetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out);
/**
* @brief StartBleScanForPaired
* @note This is similar to \ref btmStartBleScanForPaired.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmuStartBleScanForPaired(BtdrvBleAdvertisePacketParameter param);
/**
* @brief StopBleScanForPaired
* @note This is similar to \ref btmStopBleScanForPaired.
*/
Result btmuStopBleScanForPaired(void);
/**
* @brief StartBleScanForSmartDevice
* @note This is similar to \ref btmStartBleScanForSmartDevice.
* @param[in] uuid \ref BtdrvGattAttributeUuid
*/
Result btmuStartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid);
/**
* @brief StopBleScanForSmartDevice
* @note This is similar to \ref btmStopBleScanForSmartDevice.
*/
Result btmuStopBleScanForSmartDevice(void);
/**
* @brief GetBleScanResultsForSmartDevice
* @note This is similar to \ref btmGetBleScanResultsForSmartDevice.
* @param[out] results Output array of \ref BtdrvBleScanResult.
* @param[in] count Size of the results array in entries. The max is 10.
* @param[out] total_out Total output entries.
*/
Result btmuGetBleScanResultsForSmartDevice(BtdrvBleScanResult *results, u8 count, u8 *total_out);
/**
* @brief AcquireBleConnectionEvent
* @note This is similar to \ref btmAcquireBleConnectionEvent.
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmuAcquireBleConnectionEvent(Event* out_event);
/**
* @brief BleConnect
* @note This is similar to \ref btmBleConnect.
* @param[in] addr \ref BtdrvAddress
*/
Result btmuBleConnect(BtdrvAddress addr);
/**
* @brief BleDisconnect
* @note This is similar to \ref btmBleDisconnect.
* @param[in] connection_handle This must match a BtdrvBleConnectionInfo::connection_handle from \ref btmuBleGetConnectionState. [5.1.0+] 0xFFFFFFFF is invalid.
*/
Result btmuBleDisconnect(u32 connection_handle);
/**
* @brief BleGetConnectionState
* @note This is similar to \ref btmBleGetConnectionState.
* @param[out] info Output array of \ref BtdrvBleConnectionInfo.
* @param[in] count Size of the info array in entries. Other cmds which use this internally use count=4.
* @param[out] total_out Total output entries.
*/
Result btmuBleGetConnectionState(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out);
/**
* @brief AcquireBlePairingEvent
* @note This is similar to \ref btmAcquireBlePairingEvent.
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmuAcquireBlePairingEvent(Event* out_event);
/**
* @brief BlePairDevice
* @note This is similar to \ref btmBlePairDevice.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmuBlePairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/**
* @brief BleUnPairDevice
* @note This is similar to \ref btmBleUnpairDeviceOnBoth.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmuBleUnPairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/**
* @brief BleUnPairDevice2
* @note This is similar to \ref btmBleUnPairDevice.
* @param[in] addr \ref BtdrvAddress
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
*/
Result btmuBleUnPairDevice2(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param);
/**
* @brief BleGetPairedDevices
* @note This is similar to \ref btmBleGetPairedAddresses.
* @param[in] param \ref BtdrvBleAdvertisePacketParameter
* @param[out] addrs Output array of \ref BtdrvAddress.
* @param[in] count Size of the addrs array in entries.
* @param[out] total_out Total output entries. The max is 10.
*/
Result btmuBleGetPairedDevices(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out);
/**
* @brief AcquireBleServiceDiscoveryEvent
* @note This is similar to \ref btmAcquireBleServiceDiscoveryEvent.
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmuAcquireBleServiceDiscoveryEvent(Event* out_event);
/**
* @brief GetGattServices
* @note This is similar to \ref btmGetGattServices.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[out] services Output array of \ref BtmGattService.
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btmuGetGattServices(u32 connection_handle, BtmGattService *services, u8 count, u8 *total_out);
/**
* @brief Same as \ref btmuGetGattServices except this only returns the \ref BtmGattService which matches the input \ref BtdrvGattAttributeUuid.
* @note This is similar to \ref btmGetGattService.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] service \ref BtmGattService
* @param[out] flag Whether a \ref BtmGattService was returned.
*/
Result btmuGetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtmGattService *service, bool *flag);
/**
* @brief Same as \ref btmuGetGattServices except this only returns \ref BtmGattService entries where various checks pass with u16 fields.
* @note This is similar to \ref btmGetGattIncludedServices.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] service_handle ServiceHandle
* @param[out] services \ref BtmGattService
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] out Output value.
*/
Result btmuGetGattIncludedServices(u32 connection_handle, u16 service_handle, BtmGattService *services, u8 count, u8 *out);
/**
* @brief This is similar to \ref btmuGetGattIncludedServices except this only returns 1 \ref BtmGattService.
* @note This is similar to \ref btmGetBelongingService.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] attribute_handle AttributeHandle
* @param[out] service \ref BtmGattService
* @param[out] flag Whether a \ref BtmGattService was returned.
*/
Result btmuGetBelongingGattService(u32 connection_handle, u16 attribute_handle, BtmGattService *service, bool *flag);
/**
* @brief GetGattCharacteristics
* @note This is similar to \ref btmGetGattCharacteristics.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] service_handle This controls which \ref BtmGattCharacteristic entries to return.
* @param[out] characteristics \ref BtmGattCharacteristic
* @param[in] count Size of the characteristics array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btmuGetGattCharacteristics(u32 connection_handle, u16 service_handle, BtmGattCharacteristic *characteristics, u8 count, u8 *total_out);
/**
* @brief GetGattDescriptors
* @note This is similar to \ref btmGetGattDescriptors.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] char_handle Characteristic handle. This controls which \ref BtmGattDescriptor entries to return.
* @param[out] descriptors \ref BtmGattDescriptor
* @param[in] count Size of the descriptors array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btmuGetGattDescriptors(u32 connection_handle, u16 char_handle, BtmGattDescriptor *descriptors, u8 count, u8 *total_out);
/**
* @brief AcquireBleMtuConfigEvent
* @note This is similar to \ref btmAcquireBleMtuConfigEvent.
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=true.
*/
Result btmuAcquireBleMtuConfigEvent(Event* out_event);
/**
* @brief ConfigureBleMtu
* @note This is similar to \ref btmConfigureBleMtu.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] mtu MTU
*/
Result btmuConfigureBleMtu(u32 connection_handle, u16 mtu);
/**
* @brief GetBleMtu
* @note This is similar to \ref btmGetBleMtu.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[out] out Output MTU.
*/
Result btmuGetBleMtu(u32 connection_handle, u16 *out);
/**
* @brief RegisterBleGattDataPath
* @note This is similar to \ref btmRegisterBleGattDataPath.
* @param[in] path \ref BtmBleDataPath
*/
Result btmuRegisterBleGattDataPath(const BtmBleDataPath *path);
/**
* @brief UnregisterBleGattDataPath
* @note This is similar to \ref btmUnregisterBleGattDataPath.
* @param[in] path \ref BtmBleDataPath
*/
Result btmuUnregisterBleGattDataPath(const BtmBleDataPath *path);

View File

@ -1,24 +0,0 @@
/**
* @file capmtp.h
* @brief capmtp service IPC wrapper.
* @note Only available on [11.0.0+].
* @author Behemoth
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../sf/service.h"
Result capmtpInitialize(void* mem, size_t size, u32 app_count, u32 max_img, u32 max_vid, const char *other_name);
void capmtpExit(void);
Service* capmtpGetRootServiceSession(void);
Service* capmtpGetServiceSession(void);
Result capmtpStartCommandHandler(void);
Result capmtpStopCommandHandler(void);
bool capmtpIsRunning(void);
Event *capmtpGetConnectionEvent(void);
bool capmtpIsConnected(void);
Event *capmtpGetScanErrorEvent(void);
Result capmtpGetScanError(void);

View File

@ -1,234 +0,0 @@
/**
* @file caps.h
* @brief Common caps (caps:*) service IPC header.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.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;
typedef enum {
CapsAlbumStorage_Nand = 0, ///< Nand
CapsAlbumStorage_Sd = 1, ///< Sd
} CapsAlbumStorage;
/// ContentType
typedef enum {
CapsContentType_Screenshot = 0, ///< Album screenshots.
CapsContentType_Movie = 1, ///< Album videos.
CapsContentType_ExtraMovie = 3, ///< Videos recorded by the current host Application via \ref grcCreateMovieMaker.
} CapsContentType;
/// ScreenShotAttribute
typedef struct {
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;
/// ScreenShotDecoderFlag
typedef enum {
CapsScreenShotDecoderFlag_None = 0, ///< No special processing.
CapsScreenShotDecoderFlag_EnableFancyUpsampling = BIT(0), ///< See libjpeg-turbo do_fancy_upsampling.
CapsScreenShotDecoderFlag_EnableBlockSmoothing = BIT(1), ///< See libjpeg-turbo do_block_smoothing.
} CapsScreenShotDecoderFlag;
/// ScreenShotDecodeOption
typedef struct {
u64 flags; ///< Bitflags, see \ref CapsScreenShotDecoderFlag.
u64 reserved[0x3]; ///< Reserved. Unused 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 application_id; ///< ApplicationId
CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
u8 storage; ///< \ref CapsAlbumStorage
u8 content; ///< \ref CapsAlbumFileContents
u8 unknown_12; ///< [19.0.0+]
u8 unknown_13; ///< [19.0.0+]
u8 pad_x14[0x4]; ///< padding
} CapsAlbumFileId;
/// AlbumEntry
typedef struct {
u64 size; ///< Size.
CapsAlbumFileId file_id; ///< \ref CapsAlbumFileId
} CapsAlbumEntry;
/// ApplicationAlbumEntry
typedef struct {
union {
u8 data[0x20]; ///< Data.
struct {
u8 unk_x0[0x20]; ///< aes256 with random key over \ref AlbumEntry.
} v0; ///< Pre-7.0.0
struct {
u64 size; ///< size of the entry
u64 hash; ///< aes256 with hardcoded key over \ref AlbumEntry.
CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
u8 storage; ///< \ref CapsAlbumStorage
u8 content; ///< \ref CapsAlbumFileContents
u8 pad_x1a[0x5]; ///< padding
u8 unk_x1f; ///< Set to 1 by official software
} 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;
/// AlbumFileContents
typedef enum {
CapsAlbumFileContents_ScreenShot = 0,
CapsAlbumFileContents_Movie = 1,
CapsAlbumFileContents_ExtraScreenShot = 2,
CapsAlbumFileContents_ExtraMovie = 3,
} CapsAlbumFileContents;
typedef enum {
CapsAlbumContentsUsageFlag_HasGreaterUsage = BIT(0), ///< Indicates that there are additional files not captured by the count/size fields of CapsAlbumContentsUsage
CapsAlbumContentsUsageFlag_IsUnknownContents = BIT(1), ///< Indicates that the file is not a known content type
} CapsAlbumContentsUsageFlag;
typedef struct {
s64 count; ///< Count.
s64 size; ///< Size. Used storage space.
u32 flags; ///< \ref CapsAlbumContentsUsageFlag
u8 file_contents; ///< \ref CapsAlbumFileContents
u8 pad_x15[0x3]; ///< Unused
} CapsAlbumContentsUsage;
typedef struct {
CapsAlbumContentsUsage usages[2]; ///< \ref CapsAlbumContentsUsage
} CapsAlbumUsage2;
typedef struct {
CapsAlbumContentsUsage usages[3]; ///< \ref CapsAlbumContentsUsage
} CapsAlbumUsage3;
typedef struct {
CapsAlbumContentsUsage usages[16]; ///< \ref CapsAlbumContentsUsage
} CapsAlbumUsage16;
/// UserIdList
typedef struct {
AccountUid uids[ACC_USER_LIST_SIZE]; ///< \ref AccountUid
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;
/// LoadAlbumScreenShotImageOutput
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.
CapsScreenShotAttribute attr; ///< \ref CapsScreenShotAttribute
u8 unk_x50[0x400]; ///< Unused.
} CapsLoadAlbumScreenShotImageOutput;
/// AlbumFileContentsFlag
typedef enum {
CapsAlbumFileContentsFlag_ScreenShot = BIT(0), ///< Query for ScreenShot files.
CapsAlbumFileContentsFlag_Movie = BIT(1), ///< Query for Movie files.
} CapsAlbumFileContentsFlag;
/// AlbumCache
typedef struct {
u64 count; ///< Count
u64 unk_x8; ///< Unknown
} CapsAlbumCache;
/// 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;
}

View File

@ -1,414 +0,0 @@
/**
* @file capsa.h
* @brief Album Accessor (caps:a) service IPC wrapper.
* @author Behemoth
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
#include "../services/caps.h"
/// Initialize caps:a.
Result capsaInitialize(void);
/// Exit caps:a.
void capsaExit(void);
/// Gets the Service for caps:a.
Service* capsaGetServiceSession(void);
/// Gets the Service for IAlbumAccessorSession, only initialized after \ref capsaOpenAlbumMovieStream was used (unaffected by using \ref capsaCloseAlbumMovieStream).
Service* capsaGetServiceSession_Accessor(void);
/**
* @brief Gets the amount of files at a AlbumStorage.
* @param[in] storage \ref CapsAlbumStorage
* @param[out] count Amount of files.
*/
Result capsaGetAlbumFileCount(CapsAlbumStorage storage, u64 *count);
/**
* @brief Gets a listing of \ref CapsAlbumEntry, where the AlbumFile's storage matches the input one.
* @param[in] storage \ref CapsAlbumStorage
* @param[out] out Total output entries.
* @param[out] entries Output array of \ref CapsAlbumEntry.
* @param[in] count Reserved entry count.
*/
Result capsaGetAlbumFileList(CapsAlbumStorage storage, u64 *out, CapsAlbumEntry *entries, u64 count);
/**
* @brief Loads a file into the specified buffer.
* @param[in] file_id \ref CapsAlbumFileId
* @param[out] out_size Size of the AlbumFile.
* @param[out] filebuf File output buffer.
* @param[in] filebuf_size Size of the filebuf.
*/
Result capsaLoadAlbumFile(const CapsAlbumFileId *file_id, u64 *out_size, void* filebuf, u64 filebuf_size);
/**
* @brief Deletes an AlbumFile corresponding to the specified \ref CapsAlbumFileId.
* @param[in] file_id \ref CapsAlbumFileId
*/
Result capsaDeleteAlbumFile(const CapsAlbumFileId *file_id);
/**
* @brief Copies an AlbumFile to the specified \ref CapsAlbumStorage.
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] dst_storage \ref CapsAlbumStorage
*/
Result capsaStorageCopyAlbumFile(const CapsAlbumFileId *file_id, CapsAlbumStorage dst_storage);
/**
* @brief Gets the mount status of the specified \ref CapsAlbumStorage.
* @param[in] storage \ref CapsAlbumStorage
* @param[out] is_mounted Boolean over whether the storage is mounted or not.
*/
Result capsaIsAlbumMounted(CapsAlbumStorage storage, bool *is_mounted);
/**
* @brief Returns the AlbumUsage for a specified \ref CapsAlbumStorage.
* @param[in] storage \ref CapsAlbumStorage
* @param[out] out \ref CapsAlbumUsage2
*/
Result capsaGetAlbumUsage(CapsAlbumStorage storage, CapsAlbumUsage2 *out);
/**
* @brief Gets the size for the specified AlbumFile.
* @param[in] file_id \ref CapsAlbumFileId
* @param[out] size Size of the file.
*/
Result capsaGetAlbumFileSize(const CapsAlbumFileId *file_id, u64 *size);
/**
* @brief Load the Thumbnail for the specified AlbumFile.
* @note Will always be 320x180.
* @param[in] file_id \ref CapsAlbumFileId
* @param[out] out_size Size of the Thumbnail.
* @param[out] image JPEG image output buffer.
* @param[in] image_size Image buffer size.
*/
Result capsaLoadAlbumFileThumbnail(const CapsAlbumFileId *file_id, u64 *out_size, void* image, u64 image_size);
/**
* @brief Load the ScreenShotImage for the specified AlbumFile.
* @note Only available on [2.0.0+].
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[in] file_id \ref CapsAlbumFileId
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotImage(u64 *width, u64 *height, const CapsAlbumFileId *file_id, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Load the ScreenShotThumbnailImage for the specified AlbumFile.
* @note Only available on [2.0.0+].
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[in] file_id \ref CapsAlbumFileId
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotThumbnailImage(u64 *width, u64 *height, const CapsAlbumFileId *file_id, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Load an \ref CapsAlbumEntry from a \ref CapsApplicationAlbumEntry and an ApplicationId.
* @note Only available on [2.0.0+].
* @param[out] entry \ref CapsAlbumEntry
* @param[in] application_entry \ref CapsApplicationAlbumEntry
* @param[in] application_id ApplicationId
*/
Result capsaGetAlbumEntryFromApplicationAlbumEntry(CapsAlbumEntry *entry, const CapsApplicationAlbumEntry *application_entry, u64 application_id);
/**
* @brief Load the ScreenShotImage for the specified AlbumFile.
* @note Only available on [3.0.0+].
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] opts \ref CapsScreenShotDecodeOption
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotImageEx(u64 *width, u64 *height, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Load the ScreenShotThumbnailImage for the specified AlbumFile.
* @note Only available on [3.0.0+].
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] opts \ref CapsScreenShotDecodeOption
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotThumbnailImageEx(u64 *width, u64 *height, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Load the ScreenShotImage for the specified AlbumFile.
* @note Only available on [3.0.0+].
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[out] attr \ref CapsScreenShotAttribute
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] opts \ref CapsScreenShotDecodeOption
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotImageEx0(u64 *width, u64 *height, CapsScreenShotAttribute *attr, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Returns the AlbumUsage for a specified \ref CapsAlbumStorage.
* @note Only available on [4.0.0+].
* @param[in] storage \ref CapsAlbumStorage
* @param[out] out \ref CapsAlbumUsage3
*/
Result capsaGetAlbumUsage3(CapsAlbumStorage storage, CapsAlbumUsage3 *out);
/**
* @brief Returns the result for a AlbumStorage mount.
* @note Only available on [4.0.0+].
* @param[in] storage \ref CapsAlbumStorage
*/
Result capsaGetAlbumMountResult(CapsAlbumStorage storage);
/**
* @brief Returns the AlbumUsage for a specified \ref CapsAlbumStorage.
* @note Only available on [4.0.0+].
* @param[in] storage \ref CapsAlbumStorage
* @param[in] flags \ref CapsAlbumFileContentsFlag
* @param[out] out \ref CapsAlbumUsage16
*/
Result capsaGetAlbumUsage16(CapsAlbumStorage storage, u8 flags, CapsAlbumUsage16 *out);
/**
* @brief Returns the start and end of the Applet Id range.
* @note Only available on [6.0.0+].
* @param[out] success Returns bool over whether the call was handled or not.
* @param[out] min Mimimum applet id. Always 0x0100000000001000
* @param[out] max Maximum applet id. Always 0x0100000000001FFF
*/
Result capsaGetMinMaxAppletId(bool* success, u64* min, u64* max);
/**
* @brief Gets the amount of files of the specified type at a AlbumStorage.
* @note Only available on [5.0.0+].
* @param[in] storage \ref CapsAlbumStorage
* @param[in] flags \ref CapsAlbumFileContentsFlag
* @param[out] count Amount of files.
*/
Result capsaGetAlbumFileCountEx0(CapsAlbumStorage storage, u8 flags, u64 *count);
/**
* @brief Gets a listing of \ref CapsAlbumEntry, where the AlbumFile's storage and type matches the input one.
* @note Only available on [5.0.0+].
* @param[in] storage \ref CapsAlbumStorage
* @param[in] flags \ref CapsAlbumFileContentsFlag
* @param[out] out Total output entries.
* @param[out] entries Output array of \ref CapsAlbumEntry.
* @param[in] count Reserved entry count.
*/
Result capsaGetAlbumFileListEx0(CapsAlbumStorage storage, u8 flags, u64 *out, CapsAlbumEntry *entries, u64 count);
/**
* @brief Returns the image from the last shown ScreenShot Overlay.
* @param[out] file_id \ref CapsAlbumFileId
* @param[out] out_size Size of the thumbnail image. Always 0x5100.
* @param[out] image RGBA8 image output buffer.
* @param[in] image_size Image buffer size, should be at least large enough for RGBA8 96×54.
*/
Result capsaGetLastOverlayScreenShotThumbnail(CapsAlbumFileId *file_id, u64 *out_size, void* image, u64 image_size);
/**
* @brief Returns the image from the last shown Movie Overlay.
* @note Only available on [4.0.0+].
* @param[out] file_id \ref CapsAlbumFileId
* @param[out] out_size Size of the thumbnail image. Always 0x5100.
* @param[out] image RGBA8 image output buffer.
* @param[in] image_size Image buffer size, should be at least large enough for RGBA8 96×54.
*/
Result capsaGetLastOverlayMovieThumbnail(CapsAlbumFileId *file_id, u64 *out_size, void* image, u64 image_size);
/**
* @brief Gets the currently set autosaving storage.
* @note Wrapper around setsysGetPrimaryAlbumStorage but defaults to NAND if SD isn't available.
* @param[out] storage \ref CapsAlbumStorage
*/
Result capsaGetAutoSavingStorage(CapsAlbumStorage *storage);
/**
* @brief Gets required size to copy all files from one Storage to another.
* @param[in] dst_storage \ref CapsAlbumStorage
* @param[in] src_storage \ref CapsAlbumStorage
* @param[out] out Required storage space size.
*/
Result capsaGetRequiredStorageSpaceSizeToCopyAll(CapsAlbumStorage dst_storage, CapsAlbumStorage src_storage, u64 *out);
/**
* @brief Load the ScreenShotThumbnailImage for the specified AlbumFile.
* @note Only available on [3.0.0+].
* @param[out] width Output image width. Optional, can be NULL.
* @param[out] height Output image height. Optional, can be NULL.
* @param[out] attr \ref CapsScreenShotAttribute
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] opts \ref CapsScreenShotDecodeOption
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsLoadAlbumScreenShotThumbnailImageEx0(u64 *width, u64 *height, CapsScreenShotAttribute *attr, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Load the ScreenShotImage for the specified AlbumFile.
* @note Only available on [4.0.0+].
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] opts \ref CapsScreenShotDecodeOption
* @param[out] out \ref CapsLoadAlbumScreenShotImageOutput
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotImageEx1(const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, CapsLoadAlbumScreenShotImageOutput *out, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Load the ScreenShotThumbnailImage for the specified AlbumFile.
* @note Only available on [4.0.0+].
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] opts \ref CapsScreenShotDecodeOption
* @param[out] out \ref CapsLoadAlbumScreenShotImageOutput
* @param[out] image RGBA8 image output buffer.
* @param[in] 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[in] workbuf_size Work buffer size, must be at least the size of the JPEG within the AlbumFile.
*/
Result capsaLoadAlbumScreenShotThumbnailImageEx1(const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, CapsLoadAlbumScreenShotImageOutput *out, void* image, u64 image_size, void* workbuf, u64 workbuf_size);
/**
* @brief Unmounts the specified AlbumStorage.
* @param[in] storage \ref CapsAlbumStorage
*/
Result capsaForceAlbumUnmounted(CapsAlbumStorage storage);
/**
* @brief Resets mount status for the specified AlbumStorage.
* @note Mounts the Storage if available.
* @param[in] storage \ref CapsAlbumStorage
*/
Result capsaResetAlbumMountStatus(CapsAlbumStorage storage);
/**
* @brief Refreshs Album Cache for the specified AlbumStorage.
* @param[in] storage \ref CapsAlbumStorage
*/
Result capsaRefreshAlbumCache(CapsAlbumStorage storage);
/**
* @brief Gets the AlbumCache of the specified AlbumStorage.
* @note Stubbed on [4.0.0+].
* @note use \ref capsaGetAlbumCacheEx instead.
* @param[in] storage \ref CapsAlbumStorage
* @param[out] cache \ref CapsAlbumCache
*/
Result capsaGetAlbumCache(CapsAlbumStorage storage, CapsAlbumCache *cache);
/**
* @brief Gets the AlbumCache for the specified type of the specified AlbumStorage.
* @param[in] storage \ref CapsAlbumStorage
* @param[in] contents \ref CapsAlbumFileContents
* @param[out] cache \ref CapsAlbumCache
*/
Result capsaGetAlbumCacheEx(CapsAlbumStorage storage, CapsAlbumFileContents contents, CapsAlbumCache *cache);
/**
* @brief Load an \ref CapsAlbumEntry from a \ref CapsApplicationAlbumEntry and an AppletResourceUserId.
* @note Only available on [2.0.0+].
* @param[out] entry \ref CapsAlbumEntry
* @param[in] application_entry \ref CapsApplicationAlbumEntry
*/
Result capsaGetAlbumEntryFromApplicationAlbumEntryAruid(CapsAlbumEntry *entry, const CapsApplicationAlbumEntry *application_entry);
/**
* @brief Opens an AlbumMovieStream.
* @note This opens IAlbumAccessorSession if not previously opened, it's closed during \ref capsaExit.
* @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 CapsAlbumFileId.
* @note Only available on [4.0.0+].
* @param[out] stream Stream handle.
* @param[in] entry \ref CapsAlbumFileId
*/
Result capsaOpenAlbumMovieStream(u64 *stream, const CapsAlbumFileId *file_id);
/**
* @brief Closes an AlbumMovieStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capsaCloseAlbumMovieStream(u64 stream);
/**
* @brief Gets the data size of an AlbumMovieStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] size Size of the actual MP4, without the JPEG at the end.
*/
Result capsaGetAlbumMovieStreamSize(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 capsaGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size.
* @note Only available on [4.0.0+].
* @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 capsaReadMovieDataFromAlbumMovieReadStream(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.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capsaGetAlbumMovieReadStreamBrokenReason(u64 stream);
/**
* @brief Gets the data size of an Image taken from an AlbumMovieStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] size Expected size of an Image.
*/
Result capsaGetAlbumMovieReadStreamImageDataSize(u64 stream, u64 *size);
/**
* @brief Reads data of an Image taken from an AlbumMovieStream.
* @note Only available on [4.0.0+].
* @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 capsaReadImageDataFromAlbumMovieReadStream(u64 stream, s64 offset, void* buffer, size_t size, u64 *actual_size);
/**
* @brief Gets the file attribute of an AlbumMovieStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] attr \ref CapsScreenShotAttribute
*/
Result capsaReadFileAttributeFromAlbumMovieReadStream(u64 stream, CapsScreenShotAttribute *attr);

View File

@ -1,340 +0,0 @@
/**
* @file capsc.h
* @brief Album Control (caps:c) service IPC wrapper.
* @author Behemoth
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
#include "../services/caps.h"
typedef struct {
u64 application_id;
u8 unknown_08;
u8 unknown_09;
u8 reserved[6];
} CapsApplicationId;
/// Initialize caps:c
Result capscInitialize(void);
/// Exit caps:c.
void capscExit(void);
/// Gets the Service for caps:c.
Service* capscGetServiceSession(void);
/**
* @brief Notify the service that a storage is now available.
* @note This will result in capsrv mounting the image directory on that storage medium.
* @param[in] storage \ref CapsAlbumStorage
*/
Result capscNotifyAlbumStorageIsAvailable(CapsAlbumStorage storage);
/**
* @brief Notify the service that a storage is now unavailable.
* @note This will result in capsrv unmounting the image directory on that storage medium.
* @param[in] storage \ref CapsAlbumStorage
*/
Result capscNotifyAlbumStorageIsUnAvailable(CapsAlbumStorage storage);
/**
* @brief Register an applet for later usage.
* @note Called at application launch by the system.
* @note Will generate a random AES-256 key for this application for use on Shim-Version 0.
* @note Only available on [2.0.0+].
* @param[in] appletResourceUserId AppletResourceUserId.
* @param[in] application_id ApplicationId.
*/
Result capscRegisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id);
/**
* @brief Unregister an applet.
* @note Called at application exit by the system.
* @note Only available on [2.0.0+].
* @param[in] appletResourceUserId AppletResourceUserId.
* @param[in] application_id ApplicationId.
*/
Result capscUnregisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id);
/**
* @brief Get an ApplicationId that corresponds to an AppletResourceUserId.
* @note Returns value set by \ref capscRegisterAppletResourceUserId.
* @note Only available on [2.0.0+].
* @param[out] application_id ApplicationId.
* @param[in] appletResourceUserId AppletResourceUserId.
*/
Result capscGetApplicationIdFromAruid(CapsApplicationId *application_id, u64 aruid);
/**
* @brief Checks whether an ApplicationId is registered.
* @note Only available on [2.0.0+].
* @param[in] application_id ApplicationId.
*/
Result capscCheckApplicationIdRegistered(u64 application_id);
/**
* @brief Generate an AlbumFileId based on parameters and current time.
* @param[in] application_id ApplicationId.
* @note Only available on [2.0.0+].
* @param[in] contents \ref CapsAlbumFileContents
* @param[out] file_id \ref CapsAlbumFileId
*/
Result capscGenerateCurrentAlbumFileId(const CapsApplicationId *application_id, CapsAlbumFileContents contents, CapsAlbumFileId *file_id);
/**
* @brief Generate an ApplicationAlbumEntry based on parameters.
* @note Output will be different between Shim Version 0 and 1.
* @note Only available on [2.0.0+].
* @param[out] appEntry \ref CapsApplicationAlbumEntry
* @param[in] entry \ref CapsAlbumEntry
* @param[in] application_id ApplicationId.
*/
Result capscGenerateApplicationAlbumEntry(CapsApplicationAlbumEntry *appEntry, const CapsAlbumEntry *entry, u64 application_id);
/**
* @brief Save a jpeg image.
* @note Only available on [2.0.0-3.0.2].
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] buffer JPEG image buffer.
* @param[in] buffer_size Size of the JPEG image.
*/
Result capscSaveAlbumScreenShotFile(const CapsAlbumFileId *file_id, const void* buffer, u64 buffer_size);
/**
* @brief Save a jpeg image.
* @note Only available on [4.0.0+].
* @note Version 3 as of [9.1.0].
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] version Revision number.
* @param[in] makernote_offset Offset to makernote in JPEG buffer.
* @param[in] makernote_size Size of the makernote in JPEG buffer.
* @param[in] buffer JPEG image buffer.
* @param[in] buffer_size Size of the JPEG image.
*/
Result capscSaveAlbumScreenShotFileEx(const CapsAlbumFileId *file_id, u64 version, u64 makernote_offset, u64 makernote_size, const void* buffer, u64 buffer_size);
/**
* @brief Sets thumbnail data for the last taken screenshot.
* @note 96×54 Image will get saved.
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] image RGBA8 image buffer.
* @param[in] image_size size of the RGBA8 image buffer.
*/
Result capscSetOverlayScreenShotThumbnailData(const CapsAlbumFileId *file_id, const void* image, u64 image_size);
/**
* @brief Sets thumbnail data for the last recorded movie.
* @note Only availabe on [4.0.0+].
* @note 96×54 Image will get saved.
* @param[in] file_id \ref CapsAlbumFileId
* @param[in] image RGBA8 image buffer.
* @param[in] image_size size of the RGBA8 image buffer.
*/
Result capscSetOverlayMovieThumbnailData(const CapsAlbumFileId *file_id, const void* image, u64 image_size);
/**
* @brief Opens an AlbumMovieReadStream.
* @note This opens IAlbumControlSession if not previously opened, it's closed during \ref capscExit.
* @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 CapsAlbumFileId.
* @note Only available on [4.0.0+].
* @param[out] stream Stream handle.
* @param[in] entry \ref CapsAlbumFileId
*/
Result capscOpenAlbumMovieReadStream(u64 *stream, const CapsAlbumFileId *file_id);
/**
* @brief Closes an AlbumMovieReadStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscCloseAlbumMovieStream(u64 stream);
/**
* @brief Gets the data size of an AlbumMovieReadStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] size Size of the actual MP4, without the JPEG at the end.
*/
Result capscGetAlbumMovieStreamSize(u64 stream, u64 *size);
/**
* @brief Reads data from an AlbumMovieReadStream.
* @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 capscGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size.
* @note Only available on [4.0.0+].
* @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 capscReadMovieDataFromAlbumMovieReadStream(u64 stream, u64 offset, void* buffer, size_t size, u64 *actual_size);
/**
* @brief Gets the BrokenReason for an AlbumMovieReadStream.
* @note Official sw doesn't use this.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscGetAlbumMovieReadStreamBrokenReason(u64 stream);
/**
* @brief Gets the data size of an Image taken from an AlbumMovieReadStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] size Expected size of an Image.
*/
Result capscGetAlbumMovieReadStreamImageDataSize(u64 stream, u64 *size);
/**
* @brief Reads data of an Image taken from an AlbumMovieReadStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[in] offset Offset.
* @param[out] buffer Output data buffer.
* @param[in] size Data buffer size.
* @param[out] actual_size Actual read size.
*/
Result capscReadImageDataFromAlbumMovieReadStream(u64 stream, u64 offset, void* buffer, size_t size, u64 *actual_size);
/**
* @brief Gets the file attribute of an AlbumMovieReadStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] attr \ref CapsScreenShotAttribute
*/
Result capscReadFileAttributeFromAlbumMovieReadStream(u64 stream, CapsScreenShotAttribute *attribute);
/**
* @brief Opens an AlbumMovieWriteStream.
* @note This opens IAlbumControlSession if not previously opened, it's closed during \ref capsaExit.
* @note Up to 2 streams can be open at the same time.
* @note Only available on [4.0.0+].
* @param[out] stream Stream handle.
* @param[in] entry \ref CapsAlbumFileId
*/
Result capscOpenAlbumMovieWriteStream(u64 *stream, const CapsAlbumFileId *file_id);
/**
* @brief Finish write to AlbumMovieWriteStream.
* @note Copies file from save to destination storage and deletes the temporary file.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscFinishAlbumMovieWriteStream(u64 stream);
/**
* @brief Closes a finished AlbumMovieWriteStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscCommitAlbumMovieWriteStream(u64 stream);
/**
* @brief Closes an AlbumMovieWriteStream in any state.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscDiscardAlbumMovieWriteStream(u64 stream);
/**
* @brief Closes an AlbumMovieWriteStream in any state without deleting the temporary file.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscDiscardAlbumMovieWriteStreamNoDelete(u64 stream);
/**
* @brief Closes a finished AlbumMovieWriteStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] entry \ref CapsAlbumEntry
*/
Result capscCommitAlbumMovieWriteStreamEx(u64 stream, CapsAlbumEntry *entry);
/**
* @brief Start AlbumMovieWriteStream data section.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscStartAlbumMovieWriteStreamDataSection(u64 stream);
/**
* @brief End AlbumMovieWriteStream data section.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscEndAlbumMovieWriteStreamDataSection(u64 stream);
/**
* @brief Start AlbumMovieWriteStream meta section.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscStartAlbumMovieWriteStreamMetaSection(u64 stream);
/**
* @brief End AlbumMovieWriteStream meta section.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscEndAlbumMovieWriteStreamMetaSection(u64 stream);
/**
* @brief Reads data from an AlbumMovieWriteStream.
* @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 capscGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[in] offset Offset.
* @param[out] buffer Output data buffer.
* @param[in] size Data buffer size.
* @param[out] actual_size Actual read size.
*/
Result capscReadDataFromAlbumMovieWriteStream(u64 stream, u64 offset, void* buffer, u64 size, u64 *actual_size);
/**
* @brief Write data to an AlbumMovieWriteStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[in] offset Offset.
* @param[in] buffer Input data buffer.
* @param[in] size Data buffer size.
*/
Result capscWriteDataToAlbumMovieWriteStream(u64 stream, u64 offset, const void* buffer, u64 size);
/**
* @brief Write meta data to an AlbumMovieWriteStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[in] offset Offset.
* @param[in] buffer Input data buffer.
* @param[in] size Data buffer size.
*/
Result capscWriteMetaToAlbumMovieWriteStream(u64 stream, u64 offset, const void* buffer, u64 size);
/**
* @brief Gets the BrokenReason for an AlbumMovieWriteStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
*/
Result capscGetAlbumMovieWriteStreamBrokenReason(u64 stream);
/**
* @brief Gets the data size of an AlbumMovieWriteStream.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] size Size of the data section.
*/
Result capscGetAlbumMovieWriteStreamDataSize(u64 stream, u64 *size);
/**
* @brief Sets the data size of an AlbumMovieWriteStream.
* @note Must not be bigger than 2GiB.
* @note Only available on [4.0.0+].
* @param[in] stream Stream handle.
* @param[out] size Size of the data section.
*/
Result capscSetAlbumMovieWriteStreamDataSize(u64 stream, u64 size);

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