diff --git a/Source/hoc-clk/common/include/switch.hpp b/Source/hoc-clk/common/include/switch.hpp new file mode 100644 index 00000000..b39225be --- /dev/null +++ b/Source/hoc-clk/common/include/switch.hpp @@ -0,0 +1,28929 @@ +/** + * @file switch.hpp + * @brief Libnx C++ bindings (AUTO-GENERATED, do not edit). + * @copyright libnx Authors + */ +#pragma once + +#ifndef __cplusplus +#error "libnx C++ bindings require a C++ compiler." +#endif + +#include + +extern "C++" { +/// @brief Root namespace of the libnx C++ bindings. +namespace nx { + +/// @brief Version string of the generated C++ bindings. +/// @return Generator description (see switch.cpp). +const char *CppBindingsVersion(); + +/// NetworkServiceAccountId +using ::AccountNetworkServiceAccountId; +/// Profile +using ::AccountProfile; +/// ProfileBase +using ::AccountProfileBase; +using ::AccountServiceType; +/// Account UserId. +using ::AccountUid; +/// UserData +using ::AccountUserData; +/// Context for AES-128 CBC. +using ::Aes128CbcContext; +/// Context for AES-128 CMAC. +using ::Aes128CmacContext; +/// Context for AES-128 operations. +using ::Aes128Context; +/// Context for AES-128 CTR. +using ::Aes128CtrContext; +/// Context for AES-128 XTS. +using ::Aes128XtsContext; +/// Context for AES-192 CBC. +using ::Aes192CbcContext; +/// Context for AES-192 CMAC. +using ::Aes192CmacContext; +/// Context for AES-192 operations. +using ::Aes192Context; +/// Context for AES-192 CTR. +using ::Aes192CtrContext; +/// Context for AES-192 XTS. +using ::Aes192XtsContext; +/// Context for AES-256 CBC. +using ::Aes256CbcContext; +/// Context for AES-256 CMAC. +using ::Aes256CmacContext; +/// Context for AES-256 operations. +using ::Aes256Context; +/// Context for AES-256 CTR. +using ::Aes256CtrContext; +/// Context for AES-256 XTS. +using ::Aes256XtsContext; +/// ImageOrientation +using ::AlbumImageOrientation; +/// Arg type values pushed for the applet input storage, stored as an u8. +using ::AlbumLaArg; +/// AlbumReportOption +using ::AlbumReportOption; +/// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates. +using ::ApmCpuBoostMode; +/// PerformanceMode +using ::ApmPerformanceMode; +/// IApplicationAccessor container. +using ::AppletApplication; +/// ApplicationAttribute +using ::AppletApplicationAttribute; +/// Attributes for launching applications for Quest. +using ::AppletApplicationAttributeForQuest; +/// AppletApplicationExitReason +using ::AppletApplicationExitReason; +/// ApplicationLaunchProperty +using ::AppletApplicationLaunchProperty; +/// ApplicationLaunchRequestInfo +using ::AppletApplicationLaunchRequestInfo; +/// Used by \ref appletInitialize with __nx_applet_AppletAttribute for cmd OpenLibraryAppletProxy (AppletType_LibraryApplet), on [3.0.0+]. The default for this struct is all-zero. +using ::AppletAttribute; +/// CaptureSharedBuffer for the IDisplayController commands. +using ::AppletCaptureSharedBuffer; +/// FocusHandlingMode +using ::AppletFocusHandlingMode; +/// FocusState +using ::AppletFocusState; +/// GpuErrorHandler +using ::AppletGpuErrorHandler; +/// LibraryApplet state. +using ::AppletHolder; +/// applet hook cookie. +using ::AppletHookCookie; +/// applet hook function. +using ::AppletHookFn; +/// applet hook types. +using ::AppletHookType; +/// AppletId +using ::AppletId; +/// IdentityInfo +using ::AppletIdentityInfo; +/// Extension values for \ref appletSetIdleTimeDetectionExtension / \ref appletGetIdleTimeDetectionExtension, for extending user inactivity detection. +using ::AppletIdleTimeDetectionExtension; +/// Cached info for the current LibraryApplet, from \ref appletGetAppletInfo. +using ::AppletInfo; +/// Input policy values for \ref appletSetInputDetectionPolicy. +using ::AppletInputDetectionPolicy; +/// LaunchParameterKind +using ::AppletLaunchParameterKind; +/// LockAccessor +using ::AppletLockAccessor; +/// AppletMessage, for \ref appletGetMessage. See also \ref AppletHookType. +using ::AppletMessage; +/// OperationMode +using ::AppletOperationMode; +/// AppletProcessLaunchReason, from GetLaunchReason. +using ::AppletProcessLaunchReason; +/// ProgramSpecifyKind for the ExecuteProgram cmd. Controls the type of the u64 passed to the ExecuteProgram cmd. +using ::AppletProgramSpecifyKind; +/// AppletResourceUsageInfo, from \ref appletGetAppletResourceUsageInfo. +using ::AppletResourceUsageInfo; +/// Permission values for \ref appletSetScreenShotPermission. +using ::AppletScreenShotPermission; +/// applet IStorage +using ::AppletStorage; +/// Type values for \ref appletPerformSystemButtonPressingIfInFocus. +using ::AppletSystemButtonType; +/// ThemeColorType +using ::AppletThemeColorType; +/// Mode values for \ref appletSetTvPowerStateMatchingMode. +using ::AppletTvPowerStateMatchingMode; +/// AppletType +using ::AppletType; +/// WindowOriginMode +using ::AppletWindowOriginMode; +/// Input mode values for \ref appletSetWirelessPriorityMode. +using ::AppletWirelessPriorityMode; +/// WaitForAddress behaviors. +using ::ArbitrationType; +/// AsyncResult +using ::AsyncResult; +/// AsyncValue +using ::AsyncValue; +/// AudioDeviceName +using ::AudioDeviceName; +using ::AudioDriver; +using ::AudioDriverEtc; +using ::AudioDriverWaveBuf; +using ::AudioDriverWaveBufState; +using ::AudioForceMutePolicy; +using ::AudioHeadphoneOutputLevelMode; +/// Audio input buffer format +using ::AudioInBuffer; +using ::AudioInState; +/// Audio output buffer format +using ::AudioOutBuffer; +using ::AudioOutputMode; +using ::AudioOutState; +using ::AudioRendererAdpcmContext; +using ::AudioRendererAdpcmParameters; +using ::AudioRendererBehaviorInfoIn; +using ::AudioRendererBehaviorInfoOut; +using ::AudioRendererBiquadFilter; +using ::AudioRendererChannelInfoIn; +using ::AudioRendererCircularBufferSinkInfoIn; +using ::AudioRendererConfig; +using ::AudioRendererDeviceSinkInfoIn; +using ::AudioRendererDownMixParameters; +using ::AudioRendererMemPoolInfoIn; +using ::AudioRendererMemPoolInfoOut; +using ::AudioRendererMemPoolState; +using ::AudioRendererMixInfoIn; +using ::AudioRendererOutputRate; +using ::AudioRendererPerformanceBufferInfoIn; +using ::AudioRendererPerformanceBufferInfoOut; +using ::AudioRendererSinkInfoIn; +using ::AudioRendererSinkInfoOut; +using ::AudioRendererSinkType; +using ::AudioRendererUpdateDataHeader; +using ::AudioRendererVoiceInfoIn; +using ::AudioRendererVoiceInfoOut; +using ::AudioRendererVoicePlayState; +using ::AudioRendererWaveBuf; +using ::AudioTarget; +using ::AudrecRecorder; +using ::AvmRequiredVersionEntry; +using ::AvmVersionListEntry; +using ::AvmVersionListImporter; +/// Barrier structure. +using ::Barrier; +using ::Binder; +using ::BpcSleepButtonState; +using ::BqBufferInput; +using ::BqBufferOutput; +using ::BqGraphicBuffer; +using ::BqRect; +/// Break point types +using ::BreakPointType; +/// Break reasons +using ::BreakReason; +/// BSD service type used by the socket driver. +using ::BsdServiceType; +/// GattAttribute +using ::BtdevGattAttribute; +/// GattCharacteristic +using ::BtdevGattCharacteristic; +/// GattDescriptor +using ::BtdevGattDescriptor; +/// GattService +using ::BtdevGattService; +/// AdapterProperty [12.0.0+] +using ::BtdrvAdapterProperty; +/// AdapterProperty [1.0.0-11.0.1] +using ::BtdrvAdapterPropertyOld; +/// AdapterPropertySet [12.0.0+] +using ::BtdrvAdapterPropertySet; +/// AdapterPropertyType [12.0.0+] +using ::BtdrvAdapterPropertyType; +/// Address +using ::BtdrvAddress; +/// AdType +using ::BtdrvAdType; +/// AppearanceCategoryType +using ::BtdrvAppearanceCategoryType; +/// AppearanceType +using ::BtdrvAppearanceType; +/// AudioCodec +using ::BtdrvAudioCodec; +/// AudioControlButtonState +using ::BtdrvAudioControlButtonState; +/// Data for \ref btdrvGetAudioEventInfo. The data stored here depends on the \ref BtdrvAudioEventType. +using ::BtdrvAudioEventInfo; +/// AudioEventType +using ::BtdrvAudioEventType; +/// AudioOutState +using ::BtdrvAudioOutState; +/// BtdrvBleAdBit +using ::BtdrvBleAdBit; +/// BtdrvBleAdFlag +using ::BtdrvBleAdFlag; +/// BleAdvertiseFilter +using ::BtdrvBleAdvertiseFilter; +/// BleAdvertisement +using ::BtdrvBleAdvertisement; +/// BtdrvBleAdvertisePacketData +using ::BtdrvBleAdvertisePacketData; +/// BleAdvertisePacketParameter +using ::BtdrvBleAdvertisePacketParameter; +/// BleClientGattOperationInfo +using ::BtdrvBleClientGattOperationInfo; +/// BleConnectionInfo +using ::BtdrvBleConnectionInfo; +/// BleConnectionParameter [9.0.0+] +using ::BtdrvBleConnectionParameter; +/// Data for \ref btdrvGetBleManagedEventInfo and \ref btdrvGetLeHidEventInfo. The data stored here depends on the \ref BtdrvBleEventType. +using ::BtdrvBleEventInfo; +/// BleEventType +using ::BtdrvBleEventType; +/// BleScanResult +using ::BtdrvBleScanResult; +/// 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. +using ::BtdrvBluetoothHhReportType; +/// BluetoothPinCode [1.0.0-11.0.1] +using ::BtdrvBluetoothPinCode; +/// BluetoothPropertyType [1.0.0-11.0.1] +using ::BtdrvBluetoothPropertyType; +/// ChannelMapList +using ::BtdrvChannelMapList; +/// CircularBuffer +using ::BtdrvCircularBuffer; +/// ClassOfDevice +using ::BtdrvClassOfDevice; +/// ConnectionEventType +using ::BtdrvConnectionEventType; +/// Data for \ref btdrvGetEventInfo. The data stored here depends on the \ref BtdrvEventType. +using ::BtdrvEventInfo; +/// EventType +using ::BtdrvEventType; +/// ExtEventType [1.0.0-11.0.1] +using ::BtdrvExtEventType; +/// This determines the u16 data to write into a CircularBuffer. +using ::BtdrvFatalReason; +/// GattAttribute +using ::BtdrvGattAttribute; +/// GattAttributePermission +using ::BtdrvGattAttributePermission; +/// GattAttributeType +using ::BtdrvGattAttributeType; +/// GattAttributeUuid +using ::BtdrvGattAttributeUuid; +/// GattAuthReqType +using ::BtdrvGattAuthReqType; +/// GattCharacteristicProperty +using ::BtdrvGattCharacteristicProperty; +/// GattCharacteristicUuidType +using ::BtdrvGattCharacteristicUuidType; +/// GattDescriptorUuidType +using ::BtdrvGattDescriptorUuidType; +/// GattId +using ::BtdrvGattId; +/// GattServiceUuidType +using ::BtdrvGattServiceUuidType; +/// HidConnectionStatus [12.0.0+] +using ::BtdrvHidConnectionStatus; +/// HidData [1.0.0-8.1.1] +using ::BtdrvHidData; +/// Data for \ref btdrvGetHidEventInfo. The data stored here depends on the \ref BtdrvHidEventType. +using ::BtdrvHidEventInfo; +/// HidEventType +using ::BtdrvHidEventType; +/// HidReport [9.0.0+]. +using ::BtdrvHidReport; +/// Data for \ref btdrvGetHidReportEventInfo. The data stored here depends on the \ref BtdrvHidEventType. +using ::BtdrvHidReportEventInfo; +/// The raw sharedmem data for HidReportEventInfo. +using ::BtdrvHidReportEventInfoBufferData; +/// BtdrvInquiryStatus +using ::BtdrvInquiryStatus; +/// LeConnectionParams [5.0.0-8.1.1] +using ::BtdrvLeConnectionParams; +/// LeEventInfo +using ::BtdrvLeEventInfo; +/// PcmParameter +using ::BtdrvPcmParameter; +/// BtdrvPinCode [12.0.0+] +using ::BtdrvPinCode; +/// PlrList +using ::BtdrvPlrList; +/// PlrStatistics +using ::BtdrvPlrStatistics; +/// AudioDevice +using ::BtmAudioDevice; +/// AudioDeviceCondition [13.0.0+] +using ::BtmAudioDeviceCondition; +/// AudioDeviceInfo [13.0.0+] +using ::BtmAudioDeviceInfo; +/// BdName +using ::BtmBdName; +/// BleDataPath +using ::BtmBleDataPath; +/// BluetoothMode +using ::BtmBluetoothMode; +/// ClassOfDevice +using ::BtmClassOfDevice; +/// DeviceCondition [13.0.0+] +using ::BtmDeviceCondition; +/// DeviceCondition [1.0.0-12.1.0] +using ::BtmDeviceConditionLegacy; +/// DeviceConditionList [1.0.0-12.1.0] +using ::BtmDeviceConditionList; +/// DeviceConditionList [1.0.0-5.0.2] +using ::BtmDeviceConditionListV100; +/// DeviceConditionList [5.1.0-7.0.1] +using ::BtmDeviceConditionListV510; +/// DeviceConditionList [8.0.0-8.1.1] +using ::BtmDeviceConditionListV800; +/// DeviceConditionList [9.0.0-12.1.0] +using ::BtmDeviceConditionListV900; +/// DeviceInfo [13.0.0+] +using ::BtmDeviceInfo; +/// DeviceInfo [1.0.0-12.1.0] +using ::BtmDeviceInfoLegacy; +/// DeviceInfoList +using ::BtmDeviceInfoList; +/// DeviceProperty +using ::BtmDeviceProperty; +/// DevicePropertyList +using ::BtmDevicePropertyList; +/// DeviceSlotMode +using ::BtmDeviceSlotMode; +/// DeviceSlotModeList +using ::BtmDeviceSlotModeList; +/// GattCharacteristic +using ::BtmGattCharacteristic; +/// GattClientConditionList +using ::BtmGattClientConditionList; +/// GattDescriptor +using ::BtmGattDescriptor; +/// GattService +using ::BtmGattService; +/// HidDeviceCondition +using ::BtmHidDeviceCondition; +/// HidDeviceInfo +using ::BtmHidDeviceInfo; +/// HostDeviceProperty +using ::BtmHostDeviceProperty; +/// LinkKey +using ::BtmLinkKey; +/// Profile +using ::BtmProfile; +/// ShortenedDeviceCondition [14.0.0+] +using ::BtmShortenedDeviceCondition; +/// ShortenedDeviceInfo [13.0.0+] +using ::BtmShortenedDeviceInfo; +/// SlotMode +using ::BtmSlotMode; +using ::BtmSniffMode; +/// BtmState +using ::BtmState; +/// TsiMode +using ::BtmTsiMode; +/// WlanMode +using ::BtmWlanMode; +/// ZeroRetransmissionList +using ::BtmZeroRetransmissionList; +/// AlbumCache +using ::CapsAlbumCache; +using ::CapsAlbumContentsUsage; +using ::CapsAlbumContentsUsageFlag; +/// AlbumEntry +using ::CapsAlbumEntry; +/// AlbumFileContents +using ::CapsAlbumFileContents; +/// AlbumFileContentsFlag +using ::CapsAlbumFileContentsFlag; +/// AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYYYMMDDHHMMSSII". +using ::CapsAlbumFileDateTime; +/// AlbumEntryId +using ::CapsAlbumFileId; +using ::CapsAlbumStorage; +using ::CapsAlbumUsage16; +using ::CapsAlbumUsage2; +using ::CapsAlbumUsage3; +/// ApplicationAlbumEntry +using ::CapsApplicationAlbumEntry; +/// ApplicationAlbumFileEntry +using ::CapsApplicationAlbumFileEntry; +/// ApplicationData +using ::CapsApplicationData; +using ::CapsApplicationId; +/// ContentType +using ::CapsContentType; +/// LoadAlbumScreenShotImageOutput +using ::CapsLoadAlbumScreenShotImageOutput; +/// LoadAlbumScreenShotImageOutputForApplication +using ::CapsLoadAlbumScreenShotImageOutputForApplication; +/// ScreenShotAttribute +using ::CapsScreenShotAttribute; +/// ScreenShotAttributeForApplication. Only unk_x0 is used by official sw. +using ::CapsScreenShotAttributeForApplication; +/// ScreenShotDecodeOption +using ::CapsScreenShotDecodeOption; +/// ScreenShotDecoderFlag +using ::CapsScreenShotDecoderFlag; +/// UserIdList +using ::CapsUserIdList; +using ::ClkrstSession; +using ::CmifCommandType; +using ::CmifDomainInHeader; +using ::CmifDomainOutHeader; +using ::CmifDomainRequestType; +using ::CmifInHeader; +using ::CmifOutHeader; +using ::CmifRequest; +using ::CmifRequestFormat; +using ::CmifResponse; +/// Code memory mapping operations +using ::CodeMapOperation; +using ::ColorSetId; +/// Condition variable. +using ::CondVar; +/// Structure representing an entry in the homebrew environment configuration. +using ::ConfigEntry; +/// A font struct for the console. +using ::ConsoleFont; +/// Renderer interface for the console. +using ::ConsoleRenderer; +/// Armv8 CPU register. +using ::CpuRegister; +/// Address space types for CreateProcessFlags +using ::CreateProcessFlagAddressSpace; +/// Flags for svcCreateProcess and CreateProcess event +using ::CreateProcessFlags; +/// Console debug devices supported by libnx. +using ::debugDevice; +/// DebugEvent flags +using ::DebugEventFlag; +/// DebugEvent structure +using ::DebugEventInfo; +/// DebugEvent types +using ::DebugEventType; +/// Debug exception types +using ::DebugException; +/// Debug Thread Parameters. +using ::DebugThreadParam; +/// ApplicationErrorArg +using ::ErrorApplicationArg; +/// Error application config. +using ::ErrorApplicationConfig; +/// Stores error-codes which are displayed as XXXX-XXXX, low for the former and desc for the latter. +using ::ErrorCode; +/// Common error arg data. +using ::ErrorCommonArg; +/// Common header for the start of the arg storage. +using ::ErrorCommonHeader; +/// Error context. +using ::ErrorContext; +/// Error type for ErrorContext.type +using ::ErrorContextType; +/// Error arg data for EULA. +using ::ErrorEulaArg; +/// Additional input storage data for \ref errorSystemUpdateEulaShow. +using ::ErrorEulaData; +/// Error arg data for certain errors with module PCTL. +using ::ErrorPctlArg; +/// Error arg data for Record. +using ::ErrorRecordArg; +/// ResultBacktrace +using ::ErrorResultBacktrace; +/// SystemErrorArg +using ::ErrorSystemArg; +/// Error system config. +using ::ErrorSystemConfig; +/// Error type for ErrorCommonHeader.type. +using ::ErrorType; +/// Kernel-mode event structure. +using ::Event; +using ::FanController; +/// Struct for fatal Cpu context, 32-bit. +using ::FatalAarch32Context; +/// Struct for fatal Cpu context, 64-bit. +using ::FatalAarch64Context; +using ::FatalCpuContext; +/// Type of thrown fatal error. +using ::FatalPolicy; +/// FatFatError +using ::FatFatError; +/// FatFatReportInfo1 +using ::FatFatReportInfo1; +/// FatFatReportInfo2 +using ::FatFatReportInfo2; +/// FatFatSafeInfo +using ::FatFatSafeInfo; +using ::FinalOutputRecorderBuffer; +using ::FinalOutputRecorderParameter; +using ::FinalOutputRecorderParameterInternal; +/// Armv8 NEON register. +using ::FpuRegister; +/// Framebuffer structure. +using ::Framebuffer; +/// FriendInvitationGameModeDescription +using ::FriendsFriendInvitationGameModeDescription; +/// FriendInvitationGroupId +using ::FriendsFriendInvitationGroupId; +/// FriendInvitationId +using ::FriendsFriendInvitationId; +/// InAppScreenName +using ::FriendsInAppScreenName; +/// Arg struct pushed for the applet input storage, for [9.0.0+]. +using ::FriendsLaArg; +/// 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. +using ::FriendsLaArgCommonData; +/// Header for the arg struct. +using ::FriendsLaArgHeader; +/// Arg type values used with \ref FriendsLaArg. +using ::FriendsLaArgType; +/// Arg struct pushed for the applet input storage, for pre-9.0.0. +using ::FriendsLaArgV1; +using ::FriendsServiceType; +/// FriendsUserSetting +using ::FriendsUserSetting; +/// This is nn::fssystem::ArchiveMacKey. Used by \ref setsysGetThemeKey and \ref setsysSetThemeKey. Does not appear to be in use elsewhere. +using ::FsArchiveMacKey; +/// BisPartitionId +using ::FsBisPartitionId; +using ::FsCodeInfo; +/// FsContentAttributes +using ::FsContentAttributes; +using ::FsContentStorageId; +/// For use with fsFsCreateFile. +using ::FsCreateOption; +using ::FsCustomStorageId; +/// Open directory struct +using ::fsdev_dir_t; +using ::FsDeviceOperator; +using ::FsDir; +/// Directory entry. +using ::FsDirectoryEntry; +/// Returned by fsFsGetEntryType. +using ::FsDirEntryType; +/// For use with fsFsOpenDirectory. +using ::FsDirOpenMode; +using ::FsEventNotifier; +using ::FsFile; +using ::FsFileSystem; +/// FileSystemAttribute +using ::FsFileSystemAttribute; +/// FsFileSystemProxyErrorInfo +using ::FsFileSystemProxyErrorInfo; +/// FileSystemQueryId +using ::FsFileSystemQueryId; +/// FileSystemType +using ::FsFileSystemType; +using ::FsGameCardAttribute; +/// FsGameCardErrorReportInfo +using ::FsGameCardErrorReportInfo; +using ::FsGameCardHandle; +using ::FsGameCardPartition; +using ::FsGameCardUpdatePartitionInfo; +/// ImageDirectoryId +using ::FsImageDirectoryId; +/// FsMemoryReportInfo +using ::FsMemoryReportInfo; +/// For use with fsOpenHostFileSystemWithOption +using ::FsMountHostOption; +/// For use with fsFsOpenFile. +using ::FsOpenMode; +using ::FsOperationId; +/// FsPriority +using ::FsPriority; +using ::FsRangeInfo; +/// For use with fsFileRead. +using ::FsReadOption; +using ::FsRightsId; +/// SaveDataAttribute +using ::FsSaveDataAttribute; +/// SaveDataCreationInfo +using ::FsSaveDataCreationInfo; +/// SaveDataExtraData +using ::FsSaveDataExtraData; +/// SaveDataFilter +using ::FsSaveDataFilter; +/// SaveDataFlags +using ::FsSaveDataFlags; +/// SaveDataInfo +using ::FsSaveDataInfo; +using ::FsSaveDataInfoReader; +/// SaveDataMetaInfo +using ::FsSaveDataMetaInfo; +/// SaveDataMetaType +using ::FsSaveDataMetaType; +/// SaveDataRank +using ::FsSaveDataRank; +/// SaveDataSpaceId +using ::FsSaveDataSpaceId; +/// SaveDataType +using ::FsSaveDataType; +using ::FsStorage; +/// FsStorageErrorInfo +using ::FsStorageErrorInfo; +using ::FsStorageForBatchRead; +using ::FsTimeStampRaw; +/// For use with fsFileWrite. +using ::FsWriteOption; +using ::GpioDirection; +using ::GpioInterruptMode; +using ::GpioInterruptStatus; +using ::GpioPadName; +using ::GpioPadSession; +using ::GpioValue; +/// GameMovieId +using ::GrcGameMovieId; +/// GameMovieTrimmer +using ::GrcGameMovieTrimmer; +/// IMovieMaker +using ::GrcMovieMaker; +/// OffscreenRecordingParameter +using ::GrcOffscreenRecordingParameter; +/// Stream type values for \ref grcdTransfer. +using ::GrcStream; +///< 128-bit volatile signed integer. +using ::Handle; +/// HidAnalogStickCalibrationStateImpl +using ::HidAnalogStickCalibrationStateImpl; +/// HidAnalogStickCalibrationStateImplAtomicStorage +using ::HidAnalogStickCalibrationStateImplAtomicStorage; +/// HidAnalogStickCalibrationStateImplLifo +using ::HidAnalogStickCalibrationStateImplLifo; +/// HidAnalogStickState +using ::HidAnalogStickState; +/// AppletFooterUiType (system) +using ::HidAppletFooterUiType; +/// HidBasicXpadLifo +using ::HidBasicXpadLifo; +/// HidBasicXpadSharedMemoryEntry +using ::HidBasicXpadSharedMemoryEntry; +/// HidBasicXpadSharedMemoryFormat +using ::HidBasicXpadSharedMemoryFormat; +/// HidBasicXpadState +using ::HidBasicXpadState; +/// HidBasicXpadStateAtomicStorage +using ::HidBasicXpadStateAtomicStorage; +/// BusHandle +using ::HidbusBusHandle; +/// BusType +using ::HidbusBusType; +/// HidbusDataAccessorHeader +using ::HidbusDataAccessorHeader; +/// HidbusJoyButtonOnlyPollingDataAccessor +using ::HidbusJoyButtonOnlyPollingDataAccessor; +/// HidbusJoyButtonOnlyPollingDataAccessorEntry +using ::HidbusJoyButtonOnlyPollingDataAccessorEntry; +/// HidbusJoyButtonOnlyPollingDataAccessorEntryData +using ::HidbusJoyButtonOnlyPollingDataAccessorEntryData; +/// HidbusJoyDisableSixAxisPollingDataAccessor +using ::HidbusJoyDisableSixAxisPollingDataAccessor; +/// HidbusJoyDisableSixAxisPollingDataAccessorEntry +using ::HidbusJoyDisableSixAxisPollingDataAccessorEntry; +/// HidbusJoyDisableSixAxisPollingDataAccessorEntryData +using ::HidbusJoyDisableSixAxisPollingDataAccessorEntryData; +/// HidbusJoyEnableSixAxisPollingDataAccessor +using ::HidbusJoyEnableSixAxisPollingDataAccessor; +/// HidbusJoyEnableSixAxisPollingDataAccessorEntry +using ::HidbusJoyEnableSixAxisPollingDataAccessorEntry; +/// HidbusJoyEnableSixAxisPollingDataAccessorEntryData +using ::HidbusJoyEnableSixAxisPollingDataAccessorEntryData; +/// JoyPollingMode +using ::HidbusJoyPollingMode; +/// JoyPollingReceivedData +using ::HidbusJoyPollingReceivedData; +/// StatusManager +using ::HidbusStatusManager; +/// HidbusStatusManagerEntry +using ::HidbusStatusManagerEntry; +/// Common data for HidbusStatusManagerEntry*. +using ::HidbusStatusManagerEntryCommon; +/// HidbusStatusManagerEntry on 5.x. +using ::HidbusStatusManagerEntryV5; +/// StatusManager on 5.x. +using ::HidbusStatusManagerV5; +/// HidCaptureButtonLifo +using ::HidCaptureButtonLifo; +/// HidCaptureButtonSharedMemoryFormat +using ::HidCaptureButtonSharedMemoryFormat; +/// HidCaptureButtonState +using ::HidCaptureButtonState; +/// HidCaptureButtonStateAtomicStorage +using ::HidCaptureButtonStateAtomicStorage; +/// AnalogStickAssignment +using ::HidcfgAnalogStickAssignment; +/// AnalogStickRotation +using ::HidcfgAnalogStickRotation; +/// ButtonConfigEmbedded +using ::HidcfgButtonConfigEmbedded; +/// ButtonConfigFull +using ::HidcfgButtonConfigFull; +/// ButtonConfigLeft +using ::HidcfgButtonConfigLeft; +/// ButtonConfigRight +using ::HidcfgButtonConfigRight; +/// Selects what button to map to. +using ::HidcfgDigitalButtonAssignment; +/// StorageName +using ::HidcfgStorageName; +/// HidColorAttribute +using ::HidColorAttribute; +/// HidCommonLifoHeader +using ::HidCommonLifoHeader; +/// HidConsoleSixAxisSensor +using ::HidConsoleSixAxisSensor; +/// AbstractedPadHandle +using ::HiddbgAbstractedPadHandle; +/// AbstractedPadState +using ::HiddbgAbstractedPadState; +/// State for overriding \ref HidDebugPadState. +using ::HiddbgDebugPadAutoPilotState; +/// HdlsAttribute +using ::HiddbgHdlsAttribute; +/// HdlsDeviceInfo, for [9.0.0+]. Converted to/from \ref HiddbgHdlsDeviceInfoV7 on prior sysvers. +using ::HiddbgHdlsDeviceInfo; +/// HdlsDeviceInfo, for [7.0.0-8.1.0]. +using ::HiddbgHdlsDeviceInfoV7; +/// HdlsHandle +using ::HiddbgHdlsHandle; +/// HdlsNpadAssignment. Same controllers as \ref HiddbgHdlsStateList, with different entry data. +using ::HiddbgHdlsNpadAssignment; +/// HdlsNpadAssignmentEntry +using ::HiddbgHdlsNpadAssignmentEntry; +/// HdlsSessionId, returned by \ref hiddbgAttachHdlsWorkBuffer. +using ::HiddbgHdlsSessionId; +/// HdlsState, for [12.0.0+]. +using ::HiddbgHdlsState; +/// HdlsStateList, for [12.0.0+]. +/// This contains a list of all controllers, including non-virtual controllers. +using ::HiddbgHdlsStateList; +/// HdlsStateListEntry, for [12.0.0+]. +using ::HiddbgHdlsStateListEntry; +/// HdlsStateListEntryV7, for [7.0.0-8.1.0]. +using ::HiddbgHdlsStateListEntryV7; +/// HdlsStateListEntry, for [9.0.0-11.0.1]. +using ::HiddbgHdlsStateListEntryV9; +/// HdlsStateListV7, for [7.0.0-8.1.0]. This contains a list of all controllers, including non-virtual controllers. +using ::HiddbgHdlsStateListV7; +/// HdlsStateList, for [9.0.0-11.0.1]. +using ::HiddbgHdlsStateListV9; +/// HdlsState, for [7.0.0-8.1.0]. +using ::HiddbgHdlsStateV7; +/// HdlsState, for [9.0.0-11.0.1]. +using ::HiddbgHdlsStateV9; +/// State for overriding \ref HidKeyboardState. +using ::HiddbgKeyboardAutoPilotState; +/// State for overriding \ref HidMouseState. +using ::HiddbgMouseAutoPilotState; +/// HiddbgNpadButton. For the remaining buttons, see \ref HidNpadButton. +using ::HiddbgNpadButton; +/// State for overriding SleepButtonState. +using ::HiddbgSleepButtonAutoPilotState; +/// HidDebugPadAttribute +using ::HidDebugPadAttribute; +/// HidDebugPadButton +using ::HidDebugPadButton; +/// HidDebugPadLifo +using ::HidDebugPadLifo; +/// HidDebugPadSharedMemoryFormat +using ::HidDebugPadSharedMemoryFormat; +/// HidDebugPadState +using ::HidDebugPadState; +/// HidDebugPadStateAtomicStorage +using ::HidDebugPadStateAtomicStorage; +/// Internal DeviceType for [9.0.0+]. Converted to/from the pre-9.0.0 version of this by the hiddbg funcs. +using ::HidDeviceType; +/// DeviceType (system) +using ::HidDeviceTypeBits; +/// HidDigitizerLifo +using ::HidDigitizerLifo; +/// HidDigitizerSharedMemoryFormat +using ::HidDigitizerSharedMemoryFormat; +/// HidDigitizerState +using ::HidDigitizerState; +/// HidDigitizerStateAtomicStorage +using ::HidDigitizerStateAtomicStorage; +/// HidDirectionState +using ::HidDirectionState; +/// HidGestureAttribute +using ::HidGestureAttribute; +/// HidGestureDirection +using ::HidGestureDirection; +/// HidGestureDummyStateAtomicStorage +using ::HidGestureDummyStateAtomicStorage; +/// HidGestureLifo +using ::HidGestureLifo; +/// HidGesturePoint +using ::HidGesturePoint; +/// HidGestureSharedMemoryFormat +using ::HidGestureSharedMemoryFormat; +/// HidGestureState +using ::HidGestureState; +/// HidGestureType +using ::HidGestureType; +/// GyroscopeZeroDriftMode +using ::HidGyroscopeZeroDriftMode; +/// HidHomeButtonLifo +using ::HidHomeButtonLifo; +/// HidHomeButtonSharedMemoryFormat +using ::HidHomeButtonSharedMemoryFormat; +/// HidHomeButtonState +using ::HidHomeButtonState; +/// HidHomeButtonStateAtomicStorage +using ::HidHomeButtonStateAtomicStorage; +/// HidInputDetectorLifo +using ::HidInputDetectorLifo; +/// HidInputDetectorSharedMemoryEntry +using ::HidInputDetectorSharedMemoryEntry; +/// HidInputDetectorSharedMemoryFormat +using ::HidInputDetectorSharedMemoryFormat; +/// HidInputDetectorState +using ::HidInputDetectorState; +/// HidInputDetectorStateAtomicStorage +using ::HidInputDetectorStateAtomicStorage; +/// HidKeyboardKey +using ::HidKeyboardKey; +/// HidKeyboardLifo +using ::HidKeyboardLifo; +/// KeyboardLockKeyEvent +using ::HidKeyboardLockKeyEvent; +/// HidKeyboardModifier +using ::HidKeyboardModifier; +/// HidKeyboardSharedMemoryFormat +using ::HidKeyboardSharedMemoryFormat; +/// HidKeyboardState +using ::HidKeyboardState; +/// HidKeyboardStateAtomicStorage +using ::HidKeyboardStateAtomicStorage; +/// ControllerFirmwareUpdateArg +using ::HidLaControllerFirmwareUpdateArg; +/// ControllerKeyRemappingArg +using ::HidLaControllerKeyRemappingArg; +/// ControllerSupportArg for [8.0.0+], converted to \ref HidLaControllerSupportArgV3 on pre-8.0.0. +using ::HidLaControllerSupportArg; +/// Identification color used by HidLaControllerSupportArg*. When HidLaControllerSupportArgHeader::enable_identification_color is set this controls the color of the UI player box outline. +using ::HidLaControllerSupportArgColor; +/// 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. +using ::HidLaControllerSupportArgHeader; +/// ControllerSupportArgPrivate +using ::HidLaControllerSupportArgPrivate; +/// ControllerSupportArg for [1.0.0+]. +using ::HidLaControllerSupportArgV3; +/// ControllerSupportCaller +using ::HidLaControllerSupportCaller; +/// Mode values for HidLaControllerSupportArgPrivate::mode. +using ::HidLaControllerSupportMode; +/// ControllerSupportResultInfo. First 8-bytes from the applet output storage. +using ::HidLaControllerSupportResultInfo; +/// Struct for the applet output storage. +using ::HidLaControllerSupportResultInfoInternal; +/// HidMouseAttribute +using ::HidMouseAttribute; +/// HidMouseButton +using ::HidMouseButton; +/// HidMouseLifo +using ::HidMouseLifo; +/// HidMouseSharedMemoryFormat +using ::HidMouseSharedMemoryFormat; +/// HidMouseState +using ::HidMouseState; +/// HidMouseStateAtomicStorage +using ::HidMouseStateAtomicStorage; +/// HidNfcXcdDeviceHandleState +using ::HidNfcXcdDeviceHandleState; +/// HidNfcXcdDeviceHandleStateImpl +using ::HidNfcXcdDeviceHandleStateImpl; +/// HidNfcXcdDeviceHandleStateImplAtomicStorage +using ::HidNfcXcdDeviceHandleStateImplAtomicStorage; +/// HidNpadAttribute +using ::HidNpadAttribute; +/// HidNpadButton +using ::HidNpadButton; +/// HidNpadCommonLifo +using ::HidNpadCommonLifo; +/// HidNpadCommonState +using ::HidNpadCommonState; +///< State for ::HidNpadStyleTag_NpadSystem. Analog-sticks state are always zero. Only the following button bits are available: HidNpadButton_A, HidNpadButton_B, HidNpadButton_X, HidNpadButton_Y, HidNpadButton_Left, HidNpadButton_Up, HidNpadButton_Right, HidNpadButton_Down, HidNpadButton_L, HidNpadButton_R. +/// HidNpadCommonStateAtomicStorage +using ::HidNpadCommonStateAtomicStorage; +/// NpadCommunicationMode +using ::HidNpadCommunicationMode; +/// Npad colors. +/// Color fields are zero when not set. +using ::HidNpadControllerColor; +/// HidNpadFullKeyColorState +using ::HidNpadFullKeyColorState; +using ::HidNpadFullKeyState; +///< State for ::HidNpadStyleTag_NpadJoyRight. +/// State for ::HidNpadStyleTag_NpadGc. Loaded from the same lifo as \ref HidNpadFullKeyState, with the additional trigger_l/trigger_r loaded from elsewhere. +using ::HidNpadGcState; +/// HidNpadGcTriggerLifo +using ::HidNpadGcTriggerLifo; +/// HidNpadGcTriggerState +using ::HidNpadGcTriggerState; +/// HidNpadGcTriggerStateAtomicStorage +using ::HidNpadGcTriggerStateAtomicStorage; +/// This controls how many Joy-Cons must be attached for handheld-mode to be activated. +using ::HidNpadHandheldActivationMode; +/// State for ::HidNpadStyleTag_NpadHandheldLark. The base state is loaded from the same lifo as \ref HidNpadHandheldState. +using ::HidNpadHandheldLarkState; +///< State for ::HidNpadStyleTag_NpadFullKey. +using ::HidNpadHandheldState; +/// HID controller IDs +using ::HidNpadIdType; +/// NpadInterfaceType (system) +using ::HidNpadInterfaceType; +/// HidNpadInternalState +using ::HidNpadInternalState; +/// NpadJoyAssignmentMode +using ::HidNpadJoyAssignmentMode; +/// HidNpadJoyColorState +using ::HidNpadJoyColorState; +/// NpadJoyDeviceType +using ::HidNpadJoyDeviceType; +///< State for ::HidNpadStyleTag_NpadHandheld. +using ::HidNpadJoyDualState; +/// NpadJoyHoldType +using ::HidNpadJoyHoldType; +///< State for ::HidNpadStyleTag_NpadJoyDual. +using ::HidNpadJoyLeftState; +///< State for ::HidNpadStyleTag_NpadJoyLeft. +using ::HidNpadJoyRightState; +using ::HidNpadLagerState; +/// NpadLagerType +using ::HidNpadLagerType; +///< State for ::HidNpadStyleTag_NpadPalma. +/// State for ::HidNpadStyleTag_NpadLark. The base state is loaded from the same lifo as \ref HidNpadFullKeyState. +using ::HidNpadLarkState; +/// NpadLarkType +using ::HidNpadLarkType; +/// State for ::HidNpadStyleTag_NpadLucia. The base state is loaded from the same lifo as \ref HidNpadFullKeyState. +using ::HidNpadLuciaState; +/// NpadLuciaType +using ::HidNpadLuciaType; +using ::HidNpadPalmaState; +/// HidNpadSharedMemoryEntry +using ::HidNpadSharedMemoryEntry; +/// HidNpadSharedMemoryFormat +using ::HidNpadSharedMemoryFormat; +/// HidNpadSixAxisSensorLifo +using ::HidNpadSixAxisSensorLifo; +/// HID controller styles +using ::HidNpadStyleTag; +/// NpadSystemButtonProperties +using ::HidNpadSystemButtonProperties; +///< State for ::HidNpadStyleTag_NpadLager. Analog-sticks state are always zero. +using ::HidNpadSystemExtState; +/// NpadSystemProperties +using ::HidNpadSystemProperties; +///< State for ::HidNpadStyleTag_NpadSystemExt. +using ::HidNpadSystemState; +/// PalmaActivityEntry +using ::HidPalmaActivityEntry; +/// PalmaApplicationSectionAccessBuffer +using ::HidPalmaApplicationSectionAccessBuffer; +/// PalmaConnectionHandle +using ::HidPalmaConnectionHandle; +/// PalmaFeature +using ::HidPalmaFeature; +/// PalmaFrModeType +using ::HidPalmaFrModeType; +/// PalmaOperationInfo +using ::HidPalmaOperationInfo; +/// PalmaOperationType +using ::HidPalmaOperationType; +/// PalmaWaveSet +using ::HidPalmaWaveSet; +/// HidPowerInfo (system) +using ::HidPowerInfo; +/// HidSevenSixAxisSensorState +using ::HidSevenSixAxisSensorState; +/// HidSevenSixAxisSensorStateEntry +using ::HidSevenSixAxisSensorStateEntry; +/// HidSevenSixAxisSensorStates +using ::HidSevenSixAxisSensorStates; +/// HidSharedMemory +using ::HidSharedMemory; +/// HidSixAxisSensorAttribute +using ::HidSixAxisSensorAttribute; +/// HidSixAxisSensorHandle +using ::HidSixAxisSensorHandle; +/// HidSixAxisSensorState +using ::HidSixAxisSensorState; +/// HidSixAxisSensorStateAtomicStorage +using ::HidSixAxisSensorStateAtomicStorage; +/// HidSixAxisSensorUserCalibrationState +using ::HidSixAxisSensorUserCalibrationState; +/// HidSixAxisSensorUserCalibrationStateAtomicStorage +using ::HidSixAxisSensorUserCalibrationStateAtomicStorage; +/// HidSixAxisSensorUserCalibrationStateLifo +using ::HidSixAxisSensorUserCalibrationStateLifo; +/// HidSleepButtonLifo +using ::HidSleepButtonLifo; +/// HidSleepButtonSharedMemoryFormat +using ::HidSleepButtonSharedMemoryFormat; +/// HidSleepButtonState +using ::HidSleepButtonState; +/// HidSleepButtonStateAtomicStorage +using ::HidSleepButtonStateAtomicStorage; +/// ButtonConfigEmbedded +using ::HidsysButtonConfigEmbedded; +/// ButtonConfigFull +using ::HidsysButtonConfigFull; +/// ButtonConfigLeft +using ::HidsysButtonConfigLeft; +/// ButtonConfigRight +using ::HidsysButtonConfigRight; +/// Structure for \ref hidsysSetNotificationLedPattern. +/// See also: https://switchbrew.org/wiki/HID_services#NotificationLedPattern +/// Only the low 4bits of each used byte in this struct is used. +using ::HidsysNotificationLedPattern; +/// Mini Cycle struct for \ref HidsysNotificationLedPattern. +using ::HidsysNotificationLedPatternCycle; +/// UniquePadId for a controller. +using ::HidsysUniquePadId; +/// UniquePadSerialNumber +using ::HidsysUniquePadSerialNumber; +/// UniquePadType +using ::HidsysUniquePadType; +/// HidTouchAttribute +using ::HidTouchAttribute; +/// HidTouchScreenConfigurationForNx +using ::HidTouchScreenConfigurationForNx; +/// HidTouchScreenLifo +using ::HidTouchScreenLifo; +/// HidTouchScreenModeForNx +using ::HidTouchScreenModeForNx; +/// HidTouchScreenSharedMemoryFormat +using ::HidTouchScreenSharedMemoryFormat; +/// HidTouchScreenState +using ::HidTouchScreenState; +/// HidTouchScreenStateAtomicStorage +using ::HidTouchScreenStateAtomicStorage; +/// HidTouchState +using ::HidTouchState; +/// HidUniquePadConfig +using ::HidUniquePadConfig; +/// HidUniquePadConfigAtomicStorage +using ::HidUniquePadConfigAtomicStorage; +/// HidUniquePadConfigLifo +using ::HidUniquePadConfigLifo; +/// HidUniquePadConfigMutex +using ::HidUniquePadConfigMutex; +/// HidUniquePadLifo +using ::HidUniquePadLifo; +/// HidUniquePadSharedMemoryEntry +using ::HidUniquePadSharedMemoryEntry; +/// HidUniquePadSharedMemoryFormat +using ::HidUniquePadSharedMemoryFormat; +/// HidVector +using ::HidVector; +/// HidVibrationDeviceHandle +using ::HidVibrationDeviceHandle; +/// HidVibrationDeviceInfo +using ::HidVibrationDeviceInfo; +/// VibrationDevicePosition +using ::HidVibrationDevicePosition; +/// Type values for HidVibrationDeviceInfo::type. +using ::HidVibrationDeviceType; +/// VibrationGcErmCommand +using ::HidVibrationGcErmCommand; +/// HidVibrationValue +using ::HidVibrationValue; +using ::HipcBufferDescriptor; +using ::HipcBufferMode; +using ::HipcHeader; +using ::HipcMetadata; +using ::HipcParsedRequest; +using ::HipcRecvListEntry; +using ::HipcRequest; +using ::HipcResponse; +using ::HipcSpecialHeader; +using ::HipcStaticDescriptor; +/// Context for HMAC-SHA1 operations. +using ::HmacSha1Context; +/// Context for HMAC-SHA256 operations. +using ::HmacSha256Context; +using ::HwopusDecoder; +/// This structure is the start of opusin for \ref hwopusDecodeInterleaved, with the actual opus packet following this. +/// These fields are big-endian. +using ::HwopusHeader; +/// Used internally. +using ::HwopusMultistreamState; +using ::I2cDevice; +using ::I2cSession; +using ::I2cTransactionOption; +using ::in_addr; +/// GetInfo IDs. +using ::InfoType; +/// GetInfo InitialProcessIdRange Sub IDs. +using ::InitialProcessIdRangeInfo; +/// Io Pools. +using ::IoPoolType; +using ::iova_t; +/// AdaptiveClusteringMode +using ::IrsAdaptiveClusteringMode; +/// AdaptiveClusteringProcessorConfig +using ::IrsAdaptiveClusteringProcessorConfig; +/// AdaptiveClusteringTargetDistance +using ::IrsAdaptiveClusteringTargetDistance; +/// AruidFormat +using ::IrsAruidFormat; +/// ClusteringData +using ::IrsClusteringData; +/// ClusteringProcessorConfig +using ::IrsClusteringProcessorConfig; +/// ClusteringProcessorState +using ::IrsClusteringProcessorState; +/// DeviceFormat +using ::IrsDeviceFormat; +/// HandAnalysisConfig +using ::IrsHandAnalysisConfig; +/// HandAnalysisMode +using ::IrsHandAnalysisMode; +/// ImageProcessorStatus +using ::IrsImageProcessorStatus; +/// ImageTransferProcessorConfig +using ::IrsImageTransferProcessorConfig; +/// ImageTransferProcessorExConfig +using ::IrsImageTransferProcessorExConfig; +/// ImageTransferProcessorFormat. IR Sensor image resolution. +using ::IrsImageTransferProcessorFormat; +/// ImageTransferProcessorState +using ::IrsImageTransferProcessorState; +/// IrCameraHandle +using ::IrsIrCameraHandle; +/// IrCameraInternalStatus +using ::IrsIrCameraInternalStatus; +/// IrCameraStatus +using ::IrsIrCameraStatus; +/// IrLedProcessorConfig +using ::IrsIrLedProcessorConfig; +/// IrSensorMode +using ::IrsIrSensorMode; +/// IrsMomentProcessorConfig +using ::IrsMomentProcessorConfig; +/// MomentProcessorState +using ::IrsMomentProcessorState; +/// MomentStatistic +using ::IrsMomentStatistic; +/// PackedClusteringProcessorConfig +using ::IrsPackedClusteringProcessorConfig; +/// PackedFunctionLevel +using ::IrsPackedFunctionLevel; +/// PackedImageTransferProcessorConfig +using ::IrsPackedImageTransferProcessorConfig; +/// PackedImageTransferProcessorExConfig +using ::IrsPackedImageTransferProcessorExConfig; +/// PackedIrLedProcessorConfig +using ::IrsPackedIrLedProcessorConfig; +/// PackedMcuVersion +using ::IrsPackedMcuVersion; +/// PackedMomentProcessorConfig +using ::IrsPackedMomentProcessorConfig; +/// PackedPointingProcessorConfig +using ::IrsPackedPointingProcessorConfig; +/// PackedTeraPluginProcessorConfig +using ::IrsPackedTeraPluginProcessorConfig; +/// PointingProcessorMarkerState +using ::IrsPointingProcessorMarkerState; +/// PointingProcessorState +using ::IrsPointingProcessorState; +/// ProcessorState +using ::IrsProcessorState; +/// Rect +using ::IrsRect; +/// StatusManager +using ::IrsStatusManager; +/// TeraPluginProcessorConfig +using ::IrsTeraPluginProcessorConfig; +/// TeraPluginProcessorState +using ::IrsTeraPluginProcessorState; +/// Internal validation callblack. +using ::IrsValidationCb; +/// JIT buffer object. +using ::Jit; +/// JIT implementation type. +using ::JitType; +/// Context of a scheduled thread. +using ::LastThreadContext; +using ::LblBacklightSwitchStatus; +/// AcceptPolicy +using ::LdnAcceptPolicy; +/// ActionFrameSettings +using ::LdnActionFrameSettings; +/// AddressEntry +using ::LdnAddressEntry; +/// CommonNetworkInfo +using ::LdnCommonNetworkInfo; +/// DisconnectReason loaded by \ref ldnGetDisconnectReason. +using ::LdnDisconnectReason; +/// IntentId +using ::LdnIntentId; +/// Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). +using ::LdnIpv4Address; +/// MacAddress +using ::LdnMacAddress; +/// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate). +using ::LdnNetworkConfig; +/// NetworkId +using ::LdnNetworkId; +/// NetworkInfo +using ::LdnNetworkInfo; +/// NodeInfo +using ::LdnNodeInfo; +/// NodeLatestUpdate +using ::LdnNodeLatestUpdate; +/// OperationMode +using ::LdnOperationMode; +/// Protocol +using ::LdnProtocol; +/// ScanFilter. \ref ldnScan / \ref ldnScanPrivate will only return the \ref LdnNetworkInfo when validating the \ref LdnNetworkInfo with LdnScanFilter was sucessful, with the fields enabled by \ref LdnScanFilterFlag. +using ::LdnScanFilter; +/// ScanFilterFlag +using ::LdnScanFilterFlag; +/// SecurityConfig +using ::LdnSecurityConfig; +/// SecurityMode. LdnSecurityMode_Product can be used as the default value. The ldn cmds which use an input SecurityMode normally overwrite the SecurityMode. +using ::LdnSecurityMode; +/// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated. +using ::LdnSecurityParameter; +using ::LdnServiceType; +/// SessionId +using ::LdnSessionId; +/// Ssid +using ::LdnSsid; +/// State loaded by \ref ldnmGetStateForMonitor / \ref ldnGetState. +using ::LdnState; +/// SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). +using ::LdnSubnetMask; +/// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd. +using ::LdnUserConfig; +/// WirelessControllerRestriction +using ::LdnWirelessControllerRestriction; +/// User-mode light event structure. +using ::LEvent; +/// CommonArguments +using ::LibAppletArgs; +/// LibraryAppletExitReason +using ::LibAppletExitReason; +/// LibraryAppletInfo +using ::LibAppletInfo; +/// LibraryAppletMode +using ::LibAppletMode; +/// Limitable Resources. +using ::LimitableResource; +using ::LoaderModuleInfo; +using ::LoaderProgramAttributes; +using ::LoaderProgramInfo; +using ::LoaderProgramInfoV1; +/// Loader return function. +using ::LoaderReturnFn; +/// GroupId +using ::Lp2pGroupId; +/// GroupInfo +/// \ref lp2pScan only uses the following fields for the cmd input struct: supported_platform/priority, frequency/channel, and preshared_key_binary_size/preshared_key. +using ::Lp2pGroupInfo; +/// IpConfig. Only contains IPv4 addresses. +using ::Lp2pIpConfig; +/// MacAddress +using ::Lp2pMacAddress; +/// NodeInfo +using ::Lp2pNodeInfo; +/// ScanResult +using ::Lp2pScanResult; +using ::Lp2pServiceType; +using ::LrLocationResolver; +using ::LrRegisteredLocationResolver; +/// Memory attribute bitmasks. +using ::MemoryAttribute; +/// Memory information structure. +using ::MemoryInfo; +/// Memory mapping type. +using ::MemoryMapping; +/// Memory regions +using ::MemoryRegion; +/// Memory state bitmasks. +using ::MemoryState; +/// Memory type enumeration (lower 8 bits of \ref MemoryState) +using ::MemoryType; +/// Mii age. +using ::MiiAge; +using ::MiiCharInfo; +using ::MiiCreateId; +using ::MiiDatabase; +/// Mii face color. +using ::MiiFaceColor; +/// Mii gender. +using ::MiiGender; +/// Image attribute. +using ::MiiimgImageAttribute; +/// Image ID. +using ::MiiimgImageId; +/// AppletInput +using ::MiiLaAppletInput; +/// AppletMode +using ::MiiLaAppletMode; +/// AppletOutput +using ::MiiLaAppletOutput; +/// AppletOutputForCharInfoEditing +using ::MiiLaAppletOutputForCharInfoEditing; +using ::MiiNfpStoreDataExtension; +using ::MiiServiceType; +using ::MiiSourceFlag; +using ::MiiSpecialKeyCode; +using ::MiiStoreData; +using ::MiiVer3StoreData; +using ::MmuModuleId; +using ::MmuRequest; +/// Mutex datatype, defined in newlib. +using ::Mutex; +/// ApplicationControlDataCondition +using ::NacpApplicationControlDataCondition; +/// ApplicationJitConfiguration +using ::NacpApplicationJitConfiguration; +/// ApplicationNeighborDetectionGroupConfiguration +using ::NacpApplicationNeighborDetectionGroupConfiguration; +/// Language entry. These strings are UTF-8. +using ::NacpLanguageEntry; +using ::NacpLanguageEntryData; +/// NeighborDetectionClientConfiguration +using ::NacpNeighborDetectionClientConfiguration; +/// ns ApplicationControlProperty +using ::NacpStruct; +using ::NativeHandle; +/// AddOnContentMetaExtendedHeader [15.0.0+] +using ::NcmAddOnContentMetaExtendedHeader; +/// ApplicationContentMetaKey +using ::NcmApplicationContentMetaKey; +/// ApplicationMetaExtendedHeader +using ::NcmApplicationMetaExtendedHeader; +/// ContentId +using ::NcmContentId; +/// ContentInfo +using ::NcmContentInfo; +/// ContentInstallType +using ::NcmContentInstallType; +/// ContentMetaAttribute +using ::NcmContentMetaAttribute; +/// ContentMetaDatabase +using ::NcmContentMetaDatabase; +/// ContentMetaHeader +using ::NcmContentMetaHeader; +/// ContentMetaInfo +using ::NcmContentMetaInfo; +/// ContentMetaKey +using ::NcmContentMetaKey; +/// ContentMetaPlatform +using ::NcmContentMetaPlatform; +/// ContentMetaType +using ::NcmContentMetaType; +/// ContentStorage +using ::NcmContentStorage; +/// ContentType +using ::NcmContentType; +/// DataPatchMetaExtendedHeader +using ::NcmDataPatchMetaExtendedHeader; +/// LegacyAddOnContentMetaExtendedHeader [1.0.0-14.1.2] +using ::NcmLegacyAddOnContentMetaExtendedHeader; +/// PackagedContentInfo +using ::NcmPackagedContentInfo; +/// PatchMetaExtendedHeader +using ::NcmPatchMetaExtendedHeader; +/// PlaceHolderId +using ::NcmPlaceHolderId; +/// ProgramLocation +using ::NcmProgramLocation; +/// RightsId +using ::NcmRightsId; +/// StorageId +using ::NcmStorageId; +/// SystemUpdateMetaExtendedHeader +using ::NcmSystemUpdateMetaExtendedHeader; +using ::NewsDatabaseService; +using ::NewsDataService; +using ::NewsNewlyArrivedEventHolder; +using ::NewsOverwriteEventHolder; +using ::NewsRecord; +using ::NewsRecordV1; +using ::NewsServiceType; +using ::NewsTopicName; +/// Nfc/Nfp DeviceHandle +using ::NfcDeviceHandle; +using ::NfcDeviceState; +using ::NfcMifareCommand; +using ::NfcMifareDeviceState; +using ::NfcMifareReadBlockData; +using ::NfcMifareReadBlockParameter; +using ::NfcMifareWriteBlockParameter; +using ::NfcProtocol; +using ::NfcRequiredMcuVersionData; +using ::NfcSectorKey; +/// NfcServiceType +using ::NfcServiceType; +using ::NfcState; +using ::NfcTagInfo; +using ::NfcTagType; +using ::NfcTagUid; +using ::NfpAdminInfo; +using ::NfpAmiiboFlag; +using ::NfpApplicationAreaVersion; +using ::NfpBreakType; +using ::NfpCommonInfo; +using ::NfpData; +using ::NfpDate; +using ::NfpDeviceState; +using ::NfpDeviceType; +/// AmiiboSettingsStartParam +using ::NfpLaAmiiboSettingsStartParam; +/// ReturnValueForAmiiboSettings +using ::NfpLaReturnValueForAmiiboSettings; +/// StartParamForAmiiboSettings +using ::NfpLaStartParamForAmiiboSettings; +/// Values for NfpLaStartParamForAmiiboSettings::type. +using ::NfpLaStartParamTypeForAmiiboSettings; +using ::NfpModelInfo; +using ::NfpMountTarget; +using ::NfpRegisterInfo; +using ::NfpRegisterInfoPrivate; +/// NfpServiceType +using ::NfpServiceType; +using ::NfpTagInfo; +/// Authentication +using ::NifmAuthentication; +/// ClientId +using ::NifmClientId; +/// DnsSetting +using ::NifmDnsSetting; +/// Encryption +using ::NifmEncryption; +using ::NifmInternetConnectionStatus; +using ::NifmInternetConnectionType; +/// IpAddressSetting +using ::NifmIpAddressSetting; +/// IpSettingData +using ::NifmIpSettingData; +/// IpV4Address +using ::NifmIpV4Address; +/// NetworkProfileBasicInfo. Converted from/to \ref NifmSfNetworkProfileBasicInfo. +using ::NifmNetworkProfileBasicInfo; +/// NetworkProfileData. Converted from/to \ref NifmSfNetworkProfileData. +using ::NifmNetworkProfileData; +using ::NifmNetworkProfileType; +/// ProxySetting +using ::NifmProxySetting; +/// Request +using ::NifmRequest; +using ::NifmRequestState; +using ::NifmServiceType; +/// SfNetworkProfileBasicInfo. Converted from/to \ref NifmNetworkProfileBasicInfo. +using ::NifmSfNetworkProfileBasicInfo; +/// SfNetworkProfileData. Converted to/from \ref NifmNetworkProfileData. +using ::NifmSfNetworkProfileData; +/// SfWirelessSettingData +using ::NifmSfWirelessSettingData; +/// WirelessSettingData +using ::NifmWirelessSettingData; +/// SystemUpdateTaskId +using ::NimSystemUpdateTaskId; +/// AlarmSetting +using ::NotifAlarmSetting; +/// Data extracted from NotifWeeklyScheduleAlarmSetting::settings. This uses local-time. +using ::NotifAlarmTime; +/// ServiceType for \ref notifInitialize. +using ::NotifServiceType; +/// WeeklyScheduleAlarmSetting +using ::NotifWeeklyScheduleAlarmSetting; +/// Custom asset header. +using ::NroAssetHeader; +/// Custom asset section. +using ::NroAssetSection; +/// This follows NroStart, the actual nro-header. +using ::NroHeader; +/// Entry for each segment in the codebin. +using ::NroSegment; +/// Offset 0x0 in the NRO. +using ::NroStart; +/// NsApplicationContentMetaStatus +using ::NsApplicationContentMetaStatus; +/// ApplicationControlData +using ::NsApplicationControlData; +/// ApplicationControlSource +using ::NsApplicationControlSource; +/// ApplicationDeliveryInfo +using ::NsApplicationDeliveryInfo; +/// ApplicationOccupiedSize +using ::NsApplicationOccupiedSize; +/// ApplicationRecord +using ::NsApplicationRecord; +/// NsApplicationRightsOnClient +using ::NsApplicationRightsOnClient; +/// ApplicationView +using ::NsApplicationView; +/// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions. +using ::NsApplicationViewDeprecated; +/// NsApplicationViewWithPromotionInfo +using ::NsApplicationViewWithPromotionInfo; +/// BackgroundNetworkUpdateState +using ::NsBackgroundNetworkUpdateState; +/// DownloadTaskStatus +using ::NsDownloadTaskStatus; +/// EulaDataPath +using ::NsEulaDataPath; +/// LatestSystemUpdate +using ::NsLatestSystemUpdate; +/// LaunchProperties +using ::NsLaunchProperties; +/// ProgressAsyncResult +using ::NsProgressAsyncResult; +/// ProgressForDeleteUserSaveDataAll +using ::NsProgressForDeleteUserSaveDataAll; +/// ProgressMonitorForDeleteUserSaveDataAll +using ::NsProgressMonitorForDeleteUserSaveDataAll; +/// NsPromotionInfo +using ::NsPromotionInfo; +/// ReceiveApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsReceiveApplicationProgress; +/// RequestServerStopper +using ::NsRequestServerStopper; +/// SendApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsSendApplicationProgress; +/// ShellEvent +using ::NsShellEvent; +/// ShellEventInfo +using ::NsShellEventInfo; +/// SystemDeliveryInfo +using ::NsSystemDeliveryInfo; +/// SystemUpdateControl +using ::NsSystemUpdateControl; +/// SystemUpdateProgress. Commands which have this as output will return 0 with the output cleared, when no task is available. +using ::NsSystemUpdateProgress; +using ::NvAddressSpace; +using ::NvAllocSpaceFlags; +using ::NvChannel; +using ::NvChannelPriority; +using ::NvClassNumber; +using ::NvColorFormat; +using ::NvDisplayScanFormat; +using ::NvError; +using ::NvEventId; +using ::NvFence; +using ::NvGpuChannel; +using ::NvGraphicBuffer; +using ::nvioctl_clk_rate; +using ::nvioctl_cmdbuf; +using ::nvioctl_command_buffer_map; +using ::nvioctl_fence; +using ::nvioctl_gpfifo_entry; +using ::nvioctl_gpu_characteristics; +using ::nvioctl_gpu_time; +using ::nvioctl_reloc; +using ::nvioctl_reloc_shift; +using ::nvioctl_syncpt_incr; +using ::nvioctl_va_region; +using ::nvioctl_zbc_entry; +using ::nvioctl_zbc_slot_mask; +using ::nvioctl_zcull_info; +using ::NvKind; +using ::NvLayout; +using ::NvMap; +using ::NvMapBufferFlags; +using ::NvMapParam; +using ::NvMultiFence; +using ::NvNotification; +using ::NvNotificationType; +/// NvServiceType, for __nx_nv_service_type. +using ::NvServiceType; +using ::NvSurface; +using ::NvZcullConfig; +/// Native window structure. +using ::NWindow; +///OperationMode +using ::OmmOperationMode; +///OperationModePolicy +using ::OmmOperationModePolicy; +/// EnqueuePosition +using ::OvlnEnqueuePosition; +/// OverflowOption +using ::OvlnOverflowOption; +/// QueueAttribute +using ::OvlnQueueAttribute; +/// RawMessage +using ::OvlnRawMessage; +/// Receiver +using ::OvlnReceiver; +/// Sender +using ::OvlnSender; +/// SendOption +using ::OvlnSendOption; +/// SourceName +using ::OvlnSourceName; +/// Pad button repeater state object. +using ::PadRepeater; +/// Pad state object. +using ::PadState; +using ::Parcel; +using ::ParcelHeader; +/// PcmFormat +using ::PcmFormat; +/// Input arg storage for the applet. +using ::PctlAuthArg; +/// Type values for PctlAuthArg::type. +using ::PctlAuthType; +using ::PctlRestrictionSettings; +using ::PcvClockRatesListType; +using ::PcvModule; +/// Module id returned by [8.0.0+] pcv services +/// See also: https://switchbrew.org/wiki/PCV_services#Modules +using ::PcvModuleId; +/// AccountEvent. AccountEvent for [16.0.0+], converted from the older structs when needed. +using ::PdmAccountEvent; +/// AccountEventV10. AccountEvent for [10.0.0-15.0.1], converted to \ref PdmAccountEvent when needed. +using ::PdmAccountEventV10; +/// AccountEventV3. AccountEvent for [3.0.0-9.2.0], converted to \ref PdmAccountEvent when needed. +using ::PdmAccountEventV3; +/// AccountPlayEvent. +/// This is the raw entry struct directly read from FS, without any entry filtering. This is separate from \ref PdmPlayEvent. +using ::PdmAccountPlayEvent; +/// AppletEvent. AppletEvent for [16.0.0+], converted from \ref PdmAppletEventV1 on [1.0.0-15.0.1]. +using ::PdmAppletEvent; +/// AppletEventType +using ::PdmAppletEventType; +/// AppletEventV1. AppletEvent for [1.0.0-15.0.1], converted to \ref PdmAppletEvent when needed. +/// Timestamp format, converted from PosixTime: total minutes since epoch UTC 1999/12/31 00:00:00. +/// See \ref pdmPlayTimestampToPosix. +using ::PdmAppletEventV1; +/// ApplicationPlayStatistics +using ::PdmApplicationPlayStatistics; +/// LastPlayTime. +/// This contains data from the last time the application was played. +using ::PdmLastPlayTime; +/// PlayEvent. +/// This is the raw entry struct directly read from FS, without any entry filtering. +using ::PdmPlayEvent; +/// PlayEventType +using ::PdmPlayEventType; +/// PlayLogPolicy +using ::PdmPlayLogPolicy; +/// PlayStatistics. PlayStatistics for [16.0.0+], converted from \ref PdmPlayStatisticsV1 on [1.0.0-15.0.1]. +using ::PdmPlayStatistics; +/// PlayStatisticsV1. PlayStatistics for [1.0.0-15.0.1], converted to \ref PdmPlayStatistics when needed. +using ::PdmPlayStatisticsV1; +/// Memory permission bitmasks. +using ::Permission; +using ::PglEventObserver; +/// LaunchFlag +using ::PglLaunchFlag; +using ::PglProgramLaunchProperty; +/// SnapShotDumpType +using ::PglSnapShotDumpType; +/// Physical memory information structure. +using ::PhysicalMemoryInfo; +/// GetSystemInfo PhysicalMemory Sub IDs. +using ::PhysicalMemorySystemInfo; +/// FontData +using ::PlFontData; +using ::PlServiceType; +/// SharedFontType +using ::PlSharedFontType; +/// BootMode +using ::PmBootMode; +/// LaunchFlag +using ::PmLaunchFlag; +/// ProcessEvent +using ::PmProcessEvent; +/// ProcessEventInfo +using ::PmProcessEventInfo; +/// ResourceLimitValues +using ::PmResourceLimitValues; +using ::PrintConsole; +/// Process Activity. +using ::ProcessActivity; +/// Process exit reasons +using ::ProcessExitReason; +/// Process Information. +using ::ProcessInfoType; +/// Process States. +using ::ProcessState; +using ::PscPmModule; +using ::PscPmModuleId; +using ::PscPmState; +/// NintendoAccountStartupDialogType +using ::PselNintendoAccountStartupDialogType; +/// playerSelect UI modes. +using ::PselUiMode; +/// Return data sent after execution. +using ::PselUiReturnArg; +/// UI settings for versions starting with 0x10000. +using ::PselUiSettings; +/// Base UI settings for playerSelect. +using ::PselUiSettingsV1; +/// UI message text to display with ::PselUiMode_UserSelector. Invalid values are handled as ::PselUserSelectionPurpose_General. +using ::PselUserSelectionPurpose; +/// UserSelectionSettings +using ::PselUserSelectionSettings; +/// [2.0.0+] UserSelectionSettingsForSystemService +using ::PselUserSelectionSettingsForSystemService; +/// BatteryChargeInfoFields [17.0.0+] +using ::PsmBatteryChargeInfoFields; +/// BatteryChargeInfoFieldsOld [1.0.0-16.1.0] +using ::PsmBatteryChargeInfoFieldsOld; +/// BatteryVoltageState +using ::PsmBatteryVoltageState; +/// ChargerType +using ::PsmChargerType; +/// IPsmSession +using ::PsmSession; +/// Vdd50State +using ::PsmVdd50State; +/// Armv8 register group. @ref svcGetThreadContext3 uses @ref RegisterGroup_All. +using ::RegisterGroup; +///< Kernel object handle. +using ::Result; +/// Ring-Con state object. +using ::RingCon; +/// Whether the output data is valid. +using ::RingConDataValid; +using ::RingConErrorFlag; +/// Ring-Con firmware version. +using ::RingConFwVersion; +/// Ring-Con manufacturer calibration. +using ::RingConManuCal; +/// Polling data extracted from \ref HidbusJoyPollingReceivedData. +using ::RingConPollingData; +/// Ring-Con user calibration. +using ::RingConUserCal; +/// Recursive mutex datatype, defined in newlib. +using ::RMutex; +/// RomFS directory. +using ::romfs_dir; +/// RomFS file. +using ::romfs_file; +/// RomFS header. +using ::romfs_header; +using ::RsaKeyVersion; +/// Read/write lock structure. +using ::RwLock; +///< 64-bit signed integer. +using ::s128; +///< 8-bit signed integer. +using ::s16; +///< 16-bit signed integer. +using ::s32; +///< 32-bit signed integer. +using ::s64; +///< 128-bit unsigned integer. +using ::s8; +/// Secure monitor arguments. +using ::SecmonArgs; +/// Semaphore structure. +using ::Semaphore; +/// Service object structure +using ::Service; +using ::SessionMgr; +/// BatteryLot +using ::SetBatteryLot; +using ::SetCalAccelerometerOffset; +using ::SetCalAccelerometerScale; +using ::SetCalAmiiboEcdsaCertificate; +using ::SetCalAmiiboEcqvBlsCertificate; +using ::SetCalAmiiboEcqvBlsKey; +using ::SetCalAmiiboEcqvBlsRootCertificate; +using ::SetCalAmiiboEcqvCertificate; +using ::SetCalAmiiboKey; +using ::SetCalAnalogStickFactoryCalibration; +using ::SetCalAnalogStickModelParameter; +using ::SetCalBdAddress; +using ::SetCalConfigurationId1; +using ::SetCalConsoleSixAxisSensorHorizontalOffset; +using ::SetCalCountryCode; +using ::SetCalEccB233DeviceCertificate; +using ::SetCalEccB233DeviceKey; +using ::SetCalGameCardCertificate; +using ::SetCalGameCardKey; +using ::SetCalGyroscopeOffset; +using ::SetCalGyroscopeScale; +using ::SetCalMacAddress; +using ::SetCalRegionCode; +using ::SetCalRsa2048DeviceCertificate; +using ::SetCalRsa2048DeviceKey; +using ::SetCalSerialNumber; +using ::SetCalSpeakerParameter; +using ::SetCalSslCertificate; +using ::SetCalSslKey; +/// ChineseTraditionalInputMethod +using ::SetChineseTraditionalInputMethod; +/// KeyboardLayout +using ::SetKeyboardLayout; +/// IDs for Language. +using ::SetLanguage; +/// Region codes. +using ::SetRegion; +/// AccessPointSecurityStandard +using ::SetSysAccessPointSecurityStandard; +/// AccessPointSecurityType +using ::SetSysAccessPointSecurityType; +/// AccountNotificationSettings +using ::SetSysAccountNotificationSettings; +/// AccountOnlineStorageSettings +using ::SetSysAccountOnlineStorageSettings; +/// AccountSettings +using ::SetSysAccountSettings; +/// AllowedSslHosts +using ::SetSysAllowedSslHosts; +/// AnalogStickUserCalibration +using ::SetSysAnalogStickUserCalibration; +/// AudioDevice +using ::SetSysAudioDevice; +/// AudioOutputMode +using ::SetSysAudioOutputMode; +/// AudioOutputModeTarget +using ::SetSysAudioOutputModeTarget; +using ::SetSysAudioVolume; +/// AutoSettings +using ::SetSysAutoSettings; +/// BacklightSettings +using ::SetSysBacklightSettings; +/// BacklightSettingsEx +using ::SetSysBacklightSettingsEx; +/// BlePairingSettings +using ::SetSysBlePairingSettings; +/// BlockType +using ::SetSysBlockType; +/// BluetoothDevicesSettings +using ::SetSysBluetoothDevicesSettings; +/// ButtonConfigRegisteredSettings +using ::SetSysButtonConfigRegisteredSettings; +/// ButtonConfigSettings +using ::SetSysButtonConfigSettings; +/// Actually nn::util::Color4u8Type. +using ::SetSysColor4u8Type; +/// ConnectionFlag +using ::SetSysConnectionFlag; +/// ConsoleSixAxisSensorAccelerationBias +using ::SetSysConsoleSixAxisSensorAccelerationBias; +/// ConsoleSixAxisSensorAccelerationGain +using ::SetSysConsoleSixAxisSensorAccelerationGain; +/// ConsoleSixAxisSensorAngularAcceleration +using ::SetSysConsoleSixAxisSensorAngularAcceleration; +/// ConsoleSixAxisSensorAngularVelocityBias +using ::SetSysConsoleSixAxisSensorAngularVelocityBias; +/// ConsoleSixAxisSensorAngularVelocityGain +using ::SetSysConsoleSixAxisSensorAngularVelocityGain; +/// ConsoleSixAxisSensorAngularVelocityTimeBias +using ::SetSysConsoleSixAxisSensorAngularVelocityTimeBias; +/// ConsoleSleepPlan +using ::SetSysConsoleSleepPlan; +/// ControllerType +using ::SetSysControllerType; +using ::SetSysDataBlock; +/// DataDeletionSettings +using ::SetSysDataDeletionSettings; +/// DeviceNickName +using ::SetSysDeviceNickName; +/// Edid +using ::SetSysEdid; +/// ErrorReportSharePermission +using ::SetSysErrorReportSharePermission; +/// EulaVersion +using ::SetSysEulaVersion; +/// EulaVersionClockType +using ::SetSysEulaVersionClockType; +using ::SetSysExtensionBlock; +/// Structure returned by \ref setsysGetFirmwareVersion. +using ::SetSysFirmwareVersion; +/// Structure returned by \ref setsysGetFirmwareVersionDigest. +using ::SetSysFirmwareVersionDigest; +/// FriendPresenceOverlayPermission +using ::SetSysFriendPresenceOverlayPermission; +/// HandheldSleepPlan +using ::SetSysHandheldSleepPlan; +/// Output from \ref setsysGetHomeMenuScheme. This contains RGBA8 colors which correspond with the physical shell of the system. +using ::SetSysHomeMenuScheme; +/// HostFsMountPoint +using ::SetSysHostFsMountPoint; +/// InitialLaunchSettings +using ::SetSysInitialLaunchSettings; +/// LcdBacklightBrightnessMapping +using ::SetSysLcdBacklightBrightnessMapping; +using ::SetSysModeLine; +/// NetworkSettings +using ::SetSysNetworkSettings; +/// NotificationSettings +using ::SetSysNotificationSettings; +/// NotificationTime +using ::SetSysNotificationTime; +/// NotificationVolume +using ::SetSysNotificationVolume; +/// NxControllerLegacySettings +using ::SetSysNxControllerLegacySettings; +/// NxControllerSettings +using ::SetSysNxControllerSettings; +/// PlatformRegion. Other values not listed here should be handled as "Unknown". +using ::SetSysPlatformRegion; +/// PrimaryAlbumStorage +using ::SetSysPrimaryAlbumStorage; +/// Console Product Models +using ::SetSysProductModel; +/// ProxyFlags +using ::SetSysProxyFlags; +/// PtmCycleCountReliability +using ::SetSysPtmCycleCountReliability; +/// PtmFuelGaugeParameter +using ::SetSysPtmFuelGaugeParameter; +/// RebootlessSystemUpdateVersion. This is the content of the RebootlessSystemUpdateVersion SystemData, in the "/version" file. +using ::SetSysRebootlessSystemUpdateVersion; +/// Structure returned by \ref setsysGetSerialNumber. +using ::SetSysSerialNumber; +/// ServiceDiscoveryControlSettings +using ::SetSysServiceDiscoveryControlSettings; +/// SleepSettings +using ::SetSysSleepSettings; +/// ThemeId +using ::SetSysThemeId; +/// ThemeSettings +using ::SetSysThemeSettings; +/// TouchScreenMode, for "Touch-Screen Sensitivity". +using ::SetSysTouchScreenMode; +/// TvSettings +using ::SetSysTvSettings; +/// UserSelectorFlag +using ::SetSysUserSelectorFlag; +/// UserSelectorSettings +using ::SetSysUserSelectorSettings; +using ::SfBuffer; +using ::SfBufferAttrs; +using ::SfDispatchParams; +using ::SfOutHandleAttr; +using ::SfOutHandleAttrs; +/// Context for SHA1 operations. +using ::Sha1Context; +/// Context for SHA256 operations. +using ::Sha256Context; +/// Shared memory information structure. +using ::SharedMemory; +/// SignalToAddress behaviors. +using ::SignalType; +/// Structure representing a service name (null terminated, remaining characters set to zero). +using ::SmServiceName; +#ifdef _SOCKLEN_T_DECLARED +using ::sockaddr; +#endif +/// Configuration structure for socketInitalize +using ::SocketInitConfig; +using ::SplConfigItem; +/// AlpnProtoState +using ::SslAlpnProtoState; +/// BuiltInCertificateInfo +using ::SslBuiltInCertificateInfo; +/// CaCertificateId +using ::SslCaCertificateId; +/// CertificateFormat +using ::SslCertificateFormat; +/// CipherInfo +using ::SslCipherInfo; +/// SslConnection +using ::SslConnection; +/// SslContext +using ::SslContext; +/// ContextOption +using ::SslContextOption; +/// DebugOptionType +using ::SslDebugOptionType; +/// FlushSessionCacheOptionType +using ::SslFlushSessionCacheOptionType; +/// InternalPki +using ::SslInternalPki; +/// IoMode. The default value at the time of \ref sslContextCreateConnection is ::SslIoMode_Blocking. +/// The socket non-blocking flag is always set regardless of this field, this is only used internally for calculating the timeout used by various cmds. +using ::SslIoMode; +/// KeyAndCertParams +using ::SslKeyAndCertParams; +/// OptionType. The default bool flags value for these at the time of \ref sslContextCreateConnection is cleared. +using ::SslOptionType; +/// PollEvent +using ::SslPollEvent; +/// PrivateOptionType +using ::SslPrivateOptionType; +/// RenegotiationMode +using ::SslRenegotiationMode; +/// SslServerCertDetailEntry +using ::SslServerCertDetailEntry; +/// SslServerCertDetailHeader +using ::SslServerCertDetailHeader; +/// Values for __nx_ssl_service_type, controls which ssl service to initialize. +using ::SslServiceType; +/// SessionCacheMode +using ::SslSessionCacheMode; +/// TrustedCertStatus +using ::SslTrustedCertStatus; +/// VerifyOption. The default bitmask value at the time of \ref sslContextCreateConnection is ::SslVerifyOption_PeerCa | ::SslVerifyOption_HostName. +/// [5.0.0+] \ref sslConnectionSetVerifyOption: (::SslVerifyOption_PeerCa | ::SslVerifyOption_HostName) must be set, unless: ::SslOptionType_SkipDefaultVerify is set, or [9.0.0+] ::SslDebugOptionType_AllowDisableVerifyOption is set. +/// [6.0.0+] \ref sslConnectionSetVerifyOption: Following that, if ::SslVerifyOption_EvPolicyOid is set, then the following options must be set (besides the previously mentioned one): ::SslVerifyOption_PeerCa and ::SslVerifyOption_DateCheck. +using ::SslVerifyOption; +/// SslVersion. This is a bitmask which controls the min/max TLS versions to use, depending on which lowest/highest bits are set (if Auto* isn't set). +using ::SslVersion; +using ::SwkbdAppearArg; +/// Base swkbd arg struct. +using ::SwkbdArgCommon; +using ::SwkbdArgV0; +/// Arg struct for version 0x30007+. +using ::SwkbdArgV7; +/// Arg struct for version 0x6000B+. +using ::SwkbdArgVB; +/// Struct data for SwkbdInline Interactive reply storage ChangedString*, at the end following the string. +using ::SwkbdChangedStringArg; +/// 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. +using ::SwkbdChangedStringCb; +/// 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. +using ::SwkbdChangedStringV2Cb; +using ::SwkbdConfig; +using ::SwkbdCustomizedDictionarySet; +/// Input data for SwkbdInline request SetCustomizeDic. +using ::SwkbdCustomizeDicInfo; +/// Struct data for SwkbdInline Interactive reply storage DecidedEnter*, at the end following the string. +using ::SwkbdDecidedEnterArg; +/// 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. +using ::SwkbdDecidedEnterCb; +/// User dictionary word. +using ::SwkbdDictWord; +/// InitializeArg for SwkbdInline. +using ::SwkbdInitializeArg; +/// InlineKeyboard +using ::SwkbdInline; +using ::SwkbdInlineCalcArg; +/// Value for \ref SwkbdInitializeArg mode. Controls the LibAppletMode when launching the applet. +using ::SwkbdInlineMode; +/// Struct data for SwkbdInline Interactive reply storage MovedCursor*, at the end following the string. +using ::SwkbdMovedCursorArg; +/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor* replies. +/// str is the UTF-8 string for the current text. +using ::SwkbdMovedCursorCb; +/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor*V2 replies. +/// str is the UTF-8 string for the current text. +using ::SwkbdMovedCursorV2Cb; +/// Struct data for SwkbdInline Interactive reply storage MovedTab*, at the end following the string. +using ::SwkbdMovedTabArg; +/// This callback is used by \ref swkbdInlineUpdate when handling MovedTab* replies. +/// str is the UTF-8 string for the current text. +using ::SwkbdMovedTabCb; +/// Rect +using ::SwkbdRect; +/// SwkbdInline Interactive output storage reply ID. +using ::SwkbdReplyType; +/// SwkbdInline Interactive input storage request ID. +using ::SwkbdRequestCommand; +/// SwkbdInline State +using ::SwkbdState; +/// 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. +using ::SwkbdTextCheckCb; +/// Output result returned by \ref SwkbdTextCheckCb. +using ::SwkbdTextCheckResult; +/// Value for SwkbdArgCommon::textDrawType. Only applies when stringLenMax is 1..32, otherwise swkbd will only use SwkbdTextDrawType_Box. +using ::SwkbdTextDrawType; +/// Type of keyboard. +using ::SwkbdType; +/// GetSystemInfo IDs. +using ::SystemInfoType; +/// Thread information structure. +using ::Thread; +/// Thread Activity. +using ::ThreadActivity; +/// Thread context structure (register dump) +using ::ThreadContext; +/// This is for \ref ThreadExceptionDump error_desc. +using ::ThreadExceptionDesc; +/// Thread exception dump structure. +using ::ThreadExceptionDump; +using ::ThreadExceptionFrameA32; +using ::ThreadExceptionFrameA64; +/// Thread exit reasons +using ::ThreadExitReason; +///< Function error code result type. +using ::ThreadFunc; +/// GetInfo Idle/Thread Tick Count Sub IDs. +using ::TickCountInfo; +using ::TimeCalendarAdditionalInfo; +using ::TimeCalendarTime; +using ::TimeLocationName; +/// Valid types for a user-mode timer. +using ::TimerType; +/// Values for __nx_time_service_type. +using ::TimeServiceType; +using ::TimeStandardSteadyClockTimePointType; +using ::TimeSteadyClockTimePoint; +using ::TimeSystemClockContext; +/// Time clock type. +using ::TimeType; +using ::TimeZoneRule; +using ::TipcCommandType; +using ::TipcDispatchParams; +using ::TipcRequestFormat; +/// tipc Service object structure +using ::TipcService; +/// Transfer memory information structure. +using ::TransferMemory; +using ::TsDeviceCode; +/// Location +using ::TsLocation; +using ::TsSession; +///< 64-bit unsigned integer. +using ::u128; +///< 8-bit unsigned integer. +using ::u16; +///< 16-bit unsigned integer. +using ::u32; +///< 32-bit unsigned integer. +using ::u64; +using ::u8; +/// FlowControlMode +using ::UartFlowControlMode; +/// UartPort +using ::UartPort; +/// PortEventType +using ::UartPortEventType; +/// UartPortForDev +using ::UartPortForDev; +/// PortSession +using ::UartPortSession; +using ::UEvent; +/// Imported from libusb, with changed names. +using ::usb_class_code; +/// Imported from libusb, with some adjustments. +using ::usb_config_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_control_setup; +/// Imported from libusb, with changed names. +using ::usb_descriptor_type; +/// Imported from libusb, with some adjustments. +using ::usb_device_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_endpoint_descriptor; +/// Imported from libusb, with changed names. +using ::usb_endpoint_direction; +/// Imported from libusb, with some adjustments. +using ::usb_hid_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_interface_association_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_interface_descriptor; +/// Imported from libusb, with changed names. +using ::usb_iso_sync_type; +/// Imported from libusb, with changed names. +using ::usb_iso_usage_type; +/// Imported from libusb, with changed names. +using ::usb_request_recipient; +/// Imported from libusb, with changed names. +using ::usb_request_type; +/// Imported from libusb, with some adjustments. +using ::usb_ss_endpoint_companion_descriptor; +/// Imported from libusb, with changed names. +using ::usb_standard_request; +/// Imported from libusb, with some adjustments. +using ::usb_string_descriptor; +/// Imported from libusb, with changed names. +using ::usb_transfer_type; +using ::UsbCommsInterfaceInfo; +using ::UsbComplexId; +using ::UsbDeviceSpeed; +using ::UsbDsDeviceInfo; +using ::UsbDsEndpoint; +using ::UsbDsInterface; +using ::UsbDsReportData; +using ::UsbDsReportEntry; +using ::UsbHsClientEpSession; +/// The interface service object. These Events have autoclear=false. +using ::UsbHsClientIfSession; +/// Interface struct. Note that devices have a seperate \ref UsbHsInterface for each interface. +using ::UsbHsInterface; +/// Interface filtering struct. When the associated flag bit is set, the associated descriptor field and struct field are compared, on mismatch the interface is filtered out. +/// [7.0.0+]: The filter struct has to be unique, it can't be used by anything else (including other processes). Hence, Flags has to be non-zero. When initialized with usb:hs:a and VID and/or PID filtering is enabled, the VID/PID will be checked against a blacklist. +using ::UsbHsInterfaceFilter; +using ::UsbHsInterfaceFilterFlags; +/// Descriptors which are not available are set to all-zero. +/// The INPUT/OUTPUT endpoint descriptors were swapped with [8.0.0+], libnx converts this struct to the newer layout when running on pre-8.0.0. +using ::UsbHsInterfaceInfo; +using ::UsbHsRingHeader; +using ::UsbHsXferReport; +/// USB Device States, per USB 2.0 spec +using ::UsbState; +///< Unique identifier. +using ::UtilFloat3; +using ::UTimer; +///< Function without arguments nor return value. +using ::Uuid; +/// Used as argument for certain drawing commands. +using ::ViColorRgba4444; +using ::ViColorRgba8888; +using ::ViDisplay; +using ::ViDisplayName; +using ::ViLayer; +/// Used by viCreateLayer when CreateStrayLayer is used internally. +using ::ViLayerFlags; +/// Used as argument to many capture functions. +using ::ViLayerStack; +/// Used with viSetDisplayPowerState. +using ::ViPowerState; +/// Address space reservation type (see \ref virtmemAddReservation) +using ::VirtmemReservation; +/// Used with viSetLayerScalingMode. +using ::ViScalingMode; +using ::ViServiceType; +///< Thread entrypoint function. +using ::VoidFn; +///< 64-bit volatile signed integer. +using ::vs128; +///< 8-bit volatile signed integer. +using ::vs16; +///< 16-bit volatile signed integer. +using ::vs32; +///< 32-bit volatile signed integer. +using ::vs64; +///< 128-bit volatile unsigned integer. +using ::vs8; +///< 64-bit volatile unsigned integer. +using ::vu128; +///< 8-bit volatile unsigned integer. +using ::vu16; +///< 16-bit volatile unsigned integer. +using ::vu32; +///< 32-bit volatile unsigned integer. +using ::vu64; +///< 128-bit unsigned integer. +using ::vu8; +using ::Waitable; +using ::WaitableMethods; +using ::WaitableNode; +/// Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user-mode. +using ::Waiter; +using ::WaiterType; +/// Header struct at offset 0 in the web Arg storage (non-webWifi). +using ::WebArgHeader; +/// Web TLV used in the web Arg storage. +using ::WebArgTLV; +/// Types for \ref WebArgTLV, input storage. +using ::WebArgType; +/// 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. +using ::WebBackgroundKind; +/// 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. +using ::WebBootDisplayKind; +/// Entry data for ::WebArgType_BootFooterButton. +using ::WebBootFooterButtonEntry; +/// Config struct for web applets, non-WebWifi. +using ::WebCommonConfig; +/// Common container struct for applets' reply data, from the output storage. +using ::WebCommonReply; +/// Common struct for the applet output storage, for non-TLV-storage. +using ::WebCommonReturnValue; +/// TLV storage, starts with \ref WebArgHeader followed by \ref WebArgTLV entries. +using ::WebCommonTLVStorage; +/// This controls the kind of content to mount with Offline-applet. +using ::WebDocumentKind; +/// ExitReason +using ::WebExitReason; +/// Button values for \ref webConfigSetBootFooterButtonVisible. +using ::WebFooterButtonId; +/// Kind values for \ref webConfigSetFooterFixedKind. Controls UI footer display behaviour. +using ::WebFooterFixedKind; +/// 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). +using ::WebLeftStickMode; +/// Types for \ref WebArgTLV, output storage. +using ::WebReplyType; +/// WebSession +using ::WebSession; +/// WebSessionBootMode +using ::WebSessionBootMode; +/// SessionMessageHeader +using ::WebSessionMessageHeader; +/// WebSessionReceiveMessageKind +using ::WebSessionReceiveMessageKind; +/// WebSessionSendMessageKind +using ::WebSessionSendMessageKind; +/// StorageHandleQueue +using ::WebSessionStorageHandleQueue; +/// This controls the initial page for ShareApplet, used by \ref webShareCreate. +using ::WebShareStartPage; +/// This indicates the type of web-applet. +using ::WebShimKind; +/// Config for WebWifi. +using ::WebWifiConfig; +/// Struct for the WebWifi applet input storage. +using ::WebWifiPageArg; +/// Struct for the WebWifi applet output storage. +using ::WebWifiReturnValue; +/// WLAN State. +using ::WlanInfState; +/// XcdDeviceHandle +using ::XcdDeviceHandle; +/// XcdInterfaceType +using ::XcdInterfaceType; +/// SleepThread yield types. +using ::YieldType; + +/// Address of the host connected through nxlink +using ::__nxlink_host; + +/// @brief C++ wrappers for the `account` API. +/// @details Wraps: switch/services/acc.h. +namespace account { + +/// NetworkServiceAccountId +using ::AccountNetworkServiceAccountId; +/// Profile +using ::AccountProfile; +/// ProfileBase +using ::AccountProfileBase; +using ::AccountServiceType; +/// Account UserId. +using ::AccountUid; +/// UserData +using ::AccountUserData; + +/// Initialize account. +Result Initialize(AccountServiceType service_type); + +/// Exit account. +void Exit(void); + +/// Gets the Service object for the actual account service session. +Service* GetServiceSession(void); + +/// Get the total number of user profiles. +Result GetUserCount(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. + */ +Result ListAllUsers(AccountUid* uids, s32 max_uids, s32 *actual_total); + +/// Get the userId for the last opened user. +Result GetLastOpenedUser(AccountUid *uid); + +/// Get an AccountProfile for the specified userId. +Result GetProfile(AccountProfile* out, AccountUid uid); + +/// IsUserRegistrationRequestPermitted +Result IsUserRegistrationRequestPermitted(bool *out); + +/// TrySelectUserWithoutInteraction +Result TrySelectUserWithoutInteraction(AccountUid *uid, bool is_network_service_account_required); + +/// Close the AccountProfile. +void ProfileClose(AccountProfile* profile); + +/// Get \ref AccountUserData and \ref AccountProfileBase for the specified profile, userdata is optional (can be NULL). +Result ProfileGet(AccountProfile* profile, AccountUserData* userdata, AccountProfileBase* profilebase); + +/// Get the icon image size. +Result ProfileGetImageSize(AccountProfile* profile, u32* 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 ProfileLoadImage(AccountProfile* profile, void* buf, size_t len, u32* 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 GetPreselectedUser(AccountUid *uid); + +/** + * @brief Checks whether the specified \ref AccountUid is valid/set (non-zero). + * @param[in] Uid \ref AccountUid + */ +bool UidIsValid(const AccountUid *Uid); + +} // namespace account + +/// @brief C++ wrappers for the `aes128` API. +/// @details Wraps: switch/crypto/aes.h, switch/crypto/aes_cbc.h, switch/crypto/aes_ctr.h, switch/crypto/aes_xts.h. +namespace aes128 { + +/// Context for AES-128 CBC. +using ::Aes128CbcContext; +/// Context for AES-128 operations. +using ::Aes128Context; +/// Context for AES-128 CTR. +using ::Aes128CtrContext; +/// Context for AES-128 XTS. +using ::Aes128XtsContext; +/// Context for AES-192 CBC. +using ::Aes192CbcContext; +/// Context for AES-192 operations. +using ::Aes192Context; +/// Context for AES-192 CTR. +using ::Aes192CtrContext; +/// Context for AES-192 XTS. +using ::Aes192XtsContext; +/// Context for AES-256 CBC. +using ::Aes256CbcContext; +/// Context for AES-256 operations. +using ::Aes256Context; +/// Context for AES-256 CTR. +using ::Aes256CtrContext; +/// Context for AES-256 XTS. +using ::Aes256XtsContext; + +/// Initialize a 128-bit AES context. +void ContextCreate(Aes128Context *out, const void *key, bool is_encryptor); + +/// Encrypt using an AES context (Requires is_encryptor when initializing) +void EncryptBlock(const Aes128Context *ctx, void *dst, const void *src); + +/// Decrypt using an AES context (Requires !is_encryptor when initializing) +void DecryptBlock(const Aes128Context *ctx, void *dst, const void *src); + +/// 128-bit CBC API. +void CbcContextCreate(Aes128CbcContext *out, const void *key, const void *iv, bool is_encryptor); + +void CbcContextResetIv(Aes128CbcContext *ctx, const void *iv); + +size_t CbcEncrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size); + +size_t CbcDecrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size); + +/// 128-bit CTR API. +void CtrContextCreate(Aes128CtrContext *out, const void *key, const void *ctr); + +void CtrContextResetCtr(Aes128CtrContext *ctx, const void *ctr); + +void CtrCrypt(Aes128CtrContext *ctx, void *dst, const void *src, size_t size); + +/// 128-bit XTS API. +void XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor); + +void XtsContextResetTweak(Aes128XtsContext *ctx, const void *tweak); + +void XtsContextResetSector(Aes128XtsContext *ctx, uint64_t sector, bool is_nintendo); + +size_t XtsEncrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size); + +size_t XtsDecrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size); + +} // namespace aes128 + +/// @brief C++ wrappers for the `aes192` API. +/// @details Wraps: switch/crypto/aes.h, switch/crypto/aes_cbc.h, switch/crypto/aes_ctr.h, switch/crypto/aes_xts.h. +namespace aes192 { + +/// Context for AES-128 CBC. +using ::Aes128CbcContext; +/// Context for AES-128 operations. +using ::Aes128Context; +/// Context for AES-128 CTR. +using ::Aes128CtrContext; +/// Context for AES-128 XTS. +using ::Aes128XtsContext; +/// Context for AES-192 CBC. +using ::Aes192CbcContext; +/// Context for AES-192 operations. +using ::Aes192Context; +/// Context for AES-192 CTR. +using ::Aes192CtrContext; +/// Context for AES-192 XTS. +using ::Aes192XtsContext; +/// Context for AES-256 CBC. +using ::Aes256CbcContext; +/// Context for AES-256 operations. +using ::Aes256Context; +/// Context for AES-256 CTR. +using ::Aes256CtrContext; +/// Context for AES-256 XTS. +using ::Aes256XtsContext; + +/// Initialize a 192-bit AES context. +void ContextCreate(Aes192Context *out, const void *key, bool is_encryptor); + +/// Encrypt using an AES context (Requires is_encryptor when initializing) +void EncryptBlock(const Aes192Context *ctx, void *dst, const void *src); + +/// Decrypt using an AES context (Requires !is_encryptor when initializing) +void DecryptBlock(const Aes192Context *ctx, void *dst, const void *src); + +/// 192-bit CBC API. +void CbcContextCreate(Aes192CbcContext *out, const void *key, const void *iv, bool is_encryptor); + +void CbcContextResetIv(Aes192CbcContext *ctx, const void *iv); + +size_t CbcEncrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size); + +size_t CbcDecrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size); + +/// 192-bit CTR API. +void CtrContextCreate(Aes192CtrContext *out, const void *key, const void *ctr); + +void CtrContextResetCtr(Aes192CtrContext *ctx, const void *ctr); + +void CtrCrypt(Aes192CtrContext *ctx, void *dst, const void *src, size_t size); + +/// 192-bit XTS API. +void XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor); + +void XtsContextResetTweak(Aes192XtsContext *ctx, const void *tweak); + +void XtsContextResetSector(Aes192XtsContext *ctx, uint64_t sector, bool is_nintendo); + +size_t XtsEncrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size); + +size_t XtsDecrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size); + +} // namespace aes192 + +/// @brief C++ wrappers for the `aes256` API. +/// @details Wraps: switch/crypto/aes.h, switch/crypto/aes_cbc.h, switch/crypto/aes_ctr.h, switch/crypto/aes_xts.h. +namespace aes256 { + +/// Context for AES-128 CBC. +using ::Aes128CbcContext; +/// Context for AES-128 operations. +using ::Aes128Context; +/// Context for AES-128 CTR. +using ::Aes128CtrContext; +/// Context for AES-128 XTS. +using ::Aes128XtsContext; +/// Context for AES-192 CBC. +using ::Aes192CbcContext; +/// Context for AES-192 operations. +using ::Aes192Context; +/// Context for AES-192 CTR. +using ::Aes192CtrContext; +/// Context for AES-192 XTS. +using ::Aes192XtsContext; +/// Context for AES-256 CBC. +using ::Aes256CbcContext; +/// Context for AES-256 operations. +using ::Aes256Context; +/// Context for AES-256 CTR. +using ::Aes256CtrContext; +/// Context for AES-256 XTS. +using ::Aes256XtsContext; + +/// Initialize a 256-bit AES context. +void ContextCreate(Aes256Context *out, const void *key, bool is_encryptor); + +/// Encrypt using an AES context (Requires is_encryptor when initializing) +void EncryptBlock(const Aes256Context *ctx, void *dst, const void *src); + +/// Decrypt using an AES context (Requires !is_encryptor when initializing) +void DecryptBlock(const Aes256Context *ctx, void *dst, const void *src); + +/// 256-bit CBC API. +void CbcContextCreate(Aes256CbcContext *out, const void *key, const void *iv, bool is_encryptor); + +void CbcContextResetIv(Aes256CbcContext *ctx, const void *iv); + +size_t CbcEncrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size); + +size_t CbcDecrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size); + +/// 256-bit CTR API. +void CtrContextCreate(Aes256CtrContext *out, const void *key, const void *ctr); + +void CtrContextResetCtr(Aes256CtrContext *ctx, const void *ctr); + +void CtrCrypt(Aes256CtrContext *ctx, void *dst, const void *src, size_t size); + +/// 256-bit XTS API. +void XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor); + +void XtsContextResetTweak(Aes256XtsContext *ctx, const void *tweak); + +void XtsContextResetSector(Aes256XtsContext *ctx, uint64_t sector, bool is_nintendo); + +size_t XtsEncrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size); + +size_t XtsDecrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size); + +} // namespace aes256 + +/// @brief C++ wrappers for the `album` API. +/// @details Wraps: switch/applets/album_la.h. +namespace album { + +/// Arg type values pushed for the applet input storage, stored as an u8. +using ::AlbumLaArg; + +/** + * @brief Launches the applet with ::AlbumLaArg_ShowAlbumFiles and playStartupSound=false. + */ +Result LaShowAlbumFiles(void); + +/** + * @brief Launches the applet with ::AlbumLaArg_ShowAllAlbumFiles and playStartupSound=false. + */ +Result LaShowAllAlbumFiles(void); + +/** + * @brief Launches the applet with ::AlbumLaArg_ShowAllAlbumFilesForHomeMenu and playStartupSound=true. + */ +Result LaShowAllAlbumFilesForHomeMenu(void); + +} // namespace album + +/// @brief C++ wrappers for the `apm` API. +/// @details Wraps: switch/services/apm.h. +namespace apm { + +/// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates. +using ::ApmCpuBoostMode; +/// PerformanceMode +using ::ApmPerformanceMode; + +/// Initialize apm. Used automatically by \ref appletInitialize with AppletType_Application. +Result Initialize(void); + +/// Exit apm. Used automatically by \ref appletExit with AppletType_Application. +void Exit(void); + +/// Gets the Service object for the actual apm service session. +Service* GetServiceSession(void); + +/// Gets the Service object for ISession. +Service* GetServiceSession_Session(void); + +/** + * @brief Gets the current ApmPerformanceMode. + * @param[out] out_performanceMode ApmPerformanceMode + */ +Result GetPerformanceMode(ApmPerformanceMode* out_performanceMode); + +/** + * @brief Sets the PerformanceConfiguration for the specified PerformanceMode. + * @param[in] PerformanceMode \ref ApmPerformanceMode + * @param[in] PerformanceConfiguration PerformanceConfiguration + */ +Result SetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 PerformanceConfiguration); + +/** + * @brief Gets the PerformanceConfiguration for the specified PerformanceMode. + * @param[in] PerformanceMode \ref ApmPerformanceMode + * @param[out] PerformanceConfiguration PerformanceConfiguration + */ +Result GetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 *PerformanceConfiguration); + +} // namespace apm + +/// @brief C++ wrappers for the `applet` API. +/// @details Wraps: switch/services/applet.h. +namespace applet { + +/// IApplicationAccessor container. +using ::AppletApplication; +/// ApplicationAttribute +using ::AppletApplicationAttribute; +/// Attributes for launching applications for Quest. +using ::AppletApplicationAttributeForQuest; +/// AppletApplicationExitReason +using ::AppletApplicationExitReason; +/// ApplicationLaunchProperty +using ::AppletApplicationLaunchProperty; +/// ApplicationLaunchRequestInfo +using ::AppletApplicationLaunchRequestInfo; +/// Used by \ref appletInitialize with __nx_applet_AppletAttribute for cmd OpenLibraryAppletProxy (AppletType_LibraryApplet), on [3.0.0+]. The default for this struct is all-zero. +using ::AppletAttribute; +/// CaptureSharedBuffer for the IDisplayController commands. +using ::AppletCaptureSharedBuffer; +/// FocusHandlingMode +using ::AppletFocusHandlingMode; +/// FocusState +using ::AppletFocusState; +/// GpuErrorHandler +using ::AppletGpuErrorHandler; +/// LibraryApplet state. +using ::AppletHolder; +/// applet hook cookie. +using ::AppletHookCookie; +/// applet hook function. +using ::AppletHookFn; +/// applet hook types. +using ::AppletHookType; +/// AppletId +using ::AppletId; +/// IdentityInfo +using ::AppletIdentityInfo; +/// Extension values for \ref appletSetIdleTimeDetectionExtension / \ref appletGetIdleTimeDetectionExtension, for extending user inactivity detection. +using ::AppletIdleTimeDetectionExtension; +/// Cached info for the current LibraryApplet, from \ref appletGetAppletInfo. +using ::AppletInfo; +/// Input policy values for \ref appletSetInputDetectionPolicy. +using ::AppletInputDetectionPolicy; +/// LaunchParameterKind +using ::AppletLaunchParameterKind; +/// LockAccessor +using ::AppletLockAccessor; +/// AppletMessage, for \ref appletGetMessage. See also \ref AppletHookType. +using ::AppletMessage; +/// OperationMode +using ::AppletOperationMode; +/// AppletProcessLaunchReason, from GetLaunchReason. +using ::AppletProcessLaunchReason; +/// ProgramSpecifyKind for the ExecuteProgram cmd. Controls the type of the u64 passed to the ExecuteProgram cmd. +using ::AppletProgramSpecifyKind; +/// AppletResourceUsageInfo, from \ref appletGetAppletResourceUsageInfo. +using ::AppletResourceUsageInfo; +/// Permission values for \ref appletSetScreenShotPermission. +using ::AppletScreenShotPermission; +/// applet IStorage +using ::AppletStorage; +/// Type values for \ref appletPerformSystemButtonPressingIfInFocus. +using ::AppletSystemButtonType; +/// ThemeColorType +using ::AppletThemeColorType; +/// Mode values for \ref appletSetTvPowerStateMatchingMode. +using ::AppletTvPowerStateMatchingMode; +/// AppletType +using ::AppletType; +/// WindowOriginMode +using ::AppletWindowOriginMode; +/// Input mode values for \ref appletSetWirelessPriorityMode. +using ::AppletWirelessPriorityMode; +/// LibraryAppletExitReason +using ::LibAppletExitReason; +/// LibraryAppletInfo +using ::LibAppletInfo; +/// LibraryAppletMode +using ::LibAppletMode; + +/// Initialize applet, called automatically during app startup. +Result Initialize(void); + +/// Exit applet, called automatically during app exit. +void Exit(void); + +/// Gets the Service object for the actual "appletOE"/"appletAE" service session. +Service* GetServiceSession_Proxy(void); + +/// Gets the Service object for IAppletCommonFunctions. Only initialized with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [7.0.0+]. +Service* GetServiceSession_AppletCommonFunctions(void); + +/// Gets the Service object for I*Functions, specific to each AppletType (IApplicationFunctions for AppletType_*Application). Not initialized with AppletType_LibraryApplet pre-15.0.0. On [15.0.0+] with AppletType_LibraryApplet this returns the object for IHomeMenuFunctions. +Service* GetServiceSession_Functions(void); + +/// Gets the Service object for IGlobalStateController. Only initialized with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. +Service* GetServiceSession_GlobalStateController(void); + +/// Gets the Service object for IApplicationCreator. Only initialized with AppletType_SystemApplet. +Service* GetServiceSession_ApplicationCreator(void); + +/// Gets the Service object for ILibraryAppletSelfAccessor. Only initialized with AppletType_LibraryApplet. +Service* GetServiceSession_LibraryAppletSelfAccessor(void); + +/// Gets the Service object for IProcessWindingController. Only initialized with AppletType_LibraryApplet. +Service* GetServiceSession_ProcessWindingController(void); + +/// Gets the Service object for ILibraryAppletCreator. +Service* GetServiceSession_LibraryAppletCreator(void); + +/// Gets the Service object for ICommonStateGetter. +Service* GetServiceSession_CommonStateGetter(void); + +/// Gets the Service object for ISelfController. +Service* GetServiceSession_SelfController(void); + +/// Gets the Service object for IWindowController. +Service* GetServiceSession_WindowController(void); + +/// Gets the Service object for IAudioController. +Service* GetServiceSession_AudioController(void); + +/// Gets the Service object for IDisplayController. +Service* GetServiceSession_DisplayController(void); + +/// Gets the Service object for IDebugFunctions. +Service* GetServiceSession_DebugFunctions(void); + +/// Get the cached AppletResourceUserId. +u64 GetAppletResourceUserId(void); + +/// Get the \ref AppletType. +AppletType GetAppletType(void); + +/// Sets the state field for \ref AppletThemeColorType. +void SetThemeColorType(AppletThemeColorType theme); + +/// Gets the state field for \ref AppletThemeColorType. Used internally by \ref libappletArgsCreate. +AppletThemeColorType GetThemeColorType(void); + +/** + * @brief Gets the CradleStatus. + * @param[out] status Output Dock status. + */ +Result GetCradleStatus(u8 *status); + +/** + * @brief Gets the BootMode which originated from \ref pmbmGetBootMode. + * @param[out] mode \ref PmBootMode + */ +Result GetBootMode(PmBootMode *mode); + +/** + * @brief Request to AcquireSleepLock. + * @note On success, this then uses cmd GetAcquiredSleepLockEvent and waits on that event. + */ +Result RequestToAcquireSleepLock(void); + +/** + * @brief Release the SleepLock. + */ +Result ReleaseSleepLock(void); + +/** + * @brief Release the SleepLock transiently. + * @note On success, this then uses cmd GetAcquiredSleepLockEvent and waits on that event. + */ +Result ReleaseSleepLockTransiently(void); + +/** + * @brief GetWakeupCount + * @note Only available with [11.0.0+]. + * @param[out] out Output value. + */ +Result GetWakeupCount(u64 *out); + +/** + * @brief Pushes a storage to the general channel. Used for sending requests to SystemApplet. + * @note This is not usable under an Application, however it is usable under a LibraryApplet. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result PushToGeneralChannel(AppletStorage *s); + +/** + * @brief Gets a \ref AppletLockAccessor for HomeButtonReader. + * @note Similar to using \ref appletGetReaderLockAccessorEx with inval=0. + * @param a LockAccessor object. + */ +Result GetHomeButtonReaderLockAccessor(AppletLockAccessor *a); + +/** + * @brief Gets a Reader \ref AppletLockAccessor. + * @note Only available with [2.0.0+]. + * @param a LockAccessor object. + * @param[in] inval Input value, must be 0-3. 0 = HomeButton. + */ +Result GetReaderLockAccessorEx(AppletLockAccessor *a, u32 inval); + +/** + * @brief Gets a Writer \ref AppletLockAccessor. + * @note Only available with [7.0.0+]. On older sysvers, this is only available with AppletType_SystemApplet on [2.0.0+]. + * @param a LockAccessor object. + * @param[in] inval Input value, must be 0-3. 0 = HomeButton. + */ +Result GetWriterLockAccessorEx(AppletLockAccessor *a, u32 inval); + +/** + * @brief Gets the Dock firmware version. + * @note Only available with [2.0.0+]. + * @param[out] out0 First output value. + * @param[out] out1 Second output value. + * @param[out] out2 Third output value. + * @param[out] out3 Fourth output value. + */ +Result GetCradleFwVersion(u32 *out0, u32 *out1, u32 *out2, u32 *out3); + +/** + * @brief Gets whether VrMode is enabled. + * @note Only available with [3.0.0+]. + * @param out Output flag + */ +Result IsVrModeEnabled(bool *out); + +/** + * @brief Sets whether VrMode is enabled. + * @note This is only fully usable system-side with [6.0.0+]. + * @note For checking Parental Controls, see \ref pctlIsStereoVisionPermitted. + * @note On pre-7.0.0 this uses cmd SetVrModeEnabled internally, while on [7.0.0+] this uses cmds BeginVrModeEx/EndVrModeEx. + * @param flag Flag + */ +Result SetVrModeEnabled(bool flag); + +/** + * @brief Sets whether the LCD screen backlight is turned off. + * @note Only available with [4.0.0+]. + * @param[in] flag Flag + */ +Result SetLcdBacklightOffEnabled(bool flag); + +/** + * @brief Gets the ControllerFirmwareUpdateSection flag. + * @note Only available with [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsInControllerFirmwareUpdateSection(bool *out); + +/** + * @brief SetVrPositionForDebug + * @note The cached value loaded from \ref setsysGetDebugModeFlag must be 1, otherwise an error is returned. + * @note Only available with [11.0.0+]. + * @param[in] x X, must not be negative. x+width must be <=1280. + * @param[in] y Y, must not be negative. y+height must be <=720. + * @param[in] width Width, must be 1-1280. + * @param[in] height Height, must be 1-720. + */ +Result SetVrPositionForDebug(s32 x, s32 y, s32 width, s32 height); + +/** + * @brief Gets the DefaultDisplayResolution. + * @note Only available with [3.0.0+]. + * @param[out] width Output width. + * @param[out] height Output height. + */ +Result GetDefaultDisplayResolution(s32 *width, s32 *height); + +/** + * @brief Gets an Event which is signaled when the output from \ref appletGetDefaultDisplayResolution changes. + * @note Only available with [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 GetDefaultDisplayResolutionChangeEvent(Event *out_event); + +/** + * @brief Gets the HdcpAuthenticationState. + * @note Only available with [4.0.0+]. + * @param[out] state Output state. + */ +Result GetHdcpAuthenticationState(s32 *state); + +/** + * @brief Gets an Event which is signaled when the output from \ref appletGetHdcpAuthenticationState changes. + * @note Only available with [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 GetHdcpAuthenticationStateChangeEvent(Event *out_event); + +/** + * @brief Sets the \ref AppletTvPowerStateMatchingMode. + * @note Only available with [5.0.0+]. + * @param[in] mode \ref AppletTvPowerStateMatchingMode + */ +Result SetTvPowerStateMatchingMode(AppletTvPowerStateMatchingMode mode); + +/** + * @brief Gets the ApplicationId for the specified ContentActionName string. + * @note Only available when the current applet is an AppletType_SystemApplication on [5.1.0+]. + * @param[out] application_id ApplicationId. + * @param[in] name ContentActionName string. + */ +Result GetApplicationIdByContentActionName(u64 *application_id, const char *name); + +/** + * @brief Sets the \ref ApmCpuBoostMode. + * @note Only available with [7.0.0+] (not fully usable system-side with 6.x). + * @param mode \ref ApmCpuBoostMode. + */ +Result SetCpuBoostMode(ApmCpuBoostMode mode); + +/** + * @brief CancelCpuBoostMode + * @note Only available with [10.0.0+]. + */ +Result CancelCpuBoostMode(void); + +/** + * @brief GetBuiltInDisplayType + * @note Only available with [11.0.0+]. + * @param[out] out Output value. + */ +Result GetBuiltInDisplayType(s32 *out); + +/** + * @brief Perform SystemButtonPressing with the specified \ref AppletSystemButtonType. Internally this cmd checks a state field, verifies that the type is allowed, then runs the same func as \ref appletPerformSystemButtonPressing internally. + * @note Only available with [6.0.0+]. + * @param[in] type \ref AppletSystemButtonType + */ +Result PerformSystemButtonPressingIfInFocus(AppletSystemButtonType type); + +/** + * @brief Sets whether PerformanceConfigurationChangedNotification is enabled. + * @note Only available with [7.0.0+]. + * @param[in] flag Whether to enable the notification. + */ +Result SetPerformanceConfigurationChangedNotification(bool flag); + +/** + * @brief Gets the current PerformanceConfiguration. + * @note Only available with [7.0.0+]. + * @param PerformanceConfiguration Output PerformanceConfiguration. + */ +Result GetCurrentPerformanceConfiguration(u32 *PerformanceConfiguration); + +/** + * @brief Opens an \ref AppletGpuErrorHandler. + * @note The cached value loaded from \ref setsysGetDebugModeFlag must be 1, otherwise an error is returned. + * @note Only available with [11.0.0+]. + * @param[out] g \ref AppletGpuErrorHandler + */ +Result OpenMyGpuErrorHandler(AppletGpuErrorHandler *g); + +/** + * @brief Gets the OperationModeSystemInfo. + * @note Only available with [7.0.0+]. + * @param[out] info Output info. + */ +Result GetOperationModeSystemInfo(u32 *info); + +/** + * @brief This uses \ref setsysGetPlatformRegion internally. + * @note Only available with [9.0.0+]. + * @param[out] out \ref SetSysPlatformRegion + */ +Result GetSettingsPlatformRegion(SetSysPlatformRegion *out); + +/** + * @brief ActivateMigrationService + * @note Only available with [10.0.0+]. + */ +Result ActivateMigrationService(void); + +/** + * @brief DeactivateMigrationService + * @note Only available with [10.0.0+]. + */ +Result DeactivateMigrationService(void); + +/** + * @brief DisableSleepTillShutdown + * @note Only available with [11.0.0+]. + */ +Result DisableSleepTillShutdown(void); + +/** + * @brief SuppressDisablingSleepTemporarily + * @param[in] val Nanoseconds value. + * @note Only available with [11.0.0+]. + */ +Result SuppressDisablingSleepTemporarily(u64 val); + +/** + * @brief SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled + * @note Only available with [11.0.0+]. + */ +Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(void); + +/** + * @brief Close an \ref AppletGpuErrorHandler. + * @param g \ref AppletGpuErrorHandler + */ +void GpuErrorHandlerClose(AppletGpuErrorHandler *g); + +/** + * @brief Gets the size of the info available with \ref appletGpuErrorHandlerGetManualGpuErrorInfo. + * @param g \ref AppletGpuErrorHandler + * @param[out] out Output size. + */ +Result GpuErrorHandlerGetManualGpuErrorInfoSize(AppletGpuErrorHandler *g, u64 *out); + +/** + * @brief GetManualGpuErrorInfo + * @param g \ref AppletGpuErrorHandler + * @param[out] buffer Output buffer. + * @param[in] size Output buffer size, must be >= the output size from \ref appletGpuErrorHandlerGetManualGpuErrorInfoSize. + * @param[out] out Output value. + */ +Result GpuErrorHandlerGetManualGpuErrorInfo(AppletGpuErrorHandler *g, void* buffer, size_t size, u64 *out); + +/** + * @brief GetManualGpuErrorDetectionSystemEvent + * @param g \ref AppletGpuErrorHandler + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GpuErrorHandlerGetManualGpuErrorDetectionSystemEvent(AppletGpuErrorHandler *g, Event *out_event); + +/** + * @brief FinishManualGpuErrorHandling + * @param g \ref AppletGpuErrorHandler + */ +Result GpuErrorHandlerFinishManualGpuErrorHandling(AppletGpuErrorHandler *g); + +/** + * @brief Delay exiting until \ref appletUnlockExit is called, with a 15 second timeout once exit is requested. + * @note When exit is requested \ref appletMainLoop will return false, hence any main-loop using appletMainLoop will exit. This allows the app to handle cleanup post-main-loop instead of being force-terminated. + * @note If the above timeout occurs after exit was requested where \ref appletUnlockExit was not called, the process will be forced-terminated. + * @note \ref appletUnlockExit must be used before main() returns. + */ +Result LockExit(void); + +/// Unlocks exiting, see \ref appletLockExit. +Result UnlockExit(void); + +/** + * @brief Enter FatalSection. + */ +Result EnterFatalSection(void); + +/** + * @brief Leave FatalSection. + */ +Result LeaveFatalSection(void); + +/** + * @brief Controls whether screenshot-capture is allowed. + * @param permission \ref AppletScreenShotPermission + */ +Result SetScreenShotPermission(AppletScreenShotPermission permission); + +/** + * @brief Sets whether ::AppletMessage_Resume is enabled. + * @param[in] flag Whether to enable the notification. + */ +Result SetRestartMessageEnabled(bool flag); + +/** + * @brief Sets the \ref AppletIdentityInfo for screenshots. + * @param[in] info \ref AppletIdentityInfo + */ +Result SetScreenShotAppletIdentityInfo(AppletIdentityInfo *info); + +/** + * @brief Sets ControllerFirmwareUpdateSection. + * @note Only available with [3.0.0+]. + * @note This throws error 0x40280 when the internal state flag already matches the input value. + * @param[in] flag Flag + */ +Result SetControllerFirmwareUpdateSection(bool flag); + +/** + * @brief Sets whether ::AppletMessage_CaptureButtonShortPressed is enabled. + * @note Only available with [3.0.0+]. + * @note When enabled with a non-Overlay applet, Overlay applet will not be notified of capture button short-presses for screenshots. + * @param[in] flag Whether to enable the notification. + */ +Result SetRequiresCaptureButtonShortPressedMessage(bool flag); + +/** + * @brief Sets the Album screenshot ImageOrientation. + * @note Only available with [3.0.0+]. + * @param[in] orientation \ref AlbumImageOrientation + */ +Result SetAlbumImageOrientation(AlbumImageOrientation orientation); + +/** + * @brief Sets the DesirableKeyboardLayout. + * @note Only available with [4.0.0+]. + * @param[in] layout Input \ref SetKeyboardLayout. + */ +Result SetDesirableKeyboardLayout(SetKeyboardLayout layout); + +Result CreateManagedDisplayLayer(u64 *out); + +/** + * @brief Checks whether SystemBufferSharing is enabled, throwing an error otherwise. + * @note Only available with [4.0.0+]. Not usable with AppletType_*Application. + */ +Result IsSystemBufferSharingEnabled(void); + +/** + * @brief Gets the System SharedBufferHandle and SharedLayerHandle. + * @note Only available with [4.0.0+]. Not usable with AppletType_*Application. + * @param[out] SharedBufferHandle Output System SharedBufferHandle. + * @param[out] SharedLayerHandle Output System SharedLayerHandle. + */ +Result GetSystemSharedLayerHandle(u64 *SharedBufferHandle, u64 *SharedLayerHandle); + +/** + * @brief Same as \ref appletGetSystemSharedLayerHandle except this just gets the SharedBufferHandle. + * @note Only available with [5.0.0+]. Not usable with AppletType_*Application. + * @param[out] SharedBufferHandle Output System SharedBufferHandle. + */ +Result GetSystemSharedBufferHandle(u64 *SharedBufferHandle); + +/** + * @brief CreateManagedDisplaySeparableLayer + * @note Only available with [10.0.0+]. + * @param[out] display_layer Output display_layer. + * @param[out] recording_layer Output recording_layer. + */ +Result CreateManagedDisplaySeparableLayer(u64 *display_layer, u64 *recording_layer); + +/** + * @brief SetManagedDisplayLayerSeparationMode + * @note Only available with [10.0.0+]. + * @param[in] mode Mode. Must be 0-1. + */ +Result SetManagedDisplayLayerSeparationMode(u32 mode); + +/** + * @brief Sets whether ::AppletMessage_RequestToDisplay is enabled. + * @note Sets an internal state flag. When the input flag is 0, this will in additional run the same code as \ref appletApproveToDisplay. + * @param[in] flag Flag + */ +Result SetHandlesRequestToDisplay(bool flag); + +/** + * @brief Approve the display requested by ::AppletMessage_RequestToDisplay, see also \ref appletSetHandlesRequestToDisplay. + */ +Result ApproveToDisplay(void); + +/** + * @brief OverrideAutoSleepTimeAndDimmingTime + * @param[in] inval0 Unknown input value. + * @param[in] inval1 Unknown input value. + * @param[in] inval2 Unknown input value. + * @param[in] inval3 Unknown input value. + */ +Result OverrideAutoSleepTimeAndDimmingTime(s32 inval0, s32 inval1, s32 inval2, s32 inval3); + +/** + * @brief Sets the IdleTimeDetectionExtension. + * @param[in] ext \ref AppletIdleTimeDetectionExtension Must be 0-2: 0 = disabled, 1 = Extended, and 2 = ExtendedUnsafe. + */ +Result SetIdleTimeDetectionExtension(AppletIdleTimeDetectionExtension ext); + +/** + * @brief Gets the value set by \ref appletSetIdleTimeDetectionExtension. + * @param[out] ext \ref AppletIdleTimeDetectionExtension + */ +Result GetIdleTimeDetectionExtension(AppletIdleTimeDetectionExtension *ext); + +/** + * @brief Sets the InputDetectionSourceSet. + * @param[in] val Input value. + */ +Result SetInputDetectionSourceSet(u32 val); + +/** + * @brief Reports that the user is active, for idle detection (screen dimming / auto-sleep). This is equivalent to when the user uses HID input. + * @note Only available with [2.0.0+]. + */ +Result ReportUserIsActive(void); + +/** + * @brief Gets the current Illuminance from the light sensor. + * @note Only available with [3.0.0+]. + * @param fLux Output fLux + */ +Result GetCurrentIlluminance(float *fLux); + +/** + * @brief Gets whether Illuminance is available. + * @note Only available with [3.0.0+]. + * @param out Output flag + */ +Result IsIlluminanceAvailable(bool *out); + +/** + * @brief Sets AutoSleepDisabled. + * @note Only available with [5.0.0+]. + * @param[in] flag Flag + */ +Result SetAutoSleepDisabled(bool flag); + +/** + * @brief Gets AutoSleepDisabled. + * @note Only available with [5.0.0+]. + * @param[out] out Output flag + */ +Result IsAutoSleepDisabled(bool *out); + +/** + * @brief Gets the current Illuminance from the light sensor. Same as \ref appletGetCurrentIlluminance except for the additional param. + * @note Only available with [5.0.0+]. + * @param bOverLimit Output bOverLimit + * @param fLux Output fLux + */ +Result GetCurrentIlluminanceEx(bool *bOverLimit, float *fLux); + +/** + * @brief Sets the \ref AppletInputDetectionPolicy. + * @note Only available with [9.0.0+]. + * @param[in] policy \ref AppletInputDetectionPolicy + */ +Result SetInputDetectionPolicy(AppletInputDetectionPolicy policy); + +/** + * @brief Sets the WirelessPriorityMode. + * @note Only available with [4.0.0+]. + * @param[in] mode \ref AppletWirelessPriorityMode + */ +Result SetWirelessPriorityMode(AppletWirelessPriorityMode mode); + +/** + * @brief Gets the total time in nanoseconds that the current process was actively running (not suspended), relative to when \ref appletInitialize was last used. + * @note Only available with [6.0.0+]. + * @param[out] activeTime Output nanoseconds value. + */ +Result GetProgramTotalActiveTime(u64 *activeTime); + +/** + * @brief Sets whether ::AppletMessage_AlbumScreenShotTaken is enabled. + * @note Only available with [7.0.0+]. + * @param[in] flag Whether to enable the notification. + */ +Result SetAlbumImageTakenNotificationEnabled(bool flag); + +/** + * @brief Sets the Application AlbumUserData. + * @note Only available with [8.0.0+]. + * @param[in] buffer Buffer containing arbitrary UserData. + * @param[in] size Buffer size, must be <=0x400. + */ +Result SetApplicationAlbumUserData(const void* buffer, size_t size); + +/** + * @brief SaveCurrentScreenshot + * @note Only available with [11.0.0+]. + * @param[in] option \ref AlbumReportOption + */ +Result SaveCurrentScreenshot(AlbumReportOption option); + +/** + * @brief Gets the AppletResourceUserId of the CallerApplet. + * @note Only available with [6.0.0+]. + * @param[out] out AppletResourceUserId + */ +Result GetAppletResourceUserIdOfCallerApplet(u64 *out); + +/** + * @brief Sets the current applet WindowVisibility. + * @note Only available with [7.0.0+]. + * @param[in] flag Flag + */ +Result SetAppletWindowVisibility(bool flag); + +/** + * @brief Sets the AppletGpuTimeSlice. + * @note Only available with [7.0.0+]. + * @param[in] val Input value, must not be negative. + */ +Result SetAppletGpuTimeSlice(s64 val); + +/** + * @brief Sets the ExpectedMasterVolume for MainApplet and LibraryApplet. + * @note Used by some official apps before/after launching LibraryApplets. Prior to changing the volume, the official app uses \ref appletGetExpectedMasterVolume, with the output being used to restore the volume after LibraryApplet handling. + * @param[in] mainAppletVolume MainApplet ExpectedMasterVolume. + * @param[in] libraryAppletVolume LibraryApplet ExpectedMasterVolume. + */ +Result SetExpectedMasterVolume(float mainAppletVolume, float libraryAppletVolume); + +/** + * @brief Gets the ExpectedMasterVolume for MainApplet and LibraryApplet. + * @note See also \ref appletSetExpectedMasterVolume. + * @param[out] mainAppletVolume MainApplet ExpectedMasterVolume. Optional, can be NULL. Used with cmd GetMainAppletExpectedMasterVolume when not NULL. + * @param[out] libraryAppletVolume LibraryApplet ExpectedMasterVolume. Optional, can be NULL. Used with cmd GetLibraryAppletExpectedMasterVolume when not NULL. + */ +Result GetExpectedMasterVolume(float *mainAppletVolume, float *libraryAppletVolume); + +/** + * @brief Change the MainApplet MasterVolume. + * @param[in] volume MainApplet MasterVolume. + * @param[in] unk Unknown. + */ +Result ChangeMainAppletMasterVolume(float volume, u64 unk); + +/** + * @brief Sets the TransparentVolumeRate. + * @param[in] val Input value. + */ +Result SetTransparentVolumeRate(float val); + +/** + * @brief Update the LastForeground CaptureImage. + */ +Result UpdateLastForegroundCaptureImage(void); + +/** + * @brief Update the CallerApplet CaptureImage. + */ +Result UpdateCallerAppletCaptureImage(void); + +/** + * @brief Gets the LastForeground CaptureImage. + * @param[out] buffer Output buffer containing the 1280x720 RGBA8 image. + * @param[out] size Buffer size, must match 0x384000. + * @param[out] flag Output flag. + */ +Result GetLastForegroundCaptureImageEx(void* buffer, size_t size, bool *flag); + +/** + * @brief Gets the LastApplication CaptureImage. + * @param[out] buffer Output buffer containing the 1280x720 RGBA8 image. + * @param[out] size Buffer size, must match 0x384000. + * @param[out] flag Output flag. + */ +Result GetLastApplicationCaptureImageEx(void* buffer, size_t size, bool *flag); + +/** + * @brief Gets the CallerApplet CaptureImage. + * @param[out] buffer Output buffer containing the 1280x720 RGBA8 image. + * @param[out] size Buffer size, must match 0x384000. + * @param[out] flag Output flag. + */ +Result GetCallerAppletCaptureImageEx(void* buffer, size_t size, bool *flag); + +/** + * @brief Takes a screenshot of the current applet Layer into the specified CaptureSharedBuffer. + * @note Only available with [2.0.0+]. + * @param[in] flag Flag. + * @param[in] captureBuf \ref AppletCaptureSharedBuffer + */ +Result TakeScreenShotOfOwnLayer(bool flag, AppletCaptureSharedBuffer captureBuf); + +/** + * @brief Copies image data from a CaptureSharedBuffer to another CaptureSharedBuffer. + * @note Only available with [5.0.0+]. + * @param[in] dstCaptureBuf Destination \ref AppletCaptureSharedBuffer. + * @param[in] srcCaptureBuf Source \ref AppletCaptureSharedBuffer. + */ +Result CopyBetweenCaptureBuffers(AppletCaptureSharedBuffer dstCaptureBuf, AppletCaptureSharedBuffer srcCaptureBuf); + +/** + * @brief Clear the input CaptureSharedBuffer with the specified color. + * @note Only available with [3.0.0+]. + * @param[in] flag Flag. + * @param[in] captureBuf \ref AppletCaptureSharedBuffer + * @param[in] color RGBA8 color. + */ +Result ClearCaptureBuffer(bool flag, AppletCaptureSharedBuffer captureBuf, u32 color); + +/** + * @brief Clear the AppletTransitionBuffer with the specified color. + * @note Only available with [3.0.0+]. + * @param[in] color RGBA8 color. + */ +Result ClearAppletTransitionBuffer(u32 color); + +/** + * @brief Acquire the LastApplication CaptureSharedBuffer. + * @note Only available with [4.0.0+]. + * @param[out] flag Output flag. + * @param[out] id Output ID. + */ +Result AcquireLastApplicationCaptureSharedBuffer(bool *flag, s32 *id); + +/** + * @brief Release the LastApplication CaptureSharedBuffer. + * @note Only available with [4.0.0+]. + */ +Result ReleaseLastApplicationCaptureSharedBuffer(void); + +/** + * @brief Acquire the LastForeground CaptureSharedBuffer. + * @note Only available with [4.0.0+]. + * @param[out] flag Output flag. + * @param[out] id Output ID. + */ +Result AcquireLastForegroundCaptureSharedBuffer(bool *flag, s32 *id); + +/** + * @brief Release the LastForeground CaptureSharedBuffer. + * @note Only available with [4.0.0+]. + */ +Result ReleaseLastForegroundCaptureSharedBuffer(void); + +/** + * @brief Acquire the CallerApplet CaptureSharedBuffer. + * @note Only available with [4.0.0+]. + * @param[out] flag Output flag. + * @param[out] id Output ID. + */ +Result AcquireCallerAppletCaptureSharedBuffer(bool *flag, s32 *id); + +/** + * @brief Release the CallerApplet CaptureSharedBuffer. + * @note Only available with [4.0.0+]. + */ +Result ReleaseCallerAppletCaptureSharedBuffer(void); + +/** + * @brief Takes a screenshot of the current applet Layer into the specified CaptureSharedBuffer. Same as \ref appletTakeScreenShotOfOwnLayer except for the additional immediately param. + * @note Only available with [6.0.0+]. + * @param[in] flag0 Flag0. + * @param[in] immediately Whether the screenshot should be taken immediately. + * @param[in] captureBuf \ref AppletCaptureSharedBuffer + */ +Result TakeScreenShotOfOwnLayerEx(bool flag0, bool immediately, AppletCaptureSharedBuffer captureBuf); + +/** + * @brief Pushes a storage to the ContextStack. Normally this should only be used when AppletInfo::caller_flag is true. + * @note Only available with AppletType_LibraryApplet. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result PushContext(AppletStorage *s); + +/** + * @brief Pops a storage from the ContextStack. Normally this should only be used when AppletInfo::caller_flag is true. + * @note Only available with AppletType_LibraryApplet. + * @param[out] s Storage object. + */ +Result PopContext(AppletStorage *s); + +/** + * @brief Closes a LockAccessor. + * @param a LockAccessor object. + */ +void LockAccessorClose(AppletLockAccessor *a); + +/** + * @brief TryLock a LockAccessor. + * @param a LockAccessor object. + * @param[out] flag Whether locking was successful, when false this indicates that this func should be called again. + */ +Result LockAccessorTryLock(AppletLockAccessor *a, bool *flag); + +/** + * @brief Lock a LockAccessor. + * @note Similar to \ref appletLockAccessorTryLock, except this uses timeout UINT64_MAX with the eventWait call, and this uses TryLock repeatedly until the output flag value is true. + * @param a LockAccessor object. + */ +Result LockAccessorLock(AppletLockAccessor *a); + +/** + * @brief Unlock a LockAccessor. + * @param a LockAccessor object. + */ +Result LockAccessorUnlock(AppletLockAccessor *a); + +/** + * @brief Creates a LibraryApplet. + * @param h AppletHolder object. + * @param id See \ref AppletId. + * @param mode See \ref LibAppletMode. + */ +Result CreateLibraryApplet(AppletHolder *h, AppletId id, LibAppletMode mode); + +/** + * @brief Creates a LibraryApplet. This is for when a LibraryApplet creates itself. + * @note Identical to \ref appletCreateLibraryApplet except this sets the creating_self flag to true. + * @param h AppletHolder object. + * @param id See \ref AppletId. + * @param mode See \ref LibAppletMode. + */ +Result CreateLibraryAppletSelf(AppletHolder *h, AppletId id, LibAppletMode mode); + +/** + * @brief TerminateAllLibraryApplets which were created by the current applet. + * @note Normally LibraryApplet cleanup should be handled via \ref AppletHolder. + */ +Result TerminateAllLibraryApplets(void); + +/** + * @brief AreAnyLibraryAppletsLeft which were created by the current applet. + * @param[out] out Output flag. + */ +Result AreAnyLibraryAppletsLeft(bool *out); + +/// Closes an AppletHolder object. +void HolderClose(AppletHolder *h); + +/// Returns whether the AppletHolder object was initialized. +bool HolderActive(AppletHolder *h); + +/** + * @brief Gets the IndirectLayerConsumerHandle loaded during \ref appletCreateLibraryApplet, on [2.0.0+]. + * @note Only available when \ref LibAppletMode is ::LibAppletMode_BackgroundIndirect. + * @param h AppletHolder object. + * @param out Output IndirectLayerConsumerHandle. + */ +Result HolderGetIndirectLayerConsumerHandle(AppletHolder *h, u64 *out); + +/** + * @brief Starts the LibraryApplet. + * @param h AppletHolder object. + */ +Result HolderStart(AppletHolder *h); + +/** + * @brief Jumps to the LibraryApplet, with the current-LibraryApplet being terminated. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_LibraryApplet. + * @param h AppletHolder object. + */ +Result HolderJump(AppletHolder *h); + +/** + * @brief Requests the LibraryApplet to exit. The command is only used if \ref appletHolderCheckFinished returns false. + * @param h AppletHolder object. + */ +Result HolderRequestExit(AppletHolder *h); + +/** + * @brief Terminate the LibraryApplet. + * @param h AppletHolder object. + */ +Result HolderTerminate(AppletHolder *h); + +/** + * @brief Uses cmds GetAppletStateChangedEvent and RequestExit, then waits for the LibraryApplet to exit with the specified timeout. If a timeout occurs, the Terminate cmd is used. + * @param h AppletHolder object. + * @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout. + */ +Result HolderRequestExitOrTerminate(AppletHolder *h, u64 timeout); + +/** + * @brief Waits for the LibraryApplet to exit. + * @param h AppletHolder object. + */ +void HolderJoin(AppletHolder *h); + +/** + * @brief Gets the LibraryApplet StateChangedEvent. + * @param h AppletHolder object. + */ +Event * HolderGetExitEvent(AppletHolder *h); + +/** + * @brief Waits on the LibraryApplet StateChangedEvent with timeout=0, and returns whether it was successful. + * @param h AppletHolder object. + */ +bool HolderCheckFinished(AppletHolder *h); + +/** + * @brief Gets the \ref LibAppletExitReason set by \ref appletHolderJoin. + * @param h AppletHolder object. + */ +LibAppletExitReason HolderGetExitReason(AppletHolder *h); + +/** + * @brief Sets OutOfFocusApplicationSuspendingEnabled. + * @note Only available with AppletType_*Application. + * @param h AppletHolder object. + * @param[in] flag Flag + */ +Result HolderSetOutOfFocusApplicationSuspendingEnabled(AppletHolder *h, bool flag); + +/** + * @brief PresetLibraryAppletGpuTimeSliceZero + * @note Only available with [10.0.0+]. + * @param h AppletHolder object. + */ +Result HolderPresetLibraryAppletGpuTimeSliceZero(AppletHolder *h); + +/** + * @brief Gets the PopInteractiveOutDataEvent. + * @param h AppletHolder object. + * @param[out] out_event Output Event. + */ +Result HolderGetPopInteractiveOutDataEvent(AppletHolder *h, Event **out_event); + +/** + * @brief Waits for the PopInteractiveOutDataEvent and StateChangedEvent. + * @return false for error / when StateChangedEvent was signaled, and true when PopInteractiveOutDataEvent was signaled. The latter is signaled when a new storage is available with \ref appletHolderPopInteractiveOutData where previously no storage was available (this willl not clear the event), this event is automatically cleared by the system once the last storage is popped. + * @param h AppletHolder object. + */ +bool HolderWaitInteractiveOut(AppletHolder *h); + +/** + * @brief Pushes a storage for LibraryApplet input. + * @note This uses \ref appletStorageClose automatically. + * @param h AppletHolder object. + * @param[in] s Storage object. + */ +Result HolderPushInData(AppletHolder *h, AppletStorage *s); + +/** + * @brief Pops a storage from LibraryApplet output. + * @param h AppletHolder object. + * @param[out] s Storage object. + */ +Result HolderPopOutData(AppletHolder *h, AppletStorage *s); + +/** + * @brief Pushes a storage for LibraryApplet Extra storage input. + * @note This uses \ref appletStorageClose automatically. + * @param h AppletHolder object. + * @param[in] s Storage object. + */ +Result HolderPushExtraStorage(AppletHolder *h, AppletStorage *s); + +/** + * @brief Pushes a storage for LibraryApplet Interactive input. + * @note This uses \ref appletStorageClose automatically. + * @param h AppletHolder object. + * @param[in] s Storage object. + */ +Result HolderPushInteractiveInData(AppletHolder *h, AppletStorage *s); + +/** + * @brief Pops a storage from LibraryApplet Interactive output. + * @param h AppletHolder object. + * @param[out] s Storage object. + */ +Result HolderPopInteractiveOutData(AppletHolder *h, AppletStorage *s); + +/** + * @brief Gets the \ref LibAppletInfo for the specified LibraryApplet. + * @param h AppletHolder object. + * @param[out] info \ref LibAppletInfo + */ +Result HolderGetLibraryAppletInfo(AppletHolder *h, LibAppletInfo *info); + +/** + * @brief Creates a storage. + * @param s Storage object. + * @param size Size of storage. + */ +Result CreateStorage(AppletStorage *s, s64 size); + +/** + * @brief Creates a TransferMemory storage. + * @param s Storage object. + * @param buffer TransferMemory buffer, will be automatically allocated if NULL. + * @param size Size of storage. + * @param writable Controls whether writing to the storage is allowed with \ref appletStorageWrite. + */ +Result CreateTransferMemoryStorage(AppletStorage *s, void* buffer, s64 size, bool writable); + +/** + * @brief Creates a HandleStorage. + * @note Only available on [2.0.0+]. + * @param s Storage object. + * @param inval Arbitrary input value. + * @param handle Arbitrary input handle. + */ +Result CreateHandleStorage(AppletStorage *s, s64 inval, Handle handle); + +/** + * @brief Creates a HandleStorage using TransferMemory. Wrapper for \ref appletCreateHandleStorage. + * @param s Storage object. + * @param buffer TransferMemory buffer, will be automatically allocated if NULL. + * @param size Size of storage. + */ +Result CreateHandleStorageTmem(AppletStorage *s, void* buffer, s64 size); + +/// Closes the storage object. TransferMemory closing is seperate, see \ref appletStorageCloseTmem. +/// Other applet functions which push an input storage will automatically call this. +void StorageClose(AppletStorage *s); + +/// Closes the TransferMemory in the storage object. For TransferMemory storage created by the current process, this must be called after the LibraryApplet finishes using it (if sent to one). +void StorageCloseTmem(AppletStorage *s); + +/// Gets the size of the storage. This is not usable with HandleStorage, use \ref appletStorageGetHandle or \ref appletStorageMap instead for that. +Result StorageGetSize(AppletStorage *s, s64 *size); + +/** + * @brief Writes to a storage. offset(+size) must be within the actual storage size. + * @note This is not usable with HandleStorage. + * @param s Storage object. + * @param offset Offset in storage. + * @param buffer Input data. + * @param size Data size. + */ +Result StorageWrite(AppletStorage *s, s64 offset, const void* buffer, size_t size); + +/** + * @brief Reads from a storage. offset(+size) must be within the actual storage size. + * @note This is not usable with HandleStorage. + * @param s Storage object. + * @param offset Offset in storage. + * @param buffer Input data. + * @param size Data size. + */ +Result StorageRead(AppletStorage *s, s64 offset, void* buffer, size_t size); + +/** + * @brief Gets data for a HandleStorage originally from \ref appletCreateHandleStorage input. + * @note Only available on [2.0.0+]. + * @param s Storage object. + * @param out Output value. + * @param handle Output handle. + */ +Result StorageGetHandle(AppletStorage *s, s64 *out, Handle *handle); + +/** + * @brief Maps TransferMemory for a HandleStorage. Wrapper for \ref appletCreateHandleStorage. + * @note The TransferMemory can be unmapped with \ref appletStorageCloseTmem. + * @note Do not use this if the AppletStorage already contains initialized TransferMemory state. + * @param s Storage object. + * @param addr Output mapped address (optional). + * @param size Output size (optional). + */ +Result StorageMap(AppletStorage *s, void** addr, size_t *size); + +/** + * @brief Pops a LaunchParameter AppletStorage, the storage will be removed from sysmodule state during this. + * @param[out] s Output storage. + * @param kind See \ref AppletLaunchParameterKind. + * @note Only available with AppletType_*Application. + * @note See also acc.h \ref accountGetPreselectedUser (wrapper for appletPopLaunchParameter etc). + */ +Result PopLaunchParameter(AppletStorage *s, AppletLaunchParameterKind kind); + +/** + * @brief Requests to launch the specified application. + * @note Only available with AppletType_*Application, or AppletType_LibraryApplet on [5.0.0+]. + * @param[in] application_id ApplicationId. Value 0 can be used to relaunch the current application. + * @param[in] s Optional AppletStorage object, can be NULL. This is automatically closed. When NULL on pre-4.0.0 (or with AppletType_LibraryApplet), this will internally create a tmp storage with size 0 for use with the cmd. This is the storage available to the launched application via \ref appletPopLaunchParameter with ::AppletLaunchParameterKind_UserChannel. + */ +Result RequestLaunchApplication(u64 application_id, AppletStorage* s); + +/** + * @brief Requests to launch the specified application, for kiosk systems. + * @note Only available with AppletType_*Application on [3.0.0+]. + * @note Identical to \ref appletRequestLaunchApplication, except this allows the user to specify the attribute fields instead of the defaults being used. + * @param[in] application_id ApplicationId + * @param[in] s Optional AppletStorage object, can be NULL. This is automatically closed. When NULL on pre-4.0.0, this will internally create a tmp storage with size 0 for use with the cmd. This is the storage available to the launched application via \ref appletPopLaunchParameter with ::AppletLaunchParameterKind_UserChannel. + * @param[in] attr Kiosk application attributes. + */ +Result RequestLaunchApplicationForQuest(u64 application_id, AppletStorage* s, const AppletApplicationAttributeForQuest *attr); + +/** + * @brief Gets the DesiredLanguage for the current host application control.nacp. + * @note Only available with AppletType_*Application. + * @param[out] LanguageCode Output LanguageCode, see set.h. + */ +Result GetDesiredLanguage(u64 *LanguageCode); + +/** + * @brief Gets the DisplayVersion for the current host application control.nacp. + * @note Only available with AppletType_*Application. + * @param[out] displayVersion Output DisplayVersion string, must be at least 0x10-bytes. This is always NUL-terminated. + */ +Result GetDisplayVersion(char *displayVersion); + +/** + * @brief Blocks the usage of the home button, for short (Home Menu) and long (Overlay) presses. + * @note Only available with AppletType_*Application. + * @param val Unknown. Official sw only uses hard-coded value 0 for this. + */ +Result BeginBlockingHomeButtonShortAndLongPressed(s64 val); + +/** + * @brief Ends the blocking started by \ref appletBeginBlockingHomeButtonShortAndLongPressed. + * @note Only available with AppletType_*Application. + */ +Result EndBlockingHomeButtonShortAndLongPressed(void); + +/** + * @brief Blocks the usage of the home button, for short presses (Home Menu). + * @note Only available with AppletType_*Application. + * @param val Unknown nanoseconds. Value 0 can be used. + */ +Result BeginBlockingHomeButton(s64 val); + +/** + * @brief Ends the blocking started by \ref appletBeginBlockingHomeButton. + * @note Only available with AppletType_*Application. + */ +Result EndBlockingHomeButton(void); + +/** + * @brief Notify that the app is now running, for the Application logo screen. This throws a fatal-error on failure. + * @note This will just return when applet-type isn't AppletType_Application, or when this was already used previously. Used automatically by \ref appletInitialize when __nx_applet_auto_notifyrunning is set to true (the default value). + */ +void NotifyRunning(bool *out); + +/** + * @brief Gets the PseudoDeviceId. This is derived from the output of a ns command, and from data in the host application control.nacp. + * @note Only available with AppletType_*Application on [2.0.0+]. + * @param[out] out Output PseudoDeviceId. + */ +Result GetPseudoDeviceId(Uuid *out); + +/// Set media playback state. +/// If state is set to true, screen dimming and auto sleep is disabled. +/// For *Application, this uses cmd SetMediaPlaybackStateForApplication, otherwise cmd SetMediaPlaybackState is used. +Result SetMediaPlaybackState(bool state); + +/// Gets whether video recording is supported. +/// See also \ref appletInitializeGamePlayRecording. +Result IsGamePlayRecordingSupported(bool *flag); + +/// Disable/enable video recording. Only available after \ref appletInitializeGamePlayRecording was used. +/// See also \ref appletInitializeGamePlayRecording. +Result SetGamePlayRecordingState(bool state); + +/// Initializes video recording. This allocates a 0x6000000-byte buffer for the TransferMemory, cleanup is handled automatically during app exit in \ref appletExit. +/// Only available with AppletType_Application on [3.0.0+], hence errors from this can be ignored. +/// Video recording is only fully available system-side with [4.0.0+]. +/// Only usable when running under an application which supports video recording. Using this is only needed when the host application control.nacp has VideoCaptureMode set to Enabled, with Automatic appletInitializeGamePlayRecording is not needed. +Result InitializeGamePlayRecording(void); + +/** + * @brief Requests to save the video recording, as if the Capture-button was held. + * @note Only available with AppletType_*Application on [4.0.0+]. + */ +Result RequestFlushGamePlayingMovieForDebug(void); + +/** + * @brief Requests a system shutdown. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_*Application on [3.0.0+]. + */ +Result RequestToShutdown(void); + +/** + * @brief Requests a system reboot. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_*Application on [3.0.0+]. + */ +Result RequestToReboot(void); + +/** + * @brief RequestToSleep + * @note Only available with AppletType_*Application on [10.0.0+]. + */ +Result RequestToSleep(void); + +/** + * @brief Exit the application and return to the kiosk demo menu. This terminates the current process. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_*Application on [4.0.0+], on kiosk systems (QuestFlag set). + */ +Result ExitAndRequestToShowThanksMessage(void); + +/** + * @brief Initializes the ApplicationCopyrightFrameBuffer, with dimensions 1280x720 + the tmem for it. This is used as an overlay for screenshots. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @note Cleanup for this is handled automatically during app exit in \ref appletExit. + */ +Result InitializeApplicationCopyrightFrameBuffer(void); + +/** + * @brief Sets the RGBA8 image for use with \ref appletInitializeApplicationCopyrightFrameBuffer. Overrides the current image, if this was already used previously. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @note The specified coordinates and width/height must be within the bounds of the framebuffer setup by \ref appletInitializeApplicationCopyrightFrameBuffer. + * @param[in] buffer Input image buffer. + * @param[in] size Input image buffer size. + * @param[in] x X coordinate. Must not be negative. + * @param[in] y Y coordinate. Must not be negative. + * @param[in] width Image width. Must be >=1. + * @param[in] height Image height. Must be >=1. + * @param[in] mode \ref AppletWindowOriginMode + */ +Result SetApplicationCopyrightImage(const void* buffer, size_t size, s32 x, s32 y, s32 width, s32 height, AppletWindowOriginMode mode); + +/** + * @brief Sets the visibility for the image set by \ref appletSetApplicationCopyrightImage, in screenshots. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @param[in] visible Whether the image is visible. The default is true. + */ +Result SetApplicationCopyrightVisibility(bool visible); + +/** + * @brief Gets ApplicationPlayStatistics. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @note The input ApplicationIds must be allowed via control.nacp with the current host application. The minimum allowed ApplicationId is the ApplicationId for the current application. + * @param stats Output \ref PdmApplicationPlayStatistics array. + * @param application_ids Input ApplicationIds array. + * @param count Total entries in the input/output arrays. + * @param total_out Total output entries. + */ +Result QueryApplicationPlayStatistics(PdmApplicationPlayStatistics *stats, const u64 *application_ids, s32 count, s32 *total_out); + +/** + * @brief Same as \ref appletQueryApplicationPlayStatistics except this gets playstats specific to the input userId. + * @note Only available with AppletType_*Application on [6.0.0+]. + * @param[in] uid \ref AccountUid + * @param[out] stats Output \ref PdmApplicationPlayStatistics array. + * @param[in] application_ids Input ApplicationIds array. + * @param[in] count Total entries in the input/output arrays. + * @param[out] total_out Total output entries. + */ +Result QueryApplicationPlayStatisticsByUid(AccountUid uid, PdmApplicationPlayStatistics *stats, const u64 *application_ids, s32 count, s32 *total_out); + +/** + * @brief Launches Application {current_ApplicationId}+programIndex. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @note Creates the storage if needed. Uses cmd ClearUserChannel. Uses cmd UnpopToUserChannel when the storage was created. Lastly cmd ExecuteProgramCmd is used. + * @param[in] programIndex ProgramIndex, must be 0x0-0xFF. 0 is the same as the current application. ProgramIndex values where the application is not installed should not be used. + * @param[in] buffer Optional buffer containing the storage data which will be used for ::AppletLaunchParameterKind_UserChannel with the launched Application, can be NULL. + * @param[in] size Size of the above buffer, 0 to not use the storage. Must be <=0x1000. + */ +Result ExecuteProgram(s32 programIndex, const void* buffer, size_t size); + +/** + * @brief Launches the specified ApplicationId. + * @note Only available with AppletType_*Application on [5.0.0+], with DebugMode enabled. + * @note Creates the storage if needed. Uses cmd ClearUserChannel. Uses cmd UnpopToUserChannel when the storage was created. Lastly cmd ExecuteProgramCmd is used. + * @param[in] application_id ApplicationId. + * @param[in] buffer Optional buffer containing the storage data which will be used for ::AppletLaunchParameterKind_UserChannel with the launched Application, can be NULL. + * @param[in] size Size of the above buffer, 0 to not use the storage. Must be <=0x1000. + */ +Result JumpToSubApplicationProgramForDevelopment(u64 application_id, const void* buffer, size_t size); + +/** + * @brief Relaunches the current Application. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @note Creates the storage if needed. Uses cmd ClearUserChannel. Uses cmd UnpopToUserChannel when the storage was created. Lastly cmd ExecuteProgramCmd is used. + * @param[in] buffer Optional buffer containing the storage data which will be used for ::AppletLaunchParameterKind_UserChannel with the launched Application, can be NULL. + * @param[in] size Size of the above buffer, 0 to not use the storage. Must be <=0x1000. + */ +Result RestartProgram(const void* buffer, size_t size); + +/** + * @brief Gets the ProgramIndex of the program which launched this program. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @param[out] programIndex ProgramIndex, -1 when there was no previous program. + */ +Result GetPreviousProgramIndex(s32 *programIndex); + +/** + * @brief SetDelayTimeToAbortOnGpuError + * @note Only available with AppletType_*Application on [11.0.0+]. + * @param[in] val Input nanoseconds value. + */ +Result SetDelayTimeToAbortOnGpuError(u64 val); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletTryPopFromFriendInvitationStorageChannel where previously no storage was available, this event is automatically cleared by the system once the last storage is popped. + * @note This is used by \ref friendsGetFriendInvitationNotificationEvent. + * @note Only available with AppletType_*Application on [9.0.0+]. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetFriendInvitationStorageChannelEvent(Event *out_event); + +/** + * @brief Pops a storage from the FriendInvitation StorageChannel. + * @note This is used by \ref friendsTryPopFriendInvitationNotificationInfo. + * @note Only available with AppletType_*Application on [9.0.0+]. + * @param[out] s Storage object. + */ +Result TryPopFromFriendInvitationStorageChannel(AppletStorage *s); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletTryPopFromNotificationStorageChannel where previously no storage was available, this event is automatically cleared by the system once the last storage is popped. + * @note This is used by \ref notifGetNotificationSystemEvent. + * @note Only available with AppletType_*Application on [9.0.0+]. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetNotificationStorageChannelEvent(Event *out_event); + +/** + * @brief Pops a storage from the Notification StorageChannel. + * @note This is used by \ref notifTryPopNotifiedApplicationParameter. + * @note Only available with AppletType_*Application on [9.0.0+]. + * @param[out] s Storage object. + */ +Result TryPopFromNotificationStorageChannel(AppletStorage *s); + +/** + * @brief GetHealthWarningDisappearedSystemEvent + * @note Only available with AppletType_*Application on [9.0.0+]. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetHealthWarningDisappearedSystemEvent(Event *out_event); + +/** + * @brief SetHdcpAuthenticationActivated + * @note Only available with AppletType_*Application on [9.0.0+]. + * @param[in] flag Whether HdcpAuthentication is activated. + */ +Result SetHdcpAuthenticationActivated(bool flag); + +/** + * @brief GetLastApplicationExitReason + * @note Only available with AppletType_*Application on [11.0.0+]. + * @param[out] out Output value. + */ +Result GetLastApplicationExitReason(s32 *out); + +/** + * @brief CreateMovieMaker. Do not use this directly, use \ref grcCreateMovieMaker instead. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @param[out] srv_out Output Service for applet IMovieMaker. + * @param[in] tmem TransferMemory + */ +Result CreateMovieMaker(Service* srv_out, TransferMemory *tmem); + +/** + * @brief Launches the jit-sysmodule when it was not previously launched by this cmd. Returns 0 when it was previously launched. + * @note Only available with AppletType_*Application on [5.0.0+]. + * @note Requires the jit-sysmodule to actually be installed. + */ +Result PrepareForJit(void); + +/** + * @brief RequestToGetForeground + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet. + */ +Result RequestToGetForeground(void); + +/** + * @brief LockForeground + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet. + */ +Result LockForeground(void); + +/** + * @brief UnlockForeground + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet. + */ +Result UnlockForeground(void); + +/** + * @brief Pops a storage from the general channel. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet. + * @param[out] s Storage object. + */ +Result PopFromGeneralChannel(AppletStorage *s); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletPopFromGeneralChannel where previously no storage was available, this event is automatically cleared by the system once the last storage is popped. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetPopFromGeneralChannelEvent(Event *out_event); + +/** + * @brief Gets a \ref AppletLockAccessor for HomeButtonWriter. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet. + * @note Similar to using \ref appletGetWriterLockAccessorEx with inval=0. + * @param a LockAccessor object. + */ +Result GetHomeButtonWriterLockAccessor(AppletLockAccessor *a); + +/** + * @brief IsSleepEnabled + * @note Only available with AppletType_SystemApplet on [11.0.0+], or on [15.0.0+] with AppletType_LibraryApplet. + * @param[out] out Output flag. + */ +Result IsSleepEnabled(bool *out); + +/** + * @brief PopRequestLaunchApplicationForDebug + * @note Only available with AppletType_SystemApplet on [6.0.0+], or on [15.0.0+] with AppletType_LibraryApplet. + * @param[out] uids Output array of \ref AccountUid. + * @param[in] count Size of the uids array in entries, must be at least the size stored in state. + * @param[out] application_id Output ApplicationId. + * @param[out] total_out Total output userID entries. + */ +Result PopRequestLaunchApplicationForDebug(AccountUid *uids, s32 count, u64 *application_id, s32 *total_out); + +/** + * @brief IsForceTerminateApplicationDisabledForDebug + * @note Only available with AppletType_SystemApplet on [9.0.0+], or on [15.0.0+] with AppletType_LibraryApplet. + * @param[out] out Output flag. 0 when DebugMode is not enabled, otherwise this is loaded from a system-setting. + */ +Result IsForceTerminateApplicationDisabledForDebug(bool *out); + +/** + * @brief Launches DevMenu and the dev Overlay-applet. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_SystemApplet on [8.0.0+], or on [15.0.0+] with AppletType_LibraryApplet. + * @note This verifies that DebugMode is enabled, then uses a ns cmd. That cmd then loads the system-settings for these two ProgramIds (which normally only exist on devunits), and verifies that these programs are installed + launches them. + */ +Result LaunchDevMenu(void); + +/** + * @brief SetLastApplicationExitReason + * @note Only available with AppletType_SystemApplet on [11.0.0+], or on [15.0.0+] with AppletType_LibraryApplet. + * @param[in] reason Reason + */ +Result SetLastApplicationExitReason(s32 reason); + +/** + * @brief Start the sequence for entering sleep-mode. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + * @param[in] flag Flag, official sw uses hard-coded value = true. + */ +Result StartSleepSequence(bool flag); + +/** + * @brief Start the system-shutdown sequence. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + */ +Result StartShutdownSequence(void); + +/** + * @brief Start the system-reboot sequence. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + */ +Result StartRebootSequence(void); + +/** + * @brief IsAutoPowerDownRequested. Uses an idle:sys cmd internally. + * @note Only available with AppletType_SystemApplet on [7.0.0+], or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + * @param[out] out Output flag. + */ +Result IsAutoPowerDownRequested(bool *out); + +/** + * @brief LoadAndApplyIdlePolicySettings. Uses an idle:sys cmd internally. + * @note Only available with AppletType_SystemApplet, or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + */ +Result LoadAndApplyIdlePolicySettings(void); + +/** + * @brief NotifyCecSettingsChanged. Uses an omm cmd internally. + * @note Only available with AppletType_SystemApplet on [2.0.0+], or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + */ +Result NotifyCecSettingsChanged(void); + +/** + * @brief Sets the DefaultHomeButtonLongPressTime. + * @note Only available with AppletType_SystemApplet on [3.0.0+], or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + * @param[in] val Input value. + */ +Result SetDefaultHomeButtonLongPressTime(s64 val); + +/** + * @brief UpdateDefaultDisplayResolution. Uses an omm cmd internally. + * @note Only available with AppletType_SystemApplet on [3.0.0+], or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + */ +Result UpdateDefaultDisplayResolution(void); + +/** + * @brief ShouldSleepOnBoot. Uses an omm cmd internally. + * @note Only available with AppletType_SystemApplet on [3.0.0+], or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + * @param[out] out Output flag. + */ +Result ShouldSleepOnBoot(bool *out); + +/** + * @brief Gets an Event which is signaled for HdcpAuthenticationFailed. + * @note Only available with AppletType_SystemApplet on [4.0.0+], or on [15.0.0+] with AppletType_LibraryApplet/AppletType_OverlayApplet. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetHdcpAuthenticationFailedEvent(Event *out_event); + +/** + * @brief Creates an Application. + * @note Only available with AppletType_SystemApplet. + * @param[out] a \ref AppletApplication + * @param[in] application_id ApplicationId. + */ +Result CreateApplication(AppletApplication *a, u64 application_id); + +/** + * @brief Pops a \ref AppletApplication for a requested Application launch. + * @note Only available with AppletType_SystemApplet. + * @param[out] a \ref AppletApplication + */ +Result PopLaunchRequestedApplication(AppletApplication *a); + +/** + * @brief Creates a SystemApplication. + * @note Only available with AppletType_SystemApplet. + * @param[out] a \ref AppletApplication + * @param[in] system_application_id SystemApplicationId. + */ +Result CreateSystemApplication(AppletApplication *a, u64 system_application_id); + +/** + * @brief PopFloatingApplicationForDevelopment. + * @note Only available with AppletType_SystemApplet. Should not be used if no FloatingApplication is available. + * @param[out] a \ref AppletApplication + */ +Result PopFloatingApplicationForDevelopment(AppletApplication *a); + +/** + * @brief Close an \ref AppletApplication. + * @param a \ref AppletApplication + */ +void ApplicationClose(AppletApplication *a); + +/** + * @brief Returns whether the AppletApplication object was initialized. + * @param a \ref AppletApplication + */ +bool ApplicationActive(AppletApplication *a); + +/** + * @brief Starts the Application. + * @param a \ref AppletApplication + */ +Result ApplicationStart(AppletApplication *a); + +/** + * @brief Requests the Application to exit. + * @param a \ref AppletApplication + */ +Result ApplicationRequestExit(AppletApplication *a); + +/** + * @brief Terminate the Application. + * @param a \ref AppletApplication + */ +Result ApplicationTerminate(AppletApplication *a); + +/** + * @brief Waits for the Application to exit. + * @param a \ref AppletApplication + */ +void ApplicationJoin(AppletApplication *a); + +/** + * @brief Waits on the Application StateChangedEvent with timeout=0, and returns whether it was successful. + * @param a \ref AppletApplication + */ +bool ApplicationCheckFinished(AppletApplication *a); + +/** + * @brief Gets the \ref AppletApplicationExitReason set by \ref appletApplicationJoin. + * @param a \ref AppletApplication + */ +AppletApplicationExitReason ApplicationGetExitReason(AppletApplication *a); + +/** + * @brief RequestForApplicationToGetForeground. + * @param a \ref AppletApplication + */ +Result ApplicationRequestForApplicationToGetForeground(AppletApplication *a); + +/** + * @brief TerminateAllLibraryApplets which were created by the Application. + */ +Result ApplicationTerminateAllLibraryApplets(AppletApplication *a); + +/** + * @brief AreAnyLibraryAppletsLeft which were created by the Application. + * @param a \ref AppletApplication + * @param[out] out Output flag. + */ +Result ApplicationAreAnyLibraryAppletsLeft(AppletApplication *a, bool *out); + +/** + * @brief Calls the same func as \ref appletHolderRequestExitOrTerminate with the output IAppletAccessor from the GetCurrentLibraryApplet cmd. + * @param a \ref AppletApplication + * @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout. + */ +Result ApplicationRequestExitLibraryAppletOrTerminate(AppletApplication *a, u64 timeout); + +/** + * @brief Gets the ApplicationId for the Application. + * @param a \ref AppletApplication + * @param[out] application_id Output ApplicationId. + */ +Result ApplicationGetApplicationId(AppletApplication *a, u64 *application_id); + +/** + * @brief Pushes a LaunchParameter AppletStorage to the Application. + * @note This uses \ref appletStorageClose automatically. + * @param a \ref AppletApplication + * @param[in] kind \ref AppletLaunchParameterKind + * @param[in] s Input storage. + */ +Result ApplicationPushLaunchParameter(AppletApplication *a, AppletLaunchParameterKind kind, AppletStorage* s); + +/** + * @brief Gets the \ref NacpStruct for the Application. + * @note Not usable when the \ref AppletApplication is for an AppletType_SystemApplication. + * @param a \ref AppletApplication + * @param[out] nacp \ref NacpStruct + */ +Result ApplicationGetApplicationControlProperty(AppletApplication *a, NacpStruct *nacp); + +/** + * @brief Gets the \ref AppletApplicationLaunchProperty for the Application. + * @note Only available on [2.0.0+]. Not usable when the \ref AppletApplication is for an AppletType_SystemApplication. + * @param a \ref AppletApplication + * @param[out] out \ref AppletApplicationLaunchProperty + */ +Result ApplicationGetApplicationLaunchProperty(AppletApplication *a, AppletApplicationLaunchProperty *out); + +/** + * @brief Gets the \ref AppletApplicationLaunchRequestInfo for the Application. + * @note Only available on [6.0.0+]. + * @param a \ref AppletApplication + * @param[out] out \ref AppletApplicationLaunchRequestInfo + */ +Result ApplicationGetApplicationLaunchRequestInfo(AppletApplication *a, AppletApplicationLaunchRequestInfo *out); + +/** + * @brief SetUsers for the Application. + * @note Only available on [6.0.0+]. + * @param a \ref AppletApplication + * @param[in] uids Input array of \ref AccountUid. + * @param[in] count Size of the uids array in entries, must be <=ACC_USER_LIST_SIZE. + * @param[in] flag When this flag is true, this just clears the users_available state flag to 0 and returns. + */ +Result ApplicationSetUsers(AppletApplication *a, const AccountUid *uids, s32 count, bool flag); + +/** + * @brief CheckRightsEnvironmentAvailable. + * @note Only available on [6.0.0+]. + * @param a \ref AppletApplication + * @param[out] out Output flag. + */ +Result ApplicationCheckRightsEnvironmentAvailable(AppletApplication *a, bool *out); + +/** + * @brief GetNsRightsEnvironmentHandle. + * @note Only available on [6.0.0+]. + * @param a \ref AppletApplication + * @param[out] handle Output NsRightsEnvironmentHandle. + */ +Result ApplicationGetNsRightsEnvironmentHandle(AppletApplication *a, u64 *handle); + +/** + * @brief Gets an array of userIds for the Application DesirableUids. + * @note Only available on [6.0.0+]. + * @note qlaunch only uses 1 userId with this. + * @param a \ref AppletApplication + * @param[out] uids Output array of \ref AccountUid. + * @param[in] count Size of the uids array in entries, must be at least the size stored in state. + * @param[out] total_out Total output entries. + */ +Result ApplicationGetDesirableUids(AppletApplication *a, AccountUid *uids, s32 count, s32 *total_out); + +/** + * @brief ReportApplicationExitTimeout. + * @note Only available on [6.0.0+]. + * @param a \ref AppletApplication + */ +Result ApplicationReportApplicationExitTimeout(AppletApplication *a); + +/** + * @brief Sets the \ref AppletApplicationAttribute for the Application. + * @note Only available on [8.0.0+]. + * @param a \ref AppletApplication + * @param[in] attr \ref AppletApplicationAttribute + */ +Result ApplicationSetApplicationAttribute(AppletApplication *a, const AppletApplicationAttribute *attr); + +/** + * @brief Gets whether the savedata specified by the input ApplicationId is accessible. + * @note Only available on [8.0.0+]. + * @param a \ref AppletApplication + * @param[in] application_id ApplicationId for the savedata. + * @param[out] out Output flag. + */ +Result ApplicationHasSaveDataAccessPermission(AppletApplication *a, u64 application_id, bool *out); + +/** + * @brief Creates a storage using the specified input then pushes it to the FriendInvitation StorageChannel. + * @note The system will clear the StorageChannel before pushing the storage. + * @note Only available on [9.0.0+]. + * @param a \ref AppletApplication + * @param[in] uid \ref AccountUid + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + */ +Result ApplicationPushToFriendInvitationStorageChannel(AppletApplication *a, AccountUid uid, const void* buffer, u64 size); + +/** + * @brief Creates a storage using the specified input then pushes it to the Notification StorageChannel. + * @note The system will clear the StorageChannel before pushing the storage. + * @note Only available on [9.0.0+]. + * @param a \ref AppletApplication + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + */ +Result ApplicationPushToNotificationStorageChannel(AppletApplication *a, const void* buffer, u64 size); + +/** + * @brief RequestApplicationSoftReset + * @note Only available on [10.0.0+]. + * @param a \ref AppletApplication + */ +Result ApplicationRequestApplicationSoftReset(AppletApplication *a); + +/** + * @brief RestartApplicationTimer + * @note Only available on [10.0.0+]. + * @param a \ref AppletApplication + */ +Result ApplicationRestartApplicationTimer(AppletApplication *a); + +/** + * @brief Pops a storage from current-LibraryApplet input. + * @note Only available with AppletType_LibraryApplet. + * @param[out] s Storage object. + */ +Result PopInData(AppletStorage *s); + +/** + * @brief Pushes a storage for current-LibraryApplet output. + * @note Only available with AppletType_LibraryApplet. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result PushOutData(AppletStorage *s); + +/** + * @brief Pops a storage from current-LibraryApplet Interactive input. + * @note Only available with AppletType_LibraryApplet. + * @param[out] s Storage object. + */ +Result PopInteractiveInData(AppletStorage *s); + +/** + * @brief Pushes a storage for current-LibraryApplet Interactive output. + * @note Only available with AppletType_LibraryApplet. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result PushInteractiveOutData(AppletStorage *s); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletPopInData where previously no storage was available, this event is automatically cleared by the system once the last storage is popped. + * @note Only available with AppletType_LibraryApplet. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetPopInDataEvent(Event *out_event); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletPopInteractiveInData where previously no storage was available, this event is automatically cleared by the system once the last storage is popped. + * @note Only available with AppletType_LibraryApplet. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetPopInteractiveInDataEvent(Event *out_event); + +/** + * @brief Gets the \ref LibAppletInfo for the current LibraryApplet. + * @note Only available with AppletType_LibraryApplet. + * @param[out] info \ref LibAppletInfo + */ +Result GetLibraryAppletInfo(LibAppletInfo *info); + +/** + * @brief Gets the \ref AppletIdentityInfo for the MainApplet. + * @note Only available with AppletType_LibraryApplet. + * @param[out] info \ref AppletIdentityInfo + */ +Result GetMainAppletIdentityInfo(AppletIdentityInfo *info); + +/** + * @brief CanUseApplicationCore + * @note Only available with AppletType_LibraryApplet. + * @param[out] out Output flag. + */ +Result CanUseApplicationCore(bool *out); + +/** + * @brief Gets the \ref AppletIdentityInfo for the CallerApplet. + * @note Only available with AppletType_LibraryApplet. + * @param[out] info \ref AppletIdentityInfo + */ +Result GetCallerAppletIdentityInfo(AppletIdentityInfo *info); + +/** + * @brief Gets the \ref NacpStruct for the MainApplet. + * @note Only available with AppletType_LibraryApplet on [2.0.0+]. + * @param[out] nacp \ref NacpStruct + */ +Result GetMainAppletApplicationControlProperty(NacpStruct *nacp); + +/** + * @brief Gets the NcmStorageId for the MainApplet. + * @note Only available with AppletType_LibraryApplet on [2.0.0+]. + * @param[out] storageId \ref NcmStorageId + */ +Result GetMainAppletStorageId(NcmStorageId *storageId); + +/** + * @brief Gets an array of \ref AppletIdentityInfo for the CallerStack. + * @note Only available with AppletType_LibraryApplet on [3.0.0+]. + * @param[out] stack Output array of \ref AppletIdentityInfo. + * @param[in] count Size of the stack array. + * @param[out] total_out Total output entries. + */ +Result GetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 count, s32 *total_out); + +/** + * @brief Gets the \ref AppletIdentityInfo for the NextReturnDestinationApplet. + * @note Only available with AppletType_LibraryApplet on [4.0.0+]. + * @param[out] info \ref AppletIdentityInfo + */ +Result GetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info); + +/** + * @brief Gets the DesirableKeyboardLayout previously set by \ref appletSetDesirableKeyboardLayout. An error is returned when it's not set. + * @note Only available with AppletType_LibraryApplet on [4.0.0+]. + * @param[out] layout Output \ref SetKeyboardLayout. + */ +Result GetDesirableKeyboardLayout(SetKeyboardLayout *layout); + +/** + * @brief Pops a storage from current-LibraryApplet Extra input. + * @note Only available with AppletType_LibraryApplet. + * @param[out] s Storage object. + */ +Result PopExtraStorage(AppletStorage *s); + +/** + * @brief Gets an Event which is signaled when a new storage is available with \ref appletPopExtraStorage where previously no storage was available, this event is automatically cleared by the system once the last storage is popped. + * @note Only available with AppletType_LibraryApplet. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetPopExtraStorageEvent(Event *out_event); + +/** + * @brief Unpop a storage for current-LibraryApplet input. + * @note Only available with AppletType_LibraryApplet. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result UnpopInData(AppletStorage *s); + +/** + * @brief Unpop a storage for current-LibraryApplet Extra input. + * @note Only available with AppletType_LibraryApplet. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result UnpopExtraStorage(AppletStorage *s); + +/** + * @brief Gets the IndirectLayerProducerHandle. + * @note Only available with AppletType_LibraryApplet on [2.0.0+]. + * @param[out] out Output IndirectLayerProducerHandle. + */ +Result GetIndirectLayerProducerHandle(u64 *out); + +/** + * @brief Gets the DesiredLanguage for the MainApplet. + * @note Only available with AppletType_LibraryApplet on [4.0.0+]. + * @param[out] LanguageCode Output LanguageCode, see set.h. + */ +Result GetMainAppletApplicationDesiredLanguage(u64 *LanguageCode); + +/** + * @brief Gets the ApplicationId for the currently running Application. + * @note Only available with AppletType_LibraryApplet on [8.0.0+]. + * @param[out] application_id Output ApplicationId, 0 when no Application is running. + */ +Result GetCurrentApplicationId(u64 *application_id); + +/** + * @brief Exits the current applet. Same as \ref appletHolderRequestExit except this is for the current applet. + * @note Only available with AppletType_LibraryApplet on [6.0.0+]. + */ +Result RequestExitToSelf(void); + +/** + * @brief CreateGameMovieTrimmer. Do not use this directly, use \ref grcTrimGameMovie instead. + * @note Only available with AppletType_LibraryApplet on [4.0.0+]. + * @note See also \ref appletReserveResourceForMovieOperation and \ref appletUnreserveResourceForMovieOperation. + * @param[out] srv_out Output Service for grc IGameMovieTrimmer. + * @param[in] tmem TransferMemory + */ +Result CreateGameMovieTrimmer(Service* srv_out, TransferMemory *tmem); + +/** + * @brief ReserveResourceForMovieOperation. Must be used at some point prior to \ref appletCreateGameMovieTrimmer. + * @note Only available with AppletType_LibraryApplet on [5.0.0+]. + */ +Result ReserveResourceForMovieOperation(void); + +/** + * @brief UnreserveResourceForMovieOperation. Must be used at some point after all finished with GameMovieTrimmer usage (\ref appletCreateGameMovieTrimmer). + * @note Only available with AppletType_LibraryApplet on [5.0.0+]. + */ +Result UnreserveResourceForMovieOperation(void); + +/** + * @brief Gets an array of userIds for the MainApplet AvailableUsers. + * @note Only available with AppletType_LibraryApplet on [6.0.0+]. + * @param[out] uids Output array of \ref AccountUid. + * @param[in] count Size of the uids array in entries, must be at least ACC_USER_LIST_SIZE. + * @param[out] flag When true, this indicates that no users are available. + * @param[out] total_out Total output entries. This is -1 when flag is true. + */ +Result GetMainAppletAvailableUsers(AccountUid *uids, s32 count, bool *flag, s32 *total_out); + +/** + * @brief SetApplicationMemoryReservation + * @note Only available with AppletType_LibraryApplet on [10.0.0+]. + * @note An Application must be currently running. + * @param[in] val Input value. + */ +Result SetApplicationMemoryReservation(u64 val); + +/** + * @brief ShouldSetGpuTimeSliceManually + * @note Only available with AppletType_LibraryApplet on [10.0.0+]. + * @param[out] out Output flag. + */ +Result ShouldSetGpuTimeSliceManually(bool *out); + +/** + * @brief Stops forwarding the input to the foreground app. + * @note Only available with AppletType_OverlayApplet. + * @note You have to call this to receive inputs through the hid service when running as the overlay applet. + */ +Result BeginToWatchShortHomeButtonMessage(void); + +/** + * @brief Forwards input to the foreground app. + * @note Only available with AppletType_OverlayApplet. + * @note After calling this the overlay applet won't receive any input until \ref appletBeginToWatchShortHomeButtonMessage is called again. + */ +Result EndToWatchShortHomeButtonMessage(void); + +/** + * @brief Gets the ApplicationId for displaying the logo screen during application launch. + * @note Only available with AppletType_OverlayApplet. + * @param[out] application_id Output ApplicationId, 0 when no application is running. + */ +Result GetApplicationIdForLogo(u64 *application_id); + +/** + * @brief Sets the GpuTimeSliceBoost. + * @note Only available with AppletType_OverlayApplet. + * @param[in] val Input value. + */ +Result SetGpuTimeSliceBoost(u64 val); + +/** + * @brief Sets AutoSleepTimeAndDimmingTimeEnabled. + * @note Only available with AppletType_OverlayApplet on [2.0.0+]. + * @param[in] flag Flag + */ +Result SetAutoSleepTimeAndDimmingTimeEnabled(bool flag); + +/** + * @brief TerminateApplicationAndSetReason + * @note Only available with AppletType_OverlayApplet on [2.0.0+]. + * @param[in] reason Result reason. + */ +Result TerminateApplicationAndSetReason(Result reason); + +/** + * @brief Sets ScreenShotPermissionGlobally. + * @note Only available with AppletType_OverlayApplet on [3.0.0+]. + * @param[in] flag Flag + */ +Result SetScreenShotPermissionGlobally(bool flag); + +/** + * @brief Start the system-shutdown sequence. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_OverlayApplet on [6.0.0+]. + */ +Result StartShutdownSequenceForOverlay(void); + +/** + * @brief Start the system-reboot sequence. This will enter an infinite-sleep-loop on success. + * @note Only available with AppletType_OverlayApplet on [6.0.0+]. + */ +Result StartRebootSequenceForOverlay(void); + +/** + * @brief SetHealthWarningShowingState + * @note Only available with AppletType_OverlayApplet on [9.0.0+]. + * @param[in] flag Flag + */ +Result SetHealthWarningShowingState(bool flag); + +/** + * @brief IsHealthWarningRequired + * @note Only available with AppletType_OverlayApplet on [10.0.0+]. + * @param[out] out Output flag. + */ +Result IsHealthWarningRequired(bool *out); + +/** + * @brief Enables HID input for the OverlayApplet, without disabling input for the foreground applet. Generally \ref appletBeginToWatchShortHomeButtonMessage / appletEndToWatchShortHomeButtonMessage should be used instead. + * @note Only available with AppletType_OverlayApplet on [5.0.0+]. + */ +Result BeginToObserveHidInputForDevelop(void); + +/** + * @brief Reads the ThemeStorage for the current applet. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [7.0.0+]. + * @note offset(+size) must be <=0x400. + * @param[out] buffer Output buffer data. + * @param[in] size Size to read. + * @param[in] offset Offset within the ThemeStorage. + * @param[out] transfer_size Actual read size. + */ +Result ReadThemeStorage(void* buffer, size_t size, u64 offset, u64 *transfer_size); + +/** + * @brief Writes the ThemeStorage for the current applet. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [7.0.0+]. + * @note offset(+size) must be <=0x400. + * @param[in] buffer Input buffer data. + * @param[in] size Size to write. + * @param[in] offset Offset within the ThemeStorage. + */ +Result WriteThemeStorage(const void* buffer, size_t size, u64 offset); + +/** + * @brief This is similar to \ref appletPushToAppletBoundChannelForDebug (no DebugMode check), except the used channel is loaded from elsewhere and must be in the range 31-32. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [9.0.0+]. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + */ +Result PushToAppletBoundChannel(AppletStorage *s); + +/** + * @brief This is similar to \ref appletTryPopFromAppletBoundChannelForDebug (no DebugMode check), except the used channel is loaded from elsewhere and must be in the range 31-32. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [9.0.0+]. + * @param[out] s Storage object. + */ +Result TryPopFromAppletBoundChannel(AppletStorage *s); + +/** + * @brief Gets the DisplayLogicalResolution. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [8.0.0+]. + * @param[out] width Output width. + * @param[out] height Output height. + */ +Result GetDisplayLogicalResolution(s32 *width, s32 *height); + +/** + * @brief Sets the DisplayMagnification. This is essentially layer image crop, for everything non-Overlay. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [8.0.0+]. + * @note x and width are multiplied with the same width value returned by \ref appletGetDisplayLogicalResolution, so these should be in the range 0.0f-1.0f. Likewise for y and height, except these are multipled with the height value. + * @param[in] x X position. + * @param[in] y Y position. + * @param[in] width Width. + * @param[in] height Height. + */ +Result SetDisplayMagnification(float x, float y, float width, float height); + +/** + * @brief Sets whether HomeButtonDoubleClick is enabled. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [8.0.0+]. + * @param[in] flag Flag + */ +Result SetHomeButtonDoubleClickEnabled(bool flag); + +/** + * @brief Gets whether HomeButtonDoubleClick is enabled. + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [8.0.0+]. + * @param[out] out Output flag. + */ +Result GetHomeButtonDoubleClickEnabled(bool *out); + +/** + * @brief IsHomeButtonShortPressedBlocked + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [10.0.0+]. + * @param[out] out Output flag. + */ +Result IsHomeButtonShortPressedBlocked(bool *out); + +/** + * @brief IsVrModeCurtainRequired + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [11.0.0+]. + * @param[out] out Output flag. + */ +Result IsVrModeCurtainRequired(bool *out); + +/** + * @brief SetCpuBoostRequestPriority + * @note Only available with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [11.0.0+]. + * @param[in] priority Priority + */ +Result SetCpuBoostRequestPriority(s32 priority); + +/** + * @brief Open an \ref AppletApplication for the currently running Application. + * @note Should not be used when no Application is running. + * @note Only available on [1.0.0-9.2.0]. + * @param[out] a \ref AppletApplication + */ +Result OpenMainApplication(AppletApplication *a); + +/** + * @brief Perform SystemButtonPressing with the specified \ref AppletSystemButtonType. + * @param[in] type \ref AppletSystemButtonType + */ +Result PerformSystemButtonPressing(AppletSystemButtonType type); + +/** + * @brief InvalidateTransitionLayer. + */ +Result InvalidateTransitionLayer(void); + +/** + * @brief Requests to launch the specified Application, with the specified users. + * @note Only available on [6.0.0+]. + * @param[in] application_id ApplicationId. + * @param[in] uids Input array of \ref AccountUid. + * @param[in] total_uids Total input uids, must be <=ACC_USER_LIST_SIZE. + * @param[in] flag Whether to use the specified buffer to create a storage which will be pushed for ::AppletLaunchParameterKind_UserChannel. + * @param[in] buffer Buffer containing the above storage data. + * @param[in] size Size of the storage buffer. + */ +Result RequestLaunchApplicationWithUserAndArgumentForDebug(u64 application_id, const AccountUid *uids, s32 total_uids, bool flag, const void* buffer, size_t size); + +/** + * @brief Gets the \ref AppletResourceUsageInfo. + * @note Only available on [6.0.0+]. + * @param[out] info \ref AppletResourceUsageInfo + */ +Result GetAppletResourceUsageInfo(AppletResourceUsageInfo *info); + +/** + * @brief The channel must match the value already stored in state when the state value is non-zero, otherwise an error is returned. When the state value is 0, the channel is written into state. Then the input storage is pushed to the StorageChannel. + * @note Only available on [9.0.0+]. DebugMode must be enabled. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + * @param[in] channel Channel. + */ +Result PushToAppletBoundChannelForDebug(AppletStorage *s, s32 channel); + +/** + * @brief The channel must not be 0 and must match the value previously saved by \ref appletPushToAppletBoundChannelForDebug, otherwise errors are returned. Then the output storage is popped from the StorageChannel. + * @note Only available on [9.0.0+]. DebugMode must be enabled. + * @param[out] s Storage object. + * @param[in] channel Channel. + */ +Result TryPopFromAppletBoundChannelForDebug(AppletStorage *s, s32 channel); + +/** + * @brief Clears a StorageChannel, pushes the input storage there, and writes the ApplicationId into state. + * @note Only available on [9.0.0+]. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + * @param[in] application_id ApplicationId + */ +Result AlarmSettingNotificationEnableAppEventReserve(AppletStorage *s, u64 application_id); + +/** + * @brief Clears the StorageChannel/saved-ApplicationId used by \ref appletAlarmSettingNotificationEnableAppEventReserve. + * @note Only available on [9.0.0+]. + */ +Result AlarmSettingNotificationDisableAppEventReserve(void); + +/** + * @brief Same as \ref appletApplicationPushToNotificationStorageChannel except this uses the MainApplication. + * @note Only available on [9.0.0+]. + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + */ +Result AlarmSettingNotificationPushAppEventNotify(const void* buffer, u64 size); + +/** + * @brief Clears a StorageChannel, pushes the input storage there, and writes the ApplicationId into state. + * @note Only available on [9.0.0+]. + * @note This uses \ref appletStorageClose automatically. + * @param[in] s Storage object. + * @param[in] application_id ApplicationId + */ +Result FriendInvitationSetApplicationParameter(AppletStorage *s, u64 application_id); + +/** + * @brief Clears the StorageChannel/saved-ApplicationId used by \ref appletFriendInvitationSetApplicationParameter. + * @note Only available on [9.0.0+]. + */ +Result FriendInvitationClearApplicationParameter(void); + +/** + * @brief Same as \ref appletApplicationPushToFriendInvitationStorageChannel except this uses the MainApplication. + * @note Only available on [9.0.0+]. + * @param[in] uid \ref AccountUid + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + */ +Result FriendInvitationPushApplicationParameter(AccountUid uid, const void* buffer, u64 size); + +/** + * @brief Creates a GeneralStorage with the specified Id and size. + * @note Only available on [18.0.0+]. + * @param[in] id Id value, high-byte must be 0. + * @param[in] size Storage size. + */ +Result CreateGeneralStorageForDebug(u64 id, u64 size); + +/** + * @brief Reads data from the buffer previously allocated by \ref appletCreateGeneralStorageForDebug. + * @note Only available on [18.0.0+]. + * @param[out] buffer Output buffer. + * @param[in] size Output buffer size. + * @param[in] id Id value which was previously used with \ref appletCreateGeneralStorageForDebug, high-byte must be 0. + * @param[in] offset Offset in the storage. + * @param[out] out_size Output size. + */ +Result ReadGeneralStorageForDebug(void* buffer, size_t size, u64 id, u64 offset, u64 *out_size); + +/** + * @brief Writes data to the buffer previously allocated by \ref appletCreateGeneralStorageForDebug. + * @note Only available on [18.0.0+]. + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + * @param[in] id Id value which was previously used with \ref appletCreateGeneralStorageForDebug, high-byte must be 0. + * @param[in] offset Offset in the storage. + */ +Result WriteGeneralStorageForDebug(const void* buffer, size_t size, u64 id, u64 offset); + +/** + * @brief SetTerminateResult + * @note Only available with AppletType_*Application. Or with AppletType_SystemApplet, AppletType_LibraryApplet, or AppletType_OverlayApplet, on [9.0.0+]. + * @param[in] res Result + */ +Result SetTerminateResult(Result res); + +/** + * @brief Gets the LaunchStorageInfo. + * @note Only available with AppletType_*Application on [2.0.0+], or with AppletType_LibraryApplet on [9.0.0+]. + * @param[out] app_storageId Same as AppletApplicationLaunchProperty::app_storageId. + * @param[out] update_storageId Same as AppletApplicationLaunchProperty::update_storageId. + */ +Result GetLaunchStorageInfoForDebug(NcmStorageId *app_storageId, NcmStorageId *update_storageId); + +/** + * @brief Gets an Event which is signaled for GpuErrorDetected. + * @note Only available with AppletType_*Application on [8.0.0+], or with AppletType_LibraryApplet on [9.0.0+]. + * @note The Event must be closed by the user once finished with it. + * @note Official sw waits on this Event from a seperate thread, triggering an abort when it's signaled. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetGpuErrorDetectedSystemEvent(Event *out_event); + +/** + * @brief Sets HandlingHomeButtonShortPressedEnabled. + * @note Only available with AppletType_OverlayApplet on [8.0.0+]. Or with non-AppletType_OverlayApplet on [9.1.0+]. + * @param[in] flag Flag + */ +Result SetHandlingHomeButtonShortPressedEnabled(bool flag); + +/** + * @brief Gets the cached \ref AppletInfo loaded during \ref appletInitialize. This will return NULL when the info is not initialized, due to not running as AppletType_LibraryApplet, or when any of the used cmds fail. + * @note Only available with AppletType_LibraryApplet. + */ +AppletInfo * GetAppletInfo(void); + +/** + * @brief Gets the event associated with notification messages. + */ +Event * GetMessageEvent(void); + +/** + * @brief Gets a notification message, see \ref AppletMessage. + */ +Result GetMessage(u32 *msg); + +/** + * @brief Processes the current applet status using the specified msg. + * @param msg Notification message, normally from \ref appletGetMessage. + * @return Whether the application should continue running. + */ +bool ProcessMessage(u32 msg); + +/** + * @brief Processes the current applet status. Generally used within a main loop. + * @note Uses \ref appletGetMessage and \ref appletProcessMessage internally. + * @return Whether the application should continue running. + */ +bool MainLoop(void); + +/** + * @brief Sets up an applet status hook. + * @param cookie Hook cookie to use. + * @param callback Function to call when applet's status changes. + * @param param User-defined parameter to pass to the callback. + */ +void Hook(AppletHookCookie* cookie, AppletHookFn callback, void* param); + +/** + * @brief Removes an applet status hook. + * @param cookie Hook cookie to remove. + */ +void Unhook(AppletHookCookie* cookie); + +/// These return state which is updated by appletMainLoop() when notifications are received. +AppletOperationMode GetOperationMode(void); + +ApmPerformanceMode GetPerformanceMode(void); + +AppletFocusState GetFocusState(void); + +/** + * @brief Sets the current \ref AppletFocusHandlingMode. + * @note Should only be called with AppletType_Application. + */ +Result SetFocusHandlingMode(AppletFocusHandlingMode mode); + +} // namespace applet + +/// @brief C++ wrappers for the `arm` API. +/// @details Wraps: switch/arm/cache.h, switch/arm/counter.h, switch/arm/tls.h. +namespace arm { + +/** + * @brief Performs a data cache flush on the specified buffer. + * @param addr Address of the buffer. + * @param size Size of the buffer, in bytes. + * @remarks Cache flush is defined as Clean + Invalidate. + * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). + */ +void DCacheFlush(void* addr, size_t size); + +/** + * @brief Performs a data cache clean on the specified buffer. + * @param addr Address of the buffer. + * @param size Size of the buffer, in bytes. + * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). + */ +void DCacheClean(void* addr, size_t size); + +/** + * @brief Performs an instruction cache invalidation clean on the specified buffer. + * @param addr Address of the buffer. + * @param size Size of the buffer, in bytes. + * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). + */ +void ICacheInvalidate(void* addr, size_t size); + +/** + * @brief Performs a data cache zeroing operation on the specified buffer. + * @param addr Address of the buffer. + * @param size Size of the buffer, in bytes. + * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). + */ +void DCacheZero(void* addr, size_t size); + +/** + * @brief Gets the current system tick. + * @return The current system tick. + */ +u64 GetSystemTick(void); + +/** + * @brief Gets the system counter-timer frequency + * @return The system counter-timer frequency, in Hz. + */ +u64 GetSystemTickFreq(void); + +/** + * @brief Converts from nanoseconds to CPU ticks unit. + * @param ns Time in nanoseconds. + * @return Time in CPU ticks. + */ +u64 NsToTicks(u64 ns); + +/** + * @brief Converts from CPU ticks unit to nanoseconds. + * @param tick Time in ticks. + * @return Time in nanoseconds. + */ +u64 TicksToNs(u64 tick); + +/** + * @brief Gets the thread local storage buffer. + * @return The thread local storage buffer. + */ +void* GetTls(void); + +} // namespace arm + +/// @brief C++ wrappers for the `async` API. +/// @details Wraps: switch/services/async.h. +namespace async { + +/// AsyncResult +using ::AsyncResult; +/// AsyncValue +using ::AsyncValue; + +/** + * @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 ValueClose(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 ValueWait(AsyncValue *a, u64 timeout); + +/** + * @brief Gets the value size. + * @param a \ref AsyncValue + * @param[out] size Output size. + */ +Result ValueGetSize(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 ValueGet(AsyncValue *a, void* buffer, size_t size); + +/** + * @brief Cancels the async operation. + * @note Used automatically by \ref asyncValueClose. + * @param a \ref AsyncValue + */ +Result ValueCancel(AsyncValue *a); + +/** + * @brief Gets the \ref ErrorContext. + * @note Only available on [4.0.0+]. + * @param a \ref AsyncValue + * @param[out] context \ref ErrorContext + */ +Result ValueGetErrorContext(AsyncValue *a, ErrorContext *context); + +/** + * @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 ResultClose(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 ResultWait(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 ResultGet(AsyncResult *a); + +/** + * @brief Cancels the async operation. + * @note Used automatically by \ref asyncResultClose. + * @param a \ref AsyncResult + */ +Result ResultCancel(AsyncResult *a); + +/** + * @brief Gets the \ref ErrorContext. + * @note Only available on [4.0.0+]. + * @param a \ref AsyncResult + * @param[out] context \ref ErrorContext + */ +Result ResultGetErrorContext(AsyncResult *a, ErrorContext *context); + +} // namespace async + +/// @brief C++ wrappers for the `auda` API. +/// @details Wraps: switch/services/aud.h. +namespace auda { + +/// Initialize aud:a. Only available on [11.0.0+]. +Result Initialize(void); + +/// Exit aud:a. +void Exit(void); + +/// Gets the Service for aud:a. +Service* GetServiceSession(void); + +Result RequestSuspendAudio(u64 pid, u64 delay); + +Result RequestResumeAudio(u64 pid, u64 delay); + +Result GetAudioOutputProcessMasterVolume(u64 pid, float* volume_out); + +Result SetAudioOutputProcessMasterVolume(u64 pid, u64 delay, float volume); + +Result GetAudioInputProcessMasterVolume(u64 pid, float* volume_out); + +Result SetAudioInputProcessMasterVolume(u64 pid, u64 delay, float volume); + +Result GetAudioOutputProcessRecordVolume(u64 pid, float* volume_out); + +Result SetAudioOutputProcessRecordVolume(u64 pid, u64 delay, float volume); + +} // namespace auda + +/// @brief C++ wrappers for the `audctl` API. +/// @details Wraps: switch/services/audctl.h. +namespace audctl { + +using ::AudioForceMutePolicy; +using ::AudioHeadphoneOutputLevelMode; +using ::AudioOutputMode; +using ::AudioTarget; + +Result Initialize(void); + +void Exit(void); + +Service* GetServiceSession(void); + +Result GetTargetVolume(s32* volume_out, AudioTarget target); + +Result SetTargetVolume(AudioTarget target, s32 volume); + +Result GetTargetVolumeMin(s32* volume_out); + +Result GetTargetVolumeMax(s32* volume_out); + +Result IsTargetMute(bool* mute_out, AudioTarget target); + +Result SetTargetMute(AudioTarget target, bool mute); + +Result IsTargetConnected(bool* connected_out, AudioTarget target); + +///< [1.0.0-17.0.1] +Result SetDefaultTarget(AudioTarget target, u64 fade_in_ns, u64 fade_out_ns); + +Result GetDefaultTarget(AudioTarget* target_out); + +Result GetAudioOutputMode(AudioOutputMode* mode_out, AudioTarget target); + +Result SetAudioOutputMode(AudioTarget target, AudioOutputMode mode); + +Result SetForceMutePolicy(AudioForceMutePolicy policy); + +///< [1.0.0-13.2.1] +Result GetForceMutePolicy(AudioForceMutePolicy* policy_out); + +///< [1.0.0-13.2.1] +Result GetOutputModeSetting(AudioOutputMode* mode_out, AudioTarget target); + +Result SetOutputModeSetting(AudioTarget target, AudioOutputMode mode); + +Result SetOutputTarget(AudioTarget target); + +Result SetInputTargetForceEnabled(bool enable); + +Result SetHeadphoneOutputLevelMode(AudioHeadphoneOutputLevelMode mode); + +///< [3.0.0+] +Result GetHeadphoneOutputLevelMode(AudioHeadphoneOutputLevelMode* mode_out); + +///< [3.0.0+] +Result AcquireAudioVolumeUpdateEventForPlayReport(Event* event_out); + +///< [3.0.0-13.2.1] +Result AcquireAudioOutputDeviceUpdateEventForPlayReport(Event* event_out); + +///< [3.0.0-13.2.1] +Result GetAudioOutputTargetForPlayReport(AudioTarget* target_out); + +///< [3.0.0+] +Result NotifyHeadphoneVolumeWarningDisplayedEvent(void); + +///< [3.0.0+] +Result SetSystemOutputMasterVolume(float volume); + +///< [4.0.0+] +Result GetSystemOutputMasterVolume(float* volume_out); + +///< [4.0.0+] +Result GetActiveOutputTarget(AudioTarget* target); + +} // namespace audctl + +/// @brief C++ wrappers for the `audd` API. +/// @details Wraps: switch/services/aud.h. +namespace audd { + +/// Initialize aud:d. Only available on [11.0.0+]. +Result Initialize(void); + +/// Exit aud:d. +void Exit(void); + +/// Gets the Service for aud:d. +Service* GetServiceSession(void); + +Result RequestSuspendAudioForDebug(u64 pid, u64 delay); + +Result RequestResumeAudioForDebug(u64 pid, u64 delay); + +} // namespace audd + +/// @brief C++ wrappers for the `auddev` API. +/// @details Wraps: switch/services/auddev.h. +namespace auddev { + +/// Initialize IAudioDevice. +Result Initialize(void); + +/// Exit IAudioDevice. +void Exit(void); + +/// Gets the Service object for IAudioDevice. +Service* GetServiceSession(void); + +Result ListAudioDeviceName(AudioDeviceName *DeviceNames, s32 max_names, s32 *total_names); + +Result SetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float volume); + +Result GetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float *volume); + +Result GetActiveAudioDeviceName(AudioDeviceName *DeviceName); + +} // namespace auddev + +/// @brief C++ wrappers for the `audin` API. +/// @details Wraps: switch/services/audin.h. +namespace audin { + +/// Audio input buffer format +using ::AudioInBuffer; +using ::AudioInState; + +/// Initialize audin. +Result Initialize(void); + +/// Exit audin. +void Exit(void); + +/// Gets the Service object for the actual audin service session. +Service* GetServiceSession(void); + +/// Gets the Service object for IAudioIn. +Service* GetServiceSession_AudioIn(void); + +Result ListAudioIns(char *DeviceNames, s32 count, u32 *DeviceNamesCount); + +Result OpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State); + +Result GetAudioInState(AudioInState *State); + +Result StartAudioIn(void); + +Result StopAudioIn(void); + +/// Submits an \ref AudioInBuffer for capturing. +Result AppendAudioInBuffer(AudioInBuffer *Buffer); + +Result GetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount); + +Result ContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer); + +/** + * @brief Submits an audio sample data buffer for capturing and waits for it to finish capturing. + * @brief Uses \ref audinAppendAudioInBuffer and \ref audinWaitCaptureFinish internally. + * @param source AudioInBuffer containing the buffer to hold the captured sample data. + * @param released AudioInBuffer to receive the captured buffer after being released. + */ +Result CaptureBuffer(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. + */ +Result WaitCaptureFinish(AudioInBuffer **released, u32* released_count, u64 timeout); + +/// These return the state associated with the currently active audio input device. +u32 GetSampleRate(void); + +///< Supported sample rate (48000Hz). +u32 GetChannelCount(void); + +///< Supported channel count (2 channels). +PcmFormat GetPcmFormat(void); + +///< Supported PCM format (Int16). +AudioInState GetDeviceState(void); + +} // namespace audin + +/// @brief C++ wrappers for the `audout` API. +/// @details Wraps: switch/services/audout.h. +namespace audout { + +/// Audio output buffer format +using ::AudioOutBuffer; +using ::AudioOutState; + +/// Initialize audout. +Result Initialize(void); + +/// Exit audout. +void Exit(void); + +/// Gets the Service object for the actual audout service session. +Service* GetServiceSession(void); + +/// Gets the Service object for IAudioOut. +Service* GetServiceSession_AudioOut(void); + +Result ListAudioOuts(char *DeviceNames, s32 count, u32 *DeviceNamesCount); + +Result OpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State); + +Result GetAudioOutState(AudioOutState *State); + +Result StartAudioOut(void); + +Result StopAudioOut(void); + +/// Submits an \ref AudioOutBuffer for playing. +Result AppendAudioOutBuffer(AudioOutBuffer *Buffer); + +Result GetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount); + +Result ContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer); + +/// Only available with [4.0.0+]. +Result GetAudioOutBufferCount(u32 *count); + +/// Only available with [4.0.0+]. +Result GetAudioOutPlayedSampleCount(u64 *count); + +/// Only available with [4.0.0+]. +Result FlushAudioOutBuffers(bool *flushed); + +/// Only available with [6.0.0+]. +Result SetAudioOutVolume(float volume); + +/// Only available with [6.0.0+]. +Result GetAudioOutVolume(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. + * @param source AudioOutBuffer containing the source sample data to be played. + * @param released AudioOutBuffer to receive the played buffer after being released. + */ +Result PlayBuffer(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. + */ +Result WaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout); + +/// These return the state associated with the currently active audio output device. +u32 GetSampleRate(void); + +///< Supported sample rate (48000Hz). +u32 GetChannelCount(void); + +///< Supported channel count (2 channels). +PcmFormat GetPcmFormat(void); + +///< Supported PCM format (Int16). +AudioOutState GetDeviceState(void); + +} // namespace audout + +/// @brief C++ wrappers for the `audouta` API. +/// @details Wraps: switch/services/audout.h. +namespace audouta { + +/// Audio output buffer format +using ::AudioOutBuffer; +using ::AudioOutState; + +/// Initialize audout:a. Removed in [11.0.0]. +Result Initialize(void); + +/// Exit audout:a. +void Exit(void); + +/// Gets the Service for audout:a. +Service* GetServiceSession(void); + +///< Initial device state (stopped). +Result RequestSuspend(u64 pid, u64 delay); + +Result RequestResume(u64 pid, u64 delay); + +Result GetProcessMasterVolume(u64 pid, float* volume_out); + +Result SetProcessMasterVolume(u64 pid, u64 delay, float volume); + +Result GetProcessRecordVolume(u64 pid, float* volume_out); + +Result SetProcessRecordVolume(u64 pid, u64 delay, float volume); + +} // namespace audouta + +/// @brief C++ wrappers for the `audoutd` API. +/// @details Wraps: switch/services/audout.h. +namespace audoutd { + +/// Audio output buffer format +using ::AudioOutBuffer; +using ::AudioOutState; + +/// Initialize audout:d. Removed in [11.0.0]. +Result Initialize(void); + +/// Exit audout:d. +void Exit(void); + +/// Gets the Service for audout:d. +Service* GetServiceSession(void); + +Result RequestSuspendForDebug(u64 pid, u64 delay); + +Result RequestResumeForDebug(u64 pid, u64 delay); + +} // namespace audoutd + +/// @brief C++ wrappers for the `audrec` API. +/// @details Wraps: switch/services/audrec.h. +namespace audrec { + +using ::AudrecRecorder; +using ::FinalOutputRecorderBuffer; +using ::FinalOutputRecorderParameter; +using ::FinalOutputRecorderParameterInternal; + +Result Initialize(void); + +void Exit(void); + +Service* GetServiceSession(void); + +Result OpenFinalOutputRecorder(AudrecRecorder* recorder_out, FinalOutputRecorderParameter* param_in, u64 aruid, FinalOutputRecorderParameterInternal* param_out); + +Result RecorderStart(AudrecRecorder* recorder); + +Result RecorderStop(AudrecRecorder* recorder); + +Result RecorderRegisterBufferEvent(AudrecRecorder* recorder, Event* out_event); + +Result RecorderAppendFinalOutputRecorderBuffer(AudrecRecorder* recorder, u64 buffer_client_ptr, FinalOutputRecorderBuffer* param); + +Result RecorderGetReleasedFinalOutputRecorderBuffers(AudrecRecorder* recorder, u64* out_buffers, u64* inout_count, u64* out_released); + +void RecorderClose(AudrecRecorder* recorder); + +} // namespace audrec + +/// @brief C++ wrappers for the `audren` API. +/// @details Wraps: switch/services/audren.h. +namespace audren { + +using ::AudioRendererAdpcmContext; +using ::AudioRendererAdpcmParameters; +using ::AudioRendererBehaviorInfoIn; +using ::AudioRendererBehaviorInfoOut; +using ::AudioRendererBiquadFilter; +using ::AudioRendererChannelInfoIn; +using ::AudioRendererCircularBufferSinkInfoIn; +using ::AudioRendererConfig; +using ::AudioRendererDeviceSinkInfoIn; +using ::AudioRendererDownMixParameters; +using ::AudioRendererMemPoolInfoIn; +using ::AudioRendererMemPoolInfoOut; +using ::AudioRendererMemPoolState; +using ::AudioRendererMixInfoIn; +using ::AudioRendererOutputRate; +using ::AudioRendererPerformanceBufferInfoIn; +using ::AudioRendererPerformanceBufferInfoOut; +using ::AudioRendererSinkInfoIn; +using ::AudioRendererSinkInfoOut; +using ::AudioRendererSinkType; +using ::AudioRendererUpdateDataHeader; +using ::AudioRendererVoiceInfoIn; +using ::AudioRendererVoiceInfoOut; +using ::AudioRendererVoicePlayState; +using ::AudioRendererWaveBuf; + +u32 GetRevision(void); + +int GetMemPoolCount(const AudioRendererConfig* config); + +size_t GetInputParamSize(const AudioRendererConfig* config); + +size_t GetOutputParamSize(const AudioRendererConfig* config); + +/// Initialize audren. +Result Initialize(const AudioRendererConfig* config); + +/// Exit audren. +void Exit(void); + +/// Gets the Service object for IAudioRenderer. +Service* GetServiceSession_AudioRenderer(void); + +/// Returns event that is signalled on new frame (autoclear=true). +Event* GetFrameEvent(void); + +void WaitFrame(void); + +Result GetState(u32* out_state); + +Result RequestUpdateAudioRenderer(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); + +Result StartAudioRenderer(void); + +Result StopAudioRenderer(void); + +Result SetAudioRendererRenderingTimeLimit(int percent); + +} // namespace audren + +/// @brief C++ wrappers for the `audrv` API. +/// @details Wraps: switch/audio/driver.h. +namespace audrv { + +using ::AudioDriver; +using ::AudioDriverEtc; +using ::AudioDriverWaveBuf; +using ::AudioDriverWaveBufState; + +Result Create(AudioDriver* d, const AudioRendererConfig* config, int num_final_mix_channels); + +Result Update(AudioDriver* d); + +void Close(AudioDriver* d); + +int MemPoolAdd(AudioDriver* d, void* buffer, size_t size); + +bool MemPoolRemove(AudioDriver* d, int id); + +bool MemPoolAttach(AudioDriver* d, int id); + +bool MemPoolDetach(AudioDriver* d, int id); + +bool VoiceInit(AudioDriver* d, int id, int num_channels, PcmFormat format, int sample_rate); + +void VoiceDrop(AudioDriver* d, int id); + +void VoiceStop(AudioDriver* d, int id); + +bool VoiceIsPaused(AudioDriver* d, int id); + +bool VoiceIsPlaying(AudioDriver* d, int id); + +bool VoiceAddWaveBuf(AudioDriver* d, int id, AudioDriverWaveBuf* wavebuf); + +u32 VoiceGetWaveBufSeq(AudioDriver* d, int id); + +u32 VoiceGetPlayedSampleCount(AudioDriver* d, int id); + +u32 VoiceGetVoiceDropsCount(AudioDriver* d, int id); + +void VoiceSetBiquadFilter(AudioDriver* d, int id, int biquad_id, float a0, float a1, float a2, float b0, float b1, float b2); + +void VoiceSetExtraParams(AudioDriver* d, int id, const void* params, size_t params_size); + +void VoiceSetDestinationMix(AudioDriver* d, int id, int mix_id); + +void VoiceSetMixFactor(AudioDriver* d, int id, float factor, int src_channel_id, int dest_channel_id); + +void VoiceSetVolume(AudioDriver* d, int id, float volume); + +void VoiceSetPitch(AudioDriver* d, int id, float pitch); + +void VoiceSetPriority(AudioDriver* d, int id, int priority); + +void VoiceClearBiquadFilter(AudioDriver* d, int id, int biquad_id); + +void VoiceSetPaused(AudioDriver* d, int id, bool paused); + +void VoiceStart(AudioDriver* d, int id); + +int MixAdd(AudioDriver* d, int sample_rate, int num_channels); + +void MixRemove(AudioDriver* d, int id); + +void MixSetDestinationMix(AudioDriver* d, int id, int mix_id); + +void MixSetMixFactor(AudioDriver* d, int id, float factor, int src_channel_id, int dest_channel_id); + +void MixSetVolume(AudioDriver* d, int id, float volume); + +int DeviceSinkAdd(AudioDriver* d, const char* device_name, int num_channels, const u8* channel_ids); + +void SinkRemove(AudioDriver* d, int id); + +} // namespace audrv + +/// @brief C++ wrappers for the `avm` API. +/// @details Wraps: switch/services/avm.h. +namespace avm { + +using ::AvmRequiredVersionEntry; +using ::AvmVersionListEntry; +using ::AvmVersionListImporter; + +Result Initialize(void); + +void Exit(void); + +Service * GetServiceSession(void); + +Result GetHighestAvailableVersion(u64 id_1, u64 id_2, u32 *version); + +Result GetHighestRequiredVersion(u64 id_1, u64 id_2, u32 *version); + +Result GetVersionListEntry(u64 application_id, AvmVersionListEntry *entry); + +Result GetVersionListImporter(AvmVersionListImporter *out); + +Result GetLaunchRequiredVersion(u64 application_id, u32 *version); + +Result UpgradeLaunchRequiredVersion(u64 application_id, u32 version); + +Result PushLaunchVersion(u64 application_id, u32 version); + +Result ListVersionList(AvmVersionListEntry *buffer, size_t count, u32 *out); + +Result ListRequiredVersion(AvmRequiredVersionEntry *buffer, size_t count, u32 *out); + +void VersionListImporterClose(AvmVersionListImporter *srv); + +Result VersionListImporterSetTimestamp(AvmVersionListImporter *srv, u64 timestamp); + +Result VersionListImporterSetData(AvmVersionListImporter *srv, const AvmVersionListEntry *entries, u32 count); + +Result VersionListImporterFlush(AvmVersionListImporter *srv); + +} // namespace avm + +/// @brief C++ wrappers for the `barrier` API. +/// @details Wraps: switch/kernel/barrier.h. +namespace barrier { + +/// Barrier structure. +using ::Barrier; + +/** + * @brief Initializes a barrier and the number of threads to wait on. + * @param b Barrier object. + * @param thread_count Initial value for the number of threads the barrier must wait for. + */ +void Init(Barrier *b, u64 thread_count); + +/** + * @brief Forces threads to wait until all threads have called barrierWait. + * @param b Barrier object. + */ +void Wait(Barrier *b); + +} // namespace barrier + +/// @brief C++ wrappers for the `binder` API. +/// @details Wraps: switch/display/binder.h. +namespace binder { + +using ::Binder; + +void Create(Binder* b, s32 id); + +void Close(Binder* b); + +Result InitSession(Binder* b, Service* relay); + +Result TransactParcel(Binder* b, u32 code, void* parcel_data, size_t parcel_data_size, void* parcel_reply, size_t parcel_reply_size, u32 flags); + +Result ConvertErrorCode(s32 code); + +Result AdjustRefcount(Binder* b, s32 addval, s32 type); + +Result GetNativeHandle(Binder* b, u32 unk0, Event *event_out); + +Result IncreaseWeakRef(Binder* b); + +Result DecreaseWeakRef(Binder* b); + +Result IncreaseStrongRef(Binder* b); + +Result DecreaseStrongRef(Binder* b); + +} // namespace binder + +/// @brief C++ wrappers for the `bpc` API. +/// @details Wraps: switch/services/bpc.h. +namespace bpc { + +using ::BpcSleepButtonState; + +/// Initialize bpc. +Result Initialize(void); + +/// Exit bpc. +void Exit(void); + +/// Gets the Service object for the actual bpc service session. +Service* GetServiceSession(void); + +Result ShutdownSystem(void); + +Result RebootSystem(void); + +Result GetSleepButtonState(BpcSleepButtonState *out); + +///< [2.0.0-13.2.1] +Result GetPowerButton(bool* out_is_pushed); + +} // namespace bpc + +/// @brief C++ wrappers for the `bq` API. +/// @details Wraps: switch/display/buffer_producer.h. +namespace bq { + +using ::BqBufferInput; +using ::BqBufferOutput; +using ::BqGraphicBuffer; +using ::BqRect; + +Result RequestBuffer(Binder *b, s32 bufferIdx, BqGraphicBuffer *buf); + +Result DequeueBuffer(Binder *b, bool async, u32 width, u32 height, s32 format, u32 usage, s32 *buf, NvMultiFence *fence); + +Result DetachBuffer(Binder *b, s32 slot); + +Result QueueBuffer(Binder *b, s32 buf, const BqBufferInput *input, BqBufferOutput *output); + +Result CancelBuffer(Binder *b, s32 buf, const NvMultiFence *fence); + +Result Query(Binder *b, s32 what, s32* value); + +Result Connect(Binder *b, s32 api, bool producerControlledByApp, BqBufferOutput *output); + +Result Disconnect(Binder *b, s32 api); + +Result SetPreallocatedBuffer(Binder *b, s32 buf, const BqGraphicBuffer *input); + +} // namespace bq + +/// @brief C++ wrappers for the `bt` API. +/// @details Wraps: switch/services/bt.h. +namespace bt { + +/// Initialize bt. Only available on [5.0.0+]. +Result Initialize(void); + +/// Exit bt. +void Exit(void); + +/// Gets the Service object for the actual bt service session. +Service* GetServiceSession(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 LeClientReadCharacteristic(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 LeClientReadDescriptor(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 LeClientWriteCharacteristic(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 LeClientWriteDescriptor(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 LeClientRegisterNotification(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 LeClientDeregisterNotification(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 SetLeResponse(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 LeSendIndication(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 GetLeEventInfo(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 RegisterBleEvent(Event* out_event); + +} // namespace bt + +/// @brief C++ wrappers for the `btdev` API. +/// @details Wraps: switch/runtime/btdev.h. +namespace btdev { + +/// GattAttribute +using ::BtdevGattAttribute; +/// GattCharacteristic +using ::BtdevGattCharacteristic; +/// GattDescriptor +using ::BtdevGattDescriptor; +/// GattService +using ::BtdevGattService; + +/// Initialize bt/btmu. +Result Initialize(void); + +/// Exit bt/btmu. +void Exit(void); + +/// Compares two \ref BtdrvGattAttributeUuid, returning whether these match. +bool GattAttributeUuidIsSame(const BtdrvGattAttributeUuid *a, const BtdrvGattAttributeUuid *b); + +/// Wrapper for \ref btmuAcquireBleScanEvent. +Result AcquireBleScanEvent(Event* out_event); + +/// Wrapper for \ref btmuGetBleScanFilterParameter. +Result GetBleScanParameter(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out); + +/// Wrapper for \ref btmuGetBleScanFilterParameter2. +Result GetBleScanParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out); + +/// Wrapper for \ref btdevStartBleScanGeneral. +Result StartBleScanGeneral(BtdrvBleAdvertisePacketParameter param); + +/// Wrapper for \ref btmuStopBleScanForGeneral. +Result StopBleScanGeneral(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 GetBleScanResult(BtdrvBleScanResult *results, u8 count, u8 *total_out); + +/// Wrapper for \ref btmuStartBleScanForPaired. +Result EnableBleAutoConnection(BtdrvBleAdvertisePacketParameter param); + +/// Wrapper for \ref btmuStopBleScanForPaired. +Result DisableBleAutoConnection(void); + +/// Wrapper for \ref btmuStartBleScanForSmartDevice. +Result StartBleScanSmartDevice(const BtdrvGattAttributeUuid *uuid); + +/// Wrapper for \ref btmuStopBleScanForSmartDevice. +Result StopBleScanSmartDevice(void); + +/// Wrapper for \ref btmuAcquireBleConnectionEvent. +Result AcquireBleConnectionStateChangedEvent(Event* out_event); + +/// Wrapper for \ref btmuBleConnect. +Result ConnectToGattServer(BtdrvAddress addr); + +/// Wrapper for \ref btmuBleDisconnect. +Result DisconnectFromGattServer(u32 connection_handle); + +/// Wrapper for \ref btmuBleGetConnectionState. +Result GetBleConnectionInfoList(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out); + +/// Wrapper for \ref btmuAcquireBleServiceDiscoveryEvent. +Result AcquireBleServiceDiscoveryEvent(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 GetGattServices(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 GetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtdevGattService *service, bool *flag); + +/// Wrapper for \ref btmuAcquireBlePairingEvent. +Result AcquireBlePairingEvent(Event* out_event); + +/// Wrapper for \ref btmuBlePairDevice. +Result PairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param); + +/// Wrapper for \ref btmuBleUnPairDevice. +Result UnpairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param); + +/// Wrapper for \ref btmuBleUnPairDevice2. +Result UnpairGattServer2(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param); + +/// Wrapper for \ref btmuBleGetPairedDevices. +Result GetPairedGattServerAddress(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out); + +/// Wrapper for \ref btmuAcquireBleMtuConfigEvent. +Result AcquireBleMtuConfigEvent(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 ConfigureBleMtu(u32 connection_handle, u16 mtu); + +/// Wrapper for \ref btmuGetBleMtu. +Result GetBleMtu(u32 connection_handle, u16 *out); + +/// Wrapper for \ref btRegisterBleEvent. +Result AcquireBleGattOperationEvent(Event* out_event); + +/** + * @brief Wrapper for \ref btmuRegisterBleGattDataPath. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result RegisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief Wrapper for \ref btmuUnregisterBleGattDataPath. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result UnregisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief Wrapper for \ref btGetLeEventInfo. + * @param[out] out \ref BtdrvBleClientGattOperationInfo + */ +Result GetGattOperationResult(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 ReadGattCharacteristic(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 WriteGattCharacteristic(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 EnableGattCharacteristicNotification(BtdevGattCharacteristic *c, bool flag); + +/** + * @brief Wrapper for \ref btLeClientReadDescriptor. + * @param d \ref BtdevGattDescriptor + */ +Result ReadGattDescriptor(BtdevGattDescriptor *d); + +/** + * @brief Wrapper for \ref btLeClientWriteDescriptor. + * @note This uses the Value from \ref btdevGattDescriptorSetValue. + * @param d \ref BtdevGattDescriptor + */ +Result WriteGattDescriptor(BtdevGattDescriptor *d); + +/** + * @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 GattAttributeCreate(BtdevGattAttribute *a, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle); + +/** + * @brief Gets the Type. + * @param a \ref BtdevGattAttribute + */ +u8 GattAttributeGetType(BtdevGattAttribute *a); + +/** + * @brief Gets the Uuid. + * @param a \ref BtdevGattAttribute + * @param[out] out \ref BtdrvGattAttributeUuid + */ +void GattAttributeGetUuid(BtdevGattAttribute *a, BtdrvGattAttributeUuid *out); + +/** + * @brief Gets the Handle. + * @param a \ref BtdevGattAttribute + */ +u16 GattAttributeGetHandle(BtdevGattAttribute *a); + +/** + * @brief Gets the ConnectionHandle. + * @param a \ref BtdevGattAttribute + */ +u32 GattAttributeGetConnectionHandle(BtdevGattAttribute *a); + +/** + * @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 GattServiceCreate(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 + */ +u16 GattServiceGetInstanceId(BtdevGattService *s); + +/** + * @brief Gets the EndGroupHandle. + * @param s \ref BtdevGattService + */ +u16 GattServiceGetEndGroupHandle(BtdevGattService *s); + +/** + * @brief Gets whether this is the PrimaryService. + * @param s \ref BtdevGattService + */ +u16 GattServiceIsPrimaryService(BtdevGattService *s); + +/** + * @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 GattServiceGetIncludedServices(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 GattServiceGetCharacteristics(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 GattServiceGetCharacteristic(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, BtdevGattCharacteristic *characteristic, bool *flag); + +/** + * @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 GattCharacteristicCreate(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u8 properties); + +/** + * @brief Gets the InstanceId. + * @param c \ref BtdevGattCharacteristic + */ +u16 GattCharacteristicGetInstanceId(BtdevGattCharacteristic *c); + +/** + * @brief Gets the Properties. + * @param c \ref BtdevGattCharacteristic + */ +u8 GattCharacteristicGetProperties(BtdevGattCharacteristic *c); + +/** + * @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 GattCharacteristicGetService(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 GattCharacteristicGetDescriptors(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 GattCharacteristicGetDescriptor(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 GattCharacteristicSetValue(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 GattCharacteristicGetValue(BtdevGattCharacteristic *c, void* buffer, size_t size); + +/** + * @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 GattDescriptorCreate(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 GattDescriptorGetService(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 GattDescriptorGetCharacteristic(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 GattDescriptorSetValue(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 GattDescriptorGetValue(BtdevGattDescriptor *d, void* buffer, size_t size); + +} // namespace btdev + +/// @brief C++ wrappers for the `btdrv` API. +/// @details Wraps: switch/services/btdrv.h. +namespace btdrv { + +/// Data for \ref btdrvGetAudioEventInfo. The data stored here depends on the \ref BtdrvAudioEventType. +using ::BtdrvAudioEventInfo; +/// Data for \ref btdrvGetBleManagedEventInfo and \ref btdrvGetLeHidEventInfo. The data stored here depends on the \ref BtdrvBleEventType. +using ::BtdrvBleEventInfo; +/// CircularBuffer +using ::BtdrvCircularBuffer; +/// Data for \ref btdrvGetEventInfo. The data stored here depends on the \ref BtdrvEventType. +using ::BtdrvEventInfo; +/// Data for \ref btdrvGetHidEventInfo. The data stored here depends on the \ref BtdrvHidEventType. +using ::BtdrvHidEventInfo; +/// Data for \ref btdrvGetHidReportEventInfo. The data stored here depends on the \ref BtdrvHidEventType. +using ::BtdrvHidReportEventInfo; +/// The raw sharedmem data for HidReportEventInfo. +using ::BtdrvHidReportEventInfoBufferData; + +/// Initialize btdrv. +Result Initialize(void); + +/// Exit btdrv. +void Exit(void); + +/// Gets the Service object for the actual btdrv service session. +Service* GetServiceSession(void); + +/** + * @brief InitializeBluetooth + * @note This is used by btm-sysmodule, this should not be used by other processes. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=true. + */ +Result InitializeBluetooth(Event* out_event); + +/** + * @brief EnableBluetooth + * @note This is used by btm-sysmodule. + */ +Result EnableBluetooth(void); + +/** + * @brief DisableBluetooth + * @note This is used by btm-sysmodule. + */ +Result DisableBluetooth(void); + +/** + * @brief FinalizeBluetooth + * @note This is not used by btm-sysmodule, this should not be used by other processes. + */ +Result FinalizeBluetooth(void); + +/** + * @brief GetAdapterProperties [1.0.0-11.0.1] + * @param[out] properties \ref BtdrvAdapterPropertyOld + */ +Result LegacyGetAdapterProperties(BtdrvAdapterPropertyOld *properties); + +/** + * @brief GetAdapterProperties [12.0.0+] + * @param[out] properties \ref BtdrvAdapterPropertySet + */ +Result GetAdapterProperties(BtdrvAdapterPropertySet *properties); + +/** + * @brief GetAdapterProperty [1.0.0-11.0.1] + * @param[in] type \ref BtdrvBluetoothPropertyType + * @param[out] buffer Output buffer, see \ref BtdrvBluetoothPropertyType for the contents. + * @param[in] size Output buffer size. + */ +Result LegacyGetAdapterProperty(BtdrvBluetoothPropertyType type, void* buffer, size_t size); + +/** + * @brief GetAdapterProperty [12.0.0+] + * @param[in] type \ref BtdrvAdapterPropertyType + * @param[in] property \ref BtdrvAdapterProperty + */ +Result GetAdapterProperty(BtdrvAdapterPropertyType type, BtdrvAdapterProperty *property); + +/** + * @brief SetAdapterProperty [1.0.0-11.0.1] + * @param[in] type \ref BtdrvBluetoothPropertyType + * @param[in] buffer Input buffer, see \ref BtdrvBluetoothPropertyType for the contents. + * @param[in] size Input buffer size. + */ +Result LegacySetAdapterProperty(BtdrvBluetoothPropertyType type, const void* buffer, size_t size); + +/** + * @brief SetAdapterProperty [12.0.0+] + * @param[in] type \ref BtdrvAdapterPropertyType + * @param[in] property \ref BtdrvAdapterProperty + */ +Result SetAdapterProperty(BtdrvAdapterPropertyType type, const BtdrvAdapterProperty *property); + +/** + * @brief StartInquiry [1.0.0-11.0.1]. This starts Inquiry, the output data will be available via \ref btdrvGetEventInfo. Inquiry will automatically stop in 10.24 seconds. + * @note This is used by btm-sysmodule. + */ +Result LegacyStartInquiry(void); + +/** + * @brief StartInquiry [12.0.0+]. This starts Inquiry, the output data will be available via \ref btdrvGetEventInfo. + * @param[in] services Bitfield of allowed services. When -1 the original defaults from pre-12.0.0 are used. + * @param[in] duration Inquiry duration in nanoseconds. + * @note This is used by btm-sysmodule. + */ +Result StartInquiry(u32 services, s64 duration); + +/** + * @brief This stops Inquiry which was started by \ref btdrvStartInquiry, if it's still active. + * @note This is used by btm-sysmodule. + */ +Result StopInquiry(void); + +/** + * @brief CreateBond + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[in] type TransportType + */ +Result CreateBond(BtdrvAddress addr, u32 type); + +/** + * @brief RemoveBond + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + */ +Result RemoveBond(BtdrvAddress addr); + +/** + * @brief CancelBond + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + */ +Result CancelBond(BtdrvAddress addr); + +/** + * @brief RespondToPinRequest [1.0.0-11.0.1] + * @note The official sysmodule only uses the input \ref BtdrvAddress. + * @param[in] addr \ref BtdrvAddress + * @param[in] flag Flag + * @param[in] pin_code \ref BtdrvBluetoothPinCode + * @param[in] length Length of pin_code + */ +Result LegacyRespondToPinRequest(BtdrvAddress addr, bool flag, const BtdrvBluetoothPinCode *pin_code, u8 length); + +/** + * @brief RespondToPinRequest [12.0.0+] + * @param[in] addr \ref BtdrvAddress + * @param[in] pin_code \ref BtdrvPinCode + */ +Result RespondToPinRequest(BtdrvAddress addr, const BtdrvPinCode *pin_code); + +/** + * @brief RespondToSspRequest + * @note The official sysmodule only uses the input \ref BtdrvAddress and the flag. + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[in] variant BluetoothSspVariant + * @param[in] accept Whether the request is accepted. + * @param[in] passkey Passkey. + */ +Result RespondToSspRequest(BtdrvAddress addr, u32 variant, bool accept, u32 passkey); + +/** + * @brief GetEventInfo + * @note This is used by btm-sysmodule. + * @param[out] buffer Output buffer, see \ref BtdrvEventInfo. + * @param[in] size Output buffer size. + * @param[out] type Output BtdrvEventType. + */ +Result GetEventInfo(void* buffer, size_t size, BtdrvEventType *type); + +/** + * @brief InitializeHid + * @note This is used by btm-sysmodule, this should not be used by other processes. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=true. + */ +Result InitializeHid(Event* out_event); + +/** + * @brief OpenHidConnection + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + */ +Result OpenHidConnection(BtdrvAddress addr); + +/** + * @brief CloseHidConnection + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + */ +Result CloseHidConnection(BtdrvAddress addr); + +/** + * @brief This sends a HID DATA transaction packet with report-type Output. + * @param[in] addr \ref BtdrvAddress + * @param[in] buffer Input \ref BtdrvHidReport, on pre-9.0.0 this is \ref BtdrvHidData. + */ +Result WriteHidData(BtdrvAddress addr, const BtdrvHidReport *buffer); + +/** + * @brief WriteHidData2 + * @param[in] addr \ref BtdrvAddress + * @param[in] buffer Input buffer, same as the buffer for \ref btdrvWriteHidData. + * @param[in] size Input buffer size. + */ +Result WriteHidData2(BtdrvAddress addr, const void* buffer, size_t size); + +/** + * @brief This sends a HID SET_REPORT transaction packet. + * @param[in] addr \ref BtdrvAddress + * @param[in] type \ref BtdrvBluetoothHhReportType + * @param[in] buffer Input \ref BtdrvHidReport, on pre-9.0.0 this is \ref BtdrvHidData. + */ +Result SetHidReport(BtdrvAddress addr, BtdrvBluetoothHhReportType type, const BtdrvHidReport *buffer); + +/** + * @brief This sends a HID GET_REPORT transaction packet. + * @param[in] addr \ref BtdrvAddress + * @param[in] report_id This is sent in the packet for the Report Id, when non-zero. + * @param[in] type \ref BtdrvBluetoothHhReportType + */ +Result GetHidReport(BtdrvAddress addr, u8 report_id, BtdrvBluetoothHhReportType type); + +/** + * @brief TriggerConnection + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[in] timeout [9.0.0+] Host trigger timeout + */ +Result TriggerConnection(BtdrvAddress addr, u16 timeout); + +/** + * @brief AddPairedDeviceInfo + * @note This is used by btm-sysmodule. + * @param[in] settings \ref SetSysBluetoothDevicesSettings + */ +Result AddPairedDeviceInfo(const SetSysBluetoothDevicesSettings *settings); + +/** + * @brief GetPairedDeviceInfo + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[out] settings \ref SetSysBluetoothDevicesSettings + */ +Result GetPairedDeviceInfo(BtdrvAddress addr, SetSysBluetoothDevicesSettings *settings); + +/** + * @brief FinalizeHid + * @note This is not used by btm-sysmodule, this should not be used by other processes. + */ +Result FinalizeHid(void); + +/** + * @brief GetHidEventInfo + * @note This is used by btm-sysmodule. + * @param[out] buffer Output buffer, see \ref BtdrvHidEventInfo. + * @param[in] size Output buffer size. + * @param[out] type \ref BtdrvHidEventType, always ::BtdrvHidEventType_Connection or ::BtdrvHidEventType_Ext. + */ +Result GetHidEventInfo(void* buffer, size_t size, BtdrvHidEventType *type); + +/** + * @brief SetTsi + * @note The response will be available via \ref btdrvGetHidEventInfo ([12.0.0+] \ref btdrvGetEventInfo). + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[in] tsi Tsi: non-value-0xFF to Set, value 0xFF to Exit. See also \ref BtmTsiMode. + */ +Result SetTsi(BtdrvAddress addr, u8 tsi); + +/** + * @brief EnableBurstMode + * @note The response will be available via \ref btdrvGetHidEventInfo ([12.0.0+] \ref btdrvGetEventInfo). + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[in] flag Flag: true = Set, false = Exit. + */ +Result EnableBurstMode(BtdrvAddress addr, bool flag); + +/** + * @brief SetZeroRetransmission + * @note The response will be available via \ref btdrvGetHidEventInfo ([12.0.0+] \ref btdrvGetEventInfo). + * @note This is used by btm-sysmodule. + * @param[in] addr \ref BtdrvAddress + * @param[in] report_ids Input buffer containing an array of u8s. + * @param[in] count Total u8s in the input buffer. This can be 0, the max is 5. + */ +Result SetZeroRetransmission(BtdrvAddress addr, u8 *report_ids, u8 count); + +/** + * @brief EnableMcMode + * @note This is used by btm-sysmodule. + * @param[in] flag Flag + */ +Result EnableMcMode(bool flag); + +/** + * @brief EnableLlrScan + * @note This is used by btm-sysmodule. + */ +Result EnableLlrScan(void); + +/** + * @brief DisableLlrScan + * @note This is used by btm-sysmodule. + */ +Result DisableLlrScan(void); + +/** + * @brief EnableRadio + * @note This is used by btm-sysmodule. + * @param[in] flag Flag + */ +Result EnableRadio(bool flag); + +/** + * @brief SetVisibility + * @note This is used by btm-sysmodule. + * @param[in] inquiry_scan Controls Inquiry Scan, whether the device can be discovered during Inquiry. + * @param[in] page_scan Controls Page Scan, whether the device accepts connections. + */ +Result SetVisibility(bool inquiry_scan, bool page_scan); + +/** + * @brief EnableTbfcScan + * @note Only available on [4.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] flag Flag + */ +Result EnableTbfcScan(bool flag); + +/** + * @brief RegisterHidReportEvent + * @note This also does sharedmem init/handling if needed, on [7.0.0+]. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=true. This is signaled when data is available with \ref btdrvGetHidReportEventInfo. + */ +Result RegisterHidReportEvent(Event* out_event); + +/** + * @brief GetHidReportEventInfo + * @note \ref btdrvRegisterHidReportEvent must be used before this, on [7.0.0+]. + * @note This is used by hid-sysmodule. When used by other processes, hid/user-process will conflict. No events will be received by that user-process, or it will be corrupted, etc. + * @note [7.0.0+] When data isn't available, the type is set to ::BtdrvHidEventType_Data, with the buffer cleared to all-zero. + * @param[out] buffer Output buffer, see \ref BtdrvHidReportEventInfo. + * @param[in] size Output buffer size. + * @param[out] type \ref BtdrvHidEventType + */ +Result GetHidReportEventInfo(void* buffer, size_t size, BtdrvHidEventType *type); + +/// Gets the SharedMemory addr for HidReportEventInfo (\ref BtdrvCircularBuffer), only valid when \ref btdrvRegisterHidReportEvent was previously used, on [7.0.0+]. +void* GetHidReportEventInfoSharedmemAddr(void); + +/** + * @brief GetLatestPlr + * @param[out] out Output \ref BtdrvPlrList, on pre-9.0.0 this is \ref BtdrvPlrStatistics. + */ +Result GetLatestPlr(BtdrvPlrList *out); + +/** + * @brief GetPendingConnections + * @note The output data will be available via \ref btdrvGetHidEventInfo ([12.0.0+] \ref btdrvGetEventInfo). + * @note This is used by btm-sysmodule. + * @note Only available on [3.0.0+]. + */ +Result GetPendingConnections(void); + +/** + * @brief GetChannelMap + * @note Only available on [3.0.0+]. + * @param[out] out \ref BtdrvChannelMapList + */ +Result GetChannelMap(BtdrvChannelMapList *out); + +/** + * @brief EnableTxPowerBoostSetting + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result EnableTxPowerBoostSetting(bool flag); + +/** + * @brief IsTxPowerBoostSettingEnabled + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsTxPowerBoostSettingEnabled(bool *out); + +/** + * @brief EnableAfhSetting + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result EnableAfhSetting(bool flag); + +/** + * @brief IsAfhSettingEnabled + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsAfhSettingEnabled(bool *out); + +/** + * @brief InitializeBle + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=true. + */ +Result InitializeBle(Event* out_event); + +/** + * @brief EnableBle + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + */ +Result EnableBle(void); + +/** + * @brief DisableBle + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + */ +Result DisableBle(void); + +/** + * @brief FinalizeBle + * @note Only available on [5.0.0+]. + */ +Result FinalizeBle(void); + +/** + * @brief SetBleVisibility + * @note Only available on [5.0.0+]. + * @param[in] discoverable Whether the BLE device is discoverable. + * @param[in] connectable Whether the BLE device is connectable. + */ +Result SetBleVisibility(bool discoverable, bool connectable); + +/** + * @brief SetLeConnectionParameter + * @note Only available on [5.0.0-8.1.1]. This is the older version of \ref btdrvSetBleConnectionParameter. + * @param[in] param \ref BtdrvLeConnectionParams + */ +Result SetLeConnectionParameter(const BtdrvLeConnectionParams *param); + +/** + * @brief SetBleConnectionParameter + * @note Only available on [9.0.0+]. This is the newer version of \ref btdrvSetLeConnectionParameter. + * @param[in] addr \ref BtdrvAddress + * @param[in] param \ref BtdrvBleConnectionParameter + * @param[in] preference Unused + */ +Result SetBleConnectionParameter(BtdrvAddress addr, const BtdrvBleConnectionParameter *param, bool preference); + +/** + * @brief SetLeDefaultConnectionParameter + * @note Only available on [5.0.0-8.1.1]. This is the older version of \ref btdrvSetBleDefaultConnectionParameter. + * @param[in] param \ref BtdrvLeConnectionParams + */ +Result SetLeDefaultConnectionParameter(const BtdrvLeConnectionParams *param); + +/** + * @brief SetBleDefaultConnectionParameter + * @note Only available on [9.0.0+]. This is the newer version of \ref btdrvSetLeDefaultConnectionParameter. + * @param[in] param \ref BtdrvBleConnectionParameter + */ +Result SetBleDefaultConnectionParameter(const BtdrvBleConnectionParameter *param); + +/** + * @brief SetBleAdvertiseData + * @note Only available on [5.0.0+]. + * @param[in] data \ref BtdrvBleAdvertisePacketData + */ +Result SetBleAdvertiseData(const BtdrvBleAdvertisePacketData *data); + +/** + * @brief SetBleAdvertiseParameter + * @note Only available on [5.0.0+]. + * @param[in] addr \ref BtdrvAddress + * @param[in] min_interval Minimum advertisement interval + * @param[in] max_interval Maximum advertisement interval + */ +Result SetBleAdvertiseParameter(BtdrvAddress addr, u16 min_interval, u16 max_interval); + +/** + * @brief StartBleScan + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + */ +Result StartBleScan(void); + +/** + * @brief StopBleScan + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + */ +Result StopBleScan(void); + +/** + * @brief AddBleScanFilterCondition + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] filter \ref BtdrvBleAdvertiseFilter + */ +Result AddBleScanFilterCondition(const BtdrvBleAdvertiseFilter *filter); + +/** + * @brief DeleteBleScanFilterCondition + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] filter \ref BtdrvBleAdvertiseFilter + */ +Result DeleteBleScanFilterCondition(const BtdrvBleAdvertiseFilter *filter); + +/** + * @brief DeleteBleScanFilter + * @note Only available on [5.0.0+]. + * @param[in] index Filter index + */ +Result DeleteBleScanFilter(u8 index); + +/** + * @brief ClearBleScanFilters + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + */ +Result ClearBleScanFilters(void); + +/** + * @brief EnableBleScanFilter + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] flag Flag + */ +Result EnableBleScanFilter(bool flag); + +/** + * @brief RegisterGattClient + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result RegisterGattClient(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief UnregisterGattClient + * @note Only available on [5.0.0+]. + * @param[in] client_if Client interface ID + */ +Result UnregisterGattClient(u8 client_if); + +/** + * @brief UnregisterAllGattClients + * @note Only available on [5.0.0+]. + */ +Result UnregisterAllGattClients(void); + +/** + * @brief ConnectGattServer + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] client_if Client interface ID + * @param[in] addr \ref BtdrvAddress + * @param[in] is_direct Whether a direct connection or a background auto connection + * @param[in] AppletResourceUserId AppletResourceUserId + */ +Result ConnectGattServer(u8 client_if, BtdrvAddress addr, bool is_direct, u64 AppletResourceUserId); + +/** + * @brief CancelConnectGattServer + * @note Only available on [5.1.0+]. + * @note This is used by btm-sysmodule. + * @param[in] client_if Client interface ID + * @param[in] addr \ref BtdrvAddress + * @param[in] is_direct Whether a direct connection or a background auto connection + */ +Result CancelConnectGattServer(u8 client_if, BtdrvAddress addr, bool is_direct); + +/** + * @brief DisconnectGattServer + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] conn_id Connection ID + */ +Result DisconnectGattServer(u32 conn_id); + +/** + * @brief GetGattAttribute + * @note Only available on [5.0.0+]. + * @param[in] addr \ref BtdrvAddress, only used on pre-9.0.0. + * @param[in] conn_id Connection ID + */ +Result GetGattAttribute(BtdrvAddress addr, u32 conn_id); + +/** + * @brief GetGattService + * @note Only available on [5.0.0+]. + * @param[in] conn_id Connection ID + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result GetGattService(u32 conn_id, const BtdrvGattAttributeUuid *uuid); + +/** + * @brief ConfigureAttMtu + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] conn_id Connection ID + * @param[in] mtu MTU + */ +Result ConfigureAttMtu(u32 conn_id, u16 mtu); + +/** + * @brief RegisterGattServer + * @note Only available on [5.0.0+]. + * @note Event data generated by this call contains uninitialized junk instead of the server_if value received internally. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result RegisterGattServer(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief UnregisterGattServer + * @note Only available on [5.0.0+]. + * @param[in] server_if Server interface ID + */ +Result UnregisterGattServer(u8 server_if); + +/** + * @brief ConnectGattClient + * @note Only available on [5.0.0+]. + * @param[in] server_if Server interface ID + * @param[in] addr \ref BtdrvAddress + * @param[in] is_direct Whether a direct connection or a background auto connection + */ +Result ConnectGattClient(u8 server_if, BtdrvAddress addr, bool is_direct); + +/** + * @brief DisconnectGattClient + * @note Only available on [5.0.0+]. + * @param[in] conn_id Connection ID + * @param[in] addr \ref BtdrvAddress, only used on pre-9.0.0. + */ +Result DisconnectGattClient(u8 conn_id, BtdrvAddress addr); + +/** + * @brief AddGattService + * @note Only available on [5.0.0+]. + * @note Broken behaviour due to internal bugs. + * @param[in] server_if Server interface ID + * @param[in] uuid \ref BtdrvGattAttributeUuid + * @param[in] num_handle Number of handles + * @param[in] is_primary Is a primary service or not + */ +Result AddGattService(u8 server_if, const BtdrvGattAttributeUuid *uuid, u8 num_handle, bool is_primary); + +/** + * @brief EnableGattService + * @note Only available on [5.0.0+]. + * @note Broken behaviour due to internal bugs. + * @param[in] server_if Server interface ID + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result EnableGattService(u8 server_if, const BtdrvGattAttributeUuid *uuid); + +/** + * @brief AddGattCharacteristic + * @note Only available on [5.0.0+]. + * @note Broken behaviour due to internal bugs. + * @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] permissions \ref BtdrvGattAttributePermission + * @param[in] property \ref BtdrvGattCharacteristicProperty + */ +Result AddGattCharacteristic(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *char_uuid, u16 permissions, u8 property); + +/** + * @brief AddGattDescriptor + * @note Only available on [5.0.0+]. + * @note Broken behaviour due to internal bugs. + * @param[in] server_if Server interface ID + * @param[in] serv_uuid Service UUID \ref BtdrvGattAttributeUuid + * @param[in] desc_uuid Descriptor UUID \ref BtdrvGattAttributeUuid + * @param[in] permissions \ref BtdrvGattAttributePermission + */ +Result AddGattDescriptor(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *desc_uuid, u16 permissions); + +/** + * @brief GetBleManagedEventInfo + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[out] buffer Output buffer. 0x400-bytes from state is written here. See \ref BtdrvBleEventInfo. + * @param[in] size Output buffer size. + * @param[out] type Output BtdrvBleEventType. + */ +Result GetBleManagedEventInfo(void* buffer, size_t size, BtdrvBleEventType *type); + +/** + * @brief GetGattFirstCharacteristic + * @note Only available on [5.0.0+]. + * @param[in] conn_id Connection ID + * @param[in] serv_id Service GATT ID \ref BtdrvGattId + * @param[in] is_primary Is a primary service or not + * @param[in] filter_uuid Characteristic filter UUID \ref BtdrvGattAttributeUuid + * @param[out] out_property Output property \ref BtdrvGattCharacteristicProperty + * @param[out] out_char_id Output characteristic GATT ID \ref BtdrvGattId + */ +Result GetGattFirstCharacteristic(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattAttributeUuid *filter_uuid, u8 *out_property, BtdrvGattId *out_char_id); + +/** + * @brief GetGattNextCharacteristic + * @note Only available on [5.0.0+]. + * @param[in] conn_id Connection ID + * @param[in] serv_id Service ID \ref BtdrvGattId + * @param[in] is_primary Is a primary service or not + * @param[in] char_id Previous characteristic GATT ID \ref BtdrvGattId + * @param[in] filter_uuid Characteristic filter UUID \ref BtdrvGattAttributeUuid + * @param[out] out_property Output property \ref BtdrvGattCharacteristicProperty + * @param[out] out_char_id Output characteristic GATT ID \ref BtdrvGattId + */ +Result GetGattNextCharacteristic(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattId *char_id, const BtdrvGattAttributeUuid *filter_uuid, u8 *out_property, BtdrvGattId *out_char_id); + +/** + * @brief GetGattFirstDescriptor + * @note Only available on [5.0.0+]. + * @param[in] conn_id Connection ID + * @param[in] serv_id Service GATT ID \ref BtdrvGattId + * @param[in] is_primary Is a primary service or not + * @param[in] char_id Characteristic GATT ID \ref BtdrvGattId + * @param[in] filter_uuid Descriptor filter UUID \ref BtdrvGattAttributeUuid + * @param[out] out_desc_id Output descriptor GATT ID \ref BtdrvGattId + */ +Result GetGattFirstDescriptor(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattId *char_id, const BtdrvGattAttributeUuid *filter_uuid, BtdrvGattId *out_desc_id); + +/** + * @brief GetGattNextDescriptor + * @note Only available on [5.0.0+]. + * @param[in] conn_id Connection ID + * @param[in] serv_id Service GATT ID \ref BtdrvGattId + * @param[in] is_primary Is a primary service or not + * @param[in] char_id Characteristic GATT ID \ref BtdrvGattId + * @param[in] desc_id Previous descriptor GATT ID \ref BtdrvGattId + * @param[in] filter_uuid Descriptor filter UUID \ref BtdrvGattAttributeUuid + * @param[out] out_desc_id Output descriptor GATT ID \ref BtdrvGattId + */ +Result GetGattNextDescriptor(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, const BtdrvGattAttributeUuid *filter_uuid, BtdrvGattId *out_desc_id); + +/** + * @brief RegisterGattManagedDataPath + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result RegisterGattManagedDataPath(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief UnregisterGattManagedDataPath + * @note Only available on [5.0.0+]. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result UnregisterGattManagedDataPath(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief RegisterGattHidDataPath + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result RegisterGattHidDataPath(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief UnregisterGattHidDataPath + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result UnregisterGattHidDataPath(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief RegisterGattDataPath + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result RegisterGattDataPath(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief UnregisterGattDataPath + * @note Only available on [5.0.0+]. + * @note This is used by btm-sysmodule. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result UnregisterGattDataPath(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief ReadGattCharacteristic + * @note Only available on [5.0.0+]. + * @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 ReadGattCharacteristic(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, u8 auth_req); + +/** + * @brief ReadGattDescriptor + * @note Only available on [5.0.0+]. + * @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 ReadGattDescriptor(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, u8 auth_req); + +/** + * @brief WriteGattCharacteristic + * @note Only available on [5.0.0+]. + * @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 WriteGattCharacteristic(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 WriteGattDescriptor + * @note Only available on [5.0.0+]. + * @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 WriteGattDescriptor(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 RegisterGattNotification + * @note Only available on [5.0.0+]. + * @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 RegisterGattNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id); + +/** + * @brief UnregisterGattNotification + * @note Only available on [5.0.0+]. + * @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 UnregisterGattNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id); + +/** + * @brief GetLeHidEventInfo + * @note Only available on [5.0.0+]. + * @note The state used by this is reset after writing the data to output. + * @param[out] buffer Output buffer. 0x400-bytes from state is written here. See \ref BtdrvBleEventInfo. + * @param[in] size Output buffer size. + * @param[out] type \ref BtdrvBleEventType. + */ +Result GetLeHidEventInfo(void* buffer, size_t size, BtdrvBleEventType *type); + +/** + * @brief RegisterBleHidEvent + * @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 RegisterBleHidEvent(Event* out_event); + +/** + * @brief SetBleScanParameter + * @note Only available on [5.1.0+]. + * @note This is used by btm-sysmodule. + * @param[in] scan_interval Scan interval + * @param[in] scan_window Scan window + */ +Result SetBleScanParameter(u16 scan_interval, u16 scan_window); + +/** + * @brief MoveToSecondaryPiconet + * @note The response will be available via \ref btdrvGetHidEventInfo ([12.0.0+] \ref btdrvGetEventInfo). + * @note Only available on [10.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result MoveToSecondaryPiconet(BtdrvAddress addr); + +/** + * @brief IsBluetoothEnabled + * @note Only available on [12.0.0+]. + * @param[out] out Output flag. + */ +Result IsBluetoothEnabled(bool *out); + +/** + * @brief AcquireAudioEvent + * @note Only available on [12.0.0+]. + * @param[out] out_event Output Event. + * @param[in] autoclear Event autoclear. + */ +Result AcquireAudioEvent(Event* out_event, bool autoclear); + +/** + * @brief GetAudioEventInfo + * @note Only available on [12.0.0+]. + * @param[out] buffer Output buffer, see \ref BtdrvAudioEventInfo. + * @param[in] size Output buffer size. + * @param[out] type \ref BtdrvAudioEventType. + */ +Result GetAudioEventInfo(void* buffer, size_t size, BtdrvAudioEventType *type); + +/** + * @brief OpenAudioConnection + * @note Only available on [12.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result OpenAudioConnection(BtdrvAddress addr); + +/** + * @brief CloseAudioConnection + * @note Only available on [12.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result CloseAudioConnection(BtdrvAddress addr); + +/** + * @brief OpenAudioOut + * @note Only available on [12.0.0+]. + * @param[in] addr \ref BtdrvAddress + * @param[out] audio_handle Audio handle. + */ +Result OpenAudioOut(BtdrvAddress addr, u32 *audio_handle); + +/** + * @brief CloseAudioOut + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + */ +Result CloseAudioOut(u32 audio_handle); + +/** + * @brief StartAudioOut + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[in] pcm_param \ref BtdrvPcmParameter + * @param[in] in_latency Input latency in nanoseconds. + * @param[out] out_latency Output latency in nanoseconds. + * @param[out] out1 Unknown output. + */ +Result StartAudioOut(u32 audio_handle, const BtdrvPcmParameter *pcm_param, s64 in_latency, s64 *out_latency, u64 *out1); + +/** + * @brief StopAudioOut + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + */ +Result StopAudioOut(u32 audio_handle); + +/** + * @brief GetAudioOutState + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[out] out \ref BtdrvAudioOutState + */ +Result GetAudioOutState(u32 audio_handle, BtdrvAudioOutState *out); + +/** + * @brief GetAudioOutFeedingCodec + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[out] out \ref BtdrvAudioCodec + */ +Result GetAudioOutFeedingCodec(u32 audio_handle, BtdrvAudioCodec *out); + +/** + * @brief GetAudioOutFeedingParameter + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[out] out \ref BtdrvPcmParameter + */ +Result GetAudioOutFeedingParameter(u32 audio_handle, BtdrvPcmParameter *out); + +/** + * @brief AcquireAudioOutStateChangedEvent + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[out] out_event Output Event. + * @param[in] autoclear Event autoclear. + */ +Result AcquireAudioOutStateChangedEvent(u32 audio_handle, Event* out_event, bool autoclear); + +/** + * @brief AcquireAudioOutBufferAvailableEvent + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[out] out_event Output Event. + * @param[in] autoclear Event autoclear. + */ +Result AcquireAudioOutBufferAvailableEvent(u32 audio_handle, Event* out_event, bool autoclear); + +/** + * @brief SendAudioData + * @note Only available on [12.0.0+]. + * @param[in] audio_handle Audio handle from \ref btdrvOpenAudioOut. + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + * @param[out] Output transferred size. This is always either 0 (error occured) or the buffer size. + */ +Result SendAudioData(u32 audio_handle, const void* buffer, size_t size, u64 *transferred_size); + +/** + * @brief AcquireAudioControlInputStateChangedEvent + * @note Only available on [12.0.0+]. + * @param[out] out_event Output Event. + * @param[in] autoclear Event autoclear. + */ +Result AcquireAudioControlInputStateChangedEvent(Event* out_event, bool autoclear); + +/** + * @brief GetAudioControlInputState + * @note Only available on [12.0.0+]. + * @param[out] states Output array of \ref BtdrvAudioControlButtonState. + * @param[in] count Size of the states array in entries, the maximum is 0xF. + * @param[out] total_out Total output entries. + */ +Result GetAudioControlInputState(BtdrvAudioControlButtonState *states, s32 count, s32 *total_out); + +/** + * @brief AcquireAudioConnectionStateChangedEvent + * @note Only available on [12.0.0-13.2.1]. + * @param[out] out_event Output Event. + * @param[in] autoclear Event autoclear. + */ +Result AcquireAudioConnectionStateChangedEvent(Event* out_event, bool autoclear); + +/** + * @brief GetConnectedAudioDevice + * @note Only available on [12.0.0-13.2.1]. + * @param[out] addrs Output array of \ref BtdrvAddress. + * @param[in] count Size of the addrs array in entries, the maximum is 0x8. + * @param[out] total_out Total output entries. + */ +Result GetConnectedAudioDevice(BtdrvAddress *addrs, s32 count, s32 *total_out); + +/** + * @brief CloseAudioControlInput + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result CloseAudioControlInput(BtdrvAddress addr); + +/** + * @brief RegisterAudioControlNotification + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + * @param[in] event_type AvrcEventType + */ +Result RegisterAudioControlNotification(BtdrvAddress addr, u32 event_type); + +/** + * @brief SendAudioControlPassthroughCommand + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + * @param[in] op_id AvrcOperationId + * @param[in] state_type AvrcStateType + */ +Result SendAudioControlPassthroughCommand(BtdrvAddress addr, u32 op_id, u32 state_type); + +/** + * @brief SendAudioControlSetAbsoluteVolumeCommand + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + * @param[in] val Input value + */ +Result SendAudioControlSetAbsoluteVolumeCommand(BtdrvAddress addr, s32 val); + +/** + * @brief IsManufacturingMode + * @note Only available on [5.0.0+]. + * @param[out] out Output flag. + */ +Result IsManufacturingMode(bool *out); + +/** + * @brief EmulateBluetoothCrash + * @note Only available on [7.0.0+]. + * @param[in] reason \ref BtdrvFatalReason + */ +Result EmulateBluetoothCrash(BtdrvFatalReason reason); + +/** + * @brief GetBleChannelMap + * @note Only available on [9.0.0+]. + * @param[out] out \ref BtdrvChannelMapList + */ +Result GetBleChannelMap(BtdrvChannelMapList *out); + +/** + * @brief Read + * @note Used by \ref btdrvGetHidReportEventInfo on [7.0.0+]. + * @param c \ref BtdrvCircularBuffer + */ +void* CircularBufferRead(BtdrvCircularBuffer *c); + +/** + * @brief Free + * @note Used by \ref btdrvGetHidReportEventInfo on [7.0.0+]. + * @param c \ref BtdrvCircularBuffer + */ +bool CircularBufferFree(BtdrvCircularBuffer *c); + +} // namespace btdrv + +/// @brief C++ wrappers for the `btm` API. +/// @details Wraps: switch/services/btm.h. +namespace btm { + +/// Initialize btm. +Result Initialize(void); + +/// Exit btm. +void Exit(void); + +/// Gets the Service object for the actual btm service session. +Service* GetServiceSession(void); + +/** + * @brief GetState + * @param[out] out \ref BtmState + */ +Result GetState(BtmState *out); + +/** + * @brief GetHostDeviceProperty + * @param[out] out \ref BtmHostDeviceProperty + */ +Result GetHostDeviceProperty(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 AcquireDeviceConditionEvent(Event* out_event); + +/** + * @brief GetDeviceCondition [1.0.0-12.1.0] + * @param[out] out \ref BtmDeviceConditionList + */ +Result LegacyGetDeviceCondition(BtmDeviceConditionList *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 BtmDeviceCondition + * @param[in] count Size of the out array in entries. + * @param[out] total_out Total output entries. + */ +Result GetDeviceCondition(BtmProfile profile, BtmDeviceCondition *out, size_t count, s32 *total_out); + +/** + * @brief SetBurstMode + * @param[in] addr \ref BtdrvAddress + * @param[in] flag Flag + */ +Result SetBurstMode(BtdrvAddress addr, bool flag); + +/** + * @brief SetSlotMode + * @param[in] list \ref BtmDeviceSlotModeList + */ +Result SetSlotMode(const BtmDeviceSlotModeList *list); + +/** + * @brief SetBluetoothMode + * @note Only available on pre-9.0.0. + * @param[in] mode \ref BtmBluetoothMode + */ +Result SetBluetoothMode(BtmBluetoothMode mode); + +/** + * @brief SetWlanMode + * @param[in] mode \ref BtmWlanMode + */ +Result SetWlanMode(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 AcquireDeviceInfoEvent(Event* out_event); + +/** + * @brief GetDeviceInfo [1.0.0-12.1.0] + * @param[out] out \ref BtmDeviceInfoList + */ +Result LegacyGetDeviceInfo(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 BtmDeviceInfo + * @param[in] count Size of the out array in entries. + * @param[out] total_out Total output entries. + */ +Result GetDeviceInfo(BtmProfile profile, BtmDeviceInfo *out, size_t count, s32 *total_out); + +/** + * @brief AddDeviceInfo [1.0.0-12.1.0] + * @param[in] info \ref BtmDeviceInfo + */ +Result LegacyAddDeviceInfo(const BtmDeviceInfoLegacy *info); + +/** + * @brief AddDeviceInfo [13.0.0+] + * @param[in] info \ref BtmDeviceInfo + */ +Result AddDeviceInfo(const BtmDeviceInfo *info); + +/** + * @brief RemoveDeviceInfo + * @param[in] addr \ref BtdrvAddress + */ +Result RemoveDeviceInfo(BtdrvAddress addr); + +/** + * @brief IncreaseDeviceInfoOrder + * @param[in] addr \ref BtdrvAddress + */ +Result IncreaseDeviceInfoOrder(BtdrvAddress addr); + +/** + * @brief LlrNotify + * @param[in] addr \ref BtdrvAddress + * @param[in] unk [9.0.0+] Unknown + */ +Result LlrNotify(BtdrvAddress addr, s32 unk); + +/** + * @brief EnableRadio + */ +Result EnableRadio(void); + +/** + * @brief DisableRadio + */ +Result DisableRadio(void); + +/** + * @brief HidDisconnect + * @param[in] addr \ref BtdrvAddress + */ +Result HidDisconnect(BtdrvAddress addr); + +/** + * @brief HidSetRetransmissionMode + * @param[in] addr \ref BtdrvAddress + * @param[in] list \ref BtmZeroRetransmissionList + */ +Result HidSetRetransmissionMode(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 AcquireAwakeReqEvent(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 AcquireLlrStateEvent(Event* out_event); + +/** + * @brief IsLlrStarted + * @note Only available on [4.0.0+]. + * @param[out] out Output flag. + */ +Result IsLlrStarted(bool *out); + +/** + * @brief EnableSlotSaving + * @note Only available on [4.0.0+]. + * @param[in] flag Flag + */ +Result EnableSlotSaving(bool flag); + +/** + * @brief ProtectDeviceInfo + * @note Only available on [5.0.0+]. + * @param[in] addr \ref BtdrvAddress + * @param[in] flag Flag + */ +Result ProtectDeviceInfo(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 AcquireBleScanEvent(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 GetBleScanParameterGeneral(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 GetBleScanParameterSmartDevice(u16 parameter_id, BtdrvGattAttributeUuid *out); + +/** + * @brief StartBleScanForGeneral + * @note Only available on [5.1.0+]. + * @param[in] param \ref BtdrvBleAdvertisePacketParameter + */ +Result StartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param); + +/** + * @brief StopBleScanForGeneral + * @note Only available on [5.1.0+]. + */ +Result StopBleScanForGeneral(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 GetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out); + +/** + * @brief StartBleScanForPaired + * @note Only available on [5.1.0+]. + * @param[in] param \ref BtdrvBleAdvertisePacketParameter + */ +Result StartBleScanForPaired(BtdrvBleAdvertisePacketParameter param); + +/** + * @brief StopBleScanForPaired + * @note Only available on [5.1.0+]. + */ +Result StopBleScanForPaired(void); + +/** + * @brief StartBleScanForSmartDevice + * @note Only available on [5.1.0+]. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result StartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief StopBleScanForSmartDevice + * @note Only available on [5.1.0+]. + */ +Result StopBleScanForSmartDevice(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 GetBleScanResultsForSmartDevice(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 AcquireBleConnectionEvent(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 BleConnect(BtdrvAddress addr); + +/** + * @brief BleOverrideConnection + * @note Only available on [5.1.0+]. + * @param[in] id Same as \ref btmBleDisconnect. + */ +Result BleOverrideConnection(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 BleDisconnect(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 BleGetConnectionState(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out); + +/** + * @brief BleGetGattClientConditionList + * @note Only available on [5.0.0+]. + * @param[out] list \ref BtmGattClientConditionList + */ +Result BleGetGattClientConditionList(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 AcquireBlePairingEvent(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 BlePairDevice(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 BleUnpairDeviceOnBoth(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 BleUnPairDevice(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 BleGetPairedAddresses(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 AcquireBleServiceDiscoveryEvent(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 GetGattServices(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 GetGattService(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 GetGattIncludedServices(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 GetBelongingService(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 GetGattCharacteristics(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 GetGattDescriptors(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 AcquireBleMtuConfigEvent(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 ConfigureBleMtu(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 GetBleMtu(u32 connection_handle, u16 *out); + +/** + * @brief RegisterBleGattDataPath + * @note Only available on [5.0.0+]. + * @param[in] path \ref BtmBleDataPath + */ +Result RegisterBleGattDataPath(const BtmBleDataPath *path); + +/** + * @brief UnregisterBleGattDataPath + * @note Only available on [5.0.0+]. + * @param[in] path \ref BtmBleDataPath + */ +Result UnregisterBleGattDataPath(const BtmBleDataPath *path); + +/** + * @brief RegisterAppletResourceUserId + * @note Only available on [5.0.0+]. + * @param[in] AppletResourceUserId AppletResourceUserId + * @param[in] unk Unknown + */ +Result RegisterAppletResourceUserId(u64 AppletResourceUserId, u32 unk); + +/** + * @brief UnregisterAppletResourceUserId + * @note Only available on [5.0.0+]. + * @param[in] AppletResourceUserId AppletResourceUserId + */ +Result UnregisterAppletResourceUserId(u64 AppletResourceUserId); + +/** + * @brief SetAppletResourceUserId + * @note Only available on [5.0.0+]. + * @param[in] AppletResourceUserId AppletResourceUserId + */ +Result SetAppletResourceUserId(u64 AppletResourceUserId); + +/** + * @brief GetShortenedDeviceInfo + * @note Only available on [13.0.0+]. + * @param[in] profile \ref BtmProfile, when not ::BtmProfile_None entries are only returned which match this profile. + * @param[out] out \ref BtmShortenedDeviceInfo + * @param[in] count Size of the out array in entries. + * @param[out] total_out Total output entries. + */ +Result GetShortenedDeviceInfo(BtmProfile profile, BtmShortenedDeviceInfo *out, size_t count, s32 *total_out); + +/** + * @brief GetShortenedDeviceCondition + * @note Only available on [14.0.0+]. + * @param[in] profile \ref BtmProfile, when not ::BtmProfile_None entries are only returned which match this profile. + * @param[out] out \ref BtmShortenedDeviceCondition + * @param[in] count Size of the out array in entries. + * @param[out] total_out Total output entries. + */ +Result GetShortenedDeviceCondition(BtmProfile profile, BtmShortenedDeviceCondition *out, size_t count, s32 *total_out); + +} // namespace btm + +/// @brief C++ wrappers for the `btmsys` API. +/// @details Wraps: switch/services/btmsys.h. +namespace btmsys { + +/// Initialize btm:sys. +Result Initialize(void); + +/// Exit btm:sys. +void Exit(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 GetServiceSession(Service* srv_out); + +/// Gets the Service object for IBtmSystemCore. +Service* GetServiceSession_IBtmSystemCore(void); + +/** + * @brief StartGamepadPairing + */ +Result StartGamepadPairing(void); + +/** + * @brief CancelGamepadPairing + */ +Result CancelGamepadPairing(void); + +/** + * @brief ClearGamepadPairingDatabase + */ +Result ClearGamepadPairingDatabase(void); + +/** + * @brief GetPairedGamepadCount + * @param[out] out Output count. + */ +Result GetPairedGamepadCount(u8 *out); + +/** + * @brief EnableRadio + */ +Result EnableRadio(void); + +/** + * @brief DisableRadio + */ +Result DisableRadio(void); + +/** + * @brief GetRadioOnOff + * @param[out] out Output flag. + */ +Result GetRadioOnOff(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 AcquireRadioEvent(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 AcquireGamepadPairingEvent(Event* out_event); + +/** + * @brief IsGamepadPairingStarted + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsGamepadPairingStarted(bool *out); + +/** + * @brief StartAudioDeviceDiscovery + * @note Only available on [13.0.0+]. + */ +Result StartAudioDeviceDiscovery(void); + +/** + * @brief StopAudioDeviceDiscovery + * @note Only available on [13.0.0+]. + */ +Result StopAudioDeviceDiscovery(void); + +/** + * @brief IsDiscoveryingAudioDevice + * @note Only available on [13.0.0+]. + * @param[out] out Output flag. + */ +Result IsDiscoveryingAudioDevice(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 GetDiscoveredAudioDevice(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 AcquireAudioDeviceConnectionEvent(Event* out_event); + +/** + * @brief ConnectAudioDevice + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result ConnectAudioDevice(BtdrvAddress addr); + +/** + * @brief IsConnectingAudioDevice + * @note Only available on [13.0.0+]. + * @param[out] out Output flag. + */ +Result IsConnectingAudioDevice(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 GetConnectedAudioDevices(BtmAudioDevice *out, s32 count, s32 *total_out); + +/** + * @brief DisconnectAudioDevice + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result DisconnectAudioDevice(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 AcquirePairedAudioDeviceInfoChangedEvent(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 GetPairedAudioDevices(BtmAudioDevice *out, s32 count, s32 *total_out); + +/** + * @brief RemoveAudioDevicePairing + * @note Only available on [13.0.0+]. + * @param[in] addr \ref BtdrvAddress + */ +Result RemoveAudioDevicePairing(BtdrvAddress addr); + +/** + * @brief RequestAudioDeviceConnectionRejection + * @note Only available on [13.0.0+]. + */ +Result RequestAudioDeviceConnectionRejection(void); + +/** + * @brief CancelAudioDeviceConnectionRejection + * @note Only available on [13.0.0+]. + */ +Result CancelAudioDeviceConnectionRejection(void); + +} // namespace btmsys + +/// @brief C++ wrappers for the `btmu` API. +/// @details Wraps: switch/services/btmu.h. +namespace btmu { + +/// Initialize btm:u. +Result Initialize(void); + +/// Exit btm:u. +void Exit(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 GetServiceSession(Service* srv_out); + +/// Gets the Service object for IBtmUserCore. +Service* GetServiceSession_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 AcquireBleScanEvent(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 GetBleScanFilterParameter(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 GetBleScanFilterParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out); + +/** + * @brief StartBleScanForGeneral + * @note This is similar to \ref btmStartBleScanForGeneral. + * @param[in] param \ref BtdrvBleAdvertisePacketParameter + */ +Result StartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param); + +/** + * @brief StopBleScanForGeneral + * @note This is similar to \ref btmStopBleScanForGeneral. + */ +Result StopBleScanForGeneral(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 GetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out); + +/** + * @brief StartBleScanForPaired + * @note This is similar to \ref btmStartBleScanForPaired. + * @param[in] param \ref BtdrvBleAdvertisePacketParameter + */ +Result StartBleScanForPaired(BtdrvBleAdvertisePacketParameter param); + +/** + * @brief StopBleScanForPaired + * @note This is similar to \ref btmStopBleScanForPaired. + */ +Result StopBleScanForPaired(void); + +/** + * @brief StartBleScanForSmartDevice + * @note This is similar to \ref btmStartBleScanForSmartDevice. + * @param[in] uuid \ref BtdrvGattAttributeUuid + */ +Result StartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid); + +/** + * @brief StopBleScanForSmartDevice + * @note This is similar to \ref btmStopBleScanForSmartDevice. + */ +Result StopBleScanForSmartDevice(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 GetBleScanResultsForSmartDevice(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 AcquireBleConnectionEvent(Event* out_event); + +/** + * @brief BleConnect + * @note This is similar to \ref btmBleConnect. + * @param[in] addr \ref BtdrvAddress + */ +Result BleConnect(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 BleDisconnect(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 BleGetConnectionState(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 AcquireBlePairingEvent(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 BlePairDevice(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 BleUnPairDevice(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 BleUnPairDevice2(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 BleGetPairedDevices(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 AcquireBleServiceDiscoveryEvent(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 GetGattServices(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 GetGattService(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 GetGattIncludedServices(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 GetBelongingGattService(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 GetGattCharacteristics(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 GetGattDescriptors(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 AcquireBleMtuConfigEvent(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 ConfigureBleMtu(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 GetBleMtu(u32 connection_handle, u16 *out); + +/** + * @brief RegisterBleGattDataPath + * @note This is similar to \ref btmRegisterBleGattDataPath. + * @param[in] path \ref BtmBleDataPath + */ +Result RegisterBleGattDataPath(const BtmBleDataPath *path); + +/** + * @brief UnregisterBleGattDataPath + * @note This is similar to \ref btmUnregisterBleGattDataPath. + * @param[in] path \ref BtmBleDataPath + */ +Result UnregisterBleGattDataPath(const BtmBleDataPath *path); + +} // namespace btmu + +/// @brief C++ wrappers for the `capmtp` API. +/// @details Wraps: switch/services/capmtp.h. +namespace capmtp { + +Result Initialize(void* mem, size_t size, u32 app_count, u32 max_img, u32 max_vid, const char *other_name); + +void Exit(void); + +Service* GetRootServiceSession(void); + +Service* GetServiceSession(void); + +Result StartCommandHandler(void); + +Result StopCommandHandler(void); + +bool IsRunning(void); + +Event * GetConnectionEvent(void); + +bool IsConnected(void); + +Event * GetScanErrorEvent(void); + +Result GetScanError(void); + +} // namespace capmtp + +/// @brief C++ wrappers for the `caps` API. +/// @details Wraps: switch/services/caps.h, switch/services/capsa.h. +namespace caps { + +/// ImageOrientation +using ::AlbumImageOrientation; +/// AlbumReportOption +using ::AlbumReportOption; +/// AlbumCache +using ::CapsAlbumCache; +using ::CapsAlbumContentsUsage; +using ::CapsAlbumContentsUsageFlag; +/// AlbumEntry +using ::CapsAlbumEntry; +/// AlbumFileContents +using ::CapsAlbumFileContents; +/// AlbumFileContentsFlag +using ::CapsAlbumFileContentsFlag; +/// AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYYYMMDDHHMMSSII". +using ::CapsAlbumFileDateTime; +/// AlbumEntryId +using ::CapsAlbumFileId; +using ::CapsAlbumStorage; +using ::CapsAlbumUsage16; +using ::CapsAlbumUsage2; +using ::CapsAlbumUsage3; +/// ApplicationAlbumEntry +using ::CapsApplicationAlbumEntry; +/// ApplicationAlbumFileEntry +using ::CapsApplicationAlbumFileEntry; +/// ApplicationData +using ::CapsApplicationData; +/// ContentType +using ::CapsContentType; +/// LoadAlbumScreenShotImageOutput +using ::CapsLoadAlbumScreenShotImageOutput; +/// LoadAlbumScreenShotImageOutputForApplication +using ::CapsLoadAlbumScreenShotImageOutputForApplication; +/// ScreenShotAttribute +using ::CapsScreenShotAttribute; +/// ScreenShotAttributeForApplication. Only unk_x0 is used by official sw. +using ::CapsScreenShotAttributeForApplication; +/// ScreenShotDecodeOption +using ::CapsScreenShotDecodeOption; +/// ScreenShotDecoderFlag +using ::CapsScreenShotDecoderFlag; +/// UserIdList +using ::CapsUserIdList; + +/// Gets the ShimLibraryVersion. +u64 GetShimLibraryVersion(void); + +/// Gets the default start_datetime. +CapsAlbumFileDateTime GetDefaultStartDateTime(void); + +/// Gets the default end_datetime. +CapsAlbumFileDateTime GetDefaultEndDateTime(void); + +/// Convert a \ref CapsApplicationAlbumFileEntry to \ref CapsApplicationAlbumEntry. +void ConvertApplicationAlbumFileEntryToApplicationAlbumEntry(CapsApplicationAlbumEntry *out, CapsApplicationAlbumFileEntry *in); + +/// Convert a \ref CapsApplicationAlbumEntry to \ref CapsApplicationAlbumFileEntry. Should only be used on [7.0.0+]. +void ConvertApplicationAlbumEntryToApplicationAlbumFileEntry(CapsApplicationAlbumFileEntry *out, CapsApplicationAlbumEntry *in); + +/** + * @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 LoadAlbumScreenShotThumbnailImageEx0(u64 *width, u64 *height, CapsScreenShotAttribute *attr, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size); + +} // namespace caps + +/// @brief C++ wrappers for the `capsa` API. +/// @details Wraps: switch/services/capsa.h. +namespace capsa { + +/// Initialize caps:a. +Result Initialize(void); + +/// Exit caps:a. +void Exit(void); + +/// Gets the Service for caps:a. +Service* GetServiceSession(void); + +/// Gets the Service for IAlbumAccessorSession, only initialized after \ref capsaOpenAlbumMovieStream was used (unaffected by using \ref capsaCloseAlbumMovieStream). +Service* GetServiceSession_Accessor(void); + +/** + * @brief Gets the amount of files at a AlbumStorage. + * @param[in] storage \ref CapsAlbumStorage + * @param[out] count Amount of files. + */ +Result GetAlbumFileCount(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 GetAlbumFileList(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 LoadAlbumFile(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 DeleteAlbumFile(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 StorageCopyAlbumFile(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 IsAlbumMounted(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 GetAlbumUsage(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 GetAlbumFileSize(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 LoadAlbumFileThumbnail(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 LoadAlbumScreenShotImage(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 LoadAlbumScreenShotThumbnailImage(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 GetAlbumEntryFromApplicationAlbumEntry(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 LoadAlbumScreenShotImageEx(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 LoadAlbumScreenShotThumbnailImageEx(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 LoadAlbumScreenShotImageEx0(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 GetAlbumUsage3(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 GetAlbumMountResult(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 GetAlbumUsage16(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 GetMinMaxAppletId(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 GetAlbumFileCountEx0(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 GetAlbumFileListEx0(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 GetLastOverlayScreenShotThumbnail(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 GetLastOverlayMovieThumbnail(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 GetAutoSavingStorage(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 GetRequiredStorageSpaceSizeToCopyAll(CapsAlbumStorage dst_storage, CapsAlbumStorage src_storage, u64 *out); + +/** + * @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 LoadAlbumScreenShotImageEx1(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 LoadAlbumScreenShotThumbnailImageEx1(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 ForceAlbumUnmounted(CapsAlbumStorage storage); + +/** + * @brief Resets mount status for the specified AlbumStorage. + * @note Mounts the Storage if available. + * @param[in] storage \ref CapsAlbumStorage + */ +Result ResetAlbumMountStatus(CapsAlbumStorage storage); + +/** + * @brief Refreshs Album Cache for the specified AlbumStorage. + * @param[in] storage \ref CapsAlbumStorage + */ +Result RefreshAlbumCache(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 GetAlbumCache(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 GetAlbumCacheEx(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 GetAlbumEntryFromApplicationAlbumEntryAruid(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 OpenAlbumMovieStream(u64 *stream, const CapsAlbumFileId *file_id); + +/** + * @brief Closes an AlbumMovieStream. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result CloseAlbumMovieStream(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 GetAlbumMovieStreamSize(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 ReadMovieDataFromAlbumMovieReadStream(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 GetAlbumMovieReadStreamBrokenReason(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 GetAlbumMovieReadStreamImageDataSize(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 ReadImageDataFromAlbumMovieReadStream(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 ReadFileAttributeFromAlbumMovieReadStream(u64 stream, CapsScreenShotAttribute *attr); + +} // namespace capsa + +/// @brief C++ wrappers for the `capsc` API. +/// @details Wraps: switch/services/capsc.h. +namespace capsc { + +using ::CapsApplicationId; + +/// Initialize caps:c +Result Initialize(void); + +/// Exit caps:c. +void Exit(void); + +/// Gets the Service for caps:c. +Service* GetServiceSession(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 NotifyAlbumStorageIsAvailable(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 NotifyAlbumStorageIsUnAvailable(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 RegisterAppletResourceUserId(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 UnregisterAppletResourceUserId(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 GetApplicationIdFromAruid(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 CheckApplicationIdRegistered(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 GenerateCurrentAlbumFileId(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 GenerateApplicationAlbumEntry(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 SaveAlbumScreenShotFile(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 SaveAlbumScreenShotFileEx(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 SetOverlayScreenShotThumbnailData(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 SetOverlayMovieThumbnailData(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 OpenAlbumMovieReadStream(u64 *stream, const CapsAlbumFileId *file_id); + +/** + * @brief Closes an AlbumMovieReadStream. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result CloseAlbumMovieStream(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 GetAlbumMovieStreamSize(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 ReadMovieDataFromAlbumMovieReadStream(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 GetAlbumMovieReadStreamBrokenReason(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 GetAlbumMovieReadStreamImageDataSize(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 ReadImageDataFromAlbumMovieReadStream(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 ReadFileAttributeFromAlbumMovieReadStream(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 OpenAlbumMovieWriteStream(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 FinishAlbumMovieWriteStream(u64 stream); + +/** + * @brief Closes a finished AlbumMovieWriteStream. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result CommitAlbumMovieWriteStream(u64 stream); + +/** + * @brief Closes an AlbumMovieWriteStream in any state. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result DiscardAlbumMovieWriteStream(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 DiscardAlbumMovieWriteStreamNoDelete(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 CommitAlbumMovieWriteStreamEx(u64 stream, CapsAlbumEntry *entry); + +/** + * @brief Start AlbumMovieWriteStream data section. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result StartAlbumMovieWriteStreamDataSection(u64 stream); + +/** + * @brief End AlbumMovieWriteStream data section. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result EndAlbumMovieWriteStreamDataSection(u64 stream); + +/** + * @brief Start AlbumMovieWriteStream meta section. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result StartAlbumMovieWriteStreamMetaSection(u64 stream); + +/** + * @brief End AlbumMovieWriteStream meta section. + * @note Only available on [4.0.0+]. + * @param[in] stream Stream handle. + */ +Result EndAlbumMovieWriteStreamMetaSection(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 ReadDataFromAlbumMovieWriteStream(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 WriteDataToAlbumMovieWriteStream(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 WriteMetaToAlbumMovieWriteStream(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 GetAlbumMovieWriteStreamBrokenReason(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 GetAlbumMovieWriteStreamDataSize(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 SetAlbumMovieWriteStreamDataSize(u64 stream, u64 size); + +} // namespace capsc + +/// @brief C++ wrappers for the `capsdc` API. +/// @details Wraps: switch/services/capsdc.h. +namespace capsdc { + +/// Initialize caps:dc +Result Initialize(void); + +/// Exit caps:dc. +void Exit(void); + +/// Gets the Service for caps:dc. +Service* GetServiceSession(void); + +/** + * @brief Decodes a jpeg buffer into RGBX. + * @param[in] width Image width. + * @param[in] height Image height. + * @param[in] opts \ref CapsScreenShotDecodeOption. + * @param[in] jpeg Jpeg image input buffer. + * @param[in] jpeg_size Input image buffer size. + * @param[out] out_image RGBA8 image output buffer. + * @param[in] out_image_size Output image buffer size, should be at least large enough for RGBA8 width x height. + */ +Result DecodeJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_image, size_t out_image_size); + +/** + * @brief Shrinks a jpeg's dimensions by 2. + * @note Tries to compress with jpeg quality in this order: 98, 95, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0. + * @note Only available on [17.0.0+]. + * @param[in] width Input image width. + * @param[in] height Input image width. + * @param[in] opts \ref CapsScreenShotDecodeOption. + * @param[in] jpeg Jpeg image input buffer. + * @param[in] jpeg_size Input image buffer size. + * @param[out] out_jpeg Jpeg image output buffer + * @param[in] out_jpeg_size Output image buffer size. + * @param[out] out_result_size size of the resulting JPEG. + */ +Result ShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size); + +/** + * @brief Shrinks a jpeg. + * @note Fails if the scaled size is larger than the original or the output buffer isn't large enough. + * @note Only available on [19.0.0+]. + * @param[in] scaled_width Wanted image width. + * @param[in] scaled_height Wanted image width. + * @param[in] jpeg_quality has to be in range 0-100. + * @param[in] opts \ref CapsScreenShotDecodeOption. + * @param[in] jpeg Jpeg image input buffer. + * @param[in] jpeg_size Input image buffer size. + * @param[out] out_jpeg Jpeg image output buffer + * @param[in] out_jpeg_size Output image buffer size. + * @param[out] out_result_size size of the resulting jpeg. + */ +Result ShrinkJpegEx(u32 scaled_width, u32 scaled_height, u32 jpeg_quality, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size); + +} // namespace capsdc + +/// @brief C++ wrappers for the `capssc` API. +/// @details Wraps: switch/services/capssc.h. +namespace capssc { + +/// Initialize caps:sc. Only available on [2.0.0+]. +Result Initialize(void); + +/// Exit caps:sc. +void Exit(void); + +/// Gets the Service for caps:sc. +Service* GetServiceSession(void); + +/** + * @brief This takes a screenshot, with the screenshot being written into the output buffer. + * @note Not available with [5.0.0+] (stubbed). + * @note buffer_index and buffer_count correspond to buffers with size 0x384000(1280*720*4). These must not be negative. + * @param buf Output buffer containing the RGBA8 image. + * @param size Size of buf, should be 0x384000(1280*720*4) * buffer_count. + * @param layer_stack \ref ViLayerStack + * @param width Image width, must be 1280. + * @param height Image height, must be 720. + * @param buffer_count Total number of output image buffers. + * @param buffer_index Starting image buffer index. Must be < buffer_count. + * @param timeout Timeout in nanoseconds. A default value of 100000000 can be used. + */ +Result CaptureRawImageWithTimeout(void* buf, size_t size, ViLayerStack layer_stack, u64 width, u64 height, s64 buffer_count, s64 buffer_index, s64 timeout); + +/** + * @brief This takes a raw screenshot, with the screenshot being held until \ref capsscCloseRawScreenShotReadStream is called. + * @note Only available on [3.0.0+]. Requires debug mode. + * @param out_size Pointer to write the size of the captured raw image to. Always 0x384000(1280*720*4). + * @param out_width Pointer to write the width of the captured raw image to. Always 1280. + * @param out_height Pointer to write the height of the captured raw image to. Always 720. + * @param layer_stack \ref ViLayerStack + * @param timeout Timeout in nanoseconds. + */ +Result OpenRawScreenShotReadStream(u64 *out_size, u64 *out_width, u64 *out_height, ViLayerStack layer_stack, s64 timeout); + +/** + * @brief Discards a stream opened by \ref capsscOpenRawScreenShotReadStream. + * @note Only available on [3.0.0+]. Requires debug mode. + */ +Result CloseRawScreenShotReadStream(void); + +/** + * @brief Reads from a stream opened by \ref capsscOpenRawScreenShotReadStream. + * @note Only available on [3.0.0+]. Requires debug mode. + * @param bytes_read Pointer to write the amounts of bytes written to buffer. + * @param buf Output buffer containing the RGBA8 image. + * @param size Size of buf. + * @param offset Offset in image where read should start. + */ +Result ReadRawScreenShotReadStream(u64 *bytes_read, void* buf, size_t size, u64 offset); + +/** + * @brief This takes a screenshot, with the screenshot being written as jpeg into the output buffer. + * @note Only available on [9.0.0+]. Requires debug mode before [10.0.0]. + * @param out_jpeg_size Pointer to write the size of the captured jpeg to. + * @param jpeg_buf Output buffer containing the JPEG image. + * @param jpeg_buf_size Size of jpeg_buf, official software uses 0x80000. + * @param layer_stack \ref ViLayerStack + * @param timeout Timeout in nanoseconds. + */ +Result CaptureJpegScreenShot(u64* out_jpeg_size, void* jpeg_buf, size_t jpeg_buf_size, ViLayerStack layer_stack, s64 timeout); + +} // namespace capssc + +/// @brief C++ wrappers for the `capssu` API. +/// @details Wraps: switch/services/capssu.h. +namespace capssu { + +/// Initialize caps:su. Only available on [4.0.0+]. +Result Initialize(void); + +/// Exit caps:su. +void Exit(void); + +/// Gets the Service for caps:su. +Service* GetServiceSession(void); + +/** + * @brief This is a wrapper for \ref capssuSaveScreenShotEx0. + * @note This uses an all-zero \ref CapsScreenShotAttribute with orientation = input orientation, and unk_xc = 1. + * @param[in] buffer RGBA8 1280x720 image buffer. + * @param[in] size Size of the buffer. + * @param[in] reportoption \ref AlbumReportOption + * @param[in] orientation \ref AlbumImageOrientation + * @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL. + */ +Result SaveScreenShot(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, CapsApplicationAlbumEntry *out); + +/** + * @brief Similar to \ref capssuSaveScreenShot, except this is a wrapper for \ref capssuSaveScreenShotEx1. + * @note This uses an all-zero \ref CapsScreenShotAttribute with orientation = input orientation, and unk_xc = 1. + * @note Only available on [8.0.0+]. + * @param[in] buffer RGBA8 1280x720 image data buffer. + * @param[in] size Size of the buffer. + * @param[in] reportoption \ref AlbumReportOption + * @param[in] orientation \ref AlbumImageOrientation + * @param[in] userdata Input UserData buffer. If NULL, the \ref CapsApplicationData will be empty. + * @param[in] userdata_size Input UserData size, must be within bounds for CapsApplicationData::userdata. If 0, the \ref CapsApplicationData will be empty. + * @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL. + */ +Result SaveScreenShotWithUserData(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, const void* userdata, size_t userdata_size, CapsApplicationAlbumEntry *out); + +/** + * @brief Similar to \ref capssuSaveScreenShot, except this is a wrapper for \ref capssuSaveScreenShotEx2. + * @note This uses an all-zero \ref CapsScreenShotAttribute with orientation = input orientation, and unk_xc = 1. + * @note Only available on [6.0.0+]. + * @param[in] buffer RGBA8 1280x720 image data buffer. + * @param[in] size Size of the buffer. + * @param[in] reportoption \ref AlbumReportOption + * @param[in] orientation \ref AlbumImageOrientation + * @param[in] uids Input array of \ref AccountUid. If NULL, the \ref CapsUserIdList will be empty. + * @param[in] uid_count Size of the uids array in entries, must be within bounds for CapsUserIdList::uids. If 0, the \ref CapsUserIdList will be empty. + * @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL. + */ +Result SaveScreenShotWithUserIds(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, const AccountUid* uids, size_t uid_count, CapsApplicationAlbumEntry *out); + +/** + * @brief Saves an Album screenshot using the specified gfx data in the buffer, with the specified \ref CapsScreenShotAttribute. + * @param[in] buffer RGBA8 1280x720 image data buffer. + * @param[in] size Size of the buffer, must be at least 0x384000. + * @param[in] attr \ref CapsScreenShotAttribute + * @param[in] reportoption \ref AlbumReportOption + * @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL. + */ +Result SaveScreenShotEx0(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsApplicationAlbumEntry *out); + +/** + * @brief Same as \ref capssuSaveScreenShotEx0, except this allows specifying the \ref CapsApplicationData. + * @note Only available on [8.0.0+]. + * @param[in] buffer RGBA8 1280x720 image data buffer. + * @param[in] size Size of the buffer, must be at least 0x384000. + * @param[in] attr \ref CapsScreenShotAttribute + * @param[in] reportoption \ref AlbumReportOption + * @param[in] appdata \ref CapsApplicationData + * @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL. + */ +Result SaveScreenShotEx1(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsApplicationData *appdata, CapsApplicationAlbumEntry *out); + +/** + * @brief Same as \ref capssuSaveScreenShotEx0, except this allows specifying the \ref CapsUserIdList. + * @note Only available on [6.0.0+]. + * @param[in] buffer RGBA8 1280x720 image data buffer. + * @param[in] size Size of the buffer, must be at least 0x384000. + * @param[in] attr \ref CapsScreenShotAttribute + * @param[in] reportoption \ref AlbumReportOption + * @param[in] list \ref CapsUserIdList + * @param[out] out \ref CapsApplicationAlbumEntry. Optional, can be NULL. + */ +Result SaveScreenShotEx2(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsUserIdList *list, CapsApplicationAlbumEntry *out); + +} // namespace capssu + +/// @brief C++ wrappers for the `capsu` API. +/// @details Wraps: switch/services/capsu.h. +namespace capsu { + +/// Initialize caps:u. Only available on [5.0.0+]. +Result Initialize(void); + +/// Exit caps:u. +void Exit(void); + +/// Gets the Service for caps:u. +Service* GetServiceSession(void); + +/// Gets the Service for IAlbumAccessorApplicationSession, only initialized after \ref capsuOpenAlbumMovieStream was used (unaffected by using \ref capsuCloseAlbumMovieStream). +Service* GetServiceSession_Accessor(void); + +/** + * @brief Gets a listing of \ref CapsApplicationAlbumFileEntry. + * @note On [6.0.0+] this uses GetAlbumFileList1AafeAruidDeprecated, otherwise this uses GetAlbumFileList0AafeAruidDeprecated. + * @note This is an old version of \ref capsuGetAlbumFileList3. + * @param[out] entries Output array of \ref CapsApplicationAlbumFileEntry. + * @param[in] count Max size of the output array in entries. + * @param[in] type \ref CapsContentType + * @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[out] total_entries Total output entries. + */ +Result GetAlbumFileListDeprecated1(CapsApplicationAlbumFileEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, s32 *total_entries); + +/** + * @brief Gets a listing of \ref CapsApplicationAlbumFileEntry, where the AlbumFile has an UserId which matches the input one. See also \ref capssuSaveScreenShotWithUserIds. + * @note Only available on [6.0.0+]. + * @note This is an old version of \ref capsuGetAlbumFileList4. + * @param[out] entries Output array of \ref CapsApplicationAlbumFileEntry. + * @param[in] count Max size of the output array in entries. + * @param[in] type \ref CapsContentType + * @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[in] uid \ref AccountUid + * @param[out] total_entries Total output entries. + */ +Result GetAlbumFileListDeprecated2(CapsApplicationAlbumFileEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, AccountUid uid, s32 *total_entries); + +/** + * @brief Gets a listing of \ref CapsApplicationAlbumEntry. + * @note Only available on [7.0.0+], on prior sysvers use \ref capsuGetAlbumFileListDeprecated1 instead. + * @param[out] entries Output array of \ref CapsApplicationAlbumEntry. + * @param[in] count Max size of the output array in entries. + * @param[in] type \ref CapsContentType + * @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[out] total_entries Total output entries. + */ +Result GetAlbumFileList3(CapsApplicationAlbumEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, s32 *total_entries); + +/** + * @brief Gets a listing of \ref CapsApplicationAlbumEntry, where the AlbumFile has an UserId which matches the input one. See also \ref capssuSaveScreenShotWithUserIds. + * @note Only available on [7.0.0+], on prior sysvers use \ref capsuGetAlbumFileListDeprecated2 instead. + * @param[out] entries Output array of \ref CapsApplicationAlbumEntry. + * @param[in] count Max size of the output array in entries. + * @param[in] type \ref CapsContentType + * @param[in] start_datetime Start \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[in] end_datetime End \ref CapsAlbumFileDateTime, when NULL the default is used. + * @param[in] uid \ref AccountUid + * @param[out] total_entries Total output entries. + */ +Result GetAlbumFileList4(CapsApplicationAlbumEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, AccountUid uid, s32 *total_entries); + +/** + * @brief Deletes the specified AlbumFile. + * @param[in] type \ref CapsContentType, must match ::CapsContentType_ExtraMovie. + * @param[in] entry \ref CapsApplicationAlbumFileEntry + */ +Result DeleteAlbumFile(CapsContentType type, const CapsApplicationAlbumFileEntry *entry); + +/** + * @brief Gets the filesize for the entire specified AlbumFile. + * @param[in] entry \ref CapsApplicationAlbumFileEntry + * @param[out] size Output filesize. + */ +Result GetAlbumFileSize(const CapsApplicationAlbumFileEntry *entry, u64 *size); + +/** + * @brief Load the ScreenShotImage for the specified AlbumFile. + * @param[out] width Output image width. Optional, can be NULL. + * @param[out] height Output image height. Optional, can be NULL. + * @param[out] attr \ref CapsScreenShotAttributeForApplication + * @param[out] userdata Output buffer containing the UserData. Optional, can be NULL. This buffer is cleared to 0 using userdata_maxsize, prior to doing the memcpy. + * @param[in] userdata_maxsize Max size of the userdata buffer. Optional, can be 0. + * @param[out] userdata_size Userdata size field, clamped to max size sizeof(CapsApplicationData::userdata) when needed. + * @param[out] image RGBA8 image output buffer. + * @param[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. + * @param[in] entry \ref CapsApplicationAlbumFileEntry + * @param[in] option \ref CapsScreenShotDecodeOption + */ +Result LoadAlbumScreenShotImage(s32 *width, s32 *height, CapsScreenShotAttributeForApplication *attr, void* userdata, size_t userdata_maxsize, u32 *userdata_size, void* image, size_t image_size, void* workbuf, size_t workbuf_size, const CapsApplicationAlbumFileEntry *entry, const CapsScreenShotDecodeOption *option); + +/** + * @brief Load the ScreenShotThumbnailImage for the specified AlbumFile. + * @param[out] width Output image width. Optional, can be NULL. + * @param[out] height Output image height. Optional, can be NULL. + * @param[out] attr \ref CapsScreenShotAttributeForApplication + * @param[out] userdata Output buffer containing the UserData. Optional, can be NULL. This buffer is cleared to 0 using userdata_maxsize, prior to doing the memcpy. + * @param[in] userdata_maxsize Max size of the userdata buffer. Optional, can be 0. + * @param[out] userdata_size Userdata size field, clamped to max size sizeof(CapsApplicationData::userdata) when needed. + * @param[out] image RGBA8 image output buffer. + * @param[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. + * @param[in] entry \ref CapsApplicationAlbumFileEntry + * @param[in] option \ref CapsScreenShotDecodeOption + */ +Result LoadAlbumScreenShotThumbnailImage(s32 *width, s32 *height, CapsScreenShotAttributeForApplication *attr, void* userdata, size_t userdata_maxsize, u32 *userdata_size, void* image, size_t image_size, void* workbuf, size_t workbuf_size, const CapsApplicationAlbumFileEntry *entry, const CapsScreenShotDecodeOption *option); + +/** + * @brief PrecheckToCreateContents. Official sw only uses this with ::CapsContentType_ExtraMovie. + * @param[in] type \ref CapsContentType + * @param[in] unk Unknown. + */ +Result PrecheckToCreateContents(CapsContentType type, u64 unk); + +/** + * @brief Opens an AlbumMovieStream. + * @note This opens IAlbumAccessorApplicationSession if not previously opened, it's closed during \ref capsuExit. + * @note Up to 4 streams can be open at the same time. Multiple streams can be open at the same time for the same \ref CapsApplicationAlbumFileEntry. + * @param[out] stream Stream handle. + * @param[in] entry \ref CapsApplicationAlbumFileEntry + */ +Result OpenAlbumMovieStream(u64 *stream, const CapsApplicationAlbumFileEntry *entry); + +/** + * @brief Closes an AlbumMovieStream. + * @param[in] stream Stream handle. + */ +Result CloseAlbumMovieStream(u64 stream); + +/** + * @brief Gets the data size of an AlbumMovieStream. + * @param[in] stream Stream handle. + * @param[out] size Size of the actual MP4, without the JPEG at the end. + */ +Result GetAlbumMovieStreamSize(u64 stream, u64 *size); + +/** + * @brief Reads data from an AlbumMovieStream. + * @note offset(+size) must not be negative. offset and size must be aligned to 0x40000-bytes. + * @note When offset(+size) goes beyond the size from \ref capsuGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size. + * @param[in] stream Stream handle. + * @param[in] offset Offset. + * @param[out] Output data buffer. + * @param[in] size Data buffer size. + * @param[out] actual_size Actual read size. + */ +Result ReadAlbumMovieStream(u64 stream, s64 offset, void* buffer, size_t size, u64 *actual_size); + +/** + * @brief Gets the BrokenReason for an AlbumMovieStream. + * @note Official sw doesn't use this. + * @param[in] stream Stream handle. + */ +Result GetAlbumMovieStreamBrokenReason(u64 stream); + +} // namespace capsu + +/// @brief C++ wrappers for the `clkrst` API. +/// @details Wraps: switch/services/clkrst.h. +namespace clkrst { + +using ::ClkrstSession; + +/// Initialize clkrst. Only available on [8.0.0+]. +Result Initialize(void); + +/// Exit clkrst. +void Exit(void); + +/// Gets the Service object for the actual clkrst service session. +Service* GetServiceSession(void); + +/// Opens a ClkrstSession for the requested PcvModuleId, unk is set to 3 in official sysmodules. +Result OpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32 unk); + +void CloseSession(ClkrstSession* session); + +Result SetClockRate(ClkrstSession* session, u32 hz); + +Result GetClockRate(ClkrstSession* session, u32 *out_hz); + +// Result SetMinimumVoltageClockRate(ClkrstSession *session, u32 hz); + +Result GetPossibleClockRates(ClkrstSession *session, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count); + +// Result GetDvfsTable(ClkrstSession *session, u32 *out_rate_table, s32 in_rate_count, u32 *out_voltage_table, s32 in_voltage_count, s32 *out_count); + +} // namespace clkrst + +/// @brief C++ wrappers for the `cmac` API. +/// @details Wraps: switch/crypto/cmac.h. +namespace cmac { + +/// Context for AES-128 CMAC. +using ::Aes128CmacContext; +/// Context for AES-192 CMAC. +using ::Aes192CmacContext; +/// Context for AES-256 CMAC. +using ::Aes256CmacContext; + +/// Initialize an AES-128-CMAC context. +void Aes128ContextCreate(Aes128CmacContext *out, const void *key); + +/// Updates AES-128-CMAC context with data to hash +void Aes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size); + +/// Gets the context's output mac, finalizes the context. +void Aes128ContextGetMac(Aes128CmacContext *ctx, void *dst); + +/// Simple all-in-one AES-128-CMAC calculator. +void Aes128CalculateMac(void *dst, const void *key, const void *src, size_t size); + +/// Initialize an AES-192-CMAC context. +void Aes192ContextCreate(Aes192CmacContext *out, const void *key); + +/// Updates AES-192-CMAC context with data to hash +void Aes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size); + +/// Gets the context's output mac, finalizes the context. +void Aes192ContextGetMac(Aes192CmacContext *ctx, void *dst); + +/// Simple all-in-one AES-192-CMAC calculator. +void Aes192CalculateMac(void *dst, const void *key, const void *src, size_t size); + +/// Initialize an AES-256-CMAC context. +void Aes256ContextCreate(Aes256CmacContext *out, const void *key); + +/// Updates AES-256-CMAC context with data to hash +void Aes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size); + +/// Gets the context's output mac, finalizes the context. +void Aes256ContextGetMac(Aes256CmacContext *ctx, void *dst); + +/// Simple all-in-one AES-256-CMAC calculator. +void Aes256CalculateMac(void *dst, const void *key, const void *src, size_t size); + +} // namespace cmac + +/// @brief C++ wrappers for the `cmif` API. +/// @details Wraps: switch/sf/cmif.h. +namespace cmif { + +using ::CmifCommandType; +using ::CmifDomainInHeader; +using ::CmifDomainOutHeader; +using ::CmifDomainRequestType; +using ::CmifInHeader; +using ::CmifOutHeader; +using ::CmifRequest; +using ::CmifRequestFormat; +using ::CmifResponse; + +void* GetAlignedDataStart(u32* data_words, void* base); + +CmifRequest MakeRequest(void* base, CmifRequestFormat fmt); + +void* MakeControlRequest(void* base, u32 request_id, u32 size); + +void MakeCloseRequest(void* base, u32 object_id); + +void RequestInBuffer(CmifRequest* req, const void* buffer, size_t size, HipcBufferMode mode); + +void RequestOutBuffer(CmifRequest* req, void* buffer, size_t size, HipcBufferMode mode); + +void RequestInOutBuffer(CmifRequest* req, void* buffer, size_t size, HipcBufferMode mode); + +void RequestInPointer(CmifRequest* req, const void* buffer, size_t size); + +void RequestOutFixedPointer(CmifRequest* req, void* buffer, size_t size); + +void RequestOutPointer(CmifRequest* req, void* buffer, size_t size); + +void RequestInAutoBuffer(CmifRequest* req, const void* buffer, size_t size, HipcBufferMode mode); + +void RequestOutAutoBuffer(CmifRequest* req, void* buffer, size_t size, HipcBufferMode mode); + +void RequestObject(CmifRequest* req, u32 object_id); + +void RequestHandle(CmifRequest* req, Handle handle); + +Result ParseResponse(CmifResponse* res, void* base, bool is_domain, u32 size); + +u32 ResponseGetObject(CmifResponse* res); + +Handle ResponseGetCopyHandle(CmifResponse* res); + +Handle ResponseGetMoveHandle(CmifResponse* res); + +Result ConvertCurrentObjectToDomain(Handle h, u32* out_object_id); + +Result CopyFromCurrentDomain(Handle h, u32 object_id, Handle* out_h); + +Result CloneCurrentObject(Handle h, Handle* out_h); + +Result QueryPointerBufferSize(Handle h, u16* out_size); + +Result CloneCurrentObjectEx(Handle h, u32 tag, Handle* out_h); + +} // namespace cmif + +/// @brief C++ wrappers for the `condvar` API. +/// @details Wraps: switch/kernel/condvar.h. +namespace condvar { + +/// Condition variable. +using ::CondVar; + +/** + * @brief Initializes a condition variable. + * @param[in] c Condition variable object. + */ +void Init(CondVar* c); + +/** + * @brief Waits on a condition variable with a timeout. + * @param[in] c Condition variable object. + * @param[in] m Mutex object to use inside the condition variable. + * @param[in] timeout Timeout in nanoseconds. + * @return Result code (0xEA01 on timeout). + * @remark On function return, the underlying mutex is acquired. + */ +Result WaitTimeout(CondVar* c, Mutex* m, u64 timeout); + +/** + * @brief Waits on a condition variable. + * @param[in] c Condition variable object. + * @param[in] m Mutex object to use inside the condition variable. + * @return Result code. + * @remark On function return, the underlying mutex is acquired. + */ +Result Wait(CondVar* c, Mutex* m); + +/** + * @brief Wakes up up to the specified number of threads waiting on a condition variable. + * @param[in] c Condition variable object. + * @param[in] num Maximum number of threads to wake up (or -1 to wake them all up). + * @return Result code. + */ +Result Wake(CondVar* c, int num); + +/** + * @brief Wakes up a single thread waiting on a condition variable. + * @param[in] c Condition variable object. + * @return Result code. + */ +Result WakeOne(CondVar* c); + +/** + * @brief Wakes up all thread waiting on a condition variable. + * @param[in] c Condition variable object. + * @return Result code. + */ +Result WakeAll(CondVar* c); + +} // namespace condvar + +/// @brief C++ wrappers for the `console` API. +/// @details Wraps: switch/runtime/devices/console.h. +namespace console { + +/// A font struct for the console. +using ::ConsoleFont; +/// Renderer interface for the console. +using ::ConsoleRenderer; +/// Console debug devices supported by libnx. +using ::debugDevice; +using ::PrintConsole; + +/** + * @brief Loads the font into the console. + * @param console Pointer to the console to update, if NULL it will update the current console. + * @param font The font to load. + */ +void SetFont(PrintConsole* console, ConsoleFont* font); + +/** + * @brief Sets the print window. + * @param console Console to set, if NULL it will set the current console window. + * @param x X location of the window. + * @param y Y location of the window. + * @param width Width of the window. + * @param height Height of the window. + */ +void SetWindow(PrintConsole* console, int x, int y, int width, int height); + +/** + * @brief Gets a pointer to the console with the default values. + * This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit(). + * @return A pointer to the console with the default values. + */ +PrintConsole* GetDefault(void); + +/** + * @brief Make the specified console the render target. + * @param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)). + * @return A pointer to the previous console. + */ +PrintConsole * Select(PrintConsole* console); + +/** + * @brief Initialise the console. + * @param console A pointer to the console data to initialize (if it's NULL, the default console will be used). + * @return A pointer to the current console. + */ +PrintConsole* Init(PrintConsole* console); + +/** + * @brief Deinitialise the console. + * @param console A pointer to the console data to initialize (if it's NULL, the default console will be used). + */ +void Exit(PrintConsole* console); + +/** + * @brief Updates the console, submitting a new frame to the display. + * @param console A pointer to the console data to initialize (if it's NULL, the default console will be used). + * @remark This function should be called periodically. Failure to call this function will result in lack of screen updating. + */ +void Update(PrintConsole* console); + +/** + * @brief Initializes debug console output on stderr to the specified device. + * @param device The debug device (or devices) to output debug print statements to. + */ +void DebugInit(debugDevice device); + +/// Clears the screan by using printf("\x1b[2J"); +void Clear(void); + +} // namespace console + +/// @brief C++ wrappers for the `crc32` API. +/// @details Wraps: switch/crypto/crc.h. +namespace crc32 { + +/// 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. +u32 CalculateWithSeed(u32 seed, const void *src, size_t size); + +/// Calculate a CRC32 over data. +u32 Calculate(const void *src, size_t size); + +} // namespace crc32 + +/// @brief C++ wrappers for the `crc32c` API. +/// @details Wraps: switch/crypto/crc.h. +namespace crc32c { + +/// 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. +u32 CalculateWithSeed(u32 seed, const void *src, size_t size); + +/// Calculate a CRC32C over data. +u32 Calculate(const void *src, size_t size); + +} // namespace crc32c + +/// @brief C++ wrappers for the `csrng` API. +/// @details Wraps: switch/services/csrng.h. +namespace csrng { + +/// Initialize csrng. +Result Initialize(void); + +/// Exit csrng. +void Exit(void); + +/// Gets the Service object for the actual csrng service session. +Service* GetServiceSession(void); + +Result GetRandomBytes(void *out, size_t out_size); + +} // namespace csrng + +/// @brief C++ wrappers for the `detect` API. +/// @details Wraps: switch/kernel/detect.h. +namespace detect { + +/// Returns true if the process has a debugger attached. +bool Debugger(void); + +/// Returns true if the underlying kernel is Mesosphère. +bool Mesosphere(void); + +} // namespace detect + +/// @brief C++ wrappers for the `diag` API. +/// @details Wraps: switch/runtime/diag.h. +namespace diag { + +/** + * @brief Aborts program execution with a result code. + * @param[in] res Result code. + */ +[[noreturn]] void AbortWithResult(Result res); + +} // namespace diag + +/// @brief C++ wrappers for the `ectxr` API. +/// @details Wraps: switch/services/ectx.h. +namespace ectxr { + +/// Initialize ectx:r. +Result Initialize(void); + +/// Exit ectx:r. +void Exit(void); + +/// Gets the Service object for the actual ectx:r service session. +Service* GetServiceSession(void); + +/** + * @brief Retrieves the error context associated with an error descriptor and result. + * @param[out] out0 Output value. + * @param[out] out_total_size Total error context size. + * @param[out] out_size Error context size. + * @param[out] dst Buffer for output error context. + * @param[in] dst_size Buffer size for output error context. + * @param[in] descriptor Error descriptor. + * @param[in] result Error result. + * @return Result code. + */ +Result PullContext(s32 *out0, u32 *out_total_size, u32 *out_size, void *dst, size_t dst_size, u32 descriptor, Result result); + +} // namespace ectxr + +/// @brief C++ wrappers for the `env` API. +/// @details Wraps: switch/runtime/env.h. +namespace env { + +/// Structure representing an entry in the homebrew environment configuration. +using ::ConfigEntry; +/// Loader return function. +using ::LoaderReturnFn; + +/** + * @brief Parses the homebrew loader environment block (internally called). + * @param ctx Reserved. + * @param main_thread Reserved. + * @param saved_lr Reserved. + */ +void Setup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr); + +/// Returns information text about the loader, if present. +const char* GetLoaderInfo(void); + +/// Returns the size of the loader information text. +u64 GetLoaderInfoSize(void); + +/// Retrieves the handle to the main thread. +Handle GetMainThreadHandle(void); + +/// Returns true if the application is running as NSO, otherwise NRO. +bool IsNso(void); + +/// Returns true if the environment has a heap override. +bool HasHeapOverride(void); + +/// Returns the address of the overriden heap. +void* GetHeapOverrideAddr(void); + +/// Returns the size of the overriden heap. +u64 GetHeapOverrideSize(void); + +/// Returns true if the environment has an argv array. +bool HasArgv(void); + +/// Returns the pointer to the argv array. +void* GetArgv(void); + +/** + * @brief Returns whether a syscall is hinted to be available. + * @param svc Syscall number to test. + * @returns true if the syscall is available. + */ +bool IsSyscallHinted(unsigned svc); + +/// Returns the handle to the running homebrew process. +Handle GetOwnProcessHandle(void); + +/// Returns the loader's return function, to be called on program exit. +LoaderReturnFn GetExitFuncPtr(void); + +/// Sets the return function to be called on program exit. +void SetExitFuncPtr(LoaderReturnFn addr); + +/** + * @brief Configures the next homebrew application to load. + * @param path Path to the next homebrew application to load (.nro). + * @param argv Argument string to pass. + */ +Result SetNextLoad(const char* path, const char* argv); + +/// Returns true if the environment supports envSetNextLoad. +bool HasNextLoad(void); + +/// Returns the Result from the last NRO. +Result GetLastLoadResult(void); + +/// Returns true if the environment provides a random seed. +bool HasRandomSeed(void); + +/** + * @brief Retrieves the random seed provided by the environment. + * @param out Pointer to a u64[2] buffer which will contain the random seed on return. + */ +void GetRandomSeed(u64 out[2]); + +/// Returns a pointer to the user id storage area (if present). +AccountUid* GetUserIdStorage(void); + +} // namespace env + +/// @brief C++ wrappers for the `error` API. +/// @details Wraps: switch/applets/error.h. +namespace error { + +/// ApplicationErrorArg +using ::ErrorApplicationArg; +/// Error application config. +using ::ErrorApplicationConfig; +/// Stores error-codes which are displayed as XXXX-XXXX, low for the former and desc for the latter. +using ::ErrorCode; +/// Common error arg data. +using ::ErrorCommonArg; +/// Common header for the start of the arg storage. +using ::ErrorCommonHeader; +/// Error context. +using ::ErrorContext; +/// Error type for ErrorContext.type +using ::ErrorContextType; +/// Error arg data for EULA. +using ::ErrorEulaArg; +/// Additional input storage data for \ref errorSystemUpdateEulaShow. +using ::ErrorEulaData; +/// Error arg data for certain errors with module PCTL. +using ::ErrorPctlArg; +/// Error arg data for Record. +using ::ErrorRecordArg; +/// ResultBacktrace +using ::ErrorResultBacktrace; +/// SystemErrorArg +using ::ErrorSystemArg; +/// Error system config. +using ::ErrorSystemConfig; +/// Error type for ErrorCommonHeader.type. +using ::ErrorType; + +/** + * @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. + */ +ErrorCode CodeCreate(u32 low, u32 desc); + +/** + * @brief Creates an \ref ErrorCode with the input Result. Wrapper for \ref errorCodeCreate. + * @param res Input Result. + */ +ErrorCode CodeCreateResult(Result res); + +/** + * @brief Creates an invalid \ref ErrorCode. + */ +ErrorCode CodeCreateInvalid(void); + +/** + * @brief Checks whether the input ErrorCode is valid. + * @param errorCode \ref ErrorCode + */ +bool CodeIsValid(ErrorCode errorCode); + +/** + * @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 ResultShow(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 CodeShow(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 ResultBacktraceCreate(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 ResultBacktraceShow(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 EulaShow(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 SystemUpdateEulaShow(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 CodeRecordShow(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. + */ +Result ResultRecordShow(Result res, u64 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 SystemCreate(ErrorSystemConfig* c, const char* dialog_message, const char* fullscreen_message); + +/** + * @brief Launches the applet with the specified config. + * @param c ErrorSystemConfig struct. + */ +Result SystemShow(ErrorSystemConfig* c); + +/** + * @brief Sets the error code. + * @param c ErrorSystemConfig struct. + * @param errorCode \ref ErrorCode + */ +void SystemSetCode(ErrorSystemConfig* c, 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. + */ +void SystemSetResult(ErrorSystemConfig* c, Result res); + +/** + * @brief Sets the LanguageCode. + * @param c ErrorSystemConfig struct. + * @param LanguageCode LanguageCode, see set.h. + */ +void SystemSetLanguageCode(ErrorSystemConfig* c, u64 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 SystemSetContext(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 ApplicationCreate(ErrorApplicationConfig* c, const char* dialog_message, const char* fullscreen_message); + +/** + * @brief Launches the applet with the specified config. + * @param c ErrorApplicationConfig struct. + */ +Result ApplicationShow(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. + */ +void ApplicationSetNumber(ErrorApplicationConfig* c, u32 errorNumber); + +/** + * @brief Sets the LanguageCode. + * @param c ErrorApplicationConfig struct. + * @param LanguageCode LanguageCode, see set.h. + */ +void ApplicationSetLanguageCode(ErrorApplicationConfig* c, u64 LanguageCode); + +} // namespace error + +/// @brief C++ wrappers for the `event` API. +/// @details Wraps: switch/kernel/event.h. +namespace event { + +/// Kernel-mode event structure. +using ::Event; + +/** + * @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 Create(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 LoadRemote(Event* t, Handle handle, bool autoclear); + +/** + * @brief Closes a kernel-mode event. + * @param[in] t Pointer to \ref Event structure. + */ +void Close(Event* t); + +/** + * @brief Returns whether an \ref Event is initialized. + * @param[in] t Pointer to \ref Event structure. + * @return Initialization status. + */ +bool Active(Event* t); + +/** + * @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 Wait(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 Fire(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 Clear(Event* t); + +} // namespace event + +/// @brief C++ wrappers for the `fan` API. +/// @details Wraps: switch/services/fan.h. +namespace fan { + +using ::FanController; + +/// Initialize fan. +Result Initialize(void); + +/// Exit fan. +void Exit(void); + +/// Gets the Service object for the actual fan service session. +Service* GetServiceSession(void); + +/// Opens IController session. +Result OpenController(FanController *out, u32 device_code); + +/// Close IController session. +void ControllerClose(FanController *controller); + +/// @warning Disabling your fan can damage your system. +Result ControllerSetRotationSpeedLevel(FanController *controller, float level); + +Result ControllerGetRotationSpeedLevel(FanController *controller, float *level); + +} // namespace fan + +/// @brief C++ wrappers for the `fatal` API. +/// @details Wraps: switch/services/fatal.h. +namespace fatal { + +/// Struct for fatal Cpu context, 32-bit. +using ::FatalAarch32Context; +/// Struct for fatal Cpu context, 64-bit. +using ::FatalAarch64Context; +using ::FatalCpuContext; +/// Type of thrown fatal error. +using ::FatalPolicy; + +/** + * @brief Triggers a system fatal error. + * @param[in] err Result code to throw. + * @note This function does not return. + * @note This uses \ref fatalThrowWithPolicy with \ref FatalPolicy_ErrorScreen internally. + */ +[[noreturn]] void Throw(Result err); + +/** + * @brief Triggers a system fatal error with a custom \ref FatalPolicy. + * @param[in] err Result code to throw. + * @param[in] type Type of fatal error to throw. + * @note This function may not return, depending on \ref FatalPolicy. + */ +void ThrowWithPolicy(Result err, FatalPolicy type); + +/** + * @brief Triggers a system fatal error with a custom \ref FatalPolicy and \ref FatalCpuContext. + * @param[in] err Result code to throw. + * @param[in] type Type of fatal error to throw. + * @param[in] ctx Cpu context for fatal error to throw. + * @note This function may not return, depending on \ref FatalPolicy. + */ +void ThrowWithContext(Result err, FatalPolicy type, FatalCpuContext *ctx); + +} // namespace fatal + +/// @brief C++ wrappers for the `framebuffer` API. +/// @details Wraps: switch/display/framebuffer.h. +namespace framebuffer { + +/// Framebuffer structure. +using ::Framebuffer; + +/** + * @brief Creates a \ref Framebuffer object. + * @param[out] fb Output \ref Framebuffer structure. + * @param[in] win Pointer to the \ref NWindow to which the \ref Framebuffer will be registered. + * @param[in] width Desired width of the framebuffer (usually 1280). + * @param[in] height Desired height of the framebuffer (usually 720). + * @param[in] format Desired pixel format (see PIXEL_FORMAT_* enum). + * @param[in] num_fbs Number of buffers to create. Pass 1 for single-buffering, 2 for double-buffering or 3 for triple-buffering. + * @note Framebuffer images are stored in Tegra block linear format with 16Bx2 sector ordering, read TRM chapter 20.1 for more details. + * In order to use regular linear layout, consider calling \ref framebufferMakeLinear after the \ref Framebuffer object is created. + * @note Presently, only the following pixel formats are supported: + * \ref PIXEL_FORMAT_RGBA_8888 + * \ref PIXEL_FORMAT_RGBX_8888 + * \ref PIXEL_FORMAT_RGB_565 + * \ref PIXEL_FORMAT_BGRA_8888 + * \ref PIXEL_FORMAT_RGBA_4444 + */ +Result Create(Framebuffer* fb, NWindow *win, u32 width, u32 height, u32 format, u32 num_fbs); + +/// Enables linear framebuffer mode in a \ref Framebuffer, allocating a shadow buffer in the process. +Result MakeLinear(Framebuffer* fb); + +/// Closes a \ref Framebuffer object, freeing all resources associated with it. +void Close(Framebuffer* fb); + +/** + * @brief Begins rendering a frame in a \ref Framebuffer. + * @param[in] fb Pointer to \ref Framebuffer structure. + * @param[out] out_stride Output variable containing the distance in bytes between rows of pixels in memory. + * @return Pointer to buffer to which new graphics data should be written to. + * @note When this function is called, a buffer will be dequeued from the corresponding \ref NWindow. + * @note This function will return pointers to different buffers, depending on the number of buffers it was initialized with. + * @note If \ref framebufferMakeLinear was used, this function will instead return a pointer to the shadow linear buffer. + * In this case, the offset of a pixel is \p y * \p out_stride + \p x * \p bytes_per_pixel. + * @note Each call to \ref framebufferBegin must be paired with a \ref framebufferEnd call. + */ +void* Begin(Framebuffer* fb, u32* out_stride); + +/** + * @brief Finishes rendering a frame in a \ref Framebuffer. + * @param[in] fb Pointer to \ref Framebuffer structure. + * @note When this function is called, the written image data will be flushed and queued (presented) in the corresponding \ref NWindow. + * @note If \ref framebufferMakeLinear was used, this function will copy the image from the shadow linear buffer to the actual framebuffer, + * converting it in the process to the layout expected by the compositor. + * @note Each call to \ref framebufferBegin must be paired with a \ref framebufferEnd call. + */ +void End(Framebuffer* fb); + +} // namespace framebuffer + +/// @brief C++ wrappers for the `friends` API. +/// @details Wraps: switch/applets/friends_la.h, switch/services/friends.h. +namespace friends { + +/// FriendInvitationGameModeDescription +using ::FriendsFriendInvitationGameModeDescription; +/// FriendInvitationGroupId +using ::FriendsFriendInvitationGroupId; +/// FriendInvitationId +using ::FriendsFriendInvitationId; +/// InAppScreenName +using ::FriendsInAppScreenName; +/// Arg struct pushed for the applet input storage, for [9.0.0+]. +using ::FriendsLaArg; +/// 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. +using ::FriendsLaArgCommonData; +/// Header for the arg struct. +using ::FriendsLaArgHeader; +/// Arg type values used with \ref FriendsLaArg. +using ::FriendsLaArgType; +/// Arg struct pushed for the applet input storage, for pre-9.0.0. +using ::FriendsLaArgV1; +using ::FriendsServiceType; +/// FriendsUserSetting +using ::FriendsUserSetting; + +/** + * @brief Launches the applet with ::FriendsLaArgType_ShowFriendList, the specified input, and playStartupSound=false. + * @param[in] uid \ref AccountUid + */ +Result LaShowFriendList(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 LaShowUserDetailInfo(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 LaStartSendingFriendRequest(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 LaShowMethodsOfSendingFriendRequest(AccountUid uid); + +/** + * @brief Launches the applet with ::FriendsLaArgType_StartFacedFriendRequest, the specified input, and playStartupSound=false. + * @param[in] uid \ref AccountUid + */ +Result LaStartFacedFriendRequest(AccountUid uid); + +/** + * @brief Launches the applet with ::FriendsLaArgType_ShowReceivedFriendRequestList, the specified input, and playStartupSound=false. + * @param[in] uid \ref AccountUid + */ +Result LaShowReceivedFriendRequestList(AccountUid uid); + +/** + * @brief Launches the applet with ::FriendsLaArgType_ShowBlockedUserList, the specified input, and playStartupSound=false. + * @param[in] uid \ref AccountUid + */ +Result LaShowBlockedUserList(AccountUid uid); + +/** + * @brief Launches the applet with ::FriendsLaArgType_ShowMyProfile, the specified input, and playStartupSound=false. + * @param[in] uid \ref AccountUid + */ +Result LaShowMyProfile(AccountUid uid); + +/** + * @brief Same as \ref friendsLaShowMyProfile except with playStartupSound=true. + * @param[in] uid \ref AccountUid + */ +Result LaShowMyProfileForHomeMenu(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 LaStartFriendInvitation(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 LaStartSendingFriendInvitation(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 LaShowReceivedInvitationDetail(AccountUid uid, FriendsFriendInvitationId invitation_id, FriendsFriendInvitationGroupId invitation_group_id); + +/// Initialize friends +Result Initialize(FriendsServiceType service_type); + +/// Exit friends +void Exit(void); + +/// Gets the Service object for the friends service session. +Service* GetServiceSession(void); + +/// Gets the Service object for the actual IFriendsService service session. +Service* GetServiceSession_IFriendsService(void); + +/** + * @brief Gets the \ref FriendsUserSetting details + * @param[in] uid \ref User AccountUid. + * @param[out] user_setting \ref FriendsUserSetting + */ +Result GetUserSetting(AccountUid uid, FriendsUserSetting *user_setting); + +/** + * @brief Gets an Event which is signaled when data is available with \ref friendsTryPopFriendInvitationNotificationInfo. + * @note This is a wrapper for \ref appletGetFriendInvitationStorageChannelEvent, see that for the usage requirements. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetFriendInvitationNotificationEvent(Event *out_event); + +/** + * @brief Uses \ref appletTryPopFromFriendInvitationStorageChannel then reads the data from there into the output params. + * @note This is a wrapper for \ref appletTryPopFromFriendInvitationStorageChannel, see that for the usage requirements. + * @param[out] uid \ref AccountUid. Optional, can be NULL. + * @param[out] buffer Output buffer. + * @param[out] size Output buffer size. + * @param[out] out_size Size of the data which was written into the output buffer. Optional, can be NULL. + */ +Result TryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buffer, u64 size, u64 *out_size); + +} // namespace friends + +/// @brief C++ wrappers for the `fs` API. +/// @details Wraps: switch/services/fs.h. +namespace fs { + +/// FatFatError +using ::FatFatError; +/// FatFatReportInfo1 +using ::FatFatReportInfo1; +/// FatFatReportInfo2 +using ::FatFatReportInfo2; +/// FatFatSafeInfo +using ::FatFatSafeInfo; +/// This is nn::fssystem::ArchiveMacKey. Used by \ref setsysGetThemeKey and \ref setsysSetThemeKey. Does not appear to be in use elsewhere. +using ::FsArchiveMacKey; +/// BisPartitionId +using ::FsBisPartitionId; +/// FsContentAttributes +using ::FsContentAttributes; +using ::FsContentStorageId; +/// For use with fsFsCreateFile. +using ::FsCreateOption; +using ::FsCustomStorageId; +using ::FsDeviceOperator; +using ::FsDir; +/// Directory entry. +using ::FsDirectoryEntry; +/// Returned by fsFsGetEntryType. +using ::FsDirEntryType; +/// For use with fsFsOpenDirectory. +using ::FsDirOpenMode; +using ::FsEventNotifier; +using ::FsFile; +using ::FsFileSystem; +/// FileSystemAttribute +using ::FsFileSystemAttribute; +/// FsFileSystemProxyErrorInfo +using ::FsFileSystemProxyErrorInfo; +/// FileSystemQueryId +using ::FsFileSystemQueryId; +/// FileSystemType +using ::FsFileSystemType; +using ::FsGameCardAttribute; +/// FsGameCardErrorReportInfo +using ::FsGameCardErrorReportInfo; +using ::FsGameCardHandle; +using ::FsGameCardPartition; +using ::FsGameCardUpdatePartitionInfo; +/// ImageDirectoryId +using ::FsImageDirectoryId; +/// FsMemoryReportInfo +using ::FsMemoryReportInfo; +/// For use with fsOpenHostFileSystemWithOption +using ::FsMountHostOption; +/// For use with fsFsOpenFile. +using ::FsOpenMode; +using ::FsOperationId; +/// FsPriority +using ::FsPriority; +using ::FsRangeInfo; +/// For use with fsFileRead. +using ::FsReadOption; +using ::FsRightsId; +/// SaveDataAttribute +using ::FsSaveDataAttribute; +/// SaveDataCreationInfo +using ::FsSaveDataCreationInfo; +/// SaveDataExtraData +using ::FsSaveDataExtraData; +/// SaveDataFilter +using ::FsSaveDataFilter; +/// SaveDataFlags +using ::FsSaveDataFlags; +/// SaveDataInfo +using ::FsSaveDataInfo; +using ::FsSaveDataInfoReader; +/// SaveDataMetaInfo +using ::FsSaveDataMetaInfo; +/// SaveDataMetaType +using ::FsSaveDataMetaType; +/// SaveDataRank +using ::FsSaveDataRank; +/// SaveDataSpaceId +using ::FsSaveDataSpaceId; +/// SaveDataType +using ::FsSaveDataType; +using ::FsStorage; +/// FsStorageErrorInfo +using ::FsStorageErrorInfo; +using ::FsStorageForBatchRead; +using ::FsTimeStampRaw; +/// For use with fsFileWrite. +using ::FsWriteOption; + +/// Initialize fsp-srv. Used automatically during app startup. +Result Initialize(void); + +/// Exit fsp-srv. Used automatically during app exit. +void Exit(void); + +/// Gets the Service object for the actual fsp-srv service session. +Service* GetServiceSession(void); + +/// [5.0.0+] Configures the \ref FsPriority of all filesystem commands issued within the current thread. +void SetPriority(FsPriority prio); + +/// Mount requested filesystem type from content file +Result OpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); + +///< same as calling fsOpenFileSystemWithId with 0 as id +Result OpenDataFileSystemByCurrentProcess(FsFileSystem *out); + +Result OpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsType); + +///< [2.0.0+], like OpenFileSystemWithId but without content path. +Result OpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath, FsContentAttributes attr); + +///< works on all firmwares, id is ignored on [1.0.0], attr is ignored before [16.0.0] +Result OpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id); + +///< [3.0.0+] +Result OpenBisFileSystem(FsFileSystem* out, FsBisPartitionId partitionId, const char* string); + +Result OpenBisStorage(FsStorage* out, FsBisPartitionId partitionId); + +/// Do not call this directly, see fs_dev.h. +Result OpenSdCardFileSystem(FsFileSystem* out); + +Result OpenHostFileSystem(FsFileSystem* out, const char *path); + +Result OpenHostFileSystemWithOption(FsFileSystem* out, const char *path, u32 flags); + +///< [9.0.0+] +Result DeleteSaveDataFileSystem(u64 application_id); + +Result CreateSaveDataFileSystem(const FsSaveDataAttribute* attr, const FsSaveDataCreationInfo* creation_info, const FsSaveDataMetaInfo* meta); + +Result CreateSaveDataFileSystemBySystemSaveDataId(const FsSaveDataAttribute* attr, const FsSaveDataCreationInfo* creation_info); + +Result DeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId save_data_space_id, u64 saveID); + +///< [2.0.0+] +Result DeleteSaveDataFileSystemBySaveDataAttribute(FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute* attr); + +///< [4.0.0+] +Result IsExFatSupported(bool* out); + +Result OpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handle, FsGameCardPartition partition); + +Result ExtendSaveDataFileSystem(FsSaveDataSpaceId save_data_space_id, u64 saveID, s64 dataSize, s64 journalSize); + +///< [3.0.0+] +Result OpenSaveDataFileSystem(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute *attr); + +Result OpenSaveDataFileSystemBySystemSaveDataId(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute *attr); + +Result OpenReadOnlySaveDataFileSystem(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute *attr); + +///< [2.0.0+]. +Result ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(void* buf, size_t len, FsSaveDataSpaceId save_data_space_id, u64 saveID); + +Result ReadSaveDataFileSystemExtraData(void* buf, size_t len, u64 saveID); + +Result WriteSaveDataFileSystemExtraData(const void* buf, size_t len, FsSaveDataSpaceId save_data_space_id, u64 saveID); + +Result OpenSaveDataInfoReader(FsSaveDataInfoReader* out, FsSaveDataSpaceId save_data_space_id); + +Result OpenSaveDataInfoReaderWithFilter(FsSaveDataInfoReader* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataFilter *save_data_filter); + +///< [6.0.0+] +Result OpenImageDirectoryFileSystem(FsFileSystem* out, FsImageDirectoryId image_directory_id); + +Result OpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id); + +Result OpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); + +///< [7.0.0+] +Result OpenDataStorageByCurrentProcess(FsStorage* out); + +Result OpenDataStorageByProgramId(FsStorage *out, u64 program_id); + +///< [3.0.0+] +Result OpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId); + +Result OpenPatchDataStorageByCurrentProcess(FsStorage* out); + +Result OpenDataStorageByCurrentProcessForBatchRead(FsStorageForBatchRead* out); + +///< [23.0.0+] +Result OpenDataStorageByProgramIdForBatchRead(FsStorageForBatchRead* out, u64 id); + +///< [23.0.0+] +Result OpenDataStorageWithProgramIndexForBatchRead(FsStorageForBatchRead* out, u8 program_index); + +///< [23.0.0+] +Result OpenDataStorageByPathForBatchRead(FsStorageForBatchRead* out, const char* contentPath, FsContentAttributes attributes, FsFileSystemType fsType); + +///< [23.0.0+] +Result OpenDeviceOperator(FsDeviceOperator* out); + +Result OpenSdCardDetectionEventNotifier(FsEventNotifier* out); + +Result IsSignedSystemPartitionOnSdCardValid(bool *out); + +Result GetProgramId(u64* out, const char *path, FsContentAttributes attr); + +///< [17.0.0+] +/// Retrieves the rights id corresponding to the content path. Only available on [2.0.0-15.0.1]. +Result GetRightsIdByPath(const char* path, FsRightsId* out_rights_id); + +/// Retrieves the rights id and key generation corresponding to the content path. Only available on [3.0.0+], attr is ignored before [16.0.0]. +Result GetRightsIdAndKeyGenerationByPath(const char* path, FsContentAttributes attr, u8* out_key_generation, FsRightsId* out_rights_id); + +Result GetContentStorageInfoIndex(s32 *out); + +///< [19.0.0+] +Result DisableAutoSaveDataCreation(void); + +///< [1.0.0-21.2.0] +Result SetGlobalAccessLogMode(u32 mode); + +Result GetGlobalAccessLogMode(u32* out_mode); + +Result OutputAccessLogToSdCard(const char *log, size_t size); + +Result GetAndClearErrorInfo(FsFileSystemProxyErrorInfo *out); + +///< [2.0.0+] +Result GetAndClearMemoryReportInfo(FsMemoryReportInfo* out); + +///< [4.0.0+] +/// Only available on [7.0.0+]. +Result GetProgramIndexForAccessLog(u32 *out_program_index, u32 *out_program_count); + +Result Create_TemporaryStorage(u64 application_id, u64 owner_id, s64 size, u32 flags); + +Result Create_SystemSaveDataWithOwner(FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid, u64 owner_id, s64 size, s64 journal_size, u32 flags); + +Result Create_SystemSaveData(FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, s64 size, s64 journal_size, u32 flags); + +/// Wrapper for fsOpenSaveDataFileSystem. +/// See \ref FsSaveDataAttribute for application_id and uid. +Result Open_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid); + +/// Wrapper for fsOpenReadOnlySaveDataFileSystem. +/// Only available on [2.0.0+]. +/// See \ref FsSaveDataAttribute for application_id and uid. +Result Open_SaveDataReadOnly(FsFileSystem* out, u64 application_id, AccountUid uid); + +/// Wrapper for fsOpenSaveDataFileSystem, for opening BcatSaveData. +Result Open_BcatSaveData(FsFileSystem* out, u64 application_id); + +/// Wrapper for fsOpenSaveDataFileSystem, for opening DeviceSaveData. +/// See \ref FsSaveDataAttribute for application_id. +Result Open_DeviceSaveData(FsFileSystem* out, u64 application_id); + +/// Wrapper for fsOpenSaveDataFileSystem, for opening TemporaryStorage. +/// Only available on [3.0.0+]. +Result Open_TemporaryStorage(FsFileSystem* out); + +/// Wrapper for fsOpenSaveDataFileSystem, for opening CacheStorage. +/// Only available on [3.0.0+]. +/// See \ref FsSaveDataAttribute for application_id. +Result Open_CacheStorage(FsFileSystem* out, u64 application_id, u16 save_data_index); + +/// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId, for opening SystemSaveData. +/// WARNING: You can brick when writing to SystemSaveData, if the data is corrupted etc. +Result Open_SystemSaveData(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid); + +/// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId, for opening SystemBcatSaveData. +/// Only available on [4.0.0+]. +Result Open_SystemBcatSaveData(FsFileSystem* out, u64 system_save_data_id); + +Result FsCreateFile(FsFileSystem* fs, const char* path, s64 size, u32 option); + +Result FsDeleteFile(FsFileSystem* fs, const char* path); + +Result FsCreateDirectory(FsFileSystem* fs, const char* path); + +Result FsDeleteDirectory(FsFileSystem* fs, const char* path); + +Result FsDeleteDirectoryRecursively(FsFileSystem* fs, const char* path); + +Result FsRenameFile(FsFileSystem* fs, const char* cur_path, const char* new_path); + +Result FsRenameDirectory(FsFileSystem* fs, const char* cur_path, const char* new_path); + +Result FsGetEntryType(FsFileSystem* fs, const char* path, FsDirEntryType* out); + +Result FsOpenFile(FsFileSystem* fs, const char* path, u32 mode, FsFile* out); + +Result FsOpenDirectory(FsFileSystem* fs, const char* path, u32 mode, FsDir* out); + +Result FsCommit(FsFileSystem* fs); + +Result FsGetFreeSpace(FsFileSystem* fs, const char* path, s64* out); + +Result FsGetTotalSpace(FsFileSystem* fs, const char* path, s64* out); + +Result FsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); + +///< [3.0.0+] +Result FsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); + +///< [3.0.0+] +Result FsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryId query_id); + +///< [4.0.0+] +Result FsGetFileSystemAttribute(FsFileSystem* fs, FsFileSystemAttribute *out); + +///< [15.0.0+] +void FsClose(FsFileSystem* fs); + +/// Uses \ref fsFsQueryEntry to set the archive bit on the specified absolute directory path. +/// This will cause HOS to treat the directory as if it were a file containing the directory's concatenated contents. +Result FsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path); + +/// Wrapper for fsFsQueryEntry with FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard. +/// Only available on [8.0.0+]. +Result FsIsValidSignedSystemPartitionOnSdCard(FsFileSystem* fs, bool *out); + +Result FileRead(FsFile* f, s64 off, void* buf, u64 read_size, u32 option, u64* bytes_read); + +Result FileWrite(FsFile* f, s64 off, const void* buf, u64 write_size, u32 option); + +Result FileFlush(FsFile* f); + +Result FileSetSize(FsFile* f, s64 sz); + +Result FileGetSize(FsFile* f, s64* out); + +Result FileOperateRange(FsFile* f, FsOperationId op_id, s64 off, s64 len, FsRangeInfo* out); + +///< [4.0.0+] +void FileClose(FsFile* f); + +Result DirRead(FsDir* d, s64* total_entries, size_t max_entries, FsDirectoryEntry *buf); + +Result DirGetEntryCount(FsDir* d, s64* count); + +void DirClose(FsDir* d); + +Result StorageRead(FsStorage* s, s64 off, void* buf, u64 read_size); + +Result StorageWrite(FsStorage* s, s64 off, const void* buf, u64 write_size); + +Result StorageFlush(FsStorage* s); + +Result StorageSetSize(FsStorage* s, s64 sz); + +Result StorageGetSize(FsStorage* s, s64* out); + +Result StorageOperateRange(FsStorage* s, FsOperationId op_id, s64 off, s64 len, FsRangeInfo* out); + +///< [4.0.0+] +void StorageClose(FsStorage* s); + +Result StorageForBatchReadRead(FsStorageForBatchRead* s, s64 off, void* buf, u64 read_size); + +Result StorageForBatchReadWrite(FsStorageForBatchRead* s, s64 off, const void* buf, u64 write_size); + +Result StorageForBatchReadFlush(FsStorageForBatchRead* s); + +Result StorageForBatchReadSetSize(FsStorageForBatchRead* s, s64 sz); + +Result StorageForBatchReadGetSize(FsStorageForBatchRead* s, s64* out); + +Result StorageForBatchReadOperateRange(FsStorageForBatchRead* s, FsOperationId op_id, s64 off, s64 len, FsRangeInfo* out); + +Result StorageForBatchReadBatchRead(FsStorageForBatchRead* s, void* out0, void* out1, void* out2, void* out3, void* out4, void* out5, void* out6, const void* in); + +void StorageForBatchReadClose(FsStorageForBatchRead* s); + +/// Read FsSaveDataInfo data into the buf array. +Result SaveDataInfoReaderRead(FsSaveDataInfoReader *s, FsSaveDataInfo* buf, size_t max_entries, s64* total_entries); + +void SaveDataInfoReaderClose(FsSaveDataInfoReader *s); + +Result EventNotifierGetEventHandle(FsEventNotifier* e, Event* out, bool autoclear); + +void EventNotifierClose(FsEventNotifier* e); + +Result DeviceOperatorIsSdCardInserted(FsDeviceOperator* d, bool* out); + +Result DeviceOperatorGetSdCardSpeedMode(FsDeviceOperator* d, s64* out); + +Result DeviceOperatorGetSdCardCid(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size); + +Result DeviceOperatorGetSdCardUserAreaSize(FsDeviceOperator* d, s64* out); + +Result DeviceOperatorGetSdCardProtectedAreaSize(FsDeviceOperator* d, s64* out); + +Result DeviceOperatorGetAndClearSdCardErrorInfo(FsDeviceOperator* d, FsStorageErrorInfo* out, s64 *out_log_size, void *dst, size_t dst_size, s64 size); + +Result DeviceOperatorGetMmcCid(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size); + +Result DeviceOperatorGetMmcSpeedMode(FsDeviceOperator* d, s64* out); + +Result DeviceOperatorGetMmcPatrolCount(FsDeviceOperator* d, u32* out); + +Result DeviceOperatorGetAndClearMmcErrorInfo(FsDeviceOperator* d, FsStorageErrorInfo* out, s64 *out_log_size, void *dst, size_t dst_size, s64 size); + +Result DeviceOperatorGetMmcExtendedCsd(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size); + +Result DeviceOperatorIsGameCardInserted(FsDeviceOperator* d, bool* out); + +Result DeviceOperatorGetGameCardHandle(FsDeviceOperator* d, FsGameCardHandle* out); + +Result DeviceOperatorGetGameCardUpdatePartitionInfo(FsDeviceOperator* d, const FsGameCardHandle* handle, FsGameCardUpdatePartitionInfo* out); + +Result DeviceOperatorGetGameCardAttribute(FsDeviceOperator* d, const FsGameCardHandle* handle, u8 *out); + +Result DeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, s64* out_size, s64 size); + +Result DeviceOperatorGetGameCardIdSet(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size); + +Result DeviceOperatorGetGameCardErrorReportInfo(FsDeviceOperator* d, FsGameCardErrorReportInfo* out); + +Result DeviceOperatorGetGameCardDeviceId(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size); + +Result DeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size); + +void DeviceOperatorClose(FsDeviceOperator* d); + +} // namespace fs + +/// @brief C++ wrappers for the `fsdev` API. +/// @details Wraps: switch/runtime/devices/fs_dev.h. +namespace fsdev { + +/// Open directory struct +using ::fsdev_dir_t; + +/// Retrieves a pointer to temporary stage for reading entries +FsDirectoryEntry* DirGetEntries(fsdev_dir_t *dir); + +/// Initializes and mounts the sdmc device if accessible. +Result MountSdmc(void); + +/// Mounts the specified SaveData. +Result MountSaveData(const char *name, u64 application_id, AccountUid uid); + +/// Mounts the specified SaveData as ReadOnly. +/// Only available on [2.0.0+]. +Result MountSaveDataReadOnly(const char *name, u64 application_id, AccountUid uid); + +/// Mounts the specified BcatSaveData. +Result MountBcatSaveData(const char *name, u64 application_id); + +/// Mounts the specified DeviceSaveData. +Result MountDeviceSaveData(const char *name, u64 application_id); + +/// Mounts the TemporaryStorage for the current process. +/// Only available on [3.0.0+]. +Result MountTemporaryStorage(const char *name); + +/// Mounts the specified CacheStorage. +/// Only available on [3.0.0+]. +Result MountCacheStorage(const char *name, u64 application_id, u16 save_data_index); + +/// Mounts the specified SystemSaveData. +Result MountSystemSaveData(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 MountSystemBcatSaveData(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 MountDevice(const char *name, FsFileSystem fs); + +/// Unmounts the specified device. +int UnmountDevice(const char *name); + +/// Uses fsFsCommit() with the specified device. This must be used after any savedata-write operations(not just file-write). This should be used after each file-close where file-writing was done. +/// This is not used automatically at device unmount. +Result CommitDevice(const char *name); + +/// Returns the FsFileSystem for the specified device. Returns NULL when the specified device isn't found. +FsFileSystem* GetDeviceFileSystem(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 TranslatePath(const char *path, FsFileSystem** device, char *outpath); + +/// This calls fsFsSetConcatenationFileAttribute on the filesystem specified by the input path (as used in stdio). +Result SetConcatenationFileAttribute(const char *path); + +Result IsValidSignedSystemPartitionOnSdCard(const char *name, bool *out); + +/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio). +Result CreateFile(const char* path, size_t size, u32 flags); + +/// Recursively deletes the directory specified by the input path (as used in stdio). +Result DeleteDirectoryRecursively(const char *path); + +/// Unmounts all devices and cleans up any resources used by the FS driver. +Result UnmountAll(void); + +/// Retrieves the last native result code generated during a failed fsdev operation. +Result GetLastResult(void); + +} // namespace fsdev + +/// @brief C++ wrappers for the `fsldr` API. +/// @details Wraps: switch/services/fsldr.h. +namespace fsldr { + +using ::FsCodeInfo; + +/// Initialize fsp-ldr. +Result Initialize(void); + +/// Exit fsp-ldr. +void Exit(void); + +/// Gets the Service object for the actual fsp-ldr service session. +Service* GetServiceSession(void); + +Result OpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, NcmStorageId storage_id, const char *path, FsContentAttributes attr, FsFileSystem* out); + +Result IsArchivedProgram(u64 pid, bool *out); + +} // namespace fsldr + +/// @brief C++ wrappers for the `fspr` API. +/// @details Wraps: switch/services/fspr.h. +namespace fspr { + +/// Initialize fsp-pr. +Result Initialize(void); + +/// Exit fsp-pr. +void Exit(void); + +/// Gets the Service object for the actual fsp-pr service session. +Service* GetServiceSession(void); + +Result RegisterProgram(u64 pid, u64 tid, NcmStorageId sid, const void *fs_access_header, size_t fah_size, const void *fs_access_control, size_t fac_size, u8 fs_access_control_restriction_mode); + +Result UnregisterProgram(u64 pid); + +Result SetCurrentProcess(void); + +Result SetEnabledProgramVerification(bool enabled); + +} // namespace fspr + +/// @brief C++ wrappers for the `gpio` API. +/// @details Wraps: switch/services/gpio.h. +namespace gpio { + +using ::GpioDirection; +using ::GpioInterruptMode; +using ::GpioInterruptStatus; +using ::GpioPadName; +using ::GpioPadSession; +using ::GpioValue; + +/// Initialize gpio. +Result Initialize(void); + +/// Exit gpio. +void Exit(void); + +/// Gets the Service object for the actual gpio service session. +Service* GetServiceSession(void); + +Result OpenSession(GpioPadSession *out, GpioPadName name); + +Result OpenSession2(GpioPadSession *out, u32 device_code, u32 access_mode); + +Result IsWakeEventActive(bool *out, GpioPadName name); + +Result IsWakeEventActive2(bool *out, u32 device_code); + +Result PadSetDirection(GpioPadSession *p, GpioDirection dir); + +Result PadGetDirection(GpioPadSession *p, GpioDirection *out); + +Result PadSetInterruptMode(GpioPadSession *p, GpioInterruptMode mode); + +Result PadGetInterruptMode(GpioPadSession *p, GpioInterruptMode *out); + +Result PadSetInterruptEnable(GpioPadSession *p, bool en); + +Result PadGetInterruptEnable(GpioPadSession *p, bool *out); + +Result PadGetInterruptStatus(GpioPadSession *p, GpioInterruptStatus *out); + +///< [1.0.0-16.1.0] +Result PadClearInterruptStatus(GpioPadSession *p); + +///< [1.0.0-16.1.0] +Result PadSetValue(GpioPadSession *p, GpioValue val); + +Result PadGetValue(GpioPadSession *p, GpioValue *out); + +Result PadBindInterrupt(GpioPadSession *p, Event *out); + +Result PadUnbindInterrupt(GpioPadSession *p); + +Result PadSetDebounceEnabled(GpioPadSession *p, bool en); + +Result PadGetDebounceEnabled(GpioPadSession *p, bool *out); + +Result PadSetDebounceTime(GpioPadSession *p, s32 ms); + +Result PadGetDebounceTime(GpioPadSession *p, s32 *out); + +void PadClose(GpioPadSession *p); + +} // namespace gpio + +/// @brief C++ wrappers for the `grc` API. +/// @details Wraps: switch/services/grc.h. +namespace grc { + +/// GameMovieId +using ::GrcGameMovieId; +/// GameMovieTrimmer +using ::GrcGameMovieTrimmer; +/// IMovieMaker +using ::GrcMovieMaker; +/// OffscreenRecordingParameter +using ::GrcOffscreenRecordingParameter; +/// Stream type values for \ref grcdTransfer. +using ::GrcStream; + +/** + * @brief Creates a \ref GrcGameMovieTrimmer using \ref appletCreateGameMovieTrimmer, uses the cmds from it to trim the specified video, then closes it. + * @note See \ref appletCreateGameMovieTrimmer for the requirements for using this. + * @note This will block until video trimming finishes. + * @param[out] dst_movieid \ref GrcGameMovieId for the output video. + * @param[in] src_movieid \ref GrcGameMovieId for the input video. + * @param[in] tmem_size TransferMemory size. Official sw uses size 0x2000000. + * @param[in] thumbnail Optional, can be NULL. RGBA8 1280x720 thumbnail image data. + * @param[in] start Start timestamp in 0.5s units. + * @param[in] end End timestamp in 0.5s units. + */ +Result TrimGameMovie(GrcGameMovieId *dst_movieid, const GrcGameMovieId *src_movieid, size_t tmem_size, const void* thumbnail, s32 start, s32 end); + +/** + * @brief Creates a \ref GrcOffscreenRecordingParameter with the default values, see \ref GrcOffscreenRecordingParameter for the default values. + * @param[out] param \ref GrcOffscreenRecordingParameter + */ +void CreateOffscreenRecordingParameter(GrcOffscreenRecordingParameter *param); + +/** + * @brief Creates a \ref GrcMovieMaker using \ref appletCreateMovieMaker, and does the required initialization. + * @note See \ref appletCreateMovieMaker for the requirements for using this. + * @param[out] m \ref GrcMovieMaker + * @param[in] size TransferMemory WorkMemory size. See \ref GRC_MOVIEMAKER_WORKMEMORY_SIZE_DEFAULT. + */ +Result CreateMovieMaker(GrcMovieMaker *m, size_t size); + +/** + * @brief Closes a \ref GrcMovieMaker. + * @note This also uses \ref grcMovieMakerAbort. + * @param m \ref GrcMovieMaker + */ +void MovieMakerClose(GrcMovieMaker *m); + +/** + * @brief Gets the \ref NWindow for the specified MovieMaker. + * @param m \ref GrcMovieMaker + */ +NWindow* MovieMakerGetNWindow(GrcMovieMaker *m); + +/** + * @brief Aborts recording with the specified MovieMaker. + * @note This is used automatically by \ref grcMovieMakerClose. + * @note This will throw an error if \ref grcMovieMakerStart was not used previously, with the flag used for this being cleared afterwards on success. + * @param m \ref GrcMovieMaker + */ +Result MovieMakerAbort(GrcMovieMaker *m); + +/** + * @brief Starts recording with the specified MovieMaker and \ref GrcOffscreenRecordingParameter. + * @param m \ref GrcMovieMaker + * @param[in] param \ref GrcOffscreenRecordingParameter + */ +Result MovieMakerStart(GrcMovieMaker *m, const GrcOffscreenRecordingParameter *param); + +/** + * @brief Finishes recording with the specified MovieMaker. + * @note This automatically uses \ref grcMovieMakerAbort on error. + * @note The recorded video will not be accessible via the Album-applet since it's stored separately from other Album data. + * @param m \ref GrcMovieMaker + * @param width Width for the thumbnail, must be 1280. + * @param height Height for the thumbnail, must be 720. + * @param[in] userdata UserData input buffer for the JPEG thumbnail. Optional, can be NULL. + * @param[in] userdata_size Size of the UserData input buffer. Optional, can be 0. Must be <=0x400. + * @param[in] thumbnail RGBA8 image buffer containing the thumbnail. Optional, can be NULL. + * @param[in] thumbnail_size Size of the thumbnail buffer. Optional, can be 0. + * @param[out] entry Output \ref CapsApplicationAlbumEntry for the recorded video. Optional, can be NULL. Only available on [7.0.0+], if this is not NULL on pre-7.0.0 an error is thrown. + */ +Result MovieMakerFinish(GrcMovieMaker *m, s32 width, s32 height, const void* userdata, size_t userdata_size, const void* thumbnail, size_t thumbnail_size, CapsApplicationAlbumEntry *entry); + +/** + * @brief Gets the recording error with the specified MovieMaker. + * @param m \ref GrcMovieMaker + */ +Result MovieMakerGetError(GrcMovieMaker *m); + +/** + * @brief Encodes audio sample data with the specified MovieMaker. + * @note This waits on the event and uses the cmd repeatedly until the entire input buffer is handled. + * @note If you don't use this the recorded video will be missing audio. + * @param m \ref GrcMovieMaker + * @param[in] buffer Audio buffer. + * @param[in] size Size of the buffer. + */ +Result MovieMakerEncodeAudioSample(GrcMovieMaker *m, const void* buffer, size_t size); + +} // namespace grc + +/// @brief C++ wrappers for the `grcd` API. +/// @details Wraps: switch/services/grc.h. +namespace grcd { + +/// GameMovieId +using ::GrcGameMovieId; +/// GameMovieTrimmer +using ::GrcGameMovieTrimmer; +/// IMovieMaker +using ::GrcMovieMaker; +/// OffscreenRecordingParameter +using ::GrcOffscreenRecordingParameter; +/// Stream type values for \ref grcdTransfer. +using ::GrcStream; + +/// Initialize grc:d. +Result Initialize(void); + +/// Exit grc:d. +void Exit(void); + +/// Gets the Service for grc:d. +Service* GetServiceSession(void); + +/// Begins streaming. This must not be called more than once, even from a different service session: otherwise the sysmodule will assert. +Result Begin(void); + +/** + * @brief Retrieves stream data from the continuous recorder in use (from the video recording of the currently running application). + * @note This will block until data is available. This will hang if there is no application running which has video capture enabled. + * @param[in] stream \ref GrcStream + * @param[out] buffer Output buffer. + * @param[in] size Max size of the output buffer. + * @param[out] num_frames num_frames + * @param[out] data_size Actual output data size. + * @param[out] start_timestamp Start timestamp. + */ +Result Transfer(GrcStream stream, void* buffer, size_t size, u32 *num_frames, u32 *data_size, u64 *start_timestamp); + +} // namespace grcd + +/// @brief C++ wrappers for the `hid` API. +/// @details Wraps: switch/applets/hid_la.h, switch/services/hid.h. +namespace hid { + +/// HidAnalogStickCalibrationStateImpl +using ::HidAnalogStickCalibrationStateImpl; +/// HidAnalogStickCalibrationStateImplAtomicStorage +using ::HidAnalogStickCalibrationStateImplAtomicStorage; +/// HidAnalogStickCalibrationStateImplLifo +using ::HidAnalogStickCalibrationStateImplLifo; +/// HidAnalogStickState +using ::HidAnalogStickState; +/// AppletFooterUiType (system) +using ::HidAppletFooterUiType; +/// HidBasicXpadLifo +using ::HidBasicXpadLifo; +/// HidBasicXpadSharedMemoryEntry +using ::HidBasicXpadSharedMemoryEntry; +/// HidBasicXpadSharedMemoryFormat +using ::HidBasicXpadSharedMemoryFormat; +/// HidBasicXpadState +using ::HidBasicXpadState; +/// HidBasicXpadStateAtomicStorage +using ::HidBasicXpadStateAtomicStorage; +/// HidCaptureButtonLifo +using ::HidCaptureButtonLifo; +/// HidCaptureButtonSharedMemoryFormat +using ::HidCaptureButtonSharedMemoryFormat; +/// HidCaptureButtonState +using ::HidCaptureButtonState; +/// HidCaptureButtonStateAtomicStorage +using ::HidCaptureButtonStateAtomicStorage; +/// HidColorAttribute +using ::HidColorAttribute; +/// HidCommonLifoHeader +using ::HidCommonLifoHeader; +/// HidConsoleSixAxisSensor +using ::HidConsoleSixAxisSensor; +/// HidDebugPadAttribute +using ::HidDebugPadAttribute; +/// HidDebugPadButton +using ::HidDebugPadButton; +/// HidDebugPadLifo +using ::HidDebugPadLifo; +/// HidDebugPadSharedMemoryFormat +using ::HidDebugPadSharedMemoryFormat; +/// HidDebugPadState +using ::HidDebugPadState; +/// HidDebugPadStateAtomicStorage +using ::HidDebugPadStateAtomicStorage; +/// Internal DeviceType for [9.0.0+]. Converted to/from the pre-9.0.0 version of this by the hiddbg funcs. +using ::HidDeviceType; +/// DeviceType (system) +using ::HidDeviceTypeBits; +/// HidDigitizerLifo +using ::HidDigitizerLifo; +/// HidDigitizerSharedMemoryFormat +using ::HidDigitizerSharedMemoryFormat; +/// HidDigitizerState +using ::HidDigitizerState; +/// HidDigitizerStateAtomicStorage +using ::HidDigitizerStateAtomicStorage; +/// HidDirectionState +using ::HidDirectionState; +/// HidGestureAttribute +using ::HidGestureAttribute; +/// HidGestureDirection +using ::HidGestureDirection; +/// HidGestureDummyStateAtomicStorage +using ::HidGestureDummyStateAtomicStorage; +/// HidGestureLifo +using ::HidGestureLifo; +/// HidGesturePoint +using ::HidGesturePoint; +/// HidGestureSharedMemoryFormat +using ::HidGestureSharedMemoryFormat; +/// HidGestureState +using ::HidGestureState; +/// HidGestureType +using ::HidGestureType; +/// GyroscopeZeroDriftMode +using ::HidGyroscopeZeroDriftMode; +/// HidHomeButtonLifo +using ::HidHomeButtonLifo; +/// HidHomeButtonSharedMemoryFormat +using ::HidHomeButtonSharedMemoryFormat; +/// HidHomeButtonState +using ::HidHomeButtonState; +/// HidHomeButtonStateAtomicStorage +using ::HidHomeButtonStateAtomicStorage; +/// HidInputDetectorLifo +using ::HidInputDetectorLifo; +/// HidInputDetectorSharedMemoryEntry +using ::HidInputDetectorSharedMemoryEntry; +/// HidInputDetectorSharedMemoryFormat +using ::HidInputDetectorSharedMemoryFormat; +/// HidInputDetectorState +using ::HidInputDetectorState; +/// HidInputDetectorStateAtomicStorage +using ::HidInputDetectorStateAtomicStorage; +/// HidKeyboardKey +using ::HidKeyboardKey; +/// HidKeyboardLifo +using ::HidKeyboardLifo; +/// KeyboardLockKeyEvent +using ::HidKeyboardLockKeyEvent; +/// HidKeyboardModifier +using ::HidKeyboardModifier; +/// HidKeyboardSharedMemoryFormat +using ::HidKeyboardSharedMemoryFormat; +/// HidKeyboardState +using ::HidKeyboardState; +/// HidKeyboardStateAtomicStorage +using ::HidKeyboardStateAtomicStorage; +/// ControllerFirmwareUpdateArg +using ::HidLaControllerFirmwareUpdateArg; +/// ControllerKeyRemappingArg +using ::HidLaControllerKeyRemappingArg; +/// ControllerSupportArg for [8.0.0+], converted to \ref HidLaControllerSupportArgV3 on pre-8.0.0. +using ::HidLaControllerSupportArg; +/// Identification color used by HidLaControllerSupportArg*. When HidLaControllerSupportArgHeader::enable_identification_color is set this controls the color of the UI player box outline. +using ::HidLaControllerSupportArgColor; +/// 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. +using ::HidLaControllerSupportArgHeader; +/// ControllerSupportArgPrivate +using ::HidLaControllerSupportArgPrivate; +/// ControllerSupportArg for [1.0.0+]. +using ::HidLaControllerSupportArgV3; +/// ControllerSupportCaller +using ::HidLaControllerSupportCaller; +/// Mode values for HidLaControllerSupportArgPrivate::mode. +using ::HidLaControllerSupportMode; +/// ControllerSupportResultInfo. First 8-bytes from the applet output storage. +using ::HidLaControllerSupportResultInfo; +/// Struct for the applet output storage. +using ::HidLaControllerSupportResultInfoInternal; +/// HidMouseAttribute +using ::HidMouseAttribute; +/// HidMouseButton +using ::HidMouseButton; +/// HidMouseLifo +using ::HidMouseLifo; +/// HidMouseSharedMemoryFormat +using ::HidMouseSharedMemoryFormat; +/// HidMouseState +using ::HidMouseState; +/// HidMouseStateAtomicStorage +using ::HidMouseStateAtomicStorage; +/// HidNfcXcdDeviceHandleState +using ::HidNfcXcdDeviceHandleState; +/// HidNfcXcdDeviceHandleStateImpl +using ::HidNfcXcdDeviceHandleStateImpl; +/// HidNfcXcdDeviceHandleStateImplAtomicStorage +using ::HidNfcXcdDeviceHandleStateImplAtomicStorage; +/// HidNpadAttribute +using ::HidNpadAttribute; +/// HidNpadButton +using ::HidNpadButton; +/// HidNpadCommonLifo +using ::HidNpadCommonLifo; +/// HidNpadCommonState +using ::HidNpadCommonState; +///< State for ::HidNpadStyleTag_NpadSystem. Analog-sticks state are always zero. Only the following button bits are available: HidNpadButton_A, HidNpadButton_B, HidNpadButton_X, HidNpadButton_Y, HidNpadButton_Left, HidNpadButton_Up, HidNpadButton_Right, HidNpadButton_Down, HidNpadButton_L, HidNpadButton_R. +/// HidNpadCommonStateAtomicStorage +using ::HidNpadCommonStateAtomicStorage; +/// NpadCommunicationMode +using ::HidNpadCommunicationMode; +/// Npad colors. +/// Color fields are zero when not set. +using ::HidNpadControllerColor; +/// HidNpadFullKeyColorState +using ::HidNpadFullKeyColorState; +using ::HidNpadFullKeyState; +///< State for ::HidNpadStyleTag_NpadJoyRight. +/// State for ::HidNpadStyleTag_NpadGc. Loaded from the same lifo as \ref HidNpadFullKeyState, with the additional trigger_l/trigger_r loaded from elsewhere. +using ::HidNpadGcState; +/// HidNpadGcTriggerLifo +using ::HidNpadGcTriggerLifo; +/// HidNpadGcTriggerState +using ::HidNpadGcTriggerState; +/// HidNpadGcTriggerStateAtomicStorage +using ::HidNpadGcTriggerStateAtomicStorage; +/// This controls how many Joy-Cons must be attached for handheld-mode to be activated. +using ::HidNpadHandheldActivationMode; +/// State for ::HidNpadStyleTag_NpadHandheldLark. The base state is loaded from the same lifo as \ref HidNpadHandheldState. +using ::HidNpadHandheldLarkState; +///< State for ::HidNpadStyleTag_NpadFullKey. +using ::HidNpadHandheldState; +/// HID controller IDs +using ::HidNpadIdType; +/// NpadInterfaceType (system) +using ::HidNpadInterfaceType; +/// HidNpadInternalState +using ::HidNpadInternalState; +/// NpadJoyAssignmentMode +using ::HidNpadJoyAssignmentMode; +/// HidNpadJoyColorState +using ::HidNpadJoyColorState; +/// NpadJoyDeviceType +using ::HidNpadJoyDeviceType; +///< State for ::HidNpadStyleTag_NpadHandheld. +using ::HidNpadJoyDualState; +/// NpadJoyHoldType +using ::HidNpadJoyHoldType; +///< State for ::HidNpadStyleTag_NpadJoyDual. +using ::HidNpadJoyLeftState; +///< State for ::HidNpadStyleTag_NpadJoyLeft. +using ::HidNpadJoyRightState; +using ::HidNpadLagerState; +/// NpadLagerType +using ::HidNpadLagerType; +///< State for ::HidNpadStyleTag_NpadPalma. +/// State for ::HidNpadStyleTag_NpadLark. The base state is loaded from the same lifo as \ref HidNpadFullKeyState. +using ::HidNpadLarkState; +/// NpadLarkType +using ::HidNpadLarkType; +/// State for ::HidNpadStyleTag_NpadLucia. The base state is loaded from the same lifo as \ref HidNpadFullKeyState. +using ::HidNpadLuciaState; +/// NpadLuciaType +using ::HidNpadLuciaType; +using ::HidNpadPalmaState; +/// HidNpadSharedMemoryEntry +using ::HidNpadSharedMemoryEntry; +/// HidNpadSharedMemoryFormat +using ::HidNpadSharedMemoryFormat; +/// HidNpadSixAxisSensorLifo +using ::HidNpadSixAxisSensorLifo; +/// HID controller styles +using ::HidNpadStyleTag; +/// NpadSystemButtonProperties +using ::HidNpadSystemButtonProperties; +///< State for ::HidNpadStyleTag_NpadLager. Analog-sticks state are always zero. +using ::HidNpadSystemExtState; +/// NpadSystemProperties +using ::HidNpadSystemProperties; +///< State for ::HidNpadStyleTag_NpadSystemExt. +using ::HidNpadSystemState; +/// PalmaActivityEntry +using ::HidPalmaActivityEntry; +/// PalmaApplicationSectionAccessBuffer +using ::HidPalmaApplicationSectionAccessBuffer; +/// PalmaConnectionHandle +using ::HidPalmaConnectionHandle; +/// PalmaFeature +using ::HidPalmaFeature; +/// PalmaFrModeType +using ::HidPalmaFrModeType; +/// PalmaOperationInfo +using ::HidPalmaOperationInfo; +/// PalmaOperationType +using ::HidPalmaOperationType; +/// PalmaWaveSet +using ::HidPalmaWaveSet; +/// HidPowerInfo (system) +using ::HidPowerInfo; +/// HidSevenSixAxisSensorState +using ::HidSevenSixAxisSensorState; +/// HidSevenSixAxisSensorStateEntry +using ::HidSevenSixAxisSensorStateEntry; +/// HidSevenSixAxisSensorStates +using ::HidSevenSixAxisSensorStates; +/// HidSharedMemory +using ::HidSharedMemory; +/// HidSixAxisSensorAttribute +using ::HidSixAxisSensorAttribute; +/// HidSixAxisSensorHandle +using ::HidSixAxisSensorHandle; +/// HidSixAxisSensorState +using ::HidSixAxisSensorState; +/// HidSixAxisSensorStateAtomicStorage +using ::HidSixAxisSensorStateAtomicStorage; +/// HidSixAxisSensorUserCalibrationState +using ::HidSixAxisSensorUserCalibrationState; +/// HidSixAxisSensorUserCalibrationStateAtomicStorage +using ::HidSixAxisSensorUserCalibrationStateAtomicStorage; +/// HidSixAxisSensorUserCalibrationStateLifo +using ::HidSixAxisSensorUserCalibrationStateLifo; +/// HidSleepButtonLifo +using ::HidSleepButtonLifo; +/// HidSleepButtonSharedMemoryFormat +using ::HidSleepButtonSharedMemoryFormat; +/// HidSleepButtonState +using ::HidSleepButtonState; +/// HidSleepButtonStateAtomicStorage +using ::HidSleepButtonStateAtomicStorage; +/// HidTouchAttribute +using ::HidTouchAttribute; +/// HidTouchScreenConfigurationForNx +using ::HidTouchScreenConfigurationForNx; +/// HidTouchScreenLifo +using ::HidTouchScreenLifo; +/// HidTouchScreenModeForNx +using ::HidTouchScreenModeForNx; +/// HidTouchScreenSharedMemoryFormat +using ::HidTouchScreenSharedMemoryFormat; +/// HidTouchScreenState +using ::HidTouchScreenState; +/// HidTouchScreenStateAtomicStorage +using ::HidTouchScreenStateAtomicStorage; +/// HidTouchState +using ::HidTouchState; +/// HidUniquePadConfig +using ::HidUniquePadConfig; +/// HidUniquePadConfigAtomicStorage +using ::HidUniquePadConfigAtomicStorage; +/// HidUniquePadConfigLifo +using ::HidUniquePadConfigLifo; +/// HidUniquePadConfigMutex +using ::HidUniquePadConfigMutex; +/// HidUniquePadLifo +using ::HidUniquePadLifo; +/// HidUniquePadSharedMemoryEntry +using ::HidUniquePadSharedMemoryEntry; +/// HidUniquePadSharedMemoryFormat +using ::HidUniquePadSharedMemoryFormat; +/// HidVector +using ::HidVector; +/// HidVibrationDeviceHandle +using ::HidVibrationDeviceHandle; +/// HidVibrationDeviceInfo +using ::HidVibrationDeviceInfo; +/// VibrationDevicePosition +using ::HidVibrationDevicePosition; +/// Type values for HidVibrationDeviceInfo::type. +using ::HidVibrationDeviceType; +/// VibrationGcErmCommand +using ::HidVibrationGcErmCommand; +/// HidVibrationValue +using ::HidVibrationValue; +/// XcdDeviceHandle +using ::XcdDeviceHandle; +/// XcdInterfaceType +using ::XcdInterfaceType; + +/** + * @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 LaCreateControllerSupportArg(HidLaControllerSupportArg *arg); + +/** + * @brief Initializes a \ref HidLaControllerFirmwareUpdateArg with the defaults. + * @note This just uses memset() with the arg. + * @param[out] arg \ref HidLaControllerFirmwareUpdateArg + */ +void LaCreateControllerFirmwareUpdateArg(HidLaControllerFirmwareUpdateArg *arg); + +/** + * @brief Initializes a \ref HidLaControllerKeyRemappingArg with the defaults. + * @note This just uses memset() with the arg. + * @param[out] arg \ref HidLaControllerKeyRemappingArg + */ +void LaCreateControllerKeyRemappingArg(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 LaSetExplainText(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 LaShowControllerSupport(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg); + +/** + * @brief Launches the applet for ControllerStrapGuide. + * @note Only available on [3.0.0+]. + */ +Result LaShowControllerStrapGuide(void); + +/** + * @brief Launches the applet for ControllerFirmwareUpdate. + * @note Only available on [3.0.0+]. + * @param[in] arg \ref HidLaControllerFirmwareUpdateArg + */ +Result LaShowControllerFirmwareUpdate(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 LaShowControllerSupportForSystem(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 LaShowControllerFirmwareUpdateForSystem(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 LaShowControllerKeyRemappingForSystem(const HidLaControllerKeyRemappingArg *arg, HidLaControllerSupportCaller caller); + +/// Initialize hid. Called automatically during app startup. +Result Initialize(void); + +/// Exit hid. Called automatically during app exit. +void Exit(void); + +/// Gets the Service object for the actual hid service session. +Service* GetServiceSession(void); + +/// Gets the address of the SharedMemory. +void* GetSharedmemAddr(void); + +/// Initialize TouchScreen. Must be called when TouchScreen is being used. Used automatically by \ref hidScanInput when required. +void InitializeTouchScreen(void); + +/** + * @brief Gets \ref HidTouchScreenState. + * @param[out] states Output array of \ref HidTouchScreenState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetTouchScreenStates(HidTouchScreenState *states, size_t count); + +/// Initialize Mouse. Must be called when Mouse is being used. Used automatically by \ref hidScanInput when required. +void InitializeMouse(void); + +/** + * @brief Gets \ref HidMouseState. + * @param[out] states Output array of \ref HidMouseState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetMouseStates(HidMouseState *states, size_t count); + +/// Initialize Keyboard. Must be called when Keyboard is being used. Used automatically by \ref hidScanInput when required. +void InitializeKeyboard(void); + +/** + * @brief Gets \ref HidKeyboardState. + * @param[out] states Output array of \ref HidKeyboardState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetKeyboardStates(HidKeyboardState *states, size_t count); + +/** + * @brief Gets the state of a key in a \ref HidKeyboardState. + * @param[in] state \ref HidKeyboardState. + * @param[in] key \ref HidKeyboardKey. + * @return true if the key is pressed, false if not. + */ +bool KeyboardStateGetKey(const HidKeyboardState *state, HidKeyboardKey key); + +/** + * @brief Gets \ref HidHomeButtonState. + * @note Home button shmem must be activated with \ref hidsysActivateHomeButton + * @param[out] states Output array of \ref HidHomeButtonState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetHomeButtonStates(HidHomeButtonState *states, size_t count); + +/** + * @brief Gets \ref HidSleepButtonState. + * @note Sleep button shmem must be activated with \ref hidsysActivateSleepButton + * @param[out] states Output array of \ref HidSleepButtonState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetSleepButtonStates(HidSleepButtonState *states, size_t count); + +/** + * @brief Gets \ref HidCaptureButtonState. + * @note Capture button shmem must be activated with \ref hidsysActivateCaptureButton + * @param[out] states Output array of \ref HidCaptureButtonState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetCaptureButtonStates(HidCaptureButtonState *states, size_t count); + +/// Initialize Npad. Must be called when Npad is being used. Used automatically by \ref hidScanInput when required. +void InitializeNpad(void); + +/** + * @brief Gets the StyleSet for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @return Bitfield of \ref HidNpadStyleTag. + */ +u32 GetNpadStyleSet(HidNpadIdType id); + +/** + * @brief Gets the \ref HidNpadJoyAssignmentMode for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @return \ref HidNpadJoyAssignmentMode + */ +HidNpadJoyAssignmentMode GetNpadJoyAssignment(HidNpadIdType id); + +/** + * @brief Gets the main \ref HidNpadControllerColor for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @param[out] color \ref HidNpadControllerColor + */ +Result GetNpadControllerColorSingle(HidNpadIdType id, HidNpadControllerColor *color); + +/** + * @brief Gets the left/right \ref HidNpadControllerColor for the specified Npad (Joy-Con pair in dual mode). + * @param[in] id \ref HidNpadIdType + * @param[out] color_left \ref HidNpadControllerColor + * @param[out] color_right \ref HidNpadControllerColor + */ +Result GetNpadControllerColorSplit(HidNpadIdType id, HidNpadControllerColor *color_left, HidNpadControllerColor *color_right); + +/** + * @brief Gets the DeviceType for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @return Bitfield of \ref HidDeviceTypeBits. + */ +u32 GetNpadDeviceType(HidNpadIdType id); + +/** + * @brief Gets the \ref HidNpadSystemProperties for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @param[out] out \ref HidNpadSystemProperties + */ +void GetNpadSystemProperties(HidNpadIdType id, HidNpadSystemProperties *out); + +/** + * @brief Gets the \ref HidNpadSystemButtonProperties for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @param[out] out \ref HidNpadSystemButtonProperties + */ +void GetNpadSystemButtonProperties(HidNpadIdType id, HidNpadSystemButtonProperties *out); + +/** + * @brief Gets the main \ref HidPowerInfo for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @param[out] info \ref HidPowerInfo + */ +void GetNpadPowerInfoSingle(HidNpadIdType id, HidPowerInfo *info); + +/** + * @brief Gets the left/right \ref HidPowerInfo for the specified Npad (Joy-Con pair in dual mode). + * @param[in] id \ref HidNpadIdType + * @param[out] info_left \ref HidPowerInfo + * @param[out] info_right \ref HidPowerInfo + */ +void GetNpadPowerInfoSplit(HidNpadIdType id, HidPowerInfo *info_left, HidPowerInfo *info_right); + +/** + * @brief Gets the AppletFooterUiAttributesSet for the specified Npad. + * @note Only available on [9.0.0+]. + * @param[in] id \ref HidNpadIdType + * @return Bitfield of AppletFooterUiAttribute (system). + */ +u32 GetAppletFooterUiAttributesSet(HidNpadIdType id); + +/** + * @brief Gets \ref HidAppletFooterUiType for the specified Npad. + * @note Only available on [9.0.0+]. + * @param[in] id \ref HidNpadIdType + * @return \ref HidAppletFooterUiType + */ +HidAppletFooterUiType GetAppletFooterUiTypes(HidNpadIdType id); + +/** + * @brief Gets \ref HidNpadLagerType for the specified Npad. + * @param[in] id \ref HidNpadIdType + * @return \ref HidNpadLagerType + */ +HidNpadLagerType GetNpadLagerType(HidNpadIdType id); + +/** + * @brief Gets \ref HidNpadFullKeyState. + * @param[out] states Output array of \ref HidNpadFullKeyState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesFullKey(HidNpadIdType id, HidNpadFullKeyState *states, size_t count); + +/** + * @brief Gets \ref HidNpadHandheldState. + * @param[out] states Output array of \ref HidNpadHandheldState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesHandheld(HidNpadIdType id, HidNpadHandheldState *states, size_t count); + +/** + * @brief Gets \ref HidNpadJoyDualState. + * @param[out] states Output array of \ref HidNpadJoyDualState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesJoyDual(HidNpadIdType id, HidNpadJoyDualState *states, size_t count); + +/** + * @brief Gets \ref HidNpadJoyLeftState. + * @param[out] states Output array of \ref HidNpadJoyLeftState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesJoyLeft(HidNpadIdType id, HidNpadJoyLeftState *states, size_t count); + +/** + * @brief Gets \ref HidNpadJoyRightState. + * @param[out] states Output array of \ref HidNpadJoyRightState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesJoyRight(HidNpadIdType id, HidNpadJoyRightState *states, size_t count); + +/** + * @brief Gets \ref HidNpadGcState. + * @param[out] states Output array of \ref HidNpadGcState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesGc(HidNpadIdType id, HidNpadGcState *states, size_t count); + +/** + * @brief Gets \ref HidNpadPalmaState. + * @param[out] states Output array of \ref HidNpadPalmaState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesPalma(HidNpadIdType id, HidNpadPalmaState *states, size_t count); + +/** + * @brief Gets \ref HidNpadLarkState. + * @param[out] states Output array of \ref HidNpadLarkState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesLark(HidNpadIdType id, HidNpadLarkState *states, size_t count); + +/** + * @brief Gets \ref HidNpadHandheldLarkState. + * @param[out] states Output array of \ref HidNpadHandheldLarkState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesHandheldLark(HidNpadIdType id, HidNpadHandheldLarkState *states, size_t count); + +/** + * @brief Gets \ref HidNpadLuciaState. + * @param[out] states Output array of \ref HidNpadLuciaState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesLucia(HidNpadIdType id, HidNpadLuciaState *states, size_t count); + +/** + * @brief Gets \ref HidNpadLagerState. + * @param[out] states Output array of \ref HidNpadLagerState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesLager(HidNpadIdType id, HidNpadLagerState *states, size_t count); + +/** + * @brief Gets \ref HidNpadSystemExtState. + * @param[out] states Output array of \ref HidNpadSystemExtState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesSystemExt(HidNpadIdType id, HidNpadSystemExtState *states, size_t count); + +/** + * @brief Gets \ref HidNpadSystemState. + * @param[out] states Output array of \ref HidNpadSystemState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetNpadStatesSystem(HidNpadIdType id, HidNpadSystemState *states, size_t count); + +/** + * @brief Gets \ref HidSixAxisSensorState for the specified handle. + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[out] states Output array of \ref HidSixAxisSensorState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetSixAxisSensorStates(HidSixAxisSensorHandle handle, HidSixAxisSensorState *states, size_t count); + +/// Initialize Gesture. Must be called when Gesture is being used. +void InitializeGesture(void); + +/** + * @brief Gets \ref HidGestureState. + * @param[out] states Output array of \ref HidGestureState. + * @param[in] count Size of the states array in entries. + * @return Total output entries. + */ +size_t GetGestureStates(HidGestureState *states, size_t count); + +/** + * @brief SendKeyboardLockKeyEvent + * @note Same as \ref hidsysSendKeyboardLockKeyEvent. + * @note Only available on [6.0.0+]. + * @param[in] events Bitfield of \ref HidKeyboardLockKeyEvent. + */ +Result SendKeyboardLockKeyEvent(u32 events); + +/** + * @brief Gets SixAxisSensorHandles. + * @note Only ::HidNpadStyleTag_NpadJoyDual supports total_handles==2. + * @param[out] handles Output array of \ref HidSixAxisSensorHandle. + * @param[in] total_handles Total handles for the handles array. Must be 1 or 2, if 2 handles aren't supported by the specified style an error is thrown. + * @param[in] id \ref HidNpadIdType + * @param[in] style \ref HidNpadStyleTag + */ +Result GetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style); + +/** + * @brief Starts the SixAxisSensor for the specified handle. + * @param[in] handle \ref HidSixAxisSensorHandle + */ +Result StartSixAxisSensor(HidSixAxisSensorHandle handle); + +/** + * @brief Stops the SixAxisSensor for the specified handle. + * @param[in] handle \ref HidSixAxisSensorHandle + */ +Result StopSixAxisSensor(HidSixAxisSensorHandle handle); + +/** + * @brief IsSixAxisSensorFusionEnabled + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[out] out Output flag. + */ +Result IsSixAxisSensorFusionEnabled(HidSixAxisSensorHandle handle, bool *out); + +/** + * @brief EnableSixAxisSensorFusion + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[in] flag Flag + */ +Result EnableSixAxisSensorFusion(HidSixAxisSensorHandle handle, bool flag); + +/** + * @brief SetSixAxisSensorFusionParameters + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[in] unk0 Must be 0.0f-1.0f. + * @param[in] unk1 Unknown + */ +Result SetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle, float unk0, float unk1); + +/** + * @brief GetSixAxisSensorFusionParameters + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[out] unk0 Unknown + * @param[out] unk1 Unknown + */ +Result GetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle, float *unk0, float *unk1); + +/** + * @brief ResetSixAxisSensorFusionParameters + * @param[in] handle \ref HidSixAxisSensorHandle + */ +Result ResetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle); + +/** + * @brief Sets the ::HidGyroscopeZeroDriftMode for the specified SixAxisSensorHandle. + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[in] mode \ref HidGyroscopeZeroDriftMode + */ +Result SetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle, HidGyroscopeZeroDriftMode mode); + +/** + * @brief Gets the ::HidGyroscopeZeroDriftMode for the specified SixAxisSensorHandle. + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[out] mode \ref HidGyroscopeZeroDriftMode + */ +Result GetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle, HidGyroscopeZeroDriftMode *mode); + +/** + * @brief Resets the ::HidGyroscopeZeroDriftMode for the specified SixAxisSensorHandle to ::HidGyroscopeZeroDriftMode_Standard. + * @param[in] handle \ref HidSixAxisSensorHandle + */ +Result ResetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle); + +/** + * @brief IsSixAxisSensorAtRest + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[out] out Output flag. + */ +Result IsSixAxisSensorAtRest(HidSixAxisSensorHandle handle, bool *out); + +/** + * @brief IsFirmwareUpdateAvailableForSixAxisSensor + * @note Only available on [6.0.0+]. + * @param[in] handle \ref HidSixAxisSensorHandle + * @param[out] out Output flag. + */ +Result IsFirmwareUpdateAvailableForSixAxisSensor(HidSixAxisSensorHandle handle, bool *out); + +/** + * @brief Sets which controller styles are supported. + * @note This is automatically called with the needed styles in \ref hidScanInput when required. + * @param[in] style_set Bitfield of \ref HidNpadStyleTag. + */ +Result SetSupportedNpadStyleSet(u32 style_set); + +/** + * @brief Gets which controller styles are supported. + * @param[out] style_set Bitfield of \ref HidNpadStyleTag. + */ +Result GetSupportedNpadStyleSet(u32 *style_set); + +/** + * @brief Sets which \ref HidNpadIdType are supported. + * @note This is automatically called with HidNpadIdType_No{1-8} and HidNpadIdType_Handheld when required in \ref hidScanInput. + * @param[in] ids Input array of \ref HidNpadIdType. + * @param[in] count Total entries in the ids array. Must be <=10. + */ +Result SetSupportedNpadIdType(const HidNpadIdType *ids, size_t count); + +/** + * @brief Gets an Event which is signaled when the \ref hidGetNpadStyleSet output is updated for the specified controller. + * @note The Event must be closed by the user once finished with it. + * @param[in] id \ref HidNpadIdType + * @param[out] out_event Output Event. + * @param[in] autoclear The autoclear for the Event. +**/ +Result AcquireNpadStyleSetUpdateEventHandle(HidNpadIdType id, Event* out_event, bool autoclear); + +/** + * @brief DisconnectNpad + * @param[in] id \ref HidNpadIdType + */ +Result DisconnectNpad(HidNpadIdType id); + +/** + * @brief GetPlayerLedPattern + * @param[in] id \ref HidNpadIdType + * @param[out] out Output value. + */ +Result GetPlayerLedPattern(HidNpadIdType id, u8 *out); + +/** + * @brief Sets the \ref HidNpadJoyHoldType. + * @note Used automatically by \ref hidScanInput when required. + * @param[in] type \ref HidNpadJoyHoldType + */ +Result SetNpadJoyHoldType(HidNpadJoyHoldType type); + +/** + * @brief Gets the \ref HidNpadJoyHoldType. + * @param[out] type \ref HidNpadJoyHoldType + */ +Result GetNpadJoyHoldType(HidNpadJoyHoldType *type); + +/** + * @brief This is the same as \ref hidSetNpadJoyAssignmentModeSingle, except ::HidNpadJoyDeviceType_Left is used for the type. + * @param[in] id \ref HidNpadIdType, must be HidNpadIdType_No*. + */ +Result SetNpadJoyAssignmentModeSingleByDefault(HidNpadIdType id); + +/** + * @brief This is the same as \ref hidSetNpadJoyAssignmentModeSingleWithDestination, except without the output params. + * @param[in] id \ref HidNpadIdType, must be HidNpadIdType_No*. + * @param[in] type \ref HidNpadJoyDeviceType + */ +Result SetNpadJoyAssignmentModeSingle(HidNpadIdType id, HidNpadJoyDeviceType type); + +/** + * @brief Use this if you want to use a pair of joy-cons as a single HidNpadIdType_No*. When used, both joy-cons in a pair should be used with this (HidNpadIdType_No1 and HidNpadIdType_No2 for example). + * @note Used automatically by \ref hidScanInput when required. + * @param[in] id \ref HidNpadIdType, must be HidNpadIdType_No*. + */ +Result SetNpadJoyAssignmentModeDual(HidNpadIdType id); + +/** + * @brief Merge two single joy-cons into a dual-mode controller. Use this after \ref hidSetNpadJoyAssignmentModeDual, when \ref hidSetNpadJoyAssignmentModeSingleByDefault was previously used (this includes using this manually at application exit). + * @brief To be successful, id0/id1 must correspond to controllers supporting styles HidNpadStyleTag_NpadJoyLeft/Right, or HidNpadStyleTag_NpadJoyRight/Left. + * @brief If successful, the id of the resulting dual controller is set to id0. + * @param[in] id0 \ref HidNpadIdType + * @param[in] id1 \ref HidNpadIdType + */ +Result MergeSingleJoyAsDualJoy(HidNpadIdType id0, HidNpadIdType id1); + +/** + * @brief StartLrAssignmentMode + */ +Result StartLrAssignmentMode(void); + +/** + * @brief StopLrAssignmentMode + */ +Result StopLrAssignmentMode(void); + +/** + * @brief Sets the \ref HidNpadHandheldActivationMode. + * @param[in] mode \ref HidNpadHandheldActivationMode + */ +Result SetNpadHandheldActivationMode(HidNpadHandheldActivationMode mode); + +/** + * @brief Gets the \ref HidNpadHandheldActivationMode. + * @param[out] out \ref HidNpadHandheldActivationMode + */ +Result GetNpadHandheldActivationMode(HidNpadHandheldActivationMode *out); + +/** + * @brief SwapNpadAssignment + * @param[in] id0 \ref HidNpadIdType + * @param[in] id1 \ref HidNpadIdType + */ +Result SwapNpadAssignment(HidNpadIdType id0, HidNpadIdType id1); + +/** + * @brief EnableUnintendedHomeButtonInputProtection + * @note To get the state of this, use \ref hidGetNpadSystemButtonProperties to access HidNpadSystemButtonProperties::is_unintended_home_button_input_protection_enabled. + * @param[in] id \ref HidNpadIdType + * @param[in] flag Whether UnintendedHomeButtonInputProtection is enabled. + */ +Result EnableUnintendedHomeButtonInputProtection(HidNpadIdType id, bool flag); + +/** + * @brief Use this if you want to use a single joy-con as a dedicated HidNpadIdType_No*. When used, both joy-cons in a pair should be used with this (HidNpadIdType_No1 and HidNpadIdType_No2 for example). + * @note Only available on [5.0.0+]. + * @param[in] id \ref HidNpadIdType, must be HidNpadIdType_No*. + * @param[in] type \ref HidNpadJoyDeviceType + * @param[out] flag Whether the dest output is set. + * @param[out] dest \ref HidNpadIdType + */ +Result SetNpadJoyAssignmentModeSingleWithDestination(HidNpadIdType id, HidNpadJoyDeviceType type, bool *flag, HidNpadIdType *dest); + +/** + * @brief SetNpadAnalogStickUseCenterClamp + * @note Only available on [6.1.0+]. + * @param[in] flag Flag + */ +Result SetNpadAnalogStickUseCenterClamp(bool flag); + +/** + * @brief Assigns the button(s) which trigger the CaptureButton. + * @note Only available on [8.0.0+]. + * @param[in] style \ref HidNpadStyleTag, exactly 1 bit must be set. + * @param[in] buttons Bitfield of \ref HidNpadButton, multiple bits can be set. + */ +Result SetNpadCaptureButtonAssignment(HidNpadStyleTag style, u64 buttons); + +/** + * @brief ClearNpadCaptureButtonAssignment + * @note Only available on [8.0.0+]. + */ +Result ClearNpadCaptureButtonAssignment(void); + +/** + * @brief Gets and initializes vibration handles. + * @note Only the following styles support total_handles 2: ::HidNpadStyleTag_NpadFullKey, ::HidNpadStyleTag_NpadHandheld, ::HidNpadStyleTag_NpadJoyDual, ::HidNpadStyleTag_NpadHandheldLark, ::HidNpadStyleTag_NpadSystem, ::HidNpadStyleTag_NpadSystemExt. + * @param[out] handles Output array of \ref HidVibrationDeviceHandle. + * @param[in] total_handles Total handles for the handles array. Must be 1 or 2, if 2 handles aren't supported by the specified style an error is thrown. + * @param[in] id \ref HidNpadIdType + * @param[in] style \ref HidNpadStyleTag + */ +Result InitializeVibrationDevices(HidVibrationDeviceHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style); + +/** + * @brief Gets \ref HidVibrationDeviceInfo for the specified device. + * @param[in] handle \ref HidVibrationDeviceHandle + * @param[out] out \ref HidVibrationDeviceInfo + */ +Result GetVibrationDeviceInfo(HidVibrationDeviceHandle handle, HidVibrationDeviceInfo *out); + +/** + * @brief Sends the \ref HidVibrationDeviceHandle to the specified device. + * @note With ::HidVibrationDeviceType_GcErm, use \ref hidSendVibrationGcErmCommand instead. + * @param[in] handle \ref HidVibrationDeviceHandle + * @param[in] value \ref HidVibrationValue + */ +Result SendVibrationValue(HidVibrationDeviceHandle handle, const HidVibrationValue *value); + +/** + * @brief Gets the current \ref HidVibrationValue for the specified device. + * @note With ::HidVibrationDeviceType_GcErm, use \ref hidGetActualVibrationGcErmCommand instead. + * @param[in] handle \ref HidVibrationDeviceHandle + * @param[out] out \ref HidVibrationValue + */ +Result GetActualVibrationValue(HidVibrationDeviceHandle handle, HidVibrationValue *out); + +/** + * @brief Sets whether vibration is allowed, this also affects the config displayed by System Settings. + * @param[in] flag Flag + */ +Result PermitVibration(bool flag); + +/** + * @brief Gets whether vibration is allowed. + * @param[out] flag Flag + */ +Result IsVibrationPermitted(bool *flag); + +/** + * @brief Send vibration values[index] to handles[index]. + * @note With ::HidVibrationDeviceType_GcErm, use \ref hidSendVibrationGcErmCommand instead. + * @param[in] handles Input array of \ref HidVibrationDeviceHandle. + * @param[in] values Input array of \ref HidVibrationValue. + * @param[in] count Total entries in the handles/values arrays. + */ +Result SendVibrationValues(const HidVibrationDeviceHandle *handles, const HidVibrationValue *values, s32 count); + +/** + * @brief Send \ref HidVibrationGcErmCommand to the specified device, for ::HidVibrationDeviceType_GcErm. + * @note Only available on [4.0.0+]. + * @param[in] handle \ref HidVibrationDeviceHandle + * @param[in] cmd \ref HidVibrationGcErmCommand + */ +Result SendVibrationGcErmCommand(HidVibrationDeviceHandle handle, HidVibrationGcErmCommand cmd); + +/** + * @brief Get \ref HidVibrationGcErmCommand for the specified device, for ::HidVibrationDeviceType_GcErm. + * @note Only available on [4.0.0+]. + * @param[in] handle \ref HidVibrationDeviceHandle + * @param[out] out \ref HidVibrationGcErmCommand + */ +Result GetActualVibrationGcErmCommand(HidVibrationDeviceHandle handle, HidVibrationGcErmCommand *out); + +/** + * @brief Begins a forced-permitted vibration session. + * @note Only available on [4.0.0+]. + */ +Result BeginPermitVibrationSession(void); + +/** + * @brief Ends the session started by \ref hidBeginPermitVibrationSession. + * @note Only available on [4.0.0+]. + */ +Result EndPermitVibrationSession(void); + +/** + * @brief Gets whether vibration is available with the specified device. + * @note Only available on [7.0.0+]. + * @param[in] handle \ref HidVibrationDeviceHandle + * @param[out] flag Flag + */ +Result IsVibrationDeviceMounted(HidVibrationDeviceHandle handle, bool *flag); + +/** + * @brief Starts the SevenSixAxisSensor. + * @note Only available on [5.0.0+]. + */ +Result StartSevenSixAxisSensor(void); + +/** + * @brief Stops the SevenSixAxisSensor. + * @note Only available on [5.0.0+]. + */ +Result StopSevenSixAxisSensor(void); + +/** + * @brief Initializes the SevenSixAxisSensor. + * @note Only available on [5.0.0+]. + */ +Result InitializeSevenSixAxisSensor(void); + +/** + * @brief Finalizes the SevenSixAxisSensor. + * @note This must be called before \ref hidExit. + * @note Only available on [5.0.0+]. + */ +Result FinalizeSevenSixAxisSensor(void); + +/** + * @brief Sets the SevenSixAxisSensor FusionStrength. + * @note Only available on [5.0.0+]. + * @param[in] strength Strength + */ +Result SetSevenSixAxisSensorFusionStrength(float strength); + +/** + * @brief Gets the SevenSixAxisSensor FusionStrength. + * @note Only available on [5.0.0+]. + * @param[out] strength Strength + */ +Result GetSevenSixAxisSensorFusionStrength(float *strength); + +/** + * @brief Resets the timestamp for the SevenSixAxisSensor. + * @note Only available on [6.0.0+]. + */ +Result ResetSevenSixAxisSensorTimestamp(void); + +/** + * @brief GetSevenSixAxisSensorStates + * @note Only available when \ref hidInitializeSevenSixAxisSensor was previously used. + * @param[out] states Output array of \ref HidSevenSixAxisSensorState. + * @param[in] count Size of the states array in entries. + * @param[out] total_out Total output entries. + */ +Result GetSevenSixAxisSensorStates(HidSevenSixAxisSensorState *states, size_t count, size_t *total_out); + +/** + * @brief IsSevenSixAxisSensorAtRest + * @note Only available when \ref hidInitializeSevenSixAxisSensor was previously used. + * @param[out] out Output flag. + */ +Result IsSevenSixAxisSensorAtRest(bool *out); + +/** + * @brief GetSensorFusionError + * @note Only available when \ref hidInitializeSevenSixAxisSensor was previously used. + * @param[out] out Output data. + */ +Result GetSensorFusionError(float *out); + +/** + * @brief GetGyroBias + * @note Only available when \ref hidInitializeSevenSixAxisSensor was previously used. + * @param[out] out \ref UtilFloat3 + */ +Result GetGyroBias(UtilFloat3 *out); + +/** + * @brief IsUsbFullKeyControllerEnabled + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsUsbFullKeyControllerEnabled(bool *out); + +/** + * @brief EnableUsbFullKeyController + * @note Only available on [3.0.0+]. + * @param[in] flag Flag + */ +Result EnableUsbFullKeyController(bool flag); + +/** + * @brief IsUsbFullKeyControllerConnected + * @note Only available on [3.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out Output flag. + */ +Result IsUsbFullKeyControllerConnected(HidNpadIdType id, bool *out); + +/** + * @brief Gets the \ref HidNpadInterfaceType for the specified controller. + * @note When available, \ref hidsysGetNpadInterfaceType should be used instead. + * @note Only available on [4.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out \ref HidNpadInterfaceType + */ +Result GetNpadInterfaceType(HidNpadIdType id, u8 *out); + +/** + * @brief GetNpadOfHighestBatteryLevel + * @note Only available on [10.0.0+]. + * @param[in] ids Input array of \ref HidNpadIdType, ::HidNpadIdType_Handheld is ignored. + * @param[in] count Total entries in the ids array. + * @param[out] out \ref HidNpadIdType + */ +Result GetNpadOfHighestBatteryLevel(const HidNpadIdType *ids, size_t count, HidNpadIdType *out); + +/** + * @brief GetPalmaConnectionHandle + * @note Only available on [5.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out \ref HidPalmaConnectionHandle + */ +Result GetPalmaConnectionHandle(HidNpadIdType id, HidPalmaConnectionHandle *out); + +/** + * @brief InitializePalma + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result InitializePalma(HidPalmaConnectionHandle handle); + +/** + * @brief Gets an Event which is signaled when data is available with \ref hidGetPalmaOperationInfo. + * @note The Event must be closed by the user once finished with it. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[out] out_event Output Event. + * @param[in] autoclear The autoclear for the Event. +**/ +Result AcquirePalmaOperationCompleteEvent(HidPalmaConnectionHandle handle, Event* out_event, bool autoclear); + +/** + * @brief Gets \ref HidPalmaOperationInfo for a completed operation. + * @note This must be used at some point following using any of the other Palma cmds which trigger an Operation, once the Event from \ref hidAcquirePalmaOperationCompleteEvent is signaled. Up to 4 Operations can be queued at once, the other cmds will throw an error once there's too many operations. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[out] out \ref HidPalmaOperationInfo + */ +Result GetPalmaOperationInfo(HidPalmaConnectionHandle handle, HidPalmaOperationInfo *out); + +/** + * @brief PlayPalmaActivity + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] val Input value. + */ +Result PlayPalmaActivity(HidPalmaConnectionHandle handle, u16 val); + +/** + * @brief SetPalmaFrModeType + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] type \ref HidPalmaFrModeType + */ +Result SetPalmaFrModeType(HidPalmaConnectionHandle handle, HidPalmaFrModeType type); + +/** + * @brief ReadPalmaStep + * @note See \ref hidGetPalmaOperationInfo. + * @note \ref hidEnablePalmaStep should be used before this. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result ReadPalmaStep(HidPalmaConnectionHandle handle); + +/** + * @brief EnablePalmaStep + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] flag Flag + */ +Result EnablePalmaStep(HidPalmaConnectionHandle handle, bool flag); + +/** + * @brief ResetPalmaStep + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result ResetPalmaStep(HidPalmaConnectionHandle handle); + +/** + * @brief ReadPalmaApplicationSection + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] inval0 First input value. + * @param[in] size This must be within the size of \ref HidPalmaApplicationSectionAccessBuffer. + */ +Result ReadPalmaApplicationSection(HidPalmaConnectionHandle handle, s32 inval0, u64 size); + +/** + * @brief WritePalmaApplicationSection + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] inval0 First input value. + * @param[in] size Size of the data in \ref HidPalmaApplicationSectionAccessBuffer. + * @param[in] buf \ref HidPalmaApplicationSectionAccessBuffer + */ +Result WritePalmaApplicationSection(HidPalmaConnectionHandle handle, s32 inval0, u64 size, const HidPalmaApplicationSectionAccessBuffer *buf); + +/** + * @brief ReadPalmaUniqueCode + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result ReadPalmaUniqueCode(HidPalmaConnectionHandle handle); + +/** + * @brief SetPalmaUniqueCodeInvalid + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result SetPalmaUniqueCodeInvalid(HidPalmaConnectionHandle handle); + +/** + * @brief WritePalmaActivityEntry + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] unk Unknown + * @param[in] entry \ref HidPalmaActivityEntry + */ +Result WritePalmaActivityEntry(HidPalmaConnectionHandle handle, u16 unk, const HidPalmaActivityEntry *entry); + +/** + * @brief WritePalmaRgbLedPatternEntry + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] unk Unknown + * @param[in] buffer Input buffer. + * @param[in] size Input buffer size. + */ +Result WritePalmaRgbLedPatternEntry(HidPalmaConnectionHandle handle, u16 unk, const void* buffer, size_t size); + +/** + * @brief WritePalmaWaveEntry + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] wave_set \ref HidPalmaWaveSet + * @param[in] unk Unknown + * @param[in] buffer TransferMemory buffer, must be 0x1000-byte aligned. + * @param[in] tmem_size TransferMemory buffer size, must be 0x1000-byte aligned. + * @param[in] size Actual size of the data in the buffer. + */ +Result WritePalmaWaveEntry(HidPalmaConnectionHandle handle, HidPalmaWaveSet wave_set, u16 unk, const void* buffer, size_t tmem_size, size_t size); + +/** + * @brief SetPalmaDataBaseIdentificationVersion + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] version Version + */ +Result SetPalmaDataBaseIdentificationVersion(HidPalmaConnectionHandle handle, s32 version); + +/** + * @brief GetPalmaDataBaseIdentificationVersion + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result GetPalmaDataBaseIdentificationVersion(HidPalmaConnectionHandle handle); + +/** + * @brief SuspendPalmaFeature + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] features Bitfield of \ref HidPalmaFeature. + */ +Result SuspendPalmaFeature(HidPalmaConnectionHandle handle, u32 features); + +/** + * @brief ReadPalmaPlayLog + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.1.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] unk Unknown + */ +Result ReadPalmaPlayLog(HidPalmaConnectionHandle handle, u16 unk); + +/** + * @brief ResetPalmaPlayLog + * @note See \ref hidGetPalmaOperationInfo. + * @note Only available on [5.1.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[in] unk Unknown + */ +Result ResetPalmaPlayLog(HidPalmaConnectionHandle handle, u16 unk); + +/** + * @brief Sets whether any Palma can connect. + * @note Only available on [5.1.0+]. + * @param[in] flag Flag + */ +Result SetIsPalmaAllConnectable(bool flag); + +/** + * @brief Sets whether paired Palma can connect. + * @note Only available on [5.1.0+]. + * @param[in] flag Flag + */ +Result SetIsPalmaPairedConnectable(bool flag); + +/** + * @brief PairPalma + * @note Only available on [5.1.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result PairPalma(HidPalmaConnectionHandle handle); + +/** + * @brief CancelWritePalmaWaveEntry + * @note Only available on [7.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + */ +Result CancelWritePalmaWaveEntry(HidPalmaConnectionHandle handle); + +/** + * @brief EnablePalmaBoostMode + * @note Only available on [5.1.0+]. Uses cmd EnablePalmaBoostMode on [8.0.0+], otherwise cmd SetPalmaBoostMode is used. + * @param[in] flag Flag + */ +Result EnablePalmaBoostMode(bool flag); + +/** + * @brief GetPalmaBluetoothAddress + * @note Only available on [8.0.0+]. + * @param[in] handle \ref HidPalmaConnectionHandle + * @param[out] out \ref BtdrvAddress + */ +Result GetPalmaBluetoothAddress(HidPalmaConnectionHandle handle, BtdrvAddress *out); + +/** + * @brief SetDisallowedPalmaConnection + * @note Only available on [8.0.0+]. + * @param[in] addrs Input array of \ref BtdrvAddress. + * @param[in] count Total entries in the addrs array. + */ +Result SetDisallowedPalmaConnection(const BtdrvAddress *addrs, s32 count); + +/** + * @brief SetNpadCommunicationMode + * @note [2.0.0+] Stubbed, just returns 0. + * @param[in] mode \ref HidNpadCommunicationMode + */ +Result SetNpadCommunicationMode(HidNpadCommunicationMode mode); + +/** + * @brief GetNpadCommunicationMode + * @note [2.0.0+] Stubbed, always returns output mode ::HidNpadCommunicationMode_Default. + * @param[out] out \ref HidNpadCommunicationMode + */ +Result GetNpadCommunicationMode(HidNpadCommunicationMode *out); + +/** + * @brief SetTouchScreenConfiguration + * @note Only available on [9.0.0+]. + * @param[in] config \ref HidTouchScreenConfigurationForNx + */ +Result SetTouchScreenConfiguration(const HidTouchScreenConfigurationForNx *config); + +/** + * @brief IsFirmwareUpdateNeededForNotification + * @note Only available on [9.0.0+]. + * @param[out] out Output flag. + */ +Result IsFirmwareUpdateNeededForNotification(bool *out); + +} // namespace hid + +/// @brief C++ wrappers for the `hidbus` API. +/// @details Wraps: switch/services/hidbus.h. +namespace hidbus { + +/// BusHandle +using ::HidbusBusHandle; +/// BusType +using ::HidbusBusType; +/// HidbusDataAccessorHeader +using ::HidbusDataAccessorHeader; +/// HidbusJoyButtonOnlyPollingDataAccessor +using ::HidbusJoyButtonOnlyPollingDataAccessor; +/// HidbusJoyButtonOnlyPollingDataAccessorEntry +using ::HidbusJoyButtonOnlyPollingDataAccessorEntry; +/// HidbusJoyButtonOnlyPollingDataAccessorEntryData +using ::HidbusJoyButtonOnlyPollingDataAccessorEntryData; +/// HidbusJoyDisableSixAxisPollingDataAccessor +using ::HidbusJoyDisableSixAxisPollingDataAccessor; +/// HidbusJoyDisableSixAxisPollingDataAccessorEntry +using ::HidbusJoyDisableSixAxisPollingDataAccessorEntry; +/// HidbusJoyDisableSixAxisPollingDataAccessorEntryData +using ::HidbusJoyDisableSixAxisPollingDataAccessorEntryData; +/// HidbusJoyEnableSixAxisPollingDataAccessor +using ::HidbusJoyEnableSixAxisPollingDataAccessor; +/// HidbusJoyEnableSixAxisPollingDataAccessorEntry +using ::HidbusJoyEnableSixAxisPollingDataAccessorEntry; +/// HidbusJoyEnableSixAxisPollingDataAccessorEntryData +using ::HidbusJoyEnableSixAxisPollingDataAccessorEntryData; +/// JoyPollingMode +using ::HidbusJoyPollingMode; +/// JoyPollingReceivedData +using ::HidbusJoyPollingReceivedData; +/// StatusManager +using ::HidbusStatusManager; +/// HidbusStatusManagerEntry +using ::HidbusStatusManagerEntry; +/// Common data for HidbusStatusManagerEntry*. +using ::HidbusStatusManagerEntryCommon; +/// HidbusStatusManagerEntry on 5.x. +using ::HidbusStatusManagerEntryV5; +/// StatusManager on 5.x. +using ::HidbusStatusManagerV5; + +/// Gets the Service object for the actual hidbus service session. This object must be closed by the user once finished using cmds with this. +Result GetServiceSession(Service* srv_out); + +/// Gets the SharedMemory addr (\ref HidbusStatusManagerV5 on 5.x, otherwise \ref HidbusStatusManager). Only valid when at least one BusHandle is currently initialized (\ref hidbusInitialize). +void* GetSharedmemAddr(void); + +/** + * @brief GetBusHandle + * @param[out] handle \ref HidbusBusHandle + * @param[out] flag Output flag indicating whether the handle is valid. + * @param[in] id \ref HidNpadIdType + * @param[in] bus_type \ref HidbusBusType + */ +Result GetBusHandle(HidbusBusHandle *handle, bool *flag, HidNpadIdType id, HidbusBusType bus_type); + +/** + * @brief Initialize + * @param[in] handle \ref HidbusBusHandle + */ +Result Initialize(HidbusBusHandle handle); + +/** + * @brief Finalize + * @param[in] handle \ref HidbusBusHandle + */ +Result Finalize(HidbusBusHandle handle); + +/** + * @brief EnableExternalDevice + * @note This uses \ref hidLaShowControllerFirmwareUpdate if needed. + * @param[in] handle \ref HidbusBusHandle + * @param[in] flag Whether to enable the device (true = enable, false = disable). When false, this will internally use \ref hidbusDisableJoyPollingReceiveMode if needed. + * @param[in] device_id ExternalDeviceId which must match the connected device. Only used when flag is set. + */ +Result EnableExternalDevice(HidbusBusHandle handle, bool flag, u32 device_id); + +/** + * @brief SendAndReceive + * @param[in] handle \ref HidbusBusHandle + * @param[in] inbuf Input buffer, containing the command data. + * @param[in] inbuf_size Input buffer size, must be <0x26. + * @param[out] outbuf Output buffer, containing the command reply data. + * @param[in] outbuf_size Output buffer max size. + * @param[out] out_size Actual output size. + */ +Result SendAndReceive(HidbusBusHandle handle, const void* inbuf, size_t inbuf_size, void* outbuf, size_t outbuf_size, u64 *out_size); + +/** + * @brief EnableJoyPollingReceiveMode + * @param[in] handle \ref HidbusBusHandle + * @param[in] inbuf Input buffer, containing the command data. + * @param[in] inbuf_size Input buffer size, must be <0x26. + * @param[out] workbuf TransferMemory buffer, must be 0x1000-byte aligned. This buffer must not be written to until after \ref hidbusDisableJoyPollingReceiveMode is used. + * @param[in] workbuf_size TransferMemory buffer size, must be 0x1000-byte aligned. + * @param[in] polling_mode \ref HidbusJoyPollingMode + */ +Result EnableJoyPollingReceiveMode(HidbusBusHandle handle, const void* inbuf, size_t inbuf_size, void* workbuf, size_t workbuf_size, HidbusJoyPollingMode polling_mode); + +/** + * @brief DisableJoyPollingReceiveMode + * @note This can also be used via \ref hidbusEnableExternalDevice with flag=false. + * @param[in] handle \ref HidbusBusHandle + */ +Result DisableJoyPollingReceiveMode(HidbusBusHandle handle); + +/** + * @brief GetJoyPollingReceivedData + * @param[in] handle \ref HidbusBusHandle + * @param[out] recv_data Output array of \ref HidbusJoyPollingReceivedData. + * @param[in] count Total entries for the recv_data array. The maximum is 0xa. Official apps use range 0x1-0x9. + */ +Result GetJoyPollingReceivedData(HidbusBusHandle handle, HidbusJoyPollingReceivedData *recv_data, s32 count); + +} // namespace hidbus + +/// @brief C++ wrappers for the `hiddbg` API. +/// @details Wraps: switch/services/hiddbg.h. +namespace hiddbg { + +/// AbstractedPadHandle +using ::HiddbgAbstractedPadHandle; +/// AbstractedPadState +using ::HiddbgAbstractedPadState; +/// State for overriding \ref HidDebugPadState. +using ::HiddbgDebugPadAutoPilotState; +/// HdlsAttribute +using ::HiddbgHdlsAttribute; +/// HdlsDeviceInfo, for [9.0.0+]. Converted to/from \ref HiddbgHdlsDeviceInfoV7 on prior sysvers. +using ::HiddbgHdlsDeviceInfo; +/// HdlsDeviceInfo, for [7.0.0-8.1.0]. +using ::HiddbgHdlsDeviceInfoV7; +/// HdlsHandle +using ::HiddbgHdlsHandle; +/// HdlsNpadAssignment. Same controllers as \ref HiddbgHdlsStateList, with different entry data. +using ::HiddbgHdlsNpadAssignment; +/// HdlsNpadAssignmentEntry +using ::HiddbgHdlsNpadAssignmentEntry; +/// HdlsSessionId, returned by \ref hiddbgAttachHdlsWorkBuffer. +using ::HiddbgHdlsSessionId; +/// HdlsState, for [12.0.0+]. +using ::HiddbgHdlsState; +/// HdlsStateList, for [12.0.0+]. +/// This contains a list of all controllers, including non-virtual controllers. +using ::HiddbgHdlsStateList; +/// HdlsStateListEntry, for [12.0.0+]. +using ::HiddbgHdlsStateListEntry; +/// HdlsStateListEntryV7, for [7.0.0-8.1.0]. +using ::HiddbgHdlsStateListEntryV7; +/// HdlsStateListEntry, for [9.0.0-11.0.1]. +using ::HiddbgHdlsStateListEntryV9; +/// HdlsStateListV7, for [7.0.0-8.1.0]. This contains a list of all controllers, including non-virtual controllers. +using ::HiddbgHdlsStateListV7; +/// HdlsStateList, for [9.0.0-11.0.1]. +using ::HiddbgHdlsStateListV9; +/// HdlsState, for [7.0.0-8.1.0]. +using ::HiddbgHdlsStateV7; +/// HdlsState, for [9.0.0-11.0.1]. +using ::HiddbgHdlsStateV9; +/// State for overriding \ref HidKeyboardState. +using ::HiddbgKeyboardAutoPilotState; +/// State for overriding \ref HidMouseState. +using ::HiddbgMouseAutoPilotState; +/// HiddbgNpadButton. For the remaining buttons, see \ref HidNpadButton. +using ::HiddbgNpadButton; +/// State for overriding SleepButtonState. +using ::HiddbgSleepButtonAutoPilotState; + +/// Initialize hiddbg. +Result Initialize(void); + +/// Exit hiddbg. +void Exit(void); + +/// Gets the Service object for the actual hiddbg service session. +Service* GetServiceSession(void); + +/** + * @brief SetDebugPadAutoPilotState + * @param[in] state \ref HiddbgDebugPadAutoPilotState + */ +Result SetDebugPadAutoPilotState(const HiddbgDebugPadAutoPilotState *state); + +/** + * @brief UnsetDebugPadAutoPilotState + */ +Result UnsetDebugPadAutoPilotState(void); + +/** + * @brief SetTouchScreenAutoPilotState + * @param[in] states Input array of \ref HiddbgMouseAutoPilotState. + * @param[in] count Total entries in the states array. Max is 16. + */ +Result SetTouchScreenAutoPilotState(const HidTouchState *states, s32 count); + +/** + * @brief UnsetTouchScreenAutoPilotState + */ +Result UnsetTouchScreenAutoPilotState(void); + +/** + * @brief SetMouseAutoPilotState + * @param[in] state \ref HiddbgMouseAutoPilotState + */ +Result SetMouseAutoPilotState(const HiddbgMouseAutoPilotState *state); + +/** + * @brief UnsetMouseAutoPilotState + */ +Result UnsetMouseAutoPilotState(void); + +/** + * @brief SetKeyboardAutoPilotState + * @param[in] state \ref HiddbgKeyboardAutoPilotState + */ +Result SetKeyboardAutoPilotState(const HiddbgKeyboardAutoPilotState *state); + +/** + * @brief UnsetKeyboardAutoPilotState + */ +Result UnsetKeyboardAutoPilotState(void); + +/** + * @brief Deactivates the HomeButton. + */ +Result DeactivateHomeButton(void); + +/** + * @brief SetSleepButtonAutoPilotState + * @param[in] state \ref HiddbgSleepButtonAutoPilotState + */ +Result SetSleepButtonAutoPilotState(const HiddbgSleepButtonAutoPilotState *state); + +/** + * @brief UnsetSleepButtonAutoPilotState + */ +Result UnsetSleepButtonAutoPilotState(void); + +/** + * @brief Writes the input RGB colors to the spi-flash for the specified UniquePad (offset 0x6050 size 0x6). + * @note Only available with [3.0.0+]. + * @param[in] colorBody RGB body color. + * @param[in] colorButtons RGB buttons color. + * @param[in] unique_pad_id \ref HidsysUniquePadId + */ +Result UpdateControllerColor(u32 colorBody, u32 colorButtons, HidsysUniquePadId unique_pad_id); + +/** + * @brief Writes the input RGB colors followed by inval to the spi-flash for the specified UniquePad (offset 0x6050 size 0xD). + * @note Only available with [5.0.0+]. + * @param[in] colorBody RGB body color. + * @param[in] colorButtons RGB buttons color. + * @param[in] colorLeftGrip RGB left grip color. + * @param[in] colorRightGrip RGB right grip color. + * @param[in] inval Input value. + * @param[in] unique_pad_id \ref HidsysUniquePadId + */ +Result UpdateDesignInfo(u32 colorBody, u32 colorButtons, u32 colorLeftGrip, u32 colorRightGrip, u8 inval, HidsysUniquePadId unique_pad_id); + +/** + * @brief Get the OperationEvent for the specified UniquePad. + * @note The Event must be closed by the user once finished with it. + * @note Only available with [6.0.0+]. + * @param[out] out_event Output Event. + * @param[in] autoclear The autoclear for the Event. + * @param[in] unique_pad_id \ref HidsysUniquePadId +**/ +Result AcquireOperationEventHandle(Event* out_event, bool autoclear, HidsysUniquePadId unique_pad_id); + +/** + * @brief Reads spi-flash for the specified UniquePad. + * @note This also uses \ref hiddbgAcquireOperationEventHandle to wait for the operation to finish, then \ref hiddbgGetOperationResult is used. + * @note Only available with [6.0.0+]. + * @param[in] offset Offset in spi-flash. + * @param[out] buffer Output buffer. + * @param[in] size Output buffer size. + * @param[in] unique_pad_id \ref HidsysUniquePadId +**/ +Result ReadSerialFlash(u32 offset, void* buffer, size_t size, HidsysUniquePadId unique_pad_id); + +/** + * @brief Writes spi-flash for the specified UniquePad. + * @note This also uses \ref hiddbgAcquireOperationEventHandle to wait for the operation to finish, then \ref hiddbgGetOperationResult is used. + * @note Only available with [6.0.0+]. + * @param[in] offset Offset in spi-flash. + * @param[in] buffer Input buffer, must be 0x1000-byte aligned. + * @param[in] tmem_size Size of the buffer, must be 0x1000-byte aligned. + * @param[in] size Actual transfer size. + * @param[in] unique_pad_id \ref HidsysUniquePadId +**/ +Result WriteSerialFlash(u32 offset, void* buffer, size_t tmem_size, size_t size, HidsysUniquePadId unique_pad_id); + +/** + * @brief Get the Result for the Operation and handles cleanup, for the specified UniquePad. + * @note Only available with [6.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId +**/ +Result GetOperationResult(HidsysUniquePadId unique_pad_id); + +/** + * @brief Gets the internal DeviceType for the specified controller. + * @note Only available with [6.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Pre-9.0.0 this is an u32, with [9.0.0+] it's an u8. +**/ +Result GetUniquePadDeviceTypeSetInternal(HidsysUniquePadId unique_pad_id, u32 *out); + +/** @name AbstractedPad + * This is for virtual HID controllers. Only use this on pre-7.0.0, Hdls should be used otherwise. + */ +/** + * @brief Gets a list of \ref HiddbgAbstractedPadHandle. + * @note Only available with [5.0.0-8.1.0]. + * @param[out] handles Output array of \ref HiddbgAbstractedPadHandle. + * @param[in] count Max number of entries for the handles array. + * @param[out] total_out Total output entries. + */ +Result GetAbstractedPadHandles(HiddbgAbstractedPadHandle *handles, s32 count, s32 *total_out); + +/** + * @brief Gets the state for the specified \ref HiddbgAbstractedPadHandle. + * @note Only available with [5.0.0-8.1.0]. + * @param[in] handle \ref HiddbgAbstractedPadHandle + * @param[out] state \ref HiddbgAbstractedPadState + */ +Result GetAbstractedPadState(HiddbgAbstractedPadHandle handle, HiddbgAbstractedPadState *state); + +/** + * @brief Similar to \ref hiddbgGetAbstractedPadHandles except this also returns the state for each pad in output array states. + * @note Only available with [5.0.0-8.1.0]. + * @param[out] handles Output array of \ref HiddbgAbstractedPadHandle. + * @param[out] states Output array of \ref HiddbgAbstractedPadState. + * @param[in] count Max number of entries for the handles/states arrays. + * @param[out] total_out Total output entries. + */ +Result GetAbstractedPadsState(HiddbgAbstractedPadHandle *handles, HiddbgAbstractedPadState *states, s32 count, s32 *total_out); + +/** + * @brief Sets AutoPilot state for the specified pad. + * @note Only available with [5.0.0-8.1.0]. + * @param[in] AbstractedVirtualPadId This can be any unique value as long as it's within bounds. For example, 0-7 is usable. + * @param[in] state \ref HiddbgAbstractedPadState + */ +Result SetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const HiddbgAbstractedPadState *state); + +/** + * @brief Clears AutoPilot state for the specified pad set by \ref hiddbgSetAutoPilotVirtualPadState. + * @note Only available with [5.0.0-8.1.0]. + * @param[in] AbstractedVirtualPadId Id from \ref hiddbgSetAutoPilotVirtualPadState. + */ +Result UnsetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId); + +/** + * @brief Clears AutoPilot state for all pads set by \ref hiddbgSetAutoPilotVirtualPadState. + */ +Result UnsetAllAutoPilotVirtualPadState(void); + +/** @name Hdls + * This is for virtual HID controllers. + */ +/** + * @brief Initialize Hdls. + * @note Only available with [7.0.0+]. + * @param[out] session_id [13.0.0+] \ref HiddbgHdlsSessionId + * @param[in] buffer An existing buffer to be used as transfer memory. + * @param[in] size Size of the supplied buffer. + */ +Result AttachHdlsWorkBuffer(HiddbgHdlsSessionId *session_id, void *buffer, size_t size); + +/** + * @brief Exit Hdls, must be called at some point prior to \ref hiddbgExit. + * @note Only available with [7.0.0+]. + * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId + */ +Result ReleaseHdlsWorkBuffer(HiddbgHdlsSessionId session_id); + +/** + * @brief Checks if the given device is still attached. + * @note Only available with [7.0.0+]. + * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId + * @param[in] handle \ref HiddbgHdlsHandle + * @param[out] out Whether the device is attached. + */ +Result IsHdlsVirtualDeviceAttached(HiddbgHdlsSessionId session_id, HiddbgHdlsHandle handle, bool *out); + +/** + * @brief Gets state for \ref HiddbgHdlsNpadAssignment. + * @note Only available with [7.0.0+]. + * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId + * @param[out] state \ref HiddbgHdlsNpadAssignment + */ +Result DumpHdlsNpadAssignmentState(HiddbgHdlsSessionId session_id, HiddbgHdlsNpadAssignment *state); + +/** + * @brief Gets state for \ref HiddbgHdlsStateList. + * @note Only available with [7.0.0+]. + * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId + * @param[out] state \ref HiddbgHdlsStateList + */ +Result DumpHdlsStates(HiddbgHdlsSessionId session_id, HiddbgHdlsStateList *state); + +/** + * @brief Sets state for \ref HiddbgHdlsNpadAssignment. + * @note Only available with [7.0.0+]. + * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId + * @param[in] state \ref HiddbgHdlsNpadAssignment + * @param[in] flag Flag + */ +Result ApplyHdlsNpadAssignmentState(HiddbgHdlsSessionId session_id, const HiddbgHdlsNpadAssignment *state, bool flag); + +/** + * @brief Sets state for \ref HiddbgHdlsStateList. + * @note The \ref HiddbgHdlsState will be applied for each \ref HiddbgHdlsHandle. If a \ref HiddbgHdlsHandle is not found, code similar to \ref hiddbgAttachHdlsVirtualDevice will run with the \ref HiddbgHdlsDeviceInfo, then it will continue with applying state with the new device. + * @note Only available with [7.0.0+]. + * @param[in] session_id [13.0.0+] \ref HiddbgHdlsSessionId + * @param[in] state \ref HiddbgHdlsStateList + */ +Result ApplyHdlsStateList(HiddbgHdlsSessionId session_id, const HiddbgHdlsStateList *state); + +/** + * @brief Attach a device with the input info. + * @note Only available with [7.0.0+]. + * @param[out] handle \ref HiddbgHdlsHandle + * @param[in] info \ref HiddbgHdlsDeviceInfo + */ +Result AttachHdlsVirtualDevice(HiddbgHdlsHandle *handle, const HiddbgHdlsDeviceInfo *info); + +/** + * @brief Detach the specified device. + * @note Only available with [7.0.0+]. + * @param[in] handle \ref HiddbgHdlsHandle + */ +Result DetachHdlsVirtualDevice(HiddbgHdlsHandle handle); + +/** + * @brief Sets state for the specified device. + * @note Only available with [7.0.0+]. + * @param[in] handle \ref HiddbgHdlsHandle + * @param[in] state \ref HiddbgHdlsState + */ +Result SetHdlsState(HiddbgHdlsHandle handle, const HiddbgHdlsState *state); + +} // namespace hiddbg + +/// @brief C++ wrappers for the `hidsys` API. +/// @details Wraps: switch/services/hidsys.h. +namespace hidsys { + +/// AnalogStickAssignment +using ::HidcfgAnalogStickAssignment; +/// AnalogStickRotation +using ::HidcfgAnalogStickRotation; +/// ButtonConfigEmbedded +using ::HidcfgButtonConfigEmbedded; +/// ButtonConfigFull +using ::HidcfgButtonConfigFull; +/// ButtonConfigLeft +using ::HidcfgButtonConfigLeft; +/// ButtonConfigRight +using ::HidcfgButtonConfigRight; +/// Selects what button to map to. +using ::HidcfgDigitalButtonAssignment; +/// StorageName +using ::HidcfgStorageName; +/// ButtonConfigEmbedded +using ::HidsysButtonConfigEmbedded; +/// ButtonConfigFull +using ::HidsysButtonConfigFull; +/// ButtonConfigLeft +using ::HidsysButtonConfigLeft; +/// ButtonConfigRight +using ::HidsysButtonConfigRight; +/// Structure for \ref hidsysSetNotificationLedPattern. +/// See also: https://switchbrew.org/wiki/HID_services#NotificationLedPattern +/// Only the low 4bits of each used byte in this struct is used. +using ::HidsysNotificationLedPattern; +/// Mini Cycle struct for \ref HidsysNotificationLedPattern. +using ::HidsysNotificationLedPatternCycle; +/// UniquePadId for a controller. +using ::HidsysUniquePadId; +/// UniquePadSerialNumber +using ::HidsysUniquePadSerialNumber; +/// UniquePadType +using ::HidsysUniquePadType; + +/// Initialize hidsys. +Result Initialize(void); + +/// Exit hidsys. +void Exit(void); + +/// Gets the Service object for the actual hidsys service session. +Service* GetServiceSession(void); + +/** + * @brief SendKeyboardLockKeyEvent + * @param[in] events Bitfield of \ref HidKeyboardLockKeyEvent. + */ +Result SendKeyboardLockKeyEvent(u32 events); + +/** + * @brief Gets an Event which is signaled when HidHomeButtonState is updated. + * @note The Event must be closed by the user once finished with it. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. + * @param[out] out_event Output Event. + * @param[in] Event autoclear. +**/ +Result AcquireHomeButtonEventHandle(Event* out_event, bool autoclear); + +/** + * @brief Activates the HomeButton sharedmem. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. +**/ +Result ActivateHomeButton(void); + +/** + * @brief Gets an Event which is signaled when HidSleepButtonState is updated. + * @note The Event must be closed by the user once finished with it. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. + * @param[out] out_event Output Event. + * @param[in] Event autoclear. +**/ +Result AcquireSleepButtonEventHandle(Event* out_event, bool autoclear); + +/** + * @brief Activates the SleepButton sharedmem. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. +**/ +Result ActivateSleepButton(void); + +/** + * @brief Gets an Event which is signaled when HidCaptureButtonState is updated. + * @note The Event must be closed by the user once finished with it. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. + * @param[out] out_event Output Event. + * @param[in] Event autoclear. +**/ +Result AcquireCaptureButtonEventHandle(Event* out_event, bool autoclear); + +/** + * @brief Activates the CaptureButton sharedmem. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. +**/ +Result ActivateCaptureButton(void); + +/** + * @brief Applies npad system common policy. + */ +Result ApplyNpadSystemCommonPolicy(void); + +/** + * @brief Gets the npad id type of the last controller that was active. + * @param[out] out of \ref HidNpadIdType. + */ +Result GetLastActiveNpad(u32 *out); + +/** + * @brief Gets the SupportedNpadStyleSet for the CallerApplet. applet must be initialized in order to use this (uses \ref appletGetAppletResourceUserIdOfCallerApplet). + * @note Only available on [6.0.0+]. + * @param[out] out Bitmask of \ref HidNpadStyleTag. + */ +Result GetSupportedNpadStyleSetOfCallerApplet(u32 *out); + +/** + * @brief Gets the \ref HidNpadInterfaceType for the specified controller. + * @note Only available on [10.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out \ref HidNpadInterfaceType + */ +Result GetNpadInterfaceType(HidNpadIdType id, u8 *out); + +/** + * @brief GetNpadLeftRightInterfaceType + * @note Only available on [10.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out0 \ref HidNpadInterfaceType + * @param[out] out1 \ref HidNpadInterfaceType + */ +Result GetNpadLeftRightInterfaceType(HidNpadIdType id, u8 *out0, u8 *out1); + +/** + * @brief HasBattery + * @note Only available on [10.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out Output flag. + */ +Result HasBattery(HidNpadIdType id, bool *out); + +/** + * @brief HasLeftRightBattery + * @note Only available on [10.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] out0 Output flag. + * @param[out] out1 Output flag. + */ +Result HasLeftRightBattery(HidNpadIdType id, bool *out0, bool *out1); + +/** + * @brief Gets the UniquePadIds for the specified controller. + * @note Only available on [3.0.0+]. + * @param[in] id \ref HidNpadIdType + * @param[out] unique_pad_ids Output array of \ref HidsysUniquePadId. + * @param[in] count Max number of entries for the unique_pad_ids array. + * @param[out] total_out Total output array entries. Optional, can be NULL. + */ +Result GetUniquePadsFromNpad(HidNpadIdType id, HidsysUniquePadId *unique_pad_ids, s32 count, s32 *total_out); + +/** + * @brief Sets information that your AppletResourceUserId is in focus. + * @note This is automatically used by am-sysmodule, don't use it if your AppletType is other than None. + * @note Using it with uninitialized applet services results in your process being tied to currently focused applet. + */ +Result SetAppletResourceUserId(void); + +/** + * @brief EnableAppletToGetInput + * @param[in] enable Input flag. +**/ +Result EnableAppletToGetInput(bool enable); + +/** + * @brief EnableHandheldHids +**/ +Result EnableHandheldHids(void); + +/** + * @brief DisableHandheldHids +**/ +Result DisableHandheldHids(void); + +/** + * @brief SetJoyConRailEnabled + * @note Only available on [9.0.0+]. + * @param[in] enable Input flag. +**/ +Result SetJoyConRailEnabled(bool enable); + +/** + * @brief IsJoyConRailEnabled + * @note Only available on [9.0.0+]. + * @param[out] out Output flag. +**/ +Result IsJoyConRailEnabled(bool *out); + +/** + * @brief IsHandheldHidsEnabled + * @note Only available on [10.0.0+]. + * @param[out] out Output flag. +**/ +Result IsHandheldHidsEnabled(bool *out); + +/** + * @brief IsJoyConAttachedOnAllRail + * @note Only available on [11.0.0+]. + * @param[out] out Output flag. +**/ +Result IsJoyConAttachedOnAllRail(bool *out); + +/** + * @brief IsInvertedControllerConnectedOnRail + * @note Only available on [19.0.0+]. + * @param[out] out Output flag. +**/ +Result IsInvertedControllerConnectedOnRail(bool *out); + +/** + * @brief AcquireUniquePadConnectionEventHandle + * @param[out] out_event Output Event. + */ +Result AcquireUniquePadConnectionEventHandle(Event *out_event); + +/** + * @brief Gets a list of all UniquePadIds. + * @param[out] unique_pad_ids Output array of \ref HidsysUniquePadId. + * @param[in] count Max number of entries for the unique_pad_ids array. + * @param[out] total_out Total output array entries. Optional, can be NULL. + */ +Result GetUniquePadIds(HidsysUniquePadId *unique_pad_ids, s32 count, s32 *total_out); + +/** + * @brief AcquireJoyDetachOnBluetoothOffEventHandle + * @param[out] out_event Output Event. + * @param[in] Event autoclear. + */ +Result AcquireJoyDetachOnBluetoothOffEventHandle(Event *out_event, bool autoclear); + +/** + * @brief GetUniquePadBluetoothAddress + * @note Only available on [3.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] address \ref BtdrvAddress + */ +Result GetUniquePadBluetoothAddress(HidsysUniquePadId unique_pad_id, BtdrvAddress *address); + +/** + * @brief DisconnectUniquePad + * @note Only available on [3.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + */ +Result DisconnectUniquePad(HidsysUniquePadId unique_pad_id); + +/** + * @brief GetUniquePadType + * @note Only available on [5.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] pad_type \ref HidsysUniquePadType + */ +Result GetUniquePadType(HidsysUniquePadId unique_pad_id, HidsysUniquePadType *pad_type); + +/** + * @brief GetUniquePadInterface + * @note Only available on [5.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] interface \ref HidNpadInterfaceType + */ +Result GetUniquePadInterface(HidsysUniquePadId unique_pad_id, HidNpadInterfaceType *interface); + +/** + * @brief Gets the \ref HidsysUniquePadSerialNumber. + * @note Only available on [5.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] serial \ref HidsysUniquePadSerialNumber + */ +Result GetUniquePadSerialNumber(HidsysUniquePadId unique_pad_id, HidsysUniquePadSerialNumber *serial); + +/** + * @brief GetUniquePadControllerNumber + * @note Only available on [5.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] number Controller number. + */ +Result GetUniquePadControllerNumber(HidsysUniquePadId unique_pad_id, u64 *number); + +/** + * @brief Sets the HOME-button notification LED pattern, for the specified controller. + * @note Generally this should only be used if \ref hidsysSetNotificationLedPatternWithTimeout is not usable. + * @note Only available on [7.0.0+]. + * @param[in] pattern \ref HidsysNotificationLedPattern + * @param[in] unique_pad_id \ref HidsysUniquePadId + */ +Result SetNotificationLedPattern(const HidsysNotificationLedPattern *pattern, HidsysUniquePadId unique_pad_id); + +/** + * @brief Sets the HOME-button notification LED pattern, for the specified controller. The LED will automatically be disabled once the specified timeout occurs. + * @note Only available on [9.0.0+], and with controllers which have the [9.0.0+] firmware installed. + * @param[in] pattern \ref HidsysNotificationLedPattern + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] timeout Timeout in nanoseconds. + */ +Result SetNotificationLedPatternWithTimeout(const HidsysNotificationLedPattern *pattern, HidsysUniquePadId unique_pad_id, u64 timeout); + +/** + * @brief IsUsbFullKeyControllerEnabled + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsUsbFullKeyControllerEnabled(bool *out); + +/** + * @brief EnableUsbFullKeyController + * @note Only available on [3.0.0+]. + * @param[in] flag Flag + */ +Result EnableUsbFullKeyController(bool flag); + +/** + * @brief IsUsbConnected + * @note Only available on [3.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Output flag. + */ +Result IsUsbConnected(HidsysUniquePadId unique_pad_id, bool *out); + +/** + * @brief GetTouchScreenDefaultConfiguration + * @note Only available on [9.0.0+]. + * @param[out] touch_screen_configuration \ref HidTouchScreenConfigurationForNx. + */ +Result GetTouchScreenDefaultConfiguration(HidTouchScreenConfigurationForNx *touch_screen_configuration); + +/** + * @brief IsFirmwareUpdateNeededForNotification + * @note Only available on [9.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Output flag. + */ +Result IsFirmwareUpdateNeededForNotification(HidsysUniquePadId unique_pad_id, bool *out); + +/** + * @brief Legacy IsButtonConfigSupported. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysIsButtonConfigSupported instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Output bool flag. + */ +Result LegacyIsButtonConfigSupported(HidsysUniquePadId unique_pad_id, bool *out); + +/** + * @brief IsButtonConfigSupported + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyIsButtonConfigSupported instead. + * @param[in] addr \ref BtdrvAddress + * @param[out] out Output bool flag. + */ +Result IsButtonConfigSupported(BtdrvAddress addr, bool *out); + +/** + * @brief IsButtonConfigEmbeddedSupported + * @note Only available on [11.0.0-17.0.1]. + * @param[out] out Output bool flag. + */ +Result IsButtonConfigEmbeddedSupported(bool *out); + +/** + * @brief Legacy DeleteButtonConfig. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysDeleteButtonConfig instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + */ +Result LegacyDeleteButtonConfig(HidsysUniquePadId unique_pad_id); + +/** + * @brief DeleteButtonConfig + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyDeleteButtonConfig instead. + * @param[in] addr \ref BtdrvAddress + */ +Result DeleteButtonConfig(BtdrvAddress addr); + +/** + * @brief DeleteButtonConfigEmbedded + * @note Only available on [11.0.0-17.0.1]. + */ +Result DeleteButtonConfigEmbedded(void); + +/** + * @brief Legacy SetButtonConfigEnabled. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysSetButtonConfigEnabled instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] flag Input flag. + */ +Result LegacySetButtonConfigEnabled(HidsysUniquePadId unique_pad_id, bool flag); + +/** + * @brief SetButtonConfigEnabled + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacySetButtonConfigEnabled instead. + * @param[in] addr \ref BtdrvAddress + * @param[in] flag Input flag. + */ +Result SetButtonConfigEnabled(BtdrvAddress addr, bool flag); + +/** + * @brief SetButtonConfigEmbeddedEnabled + * @note Only available on [11.0.0-17.0.1]. + * @param[in] flag Input flag. + */ +Result SetButtonConfigEmbeddedEnabled(bool flag); + +/** + * @brief Legacy IsButtonConfigEnabled. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysIsButtonConfigEnabled instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Output bool flag. + */ +Result LegacyIsButtonConfigEnabled(HidsysUniquePadId unique_pad_id, bool *out); + +/** + * @brief IsButtonConfigEnabled + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyIsButtonConfigEnabled instead. + * @param[in] addr \ref BtdrvAddress + * @param[in] out Output bool flag. + */ +Result IsButtonConfigEnabled(BtdrvAddress addr, bool *out); + +/** + * @brief IsButtonConfigEmbeddedEnabled + * @note Only available on [11.0.0-17.0.1]. + * @param[out] out Output bool flag. + */ +Result IsButtonConfigEmbeddedEnabled(bool *out); + +/** + * @brief Legacy SetButtonConfigEmbedded. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysSetButtonConfigEmbedded instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidsysButtonConfigEmbedded + */ +Result LegacySetButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigEmbedded *config); + +/** + * @brief SetButtonConfigEmbedded + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacySetButtonConfigEmbedded instead. + * @param[in] config \ref HidsysButtonConfigEmbedded + */ +Result SetButtonConfigEmbedded(const HidsysButtonConfigEmbedded *config); + +/** + * @brief Legacy SetButtonConfigFull. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysSetButtonConfigFull instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidsysButtonConfigFull + */ +Result LegacySetButtonConfigFull(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigFull *config); + +/** + * @brief SetButtonConfigFull + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacySetButtonConfigFull instead. + * @param[in] addr \ref BtdrvAddress + * @param[in] config \ref HidsysButtonConfigFull + */ +Result SetButtonConfigFull(BtdrvAddress addr, const HidsysButtonConfigFull *config); + +/** + * @brief Legacy SetButtonConfigLeft. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysSetButtonConfigLeft instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidsysButtonConfigLeft + */ +Result LegacySetButtonConfigLeft(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigLeft *config); + +/** + * @brief SetButtonConfigLeft + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacySetButtonConfigLeft instead. + * @param[in] addr \ref BtdrvAddress + * @param[in] config \ref HidsysButtonConfigLeft + */ +Result SetButtonConfigLeft(BtdrvAddress addr, const HidsysButtonConfigLeft *config); + +/** + * @brief Legacy SetButtonConfigRight. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysSetButtonConfigRight instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidsysButtonConfigRight + */ +Result LegacySetButtonConfigRight(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigRight *config); + +/** + * @brief SetButtonConfigRight + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacySetButtonConfigRight instead. + * @param[in] addr \ref BtdrvAddress + * @param[in] config \ref HidsysButtonConfigRight + */ +Result SetButtonConfigRight(BtdrvAddress addr, const HidsysButtonConfigRight *config); + +/** + * @brief Legacy GetButtonConfigEmbedded. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysGetButtonConfigEmbedded instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidsysButtonConfigEmbedded + */ +Result LegacyGetButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, HidsysButtonConfigEmbedded *config); + +/** + * @brief GetButtonConfigEmbedded + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyGetButtonConfigEmbedded instead. + * @param[out] config \ref HidsysButtonConfigEmbedded + */ +Result GetButtonConfigEmbedded(HidsysButtonConfigEmbedded *config); + +/** + * @brief Legacy GetButtonConfigFull. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysGetButtonConfigFull instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidsysButtonConfigFull + */ +Result LegacyGetButtonConfigFull(HidsysUniquePadId unique_pad_id, HidsysButtonConfigFull *config); + +/** + * @brief GetButtonConfigFull + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyGetButtonConfigFull instead. + * @param[in] addr \ref BtdrvAddress + * @param[out] config \ref HidsysButtonConfigFull + */ +Result GetButtonConfigFull(BtdrvAddress addr, HidsysButtonConfigFull *config); + +/** + * @brief Legacy GetButtonConfigLeft. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysGetButtonConfigLeft instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidsysButtonConfigLeft + */ +Result LegacyGetButtonConfigLeft(HidsysUniquePadId unique_pad_id, HidsysButtonConfigLeft *config); + +/** + * @brief GetButtonConfigLeft + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyGetButtonConfigLeft instead. + * @param[in] addr \ref BtdrvAddress + * @param[out] config \ref HidsysButtonConfigLeft + */ +Result GetButtonConfigLeft(BtdrvAddress addr, HidsysButtonConfigLeft *config); + +/** + * @brief Legacy GetButtonConfigRight. + * @note Only available on [10.0.0-10.2.0]. On [11.0.0-17.0.1], use \ref hidsysGetButtonConfigRight instead. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidsysButtonConfigRight + */ +Result LegacyGetButtonConfigRight(HidsysUniquePadId unique_pad_id, HidsysButtonConfigRight *config); + +/** + * @brief GetButtonConfigRight + * @note Only available on [11.0.0-17.0.1]. On [10.0.0-10.2.0], use \ref hidsysLegacyGetButtonConfigRight instead. + * @param[in] addr \ref BtdrvAddress + * @param[out] config \ref HidsysButtonConfigRight + */ +Result GetButtonConfigRight(BtdrvAddress addr, HidsysButtonConfigRight *config); + +/** + * @brief IsCustomButtonConfigSupported + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Output bool flag. + */ +Result IsCustomButtonConfigSupported(HidsysUniquePadId unique_pad_id, bool *out); + +/** + * @brief IsDefaultButtonConfigEmbedded + * @note Only available on [10.0.0+]. + * @param[in] config \ref HidcfgButtonConfigEmbedded + * @param[out] out Output bool flag. + */ +Result IsDefaultButtonConfigEmbedded(const HidcfgButtonConfigEmbedded *config, bool *out); + +/** + * @brief IsDefaultButtonConfigFull + * @note Only available on [10.0.0+]. + * @param[in] config \ref HidcfgButtonConfigFull + * @param[out] out Output bool flag. + */ +Result IsDefaultButtonConfigFull(const HidcfgButtonConfigFull *config, bool *out); + +/** + * @brief IsDefaultButtonConfigLeft + * @note Only available on [10.0.0+]. + * @param[in] config \ref HidcfgButtonConfigLeft + * @param[out] out Output bool flag. + */ +Result IsDefaultButtonConfigLeft(const HidcfgButtonConfigLeft *config, bool *out); + +/** + * @brief IsDefaultButtonConfigRight + * @note Only available on [10.0.0+]. + * @param[in] config \ref HidcfgButtonConfigRight + * @param[out] out Output bool flag. + */ +Result IsDefaultButtonConfigRight(const HidcfgButtonConfigRight *config, bool *out); + +/** + * @brief IsButtonConfigStorageEmbeddedEmpty + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] out Output bool flag. + */ +Result IsButtonConfigStorageEmbeddedEmpty(s32 index, bool *out); + +/** + * @brief IsButtonConfigStorageFullEmpty + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] out Output bool flag. + */ +Result IsButtonConfigStorageFullEmpty(s32 index, bool *out); + +/** + * @brief IsButtonConfigStorageLeftEmpty + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] out Output bool flag. + */ +Result IsButtonConfigStorageLeftEmpty(s32 index, bool *out); + +/** + * @brief IsButtonConfigStorageRightEmpty + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] out Output bool flag. + */ +Result IsButtonConfigStorageRightEmpty(s32 index, bool *out); + +/** + * @brief GetButtonConfigStorageEmbeddedDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigEmbedded + */ +Result GetButtonConfigStorageEmbeddedDeprecated(s32 index, HidcfgButtonConfigEmbedded *config); + +/** + * @brief GetButtonConfigStorageFullDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigFull + */ +Result GetButtonConfigStorageFullDeprecated(s32 index, HidcfgButtonConfigFull *config); + +/** + * @brief GetButtonConfigStorageLeftDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigLeft + */ +Result GetButtonConfigStorageLeftDeprecated(s32 index, HidcfgButtonConfigLeft *config); + +/** + * @brief GetButtonConfigStorageRightDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigRight + */ +Result GetButtonConfigStorageRightDeprecated(s32 index, HidcfgButtonConfigRight *config); + +/** + * @brief SetButtonConfigStorageEmbeddedDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigEmbedded + */ +Result SetButtonConfigStorageEmbeddedDeprecated(s32 index, const HidcfgButtonConfigEmbedded *config); + +/** + * @brief SetButtonConfigStorageFullDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigFull + */ +Result SetButtonConfigStorageFullDeprecated(s32 index, const HidcfgButtonConfigFull *config); + +/** + * @brief SetButtonConfigStorageLeftDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigLeft + */ +Result SetButtonConfigStorageLeftDeprecated(s32 index, const HidcfgButtonConfigLeft *config); + +/** + * @brief SetButtonConfigStorageRightDeprecated + * @note Only available on [10.0.0-12.1.0]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigRight + */ +Result SetButtonConfigStorageRightDeprecated(s32 index, const HidcfgButtonConfigRight *config); + +/** + * @brief DeleteButtonConfigStorageEmbedded + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + */ +Result DeleteButtonConfigStorageEmbedded(s32 index); + +/** + * @brief DeleteButtonConfigStorageFull + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + */ +Result DeleteButtonConfigStorageFull(s32 index); + +/** + * @brief DeleteButtonConfigStorageLeft + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + */ +Result DeleteButtonConfigStorageLeft(s32 index); + +/** + * @brief DeleteButtonConfigStorageRight + * @note Only available on [10.0.0+]. + * @param[in] index Array index, should be 0-4. + */ +Result DeleteButtonConfigStorageRight(s32 index); + +/** + * @brief IsUsingCustomButtonConfig + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] out Output bool flag. + */ +Result IsUsingCustomButtonConfig(HidsysUniquePadId unique_pad_id, bool *out); + +/** + * @brief IsAnyCustomButtonConfigEnabled + * @note Only available on [10.0.0+]. + * @param[out] out Output bool flag. + */ +Result IsAnyCustomButtonConfigEnabled(bool *out); + +/** + * @brief SetAllCustomButtonConfigEnabled + * @note Only available on [10.0.0+]. + * @param[in] AppletResourceUserId AppletResourceUserId + * @param[in] flag Input bool flag. + */ +Result SetAllCustomButtonConfigEnabled(u64 AppletResourceUserId, bool flag); + +/** + * @brief SetAllDefaultButtonConfig + * @note Only available on [10.0.0+]. + */ +Result SetAllDefaultButtonConfig(void); + +/** + * @brief SetHidButtonConfigEmbedded + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidcfgButtonConfigEmbedded + */ +Result SetHidButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigEmbedded *config); + +/** + * @brief SetHidButtonConfigFull + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidcfgButtonConfigFull + */ +Result SetHidButtonConfigFull(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigFull *config); + +/** + * @brief SetHidButtonConfigLeft + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidcfgButtonConfigLeft + */ +Result SetHidButtonConfigLeft(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigLeft *config); + +/** + * @brief SetHidButtonConfigRight + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[in] config \ref HidcfgButtonConfigRight + */ +Result SetHidButtonConfigRight(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigRight *config); + +/** + * @brief GetHidButtonConfigEmbedded + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidcfgButtonConfigEmbedded + */ +Result GetHidButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigEmbedded *config); + +/** + * @brief GetHidButtonConfigFull + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidcfgButtonConfigFull + */ +Result GetHidButtonConfigFull(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigFull *config); + +/** + * @brief GetHidButtonConfigLeft + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidcfgButtonConfigLeft + */ +Result GetHidButtonConfigLeft(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigLeft *config); + +/** + * @brief GetHidButtonConfigRight + * @note Only available on [10.0.0+]. + * @param[in] unique_pad_id \ref HidsysUniquePadId + * @param[out] config \ref HidcfgButtonConfigRight + */ +Result GetHidButtonConfigRight(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigRight *config); + +/** + * @brief GetButtonConfigStorageEmbedded + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigEmbedded + * @param[out] name \ref HidcfgStorageName + */ +Result GetButtonConfigStorageEmbedded(s32 index, HidcfgButtonConfigEmbedded *config, HidcfgStorageName *name); + +/** + * @brief GetButtonConfigStorageFull + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigFull + * @param[out] name \ref HidcfgStorageName + */ +Result GetButtonConfigStorageFull(s32 index, HidcfgButtonConfigFull *config, HidcfgStorageName *name); + +/** + * @brief GetButtonConfigStorageLeft + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigLeft + * @param[out] name \ref HidcfgStorageName + */ +Result GetButtonConfigStorageLeft(s32 index, HidcfgButtonConfigLeft *config, HidcfgStorageName *name); + +/** + * @brief GetButtonConfigStorageRight + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[out] config \ref HidcfgButtonConfigRight + * @param[out] name \ref HidcfgStorageName + */ +Result GetButtonConfigStorageRight(s32 index, HidcfgButtonConfigRight *config, HidcfgStorageName *name); + +/** + * @brief SetButtonConfigStorageEmbedded + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigEmbedded + * @param[in] name \ref HidcfgStorageName + */ +Result SetButtonConfigStorageEmbedded(s32 index, const HidcfgButtonConfigEmbedded *config, const HidcfgStorageName *name); + +/** + * @brief SetButtonConfigStorageFull + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigFull + * @param[in] name \ref HidcfgStorageName + */ +Result SetButtonConfigStorageFull(s32 index, const HidcfgButtonConfigFull *config, const HidcfgStorageName *name); + +/** + * @brief SetButtonConfigStorageLeft + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigLeft + * @param[in] name \ref HidcfgStorageName + */ +Result SetButtonConfigStorageLeft(s32 index, const HidcfgButtonConfigLeft *config, const HidcfgStorageName *name); + +/** + * @brief SetButtonConfigStorageRight + * @note Only available on [11.0.0+]. + * @param[in] index Array index, should be 0-4. + * @param[in] config \ref HidcfgButtonConfigRight + * @param[in] name \ref HidcfgStorageName + */ +Result SetButtonConfigStorageRight(s32 index, const HidcfgButtonConfigRight *config, const HidcfgStorageName *name); + +} // namespace hidsys + +/// @brief C++ wrappers for the `hipc` API. +/// @details Wraps: switch/sf/hipc.h. +namespace hipc { + +using ::HipcBufferDescriptor; +using ::HipcBufferMode; +using ::HipcHeader; +using ::HipcMetadata; +using ::HipcParsedRequest; +using ::HipcRecvListEntry; +using ::HipcRequest; +using ::HipcResponse; +using ::HipcSpecialHeader; +using ::HipcStaticDescriptor; + +HipcStaticDescriptor MakeSendStatic(const void* buffer, size_t size, u8 index); + +HipcBufferDescriptor MakeBuffer(const void* buffer, size_t size, HipcBufferMode mode); + +HipcRecvListEntry MakeRecvStatic(void* buffer, size_t size); + +void* GetStaticAddress(const HipcStaticDescriptor* desc); + +size_t GetStaticSize(const HipcStaticDescriptor* desc); + +void* GetBufferAddress(const HipcBufferDescriptor* desc); + +size_t GetBufferSize(const HipcBufferDescriptor* desc); + +HipcRequest CalcRequestLayout(HipcMetadata meta, void* base); + +HipcRequest MakeRequest(void* base, HipcMetadata meta); + +HipcParsedRequest ParseRequest(void* base); + +HipcResponse ParseResponse(void* base); + +} // namespace hipc + +/// @brief C++ wrappers for the `hmac` API. +/// @details Wraps: switch/crypto/hmac.h. +namespace hmac { + +/// Context for HMAC-SHA1 operations. +using ::HmacSha1Context; +/// Context for HMAC-SHA256 operations. +using ::HmacSha256Context; + +/// Initialize a HMAC-SHA256 context. +void Sha256ContextCreate(HmacSha256Context *out, const void *key, size_t key_size); + +/// Updates HMAC-SHA256 context with data to hash +void Sha256ContextUpdate(HmacSha256Context *ctx, const void *src, size_t size); + +/// Gets the context's output mac, finalizes the context. +void Sha256ContextGetMac(HmacSha256Context *ctx, void *dst); + +/// Simple all-in-one HMAC-SHA256 calculator. +void Sha256CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size); + +/// Initialize a HMAC-SHA1 context. +void Sha1ContextCreate(HmacSha1Context *out, const void *key, size_t key_size); + +/// Updates HMAC-SHA1 context with data to hash +void Sha1ContextUpdate(HmacSha1Context *ctx, const void *src, size_t size); + +/// Gets the context's output mac, finalizes the context. +void Sha1ContextGetMac(HmacSha1Context *ctx, void *dst); + +/// Simple all-in-one HMAC-SHA1 calculator. +void Sha1CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size); + +} // namespace hmac + +/// @brief C++ wrappers for the `hosversion` API. +/// @details Wraps: switch/runtime/hosversion.h. +namespace hosversion { + +/// 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 Get(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 Set(u32 version); + +/// Returns whether the current HOS version is augmented by running the Atmosphère custom firmware. +bool IsAtmosphere(void); + +/// Returns true if the current HOS version is equal to or above the specified major/minor/micro version. +bool AtLeast(u8 major, u8 minor, u8 micro); + +/// Returns true if the current HOS version is earlier than the specified major/minor/micro version. +bool Before(u8 major, u8 minor, u8 micro); + +/// Returns true if the current HOS version is between the two specified major versions, i.e. [major1, major2). +bool Between(u8 major1, u8 major2); + +} // namespace hosversion + +/// @brief C++ wrappers for the `hwopus` API. +/// @details Wraps: switch/services/hwopus.h. +namespace hwopus { + +using ::HwopusDecoder; +/// This structure is the start of opusin for \ref hwopusDecodeInterleaved, with the actual opus packet following this. +/// These fields are big-endian. +using ::HwopusHeader; +/// Used internally. +using ::HwopusMultistreamState; + +Result DecoderInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount); + +void DecoderExit(HwopusDecoder* decoder); + +/// Only available on [3.0.0+]. +/// See libopus multistream docs. +Result DecoderMultistreamInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount, s32 TotalStreamCount, s32 StereoStreamCount, u8 *channel_mapping); + +/// Decodes opus data. +Result DecodeInterleaved(HwopusDecoder* decoder, s32 *DecodedDataSize, s32 *DecodedSampleCount, const void* opusin, size_t opusin_size, s16 *pcmbuf, size_t pcmbuf_size); + +} // namespace hwopus + +/// @brief C++ wrappers for the `i2c` API. +/// @details Wraps: switch/services/i2c.h. +namespace i2c { + +using ::I2cDevice; +using ::I2cSession; +using ::I2cTransactionOption; + +/// Initialize i2c. +Result Initialize(void); + +/// Exit i2c. +void Exit(void); + +/// Gets the Service object for the actual i2c service session. +Service* GetServiceSession(void); + +Result OpenSession(I2cSession *out, I2cDevice dev); + +} // namespace i2c + +/// @brief C++ wrappers for the `i2csession` API. +/// @details Wraps: switch/services/i2c.h. +namespace i2csession { + +using ::I2cDevice; +using ::I2cSession; +using ::I2cTransactionOption; + +Result SendAuto(I2cSession *s, const void *buf, size_t size, I2cTransactionOption option); + +Result ReceiveAuto(I2cSession *s, void *buf, size_t size, I2cTransactionOption option); + +Result ExecuteCommandList(I2cSession *s, void *dst, size_t dst_size, const void *cmd_list, size_t cmd_list_size); + +void Close(I2cSession *s); + +} // namespace i2csession + +/// @brief C++ wrappers for the `idlesys` API. +/// @details Wraps: switch/services/idlesys.h. +namespace idlesys { + +/// Initialize idle:sys. +Result Initialize(void); + +/// Exit idle:sys. +void Exit(void); + +/// Gets the Service for idle:sys. +Service* GetServiceSession(void); + +/// Resets sleep counter. +Result ReportUserIsActive(void); + +} // namespace idlesys + +/// @brief C++ wrappers for the `insr` API. +/// @details Wraps: switch/services/ins.h. +namespace insr { + +/// Initialize ins:r. +Result Initialize(void); + +/// Exit ins:r. +void Exit(void); + +/// Gets the Service object for the actual ins:r service session. +Service* GetServiceSession(void); + +/** + * @brief Retrieves the last system tick the event corresponding to the ID was signaled at. + * @param[in] id Ins request ID (should be 0..4). + * @param[out] tick. + * @return Result code. + * @note The tick is only updated once per second at minimum. + */ +Result GetLastTick(u32 id, u64 *tick); + +/** + * @brief Retrieves the event corresponding to the ID. + * @param[in] id Ins request ID (should be 0..4). + * @param[out] out. + * @return Result code. + * @note The event is only signaled once per second at minimum. + */ +Result GetReadableEvent(u32 id, Event *out); + +} // namespace insr + +/// @brief C++ wrappers for the `inss` API. +/// @details Wraps: switch/services/ins.h. +namespace inss { + +/// Initialize ins:s. +Result Initialize(void); + +/// Exit ins:s. +void Exit(void); + +/// Gets the Service object for the actual ins:s service session. +Service* GetServiceSession(void); + +/** + * @brief Retrieves the event corresponding to the ID. + * @param[in] id Ins send ID (should be 0..11). + * @param[out] out. + * @return Result code. + * @note The returned event cannot be waited on, only signaled. Clearing is handled by the service. + */ +Result GetWritableEvent(u32 id, Event *out); + +} // namespace inss + +/// @brief C++ wrappers for the `irs` API. +/// @details Wraps: switch/services/irs.h. +namespace irs { + +/// AdaptiveClusteringMode +using ::IrsAdaptiveClusteringMode; +/// AdaptiveClusteringProcessorConfig +using ::IrsAdaptiveClusteringProcessorConfig; +/// AdaptiveClusteringTargetDistance +using ::IrsAdaptiveClusteringTargetDistance; +/// AruidFormat +using ::IrsAruidFormat; +/// ClusteringData +using ::IrsClusteringData; +/// ClusteringProcessorConfig +using ::IrsClusteringProcessorConfig; +/// ClusteringProcessorState +using ::IrsClusteringProcessorState; +/// DeviceFormat +using ::IrsDeviceFormat; +/// HandAnalysisConfig +using ::IrsHandAnalysisConfig; +/// HandAnalysisMode +using ::IrsHandAnalysisMode; +/// ImageProcessorStatus +using ::IrsImageProcessorStatus; +/// ImageTransferProcessorConfig +using ::IrsImageTransferProcessorConfig; +/// ImageTransferProcessorExConfig +using ::IrsImageTransferProcessorExConfig; +/// ImageTransferProcessorFormat. IR Sensor image resolution. +using ::IrsImageTransferProcessorFormat; +/// ImageTransferProcessorState +using ::IrsImageTransferProcessorState; +/// IrCameraHandle +using ::IrsIrCameraHandle; +/// IrCameraInternalStatus +using ::IrsIrCameraInternalStatus; +/// IrCameraStatus +using ::IrsIrCameraStatus; +/// IrLedProcessorConfig +using ::IrsIrLedProcessorConfig; +/// IrSensorMode +using ::IrsIrSensorMode; +/// IrsMomentProcessorConfig +using ::IrsMomentProcessorConfig; +/// MomentProcessorState +using ::IrsMomentProcessorState; +/// MomentStatistic +using ::IrsMomentStatistic; +/// PackedClusteringProcessorConfig +using ::IrsPackedClusteringProcessorConfig; +/// PackedFunctionLevel +using ::IrsPackedFunctionLevel; +/// PackedImageTransferProcessorConfig +using ::IrsPackedImageTransferProcessorConfig; +/// PackedImageTransferProcessorExConfig +using ::IrsPackedImageTransferProcessorExConfig; +/// PackedIrLedProcessorConfig +using ::IrsPackedIrLedProcessorConfig; +/// PackedMcuVersion +using ::IrsPackedMcuVersion; +/// PackedMomentProcessorConfig +using ::IrsPackedMomentProcessorConfig; +/// PackedPointingProcessorConfig +using ::IrsPackedPointingProcessorConfig; +/// PackedTeraPluginProcessorConfig +using ::IrsPackedTeraPluginProcessorConfig; +/// PointingProcessorMarkerState +using ::IrsPointingProcessorMarkerState; +/// PointingProcessorState +using ::IrsPointingProcessorState; +/// ProcessorState +using ::IrsProcessorState; +/// Rect +using ::IrsRect; +/// StatusManager +using ::IrsStatusManager; +/// TeraPluginProcessorConfig +using ::IrsTeraPluginProcessorConfig; +/// TeraPluginProcessorState +using ::IrsTeraPluginProcessorState; +/// Internal validation callblack. +using ::IrsValidationCb; + +/// Initialize irs. +Result Initialize(void); + +/// Exit irs. +void Exit(void); + +/// Gets the Service object for the actual irs service session. +Service* GetServiceSession(void); + +/// Gets the address of the SharedMemory (\ref IrsStatusManager). +void* GetSharedmemAddr(void); + +/// Gets the \ref IrsIrCameraHandle for the specified controller. +Result GetIrCameraHandle(IrsIrCameraHandle *handle, HidNpadIdType id); + +/// GetIrCameraStatus +Result GetIrCameraStatus(IrsIrCameraHandle handle, IrsIrCameraStatus *out); + +/// CheckFirmwareUpdateNecessity +/// When successful where the output flag is set, the user should use \ref hidLaShowControllerFirmwareUpdate. +/// Only available on [4.0.0+]. +Result CheckFirmwareUpdateNecessity(IrsIrCameraHandle handle, bool *out); + +/// GetImageProcessorStatus +/// Only available on [4.0.0+]. +Result GetImageProcessorStatus(IrsIrCameraHandle handle, IrsImageProcessorStatus *out); + +/// Stop the current Processor. +/// \ref irsExit calls this with all IrCameraHandles which were not already used with \ref irsStopImageProcessor. +Result StopImageProcessor(IrsIrCameraHandle handle); + +/// Stop the current Processor, async. +/// Only available on [4.0.0+]. +Result StopImageProcessorAsync(IrsIrCameraHandle handle); + +/** + * @brief Run the MomentProcessor. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + */ +Result RunMomentProcessor(IrsIrCameraHandle handle, const IrsMomentProcessorConfig *config); + +/** + * @brief Gets the states for MomentProcessor or IrLedProcessor. + * @note The official GetIrLedProcessorState is essentially the same as this, except it uses hard-coded count=1 with output-array on stack, without returning that data. Hence we don't implement a seperate func for that. + * @param[in] handle \ref IrsIrCameraHandle + * @param[out] states Output array of \ref IrsMomentProcessorState. + * @param[in] count Size of the states array in entries. Must be 1-5. + * @param[out] total_out Total output entries. + */ +Result GetMomentProcessorStates(IrsIrCameraHandle handle, IrsMomentProcessorState *states, s32 count, s32 *total_out); + +/** + * @brief Calculates an \ref IrsMomentStatistic from the specified region in the input \ref IrsMomentProcessorState. + * @param[in] state \ref IrsMomentProcessorState + * @param[in] rect \ref IrsRect, containing the image width and height. + * @param[in] region_x Region x, must be 0-5 (clamped to this range otherwise). region_x = image_x/6. + * @param[in] region_y Region y, must be 0-7 (clamped to this range otherwise). region_y = image_y/8. + * @param[in] region_width Region width. region_x+region_width must be <=6 (clamped to this range otherwise). + * @param[in] region_height Region height. region_y+region_height must be <=8 (clamped to this range otherwise). + */ +IrsMomentStatistic CalculateMomentRegionStatistic(const IrsMomentProcessorState *state, IrsRect rect, s32 region_x, s32 region_y, s32 region_width, s32 region_height); + +/** + * @brief Run the ClusteringProcessor. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + */ +Result RunClusteringProcessor(IrsIrCameraHandle handle, const IrsClusteringProcessorConfig *config); + +/** + * @brief Gets the states for ClusteringProcessor. + * @param[in] handle \ref IrsIrCameraHandle + * @param[out] states Output array of \ref IrsClusteringProcessorState. + * @param[in] count Size of the states array in entries. Must be 1-5. + * @param[out] total_out Total output entries. + */ +Result GetClusteringProcessorStates(IrsIrCameraHandle handle, IrsClusteringProcessorState *states, s32 count, s32 *total_out); + +/** + * @brief Run the ImageTransferProcessor. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + * @param[in] size Work-buffer size, must be 0x1000-byte aligned. + */ +Result RunImageTransferProcessor(IrsIrCameraHandle handle, const IrsImageTransferProcessorConfig *config, size_t size); + +/** + * @brief Run the ImageTransferExProcessor. + * @note Only available on [4.0.0+]. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + * @param[in] size Work-buffer size, must be 0x1000-byte aligned. + */ +Result RunImageTransferExProcessor(IrsIrCameraHandle handle, const IrsImageTransferProcessorExConfig *config, size_t size); + +/// GetImageTransferProcessorState +Result GetImageTransferProcessorState(IrsIrCameraHandle handle, void* buffer, size_t size, IrsImageTransferProcessorState *state); + +/** + * @brief Run the PointingProcessor. + * @param[in] handle \ref IrsIrCameraHandle + */ +Result RunPointingProcessor(IrsIrCameraHandle handle); + +/** + * @brief Gets the states for PointingProcessor. + * @param[in] handle \ref IrsIrCameraHandle + * @param[out] states Output array of \ref IrsPointingProcessorMarkerState. + * @param[in] count Size of the states array in entries. Must be 1-6. + * @param[out] total_out Total output entries. + */ +Result GetPointingProcessorMarkerStates(IrsIrCameraHandle handle, IrsPointingProcessorMarkerState *states, s32 count, s32 *total_out); + +/** + * @brief Gets the states for \ref IrsPointingProcessorState. + * @note This uses \ref irsGetPointingProcessorMarkerStates, then converts the output to \ref IrsPointingProcessorState. + * @param[in] handle \ref IrsIrCameraHandle + * @param[out] states Output array of \ref IrsPointingProcessorState. + * @param[in] count Size of the states array in entries. Must be 1-6. + * @param[out] total_out Total output entries. + */ +Result GetPointingProcessorStates(IrsIrCameraHandle handle, IrsPointingProcessorState *states, s32 count, s32 *total_out); + +/** + * @brief Run the TeraPluginProcessor. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + */ +Result RunTeraPluginProcessor(IrsIrCameraHandle handle, const IrsTeraPluginProcessorConfig *config); + +/** + * @brief Gets the states for TeraPluginProcessor, filtered using the input params. + * @param[in] handle \ref IrsIrCameraHandle + * @param[out] states Output array of \ref IrsTeraPluginProcessorState. + * @param[in] count Size of the states array in entries. Must be 1-5. + * @param[in] sampling_number Minimum value for IrsTeraPluginProcessorState::sampling_number. + * @param[in] prefix_data Only used when prefix_bitcount is not 0. The first prefix_bitcount bits from prefix_data must match the first prefix_bitcount bits in IrsTeraPluginProcessorState::plugin_data. + * @param[in] prefix_bitcount Total bits for prefix_data. + * @param[out] total_out Total output entries. + */ +Result GetTeraPluginProcessorStates(IrsIrCameraHandle handle, IrsTeraPluginProcessorState *states, s32 count, s64 sampling_number, u32 prefix_data, u32 prefix_bitcount, s32 *total_out); + +/** + * @brief Run the IrLedProcessor. + * @note Only available on [4.0.0+]. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + */ +Result RunIrLedProcessor(IrsIrCameraHandle handle, const IrsIrLedProcessorConfig *config); + +/** + * @brief Run the AdaptiveClusteringProcessor. + * @note Only available on [5.0.0+]. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + */ +Result RunAdaptiveClusteringProcessor(IrsIrCameraHandle handle, const IrsAdaptiveClusteringProcessorConfig *config); + +/** + * @brief Run HandAnalysis. + * @param[in] handle \ref IrsIrCameraHandle + * @param[in] config Input config. + */ +Result RunHandAnalysis(IrsIrCameraHandle handle, const IrsHandAnalysisConfig *config); + +/** + * Gets the default configuration for MomentProcessor. + */ +void GetMomentProcessorDefaultConfig(IrsMomentProcessorConfig *config); + +/** + * Gets the default configuration for ClusteringProcessor. + */ +void GetClusteringProcessorDefaultConfig(IrsClusteringProcessorConfig *config); + +/** + * Gets the default configuration for ImageTransferProcessor. + * Defaults are exposure 300us, 8x digital gain, the rest is all-zero. Format is ::IrsImageTransferProcessorFormat_320x240. + */ +void GetDefaultImageTransferProcessorConfig(IrsImageTransferProcessorConfig *config); + +/** + * Gets the default configuration for ImageTransferProcessorEx. + * Defaults are exposure 300us, 8x digital gain, the rest is all-zero. OrigFormat/TrimmingFormat are ::IrsImageTransferProcessorFormat_320x240. + */ +void GetDefaultImageTransferProcessorExConfig(IrsImageTransferProcessorExConfig *config); + +/** + * Gets the default configuration for IrLedProcessor. + */ +void GetIrLedProcessorDefaultConfig(IrsIrLedProcessorConfig *config); + +} // namespace irs + +/// @brief C++ wrappers for the `jit` API. +/// @details Wraps: switch/kernel/jit.h. +namespace jit { + +/// JIT buffer object. +using ::Jit; +/// JIT implementation type. +using ::JitType; + +/** + * @brief Creates a JIT buffer. + * @param j JIT buffer. + * @param size Size of the JIT buffer. + * @return Result code. + */ +Result Create(Jit* j, size_t size); + +/** + * @brief Transition a JIT buffer to have writable permission. + * @param j JIT buffer. + * @return Result code. + */ +Result TransitionToWritable(Jit* j); + +/** + * @brief Transition a JIT buffer to have executable permission. + * @param j JIT buffer. + * @return Result code. + */ +Result TransitionToExecutable(Jit* j); + +/** + * @brief Destroys a JIT buffer. + * @param j JIT buffer. + * @return Result code. + */ +Result Close(Jit* j); + +/** + * @brief Gets the address of the writable memory alias of a JIT buffer. + * @param j JIT buffer. + * @return Pointer to alias of the JIT buffer that can be written to. + */ +void* GetRwAddr(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. + */ +void* GetRxAddr(Jit* j); + +} // namespace jit + +/// @brief C++ wrappers for the `lbl` API. +/// @details Wraps: switch/services/lbl.h. +namespace lbl { + +using ::LblBacklightSwitchStatus; + +/// Initialize lbl. +Result Initialize(void); + +/// Exit lbl. +void Exit(void); + +/// Gets the Service object for the actual lbl service session. +Service* GetServiceSession(void); + +Result SaveCurrentSetting(void); + +Result LoadCurrentSetting(void); + +/** + * @note The brightness goes from 0 to 1.0. + */ +Result SetCurrentBrightnessSetting(float brightness); + +Result GetCurrentBrightnessSetting(float *out_value); + +Result ApplyCurrentBrightnessSettingToBacklight(void); + +Result GetBrightnessSettingAppliedToBacklight(float *out_value); + +Result SwitchBacklightOn(u64 fade_time); + +Result SwitchBacklightOff(u64 fade_time); + +Result GetBacklightSwitchStatus(LblBacklightSwitchStatus *out_value); + +Result EnableDimming(void); + +Result DisableDimming(void); + +Result IsDimmingEnabled(bool *out_value); + +Result EnableAutoBrightnessControl(void); + +Result DisableAutoBrightnessControl(void); + +Result IsAutoBrightnessControlEnabled(bool *out_value); + +Result SetAmbientLightSensorValue(float value); + +/** + * @note Used internally by \ref appletGetAmbientLightSensorValue and \ref appletGetCurrentIlluminanceEx. + */ +Result GetAmbientLightSensorValue(bool *over_limit, float *lux); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by \ref appletIsIlluminanceAvailable. + */ +Result IsAmbientLightSensorAvailable(bool *out_value); + +/** + * @note Only available on [3.0.0+]. + */ +Result SetCurrentBrightnessSettingForVrMode(float brightness); + +/** + * @note Only available on [3.0.0+]. + */ +Result GetCurrentBrightnessSettingForVrMode(float *out_value); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by \ref appletSetVrModeEnabled. + */ +Result EnableVrMode(void); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by \ref appletSetVrModeEnabled. + */ +Result DisableVrMode(void); + +/** + * @note Only available on [3.0.0+]. + * @note Used internally by \ref appletIsVrModeEnabled. + */ +Result IsVrModeEnabled(bool *out_value); + +} // namespace lbl + +/// @brief C++ wrappers for the `ldn` API. +/// @details Wraps: switch/services/ldn.h. +namespace ldn { + +/// AcceptPolicy +using ::LdnAcceptPolicy; +/// ActionFrameSettings +using ::LdnActionFrameSettings; +/// AddressEntry +using ::LdnAddressEntry; +/// CommonNetworkInfo +using ::LdnCommonNetworkInfo; +/// DisconnectReason loaded by \ref ldnGetDisconnectReason. +using ::LdnDisconnectReason; +/// IntentId +using ::LdnIntentId; +/// Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). +using ::LdnIpv4Address; +/// MacAddress +using ::LdnMacAddress; +/// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate). +using ::LdnNetworkConfig; +/// NetworkId +using ::LdnNetworkId; +/// NetworkInfo +using ::LdnNetworkInfo; +/// NodeInfo +using ::LdnNodeInfo; +/// NodeLatestUpdate +using ::LdnNodeLatestUpdate; +/// OperationMode +using ::LdnOperationMode; +/// Protocol +using ::LdnProtocol; +/// ScanFilter. \ref ldnScan / \ref ldnScanPrivate will only return the \ref LdnNetworkInfo when validating the \ref LdnNetworkInfo with LdnScanFilter was sucessful, with the fields enabled by \ref LdnScanFilterFlag. +using ::LdnScanFilter; +/// ScanFilterFlag +using ::LdnScanFilterFlag; +/// SecurityConfig +using ::LdnSecurityConfig; +/// SecurityMode. LdnSecurityMode_Product can be used as the default value. The ldn cmds which use an input SecurityMode normally overwrite the SecurityMode. +using ::LdnSecurityMode; +/// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated. +using ::LdnSecurityParameter; +using ::LdnServiceType; +/// SessionId +using ::LdnSessionId; +/// Ssid +using ::LdnSsid; +/// State loaded by \ref ldnmGetStateForMonitor / \ref ldnGetState. +using ::LdnState; +/// SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). +using ::LdnSubnetMask; +/// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd. +using ::LdnUserConfig; +/// WirelessControllerRestriction +using ::LdnWirelessControllerRestriction; + +/// Initialize ldn. +/// The priority is only used with ::LdnServiceType_System on [19.0.0+]. To optionally set this, define "s32 __nx_ldn_priority". The priority must be \ref LDN_PRIORITY_SYSTEM (default) or \ref LDN_PRIORITY_USER. +Result Initialize(LdnServiceType service_type); + +/// Exit ldn. +void Exit(void); + +/// Gets the Service object for IUserLocalCommunicationService/ISystemLocalCommunicationService. +Service* GetServiceSession_LocalCommunicationService(void); + +/// Gets the Service object for IClientProcessMonitor, only valid with [18.0.0+]. +Service* GetServiceSession_IClientProcessMonitor(void); + +/** + * @brief GetState + * @param[out] out \ref LdnState + */ +Result GetState(LdnState *out); + +/** + * @brief GetNetworkInfo + * @param[out] out \ref LdnNetworkInfo + */ +Result GetNetworkInfo(LdnNetworkInfo *out); + +/** + * @brief GetIpv4Address + * @param[out] addr \ref LdnIpv4Address + * @param[out] mask \ref LdnSubnetMask + */ +Result GetIpv4Address(LdnIpv4Address *addr, LdnSubnetMask *mask); + +/** + * @brief GetDisconnectReason + * @param[out] out \ref LdnDisconnectReason + */ +Result GetDisconnectReason(LdnDisconnectReason *out); + +/** + * @brief GetSecurityParameter + * @param[out] out \ref LdnSecurityParameter + */ +Result GetSecurityParameter(LdnSecurityParameter *out); + +/** + * @brief GetNetworkConfig + * @param[out] out \ref LdnNetworkConfig + */ +Result GetNetworkConfig(LdnNetworkConfig *out); + +/** + * @brief GetStateChangeEvent + * @note The Event must be closed by the user once finished with it. + * @note This is signaled when the data returned by \ref ldnGetNetworkInfo / \ref ldnGetNetworkInfoLatestUpdate is updated. + * @param[out] out_event Output Event with autoclear=true. + */ +Result GetStateChangeEvent(Event* out_event); + +/** + * @brief GetNetworkInfoAndHistory + * @param[out] network_info \ref LdnNetworkInfo + * @param[out] nodes Output array of \ref LdnNodeLatestUpdate. + * @param[in] count Size of the nodes array in entries, must be 8. + */ +Result GetNetworkInfoAndHistory(LdnNetworkInfo *network_info, LdnNodeLatestUpdate *nodes, s32 count); + +/** + * @brief Scan + * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_Station, or ::LdnState_StationConnected. + * @note This is the same as \ref ldnScanPrivate (minus the masking for LdnScanFilter::flags), except this has the same channel-override functionality as \ref ldnCreateNetwork. + * @param[in] channel Channel, value 0 can be used for this. + * @param[in] filter \ref LdnScanFilter + * @param[out] network_info Output array of \ref LdnNetworkInfo. + * @param[in] count Size of the network_info array in entries. Must be at least 1, this is clamped to a maximum of 0x18 internally. + * @param[out] total_out Total output entries. + */ +Result Scan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out); + +/** + * @brief ScanPrivate + * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_Station, or ::LdnState_StationConnected. + * @note See \ref ldnScan. + * @param[in] channel Channel, value 0 can be used for this. + * @param[in] filter \ref LdnScanFilter + * @param[out] network_info Output array of \ref LdnNetworkInfo. + * @param[in] count Size of the network_info array in entries. Must be at least 1, this is clamped to a maximum of 0x18 internally. + * @param[out] total_out Total output entries. + */ +Result ScanPrivate(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out); + +/** + * @brief SetWirelessControllerRestriction + * @note Only available on [5.0.0+]. + * @note \ref LdnState must be ::LdnState_Initialized. + * @param[in] restriction \ref LdnWirelessControllerRestriction + */ +Result SetWirelessControllerRestriction(LdnWirelessControllerRestriction restriction); + +/** + * @brief SetProtocol + * @note This is only usable with [20.0.0+] (with [18.0.0-19-0.1] this is available but not usable). + * @note \ref LdnState must be ::LdnState_Initialized. If a non-default Protocol is wanted, use this after \ref ldnInitialize. + * @note This is used by \ref ldnInitialize with LdnProtocol_NX on [20.0.0+]. + * @param[in] protocol \ref LdnProtocol + */ +Result SetProtocol(LdnProtocol protocol); + +/** + * @brief OpenAccessPoint + * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_AccessPoint. + */ +Result OpenAccessPoint(void); + +/** + * @brief CloseAccessPoint + * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_Initialized. + * @note Used automatically internally by \ref ldnExit if needed. + */ +Result CloseAccessPoint(void); + +/** + * @brief CreateNetwork + * @note \ref LdnState must be ::LdnState_AccessPoint, this eventually sets the State to ::LdnState_AccessPointCreated. + * @param[in] sec_config \ref LdnSecurityConfig + * @param[in] user_config \ref LdnUserConfig + * @param[in] network_config \ref LdnNetworkConfig + */ +Result CreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config); + +/** + * @brief CreateNetworkPrivate + * @note \ref LdnState must be ::LdnState_AccessPoint, this eventually sets the State to ::LdnState_AccessPointCreated. + * @note This is the same as \ref ldnCreateNetwork besides the additional user-specified params, and with this cmd LdnNetworkConfig::channel is not overwritten (unlike \ref ldnCreateNetwork). + * @param[in] sec_config \ref LdnSecurityConfig + * @param[in] sec_param \ref LdnSecurityParameter + * @param[in] user_config \ref LdnUserConfig + * @param[in] network_config \ref LdnNetworkConfig + * @param[in] addrs Input array of \ref LdnAddressEntry. This can be NULL. + * @param[in] count Size of the addrs array in entries. This must be <=8. This can be 0, in which case the network will be non-Private like \ref ldnCreateNetwork. + */ +Result CreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count); + +/** + * @brief DestroyNetwork + * @note \ref LdnState must be ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_AccessPoint. + */ +Result DestroyNetwork(void); + +/** + * @brief Reject + * @note \ref LdnState must be ::LdnState_AccessPointCreated. + * @param[in] addr \ref LdnIpv4Address + */ +Result Reject(LdnIpv4Address addr); + +/** + * @brief SetAdvertiseData + * @note An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero. + * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated. + * @param[in] buffer Input buffer containing arbitrary user data. + * @param[in] size Input buffer size, must be <=0x180. + */ +Result SetAdvertiseData(const void* buffer, size_t size); + +/** + * @brief SetStationAcceptPolicy + * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated. + * @param[in] policy \ref LdnAcceptPolicy + */ +Result SetStationAcceptPolicy(LdnAcceptPolicy policy); + +/** + * @brief AddAcceptFilterEntry + * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated. + * @note See \ref LdnAcceptPolicy. + * @param[in] addr \ref LdnMacAddress. If you want, you can also pass LdnNodeInfo::mac_addr for this. + */ +Result AddAcceptFilterEntry(LdnMacAddress addr); + +/** + * @brief ClearAcceptFilter + * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated. + */ +Result ClearAcceptFilter(void); + +/** + * @brief OpenStation + * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_Station. + */ +Result OpenStation(void); + +/** + * @brief CloseStation + * @note \ref LdnState must be ::LdnState_Station or ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Initialized. + * @note Used automatically internally by \ref ldnExit if needed. + */ +Result CloseStation(void); + +/** + * @brief Connect + * @note \ref LdnState must be ::LdnState_Station, this eventually sets the State to ::LdnState_StationConnected. + * @note This is identical to \ref ldnConnectPrivate besides the used params, the code overwriting LdnSecurityConfig::type also differs. + * @param[in] sec_config \ref LdnSecurityConfig + * @param[in] user_config \ref LdnUserConfig + * @param[in] version LocalCommunicationVersion, this must be 0x0-0x7FFF. + * @param[in] option ConnectOption bitmask, must be <=0x1. You can use value 0 for example here. + * @param[in] network_info \ref LdnNetworkInfo + */ +Result Connect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info); + +/** + * @brief ConnectPrivate + * @note \ref LdnState must be ::LdnState_Station, this eventually sets the State to ::LdnState_StationConnected. + * @note See \ref ldnConnect. + * @param[in] sec_config \ref LdnSecurityConfig + * @param[in] sec_param \ref LdnSecurityParameter + * @param[in] user_config \ref LdnUserConfig + * @param[in] version LocalCommunicationVersion, this must be 0x0-0x7FFF. + * @param[in] option ConnectOption bitmask, must be <=0x1. You can use value 0 for example here. + * @param[in] network_config \ref LdnNetworkConfig + */ +Result ConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config); + +/** + * @brief Disconnect + * @note \ref LdnState must be ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Station. + */ +Result Disconnect(void); + +/** + * @brief SetOperationMode + * @note With ::LdnServiceType_System this is only available on [4.0.0+]. + * @note With ::LdnServiceType_User this is only available on [19.0.0+]. + * @note \ref LdnState must be ::LdnState_Initialized. + * @param[in] mode \ref LdnOperationMode + */ +Result SetOperationMode(LdnOperationMode mode); + +/** + * @brief EnableActionFrame + * @note Only available on [18.0.0+]. + * @note \ref LdnState must be ::LdnState_Initialized. + * @param[in] settings \ref LdnActionFrameSettings + */ +Result EnableActionFrame(const LdnActionFrameSettings *settings); + +/** + * @brief DisableActionFrame + * @note Only available on [18.0.0+]. + * @note \ref LdnState must be ::LdnState_Initialized. + */ +Result DisableActionFrame(void); + +/** + * @brief SendActionFrame + * @note Only available on [18.0.0+]. + * @note \ref LdnState must be ::LdnState_AccessPointCreated / ::LdnState_Station. + * @param[in] data Data buffer. + * @param[in] size Data buffer size. + * @param[in] destination Destination \ref LdnMacAddress. + * @param[in] bssid Bssid \ref LdnMacAddress. + * @param[in] channel Channel, must be non-zero. + * @param[in] flags MessageFlag bit0 clear = block until the data can be sent, set = return error when the data can't be sent. + */ +Result SendActionFrame(const void* data, size_t size, LdnMacAddress destination, LdnMacAddress bssid, s16 channel, u32 flags); + +/** + * @brief RecvActionFrame + * @note Only available on [18.0.0+]. + * @note \ref ldnEnableActionFrame must be used prior to this. + * @param[out] data Output data buffer. + * @param[in] size Max size of the data buffer. + * @param[out] addr0 First \ref LdnMacAddress. + * @param[out] addr1 Second \ref LdnMacAddress. + * @param[out] channel Channel + * @param[out] out_size Output size. + * @param[out] link_level LinkLevel + * @param[in] flags MessageFlag bit0 clear = block until data is available, set = return error when data is not available. + */ +Result RecvActionFrame(void* data, size_t size, LdnMacAddress *addr0, LdnMacAddress *addr1, s16 *channel, u32 *out_size, s32 *link_level, u32 flags); + +/** + * @brief SetHomeChannel + * @note Only available on [18.0.0+]. + * @note \ref LdnState must be ::LdnState_Station. + * @param[in] channel Channel, must be non-zero. + */ +Result SetHomeChannel(s16 channel); + +/** + * @brief SetTxPower + * @note Only available on [18.0.0+]. + * @note \ref LdnState must be ::LdnState_AccessPoint* / ::LdnState_Station*. + * @param[in] power Power, must be 0x0..0xFF. + */ +Result SetTxPower(s16 power); + +/** + * @brief ResetTxPower + * @note Only available on [18.0.0+]. + * @note \ref LdnState must be ::LdnState_AccessPoint* / ::LdnState_Station*. + */ +Result ResetTxPower(void); + +} // namespace ldn + +/// @brief C++ wrappers for the `ldnm` API. +/// @details Wraps: switch/services/ldn.h. +namespace ldnm { + +/// AcceptPolicy +using ::LdnAcceptPolicy; +/// ActionFrameSettings +using ::LdnActionFrameSettings; +/// AddressEntry +using ::LdnAddressEntry; +/// CommonNetworkInfo +using ::LdnCommonNetworkInfo; +/// DisconnectReason loaded by \ref ldnGetDisconnectReason. +using ::LdnDisconnectReason; +/// IntentId +using ::LdnIntentId; +/// Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). +using ::LdnIpv4Address; +/// MacAddress +using ::LdnMacAddress; +/// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate). +using ::LdnNetworkConfig; +/// NetworkId +using ::LdnNetworkId; +/// NetworkInfo +using ::LdnNetworkInfo; +/// NodeInfo +using ::LdnNodeInfo; +/// NodeLatestUpdate +using ::LdnNodeLatestUpdate; +/// OperationMode +using ::LdnOperationMode; +/// Protocol +using ::LdnProtocol; +/// ScanFilter. \ref ldnScan / \ref ldnScanPrivate will only return the \ref LdnNetworkInfo when validating the \ref LdnNetworkInfo with LdnScanFilter was sucessful, with the fields enabled by \ref LdnScanFilterFlag. +using ::LdnScanFilter; +/// ScanFilterFlag +using ::LdnScanFilterFlag; +/// SecurityConfig +using ::LdnSecurityConfig; +/// SecurityMode. LdnSecurityMode_Product can be used as the default value. The ldn cmds which use an input SecurityMode normally overwrite the SecurityMode. +using ::LdnSecurityMode; +/// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated. +using ::LdnSecurityParameter; +using ::LdnServiceType; +/// SessionId +using ::LdnSessionId; +/// Ssid +using ::LdnSsid; +/// State loaded by \ref ldnmGetStateForMonitor / \ref ldnGetState. +using ::LdnState; +/// SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). +using ::LdnSubnetMask; +/// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd. +using ::LdnUserConfig; +/// WirelessControllerRestriction +using ::LdnWirelessControllerRestriction; + +/// Initialize ldn:m. +Result Initialize(void); + +/// Exit ldn:m. +void Exit(void); + +/// Gets the Service object for IMonitorService. +Service* GetServiceSession_MonitorService(void); + +/** + * @brief GetState + * @param[out] out \ref LdnState + */ +Result GetState(LdnState *out); + +/** + * @brief GetNetworkInfo + * @param[out] out \ref LdnNetworkInfo + */ +Result GetNetworkInfo(LdnNetworkInfo *out); + +/** + * @brief GetIpv4Address + * @param[out] addr \ref LdnIpv4Address + * @param[out] mask \ref LdnSubnetMask + */ +Result GetIpv4Address(LdnIpv4Address *addr, LdnSubnetMask *mask); + +/** + * @brief GetSecurityParameter + * @note Not exposed by official sw. + * @param[out] out \ref LdnSecurityParameter + */ +Result GetSecurityParameter(LdnSecurityParameter *out); + +/** + * @brief GetNetworkConfig + * @note Not exposed by official sw. + * @param[out] out \ref LdnNetworkConfig + */ +Result GetNetworkConfig(LdnNetworkConfig *out); + +} // namespace ldnm + +/// @brief C++ wrappers for the `ldr` API. +/// @details Wraps: switch/services/ldr.h, switch/services/ro.h. +namespace ldr { + +using ::LoaderModuleInfo; +using ::LoaderProgramAttributes; +using ::LoaderProgramInfo; +using ::LoaderProgramInfoV1; + +/// Initialize ldr:shel. +Result ShellInitialize(void); + +/// Exit ldr:shel. +void ShellExit(void); + +/// Gets the Service object for the actual ldr:shel service session. +Service* ShellGetServiceSession(void); + +/// Initialize ldr:dmnt. +Result DmntInitialize(void); + +/// Exit ldr:dmnt. +void DmntExit(void); + +/// Gets the Service object for the actual ldr:dmnt service session. +Service* DmntGetServiceSession(void); + +/// Initialize ldr:pm. +Result PmInitialize(void); + +/// Exit ldr:pm. +void PmExit(void); + +/// Gets the Service object for the actual ldr:pm service session. +Service* PmGetServiceSession(void); + +Result ShellSetProgramArguments(u64 program_id, const void *args, size_t args_size); + +Result ShellFlushArguments(void); + +Result DmntSetProgramArguments(u64 program_id, const void *args, size_t args_size); + +Result DmntFlushArguments(void); + +Result DmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, s32 *num_out); + +Result PmCreateProcess(u64 pin_id, u32 flags, Handle reslimit_h, const LoaderProgramAttributes *attrs, Handle *out_process_h); + +Result PmGetProgramInfo(const NcmProgramLocation *loc, const LoaderProgramAttributes *attrs, LoaderProgramInfo *out_program_info); + +///< [19.0.0+/Atmosphere] +Result PmGetProgramInfoV1(const NcmProgramLocation *loc, LoaderProgramInfoV1 *out_program_info); + +///< [1.0.0-18.1.0/Non-Atmosphere] +Result PmPinProgram(const NcmProgramLocation *loc, u64 *out_pin_id); + +Result PmUnpinProgram(u64 pin_id); + +Result PmSetEnabledProgramVerification(bool enabled); + +/// Initialize ldr:ro. +Result RoInitialize(void); + +/// Exit ldr:ro. +void RoExit(void); + +/// Gets the Service object for the actual ldr:ro service session. +Service* RoGetServiceSession(void); + +Result RoLoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); + +Result RoUnloadNro(u64 nro_address); + +Result RoLoadNrr(u64 nrr_address, u64 nrr_size); + +Result RoUnloadNrr(u64 nrr_address); + +Result RoLoadNrrEx(u64 nrr_address, u64 nrr_size); + +} // namespace ldr + +/// @brief C++ wrappers for the `levent` API. +/// @details Wraps: switch/kernel/levent.h. +namespace levent { + +/// User-mode light event structure. +using ::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. + */ +void Init(LEvent* le, bool signaled, bool 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 Wait(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 TryWait(LEvent* le); + +/** + * @brief Signals a user-mode light event. + * @param[in] le Pointer to \ref LEvent structure. + */ +void Signal(LEvent* le); + +/** + * @brief Clears a user-mode light event. + * @param[in] le Pointer to \ref LEvent structure. + */ +void Clear(LEvent* le); + +} // namespace levent + +/// @brief C++ wrappers for the `libapplet` API. +/// @details Wraps: switch/applets/libapplet.h. +namespace libapplet { + +/// CommonArguments +using ::LibAppletArgs; + +/** + * @brief Creates a LibAppletArgs struct. + * @param a LibAppletArgs struct. + * @param version LaVersion for \ref LibAppletArgs. + */ +void ArgsCreate(LibAppletArgs* a, u32 version); + +/** + * @brief Sets the PlayStartupSound field in \ref LibAppletArgs. + * @param a LibAppletArgs struct. + * @param flag Value for \ref LibAppletArgs PlayStartupSound. + */ +void ArgsSetPlayStartupSound(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 CreateWriteStorage(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 ReadStorage(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. + * @param h AppletHolder object. + */ +Result ArgsPush(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 ArgsPop(LibAppletArgs* a); + +/** + * @brief Creates a storage using the input buffer which is pushed to the AppletHolder via \ref appletHolderPushInData. + * @param h AppletHolder object. + * @param buffer Input data buffer. + * @param size Input data size. + */ +Result PushInData(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 PopOutData(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 SetJumpFlag(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 Start(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 Launch(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 RequestHomeMenu(void); + +/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this. +/// Equivalent to entering "System Update" under System Settings. When leaving this, it returns to the main Home Menu. +Result RequestJumpToSystemUpdate(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 RequestToLaunchApplication(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 RequestJumpToStory(AccountUid uid, u64 application_id); + +} // namespace libapplet + +/// @brief C++ wrappers for the `lp2p` API. +/// @details Wraps: switch/services/lp2p.h. +namespace lp2p { + +/// GroupId +using ::Lp2pGroupId; +/// GroupInfo +/// \ref lp2pScan only uses the following fields for the cmd input struct: supported_platform/priority, frequency/channel, and preshared_key_binary_size/preshared_key. +using ::Lp2pGroupInfo; +/// IpConfig. Only contains IPv4 addresses. +using ::Lp2pIpConfig; +/// MacAddress +using ::Lp2pMacAddress; +/// NodeInfo +using ::Lp2pNodeInfo; +/// ScanResult +using ::Lp2pScanResult; +using ::Lp2pServiceType; + +/// Initialize lp2p. +Result Initialize(Lp2pServiceType service_type); + +/// Exit lp2p. +void Exit(void); + +/// Gets the Service object for INetworkService. +Service* GetServiceSession_INetworkService(void); + +/// Gets the Service object for INetworkServiceMonitor. +Service* GetServiceSession_INetworkServiceMonitor(void); + +/** + * @brief Creates a default \ref Lp2pGroupInfo for use with \ref lp2pCreateGroup / \ref lp2pJoin. + * @param info \ref Lp2pGroupInfo + */ +void CreateGroupInfo(Lp2pGroupInfo *info); + +/** + * @brief Creates a default \ref Lp2pGroupInfo for use with \ref lp2pScan. + * @param info \ref Lp2pGroupInfo + */ +void CreateGroupInfoScan(Lp2pGroupInfo *info); + +/** + * @brief Sets Lp2pGroupInfo::service_name. + * @param info \ref Lp2pGroupInfo + * @param[in] name ServiceName / SSID. + */ +void GroupInfoSetServiceName(Lp2pGroupInfo *info, const char *name); + +/** + * @brief Sets Lp2pGroupInfo::flags_count and Lp2pGroupInfo::flags. + * @note The default is count=1 flags[0]=1, which is used by \ref lp2pCreateGroupInfo. [11.0.0+] To use standard WPA2-PSK, you can use flags[0]=0. + * @param info \ref Lp2pGroupInfo + * @param[in] flags Lp2pGroupInfo::flags + * @param[in] count Lp2pGroupInfo::flags_count + */ +void GroupInfoSetFlags(Lp2pGroupInfo *info, s8 *flags, size_t count); + +/** + * @brief Sets Lp2pGroupInfo::member_count_max. + * @param info \ref Lp2pGroupInfo + * @param[in] count MemberCountMax + */ +void GroupInfoSetMemberCountMax(Lp2pGroupInfo *info, size_t count); + +/** + * @brief Sets Lp2pGroupInfo::frequency and Lp2pGroupInfo::channel. + * @param info \ref Lp2pGroupInfo + * @param[in] frequency Lp2pGroupInfo::frequency + * @param[in] channel Lp2pGroupInfo::channel + */ +void GroupInfoSetFrequencyChannel(Lp2pGroupInfo *info, u16 frequency, s16 channel); + +/** + * @brief Sets Lp2pGroupInfo::stealth_enabled. + * @param info \ref Lp2pGroupInfo + * @param[in] flag Lp2pGroupInfo::stealth_enabled + */ +void GroupInfoSetStealthEnabled(Lp2pGroupInfo *info, bool flag); + +/** + * @brief Sets the PresharedKey for the specified \ref Lp2pGroupInfo. + * @note Using this is required before using the \ref Lp2pGroupInfo as input for any cmds, so that Lp2pGroupInfo::preshared_key_binary_size gets initialized. + * @note If standard WPA2-PSK is being used, use \ref lp2pGroupInfoSetPassphrase instead. + * @param info \ref Lp2pGroupInfo + * @param[in] key Data for the PresharedKey. + * @param[in] size Size to copy into the PresharedKey, max is 0x20. + */ +void GroupInfoSetPresharedKey(Lp2pGroupInfo *info, const void* key, size_t size); + +/** + * @brief Sets the passphrase, for when standard WPA2-PSK is being used. + * @note Configure standard WPA2-PSK usage via \ref lp2pGroupInfoSetFlags / Lp2pGroupInfo::security_type. + * @note Only available on [11.0.0+]. + * @param info \ref Lp2pGroupInfo + * @param[in] passphrase Passphrase string, the required length is 0x8-0x3F. + */ +Result GroupInfoSetPassphrase(Lp2pGroupInfo *info, const char *passphrase); + +/** + * @brief Scan + * @param[in] info \ref Lp2pGroupInfo + * @param[out] results Output array of \ref Lp2pScanResult. + * @param[in] count Size of the results array in entries. + * @param[out] total_out Total output entries. + */ +Result Scan(const Lp2pGroupInfo *info, Lp2pScanResult *results, s32 count, s32 *total_out); + +/** + * @brief CreateGroup + * @note The role (\ref lp2pGetRole) must be 0. This eventually sets the role to value 1. + * @param[in] info \ref Lp2pGroupInfo + */ +Result CreateGroup(const Lp2pGroupInfo *info); + +/** + * @brief This destroys the previously created group from \ref lp2pCreateGroup. + * @note If no group was previously created (role from \ref lp2pGetRole is not 1), this just returns 0. + */ +Result DestroyGroup(void); + +/** + * @brief SetAdvertiseData + * @note The role (\ref lp2pGetRole) must be <=1. + * @note An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero. + * @param[out] buffer Input buffer containing arbitrary user data. + * @param[in] size Input buffer size, must be <=0x80. + */ +Result SetAdvertiseData(const void* buffer, size_t size); + +/** + * @brief This sends an Action frame to the specified \ref Lp2pGroupId, with the specified destination \ref Lp2pMacAddress. + * @note The role (\ref lp2pGetRole) must be non-zero. + * @note The error from \ref lp2pGetNetworkInterfaceLastError will be returned if it's set. + * @note [11.0.0+] Lp2pGroupInfo::security_type must be value 2 (default encryption), otherwise an error is returned. + * @param[in] buffer Input buffer containing arbitrary user data. + * @param[in] size Input buffer size, must be <=0x400. + * @param[in] addr \ref Lp2pMacAddress, this can be a broadcast address. This must be non-zero. + * @param[in] group_id \ref Lp2pGroupId + * @param[in] frequency Must be >=1. See Lp2pGroupInfo::frequency. + * @param[in] channel Must be >=1. See Lp2pGroupInfo::channel. + * @param[in] flags Only bit0 is used: clear = block until the data can be sent, set = return error when the data can't be sent. + */ +Result SendToOtherGroup(const void* buffer, size_t size, Lp2pMacAddress addr, Lp2pGroupId group_id, s16 frequency, s16 channel, u32 flags); + +/** + * @brief This receives an Action frame. + * @note The role (\ref lp2pGetRole) must be non-zero. + * @note When data is not available, the error from \ref lp2pGetNetworkInterfaceLastError will be returned if it's set. + * @param[out] buffer Output buffer containing arbitrary user data. + * @param[in] size Output buffer size. + * @param[in] flags Only bit0 is used: clear = block until data is available, set = return error when data is not available. + * @param[in] addr \ref Lp2pMacAddress + * @param[in] unk0 Unknown + * @param[in] unk1 Unknown + * @param[out] out_size This is the original size used for copying to the output buffer, before it's clamped to the output-buffer size. + * @param[out] unk2 Unknown + */ +Result RecvFromOtherGroup(void* buffer, size_t size, u32 flags, Lp2pMacAddress *addr, u16 *unk0, s32 *unk1, u64 *out_size, s32 *unk2); + +/** + * @brief AddAcceptableGroupId + * @param[in] group_id \ref Lp2pGroupId + */ +Result AddAcceptableGroupId(Lp2pGroupId group_id); + +/** + * @brief RemoveAcceptableGroupId + */ +Result RemoveAcceptableGroupId(void); + +/** + * @brief AttachNetworkInterfaceStateChangeEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result AttachNetworkInterfaceStateChangeEvent(Event* out_event); + +/** + * @brief GetNetworkInterfaceLastError + */ +Result GetNetworkInterfaceLastError(void); + +/** + * @brief GetRole + * @param[out] out Output Role. + */ +Result GetRole(u8 *out); + +/** + * @brief GetAdvertiseData + * @note The role from \ref lp2pGetRole must be value 2. + * @param[out] buffer Output buffer data. + * @param[in] size Output buffer size. + * @param[out] transfer_size Size of the data copied into the buffer. + * @param[out] original_size Original size from state. + */ +Result GetAdvertiseData(void* buffer, size_t size, u16 *transfer_size, u16 *original_size); + +/** + * @brief GetAdvertiseData2 + * @note This is identical to \ref lp2pGetAdvertiseData except this doesn't run the role validation. + * @param[out] buffer Output buffer data. + * @param[in] size Output buffer size. + * @param[out] transfer_size Size of the data copied into the buffer. + * @param[out] original_size Original size from state. + */ +Result GetAdvertiseData2(void* buffer, size_t size, u16 *transfer_size, u16 *original_size); + +/** + * @brief GetGroupInfo + * @note The role from \ref lp2pGetRole must be non-zero. + * @param[out] out \ref Lp2pGroupInfo + */ +Result GetGroupInfo(Lp2pGroupInfo *out); + +/** + * @brief This runs the same code as \ref lp2pCreateGroup to generate the \ref Lp2pGroupInfo for the input struct. + * @param[out] out \ref Lp2pGroupInfo + * @param[in] info \ref Lp2pGroupInfo + */ +Result Join(Lp2pGroupInfo *out, const Lp2pGroupInfo *info); + +/** + * @brief GetGroupOwner + * @note The role from \ref lp2pGetRole must be non-zero. + * @param[out] out \ref Lp2pNodeInfo + */ +Result GetGroupOwner(Lp2pNodeInfo *out); + +/** + * @brief GetIpConfig + * @note The role from \ref lp2pGetRole must be non-zero. + * @param[out] out \ref Lp2pIpConfig + */ +Result GetIpConfig(Lp2pIpConfig *out); + +/** + * @brief Leave + * @param[out] out Output value. + */ +Result Leave(u32 *out); + +/** + * @brief AttachJoinEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result AttachJoinEvent(Event* out_event); + +/** + * @brief GetMembers + * @note The role from \ref lp2pGetRole must be value 1. + * @param[out] members Output array of \ref Lp2pNodeInfo. + * @param[in] count Size of the members array in entries. A maximum of 8 entries can be returned. + * @param[out] total_out Total output entries. + */ +Result GetMembers(Lp2pNodeInfo *members, s32 count, s32 *total_out); + +} // namespace lp2p + +/// @brief C++ wrappers for the `lr` API. +/// @details Wraps: switch/services/lr.h. +namespace lr { + +using ::LrLocationResolver; +using ::LrRegisteredLocationResolver; + +/// Initialize lr. +Result Initialize(void); + +/// Exit lr. +void Exit(void); + +/// Gets the Service object for the actual lr service session. +Service* GetServiceSession(void); + +Result OpenLocationResolver(NcmStorageId storage, LrLocationResolver* out); + +Result OpenRegisteredLocationResolver(LrRegisteredLocationResolver* out); + +Result LrResolveProgramPath(LrLocationResolver* lr, u64 tid, char *out); + +Result LrRedirectProgramPath(LrLocationResolver* lr, u64 tid, const char *path); + +Result LrResolveApplicationControlPath(LrLocationResolver* lr, u64 tid, char *out); + +Result LrResolveApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, char *out); + +Result LrResolveDataPath(LrLocationResolver* lr, u64 tid, char *out); + +Result LrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path); + +Result LrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path); + +Result LrResolveApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out); + +Result LrRedirectApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path); + +Result LrRefresh(LrLocationResolver* lr); + +/// Only available on [5.0.0+]. +Result LrEraseProgramRedirection(LrLocationResolver* lr, u64 tid); + +Result RegLrResolveProgramPath(LrRegisteredLocationResolver* reg, u64 tid, char *out); + +} // namespace lr + +/// @brief C++ wrappers for the `mii` API. +/// @details Wraps: switch/applets/mii_la.h, switch/services/mii.h. +namespace mii { + +/// Mii age. +using ::MiiAge; +using ::MiiCharInfo; +using ::MiiCreateId; +using ::MiiDatabase; +/// Mii face color. +using ::MiiFaceColor; +/// Mii gender. +using ::MiiGender; +/// AppletInput +using ::MiiLaAppletInput; +/// AppletMode +using ::MiiLaAppletMode; +/// AppletOutput +using ::MiiLaAppletOutput; +/// AppletOutputForCharInfoEditing +using ::MiiLaAppletOutputForCharInfoEditing; +using ::MiiNfpStoreDataExtension; +using ::MiiServiceType; +using ::MiiSourceFlag; +using ::MiiSpecialKeyCode; +using ::MiiStoreData; +using ::MiiVer3StoreData; + +/** + * @brief Launches the applet for ShowMiiEdit. + * @param[in] special_key_code \ref MiiSpecialKeyCode + */ +Result LaShowMiiEdit(MiiSpecialKeyCode special_key_code); + +/** + * @brief Launches the applet for AppendMii. + * @param[in] special_key_code \ref MiiSpecialKeyCode + * @param[out] index Output Index. + */ +Result LaAppendMii(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 LaAppendMiiImage(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 LaUpdateMiiImage(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 LaCreateMii(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 LaEditMii(MiiSpecialKeyCode special_key_code, const MiiCharInfo *in_char, MiiCharInfo *out_char); + +/// Initialize mii. +Result Initialize(MiiServiceType service_type); + +/// Exit mii. +void Exit(void); + +/// Gets the Service object for the actual mii service session. +Service* GetServiceSession(void); + +/** + * @brief Opens a mii database. + * @param[in] key_code Mii key code filter. + * @param[out] out Database. + */ +Result OpenDatabase(MiiDatabase *out, MiiSpecialKeyCode key_code); + +/** + * @brief Returns whether the mii database is updated. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out_updated Whether the mii database is updated. + */ +Result DatabaseIsUpdated(MiiDatabase *db, bool *out_updated, MiiSourceFlag flag); + +/** + * @brief Returns whether the mii database is full. + * @param[in] db Database. + * @param[out] out_full Whether the mii database is full. + */ +Result DatabaseIsFull(MiiDatabase *db, bool *out_full); + +/** + * @brief Returns number of miis in the database with the specified source flag. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out_count Out mii count. + */ +Result DatabaseGetCount(MiiDatabase *db, s32 *out_count, MiiSourceFlag flag); + +/** + * @brief Reads mii charinfo data from the specified source flag. + * @param[in] db Database. + * @param[in] flag Source flag. + * @param[out] out_infos Output mii charinfo array. + * @param[in] count Number of mii chainfos to read. + * @param[out] total_out Number of mii charinfos which were actually read. + */ +Result DatabaseGet1(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, s32 count, s32 *total_out); + +/** + * @brief Generates a random mii charinfo (doesn't register it in the console database). + * @param[in] db Database. + * @param[in] age Mii's age. + * @param[in] gender Mii's gender. + * @param[in] face_color Mii's face color. + * @param[out] out_info Out mii charinfo data. + */ +Result DatabaseBuildRandom(MiiDatabase *db, MiiAge age, MiiGender gender, MiiFaceColor face_color, MiiCharInfo *out_info); + +/// Closes a mii database. +void DatabaseClose(MiiDatabase *db); + +} // namespace mii + +/// @brief C++ wrappers for the `miiimg` API. +/// @details Wraps: switch/services/miiimg.h. +namespace miiimg { + +/// Image attribute. +using ::MiiimgImageAttribute; +/// Image ID. +using ::MiiimgImageId; + +/// Initialize miiimg. +Result Initialize(void); + +/// Exit miiimg. +void Exit(void); + +/// Gets the Service object for the actual miiimg service session. +Service* GetServiceSession(void); + +/** + * @brief Reloads the image database. + */ +Result Reload(void); + +/** + * @brief Gets the number of mii images in the database. + * @param[out] out_count Mii image count. + */ +Result GetCount(s32 *out_count); + +/** + * @brief Gets whether the image database is empty. + * @param[out] out_empty Whether the database is empty. + */ +Result IsEmpty(bool *out_empty); + +/** + * @brief Gets whether the image database is full. + * @param[out] out_empty Whether the database is full. + */ +Result IsFull(bool *out_full); + +/** + * @brief Gets the image attribute for the specified image index. + * @param[in] index Image index. + * @param[out] out_attr Out image attribute. + */ +Result GetAttribute(s32 index, MiiimgImageAttribute *out_attr); + +/** + * @brief Loads the image data (raw RGBA8) for the specified image ID. + * @note Server doesn't seem to check the image buffer size, but 0x40000 is the optimal size. + * @param[in] id Input image ID. + * @param[out] out_image Out iamge buffer. + * @param[in] out_image_size Out image buffer size. + */ +Result LoadImage(MiiimgImageId id, void* out_image, size_t out_image_size); + +} // namespace miiimg + +/// @brief C++ wrappers for the `mmu` API. +/// @details Wraps: switch/services/mm.h. +namespace mmu { + +using ::MmuModuleId; +using ::MmuRequest; + +Result Initialize(void); + +void Exit(void); + +Service* GetServiceSession(void); + +Result RequestInitialize(MmuRequest *request, MmuModuleId module, u32 unk, bool autoclear); + +///< unk is ignored by official software +Result RequestFinalize(const MmuRequest *request); + +Result RequestGet(const MmuRequest *request, u32 *out_freq_hz); + +Result RequestSetAndWait(const MmuRequest *request, u32 freq_hz, s32 timeout); + +} // namespace mmu + +/// @brief C++ wrappers for the `mutex` API. +/// @details Wraps: switch/kernel/mutex.h. +namespace mutex { + +/// Mutex datatype, defined in newlib. +using ::Mutex; +/// Recursive mutex datatype, defined in newlib. +using ::RMutex; + +/** + * @brief Initializes a mutex. + * @param m Mutex object. + * @note A mutex can also be statically initialized by assigning 0 to it. + */ +void Init(Mutex* m); + +/** + * @brief Locks a mutex. + * @param m Mutex object. + */ +void Lock(Mutex* m); + +/** + * @brief Attempts to lock a mutex without waiting. + * @param m Mutex object. + * @return 1 if the mutex has been acquired successfully, and 0 on contention. + */ +bool TryLock(Mutex* m); + +/** + * @brief Unlocks a mutex. + * @param m Mutex object. + */ +void Unlock(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 IsLockedByCurrentThread(const Mutex* m); + +} // namespace mutex + +/// @brief C++ wrappers for the `nacp` API. +/// @details Wraps: switch/nacp.h. +namespace nacp { + +/// ApplicationControlDataCondition +using ::NacpApplicationControlDataCondition; +/// ApplicationJitConfiguration +using ::NacpApplicationJitConfiguration; +/// ApplicationNeighborDetectionGroupConfiguration +using ::NacpApplicationNeighborDetectionGroupConfiguration; +/// Language entry. These strings are UTF-8. +using ::NacpLanguageEntry; +using ::NacpLanguageEntryData; +/// NeighborDetectionClientConfiguration +using ::NacpNeighborDetectionClientConfiguration; +/// ns ApplicationControlProperty +using ::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 GetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry); + +} // namespace nacp + +/// @brief C++ wrappers for the `ncm` API. +/// @details Wraps: switch/services/ncm.h, switch/services/ncm_types.h. +namespace ncm { + +/// AddOnContentMetaExtendedHeader [15.0.0+] +using ::NcmAddOnContentMetaExtendedHeader; +/// ApplicationContentMetaKey +using ::NcmApplicationContentMetaKey; +/// ApplicationMetaExtendedHeader +using ::NcmApplicationMetaExtendedHeader; +/// ContentId +using ::NcmContentId; +/// ContentInfo +using ::NcmContentInfo; +/// ContentInstallType +using ::NcmContentInstallType; +/// ContentMetaAttribute +using ::NcmContentMetaAttribute; +/// ContentMetaDatabase +using ::NcmContentMetaDatabase; +/// ContentMetaHeader +using ::NcmContentMetaHeader; +/// ContentMetaInfo +using ::NcmContentMetaInfo; +/// ContentMetaKey +using ::NcmContentMetaKey; +/// ContentMetaPlatform +using ::NcmContentMetaPlatform; +/// ContentMetaType +using ::NcmContentMetaType; +/// ContentStorage +using ::NcmContentStorage; +/// ContentType +using ::NcmContentType; +/// DataPatchMetaExtendedHeader +using ::NcmDataPatchMetaExtendedHeader; +/// LegacyAddOnContentMetaExtendedHeader [1.0.0-14.1.2] +using ::NcmLegacyAddOnContentMetaExtendedHeader; +/// PackagedContentInfo +using ::NcmPackagedContentInfo; +/// PatchMetaExtendedHeader +using ::NcmPatchMetaExtendedHeader; +/// PlaceHolderId +using ::NcmPlaceHolderId; +/// ProgramLocation +using ::NcmProgramLocation; +/// RightsId +using ::NcmRightsId; +/// StorageId +using ::NcmStorageId; +/// SystemUpdateMetaExtendedHeader +using ::NcmSystemUpdateMetaExtendedHeader; + +/// Initialize ncm. +Result Initialize(void); + +/// Exit ncm. +void Exit(void); + +/// Gets the Service object for the actual ncm service session. +Service* GetServiceSession(void); + +Result CreateContentStorage(NcmStorageId storage_id); + +Result CreateContentMetaDatabase(NcmStorageId storage_id); + +Result VerifyContentStorage(NcmStorageId storage_id); + +Result VerifyContentMetaDatabase(NcmStorageId storage_id); + +Result OpenContentStorage(NcmContentStorage* out_content_storage, NcmStorageId storage_id); + +Result OpenContentMetaDatabase(NcmContentMetaDatabase* out_content_meta_database, NcmStorageId storage_id); + +Result CloseContentStorageForcibly(NcmStorageId storage_id); + +///< [1.0.0] +Result CloseContentMetaDatabaseForcibly(NcmStorageId storage_id); + +///< [1.0.0] +Result CleanupContentMetaDatabase(NcmStorageId storage_id); + +Result ActivateContentStorage(NcmStorageId storage_id); + +///< [2.0.0+] +Result InactivateContentStorage(NcmStorageId storage_id); + +///< [2.0.0+] +Result ActivateContentMetaDatabase(NcmStorageId storage_id); + +///< [2.0.0+] +Result InactivateContentMetaDatabase(NcmStorageId storage_id); + +///< [2.0.0+] +Result InvalidateRightsIdCache(void); + +///< [9.0.0+] +Result ActivateFsContentStorage(FsContentStorageId fs_storage_id); + +///< [16.0.0+] +void ContentStorageClose(NcmContentStorage* cs); + +Result ContentStorageGeneratePlaceHolderId(NcmContentStorage* cs, NcmPlaceHolderId* out_id); + +Result ContentStorageCreatePlaceHolder(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id, s64 size); + +Result ContentStorageDeletePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id); + +Result ContentStorageHasPlaceHolder(NcmContentStorage* cs, bool* out, const NcmPlaceHolderId* placeholder_id); + +Result ContentStorageWritePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, u64 offset, const void* data, size_t data_size); + +Result ContentStorageRegister(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id); + +Result ContentStorageDelete(NcmContentStorage* cs, const NcmContentId* content_id); + +Result ContentStorageHas(NcmContentStorage* cs, bool* out, const NcmContentId* content_id); + +Result ContentStorageGetPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmContentId* content_id); + +Result ContentStorageGetPlaceHolderPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmPlaceHolderId* placeholder_id); + +Result ContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs); + +Result ContentStorageListPlaceHolder(NcmContentStorage* cs, NcmPlaceHolderId* out_ids, s32 count, s32* out_count); + +Result ContentStorageGetContentCount(NcmContentStorage* cs, s32* out_count); + +Result ContentStorageListContentId(NcmContentStorage* cs, NcmContentId* out_ids, s32 count, s32* out_count, s32 start_offset); + +Result ContentStorageGetSizeFromContentId(NcmContentStorage* cs, s64* out_size, const NcmContentId* content_id); + +Result ContentStorageDisableForcibly(NcmContentStorage* cs); + +Result ContentStorageRevertToPlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, const NcmContentId* old_content_id, const NcmContentId* new_content_id); + +///< [2.0.0+] +Result ContentStorageSetPlaceHolderSize(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, s64 size); + +///< [2.0.0+] +Result ContentStorageReadContentIdFile(NcmContentStorage* cs, void* out_data, size_t out_data_size, const NcmContentId* content_id, s64 offset); + +///< [2.0.0+] +Result ContentStorageGetRightsIdFromPlaceHolderId(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id, FsContentAttributes attr); + +///< [2.0.0+] +Result ContentStorageGetRightsIdFromContentId(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmContentId* content_id, FsContentAttributes attr); + +///< [2.0.0+] +Result ContentStorageWriteContentForDebug(NcmContentStorage* cs, const NcmContentId* content_id, s64 offset, const void* data, size_t data_size); + +///< [2.0.0+] +Result ContentStorageGetFreeSpaceSize(NcmContentStorage* cs, s64* out_size); + +///< [2.0.0+] +Result ContentStorageGetTotalSpaceSize(NcmContentStorage* cs, s64* out_size); + +///< [2.0.0+] +Result ContentStorageFlushPlaceHolder(NcmContentStorage* cs); + +///< [3.0.0+] +Result ContentStorageGetSizeFromPlaceHolderId(NcmContentStorage* cs, s64* out_size, const NcmPlaceHolderId* placeholder_id); + +///< [4.0.0+] +Result ContentStorageRepairInvalidFileAttribute(NcmContentStorage* cs); + +///< [4.0.0+] +Result ContentStorageGetRightsIdFromPlaceHolderIdWithCache(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id, const NcmContentId* cache_content_id, FsContentAttributes attr); + +///< [8.0.0+] +Result ContentStorageRegisterPath(NcmContentStorage* cs, const NcmContentId* content_id, const char *path); + +///< [13.0.0+] +Result ContentStorageClearRegisteredPath(NcmContentStorage* cs); + +///< [13.0.0+] +Result ContentStorageGetProgramId(NcmContentStorage* cs, u64* out, const NcmContentId* content_id, FsContentAttributes attr); + +///< [17.0.0+] +void ContentMetaDatabaseClose(NcmContentMetaDatabase* db); + +Result ContentMetaDatabaseSet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, const void* data, u64 data_size); + +Result ContentMetaDatabaseGet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u64* out_size, void* out_data, u64 out_data_size); + +Result ContentMetaDatabaseRemove(NcmContentMetaDatabase* db, const NcmContentMetaKey *key); + +Result ContentMetaDatabaseGetContentIdByType(NcmContentMetaDatabase* db, NcmContentId* out_content_id, const NcmContentMetaKey* key, NcmContentType type); + +Result ContentMetaDatabaseListContentInfo(NcmContentMetaDatabase* db, s32* out_entries_written, NcmContentInfo* out_info, s32 count, const NcmContentMetaKey* key, s32 start_index); + +Result ContentMetaDatabaseList(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type, u64 id, u64 id_min, u64 id_max, NcmContentInstallType install_type); + +Result ContentMetaDatabaseGetLatestContentMetaKey(NcmContentMetaDatabase* db, NcmContentMetaKey* out_key, u64 id); + +Result ContentMetaDatabaseListApplication(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmApplicationContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type); + +Result ContentMetaDatabaseHas(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key); + +Result ContentMetaDatabaseHasAll(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* keys, s32 count); + +Result ContentMetaDatabaseGetSize(NcmContentMetaDatabase* db, u64* out_size, const NcmContentMetaKey* key); + +Result ContentMetaDatabaseGetRequiredSystemVersion(NcmContentMetaDatabase* db, u32* out_version, const NcmContentMetaKey* key); + +Result ContentMetaDatabaseGetPatchContentMetaId(NcmContentMetaDatabase* db, u64* out_patch_id, const NcmContentMetaKey* key); + +Result ContentMetaDatabaseDisableForcibly(NcmContentMetaDatabase* db); + +Result ContentMetaDatabaseLookupOrphanContent(NcmContentMetaDatabase* db, bool* out_orphaned, const NcmContentId* content_ids, s32 count); + +Result ContentMetaDatabaseCommit(NcmContentMetaDatabase* db); + +Result ContentMetaDatabaseHasContent(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key, const NcmContentId* content_id); + +Result ContentMetaDatabaseListContentMetaInfo(NcmContentMetaDatabase* db, s32* out_entries_written, void* out_meta_info, s32 count, const NcmContentMetaKey* key, s32 start_index); + +Result ContentMetaDatabaseGetAttributes(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u8* out); + +Result ContentMetaDatabaseGetRequiredApplicationVersion(NcmContentMetaDatabase* db, u32* out_version, const NcmContentMetaKey* key); + +///< [2.0.0+] +Result ContentMetaDatabaseGetContentIdByTypeAndIdOffset(NcmContentMetaDatabase* db, NcmContentId* out_content_id, const NcmContentMetaKey* key, NcmContentType type, u8 id_offset); + +///< [5.0.0+] +Result ContentMetaDatabaseGetPlatform(NcmContentMetaDatabase* db, u8* out, const NcmContentMetaKey* key); + +/** + * @brief Retrieves the content size from a \ref NcmContentInfo struct. + * @param[in] info Pointer to \ref NcmContentInfo struct. + * @param[out] out Output size. + */ +void ContentInfoSizeToU64(const NcmContentInfo *info, u64 *out); + +/** + * @brief Updates the content size from a \ref NcmContentInfo struct. + * @param[in] size Input size. + * @param[out] out Pointer to \ref NcmContentInfo struct. + */ +void U64ToContentInfoSize(const u64 size, NcmContentInfo *info); + +} // namespace ncm + +/// @brief C++ wrappers for the `news` API. +/// @details Wraps: switch/services/news.h. +namespace news { + +using ::NewsDatabaseService; +using ::NewsDataService; +using ::NewsNewlyArrivedEventHolder; +using ::NewsOverwriteEventHolder; +using ::NewsRecord; +using ::NewsRecordV1; +using ::NewsServiceType; +using ::NewsTopicName; + +Result Initialize(NewsServiceType service_type); + +void Exit(void); + +Service * GetServiceSession(void); + +Result CreateNewlyArrivedEventHolder(NewsNewlyArrivedEventHolder *out); + +Result CreateNewsDataService(NewsDataService *out); + +Result CreateNewsDatabaseService(NewsDatabaseService *out); + +Result CreateOverwriteEventHolder(NewsOverwriteEventHolder *out); + +///< [2.0.0+] +Result PostLocalNews(const void *news, size_t size); + +Result SetPassphrase(u64 program_id, const char *passphrase); + +Result GetSubscriptionStatus(const char *filter, u32 *status); + +Result GetTopicList(u32 channel, u32 *out_count, NewsTopicName *out, u32 max_count); + +///< [3.0.0+] +Result GetSavedataUsage(u64 *current, u64 *total); + +///< [6.0.0+] +Result IsSystemUpdateRequired(bool *out); + +Result GetDatabaseVersion(u32 *version); + +///< [10.0.0+] +Result RequestImmediateReception(const char *filter); + +Result SetSubscriptionStatus(const char *filter, u32 status); + +Result ClearStorage(void); + +Result ClearSubscriptionStatusAll(void); + +Result GetNewsDatabaseDump(void *buffer, u64 size, u64 *out); + +void NewlyArrivedEventHolderClose(NewsNewlyArrivedEventHolder *srv); + +Result NewlyArrivedEventHolderGet(NewsNewlyArrivedEventHolder *srv, Event *out); + +void DataClose(NewsDataService *srv); + +Result DataOpen(NewsDataService *srv, const char *file_name); + +Result DataOpenWithNewsRecordV1(NewsDataService *srv, NewsRecordV1 *record); + +Result DataRead(NewsDataService *srv, u64 *bytes_read, u64 offset, void *out, size_t out_size); + +Result DataGetSize(NewsDataService *srv, u64 *size); + +Result DataOpenWithNewsRecord(NewsDataService *srv, NewsRecord *record); + +///< [6.0.0+] +void DatabaseClose(NewsDatabaseService *srv); + +Result DatabaseGetListV1(NewsDatabaseService *srv, NewsRecordV1 *out, u32 max_count, const char *where, const char *order, u32 *count, u32 offset); + +Result DatabaseCount(NewsDatabaseService *srv, const char *filter, u32 *count); + +Result DatabaseGetList(NewsDatabaseService *srv, NewsRecord *out, u32 max_count, const char *where, const char *order, u32 *count, u32 offset); + +///< [6.0.0+] +void OverwriteEventHolderClose(NewsOverwriteEventHolder *srv); + +Result OverwriteEventHolderGet(NewsOverwriteEventHolder *srv, Event *out); + +} // namespace news + +/// @brief C++ wrappers for the `nfc` API. +/// @details Wraps: switch/services/nfc.h. +namespace nfc { + +/// Nfc/Nfp DeviceHandle +using ::NfcDeviceHandle; +using ::NfcDeviceState; +using ::NfcMifareCommand; +using ::NfcMifareDeviceState; +using ::NfcMifareReadBlockData; +using ::NfcMifareReadBlockParameter; +using ::NfcMifareWriteBlockParameter; +using ::NfcProtocol; +using ::NfcRequiredMcuVersionData; +using ::NfcSectorKey; +/// NfcServiceType +using ::NfcServiceType; +using ::NfcState; +using ::NfcTagInfo; +using ::NfcTagType; +using ::NfcTagUid; +using ::NfpAdminInfo; +using ::NfpAmiiboFlag; +using ::NfpApplicationAreaVersion; +using ::NfpBreakType; +using ::NfpCommonInfo; +using ::NfpData; +using ::NfpDate; +using ::NfpDeviceState; +using ::NfpDeviceType; +using ::NfpModelInfo; +using ::NfpMountTarget; +using ::NfpRegisterInfo; +using ::NfpRegisterInfoPrivate; +/// NfpServiceType +using ::NfpServiceType; +using ::NfpTagInfo; + +/// Initialize nfc:*. +Result Initialize(NfcServiceType service_type); + +/// Exit nfc:*. +void Exit(void); + +/// Initialize nfc:mf:u. +Result MfInitialize(void); + +/// Exit nfc:mf:u. +void MfExit(void); + +/// Gets the Service object for the actual nfc:* service session. +Service* GetServiceSession(void); + +/// Gets the Service object for the interface from nfc:*. +Service* GetServiceSession_Interface(void); + +/// Gets the Service object for the actual nfc:mf:u service session. +Service* MfGetServiceSession(void); + +/// Gets the Service object for the interface from nfc:mf:u. +Service* MfGetServiceSession_Interface(void); + +/// Only available with [4.0.0+]. +Result ListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count); + +/// Only available with [4.0.0+]. +Result StartDetection(const NfcDeviceHandle *handle, NfcProtocol protocol); + +/// Only available with [4.0.0+]. +Result StopDetection(const NfcDeviceHandle *handle); + +Result MfListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count); + +Result MfStartDetection(const NfcDeviceHandle *handle); + +Result MfStopDetection(const NfcDeviceHandle *handle); + +/// Only available with [4.0.0+]. +Result GetTagInfo(const NfcDeviceHandle *handle, NfcTagInfo *out); + +Result MfGetTagInfo(const NfcDeviceHandle *handle, NfcTagInfo *out); + +/// Returned event will have autoclear off. +/// Only available with [4.0.0+]. +Result AttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event); + +/// Returned event will have autoclear off. +/// Only available with [4.0.0+]. +Result AttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event); + +/// Returned event will have autoclear off. +Result MfAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event); + +/// Returned event will have autoclear off. +Result MfAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event); + +/// Only available with [4.0.0+]. +Result GetState(NfcState *out); + +/// Only available with [4.0.0+]. +Result GetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out); + +/// Only available with [4.0.0+]. +Result GetNpadId(const NfcDeviceHandle *handle, u32 *out); + +Result MfGetState(NfcState *out); + +Result MfGetDeviceState(const NfcDeviceHandle *handle, NfcMifareDeviceState *out); + +Result MfGetNpadId(const NfcDeviceHandle *handle, u32 *out); + +/// Returned event will have autoclear on. +/// Only available with [4.0.0+]. +Result AttachAvailabilityChangeEvent(Event *out_event); + +/// Returned event will have autoclear on. +Result MfAttachAvailabilityChangeEvent(Event *out_event); + +/// This uses nfc:*. +Result IsNfcEnabled(bool *out); + +/// Only available with [4.0.0+]. +Result ReadMifare(const NfcDeviceHandle *handle, NfcMifareReadBlockData *out_block_data, const NfcMifareReadBlockParameter *read_block_parameter, s32 count); + +/// Only available with [4.0.0+]. +Result WriteMifare(const NfcDeviceHandle *handle, const NfcMifareWriteBlockParameter *write_block_parameter, s32 count); + +Result MfReadMifare(const NfcDeviceHandle *handle, NfcMifareReadBlockData *out_block_data, const NfcMifareReadBlockParameter *read_block_parameter, s32 count); + +Result MfWriteMifare(const NfcDeviceHandle *handle, const NfcMifareWriteBlockParameter *write_block_parameter, s32 count); + +/// Only available with [4.0.0+]. +Result SendCommandByPassThrough(const NfcDeviceHandle *handle, u64 timeout, const void* cmd_buf, size_t cmd_buf_size, void* reply_buf, size_t reply_buf_size, u64 *out_size); + +/// Only available with [4.0.0+]. +Result KeepPassThroughSession(const NfcDeviceHandle *handle); + +/// Only available with [4.0.0+]. +Result ReleasePassThroughSession(const NfcDeviceHandle *handle); + +} // namespace nfc + +/// @brief C++ wrappers for the `nfp` API. +/// @details Wraps: switch/applets/nfp_la.h, switch/services/nfc.h. +namespace nfp { + +/// Nfc/Nfp DeviceHandle +using ::NfcDeviceHandle; +using ::NfcDeviceState; +using ::NfcMifareCommand; +using ::NfcMifareDeviceState; +using ::NfcMifareReadBlockData; +using ::NfcMifareReadBlockParameter; +using ::NfcMifareWriteBlockParameter; +using ::NfcProtocol; +using ::NfcRequiredMcuVersionData; +using ::NfcSectorKey; +/// NfcServiceType +using ::NfcServiceType; +using ::NfcState; +using ::NfcTagInfo; +using ::NfcTagType; +using ::NfcTagUid; +using ::NfpAdminInfo; +using ::NfpAmiiboFlag; +using ::NfpApplicationAreaVersion; +using ::NfpBreakType; +using ::NfpCommonInfo; +using ::NfpData; +using ::NfpDate; +using ::NfpDeviceState; +using ::NfpDeviceType; +/// AmiiboSettingsStartParam +using ::NfpLaAmiiboSettingsStartParam; +/// ReturnValueForAmiiboSettings +using ::NfpLaReturnValueForAmiiboSettings; +/// StartParamForAmiiboSettings +using ::NfpLaStartParamForAmiiboSettings; +/// Values for NfpLaStartParamForAmiiboSettings::type. +using ::NfpLaStartParamTypeForAmiiboSettings; +using ::NfpModelInfo; +using ::NfpMountTarget; +using ::NfpRegisterInfo; +using ::NfpRegisterInfoPrivate; +/// NfpServiceType +using ::NfpServiceType; +using ::NfpTagInfo; + +/** + * @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 LaStartNicknameAndOwnerSettings(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 LaStartGameDataEraser(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 LaStartRestorer(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 LaStartFormatter(const NfpLaAmiiboSettingsStartParam *in_param, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle); + +/// Initialize nfp:*. +Result Initialize(NfpServiceType service_type); + +/// Exit nfp:*. +void Exit(void); + +/// Gets the Service object for the actual nfp:* service session. +Service* GetServiceSession(void); + +/// Gets the Service object for the interface from nfp:*. +Service* GetServiceSession_Interface(void); + +Result ListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count); + +Result StartDetection(const NfcDeviceHandle *handle); + +Result StopDetection(const NfcDeviceHandle *handle); + +Result Mount(const NfcDeviceHandle *handle, NfpDeviceType device_type, NfpMountTarget mount_target); + +Result Unmount(const NfcDeviceHandle *handle); + +/// Not available with ::NfpServiceType_System. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result OpenApplicationArea(const NfcDeviceHandle *handle, u32 app_id); + +/// Not available with ::NfpServiceType_System. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram, and the application area to be opened. +Result GetApplicationArea(const NfcDeviceHandle *handle, void* buf, size_t buf_size, u32 *out_size); + +/// Not available with ::NfpServiceType_System. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram, and the application area to be opened. +Result SetApplicationArea(const NfcDeviceHandle *handle, const void* buf, size_t buf_size); + +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result Flush(const NfcDeviceHandle *handle); + +Result Restore(const NfcDeviceHandle *handle); + +/// Not available with ::NfpServiceType_System. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result CreateApplicationArea(const NfcDeviceHandle *handle, u32 app_id, const void* buf, size_t buf_size); + +/// Not available with ::NfpServiceType_System. +/// Only available with [3.0.0+]. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram, and the application area to be opened. +Result RecreateApplicationArea(const NfcDeviceHandle *handle, u32 app_id, const void* buf, size_t buf_size); + +/// Not available with ::NfpServiceType_System. +Result GetApplicationAreaSize(const NfcDeviceHandle *handle, u32 *out_app_area_size); + +/// Not available with ::NfpServiceType_User. +Result DeleteApplicationArea(const NfcDeviceHandle *handle); + +/// Not available with ::NfpServiceType_User. +Result ExistsApplicationArea(const NfcDeviceHandle *handle, bool *out); + +Result GetTagInfo(const NfcDeviceHandle *handle, NfpTagInfo *out); + +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result GetRegisterInfo(const NfcDeviceHandle *handle, NfpRegisterInfo *out); + +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result GetCommonInfo(const NfcDeviceHandle *handle, NfpCommonInfo *out); + +/// Requires the amiibo to be mounted with ::NfpMountTarget_Rom. +Result GetModelInfo(const NfcDeviceHandle *handle, NfpModelInfo *out); + +/// Not available with ::NfpServiceType_User. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result GetAdminInfo(const NfcDeviceHandle *handle, NfpAdminInfo *out); + +/// Returned event will have autoclear off. +Result AttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event); + +/// Returned event will have autoclear off. +Result AttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event); + +Result GetState(NfcState *out); + +Result GetDeviceState(const NfcDeviceHandle *handle, NfpDeviceState *out); + +Result GetNpadId(const NfcDeviceHandle *handle, u32 *out); + +/// Returned event will have autoclear on. +/// Only available with [3.0.0+]. +Result AttachAvailabilityChangeEvent(Event *out_event); + +/// Not available with ::NfpServiceType_User. +Result Format(const NfcDeviceHandle *handle); + +/// Not available with ::NfpServiceType_User. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result GetRegisterInfoPrivate(const NfcDeviceHandle *handle, NfpRegisterInfoPrivate *out); + +/// Not available with ::NfpServiceType_User. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result SetRegisterInfoPrivate(const NfcDeviceHandle *handle, const NfpRegisterInfoPrivate *register_info_private); + +/// Not available with ::NfpServiceType_User. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result DeleteRegisterInfo(const NfcDeviceHandle *handle); + +/// Only available with ::NfpServiceType_Debug. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result GetAll(const NfcDeviceHandle *handle, NfpData *out); + +/// Only available with ::NfpServiceType_Debug. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result SetAll(const NfcDeviceHandle *handle, const NfpData *nfp_data); + +/// Only available with ::NfpServiceType_Debug. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result FlushDebug(const NfcDeviceHandle *handle); + +/// Only available with ::NfpServiceType_Debug. +/// Requires the amiibo to be mounted with ::NfpMountTarget_Ram. +Result BreakTag(const NfcDeviceHandle *handle, NfpBreakType break_type); + +/// Only available with ::NfpServiceType_Debug. +Result ReadBackupData(const NfcDeviceHandle *handle, void* out_buf, size_t buf_size, u32 *out_size); + +/// Only available with ::NfpServiceType_Debug. +Result WriteBackupData(const NfcDeviceHandle *handle, const void* buf, size_t buf_size); + +/// Only available with ::NfpServiceType_Debug. +Result WriteNtf(const NfcDeviceHandle *handle, u32 write_type, const void* buf, size_t buf_size); + +} // namespace nfp + +/// @brief C++ wrappers for the `nifm` API. +/// @details Wraps: switch/applets/nifm_la.h, switch/services/nifm.h. +namespace nifm { + +/// Authentication +using ::NifmAuthentication; +/// ClientId +using ::NifmClientId; +/// DnsSetting +using ::NifmDnsSetting; +/// Encryption +using ::NifmEncryption; +using ::NifmInternetConnectionStatus; +using ::NifmInternetConnectionType; +/// IpAddressSetting +using ::NifmIpAddressSetting; +/// IpSettingData +using ::NifmIpSettingData; +/// IpV4Address +using ::NifmIpV4Address; +/// NetworkProfileBasicInfo. Converted from/to \ref NifmSfNetworkProfileBasicInfo. +using ::NifmNetworkProfileBasicInfo; +/// NetworkProfileData. Converted from/to \ref NifmSfNetworkProfileData. +using ::NifmNetworkProfileData; +using ::NifmNetworkProfileType; +/// ProxySetting +using ::NifmProxySetting; +/// Request +using ::NifmRequest; +using ::NifmRequestState; +using ::NifmServiceType; +/// SfNetworkProfileBasicInfo. Converted from/to \ref NifmNetworkProfileBasicInfo. +using ::NifmSfNetworkProfileBasicInfo; +/// SfNetworkProfileData. Converted to/from \ref NifmNetworkProfileData. +using ::NifmSfNetworkProfileData; +/// SfWirelessSettingData +using ::NifmSfWirelessSettingData; +/// WirelessSettingData +using ::NifmWirelessSettingData; + +/** + * @brief Uses \ref nifmGetResult, then on failure launches the applet. + * @param r \ref NifmRequest + */ +Result LaHandleNetworkRequestResult(NifmRequest* r); + +/// Initialize nifm. This is used automatically by gethostid(). +Result Initialize(NifmServiceType service_type); + +/// Exit nifm. This is used automatically by gethostid(). +void Exit(void); + +/// Gets the Service object for the actual nifm:* service session. +Service* GetServiceSession_StaticService(void); + +/// Gets the Service object for IGeneralService. +Service* GetServiceSession_GeneralService(void); + +/** + * @brief GetClientId + */ +NifmClientId GetClientId(void); + +/** + * @brief CreateRequest + * @param[out] r \ref NifmRequest + * @param[in] autoclear Event autoclear to use for NifmRequest::event1, a default of true can be used for this. + */ +Result CreateRequest(NifmRequest* r, bool autoclear); + +/** + * @brief GetCurrentNetworkProfile + * @param[out] profile \ref NifmNetworkProfileData + */ +Result GetCurrentNetworkProfile(NifmNetworkProfileData *profile); + +/** + * @brief Returns saved network profiles + * @note NifmServiceType User and System have access only to NifmNetworkProfileType_User + * @param[in] type \ref NifmNetworkProfileType + * @param[out] buffer \ref NifmNetworkProfileBasicInfo + * @param[in] max_entries How many \ref NifmNetworkProfileBasicInfo can fit into buffer + * @param[out] total_entries How many \ref NifmNetworkProfileBasicInfo is available + */ +Result EnumerateNetworkProfiles(NifmNetworkProfileType type, NifmNetworkProfileBasicInfo* buffer, s32 max_entries, s32* total_entries); + +/** + * @brief GetNetworkProfile + * @param[in] uuid Uuid + * @param[out] profile \ref NifmNetworkProfileData + */ +Result GetNetworkProfile(Uuid uuid, NifmNetworkProfileData *profile); + +/** + * @brief SetNetworkProfile + * @note Only available with ::NifmServiceType_Admin. + * @param[in] profile \ref NifmNetworkProfileData + * @param[out] uuid Uuid + */ +Result SetNetworkProfile(const NifmNetworkProfileData *profile, Uuid *uuid); + +/** + * @brief GetCurrentIpAddress + * @param[out] out IPv4 address (struct in_addr). + */ +Result GetCurrentIpAddress(u32* out); + +/** + * @brief GetCurrentIpConfigInfo + * @param[out] current_addr Same as \ref nifmGetCurrentIpAddress output. + * @param[out] subnet_mask Subnet Mask (struct in_addr). + * @param[out] gateway Gateway (struct in_addr). + * @param[out] primary_dns_server Primary DNS server IPv4 address (struct in_addr). + * @param[out] secondary_dns_server Secondary DNS server IPv4 address (struct in_addr). + */ +Result GetCurrentIpConfigInfo(u32 *current_addr, u32 *subnet_mask, u32 *gateway, u32 *primary_dns_server, u32 *secondary_dns_server); + +/** + * @note Works only if called from nifm:a or nifm:s. + */ +Result SetWirelessCommunicationEnabled(bool enable); + +Result IsWirelessCommunicationEnabled(bool* out); + +/** + * @note Will fail with 0xd46ed if Internet is neither connecting or connected (airplane mode or no known network in reach). + * @param wifiStrength Strength of the Wi-Fi signal in number of bars from 0 to 3. + */ +Result GetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus); + +Result IsEthernetCommunicationEnabled(bool* out); + +/** + * @brief IsAnyInternetRequestAccepted + * @param[in] id \ref NifmClientId + */ +bool IsAnyInternetRequestAccepted(NifmClientId id); + +Result IsAnyForegroundRequestAccepted(bool* out); + +Result PutToSleep(void); + +Result WakeUp(void); + +/** + * @brief SetWowlDelayedWakeTime + * @note Only available with ::NifmServiceType_System or ::NifmServiceType_Admin. + * @note Only available on [9.0.0+]. + * @param[in] val Input value. + */ +Result SetWowlDelayedWakeTime(s32 val); + +/** + * @brief Close a \ref NifmRequest. + * @param r \ref NifmRequest + */ +void RequestClose(NifmRequest* r); + +/** + * @brief GetRequestState + * @param r \ref NifmRequest + * @param[out] out \ref NifmRequestState + */ +Result GetRequestState(NifmRequest* r, NifmRequestState *out); + +/** + * @brief GetResult + * @param r \ref NifmRequest + */ +Result GetResult(NifmRequest* r); + +/** + * @brief Cancel + * @param r \ref NifmRequest + */ +Result RequestCancel(NifmRequest* r); + +/** + * @brief Submit + * @param r \ref NifmRequest + */ +Result RequestSubmit(NifmRequest* r); + +/** + * @brief SubmitAndWait + * @param r \ref NifmRequest + */ +Result RequestSubmitAndWait(NifmRequest* r); + +/** + * @brief GetAppletInfo + * @note This is used by \ref nifmLaHandleNetworkRequestResult. + * @param r \ref NifmRequest + * @param[in] theme_color ThemeColor + * @param[out] buffer Output buffer for storage data. + * @param[in] size Output buffer size. + * @param[out] applet_id \ref AppletId + * @param[out] mode \ref LibAppletMode + * @param[out] out_size Total data size written to the output buffer. + */ +Result RequestGetAppletInfo(NifmRequest* r, u32 theme_color, void* buffer, size_t size, u32 *applet_id, u32 *mode, u32 *out_size); + +/** + * @brief SetKeptInSleep + * @note Only available on [3.0.0+]. + * @note ::NifmRequestState must be ::NifmRequestState_Unknown1. + * @param r \ref NifmRequest + * @param[in] flag Flag + */ +Result RequestSetKeptInSleep(NifmRequest* r, bool flag); + +/** + * @brief RegisterSocketDescriptor. Only 1 socket can be registered at a time with a NifmRequest. Do not use directly, use \ref socketNifmRequestRegisterSocketDescriptor instead. + * @note Only available on [3.0.0+]. + * @note ::NifmRequestState must be ::NifmRequestState_Available. + * @param r \ref NifmRequest + * @param[in] sockfd Socket fd + */ +Result RequestRegisterSocketDescriptor(NifmRequest* r, int sockfd); + +/** + * @brief UnregisterSocketDescriptor. Do not use directly, use \ref socketNifmRequestUnregisterSocketDescriptor instead. + * @note Only available on [3.0.0+]. + * @note ::NifmRequestState must be ::NifmRequestState_Available. + * @param r \ref NifmRequest + * @param[in] sockfd Socket fd, must match the fd previously registered with \ref nifmRequestRegisterSocketDescriptor. + */ +Result RequestUnregisterSocketDescriptor(NifmRequest* r, int sockfd); + +/** + * @brief SetNetworkProfileId + * @param r \ref NifmRequest + * @param[in] uuid Uuid + */ +Result RequestSetNetworkProfileId(NifmRequest* r, Uuid uuid); + +} // namespace nifm + +/// @brief C++ wrappers for the `nim` API. +/// @details Wraps: switch/services/nim.h. +namespace nim { + +/// SystemUpdateTaskId +using ::NimSystemUpdateTaskId; + +/// Initialize nim. +Result Initialize(void); + +/// Exit nim. +void Exit(void); + +/// Gets the Service object for the actual nim service session. +Service* GetServiceSession(void); + +Result ListSystemUpdateTask(s32 *out_count, NimSystemUpdateTaskId *out_task_ids, size_t max_task_ids); + +Result DestroySystemUpdateTask(const NimSystemUpdateTaskId *task_id); + +} // namespace nim + +/// @brief C++ wrappers for the `notif` API. +/// @details Wraps: switch/services/notif.h. +namespace notif { + +/// AlarmSetting +using ::NotifAlarmSetting; +/// Data extracted from NotifWeeklyScheduleAlarmSetting::settings. This uses local-time. +using ::NotifAlarmTime; +/// ServiceType for \ref notifInitialize. +using ::NotifServiceType; +/// WeeklyScheduleAlarmSetting +using ::NotifWeeklyScheduleAlarmSetting; + +/// Initialize notif. Only available on [9.0.0+]. +Result Initialize(NotifServiceType service_type); + +/// Exit notif. +void Exit(void); + +/// Gets the Service object for the actual notif:* service session. +Service* GetServiceSession(void); + +/** + * @brief Creates a \ref NotifAlarmSetting. + * @note This clears the struct, with all schedule settings set the same as \ref notifAlarmSettingDisable. + * @param[out] alarm_setting \ref NotifAlarmSetting + */ +void AlarmSettingCreate(NotifAlarmSetting *alarm_setting); + +/** + * @brief Sets whether the \ref NotifAlarmSetting is muted. + * @note By default (\ref notifAlarmSettingCreate) this is false. + * @param alarm_setting \ref NotifAlarmSetting + * @param[in] flag Whether the alarm is muted (true = Alarm turned off, false = on). + */ +void AlarmSettingSetIsMuted(NotifAlarmSetting *alarm_setting, bool flag); + +/** + * @brief Sets the \ref AccountUid for the \ref NotifAlarmSetting, see NotifAlarmSetting::uid. + * @param alarm_setting \ref NotifAlarmSetting + * @param[in] uid \ref AccountUid. If want to clear the uid after it was previously set, you can use an all-zero uid to reset to the default (\ref notifAlarmSettingCreate). + */ +void AlarmSettingSetUid(NotifAlarmSetting *alarm_setting, AccountUid uid); + +/** + * @brief Gets whether the schedule setting for the specified day_of_week is enabled, for the \ref NotifAlarmSetting. + * @param alarm_setting \ref NotifAlarmSetting + * @param[in] day_of_week Day-of-week, must be 0-6 (Sun-Sat). + * @param[out] out Whether the setting is enabled. + */ +Result AlarmSettingIsEnabled(NotifAlarmSetting *alarm_setting, u32 day_of_week, bool *out); + +/** + * @brief Gets the schedule setting for the specified day_of_week, for the \ref NotifAlarmSetting. + * @note Should not be used if the output from \ref notifAlarmSettingIsEnabled is false. + * @param alarm_setting \ref NotifAlarmSetting + * @param[in] day_of_week Day-of-week, must be 0-6 (Sun-Sat). + * @param[out] out \ref NotifAlarmTime + */ +Result AlarmSettingGet(NotifAlarmSetting *alarm_setting, u32 day_of_week, NotifAlarmTime *out); + +/** + * @brief Enables the schedule setting for the specified day_of_week, for the \ref NotifAlarmSetting. This uses local-time. + * @param alarm_setting \ref NotifAlarmSetting + * @param[in] day_of_week Day-of-week, must be 0-6 (Sun-Sat). + * @param[in] hour Hour. + * @param[in] minute Minute. + */ +Result AlarmSettingEnable(NotifAlarmSetting *alarm_setting, u32 day_of_week, s32 hour, s32 minute); + +/** + * @brief Disables the schedule setting for the specified day_of_week, for the \ref NotifAlarmSetting. + * @note Schedule settings are disabled by default (\ref notifAlarmSettingCreate). + * @param alarm_setting \ref NotifAlarmSetting + * @param[in] day_of_week Day-of-week, must be 0-6 (Sun-Sat). + */ +Result AlarmSettingDisable(NotifAlarmSetting *alarm_setting, u32 day_of_week); + +/** + * @brief Registers the specified AlarmSetting. + * @note See \ref NOTIF_MAX_ALARMS for the maximum alarms. + * @note When indicated by the output from \ref hidIsFirmwareUpdateNeededForNotification, this will use \ref hidLaShowControllerFirmwareUpdate. + * @param[out] alarm_setting_id AlarmSettingId + * @param[in] alarm_setting \ref NotifAlarmSetting + * @param[in] buffer Input buffer containing the ApplicationParameter. Optional, can be NULL. + * @param[in] size Input buffer size, must be <=0x400. Optional, can be 0. + */ +Result RegisterAlarmSetting(u16 *alarm_setting_id, const NotifAlarmSetting *alarm_setting, const void* buffer, size_t size); + +/** + * @brief Updates the specified AlarmSetting. + * @param[in] alarm_setting \ref NotifAlarmSetting + * @param[in] buffer Input buffer containing the ApplicationParameter. Optional, can be NULL. + * @param[in] size Input buffer size, must be <=0x400. Optional, can be 0. + */ +Result UpdateAlarmSetting(const NotifAlarmSetting *alarm_setting, const void* buffer, size_t size); + +/** + * @brief Gets a listing of AlarmSettings. + * @param[out] alarm_settings Output \ref NotifAlarmSetting array. + * @param[in] count Total entries in the alarm_settings array. + * @param[out] total_out Total output entries. + */ +Result ListAlarmSettings(NotifAlarmSetting *alarm_settings, s32 count, s32 *total_out); + +/** + * @brief Loads the ApplicationParameter for the specified AlarmSetting. + * @param[in] alarm_setting_id AlarmSettingId + * @param[out] buffer Output buffer containing the ApplicationParameter. + * @param[in] size Output buffer size. + * @param[out] actual_size Actual output size. + */ +Result LoadApplicationParameter(u16 alarm_setting_id, void* buffer, size_t size, u32 *actual_size); + +/** + * @brief Deletes the specified AlarmSetting. + * @param[in] alarm_setting_id AlarmSettingId + */ +Result DeleteAlarmSetting(u16 alarm_setting_id); + +/** + * @brief Gets an Event which is signaled when data is available with \ref notifTryPopNotifiedApplicationParameter. + * @note This is a wrapper for \ref appletGetNotificationStorageChannelEvent, see that for the usage requirements. + * @note Some official apps don't use this. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetNotificationSystemEvent(Event *out_event); + +/** + * @brief Uses \ref appletTryPopFromNotificationStorageChannel then reads the data from there into the output params. + * @note This is a wrapper for \ref appletTryPopFromNotificationStorageChannel, see that for the usage requirements. + * @note The system will only push data for this when launching the Application when the Alarm was triggered, where the system was previously in sleep-mode. + * @note Some official apps don't use this. + * @param[out] buffer Output buffer. + * @param[out] size Output buffer size. + * @param[out] out_size Size of the data which was written into the output buffer. Optional, can be NULL. + */ +Result TryPopNotifiedApplicationParameter(void* buffer, u64 size, u64 *out_size); + +} // namespace notif + +/// @brief C++ wrappers for the `ns` API. +/// @details Wraps: switch/services/ns.h. +namespace ns { + +/// NsApplicationContentMetaStatus +using ::NsApplicationContentMetaStatus; +/// ApplicationControlData +using ::NsApplicationControlData; +/// ApplicationControlSource +using ::NsApplicationControlSource; +/// ApplicationDeliveryInfo +using ::NsApplicationDeliveryInfo; +/// ApplicationOccupiedSize +using ::NsApplicationOccupiedSize; +/// ApplicationRecord +using ::NsApplicationRecord; +/// NsApplicationRightsOnClient +using ::NsApplicationRightsOnClient; +/// ApplicationView +using ::NsApplicationView; +/// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions. +using ::NsApplicationViewDeprecated; +/// NsApplicationViewWithPromotionInfo +using ::NsApplicationViewWithPromotionInfo; +/// BackgroundNetworkUpdateState +using ::NsBackgroundNetworkUpdateState; +/// DownloadTaskStatus +using ::NsDownloadTaskStatus; +/// EulaDataPath +using ::NsEulaDataPath; +/// LatestSystemUpdate +using ::NsLatestSystemUpdate; +/// LaunchProperties +using ::NsLaunchProperties; +/// ProgressAsyncResult +using ::NsProgressAsyncResult; +/// ProgressForDeleteUserSaveDataAll +using ::NsProgressForDeleteUserSaveDataAll; +/// ProgressMonitorForDeleteUserSaveDataAll +using ::NsProgressMonitorForDeleteUserSaveDataAll; +/// NsPromotionInfo +using ::NsPromotionInfo; +/// ReceiveApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsReceiveApplicationProgress; +/// RequestServerStopper +using ::NsRequestServerStopper; +/// SendApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsSendApplicationProgress; +/// ShellEvent +using ::NsShellEvent; +/// ShellEventInfo +using ::NsShellEventInfo; +/// SystemDeliveryInfo +using ::NsSystemDeliveryInfo; +/// SystemUpdateControl +using ::NsSystemUpdateControl; +/// SystemUpdateProgress. Commands which have this as output will return 0 with the output cleared, when no task is available. +using ::NsSystemUpdateProgress; + +/// Initialize ns services. Uses ns:am on pre-3.0.0, ns:am2 on [3.0.0+]. +Result Initialize(void); + +/// Exit ns services. +void Exit(void); + +/// Gets the Service object for the actual ns:* service session. Only initialized on [3.0.0+], on pre-3.0.0 see \ref nsGetServiceSession_ApplicationManagerInterface. +Service* GetServiceSession_GetterInterface(void); + +/// Gets the Service object for IApplicationManagerInterface. Only initialized on pre-3.0.0, on [3.0.0+] use \ref nsGetApplicationManagerInterface. +Service* GetServiceSession_ApplicationManagerInterface(void); + +/// Gets the Service object for IDynamicRightsInterface via the cmd for that. +/// Only available on [6.0.0+]. +Result GetDynamicRightsInterface(Service* srv_out); + +/// Gets the Service object for IReadOnlyApplicationControlDataInterface via the cmd for that. +/// Only available on [5.1.0+]. +Result GetReadOnlyApplicationControlDataInterface(Service* srv_out); + +/// Gets the Service object for IReadOnlyApplicationRecordInterface via the cmd for that. +/// Only available on [5.0.0+]. +Result GetReadOnlyApplicationRecordInterface(Service* srv_out); + +/// Gets the Service object for IECommerceInterface via the cmd for that. +/// Only available on [4.0.0+]. +Result GetECommerceInterface(Service* srv_out); + +/// Gets the Service object for IApplicationVersionInterface via the cmd for that. +/// Only available on [4.0.0+]. +Result GetApplicationVersionInterface(Service* srv_out); + +/// Gets the Service object for IFactoryResetInterface via the cmd for that. +/// Only available on [3.0.0+]. +Result GetFactoryResetInterface(Service* srv_out); + +/// Gets the Service object for IAccountProxyInterface via the cmd for that. +/// Only available on [3.0.0+]. +Result GetAccountProxyInterface(Service* srv_out); + +/// Gets the Service object for IApplicationManagerInterface via the cmd for that. +/// Only available on [3.0.0+], on prior sysvers use \ref nsGetServiceSession_ApplicationManagerInterface. +Result GetApplicationManagerInterface(Service* srv_out); + +/// Gets the Service object for IDownloadTaskInterface via the cmd for that. +/// Only available on [3.0.0+]. +Result GetDownloadTaskInterface(Service* srv_out); + +/// Gets the Service object for IContentManagementInterface via the cmd for that. +/// Only available on [3.0.0+]. +Result GetContentManagementInterface(Service* srv_out); + +/// Gets the Service object for IDocumentInterface via the cmd for that. +/// Only available on [3.0.0+]. +Result GetDocumentInterface(Service* srv_out); + +/** + * @brief Gets the \ref NsApplicationControlData for the specified application. + * @note Uses \ref nsGetReadOnlyApplicationControlDataInterface on [5.1.0+], otherwise IApplicationManagerInterface is used. + * @param[in] source Source, official sw uses ::NsApplicationControlSource_Storage. + * @param[in] application_id ApplicationId. + * @param[out] buffer \ref NsApplicationControlData + * @param[in] size Size of the buffer. + * @param[out] actual_size Actual output size. + */ +Result GetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size); + +/** + * @brief Gets the \ref NsApplicationControlData for the specified application. + * @note Only available on [19.0.0+]. + * @param[in] source Source, official sw uses ::NsApplicationControlSource_Storage. + * @param[in] application_id ApplicationId. + * @param[out] buffer \ref NsApplicationControlData + * @param[in] size Size of the buffer. + * @param[in] flag1 Default is 0. 1 retrieves 174x174 icon instead of 256x256. 0xFF uses an unknown alternative path. + * @param[in] acd_idx Default is 0. 1 tries to get NsApplicationControlData for Switch 2 Edition. + * @param[out] actual_size Actual output size. + * @param[out] unk Returned with size, always 0. + */ +Result GetApplicationControlData2(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u8 flag1, u8 acd_idx, u64* actual_size, u32* unk); + +/** + * @brief GetApplicationDesiredLanguage. Selects a \ref NacpLanguageEntry to use from the specified \ref NacpStruct. + * @note Uses \ref nsGetReadOnlyApplicationControlDataInterface on [5.1.0+], otherwise IApplicationManagerInterface is used. + * @param[in] nacp \ref NacpStruct + * @param[out] langentry \ref NacpLanguageEntry + */ +Result GetApplicationDesiredLanguage(NacpStruct *nacp, NacpLanguageEntry **langentry); + +/** + * @brief RequestLinkDevice + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [4.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] uid \ref AccountUid + */ +Result RequestLinkDevice(AsyncResult *a, AccountUid uid); + +/** + * @brief RequestSyncRights + * @note Only available on [6.0.0+]. + * @param[out] a \ref AsyncResult + */ +Result RequestSyncRights(AsyncResult *a); + +/** + * @brief RequestUnlinkDevice + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [6.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] uid \ref AccountUid + */ +Result RequestUnlinkDevice(AsyncResult *a, AccountUid uid); + +/** + * @brief ResetToFactorySettings + * @note Uses \ref nsGetFactoryResetInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + */ +Result ResetToFactorySettings(void); + +/** + * @brief ResetToFactorySettingsWithoutUserSaveData + * @note Uses \ref nsGetFactoryResetInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + */ +Result ResetToFactorySettingsWithoutUserSaveData(void); + +/** + * @brief ResetToFactorySettingsForRefurbishment + * @note Uses \ref nsGetFactoryResetInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + */ +Result ResetToFactorySettingsForRefurbishment(void); + +/** + * @brief ResetToFactorySettingsWithPlatformRegion + * @note Only available on [9.1.0+]. + */ +Result ResetToFactorySettingsWithPlatformRegion(void); + +/** + * @brief ResetToFactorySettingsWithPlatformRegionAuthentication + * @note Only available on [9.1.0+]. + */ +Result ResetToFactorySettingsWithPlatformRegionAuthentication(void); + +/** + * @brief Gets an listing of \ref NsApplicationRecord. + * @param[out] records Output array of \ref NsApplicationRecord. + * @param[in] count Size of the records array in entries. + * @param[in] entry_offset Starting entry offset. + * @param[out] out_entrycount Total output entries. + */ +Result ListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount); + +/** + * @brief GetApplicationRecordUpdateSystemEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=true. + */ +Result GetApplicationRecordUpdateSystemEvent(Event* out_event); + +/** + * @brief GetApplicationViewDeprecated + * @note On [3.0.0+] you should generally use \ref nsGetApplicationView instead. + * @param[out] out Output array of \ref NsApplicationViewDeprecated. + * @param[in] application_ids Input array of ApplicationIds. + * @param[in] count Size of the input/output arrays in entries. + */ +Result GetApplicationViewDeprecated(NsApplicationViewDeprecated *views, const u64 *application_ids, s32 count); + +/** + * @brief DeleteApplicationEntity + * @param[in] application_id ApplicationId. + */ +Result DeleteApplicationEntity(u64 application_id); + +/** + * @brief DeleteApplicationCompletely + * @param[in] application_id ApplicationId. + */ +Result DeleteApplicationCompletely(u64 application_id); + +/** + * @brief DeleteRedundantApplicationEntity + */ +Result DeleteRedundantApplicationEntity(void); + +/** + * @brief IsApplicationEntityMovable + * @param[in] application_id ApplicationId. + * @param[in] storage_id \ref NcmStorageId + * @param[out] out Output flag. + */ +Result IsApplicationEntityMovable(u64 application_id, NcmStorageId storage_id, bool *out); + +/** + * @brief MoveApplicationEntity + * @note Only available on [1.0.0-9.2.0]. + * @param[in] application_id ApplicationId. + * @param[in] storage_id \ref NcmStorageId + */ +Result MoveApplicationEntity(u64 application_id, NcmStorageId storage_id); + +/** + * @brief RequestApplicationUpdateInfo + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @param[out] a \ref AsyncValue. The data that can be read from this is u8 ApplicationUpdateInfo. qlaunch just checks whether this is 0. + * @param application_id ApplicationId. + */ +Result RequestApplicationUpdateInfo(AsyncValue *a, u64 application_id); + +/** + * @brief CancelApplicationDownload + * @param[in] application_id ApplicationId. + */ +Result CancelApplicationDownload(u64 application_id); + +/** + * @brief ResumeApplicationDownload + * @param[in] application_id ApplicationId. + */ +Result ResumeApplicationDownload(u64 application_id); + +/** + * @brief CheckApplicationLaunchVersion + * @param[in] application_id ApplicationId. + */ +Result CheckApplicationLaunchVersion(u64 application_id); + +/** + * @brief CalculateApplicationApplyDeltaRequiredSize + * @param[in] application_id ApplicationId. + * @param[out] storage_id Output \ref NcmStorageId. + * @param[out] size Output size. + */ +Result CalculateApplicationDownloadRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size); + +/** + * @brief CleanupSdCard + */ +Result CleanupSdCard(void); + +/** + * @brief GetSdCardMountStatusChangedEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetSdCardMountStatusChangedEvent(Event* out_event); + +/** + * @brief GetGameCardUpdateDetectionEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetGameCardUpdateDetectionEvent(Event* out_event); + +/** + * @brief DisableApplicationAutoDelete + * @param[in] application_id ApplicationId. + */ +Result DisableApplicationAutoDelete(u64 application_id); + +/** + * @brief EnableApplicationAutoDelete + * @param[in] application_id ApplicationId. + */ +Result EnableApplicationAutoDelete(u64 application_id); + +/** + * @brief SetApplicationTerminateResult + * @param[in] application_id ApplicationId. + * @param[in] res Result. + */ +Result SetApplicationTerminateResult(u64 application_id, Result res); + +/** + * @brief ClearApplicationTerminateResult + * @param[in] application_id ApplicationId. + */ +Result ClearApplicationTerminateResult(u64 application_id); + +/** + * @brief GetLastSdCardMountUnexpectedResult + */ +Result GetLastSdCardMountUnexpectedResult(void); + +/** + * @brief Opens a \ref NsRequestServerStopper. + * @note Only available on [2.0.0+]. + * @param[out] r \ref NsRequestServerStopper + */ +Result GetRequestServerStopper(NsRequestServerStopper *r); + +/** + * @brief CancelApplicationApplyDelta + * @note Only available on [3.0.0+]. + * @param[in] application_id ApplicationId. + */ +Result CancelApplicationApplyDelta(u64 application_id); + +/** + * @brief ResumeApplicationApplyDelta + * @note Only available on [3.0.0+]. + * @param[in] application_id ApplicationId. + */ +Result ResumeApplicationApplyDelta(u64 application_id); + +/** + * @brief CalculateApplicationApplyDeltaRequiredSize + * @note Only available on [3.0.0+]. + * @param[in] application_id ApplicationId. + * @param[out] storage_id Output \ref NcmStorageId. + * @param[out] size Output size. + */ +Result CalculateApplicationApplyDeltaRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size); + +/** + * @brief ResumeAll + * @note Only available on [3.0.0+]. + */ +Result ResumeAll(void); + +/** + * @brief Temporarily mounts the specified fs ContentStorage, then uses fs GetTotalSpaceSize/GetFreeSpaceSize with that mounted ContentStorage. + * @note Only available on [3.0.0+]. + * @param[in] storage_id \ref NcmStorageId, must be ::NcmStorageId_BuiltInUser or ::NcmStorageId_SdCard. + * @param[out] total_space_size Output from GetTotalSpaceSize. + * @param[out] free_space_size Output from GetFreeSpaceSize. + */ +Result GetStorageSize(NcmStorageId storage_id, s64 *total_space_size, s64 *free_space_size); + +/** + * @brief RequestUpdateApplication2 + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [4.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] application_id ApplicationId. + */ +Result RequestUpdateApplication2(AsyncResult *a, u64 application_id); + +/** + * @brief DeleteUserSaveDataAll + * @param[in] p \ref NsProgressMonitorForDeleteUserSaveDataAll + * @param[in] uid \ref AccountUid + */ +Result DeleteUserSaveDataAll(NsProgressMonitorForDeleteUserSaveDataAll *p, AccountUid uid); + +/** + * @brief DeleteUserSystemSaveData + * @param[in] uid \ref AccountUid + * @param[in] system_save_data_id SystemSaveDataId + */ +Result DeleteUserSystemSaveData(AccountUid uid, u64 system_save_data_id); + +/** + * @brief DeleteSaveData + * @note Only available on [6.0.0+]. + * @param[in] save_data_space_id \ref FsSaveDataSpaceId + * @param[in] save_data_id SaveDataId + */ +Result DeleteSaveData(FsSaveDataSpaceId save_data_space_id, u64 save_data_id); + +/** + * @brief UnregisterNetworkServiceAccount + * @param[in] uid \ref AccountUid + */ +Result UnregisterNetworkServiceAccount(AccountUid uid); + +/** + * @brief UnregisterNetworkServiceAccountWithUserSaveDataDeletion + * @note Only available on [6.0.0+]. + * @param[in] uid \ref AccountUid + */ +Result UnregisterNetworkServiceAccountWithUserSaveDataDeletion(AccountUid uid); + +/** + * @brief RequestDownloadApplicationControlData + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @param[out] a \ref AsyncResult + * @param[in] application_id ApplicationId. + */ +Result RequestDownloadApplicationControlData(AsyncResult *a, u64 application_id); + +/** + * @brief ListApplicationTitle + * @note The data available with \ref asyncValueGet is a s32 for the offset within the buffer where the output data is located, \ref asyncValueGetSize returns the total byte-size of the data located here. The data located here is the \ref NacpLanguageEntry for each specified ApplicationId. + * @note Only available on [8.0.0+]. + * @param[out] a \ref AsyncValue + * @param[in] source Source, qlaunch uses ::NsApplicationControlSource_Storage. + * @param[in] application_ids Input array of ApplicationIds. + * @param[in] count Size of the application_ids array in entries. + * @param buffer 0x1000-byte aligned buffer for TransferMemory. This buffer must not be accessed until the async operation finishes. + * @param[in] size 0x1000-byte aligned buffer size for TransferMemory. This must be at least: count*sizeof(\ref NacpLanguageEntry) + count*sizeof(u64) + count*sizeof(\ref NsApplicationControlData). + */ +Result ListApplicationTitle(AsyncValue *a, NsApplicationControlSource source, const u64 *application_ids, s32 count, void* buffer, size_t size); + +/** + * @brief ListApplicationTitle2. Returns \ref NacpLanguageEntry matching currently set system language for each specified ApplicationId. + * @note The data available with \ref asyncValueGet is a s32 for the offset within the buffer where the output data is located, \ref asyncValueGetSize returns the total byte-size of the data located here. The data located here is the \ref NacpLanguageEntry for each specified ApplicationId. + * @note Only available on [20.0.0+]. + * @note NacpLanguageEntry is decompressed when necessary only on [21.0.0+]. + * @param[out] a \ref AsyncValue + * @param[in] source Source, official sw uses ::NsApplicationControlSource_Storage. + * @param[in] application_ids Input array of ApplicationIds. + * @param[in] count Size of the application_ids array in entries. + * @param buffer 0x1000-byte aligned buffer for TransferMemory. This buffer must not be accessed until the async operation finishes. + * @param[in] size 0x1000-byte aligned buffer size for TransferMemory. This must be at least: count*sizeof(\ref NacpLanguageEntry) + count*sizeof(u64) + sizeof(\ref NsApplicationControlData). + */ +Result ListApplicationTitle2(AsyncValue *a, NsApplicationControlSource source, const u64 *application_ids, s32 count, void* buffer, size_t size); + +/** + * @brief ListApplicationIcon + * @note The data available with \ref asyncValueGet is a s32 for the offset within the buffer where the output data is located, \ref asyncValueGetSize returns the total byte-size of the data located here. This data is: an u64 for total entries, an array of u64s for each icon size, then the icon JPEGs for the specified ApplicationIds. + * @note Only available on [8.0.0+]. + * @param[out] a \ref AsyncValue + * @param[in] source Source. + * @param[in] application_ids Input array of ApplicationIds. + * @param[in] count Size of the application_ids array in entries. + * @param buffer 0x1000-byte aligned buffer for TransferMemory. This buffer must not be accessed until the async operation finishes. + * @param[in] size 0x1000-byte aligned buffer size for TransferMemory. This must be at least: 0x4 + count*sizeof(u64) + count*sizeof(\ref NsApplicationControlData::icon) + count*sizeof(u64) + sizeof(\ref NsApplicationControlData). + */ +Result ListApplicationIcon(AsyncValue *a, NsApplicationControlSource source, const u64 *application_ids, s32 count, void* buffer, size_t size); + +/** + * @brief RequestCheckGameCardRegistration + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [2.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] application_id ApplicationId. + */ +Result RequestCheckGameCardRegistration(AsyncResult *a, u64 application_id); + +/** + * @brief RequestGameCardRegistrationGoldPoint + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [2.0.0+]. + * @param[out] a \ref AsyncValue. The data that can be read from this is 4-bytes. + * @param[in] uid \ref AccountUid + * @param[in] application_id ApplicationId. + */ +Result RequestGameCardRegistrationGoldPoint(AsyncValue *a, AccountUid uid, u64 application_id); + +/** + * @brief RequestRegisterGameCard + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [2.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] uid \ref AccountUid + * @param[in] application_id ApplicationId. + * @param[in] inval Input value. + */ +Result RequestRegisterGameCard(AsyncResult *a, AccountUid uid, u64 application_id, s32 inval); + +/** + * @brief GetGameCardMountFailureEvent + * @note The Event must be closed by the user once finished with it. + * @note Only available on [3.0.0+]. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetGameCardMountFailureEvent(Event* out_event); + +/** + * @brief IsGameCardInserted + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsGameCardInserted(bool *out); + +/** + * @brief EnsureGameCardAccess + * @note Only available on [3.0.0+]. + */ +Result EnsureGameCardAccess(void); + +/** + * @brief GetLastGameCardMountFailureResult + * @note Only available on [3.0.0+]. + */ +Result GetLastGameCardMountFailureResult(void); + +/** + * @brief ListApplicationIdOnGameCard + * @note Only available on [5.0.0+]. + * @param[out] application_ids Output array of ApplicationIds. + * @param[in] count Size of the application_ids array in entries. + * @param[out] total_out Total output entries. + */ +Result ListApplicationIdOnGameCard(u64 *application_ids, s32 count, s32 *total_out); + +/** + * @brief TouchApplication + * @note Only available on [2.0.0+]. + * @param[in] application_id ApplicationId. + */ +Result TouchApplication(u64 application_id); + +/** + * @brief IsApplicationUpdateRequested + * @note Only available on [2.0.0+]. + * @param[in] application_id ApplicationId. + * @param[out] flag Output flag, indicating whether out is valid. + * @param[out] out Output value. + */ +Result IsApplicationUpdateRequested(u64 application_id, bool *flag, u32 *out); + +/** + * @brief WithdrawApplicationUpdateRequest + * @note Only available on [2.0.0+]. + * @param[in] application_id ApplicationId. + */ +Result WithdrawApplicationUpdateRequest(u64 application_id); + +/** + * @brief RequestVerifyAddOnContentsRights + * @note Only available on [3.0.0-9.2.0]. + * @param[out] a \ref NsProgressAsyncResult + * @param[in] application_id ApplicationId. + */ +Result RequestVerifyAddOnContentsRights(NsProgressAsyncResult *a, u64 application_id); + +/** + * @brief RequestVerifyApplication + * @note On pre-5.0.0 this uses cmd RequestVerifyApplicationDeprecated, otherwise cmd RequestVerifyApplication is used. + * @param[out] a \ref NsProgressAsyncResult. The data available with \ref nsProgressAsyncResultGetProgress is basically the same as \ref NsSystemUpdateProgress. + * @param[in] application_id ApplicationId. + * @param[in] unk Unknown. A default value of 0x7 can be used (which is what qlaunch uses). Only used on [5.0.0+]. + * @param buffer 0x1000-byte aligned buffer for TransferMemory. This buffer must not be accessed until the async operation finishes. + * @param[in] size 0x1000-byte aligned buffer size for TransferMemory. qlaunch uses size 0x100000. + */ +Result RequestVerifyApplication(NsProgressAsyncResult *a, u64 application_id, u32 unk, void* buffer, size_t size); + +/** + * @brief IsAnyApplicationEntityInstalled + * @note Only available on [2.0.0+]. + * @param[in] application_id ApplicationId. + * @param[out] out Output flag. + */ +Result IsAnyApplicationEntityInstalled(u64 application_id, bool *out); + +/** + * @brief CleanupUnavailableAddOnContents + * @note Only available on [6.0.0+]. + * @param[in] application_id ApplicationId. + * @param[in] uid \ref AccountUid + */ +Result CleanupUnavailableAddOnContents(u64 application_id, AccountUid uid); + +/** + * @brief EstimateSizeToMove + * @note Only available on [10.0.0+]. + * @param[in] storage_ids Array of u8 \ref NcmStorageId. + * @param[in] count Size of the storage_ids array in entries. + * @param[in] storage_id storage_id \ref NcmStorageId + * @param[in] flags Flags + * @param[in] application_id ApplicationId. + * @param[out] Out Output value. + */ +Result EstimateSizeToMove(u8 *storage_ids, s32 count, NcmStorageId storage_id, u32 flags, u64 application_id, s64 *out); + +/** + * @brief FormatSdCard + * @note Only available on [2.0.0+]. + */ +Result FormatSdCard(void); + +/** + * @brief NeedsSystemUpdateToFormatSdCard + * @note Only available on [2.0.0+]. + * @param[out] out Output flag. + */ +Result NeedsSystemUpdateToFormatSdCard(bool *out); + +/** + * @brief GetLastSdCardFormatUnexpectedResult + * @note Only available on [2.0.0+]. + */ +Result GetLastSdCardFormatUnexpectedResult(void); + +/** + * @brief GetApplicationView + * @note Only available on [3.0.0+], on prior system-versions use \ref nsGetApplicationViewDeprecated instead. + * @param[out] out Output array of \ref NsApplicationView. + * @param[in] application_ids Input array of ApplicationIds. + * @param[in] count Size of the input/output arrays in entries. + */ +Result GetApplicationView(NsApplicationView *views, const u64 *application_ids, s32 count); + +/** + * @brief GetApplicationViewDownloadErrorContext + * @note Only available on [4.0.0+]. + * @param[in] application_id ApplicationId + * @param[out] context \ref ErrorContext + */ +Result GetApplicationViewDownloadErrorContext(u64 application_id, ErrorContext *context); + +/** + * @brief GetApplicationViewWithPromotionInfo + * @note Only available on [8.0.0+]. + * @param[out] out Output array of \ref NsApplicationViewWithPromotionInfo. + * @param[in] application_ids Input array of ApplicationIds. + * @param[in] count Size of the input/output arrays in entries. + */ +Result GetApplicationViewWithPromotionInfo(NsApplicationViewWithPromotionInfo *out, const u64 *application_ids, s32 count); + +/** + * @brief RequestDownloadApplicationPrepurchasedRights + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [4.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] application_id ApplicationId. + */ +Result RequestDownloadApplicationPrepurchasedRights(AsyncResult *a, u64 application_id); + +/** + * @brief Generates a \ref NsSystemDeliveryInfo using the currently installed SystemUpdate meta. + * @note Only available on [4.0.0+]. + * @param[out] info \ref NsSystemDeliveryInfo + */ +Result GetSystemDeliveryInfo(NsSystemDeliveryInfo *info); + +/** + * @brief SelectLatestSystemDeliveryInfo + * @note This selects the \ref NsSystemDeliveryInfo with the latest version from sys_list, using minimum versions determined from app_list/state and base_info, etc. + * @note Only available on [4.0.0+]. + * @param[in] sys_list Input array of \ref NsSystemDeliveryInfo. + * @param[in] sys_count Size of the sys_list array in entries. + * @param[in] base_info \ref NsSystemDeliveryInfo + * @param[in] app_list Input array of \ref NsApplicationDeliveryInfo. This can be NULL. + * @param[in] app_count Size of the app_list array in entries. This can be 0. + * @param[out] index Output index for the selected entry in sys_list, -1 if none found. + */ +Result SelectLatestSystemDeliveryInfo(const NsSystemDeliveryInfo *sys_list, s32 sys_count, const NsSystemDeliveryInfo *base_info, const NsApplicationDeliveryInfo *app_list, s32 app_count, s32 *index); + +/** + * @brief VerifyDeliveryProtocolVersion + * @note Only available on [4.0.0+]. + * @param[in] info \ref NsSystemDeliveryInfo + */ +Result VerifyDeliveryProtocolVersion(const NsSystemDeliveryInfo *info); + +/** + * @brief Generates \ref NsApplicationDeliveryInfo for the specified ApplicationId. + * @note Only available on [4.0.0+]. + * @param[out] info Output array of \ref NsApplicationDeliveryInfo. + * @param[in] count Size of the array in entries. + * @param[in] application_id ApplicationId + * @param[in] attr ApplicationDeliveryAttributeTag bitmask. + * @param[out] total_out Total output entries. + */ +Result GetApplicationDeliveryInfo(NsApplicationDeliveryInfo *info, s32 count, u64 application_id, u32 attr, s32 *total_out); + +/** + * @brief HasAllContentsToDeliver + * @note Only available on [4.0.0+]. + * @param[in] info Input array of \ref NsApplicationDeliveryInfo. + * @param[in] count Size of the array in entries. Must be value 1. + * @param[out] out Output flag. + */ +Result HasAllContentsToDeliver(const NsApplicationDeliveryInfo* info, s32 count, bool *out); + +/** + * @brief Both \ref NsApplicationDeliveryInfo are validated, then the application_version in the first/second \ref NsApplicationDeliveryInfo are compared. + * @note Only available on [4.0.0+]. + * @param[in] info0 First input array of \ref NsApplicationDeliveryInfo. + * @param[in] count0 Size of the info0 array in entries. Must be value 1. + * @param[in] info1 Second input array of \ref NsApplicationDeliveryInfo. + * @param[in] count1 Size of the info1 array in entries. Must be value 1. + * @param[out] out Comparison result: -1 for less than, 0 for equal, and 1 for higher than. + */ +Result CompareApplicationDeliveryInfo(const NsApplicationDeliveryInfo *info0, s32 count0, const NsApplicationDeliveryInfo *info1, s32 count1, s32 *out); + +/** + * @brief CanDeliverApplication + * @note Only available on [4.0.0+]. + * @param[in] info0 First input array of \ref NsApplicationDeliveryInfo. + * @param[in] count0 Size of the info0 array in entries. Must be value <=1, when 0 this will return 0 with out set to 0. + * @param[in] info1 Second input array of \ref NsApplicationDeliveryInfo. + * @param[in] count1 Size of the info1 array in entries. Must be value 1. + * @param[out] out Output flag. + */ +Result CanDeliverApplication(const NsApplicationDeliveryInfo *info0, s32 count0, const NsApplicationDeliveryInfo *info1, s32 count1, bool *out); + +/** + * @brief ListContentMetaKeyToDeliverApplication + * @note Only available on [4.0.0+]. + * @param[out] meta Output array of \ref NcmContentMetaKey. + * @param[in] meta_count Size of the meta array in entries. Must be at least 1, only 1 entry will be returned. + * @param[in] meta_index Meta entry index. An output \ref NcmContentMetaKey will not be returned when this value is larger than 0. + * @param[in] info Input array of \ref NsApplicationDeliveryInfo. + * @param[in] info_count Size of the info array in entries. Must be value 1. + * @param[out] total_out Total output entries. + */ +Result ListContentMetaKeyToDeliverApplication(NcmContentMetaKey *meta, s32 meta_count, s32 meta_index, const NsApplicationDeliveryInfo *info, s32 info_count, s32 *total_out); + +/** + * @brief After validation, this sets the output bool by comparing system-version fields in the \ref NsSystemDeliveryInfo / info-array and with a state field, etc. + * @note Only available on [4.0.0+]. + * @param[in] info Input array of \ref NsApplicationDeliveryInfo. + * @param[in] count Size of the info array in entries. Must be value 1. + * @param[in] sys_info \ref NsSystemDeliveryInfo + * @param[out] out Output flag. + */ +Result NeedsSystemUpdateToDeliverApplication(const NsApplicationDeliveryInfo *info, s32 count, const NsSystemDeliveryInfo *sys_info, bool *out); + +/** + * @brief EstimateRequiredSize + * @note Only available on [4.0.0+]. + * @param[in] meta Input array of \ref NcmContentMetaKey. + * @param[in] count Size of the meta array in entries. When less than 1, this will return 0 with out set to 0. + * @param[out] out Output size. + */ +Result EstimateRequiredSize(const NcmContentMetaKey *meta, s32 count, s64 *out); + +/** + * @brief RequestReceiveApplication + * @note This is the Application version of \ref nssuControlRequestReceiveSystemUpdate, see the notes for that. + * @note Only available on [4.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] addr Server IPv4 address. + * @param[in] port Socket port. qlaunch uses value 55556. + * @param[in] application_id ApplicationId + * @param[in] meta Input array of \ref NcmContentMetaKey. The ::NcmContentMetaType must match ::NcmContentMetaType_Patch. + * @param[in] count Size of the meta array in entries. + * @param[in] storage_id \ref NcmStorageId. qlaunch uses ::NcmStorageId_Any. + */ +Result RequestReceiveApplication(AsyncResult *a, u32 addr, u16 port, u64 application_id, const NcmContentMetaKey *meta, s32 count, NcmStorageId storage_id); + +/** + * @brief CommitReceiveApplication + * @note Only available on [4.0.0+]. + * @param[in] application_id ApplicationId + */ +Result CommitReceiveApplication(u64 application_id); + +/** + * @brief GetReceiveApplicationProgress + * @note Only available on [4.0.0+]. + * @param[in] application_id ApplicationId + * @param[out] out \ref NsReceiveApplicationProgress + */ +Result GetReceiveApplicationProgress(u64 application_id, NsReceiveApplicationProgress *out); + +/** + * @brief RequestSendApplication + * @note This is the Application version of \ref nssuRequestSendSystemUpdate, see the notes for that. + * @note Only available on [4.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] addr Client IPv4 address. + * @param[in] port Socket port. qlaunch uses value 55556. + * @param[in] application_id ApplicationId + * @param[in] meta Input array of \ref NcmContentMetaKey. The ::NcmContentMetaType must match ::NcmContentMetaType_Patch. + * @param[in] count Size of the meta array in entries. + */ +Result RequestSendApplication(AsyncResult *a, u32 addr, u16 port, u64 application_id, const NcmContentMetaKey *meta, s32 count); + +/** + * @brief GetSendApplicationProgress + * @note Only available on [4.0.0+]. + * @param[in] application_id ApplicationId + * @param[out] out \ref NsSendApplicationProgress + */ +Result GetSendApplicationProgress(u64 application_id, NsSendApplicationProgress *out); + +/** + * @brief Both \ref NsSystemDeliveryInfo are validated, then the system_update_version in the first/second \ref NsSystemDeliveryInfo are compared. + * @note Only available on [4.0.0+]. + * @param[in] info0 First \ref NsSystemDeliveryInfo. + * @param[in] info1 Second \ref NsSystemDeliveryInfo. + * @param[out] out Comparison result: -1 for less than, 0 for equal, and 1 for higher than. + */ +Result CompareSystemDeliveryInfo(const NsSystemDeliveryInfo *info0, const NsSystemDeliveryInfo *info1, s32 *out); + +/** + * @brief ListNotCommittedContentMeta + * @note Only available on [4.0.0+]. + * @param[out] meta Output array of \ref NcmContentMetaKey. + * @param[in] count Size of the meta array in entries. + * @param[in] application_id ApplicationId + * @param[in] unk Unknown. + * @param[out] total_out Total output entries. + */ +Result ListNotCommittedContentMeta(NcmContentMetaKey *meta, s32 count, u64 application_id, s32 unk, s32 *total_out); + +/** + * @brief This extracts data from the input array for hashing with SHA256, with validation being done when handling each entry. + * @note Only available on [5.0.0+]. + * @param[in] info Input array of \ref NsApplicationDeliveryInfo. + * @param[in] count Size of the array in entries. + * @param[out] out_hash Output 0x20-byte SHA256 hash. + */ +Result GetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s32 count, u8 *out_hash); + +/** + * @brief GetApplicationTerminateResult + * @note Only available on [6.0.0+]. + * @param[in] application_id ApplicationId. + * @param[out] res Output Result. + */ +Result GetApplicationTerminateResult(u64 application_id, Result *res); + +/** + * @brief GetApplicationRightsOnClient + * @note Only available on [6.0.0+]. + * @param[out] rights Output array of \ref NsApplicationRightsOnClient. + * @param[in] count Size of the rights array in entries. qlaunch uses value 3 for this. + * @param[in] application_id ApplicationId + * @param[in] uid \ref AccountUid, can optionally be all-zero. + * @param[in] flags Flags. Official sw hard-codes this to value 0x3. + * @param[out] total_out Total output entries. + */ +Result GetApplicationRightsOnClient(NsApplicationRightsOnClient *rights, s32 count, u64 application_id, AccountUid uid, u32 flags, s32 *total_out); + +/** + * @brief RequestNoDownloadRightsErrorResolution + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [9.0.0+]. + * @param[out] a \ref AsyncValue. The data that can be read from this is u8 NoDownloadRightsErrorResolution. + * @param application_id ApplicationId. + */ +Result RequestNoDownloadRightsErrorResolution(AsyncValue *a, u64 application_id); + +/** + * @brief RequestResolveNoDownloadRightsError + * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. + * @note Only available on [9.0.0+]. + * @param[out] a \ref AsyncValue. The data that can be read from this is u8 NoDownloadRightsErrorResolution. + * @param application_id ApplicationId. + */ +Result RequestResolveNoDownloadRightsError(AsyncValue *a, u64 application_id); + +/** + * @brief GetPromotionInfo + * @note Only available on [8.0.0+]. + * @param[out] promotion \ref NsPromotionInfo + * @param application_id ApplicationId. + * @param[in] uid \ref AccountUid + */ +Result GetPromotionInfo(NsPromotionInfo *promotion, u64 application_id, AccountUid uid); + +/** + * @brief ClearTaskStatusList + * @note Uses \ref nsGetDownloadTaskInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + */ +Result ClearTaskStatusList(void); + +/** + * @brief RequestDownloadTaskList + * @note Uses \ref nsGetDownloadTaskInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + */ +Result RequestDownloadTaskList(void); + +/** + * @brief RequestEnsureDownloadTask + * @note Uses \ref nsGetDownloadTaskInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + * @param[out] a \ref AsyncResult + */ +Result RequestEnsureDownloadTask(AsyncResult *a); + +/** + * @brief ListDownloadTaskStatus + * @note Uses \ref nsGetDownloadTaskInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + * @param[out] tasks Output array of \ref NsDownloadTaskStatus. + * @param[in] count Size of the tasks array in entries. A maximum of 0x100 tasks can be stored in state. + * @param[out] total_out Total output entries. + */ +Result ListDownloadTaskStatus(NsDownloadTaskStatus* tasks, s32 count, s32 *total_out); + +/** + * @brief RequestDownloadTaskListData + * @note Uses \ref nsGetDownloadTaskInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + * @param[out] a \ref AsyncValue + */ +Result RequestDownloadTaskListData(AsyncValue *a); + +/** + * @brief TryCommitCurrentApplicationDownloadTask + * @note Only available on [4.0.0+]. + */ +Result TryCommitCurrentApplicationDownloadTask(void); + +/** + * @brief EnableAutoCommit + * @note Only available on [4.0.0+]. + */ +Result EnableAutoCommit(void); + +/** + * @brief DisableAutoCommit + * @note Only available on [4.0.0+]. + */ +Result DisableAutoCommit(void); + +/** + * @brief TriggerDynamicCommitEvent + * @note Only available on [4.0.0+]. + */ +Result TriggerDynamicCommitEvent(void); + +/** + * @brief CalculateApplicationOccupiedSize + * @note Uses \ref nsGetContentManagementInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @param[in] application_id ApplicationId. + * @param[out] out \ref NsApplicationOccupiedSize + */ +Result CalculateApplicationOccupiedSize(u64 application_id, NsApplicationOccupiedSize *out); + +/** + * @brief CheckSdCardMountStatus + * @note Uses \ref nsGetContentManagementInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + */ +Result CheckSdCardMountStatus(void); + +/** + * @brief Returns the total storage capacity (used + free) from content manager services. + * @note Uses \ref nsGetContentManagementInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @param[in] storage_id \ref NcmStorageId. Must be ::NcmStorageId_SdCard. + * @param[out] size Pointer to output the total storage size to. + */ +Result GetTotalSpaceSize(NcmStorageId storage_id, s64 *size); + +/** + * @brief Returns the available storage capacity from content manager services. + * @note Uses \ref nsGetContentManagementInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @param[in] storage_id \ref NcmStorageId. Must be ::NcmStorageId_SdCard. + * @param[out] size Pointer to output the free storage size to. + */ +Result GetFreeSpaceSize(NcmStorageId storage_id, s64 *size); + +/** + * @brief CountApplicationContentMeta + * @note Uses \ref nsGetContentManagementInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + * @param[in] application_id ApplicationId. + * @param[out] out Output count. + */ +Result CountApplicationContentMeta(u64 application_id, s32 *out); + +/** + * @brief Gets an listing of \ref NsApplicationContentMetaStatus. + * @note Uses \ref nsGetContentManagementInterface on [3.0.0+], otherwise IApplicationManagerInterface is used. + * @note Only available on [2.0.0+]. + * @param[in] application_id ApplicationId. + * @param[in] index Starting entry index. + * @param[out] list Output array of \ref NsApplicationContentMetaStatus. + * @param[in] count Size of the list array in entries. + * @param[out] out_entrycount Total output entries. + */ +Result ListApplicationContentMetaStatus(u64 application_id, s32 index, NsApplicationContentMetaStatus* list, s32 count, s32* out_entrycount); + +/** + * @brief IsAnyApplicationRunning + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result IsAnyApplicationRunning(bool *out); + +/** + * @brief Close a \ref NsRequestServerStopper. + * @param r \ref NsRequestServerStopper + */ +void RequestServerStopperClose(NsRequestServerStopper *r); + +/** + * @brief Close a \ref NsProgressMonitorForDeleteUserSaveDataAll. When initialized this will use \ref nsProgressMonitorForDeleteUserSaveDataAllIsFinished, throwing errors on failure / when the operation isn't finished (without closing the object). + * @note Cancelling the operation before it's finished is not supported by \ref NsProgressMonitorForDeleteUserSaveDataAll. + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + */ +Result ProgressMonitorForDeleteUserSaveDataAllClose(NsProgressMonitorForDeleteUserSaveDataAll *p); + +/** + * @brief GetSystemEvent + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result ProgressMonitorForDeleteUserSaveDataAllGetSystemEvent(NsProgressMonitorForDeleteUserSaveDataAll *p, Event* out_event); + +/** + * @brief IsFinished + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + * @param[out] out Whether the operation finished. + */ +Result ProgressMonitorForDeleteUserSaveDataAllIsFinished(NsProgressMonitorForDeleteUserSaveDataAll *p, bool *out); + +/** + * @brief GetResult + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + */ +Result ProgressMonitorForDeleteUserSaveDataAllGetResult(NsProgressMonitorForDeleteUserSaveDataAll *p); + +/** + * @brief GetProgress + * @param p \ref NsProgressMonitorForDeleteUserSaveDataAll + * @param[out] progress Output \ref NsProgressForDeleteUserSaveDataAll. + */ +Result ProgressMonitorForDeleteUserSaveDataAllGetProgress(NsProgressMonitorForDeleteUserSaveDataAll *p, NsProgressForDeleteUserSaveDataAll *progress); + +/** + * @brief Close a \ref NsProgressAsyncResult. + * @note When the object is initialized, this uses \ref nsProgressAsyncResultCancel then \ref nsProgressAsyncResultWait with timeout=UINT64_MAX. + * @param a \ref NsProgressAsyncResult + */ +void ProgressAsyncResultClose(NsProgressAsyncResult *a); + +/** + * @brief Waits for the async operation to finish using the specified timeout. + * @param a \ref NsProgressAsyncResult + * @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout. + */ +Result ProgressAsyncResultWait(NsProgressAsyncResult *a, u64 timeout); + +/** + * @brief Gets the Result. + * @note Prior to using the cmd, this uses \ref nsProgressAsyncResultWait with timeout=UINT64_MAX. + * @param a \ref NsProgressAsyncResult + */ +Result ProgressAsyncResultGet(NsProgressAsyncResult *a); + +/** + * @brief Cancels the async operation. + * @note Used automatically by \ref nsProgressAsyncResultClose. + * @param a \ref NsProgressAsyncResult + */ +Result ProgressAsyncResultCancel(NsProgressAsyncResult *a); + +/** + * @brief Gets the progress. + * @param a \ref NsProgressAsyncResult + * @param[out] buffer Output buffer. + * @param[in] size Output buffer size. + */ +Result ProgressAsyncResultGetProgress(NsProgressAsyncResult *a, void* buffer, size_t size); + +/** + * @brief GetDetailResult + * @param a \ref NsProgressAsyncResult + */ +Result ProgressAsyncResultGetDetailResult(NsProgressAsyncResult *a); + +/** + * @brief Gets the \ref ErrorContext. + * @note Only available on [4.0.0+]. + * @param a \ref NsProgressAsyncResult + * @param[out] context \ref ErrorContext + */ +Result ProgressAsyncResultGetErrorContext(NsProgressAsyncResult *a, ErrorContext *context); + +} // namespace ns + +/// @brief C++ wrappers for the `nsdev` API. +/// @details Wraps: switch/services/ns.h. +namespace nsdev { + +/// NsApplicationContentMetaStatus +using ::NsApplicationContentMetaStatus; +/// ApplicationControlData +using ::NsApplicationControlData; +/// ApplicationControlSource +using ::NsApplicationControlSource; +/// ApplicationDeliveryInfo +using ::NsApplicationDeliveryInfo; +/// ApplicationOccupiedSize +using ::NsApplicationOccupiedSize; +/// ApplicationRecord +using ::NsApplicationRecord; +/// NsApplicationRightsOnClient +using ::NsApplicationRightsOnClient; +/// ApplicationView +using ::NsApplicationView; +/// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions. +using ::NsApplicationViewDeprecated; +/// NsApplicationViewWithPromotionInfo +using ::NsApplicationViewWithPromotionInfo; +/// BackgroundNetworkUpdateState +using ::NsBackgroundNetworkUpdateState; +/// DownloadTaskStatus +using ::NsDownloadTaskStatus; +/// EulaDataPath +using ::NsEulaDataPath; +/// LatestSystemUpdate +using ::NsLatestSystemUpdate; +/// LaunchProperties +using ::NsLaunchProperties; +/// ProgressAsyncResult +using ::NsProgressAsyncResult; +/// ProgressForDeleteUserSaveDataAll +using ::NsProgressForDeleteUserSaveDataAll; +/// ProgressMonitorForDeleteUserSaveDataAll +using ::NsProgressMonitorForDeleteUserSaveDataAll; +/// NsPromotionInfo +using ::NsPromotionInfo; +/// ReceiveApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsReceiveApplicationProgress; +/// RequestServerStopper +using ::NsRequestServerStopper; +/// SendApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsSendApplicationProgress; +/// ShellEvent +using ::NsShellEvent; +/// ShellEventInfo +using ::NsShellEventInfo; +/// SystemDeliveryInfo +using ::NsSystemDeliveryInfo; +/// SystemUpdateControl +using ::NsSystemUpdateControl; +/// SystemUpdateProgress. Commands which have this as output will return 0 with the output cleared, when no task is available. +using ::NsSystemUpdateProgress; + +///< [4.0.0+] +/// Initialize ns:dev. +Result Initialize(void); + +/// Initialize ns:dev. +void Exit(void); + +/// Gets the Service object for ns:dev. +Service* GetServiceSession(void); + +Result LaunchProgram(u64* out_pid, const NsLaunchProperties* properties, u32 flags); + +///< [1.0.0-9.2.0] +Result TerminateProcess(u64 pid); + +Result TerminateProgram(u64 tid); + +///< [1.0.0-9.2.0] +Result GetShellEvent(Event* out_event); + +///< Autoclear for nsdevShellEvent is always true. [1.0.0-9.2.0] +Result GetShellEventInfo(NsShellEventInfo* out); + +///< [1.0.0-9.2.0] +Result TerminateApplication(void); + +Result PrepareLaunchProgramFromHost(NsLaunchProperties* out, const char* path, size_t path_len); + +///< [1.0.0-9.2.0] +Result LaunchApplicationForDevelop(u64* out_pid, u64 application_id, u32 flags); + +///< [1.0.0-9.2.0] +Result LaunchApplicationFromHost(u64* out_pid, const char* path, size_t path_len, u32 flags); + +///< [10.0.0-17.0.1] +Result LaunchApplicationWithStorageIdForDevelop(u64* out_pid, u64 application_id, u32 flags, u8 app_storage_id, u8 patch_storage_id); + +///< [1.0.0-17.0.1] +Result IsSystemMemoryResourceLimitBoosted(bool* out); + +///< [6.0.0-8.1.0] +Result GetRunningApplicationProcessIdForDevelop(u64* out_pid); + +///< [6.0.0+] +Result SetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop(bool can_be_active); + +} // namespace nsdev + +/// @brief C++ wrappers for the `nssu` API. +/// @details Wraps: switch/services/ns.h. +namespace nssu { + +/// NsApplicationContentMetaStatus +using ::NsApplicationContentMetaStatus; +/// ApplicationControlData +using ::NsApplicationControlData; +/// ApplicationControlSource +using ::NsApplicationControlSource; +/// ApplicationDeliveryInfo +using ::NsApplicationDeliveryInfo; +/// ApplicationOccupiedSize +using ::NsApplicationOccupiedSize; +/// ApplicationRecord +using ::NsApplicationRecord; +/// NsApplicationRightsOnClient +using ::NsApplicationRightsOnClient; +/// ApplicationView +using ::NsApplicationView; +/// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions. +using ::NsApplicationViewDeprecated; +/// NsApplicationViewWithPromotionInfo +using ::NsApplicationViewWithPromotionInfo; +/// BackgroundNetworkUpdateState +using ::NsBackgroundNetworkUpdateState; +/// DownloadTaskStatus +using ::NsDownloadTaskStatus; +/// EulaDataPath +using ::NsEulaDataPath; +/// LatestSystemUpdate +using ::NsLatestSystemUpdate; +/// LaunchProperties +using ::NsLaunchProperties; +/// ProgressAsyncResult +using ::NsProgressAsyncResult; +/// ProgressForDeleteUserSaveDataAll +using ::NsProgressForDeleteUserSaveDataAll; +/// ProgressMonitorForDeleteUserSaveDataAll +using ::NsProgressMonitorForDeleteUserSaveDataAll; +/// NsPromotionInfo +using ::NsPromotionInfo; +/// ReceiveApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsReceiveApplicationProgress; +/// RequestServerStopper +using ::NsRequestServerStopper; +/// SendApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsSendApplicationProgress; +/// ShellEvent +using ::NsShellEvent; +/// ShellEventInfo +using ::NsShellEventInfo; +/// SystemDeliveryInfo +using ::NsSystemDeliveryInfo; +/// SystemUpdateControl +using ::NsSystemUpdateControl; +/// SystemUpdateProgress. Commands which have this as output will return 0 with the output cleared, when no task is available. +using ::NsSystemUpdateProgress; + +///< [6.0.0+] +/// Initialize ns:su. +Result Initialize(void); + +/// Exit ns:su. +void Exit(void); + +/// Gets the Service object for ns:su. +Service* GetServiceSession(void); + +/** + * @brief Gets the \ref NsBackgroundNetworkUpdateState. + * @note Internally this uses nim commands ListSystemUpdateTask and GetSystemUpdateTaskInfo to determine the output state. + * @param[out] out \ref NsBackgroundNetworkUpdateState + */ +Result GetBackgroundNetworkUpdateState(NsBackgroundNetworkUpdateState *out); + +/** + * @brief Opens a \ref NsSystemUpdateControl. + * @note Only 1 \ref NsSystemUpdateControl can be open at a time. + * @param[out] c \ref NsSystemUpdateControl + */ +Result OpenSystemUpdateControl(NsSystemUpdateControl *c); + +/** + * @brief Uses nim ListSystemUpdateTask, then uses the task with DestroySystemUpdateTask if it exists. Then this runs ExFat handling, updates state, and sets the same state flag as \ref nssuRequestBackgroundNetworkUpdate. + * @note Only usable when a \ref NsSystemUpdateControl isn't open. + */ +Result NotifyExFatDriverRequired(void); + +/** + * @brief ClearExFatDriverStatusForDebug + */ +Result ClearExFatDriverStatusForDebug(void); + +/** + * @brief RequestBackgroundNetworkUpdate + * @note Only usable when a \ref NsSystemUpdateControl isn't open. + */ +Result RequestBackgroundNetworkUpdate(void); + +/** + * @brief This checks whether a sysupdate is needed with the input \ref NcmContentMetaKey using NCM commands, if not this will just return 0. Otherwise, this will then run code which is identical to \ref nssuRequestBackgroundNetworkUpdate. + * @note Only usable when a \ref NsSystemUpdateControl isn't open. + * @param[in] key \ref NcmContentMetaKey + */ +Result NotifyBackgroundNetworkUpdate(const NcmContentMetaKey *key); + +/** + * @brief NotifyExFatDriverDownloadedForDebug + */ +Result NotifyExFatDriverDownloadedForDebug(void); + +/** + * @brief Gets an Event which can be signaled by \ref nssuNotifySystemUpdateForContentDelivery. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetSystemUpdateNotificationEventForContentDelivery(Event* out_event); + +/** + * @brief Signals the event returned by \ref nssuGetSystemUpdateNotificationEventForContentDelivery. + */ +Result NotifySystemUpdateForContentDelivery(void); + +/** + * @brief This does shutdown preparation. + * @note This is used by am-sysmodule, so generally there's no need to use this. + * @note Only available on [3.0.0+]. + */ +Result PrepareShutdown(void); + +/** + * @brief This uses nim ListSystemUpdateTask, then when a task is returned uses it with DestroySystemUpdateTask. + * @note Only available on [4.0.0+]. + */ +Result DestroySystemUpdateTask(void); + +/** + * @brief RequestSendSystemUpdate + * @note addr/port are little-endian. + * @note Only available on [4.0.0+]. + * @param[out] a \ref AsyncResult + * @param[in] addr Client IPv4 address. + * @param[in] port Socket port. qlaunch uses value 55556. + * @param[in] info \ref NsSystemDeliveryInfo + */ +Result RequestSendSystemUpdate(AsyncResult *a, u32 addr, u16 port, NsSystemDeliveryInfo *info); + +/** + * @brief GetSendSystemUpdateProgress + * @note Only available on [4.0.0+]. + * @param[out] out \ref NsSystemUpdateProgress + */ +Result GetSendSystemUpdateProgress(NsSystemUpdateProgress *out); + +/** + * @brief Close a \ref NsSystemUpdateControl. + * @param c \ref NsSystemUpdateControl + */ +void ControlClose(NsSystemUpdateControl *c); + +/** + * @brief Gets whether a network sysupdate was downloaded, with install pending. + * @param c \ref NsSystemUpdateControl + * @param[out] out Output flag. + */ +Result ControlHasDownloaded(NsSystemUpdateControl *c, bool* out); + +/** + * @brief RequestCheckLatestUpdate + * @param c \ref NsSystemUpdateControl + * @param[out] a \ref AsyncValue. The data that can be read from this is u8 \ref NsLatestSystemUpdate. + */ +Result ControlRequestCheckLatestUpdate(NsSystemUpdateControl *c, AsyncValue *a); + +/** + * @brief RequestDownloadLatestUpdate + * @param c \ref NsSystemUpdateControl + * @param[out] a \ref AsyncResult + */ +Result ControlRequestDownloadLatestUpdate(NsSystemUpdateControl *c, AsyncResult *a); + +/** + * @brief GetDownloadProgress + * @param c \ref NsSystemUpdateControl + * @param[out] out \ref NsSystemUpdateProgress + */ +Result ControlGetDownloadProgress(NsSystemUpdateControl *c, NsSystemUpdateProgress *out); + +/** + * @brief ApplyDownloadedUpdate + * @param c \ref NsSystemUpdateControl + */ +Result ControlApplyDownloadedUpdate(NsSystemUpdateControl *c); + +/** + * @brief RequestPrepareCardUpdate + * @param c \ref NsSystemUpdateControl + * @param[out] a \ref AsyncResult + */ +Result ControlRequestPrepareCardUpdate(NsSystemUpdateControl *c, AsyncResult *a); + +/** + * @brief GetPrepareCardUpdateProgress + * @note \ref nssuControlSetupCardUpdate / \ref nssuControlSetupCardUpdateViaSystemUpdater must have been used at some point prior to using this. + * @param c \ref NsSystemUpdateControl + * @param[out] out \ref NsSystemUpdateProgress + */ +Result ControlGetPrepareCardUpdateProgress(NsSystemUpdateControl *c, NsSystemUpdateProgress *out); + +/** + * @brief HasPreparedCardUpdate + * @note \ref nssuControlSetupCardUpdate / \ref nssuControlSetupCardUpdateViaSystemUpdater must have been used at some point prior to using this. + * @param c \ref NsSystemUpdateControl + * @param[out] out Output flag. + */ +Result ControlHasPreparedCardUpdate(NsSystemUpdateControl *c, bool* out); + +/** + * @brief ApplyCardUpdate + * @note \ref nssuControlSetupCardUpdate / \ref nssuControlSetupCardUpdateViaSystemUpdater must have been used at some point prior to using this. + * @param c \ref NsSystemUpdateControl + */ +Result ControlApplyCardUpdate(NsSystemUpdateControl *c); + +/** + * @brief Gets the filesize for the specified DownloadedEulaData. + * @note This mounts the Eula SystemData, then uses the file ":/". + * @param c \ref NsSystemUpdateControl + * @param[in] path EulaData path. + * @param[out] filesize Output filesize. + */ +Result ControlGetDownloadedEulaDataSize(NsSystemUpdateControl *c, const char* path, u64 *filesize); + +/** + * @brief Gets the specified DownloadedEulaData. + * @note See the note for \ref nssuControlGetDownloadedEulaDataSize. + * @param c \ref NsSystemUpdateControl + * @param[in] path EulaData path. + * @param[out] buffer Output buffer. + * @param[in] size Size of the output buffer, must be at least the output size from \ref nssuControlGetDownloadedEulaDataSize. + * @param[out] filesize Output filesize. + */ +Result ControlGetDownloadedEulaData(NsSystemUpdateControl *c, const char* path, void* buffer, size_t size, u64 *filesize); + +/** + * @brief SetupCardUpdate + * @param c \ref NsSystemUpdateControl + * @param[in] buffer TransferMemory buffer, when NULL this is automatically allocated. + * @param[in] size TransferMemory buffer size, see \ref NSSU_CARDUPDATE_TMEM_SIZE_DEFAULT. + */ +Result ControlSetupCardUpdate(NsSystemUpdateControl *c, void* buffer, size_t size); + +/** + * @brief Gets the filesize for the specified PreparedCardUpdateEulaData. + * @note See the note for \ref nssuControlGetDownloadedEulaDataSize. + * @param c \ref NsSystemUpdateControl + * @param[in] path EulaData path. + * @param[out] filesize Output filesize. + */ +Result ControlGetPreparedCardUpdateEulaDataSize(NsSystemUpdateControl *c, const char* path, u64 *filesize); + +/** + * @brief Gets the specified PreparedCardUpdateEulaData. + * @note See the note for \ref nssuControlGetDownloadedEulaDataSize. + * @param c \ref NsSystemUpdateControl + * @param[in] path EulaData path. + * @param[out] buffer Output buffer. + * @param[in] size Size of the output buffer, must be at least the output size from \ref nssuControlGetPreparedCardUpdateEulaDataSize. + * @param[out] filesize Output filesize. + */ +Result ControlGetPreparedCardUpdateEulaData(NsSystemUpdateControl *c, const char* path, void* buffer, size_t size, u64 *filesize); + +/** + * @brief SetupCardUpdateViaSystemUpdater + * @note Same as \ref nssuControlSetupCardUpdate, except this doesn't run the code for fs cmds GetGameCardHandle/GetGameCardUpdatePartitionInfo, and uses fs OpenRegisteredUpdatePartition instead of OpenGameCardFileSystem. + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[in] buffer TransferMemory buffer, when NULL this is automatically allocated. + * @param[in] size TransferMemory buffer size, see \ref NSSU_CARDUPDATE_TMEM_SIZE_DEFAULT. + */ +Result ControlSetupCardUpdateViaSystemUpdater(NsSystemUpdateControl *c, void* buffer, size_t size); + +/** + * @brief HasReceived + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[out] out Output flag. + */ +Result ControlHasReceived(NsSystemUpdateControl *c, bool* out); + +/** + * @brief RequestReceiveSystemUpdate + * @note addr/port are little-endian. + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[out] a \ref AsyncResult + * @param[in] addr Server IPv4 address. + * @param[in] port Socket port. qlaunch uses value 55556. + * @param[in] info \ref NsSystemDeliveryInfo + */ +Result ControlRequestReceiveSystemUpdate(NsSystemUpdateControl *c, AsyncResult *a, u32 addr, u16 port, NsSystemDeliveryInfo *info); + +/** + * @brief GetReceiveProgress + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[out] out \ref NsSystemUpdateProgress + */ +Result ControlGetReceiveProgress(NsSystemUpdateControl *c, NsSystemUpdateProgress *out); + +/** + * @brief ApplyReceivedUpdate + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + */ +Result ControlApplyReceivedUpdate(NsSystemUpdateControl *c); + +/** + * @brief Gets the filesize for the specified ReceivedEulaData. + * @note See the note for \ref nssuControlGetDownloadedEulaDataSize. + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[in] path EulaData path. + * @param[out] filesize Output filesize. + */ +Result ControlGetReceivedEulaDataSize(NsSystemUpdateControl *c, const char* path, u64 *filesize); + +/** + * @brief Gets the specified ReceivedEulaData. + * @note See the note for \ref nssuControlGetDownloadedEulaDataSize. + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[in] path EulaData path. + * @param[out] buffer Output buffer. + * @param[in] size Size of the output buffer, must be at least the output size from \ref nssuControlGetReceivedEulaDataSize. + * @param[out] filesize Output filesize. + */ +Result ControlGetReceivedEulaData(NsSystemUpdateControl *c, const char* path, void* buffer, size_t size, u64 *filesize); + +/** + * @brief Does setup for ReceiveSystemUpdate by using the same nim cmds as \ref nssuDestroySystemUpdateTask. + * @note qlaunch uses this before \ref nssuControlRequestReceiveSystemUpdate. + * @note Only available on [4.0.0+]. + * @param c \ref NsSystemUpdateControl + */ +Result ControlSetupToReceiveSystemUpdate(NsSystemUpdateControl *c); + +/** + * @brief RequestCheckLatestUpdateIncludesRebootlessUpdate + * @note Only available on [6.0.0+]. + * @param c \ref NsSystemUpdateControl + * @param[out] a \ref AsyncValue + */ +Result ControlRequestCheckLatestUpdateIncludesRebootlessUpdate(NsSystemUpdateControl *c, AsyncValue *a); + +} // namespace nssu + +/// @brief C++ wrappers for the `nsvm` API. +/// @details Wraps: switch/services/ns.h. +namespace nsvm { + +/// NsApplicationContentMetaStatus +using ::NsApplicationContentMetaStatus; +/// ApplicationControlData +using ::NsApplicationControlData; +/// ApplicationControlSource +using ::NsApplicationControlSource; +/// ApplicationDeliveryInfo +using ::NsApplicationDeliveryInfo; +/// ApplicationOccupiedSize +using ::NsApplicationOccupiedSize; +/// ApplicationRecord +using ::NsApplicationRecord; +/// NsApplicationRightsOnClient +using ::NsApplicationRightsOnClient; +/// ApplicationView +using ::NsApplicationView; +/// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions. +using ::NsApplicationViewDeprecated; +/// NsApplicationViewWithPromotionInfo +using ::NsApplicationViewWithPromotionInfo; +/// BackgroundNetworkUpdateState +using ::NsBackgroundNetworkUpdateState; +/// DownloadTaskStatus +using ::NsDownloadTaskStatus; +/// EulaDataPath +using ::NsEulaDataPath; +/// LatestSystemUpdate +using ::NsLatestSystemUpdate; +/// LaunchProperties +using ::NsLaunchProperties; +/// ProgressAsyncResult +using ::NsProgressAsyncResult; +/// ProgressForDeleteUserSaveDataAll +using ::NsProgressForDeleteUserSaveDataAll; +/// ProgressMonitorForDeleteUserSaveDataAll +using ::NsProgressMonitorForDeleteUserSaveDataAll; +/// NsPromotionInfo +using ::NsPromotionInfo; +/// ReceiveApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsReceiveApplicationProgress; +/// RequestServerStopper +using ::NsRequestServerStopper; +/// SendApplicationProgress. Same as \ref NsSystemUpdateProgress, except cmds which return this will return actual errors on failure, instead of returning 0 with a cleared struct. +using ::NsSendApplicationProgress; +/// ShellEvent +using ::NsShellEvent; +/// ShellEventInfo +using ::NsShellEventInfo; +/// SystemDeliveryInfo +using ::NsSystemDeliveryInfo; +/// SystemUpdateControl +using ::NsSystemUpdateControl; +/// SystemUpdateProgress. Commands which have this as output will return 0 with the output cleared, when no task is available. +using ::NsSystemUpdateProgress; + +/// Initialize ns:vm. On pre-3.0.0 this must be used with \ref nsInitialize. +Result Initialize(void); + +/// Exit ns:vm. +void Exit(void); + +/// Gets the Service object for ns:vm. This is only initialized on [3.0.0+]. +Service* GetServiceSession(void); + +Result NeedsUpdateVulnerability(bool *out); + +Result GetSafeSystemVersion(NcmContentMetaKey *out); + +} // namespace nsvm + +/// @brief C++ wrappers for the `nv` API. +/// @details Wraps: switch/nvidia/address_space.h, switch/nvidia/channel.h, switch/nvidia/fence.h, switch/nvidia/gpu.h, switch/nvidia/gpu_channel.h, switch/nvidia/map.h, switch/services/nv.h. +namespace nv { + +using ::NvAddressSpace; +using ::NvChannel; +using ::NvEventId; +using ::NvFence; +using ::NvGpuChannel; +using ::NvMap; +using ::NvMultiFence; +/// NvServiceType, for __nx_nv_service_type. +using ::NvServiceType; + +Result AddressSpaceCreate(NvAddressSpace* a, u32 page_size); + +void AddressSpaceClose(NvAddressSpace* a); + +Result AddressSpaceAlloc(NvAddressSpace* a, bool sparse, u64 size, iova_t* iova_out); + +Result AddressSpaceAllocFixed(NvAddressSpace* a, bool sparse, u64 size, iova_t iova); + +Result AddressSpaceFree(NvAddressSpace* a, iova_t iova, u64 size); + +Result AddressSpaceMap(NvAddressSpace* a, u32 nvmap_handle, bool is_gpu_cacheable, NvKind kind, iova_t* iova_out); + +Result AddressSpaceMapFixed(NvAddressSpace* a, u32 nvmap_handle, bool is_gpu_cacheable, NvKind kind, iova_t iova); + +Result AddressSpaceModify(NvAddressSpace* a, iova_t iova, u64 offset, u64 size, NvKind kind); + +Result AddressSpaceUnmap(NvAddressSpace* a, iova_t iova); + +Result ChannelCreate(NvChannel* c, const char* dev); + +void ChannelClose(NvChannel* c); + +Result ChannelSetPriority(NvChannel* c, NvChannelPriority prio); + +Result ChannelSetTimeout(NvChannel* c, u32 timeout); + +Result FenceInit(void); + +void FenceExit(void); + +u32 FenceGetFd(void); + +Result FenceWait(NvFence* f, s32 timeout_us); + +void MultiFenceCreate(NvMultiFence* mf, const NvFence* fence); + +Result MultiFenceWait(NvMultiFence* mf, s32 timeout_us); + +Result GpuInit(void); + +void GpuExit(void); + +const nvioctl_gpu_characteristics* GpuGetCharacteristics(void); + +u32 GpuGetZcullCtxSize(void); + +const nvioctl_zcull_info* GpuGetZcullInfo(void); + +const u32* GpuGetTpcMasks(u32 *num_masks_out); + +Result GpuZbcGetActiveSlotMask(u32 *out_slot, u32 *out_mask); + +Result GpuZbcAddColor(const u32 color_l2[4], const u32 color_ds[4], u32 format); + +Result GpuZbcAddDepth(float depth); + +Result GpuGetTimestamp(u64 *ts); + +Result GpuChannelCreate(NvGpuChannel* c, struct NvAddressSpace* as, NvChannelPriority prio); + +void GpuChannelClose(NvGpuChannel* c); + +Result GpuChannelZcullBind(NvGpuChannel* c, iova_t iova); + +Result GpuChannelAppendEntry(NvGpuChannel* c, iova_t start, size_t num_cmds, u32 flags, u32 flush_threshold); + +Result GpuChannelKickoff(NvGpuChannel* c); + +Result GpuChannelGetErrorNotification(NvGpuChannel* c, NvNotification* notif); + +Result GpuChannelGetErrorInfo(NvGpuChannel* c, NvError* error); + +u32 GpuChannelGetSyncpointId(NvGpuChannel* c); + +void GpuChannelGetFence(NvGpuChannel* c, NvFence* fence_out); + +void GpuChannelIncrFence(NvGpuChannel* c); + +Result MapInit(void); + +u32 MapGetFd(void); + +void MapExit(void); + +Result MapCreate(NvMap* m, void* cpu_addr, u32 size, u32 align, NvKind kind, bool is_cpu_cacheable); + +Result MapLoadRemote(NvMap* m, u32 id); + +void MapClose(NvMap* m); + +u32 MapGetHandle(NvMap* m); + +u32 MapGetId(NvMap* m); + +u32 MapGetSize(NvMap* m); + +void* MapGetCpuAddr(NvMap* m); + +bool MapIsRemote(NvMap* m); + +NvKind MapGetKind(NvMap* m); + +/// Initialize nvdrv*. +Result Initialize(void); + +/// Exit nvdrv*. +void Exit(void); + +/// Gets the Service object for the actual nvdrv* service session. +Service* GetServiceSession(void); + +Result Open(u32 *fd, const char *devicepath); + +Result Ioctl(u32 fd, u32 request, void* argp); + +Result Ioctl2(u32 fd, u32 request, void* argp, const void* inbuf, size_t inbuf_size); + +///< [3.0.0+] +Result Ioctl3(u32 fd, u32 request, void* argp, void* outbuf, size_t outbuf_size); + +///< [3.0.0+] +Result Close(u32 fd); + +Result QueryEvent(u32 fd, u32 event_id, Event *event_out); + +Result ConvertError(int rc); + +} // namespace nv + +/// @brief C++ wrappers for the `nvioctl` API. +/// @details Wraps: switch/nvidia/ioctl.h. +namespace nvioctl { + +using ::NvAllocSpaceFlags; +using ::NvChannelPriority; +using ::NvClassNumber; +using ::NvError; +using ::nvioctl_clk_rate; +using ::nvioctl_cmdbuf; +using ::nvioctl_command_buffer_map; +using ::nvioctl_fence; +using ::nvioctl_gpfifo_entry; +using ::nvioctl_gpu_characteristics; +using ::nvioctl_gpu_time; +using ::nvioctl_reloc; +using ::nvioctl_reloc_shift; +using ::nvioctl_syncpt_incr; +using ::nvioctl_va_region; +using ::nvioctl_zbc_entry; +using ::nvioctl_zbc_slot_mask; +using ::nvioctl_zcull_info; +using ::NvMapBufferFlags; +using ::NvMapParam; +using ::NvNotification; +using ::NvNotificationType; +using ::NvZcullConfig; + +Result NvhostCtrl_SyncptRead(u32 fd, u32 id, u32* out); + +Result NvhostCtrl_SyncptIncr(u32 fd, u32 id); + +Result NvhostCtrl_SyncptWait(u32 fd, u32 id, u32 threshold, u32 timeout); + +Result NvhostCtrl_EventSignal(u32 fd, u32 event_id); + +Result NvhostCtrl_EventWait(u32 fd, u32 syncpt_id, u32 threshold, s32 timeout, u32 event_id, u32 *out); + +Result NvhostCtrl_EventWaitAsync(u32 fd, u32 syncpt_id, u32 threshold, s32 timeout, u32 event_id); + +Result NvhostCtrl_EventRegister(u32 fd, u32 event_id); + +Result NvhostCtrl_EventUnregister(u32 fd, u32 event_id); + +Result NvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out); + +Result NvhostCtrlGpu_ZCullGetInfo(u32 fd, nvioctl_zcull_info *out); + +Result NvhostCtrlGpu_ZbcSetTable(u32 fd, const u32 color_ds[4], const u32 color_l2[4], u32 depth, u32 format, u32 type); + +Result NvhostCtrlGpu_ZbcQueryTable(u32 fd, u32 index, nvioctl_zbc_entry *out); + +Result NvhostCtrlGpu_GetCharacteristics(u32 fd, nvioctl_gpu_characteristics *out); + +Result NvhostCtrlGpu_GetTpcMasks(u32 fd, void *buffer, size_t size); + +Result NvhostCtrlGpu_ZbcGetActiveSlotMask(u32 fd, nvioctl_zbc_slot_mask *out); + +Result NvhostCtrlGpu_GetGpuTime(u32 fd, nvioctl_gpu_time *out); + +Result NvhostAsGpu_BindChannel(u32 fd, u32 channel_fd); + +Result NvhostAsGpu_AllocSpace(u32 fd, u32 pages, u32 page_size, u32 flags, u64 align_or_offset, u64 *offset); + +Result NvhostAsGpu_FreeSpace(u32 fd, u64 offset, u32 pages, u32 page_size); + +Result NvhostAsGpu_MapBufferEx(u32 fd, u32 flags, u32 kind, u32 nvmap_handle, u32 page_size, u64 buffer_offset, u64 mapping_size, u64 input_offset, u64 *offset); + +Result NvhostAsGpu_UnmapBuffer(u32 fd, u64 offset); + +Result NvhostAsGpu_GetVARegions(u32 fd, nvioctl_va_region regions[2]); + +Result NvhostAsGpu_InitializeEx(u32 fd, u32 flags, u32 big_page_size); + +Result Nvmap_Create(u32 fd, u32 size, u32 *nvmap_handle); + +Result Nvmap_FromId(u32 fd, u32 id, u32 *nvmap_handle); + +Result Nvmap_Alloc(u32 fd, u32 nvmap_handle, u32 heapmask, u32 flags, u32 align, u8 kind, void* addr); + +Result Nvmap_Free(u32 fd, u32 nvmap_handle); + +Result Nvmap_Param(u32 fd, u32 nvmap_handle, NvMapParam param, u32 *result); + +Result Nvmap_GetId(u32 fd, u32 nvmap_handle, u32 *id); + +Result Channel_SetNvmapFd(u32 fd, u32 nvmap_fd); + +Result Channel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_inout); + +Result Channel_KickoffPb(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_inout); + +Result Channel_AllocObjCtx(u32 fd, u32 class_num, u32 flags, u64* id_out); + +Result Channel_ZCullBind(u32 fd, u64 gpu_va, u32 mode); + +Result Channel_SetErrorNotifier(u32 fd, u32 enable); + +Result Channel_GetErrorInfo(u32 fd, NvError* out); + +Result Channel_GetErrorNotification(u32 fd, NvNotification* out); + +Result Channel_SetPriority(u32 fd, u32 priority); + +Result Channel_SetTimeout(u32 fd, u32 timeout); + +Result Channel_AllocGpfifoEx2(u32 fd, u32 num_entries, u32 flags, u32 unk0, u32 unk1, u32 unk2, u32 unk3, nvioctl_fence *fence_out); + +Result Channel_SetUserData(u32 fd, void* addr); + +Result Channel_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 Channel_GetSyncpt(u32 fd, u32 module_id, u32 *syncpt); + +Result Channel_GetModuleClockRate(u32 fd, u32 module_id, u32 *freq); + +Result Channel_SetModuleClockRate(u32 fd, u32 module_id, u32 freq); + +Result Channel_MapCommandBuffer(u32 fd, nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed); + +Result Channel_UnmapCommandBuffer(u32 fd, const nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed); + +Result Channel_SetSubmitTimeout(u32 fd, u32 timeout); + +} // namespace nvioctl + +/// @brief C++ wrappers for the `nwindow` API. +/// @details Wraps: switch/display/native_window.h. +namespace nwindow { + +/// Native window structure. +using ::NWindow; + +/// Checks whether a pointer refers to a valid \ref NWindow object. +bool IsValid(NWindow* nw); + +/** + * @brief Retrieves the default \ref NWindow object. + * @return Pointer to the default \ref NWindow object. + * @note When this function is used/referenced, libnx will initialize VI services + * and create a \ref NWindow object from a \ref ViLayer created on the default \ref ViDisplay; + * all of this happening automatically during application startup (i.e. before main is called). + * If creating the default \ref NWindow fails, libnx will throw a LibnxError_BadGfxInit fatal error. + * Likewise, after main returns (or exit is called) libnx will clean up all resources used by it. + */ +NWindow* GetDefault(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 Create(NWindow* nw, Service* binder_session, s32 binder_id, bool producer_controlled_by_app); + +/** + * @brief Creates a \ref NWindow operating on a \ref ViLayer. + * @param[out] nw Output \ref NWindow structure. + * @param[in] layer Pointer to \ref ViLayer structure (such as the one returned by \ref viCreateLayer). + */ +Result CreateFromLayer(NWindow* nw, const ViLayer* layer); + +/// Closes a \ref NWindow, freeing all resources associated with it. +void Close(NWindow* nw); + +/** + * @brief Retrieves the dimensions of a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[out] out_width Output variable containing the width of the \ref NWindow. + * @param[out] out_height Output variable containing the height of the \ref NWindow. + * @note After creation, a \ref NWindow reports a default size (usually 1280x720). + * This size can be overriden by calling \ref nwindowSetDimensions. + */ +Result GetDimensions(NWindow* nw, u32* out_width, u32* out_height); + +/** + * @brief Sets the dimensions of a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] width Desired width of the \ref NWindow. + * @param[in] height Desired width of the \ref NWindow. + * @note This function cannot be called when there are buffers registered with the \ref NWindow. + */ +Result SetDimensions(NWindow* nw, u32 width, u32 height); + +/** + * @brief Configures the crop applied to images presented through a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] left X coordinate of the left margin of the crop bounding box. + * @param[in] top Y coordinate of the top margin of the crop bounding box. + * @param[in] right X coordinate of the right margin of the crop bounding box. + * @param[in] bottom Y coordinate of the bottom margin of the crop bounding box. + * @note Passing zero to all parameters disables the crop functionality. This is also the default. + * @note The bounding box defined by the parameters will be adjusted to fit within the dimensions of the \ref NWindow. + * @note \p left must be less or equal than \p right. + * @note \p top must be less or equal than \p bottom. + */ +Result SetCrop(NWindow* nw, s32 left, s32 top, s32 right, s32 bottom); + +/** + * @brief Configures the transformation applied to images presented through a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] transform Android transformation mode (see NATIVE_WINDOW_TRANSFORM_* enum) + * @note The default transformation is 0 (i.e. no transformation applied) + */ +Result SetTransform(NWindow* nw, u32 transform); + +/** + * @brief Configures the swap interval of a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] swap_interval Value specifying the number of display refreshes (VBlanks) that must occur between presenting images. + * @note The default swap interval is 1. + * @note If the \ref NWindow has three or more buffers configured (with \ref nwindowConfigureBuffer), it is possible to pass 0 + * to disable the swap interval feature and present images as fast as allowed by the compositor. Otherwise, the system + * enforces a minimum of 1 as the swap interval. + */ +Result SetSwapInterval(NWindow* nw, u32 swap_interval); + +/// Checks whether the consumer of a \ref NWindow is running behind. +bool IsConsumerRunningBehind(NWindow* nw); + +/** + * @brief Registers a \ref NvGraphicBuffer with a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] slot ID of the slot to configure (starting from 0). + * @param[in] buf Pointer to \ref NvGraphicBuffer structure. + * @note When a buffer is registered, it is added to the internal queue of buffers used for presenting. + * @note All buffers registered with a \ref NWindow must have the same dimensions, format and usage. + * If \ref nwindowSetDimensions has not been previously called, the \ref NWindow will automatically + * adopt the dimensions of the first buffer registered with it. Otherwise, said buffer will need + * to match the dimensions that were previously configured. + */ +Result ConfigureBuffer(NWindow* nw, s32 slot, NvGraphicBuffer* buf); + +/** + * @brief Dequeues a buffer from a \ref NWindow. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[out] out_slot Output variable containing the ID of the slot that has been dequeued. + * @param[out] out_fence Output variable containing a \ref NvMultiFence that will be signalled by + * the compositor when the buffer is ready to be written to. Pass NULL to wait instead + * on this fence before this function returns. + * @note For \p out_fence=NULL to work, \ref nvFenceInit must have been previously called. + */ +Result DequeueBuffer(NWindow* nw, s32* out_slot, NvMultiFence* out_fence); + +/** + * @brief Cancels a buffer previously dequeued with \ref nwindowDequeueBuffer. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] slot ID of the slot to cancel. This must match the output of the previous \ref nwindowDequeueBuffer call. + * @param[in] fence Pointer to the \ref NvMultiFence that will be waited on by the compositor before cancelling the buffer. + * Pass NULL if there is no such fence. + */ +Result CancelBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence); + +/** + * @brief Queues a buffer previously dequeued with \ref nwindowDequeueBuffer, making it ready for presentation. + * @param[in] nw Pointer to \ref NWindow structure. + * @param[in] slot ID of the slot to queue. This must match the output of the previous \ref nwindowDequeueBuffer call. + * @param[in] fence Pointer to the \ref NvMultiFence that will be waited on by the compositor before queuing/presenting the buffer. + * Pass NULL if there is no such fence. + */ +Result QueueBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence); + +/// Releases all buffers registered with a \ref NWindow. +Result ReleaseBuffers(NWindow* nw); + +} // namespace nwindow + +/// @brief C++ wrappers for the `nxlink` API. +/// @details Wraps: switch/runtime/nxlink.h. +namespace nxlink { + +using ::in_addr; +/// Address of the host connected through nxlink +using ::__nxlink_host; + +/** + * @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 ConnectToHost(bool redirStdout, bool redirStderr); + +/// Same as \ref nxlinkConnectToHost but redirecting both stdout/stderr. +int Stdio(void); + +/// Same as \ref nxlinkConnectToHost but redirecting only stderr. +int StdioForDebug(void); + +} // namespace nxlink + +/// @brief C++ wrappers for the `omm` API. +/// @details Wraps: switch/services/omm.h. +namespace omm { + +///OperationMode +using ::OmmOperationMode; +///OperationModePolicy +using ::OmmOperationModePolicy; + +/// Initialize omm. +Result Initialize(void); + +/// Exit omm. +void Exit(void); + +/// Gets the Service for omm. +Service* GetServiceSession(void); + +/// Returns a DefaultDisplayResolution. Only available on [3.0.0+]. +Result GetDefaultDisplayResolution(s32* width, s32* height); + +/// Returns an OmmOperationMode. +Result GetOperationMode(OmmOperationMode* s); + +/// Takes an OmmOperationModePolicy. Only available on [3.0.0+]. +Result SetOperationModePolicy(OmmOperationModePolicy value); + +} // namespace omm + +/// @brief C++ wrappers for the `ovlnrcv` API. +/// @details Wraps: switch/services/ovln.h. +namespace ovlnrcv { + +/// EnqueuePosition +using ::OvlnEnqueuePosition; +/// OverflowOption +using ::OvlnOverflowOption; +/// QueueAttribute +using ::OvlnQueueAttribute; +/// RawMessage +using ::OvlnRawMessage; +/// Receiver +using ::OvlnReceiver; +/// Sender +using ::OvlnSender; +/// SendOption +using ::OvlnSendOption; +/// SourceName +using ::OvlnSourceName; + +/// Initialize ovln:rcv. +Result Initialize(void); + +/// Exit ovln:rcv. +void Exit(void); + +/// Gets the Service object for the actual ovln:rcv service session. +Service* GetServiceSession(void); + +/** + * @brief OpenReceiver + * @param[out] r \ref OvlnReceiver + */ +Result OpenReceiver(OvlnReceiver *r); + +/** + * @brief CloseReceiver + * @param[in] r \ref OvlnReceiver + */ +void CloseReceiver(OvlnReceiver *r); + +/** + * @brief AddSource + * @param[in] r \ref OvlnReceiver + * @param[in] name \ref OvlnSourceName + */ +Result AddSource(OvlnReceiver *r, const OvlnSourceName *name); + +/** + * @brief RemoveSource + * @param[in] r \ref OvlnReceiver + * @param[in] name \ref OvlnSourceName + */ +Result RemoveSource(OvlnReceiver *r, const OvlnSourceName *name); + +/** + * @brief GetReceiveEventHandle + * @param[in] r \ref OvlnReceiver + * @param[out] out_event Output Event with autoclear=true. + */ +Result GetReceiveEventHandle(OvlnReceiver *r, Event* out_event); + +/** + * @brief Receive + * @param[in] r \ref OvlnReceiver + * @param[out] message \ref OvlnRawMessage + */ +Result Receive(OvlnReceiver *r, OvlnRawMessage *message); + +/** + * @brief ReceiveWithTick + * @param[in] r \ref OvlnReceiver + * @param[out] message \ref OvlnRawMessage + * @param[out] tick System tick. + */ +Result ReceiveWithTick(OvlnReceiver *r, OvlnRawMessage *message, s64 *tick); + +} // namespace ovlnrcv + +/// @brief C++ wrappers for the `ovlnsnd` API. +/// @details Wraps: switch/services/ovln.h. +namespace ovlnsnd { + +/// EnqueuePosition +using ::OvlnEnqueuePosition; +/// OverflowOption +using ::OvlnOverflowOption; +/// QueueAttribute +using ::OvlnQueueAttribute; +/// RawMessage +using ::OvlnRawMessage; +/// Receiver +using ::OvlnReceiver; +/// Sender +using ::OvlnSender; +/// SendOption +using ::OvlnSendOption; +/// SourceName +using ::OvlnSourceName; + +/// Initialize ovln:snd. +Result Initialize(void); + +/// Exit ovln:snd. +void Exit(void); + +/// Gets the Service object for the actual ovln:snd service session. +Service* GetServiceSession(void); + +/** + * @brief OpenSender + * @param[in] s \ref OvlnSender + * @param[in] name \ref OvlnSourceName + * @param[in] attribute \ref OvlnQueueAttribute + */ +Result OpenSender(OvlnSender *s, const OvlnSourceName *name, OvlnQueueAttribute attribute); + +/** + * @brief CloseSender + * @param[in] s \ref OvlnSender + */ +void CloseSender(OvlnSender *s); + +/** + * @brief Send + * @param[in] s \ref OvlnSender + * @param[in] option \ref OvlnSendOption + * @param[in] message \ref OvlnRawMessage + */ +Result Send(OvlnSender *s, OvlnSendOption option, const OvlnRawMessage *message); + +/** + * @brief GetUnreceivedMessageCount + * @param[in] s \ref OvlnSender + * @param[out] count number of unreceived messages. + */ +Result GetUnreceivedMessageCount(OvlnSender *s, u32 *count); + +} // namespace ovlnsnd + +/// @brief C++ wrappers for the `pad` API. +/// @details Wraps: switch/runtime/pad.h. +namespace pad { + +/// Pad button repeater state object. +using ::PadRepeater; +/// Pad state object. +using ::PadState; + +/** + * @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 ConfigureInput(u32 max_players, u32 style_set); + +/** + * @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 InitializeWithMask(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. + */ +void InitializeAny(PadState* pad); + +/** + * @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. + */ +void InitializeDefault(PadState* pad); + +/** + * @brief Updates pad state by reading from the controller input sources specified during initialization. + * @param[in] pad Pointer to \ref PadState. + */ +void Update(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. + */ +bool IsHandheld(const PadState* pad); + +/** + * @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. + */ +bool IsNpadActive(const PadState* pad, HidNpadIdType id); + +/** + * @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. + */ +u32 GetStyleSet(const PadState* pad); + +/** + * @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. + */ +u32 GetAttributes(const PadState* pad); + +/** + * @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. + */ +bool IsConnected(const PadState* pad); + +/** + * @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. + */ +u64 GetButtons(const PadState* pad); + +/** + * @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. + */ +u64 GetButtonsDown(const PadState* pad); + +/** + * @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. + */ +u64 GetButtonsUp(const PadState* pad); + +/** + * @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. + */ +HidAnalogStickState GetStickPos(const PadState* pad, unsigned 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. + */ +u32 GetGcTriggerPos(const PadState* pad, unsigned 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. + */ +void RepeaterInitialize(PadRepeater* r, u16 delay, u16 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 RepeaterUpdate(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. + */ +u64 RepeaterGetButtons(const PadRepeater* r); + +} // namespace pad + +/// @brief C++ wrappers for the `parcel` API. +/// @details Wraps: switch/display/parcel.h. +namespace parcel { + +using ::Parcel; +using ::ParcelHeader; + +void Create(Parcel *ctx); + +Result Transact(Binder *session, u32 code, Parcel *in_parcel, Parcel *reply_parcel); + +void* WriteData(Parcel *ctx, const void* data, size_t data_size); + +void* ReadData(Parcel *ctx, void* data, size_t data_size); + +void WriteInt32(Parcel *ctx, s32 val); + +void WriteUInt32(Parcel *ctx, u32 val); + +void WriteString16(Parcel *ctx, const char *str); + +s32 ReadInt32(Parcel *ctx); + +u32 ReadUInt32(Parcel *ctx); + +void WriteInterfaceToken(Parcel *ctx, const char *str); + +void* ReadFlattenedObject(Parcel *ctx, size_t *size); + +void* WriteFlattenedObject(Parcel *ctx, const void* data, size_t size); + +} // namespace parcel + +/// @brief C++ wrappers for the `pctl` API. +/// @details Wraps: switch/services/pctl.h. +namespace pctl { + +using ::PctlRestrictionSettings; + +/// Initialize pctl. +Result Initialize(void); + +/// Exit pctl. +void Exit(void); + +/// Gets the Service object for the actual pctl service session. +Service* GetServiceSession(void); + +/// Gets the Service object for IParentalControlService. +Service* GetServiceSession_Service(void); + +/// Gets whether Parental Controls restrictions are temporarily unlocked. +Result IsRestrictionTemporaryUnlocked(bool *flag); + +/// Confirm whether VrMode is allowed. Only available with [4.0.0+]. +Result ConfirmStereoVisionPermission(void); + +/// Gets whether Parental Controls are enabled. +Result IsRestrictionEnabled(bool *flag); + +/// Gets whether Parental Controls are enabled. +Result GetSafetyLevel(u32 *safety_level); + +/// Returns the current restrictions settings. +Result GetCurrentSettings(PctlRestrictionSettings *settings); + +/// Gets the count of applications that have free communication. +Result GetFreeCommunicationApplicationListCount(u32 *count); + +/// Reset the confirmation done by \ref pctlConfirmStereoVisionPermission. Only available with [5.0.0+]. +Result ResetConfirmedStereoVisionPermission(void); + +/// Gets whether VrMode is allowed. Only available with [5.0.0+]. +Result IsStereoVisionPermitted(bool *flag); + +/// Confirm whether pairing is active. +Result IsPairingActive(bool *flag); + +/// Returns the synchronization event. +Result GetSynchronizationEvent(Event* out_event); + +/// Returns the supension event. +Result GetPlayTimerEventToRequestSuspension(Event* out_event); + +/// Confirm whether play timer alarm is disabled. Only available with [4.0.0+]. +Result IsPlayTimerAlarmDisabled(bool *flag); + +/// Returns the unlinked event. +Result GetUnlinkedEvent(Event* out_event); + +} // namespace pctl + +/// @brief C++ wrappers for the `pctlauth` API. +/// @details Wraps: switch/applets/pctlauth.h. +namespace pctlauth { + +/// Input arg storage for the applet. +using ::PctlAuthArg; +/// Type values for PctlAuthArg::type. +using ::PctlAuthType; + +/** + * @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 Show(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 ShowEx(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 ShowForConfiguration(void); + +/** + * @brief Launches the applet for registering the Parental Controls PIN. + */ +Result RegisterPasscode(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 ChangePasscode(void); + +} // namespace pctlauth + +/// @brief C++ wrappers for the `pcv` API. +/// @details Wraps: switch/services/pcv.h. +namespace pcv { + +using ::PcvClockRatesListType; +using ::PcvModule; +/// Module id returned by [8.0.0+] pcv services +/// See also: https://switchbrew.org/wiki/PCV_services#Modules +using ::PcvModuleId; + +/// Initialize pcv. +Result Initialize(void); + +/// Exit pcv. +void Exit(void); + +/// Gets the Service object for the actual pcv service session. +Service* GetServiceSession(void); + +Result GetModuleId(PcvModuleId *module_id, PcvModule module); + +/// Only available on [1.0.0-7.0.1]. +Result GetClockRate(PcvModule module, u32 *out_hz); + +/// Only available on [1.0.0-7.0.1]. +Result SetClockRate(PcvModule module, u32 hz); + +/// Only available on [1.0.0-7.0.1]. +Result SetVoltageEnabled(u32 power_domain, bool state); + +/// Only available on [1.0.0-7.0.1]. +Result GetVoltageEnabled(bool *isEnabled, u32 power_domain); + +/// Only available on [1.0.0-7.0.1]. +Result GetPossibleClockRates(PcvModule module, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count); + +} // namespace pcv + +/// @brief C++ wrappers for the `pdm` API. +/// @details Wraps: switch/services/pdm.h. +namespace pdm { + +/// AccountEvent. AccountEvent for [16.0.0+], converted from the older structs when needed. +using ::PdmAccountEvent; +/// AccountEventV10. AccountEvent for [10.0.0-15.0.1], converted to \ref PdmAccountEvent when needed. +using ::PdmAccountEventV10; +/// AccountEventV3. AccountEvent for [3.0.0-9.2.0], converted to \ref PdmAccountEvent when needed. +using ::PdmAccountEventV3; +/// AccountPlayEvent. +/// This is the raw entry struct directly read from FS, without any entry filtering. This is separate from \ref PdmPlayEvent. +using ::PdmAccountPlayEvent; +/// AppletEvent. AppletEvent for [16.0.0+], converted from \ref PdmAppletEventV1 on [1.0.0-15.0.1]. +using ::PdmAppletEvent; +/// AppletEventType +using ::PdmAppletEventType; +/// AppletEventV1. AppletEvent for [1.0.0-15.0.1], converted to \ref PdmAppletEvent when needed. +/// Timestamp format, converted from PosixTime: total minutes since epoch UTC 1999/12/31 00:00:00. +/// See \ref pdmPlayTimestampToPosix. +using ::PdmAppletEventV1; +/// ApplicationPlayStatistics +using ::PdmApplicationPlayStatistics; +/// LastPlayTime. +/// This contains data from the last time the application was played. +using ::PdmLastPlayTime; +/// PlayEvent. +/// This is the raw entry struct directly read from FS, without any entry filtering. +using ::PdmPlayEvent; +/// PlayEventType +using ::PdmPlayEventType; +/// PlayLogPolicy +using ::PdmPlayLogPolicy; +/// PlayStatistics. PlayStatistics for [16.0.0+], converted from \ref PdmPlayStatisticsV1 on [1.0.0-15.0.1]. +using ::PdmPlayStatistics; +/// PlayStatisticsV1. PlayStatistics for [1.0.0-15.0.1], converted to \ref PdmPlayStatistics when needed. +using ::PdmPlayStatisticsV1; + +/** + * @brief Helper function which converts a Play timestamp from the Pdm*Event structs to POSIX. + * @param[in] timestamp Input timestamp. + */ +u64 PlayTimestampToPosix(u32 timestamp); + +} // namespace pdm + +/// @brief C++ wrappers for the `pdmqry` API. +/// @details Wraps: switch/services/pdm.h. +namespace pdmqry { + +/// AccountEvent. AccountEvent for [16.0.0+], converted from the older structs when needed. +using ::PdmAccountEvent; +/// AccountEventV10. AccountEvent for [10.0.0-15.0.1], converted to \ref PdmAccountEvent when needed. +using ::PdmAccountEventV10; +/// AccountEventV3. AccountEvent for [3.0.0-9.2.0], converted to \ref PdmAccountEvent when needed. +using ::PdmAccountEventV3; +/// AccountPlayEvent. +/// This is the raw entry struct directly read from FS, without any entry filtering. This is separate from \ref PdmPlayEvent. +using ::PdmAccountPlayEvent; +/// AppletEvent. AppletEvent for [16.0.0+], converted from \ref PdmAppletEventV1 on [1.0.0-15.0.1]. +using ::PdmAppletEvent; +/// AppletEventType +using ::PdmAppletEventType; +/// AppletEventV1. AppletEvent for [1.0.0-15.0.1], converted to \ref PdmAppletEvent when needed. +/// Timestamp format, converted from PosixTime: total minutes since epoch UTC 1999/12/31 00:00:00. +/// See \ref pdmPlayTimestampToPosix. +using ::PdmAppletEventV1; +/// ApplicationPlayStatistics +using ::PdmApplicationPlayStatistics; +/// LastPlayTime. +/// This contains data from the last time the application was played. +using ::PdmLastPlayTime; +/// PlayEvent. +/// This is the raw entry struct directly read from FS, without any entry filtering. +using ::PdmPlayEvent; +/// PlayEventType +using ::PdmPlayEventType; +/// PlayLogPolicy +using ::PdmPlayLogPolicy; +/// PlayStatistics. PlayStatistics for [16.0.0+], converted from \ref PdmPlayStatisticsV1 on [1.0.0-15.0.1]. +using ::PdmPlayStatistics; +/// PlayStatisticsV1. PlayStatistics for [1.0.0-15.0.1], converted to \ref PdmPlayStatistics when needed. +using ::PdmPlayStatisticsV1; + +/// Initialize pdm:qry. +Result Initialize(void); + +/// Exit pdm:qry. +void Exit(void); + +/// Gets the Service object for the actual pdm:qry service session. +Service* GetServiceSession(void); + +/** + * @brief Gets a list of \ref PdmAppletEvent. + * @param[in] entry_index Start entry index. + * @param[in] flag [10.0.0+] Whether to additionally allow using entries with ::PdmPlayLogPolicy_Unknown3. + * @param[out] events Output \ref PdmAppletEvent array. + * @param[in] count Max entries in the output array. + * @param[out] total_out Total output entries. + */ +Result QueryAppletEvent(s32 entry_index, bool flag, PdmAppletEvent *events, s32 count, s32 *total_out); + +/** + * @brief Gets \ref PdmPlayStatistics for the specified ApplicationId. + * @param[in] application_id ApplicationId + * @param[in] flag [10.0.0+] Whether to additionally allow using entries with ::PdmPlayLogPolicy_Unknown3. + * @param[out] stats \ref PdmPlayStatistics + */ +Result QueryPlayStatisticsByApplicationId(u64 application_id, bool flag, PdmPlayStatistics *stats); + +/** + * @brief Gets \ref PdmPlayStatistics for the specified ApplicationId and account userId. + * @param[in] application_id ApplicationId + * @param[in] uid \ref AccountUid + * @param[in] flag [10.0.0+] Whether to additionally allow using entries with ::PdmPlayLogPolicy_Unknown3. + * @param[out] stats \ref PdmPlayStatistics + */ +Result QueryPlayStatisticsByApplicationIdAndUserAccountId(u64 application_id, AccountUid uid, bool flag, PdmPlayStatistics *stats); + +/** + * @brief Gets \ref PdmLastPlayTime for the specified applications. + * @param[in] flag [10.0.0+] Whether to additionally allow using entries with ::PdmPlayLogPolicy_Unknown3. + * @param[out] playtimes Output \ref PdmLastPlayTime array. + * @param[in] application_ids Input ApplicationIds array. + * @param[in] count Total entries in the input/output arrays. + * @param[out] total_out Total output entries. + */ +Result QueryLastPlayTime(bool flag, PdmLastPlayTime *playtimes, const u64 *application_ids, s32 count, s32 *total_out); + +/** + * @brief Gets a list of \ref PdmPlayEvent. + * @param[in] entry_index Start entry index. + * @param[out] events Output \ref PdmPlayEvent array. + * @param[in] count Max entries in the output array. + * @param[out] total_out Total output entries. + */ +Result QueryPlayEvent(s32 entry_index, PdmPlayEvent *events, s32 count, s32 *total_out); + +/** + * @brief Gets range fields which can then be used with the other pdmqry funcs, except for \ref pdmqryQueryAccountPlayEvent. + * @param[out] total_entries Total entries. + * @param[out] start_entry_index Start entry index. + * @param[out] end_entry_index End entry index. + */ +Result GetAvailablePlayEventRange(s32 *total_entries, s32 *start_entry_index, s32 *end_entry_index); + +/** + * @brief Gets a list of \ref PdmAccountEvent. + * @note Only available with [3.0.0+]. + * @param[in] entry_index Start entry index. + * @param[out] events Output \ref PdmAccountEvent array. + * @param[in] count Max entries in the output array. + * @param[out] total_out Total output entries. + */ +Result QueryAccountEvent(s32 entry_index, PdmAccountEvent *events, s32 count, s32 *total_out); + +/** + * @brief Gets a list of \ref PdmAccountPlayEvent. + * @note Only available with [4.0.0+]. + * @param[in] entry_index Start entry index. + * @param[in] uid \ref AccountUid + * @param[out] events Output \ref PdmAccountPlayEvent array. + * @param[in] count Max entries in the output array. + * @param[out] total_out Total output entries. + */ +Result QueryAccountPlayEvent(s32 entry_index, AccountUid uid, PdmAccountPlayEvent *events, s32 count, s32 *total_out); + +/** + * @brief Gets range fields which can then be used with \ref pdmqryQueryAccountPlayEvent. + * @param[in] uid \ref AccountUid + * @param[out] total_entries Total entries. + * @param[out] start_entry_index Start entry index. + * @param[out] end_entry_index End entry index. + */ +Result GetAvailableAccountPlayEventRange(AccountUid uid, s32 *total_entries, s32 *start_entry_index, s32 *end_entry_index); + +/** + * @brief Gets a list of applications played by the specified user. + * @note Only available with [6.0.0-14.1.2]. + * @param[in] uid \ref AccountUid + * @param[in] flag [10.0.0+] Whether to additionally allow using entries with ::PdmPlayLogPolicy_Unknown3. + * @param[out] application_ids Output ApplicationIds array. + * @param[in] count Max entries in the output array. + * @param[out] total_out Total output entries. + */ +Result QueryRecentlyPlayedApplication(AccountUid uid, bool flag, u64 *application_ids, s32 count, s32 *total_out); + +/** + * @brief Gets an Event which is signaled when logging a new \ref PdmPlayEvent which would be available via \ref pdmqryQueryAccountEvent, where PdmPlayEvent::event_data::account::type is 0. + * @note Only available with [6.0.0-14.1.2]. + * @note The Event must be closed by the user once finished with it. + * @param[out] out_event Output Event with autoclear=false. + */ +Result GetRecentlyPlayedApplicationUpdateEvent(Event* out_event); + +} // namespace pdmqry + +/// @brief C++ wrappers for the `pgl` API. +/// @details Wraps: switch/services/pgl.h. +namespace pgl { + +using ::PglEventObserver; +/// LaunchFlag +using ::PglLaunchFlag; +using ::PglProgramLaunchProperty; +/// SnapShotDumpType +using ::PglSnapShotDumpType; + +/// Initialize pgl. +Result Initialize(void); + +/// Exit pgl. +void Exit(void); + +/// Gets the Service object for the actual pgl service session. Requires < 12.0.0 +Service* GetServiceSessionCmif(void); + +/// Gets the TipcService object for the actual pgl service session. Requires 12.0.0+ +TipcService* GetServiceSessionTipc(void); + +Result LaunchProgram(u64 *out_pid, const NcmProgramLocation *loc, u32 pm_launch_flags, u8 pgl_launch_flags); + +Result TerminateProcess(u64 pid); + +Result LaunchProgramFromHost(u64 *out_pid, const char *content_path, u32 pm_launch_flags); + +Result GetHostProgramLaunchProperty(PglProgramLaunchProperty *out, const char *content_path); + +Result GetRunningApplicationProcessId(u64 *out_pid); + +Result BoostSystemMemoryResourceLimit(u64 size); + +Result IsRunningProcess(bool *out, u64 pid); + +Result EnableApplicationCrashReport(bool en); + +Result IsApplicationCrashReportEnabled(bool *out); + +Result EnableApplicationAllThreadDumpOnCrash(bool en); + +Result GetProcessId(u64 *out_pid, u64 program_id); + +///< [19.0.0+] +Result TriggerSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg); + +///< [10.0.0-11.0.1] +Result CreateShellEvent(PglEventObserver *out); + +Result EnableApplicationCrashReport2(u64 pid, bool en); + +///< [23.0.0+] +Result EventObserverGetShellEvent(PglEventObserver *observer, Event *out); + +Result EventObserverGetShellEventInfo(PglEventObserver *observer, PmProcessEventInfo *out); + +void EventObserverClose(PglEventObserver *observer); + +} // namespace pgl + +/// @brief C++ wrappers for the `pl` API. +/// @details Wraps: switch/services/pl.h. +namespace pl { + +/// FontData +using ::PlFontData; +using ::PlServiceType; +/// SharedFontType +using ::PlSharedFontType; + +/// Initialize pl. +Result Initialize(PlServiceType service_type); + +/// Exit pl. +void Exit(void); + +/// Gets the Service object for the actual pl service session. +Service* GetServiceSession(void); + +/// Gets the address of the SharedMemory. +void* GetSharedmemAddr(void); + +///< Gets a specific shared-font via \ref PlSharedFontType. +Result GetSharedFontByType(PlFontData* font, PlSharedFontType SharedFontType); + +///< Gets shared font(s). +Result GetSharedFont(u64 LanguageCode, PlFontData* fonts, s32 max_fonts, s32* total_fonts); + +} // namespace pl + +/// @brief C++ wrappers for the `pmbm` API. +/// @details Wraps: switch/services/pm.h. +namespace pmbm { + +/// BootMode +using ::PmBootMode; +/// LaunchFlag +using ::PmLaunchFlag; +/// ProcessEvent +using ::PmProcessEvent; +/// ProcessEventInfo +using ::PmProcessEventInfo; +/// ResourceLimitValues +using ::PmResourceLimitValues; + +/// Initialize pm:bm. +Result Initialize(void); + +/// Exit pm:bm. +void Exit(void); + +/// Gets the Service object for the actual pm:bm service session. +Service* GetServiceSession(void); + +/** + * @brief Gets the \ref PmBootMode. + * @param[out] out \ref PmBootMode + */ +Result GetBootMode(PmBootMode *out); + +/** + * @brief Sets the \ref PmBootMode to ::PmBootMode_Maintenance. + */ +Result SetMaintenanceBoot(void); + +} // namespace pmbm + +/// @brief C++ wrappers for the `pmdmnt` API. +/// @details Wraps: switch/services/pm.h. +namespace pmdmnt { + +/// BootMode +using ::PmBootMode; +/// LaunchFlag +using ::PmLaunchFlag; +/// ProcessEvent +using ::PmProcessEvent; +/// ProcessEventInfo +using ::PmProcessEventInfo; +/// ResourceLimitValues +using ::PmResourceLimitValues; + +/// Initialize pm:dmnt. +Result Initialize(void); + +/// Exit pm:dmnt. +void Exit(void); + +/// Gets the Service object for the actual pm:dmnt service session. +Service* GetServiceSession(void); + +Result GetJitDebugProcessIdList(u32* out_count, u64* out_pids, size_t max_pids); + +Result StartProcess(u64 pid); + +Result GetProcessId(u64* pid_out, u64 program_id); + +Result HookToCreateProcess(Event* out, u64 program_id); + +Result GetApplicationProcessId(u64* pid_out); + +Result HookToCreateApplicationProcess(Event* out); + +Result ClearHook(u32 which); + +Result GetProgramId(u64* program_id_out, u64 pid); + +} // namespace pmdmnt + +/// @brief C++ wrappers for the `pminfo` API. +/// @details Wraps: switch/services/pm.h. +namespace pminfo { + +/// BootMode +using ::PmBootMode; +/// LaunchFlag +using ::PmLaunchFlag; +/// ProcessEvent +using ::PmProcessEvent; +/// ProcessEventInfo +using ::PmProcessEventInfo; +/// ResourceLimitValues +using ::PmResourceLimitValues; + +/// Initialize pm:info. +Result Initialize(void); + +/// Exit pm:info. +void Exit(void); + +/// Gets the Service object for the actual pm:info service session. +Service* GetServiceSession(void); + +Result GetProgramId(u64* program_id_out, u64 pid); + +Result GetAppletCurrentResourceLimitValues(PmResourceLimitValues* out); + +Result GetAppletPeakResourceLimitValues(PmResourceLimitValues* out); + +} // namespace pminfo + +/// @brief C++ wrappers for the `pmshell` API. +/// @details Wraps: switch/services/pm.h. +namespace pmshell { + +/// BootMode +using ::PmBootMode; +/// LaunchFlag +using ::PmLaunchFlag; +/// ProcessEvent +using ::PmProcessEvent; +/// ProcessEventInfo +using ::PmProcessEventInfo; +/// ResourceLimitValues +using ::PmResourceLimitValues; + +/// Initialize pm:shell. +Result Initialize(void); + +/// Exit pm:shell. +void Exit(void); + +/// Gets the Service object for the actual pm:shell service session. +Service* GetServiceSession(void); + +Result LaunchProgram(u32 launch_flags, const NcmProgramLocation *location, u64 *pid); + +Result TerminateProcess(u64 processID); + +Result TerminateProgram(u64 program_id); + +Result GetProcessEventHandle(Event* out); + +Result GetProcessEventInfo(PmProcessEventInfo* out); + +Result CleanupProcess(u64 pid); + +Result ClearJitDebugOccured(u64 pid); + +Result NotifyBootFinished(void); + +Result GetApplicationProcessIdForShell(u64* pid_out); + +Result BoostSystemMemoryResourceLimit(u64 boost_size); + +Result BoostApplicationThreadResourceLimit(void); + +Result BoostSystemThreadResourceLimit(void); + +Result GetProcessId(u64* pid_out, u64 program_id); + +} // namespace pmshell + +/// @brief C++ wrappers for the `psc` API. +/// @details Wraps: switch/services/psc.h. +namespace psc { + +using ::PscPmModule; +using ::PscPmModuleId; +using ::PscPmState; + +Result PmModuleGetRequest(PscPmModule *module, PscPmState *out_state, u32 *out_flags); + +Result PmModuleAcknowledge(PscPmModule *module, PscPmState state); + +Result PmModuleFinalize(PscPmModule *module); + +void PmModuleClose(PscPmModule *module); + +} // namespace psc + +/// @brief C++ wrappers for the `pscm` API. +/// @details Wraps: switch/services/psc.h. +namespace pscm { + +using ::PscPmModule; +using ::PscPmModuleId; +using ::PscPmState; + +/// Initialize psc:m. +Result Initialize(void); + +/// Exit psc:m. +void Exit(void); + +/// Gets the Service object for the actual psc:m service session. +Service* GetServiceSession(void); + +Result GetPmModule(PscPmModule *out, PscPmModuleId module_id, const u32 *dependencies, size_t dependency_count, bool autoclear); + +} // namespace pscm + +/// @brief C++ wrappers for the `psel` API. +/// @details Wraps: switch/applets/psel.h. +namespace psel { + +/// NintendoAccountStartupDialogType +using ::PselNintendoAccountStartupDialogType; +/// playerSelect UI modes. +using ::PselUiMode; +/// Return data sent after execution. +using ::PselUiReturnArg; +/// UI settings for versions starting with 0x10000. +using ::PselUiSettings; +/// Base UI settings for playerSelect. +using ::PselUiSettingsV1; +/// UI message text to display with ::PselUiMode_UserSelector. Invalid values are handled as ::PselUserSelectionPurpose_General. +using ::PselUserSelectionPurpose; +/// UserSelectionSettings +using ::PselUserSelectionSettings; +/// [2.0.0+] UserSelectionSettingsForSystemService +using ::PselUserSelectionSettingsForSystemService; + +/** + * @brief Creates a new UI config for the playerSelect applet with the specified mode. + * @param ui PseluiSettings struct. + * @param mode playerSelect UI mode. + */ +Result UiCreate(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 UiAddUser(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. + */ +void UiSetAllowUserCreation(PselUiSettings *ui, bool flag); + +/** + * @brief Sets whether users need to be linked to a Nintendo account. + * @param ui PselUiSettings struct. + * @param flag Flag value. + */ +void UiSetNetworkServiceRequired(PselUiSettings *ui, bool flag); + +/** + * @brief Sets whether selection can be skipped with a button. + * @param ui PselUiSettings struct. + * @param flag Flag value. + */ +void UiSetSkipButtonEnabled(PselUiSettings *ui, bool flag); + +/** + * @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 UiShow(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 ShowUserSelectorForSystem(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 ShowUserSelectorForLauncher(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 ShowUserSelector(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 ShowUserCreator(void); + +/** + * @brief Shows the applet to change a user's icon. + * @param[in] user Input user ID. + */ +Result ShowUserIconEditor(AccountUid user); + +/** + * @brief Shows the applet to change a user's nickname. + * @param[in] user Input user ID. + */ +Result ShowUserNicknameEditor(AccountUid user); + +/** + * @brief Shows the applet to create a user. Used by the starter applet during system setup. + */ +Result ShowUserCreatorForStarter(void); + +/** + * @brief Shows the applet for Nintendo Account Nnid linking. + * @note Only available on [6.0.0+]. + * @param[in] user Input user ID. + */ +Result ShowNintendoAccountNnidLinker(AccountUid user); + +/** + * @brief Shows the applet for UserQualificationPromoter. + * @note Only available on [13.0.0+]. + * @param[in] user Input user ID. + */ +Result ShowUserQualificationPromoter(AccountUid user); + +} // namespace psel + +/// @brief C++ wrappers for the `psm` API. +/// @details Wraps: switch/services/psm.h. +namespace psm { + +/// BatteryChargeInfoFields [17.0.0+] +using ::PsmBatteryChargeInfoFields; +/// BatteryChargeInfoFieldsOld [1.0.0-16.1.0] +using ::PsmBatteryChargeInfoFieldsOld; +/// BatteryVoltageState +using ::PsmBatteryVoltageState; +/// ChargerType +using ::PsmChargerType; +/// IPsmSession +using ::PsmSession; +/// Vdd50State +using ::PsmVdd50State; + +/// Initialize psm. +Result Initialize(void); + +/// Exit psm. +void Exit(void); + +/// Gets the Service object for the actual psm service session. +Service* GetServiceSession(void); + +/** + * @brief GetBatteryChargePercentage + * @param[out] out Battery charge percentage. + */ +Result GetBatteryChargePercentage(u32 *out); + +/** + * @brief GetChargerType + * @param[out] out \ref PsmChargerType + */ +Result GetChargerType(PsmChargerType *out); + +/** + * @brief EnableBatteryCharging + */ +Result EnableBatteryCharging(void); + +/** + * @brief DisableBatteryCharging + */ +Result DisableBatteryCharging(void); + +/** + * @brief IsBatteryChargingEnabled + * @param[out] out Output flag. + */ +Result IsBatteryChargingEnabled(bool *out); + +/** + * @brief AcquireControllerPowerSupply + */ +Result AcquireControllerPowerSupply(void); + +/** + * @brief ReleaseControllerPowerSupply + */ +Result ReleaseControllerPowerSupply(void); + +/** + * @brief EnableEnoughPowerChargeEmulation + */ +Result EnableEnoughPowerChargeEmulation(void); + +/** + * @brief DisableEnoughPowerChargeEmulation + */ +Result DisableEnoughPowerChargeEmulation(void); + +/** + * @brief EnableFastBatteryCharging + */ +Result EnableFastBatteryCharging(void); + +/** + * @brief DisableFastBatteryCharging + */ +Result DisableFastBatteryCharging(void); + +/** + * @brief GetBatteryVoltageState + * @param[out] out \ref PsmBatteryVoltageState + */ +Result GetBatteryVoltageState(PsmBatteryVoltageState *out); + +/** + * @brief GetRawBatteryChargePercentage + * @param[out] out Raw battery charge percentage. + */ +Result GetRawBatteryChargePercentage(double *out); + +/** + * @brief IsEnoughPowerSupplied + * @param[out] out Output flag. + */ +Result IsEnoughPowerSupplied(bool *out); + +/** + * @brief GetBatteryAgePercentage + * @param[out] out Battery age percentage. + */ +Result GetBatteryAgePercentage(double *out); + +/** + * @brief GetBatteryChargeInfoEvent + * @param[out] out_event Event object. + * @param[in] autoclear Event autoclear. + */ +Result GetBatteryChargeInfoEvent(Event* out_event, bool autoclear); + +/** + * @brief GetBatteryChargeInfoFields + * @param[out] out_fields \ref PsmBatteryChargeInfoFields + */ +Result GetBatteryChargeInfoFields(PsmBatteryChargeInfoFields *out_fields); + +/** + * @brief GetBatteryChargeCalibratedEvent + * @note Only available on [3.0.0+]. + * @param[out] out_event Event object. + * @param[in] autoclear Event autoclear. + */ +Result GetBatteryChargeCalibratedEvent(Event* out_event, bool autoclear); + +/** + * @brief Wrapper func which opens a PsmSession and handles event setup. + * @note Uses the actual BindStateChangeEvent cmd internally. + * @note The event is not signalled on BatteryChargePercentage changes. + * @param[out] s PsmSession object. + * @param[in] ChargerType Passed to SetChargerTypeChangeEventEnabled. + * @param[in] PowerSupply Passed to SetPowerSupplyChangeEventEnabled. + * @param[in] BatteryVoltage Passed to SetBatteryVoltageStateChangeEventEnabled. + */ +Result BindStateChangeEvent(PsmSession* s, bool ChargerType, bool PowerSupply, bool BatteryVoltage); + +/// Wait on the Event setup by \ref psmBindStateChangeEvent. +Result WaitStateChangeEvent(PsmSession* s, u64 timeout); + +/// Cleanup version of \ref psmBindStateChangeEvent. Must be called by the user once the PsmSession is done being used. +Result UnbindStateChangeEvent(PsmSession* s); + +} // namespace psm + +/// @brief C++ wrappers for the `random` API. +/// @details Wraps: switch/kernel/random.h. +namespace random { + +/** + * @brief Fills a buffer with random data. + * @param buf Pointer to the buffer. + * @param len Size of the buffer in bytes. + */ +void Get(void* buf, size_t len); + +/** + * @brief Returns a random 64-bit value. + * @return Random value. + */ +u64 Get64(void); + +} // namespace random + +/// @brief C++ wrappers for the `resolver` API. +/// @details Wraps: switch/runtime/resolver.h. +namespace resolver { + +/// Fetches the last resolver Switch result code of the current thread. +Result GetLastResult(void); + +/// Retrieves a handle used to cancel the next resolver command on the current thread. +u32 GetCancelHandle(void); + +/// Retrieves whether service discovery is enabled for resolver commands on the current thread. +bool GetEnableServiceDiscovery(void); + +/// [5.0.0+] Retrieves whether the DNS cache is used to resolve queries on the current thread (not implemented). +bool GetEnableDnsCache(void); + +/// Enables or disables service discovery for the current thread. +void SetEnableServiceDiscovery(bool enable); + +/// [5.0.0+] Enables or disables the usage of the DNS cache on the current thread (not implemented). +void SetEnableDnsCache(bool enable); + +/// Cancels a previous resolver command (handle obtained with \ref resolverGetCancelHandle prior to calling the command). +Result Cancel(u32 handle); + +/// [5.0.0+] Removes a hostname from the DNS cache (not implemented). +Result RemoveHostnameFromCache(const char* hostname); + +/// [5.0.0+] Removes an IP address from the DNS cache (not implemented). +Result RemoveIpAddressFromCache(u32 ip); + +} // namespace resolver + +/// @brief C++ wrappers for the `ringcon` API. +/// @details Wraps: switch/runtime/ringcon.h. +namespace ringcon { + +/// Ring-Con state object. +using ::RingCon; +/// Whether the output data is valid. +using ::RingConDataValid; +using ::RingConErrorFlag; +/// Ring-Con firmware version. +using ::RingConFwVersion; +/// Ring-Con manufacturer calibration. +using ::RingConManuCal; +/// Polling data extracted from \ref HidbusJoyPollingReceivedData. +using ::RingConPollingData; +/// Ring-Con user calibration. +using ::RingConUserCal; + +/** + * @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 Create(RingCon *c, HidNpadIdType id); + +/** + * @brief Close a \ref RingCon. + * @param c \ref RingCon + */ +void Close(RingCon *c); + +/** + * @brief Gets the error flags field. + * @param c \ref RingCon + */ +u32 GetErrorFlags(RingCon *c); + +/** + * @brief Gets the value of an error flag, set by \ref ringconSetErrorFlag. + * @param c \ref RingCon + * @param[in] flag \ref RingConErrorFlag + */ +bool GetErrorFlag(RingCon *c, RingConErrorFlag flag); + +/** + * @brief Gets the \ref RingConFwVersion previously loaded by \ref ringconCreate. + * @param c \ref RingCon + * @param[out] out \ref RingConFwVersion + */ +RingConFwVersion GetFwVersion(RingCon *c); + +/** + * @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. + */ +void GetId(RingCon *c, u64 *id_l, u64 *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 + */ +s16 GetUnkCal(RingCon *c); + +/** + * @brief Gets the total-push-count previously loaded by \ref ringconCreate. + * @param c \ref RingCon + * @param[out] out total_push_count + */ +s32 GetTotalPushCount(RingCon *c); + +/** + * @brief Gets the \ref RingConManuCal previously loaded by \ref ringconCreate. + * @param c \ref RingCon + * @param[out] out \ref RingConManuCal + */ +void GetManuCal(RingCon *c, RingConManuCal *out); + +/** + * @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 + */ +void GetUserCal(RingCon *c, RingConUserCal *out); + +/** + * @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 UpdateUserCal(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 ReadFwVersion(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 ReadId(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 GetPollingData(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 Cmdx00020105(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 ReadManuCal(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 ReadUnkCal(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 ReadUserCal(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 ReadRepCount(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 ReadTotalPushCount(RingCon *c, s32 *out, RingConDataValid *data_valid); + +/** + * @brief This resets the value returned by \ref ringconReadRepCount to 0. + * @param c \ref RingCon + */ +Result ResetRepCount(RingCon *c); + +/** + * @brief Writes the \ref RingConUserCal. + * @note Used internally by \ref ringconUpdateUserCal. + * @param c \ref RingCon + * @param[in] cal \ref RingConUserCal + */ +Result WriteUserCal(RingCon *c, RingConUserCal cal); + +} // namespace ringcon + +/// @brief C++ wrappers for the `rmutex` API. +/// @details Wraps: switch/kernel/mutex.h. +namespace rmutex { + +/// Mutex datatype, defined in newlib. +using ::Mutex; +/// Recursive mutex datatype, defined in newlib. +using ::RMutex; + +/** + * @brief Initializes a recursive mutex. + * @param m Recursive mutex object. + * @note A recursive mutex can also be statically initialized by assigning {0,0,0} to it. + */ +void Init(RMutex* m); + +/** + * @brief Locks a recursive mutex. + * @param m Recursive mutex object. + */ +void Lock(RMutex* m); + +/** + * @brief Attempts to lock a recursive mutex without waiting. + * @param m Recursive mutex object. + * @return 1 if the mutex has been acquired successfully, and 0 on contention. + */ +bool TryLock(RMutex* m); + +/** + * @brief Unlocks a recursive mutex. + * @param m Recursive mutex object. + */ +void Unlock(RMutex* m); + +} // namespace rmutex + +/// @brief C++ wrappers for the `ro` API. +/// @details Wraps: switch/services/ro.h. +namespace ro { + +/// Initialize ro:dmnt. Only available with [3.0.0+]. +Result DmntInitialize(void); + +/// Exit ro:dmnt. +void DmntExit(void); + +/// Gets the Service object for the actual ro:dmnt service session. +Service* DmntGetServiceSession(void); + +Result DmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, s32 *num_out); + +} // namespace ro + +/// @brief C++ wrappers for the `ro1` API. +/// @details Wraps: switch/services/ro.h. +namespace ro1 { + +/// Initialize ro:1. Only available with [7.0.0+]. +Result Initialize(void); + +/// Exit ro:1. +void Exit(void); + +/// Gets the Service object for the actual ro:1 service session. +Service* GetServiceSession(void); + +Result LoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); + +Result UnloadNro(u64 nro_address); + +Result LoadNrr(u64 nrr_address, u64 nrr_size); + +Result UnloadNrr(u64 nrr_address); + +Result LoadNrrEx(u64 nrr_address, u64 nrr_size); + +} // namespace ro1 + +/// @brief C++ wrappers for the `romfs` API. +/// @details Wraps: switch/runtime/devices/romfs_dev.h. +namespace romfs { + +/// RomFS directory. +using ::romfs_dir; +/// RomFS file. +using ::romfs_file; +/// RomFS header. +using ::romfs_header; + +/** + * @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. + */ +Result MountSelf(const char *name); + +/** + * @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. + */ +Result MountFromFile(FsFile file, u64 offset, const char *name); + +/** + * @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. + */ +Result MountFromStorage(FsStorage storage, u64 offset, const char *name); + +/** + * @brief Mounts RomFS using the current process host program RomFS. + * @param name Device mount name. + */ +Result MountFromCurrentProcess(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 MountDataStorageFromProgram(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 MountFromFsdev(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 MountFromDataArchive(u64 dataId, NcmStorageId storageId, const char *name); + +/// Unmounts the RomFS device. +Result Unmount(const char *name); + +/// Wrapper for \ref romfsMountSelf with the default "romfs" device name. +Result Init(void); + +/// Wrapper for \ref romfsUnmount with the default "romfs" device name. +Result Exit(void); + +} // namespace romfs + +/// @brief C++ wrappers for the `rwlock` API. +/// @details Wraps: switch/kernel/rwlock.h. +namespace rwlock { + +/// Read/write lock structure. +using ::RwLock; + +/** + * @brief Initializes the read/write lock. + * @param r Read/write lock object. + */ +void Init(RwLock* r); + +/** + * @brief Locks the read/write lock for reading. + * @param r Read/write lock object. + */ +void ReadLock(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 TryReadLock(RwLock* r); + +/** + * @brief Unlocks the read/write lock for reading. + * @param r Read/write lock object. + */ +void ReadUnlock(RwLock* r); + +/** + * @brief Locks the read/write lock for writing. + * @param r Read/write lock object. + */ +void WriteLock(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 TryWriteLock(RwLock* r); + +/** + * @brief Unlocks the read/write lock for writing. + * @param r Read/write lock object. + */ +void WriteUnlock(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 IsWriteLockHeldByCurrentThread(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 IsOwnedByCurrentThread(RwLock* r); + +} // namespace rwlock + +/// @brief C++ wrappers for the `semaphore` API. +/// @details Wraps: switch/kernel/semaphore.h. +namespace semaphore { + +/// Semaphore structure. +using ::Semaphore; + +/** + * @brief Initializes a semaphore and its internal counter. + * @param s Semaphore object. + * @param initial_count initial value for internal counter (typically the # of free resources). + */ +void Init(Semaphore *s, u64 initial_count); + +/** + * @brief Increments the Semaphore to allow other threads to continue. + * @param s Semaphore object. + */ +void Signal(Semaphore *s); + +/** + * @brief Decrements Semaphore and waits if 0. + * @param s Semaphore object. + */ +void Wait(Semaphore *s); + +/** + * @brief Attempts to get lock without waiting. + * @param s Semaphore object. + * @return true if no wait and successful lock, false otherwise. + */ +bool TryWait(Semaphore *s); + +} // namespace semaphore + +/// @brief C++ wrappers for the `service` API. +/// @details Wraps: switch/sf/service.h. +namespace service { + +/// Service object structure +using ::Service; +using ::SfBuffer; +using ::SfBufferAttrs; +using ::SfDispatchParams; +using ::SfOutHandleAttr; +using ::SfOutHandleAttrs; + +/** + * @brief Returns whether a service has been initialized. + * @param[in] s Service object. + * @return true if initialized. + */ +bool IsActive(Service* s); + +/** + * @brief Returns whether a service is overriden in the homebrew environment. + * @param[in] s Service object. + * @return true if overriden. + */ +bool IsOverride(Service* s); + +/** + * @brief Returns whether a service is a domain. + * @param[in] s Service object. + * @return true if a domain. + */ +bool IsDomain(Service* s); + +/** + * @brief Returns whether a service is a domain subservice. + * @param[in] s Service object. + * @return true if a domain subservice. + */ +bool IsDomainSubservice(Service* s); + +/** + * @brief For a domain/domain subservice, return the associated object ID. + * @param[in] s Service object, necessarily a domain or domain subservice. + * @return The object ID. + */ +u32 GetObjectId(Service* s); + +/** + * @brief Creates a service object from an IPC session handle. + * @param[out] s Service object. + * @param[in] h IPC session handle. + */ +void Create(Service* s, Handle h); + +/** + * @brief Creates a non-domain subservice object from a parent service. + * @param[out] s Service object. + * @param[in] parent Parent service. + * @param[in] h IPC session handle for this subservice. + */ +void CreateNonDomainSubservice(Service* s, Service* parent, Handle h); + +/** + * @brief Creates a domain subservice object from a parent service. + * @param[out] s Service object. + * @param[in] parent Parent service, necessarily a domain or domain subservice. + * @param[in] object_id Object ID for this subservice. + */ +void CreateDomainSubservice(Service* s, Service* parent, u32 object_id); + +/** + * @brief Closes a service. + * @param[in] s Service object. + */ +void Close(Service* s); + +/** + * @brief Clones a service. + * @param[in] s Service object. + * @param[out] out_s Output service object. + */ +Result Clone(Service* s, Service* out_s); + +/** + * @brief Clones a service with a session manager tag. + * @param[in] s Service object. + * @param[in] tag Session manager tag (unused in current official server code) + * @param[out] out_s Output service object. + */ +Result CloneEx(Service* s, u32 tag, Service* out_s); + +/** + * @brief Converts a regular service to a domain. + * @param[in] s Service object. + * @return Result code. + */ +Result ConvertToDomain(Service* s); + +void RequestFormatProcessBuffer(CmifRequestFormat* fmt, u32 attr); + +void RequestProcessBuffer(CmifRequest* req, const SfBuffer* buf, u32 attr); + +void* MakeRequest(Service* s, u32 request_id, u32 context, u32 data_size, bool send_pid, const SfBufferAttrs buffer_attrs, const SfBuffer* buffers, u32 num_objects, const Service* const* objects, u32 num_handles, const Handle* handles); + +void ResponseGetHandle(CmifResponse* res, SfOutHandleAttr type, Handle* out); + +Result ParseResponse(Service* s, u32 out_size, void** out_data, u32 num_out_objects, Service* out_objects, const SfOutHandleAttrs out_handle_attrs, Handle* out_handles); + +Result DispatchImpl(Service* s, u32 request_id, const void* in_data, u32 in_data_size, void* out_data, u32 out_data_size, SfDispatchParams disp); + +} // namespace service + +/// @brief C++ wrappers for the `sessionmgr` API. +/// @details Wraps: switch/sf/sessionmgr.h. +namespace sessionmgr { + +using ::SessionMgr; + +Result Create(SessionMgr* mgr, Handle root_session, u32 num_sessions); + +void Close(SessionMgr* mgr); + +int AttachClient(SessionMgr* mgr); + +void DetachClient(SessionMgr* mgr, int slot); + +Handle GetClientSession(SessionMgr* mgr, int slot); + +} // namespace sessionmgr + +/// @brief C++ wrappers for the `set` API. +/// @details Wraps: switch/services/set.h. +namespace set { + +using ::ColorSetId; +/// BatteryLot +using ::SetBatteryLot; +using ::SetCalAccelerometerOffset; +using ::SetCalAccelerometerScale; +using ::SetCalAmiiboEcdsaCertificate; +using ::SetCalAmiiboEcqvBlsCertificate; +using ::SetCalAmiiboEcqvBlsKey; +using ::SetCalAmiiboEcqvBlsRootCertificate; +using ::SetCalAmiiboEcqvCertificate; +using ::SetCalAmiiboKey; +using ::SetCalAnalogStickFactoryCalibration; +using ::SetCalAnalogStickModelParameter; +using ::SetCalBdAddress; +using ::SetCalConfigurationId1; +using ::SetCalConsoleSixAxisSensorHorizontalOffset; +using ::SetCalCountryCode; +using ::SetCalEccB233DeviceCertificate; +using ::SetCalEccB233DeviceKey; +using ::SetCalGameCardCertificate; +using ::SetCalGameCardKey; +using ::SetCalGyroscopeOffset; +using ::SetCalGyroscopeScale; +using ::SetCalMacAddress; +using ::SetCalRegionCode; +using ::SetCalRsa2048DeviceCertificate; +using ::SetCalRsa2048DeviceKey; +using ::SetCalSerialNumber; +using ::SetCalSpeakerParameter; +using ::SetCalSslCertificate; +using ::SetCalSslKey; +/// ChineseTraditionalInputMethod +using ::SetChineseTraditionalInputMethod; +/// KeyboardLayout +using ::SetKeyboardLayout; +/// IDs for Language. +using ::SetLanguage; +/// Region codes. +using ::SetRegion; +/// AccessPointSecurityStandard +using ::SetSysAccessPointSecurityStandard; +/// AccessPointSecurityType +using ::SetSysAccessPointSecurityType; +/// AccountNotificationSettings +using ::SetSysAccountNotificationSettings; +/// AccountOnlineStorageSettings +using ::SetSysAccountOnlineStorageSettings; +/// AccountSettings +using ::SetSysAccountSettings; +/// AllowedSslHosts +using ::SetSysAllowedSslHosts; +/// AnalogStickUserCalibration +using ::SetSysAnalogStickUserCalibration; +/// AudioDevice +using ::SetSysAudioDevice; +/// AudioOutputMode +using ::SetSysAudioOutputMode; +/// AudioOutputModeTarget +using ::SetSysAudioOutputModeTarget; +using ::SetSysAudioVolume; +/// AutoSettings +using ::SetSysAutoSettings; +/// BacklightSettings +using ::SetSysBacklightSettings; +/// BacklightSettingsEx +using ::SetSysBacklightSettingsEx; +/// BlePairingSettings +using ::SetSysBlePairingSettings; +/// BlockType +using ::SetSysBlockType; +/// BluetoothDevicesSettings +using ::SetSysBluetoothDevicesSettings; +/// ButtonConfigRegisteredSettings +using ::SetSysButtonConfigRegisteredSettings; +/// ButtonConfigSettings +using ::SetSysButtonConfigSettings; +/// Actually nn::util::Color4u8Type. +using ::SetSysColor4u8Type; +/// ConnectionFlag +using ::SetSysConnectionFlag; +/// ConsoleSixAxisSensorAccelerationBias +using ::SetSysConsoleSixAxisSensorAccelerationBias; +/// ConsoleSixAxisSensorAccelerationGain +using ::SetSysConsoleSixAxisSensorAccelerationGain; +/// ConsoleSixAxisSensorAngularAcceleration +using ::SetSysConsoleSixAxisSensorAngularAcceleration; +/// ConsoleSixAxisSensorAngularVelocityBias +using ::SetSysConsoleSixAxisSensorAngularVelocityBias; +/// ConsoleSixAxisSensorAngularVelocityGain +using ::SetSysConsoleSixAxisSensorAngularVelocityGain; +/// ConsoleSixAxisSensorAngularVelocityTimeBias +using ::SetSysConsoleSixAxisSensorAngularVelocityTimeBias; +/// ConsoleSleepPlan +using ::SetSysConsoleSleepPlan; +/// ControllerType +using ::SetSysControllerType; +using ::SetSysDataBlock; +/// DataDeletionSettings +using ::SetSysDataDeletionSettings; +/// DeviceNickName +using ::SetSysDeviceNickName; +/// Edid +using ::SetSysEdid; +/// ErrorReportSharePermission +using ::SetSysErrorReportSharePermission; +/// EulaVersion +using ::SetSysEulaVersion; +/// EulaVersionClockType +using ::SetSysEulaVersionClockType; +using ::SetSysExtensionBlock; +/// Structure returned by \ref setsysGetFirmwareVersion. +using ::SetSysFirmwareVersion; +/// Structure returned by \ref setsysGetFirmwareVersionDigest. +using ::SetSysFirmwareVersionDigest; +/// FriendPresenceOverlayPermission +using ::SetSysFriendPresenceOverlayPermission; +/// HandheldSleepPlan +using ::SetSysHandheldSleepPlan; +/// Output from \ref setsysGetHomeMenuScheme. This contains RGBA8 colors which correspond with the physical shell of the system. +using ::SetSysHomeMenuScheme; +/// HostFsMountPoint +using ::SetSysHostFsMountPoint; +/// InitialLaunchSettings +using ::SetSysInitialLaunchSettings; +/// LcdBacklightBrightnessMapping +using ::SetSysLcdBacklightBrightnessMapping; +using ::SetSysModeLine; +/// NetworkSettings +using ::SetSysNetworkSettings; +/// NotificationSettings +using ::SetSysNotificationSettings; +/// NotificationTime +using ::SetSysNotificationTime; +/// NotificationVolume +using ::SetSysNotificationVolume; +/// NxControllerLegacySettings +using ::SetSysNxControllerLegacySettings; +/// NxControllerSettings +using ::SetSysNxControllerSettings; +/// PlatformRegion. Other values not listed here should be handled as "Unknown". +using ::SetSysPlatformRegion; +/// PrimaryAlbumStorage +using ::SetSysPrimaryAlbumStorage; +/// Console Product Models +using ::SetSysProductModel; +/// ProxyFlags +using ::SetSysProxyFlags; +/// PtmCycleCountReliability +using ::SetSysPtmCycleCountReliability; +/// PtmFuelGaugeParameter +using ::SetSysPtmFuelGaugeParameter; +/// RebootlessSystemUpdateVersion. This is the content of the RebootlessSystemUpdateVersion SystemData, in the "/version" file. +using ::SetSysRebootlessSystemUpdateVersion; +/// Structure returned by \ref setsysGetSerialNumber. +using ::SetSysSerialNumber; +/// ServiceDiscoveryControlSettings +using ::SetSysServiceDiscoveryControlSettings; +/// SleepSettings +using ::SetSysSleepSettings; +/// ThemeId +using ::SetSysThemeId; +/// ThemeSettings +using ::SetSysThemeSettings; +/// TouchScreenMode, for "Touch-Screen Sensitivity". +using ::SetSysTouchScreenMode; +/// TvSettings +using ::SetSysTvSettings; +/// UserSelectorFlag +using ::SetSysUserSelectorFlag; +/// UserSelectorSettings +using ::SetSysUserSelectorSettings; + +/// Initialize set. +Result Initialize(void); + +/// Exit set. +void Exit(void); + +/// Gets the Service object for the actual set service session. +Service* GetServiceSession(void); + +/// Converts LanguageCode to \ref SetLanguage. +Result MakeLanguage(u64 LanguageCode, SetLanguage *Language); + +/// Converts \ref SetLanguage to LanguageCode. +Result MakeLanguageCode(SetLanguage Language, u64 *LanguageCode); + +/// Gets the current system LanguageCode. +/// Normally this should be used instead of \ref setGetLanguageCode. +/// LanguageCode is a string, see here: https://switchbrew.org/wiki/Settings_services#LanguageCode +Result GetSystemLanguage(u64 *LanguageCode); + +/// Gets the current LanguageCode, \ref setGetSystemLanguage should be used instead normally. +Result GetLanguageCode(u64 *LanguageCode); + +/// Gets available LanguageCodes. +/// On system-version <4.0.0, max_entries is set to the output from \ref setGetAvailableLanguageCodeCount if max_entries is larger than that. +Result GetAvailableLanguageCodes(s32 *total_entries, u64 *LanguageCodes, size_t max_entries); + +/// Gets total available LanguageCodes. +/// Output total is overridden with value 0 if the total is <0. +Result GetAvailableLanguageCodeCount(s32 *total); + +/// Gets the RegionCode. +Result GetRegionCode(SetRegion *out); + +/** + * @brief GetQuestFlag + * @note Only available on [5.0.0+]. + * @param[out] out Output flag. + */ +Result GetQuestFlag(bool *out); + +/** + * @brief Gets the system's nickname. + * @note Only available on [10.1.0+]. + * @param[out] nickname \ref SetSysDeviceNickName + */ +Result GetDeviceNickname(SetSysDeviceNickName *nickname); + +} // namespace set + +/// @brief C++ wrappers for the `setcal` API. +/// @details Wraps: switch/services/set.h. +namespace setcal { + +using ::ColorSetId; +/// BatteryLot +using ::SetBatteryLot; +using ::SetCalAccelerometerOffset; +using ::SetCalAccelerometerScale; +using ::SetCalAmiiboEcdsaCertificate; +using ::SetCalAmiiboEcqvBlsCertificate; +using ::SetCalAmiiboEcqvBlsKey; +using ::SetCalAmiiboEcqvBlsRootCertificate; +using ::SetCalAmiiboEcqvCertificate; +using ::SetCalAmiiboKey; +using ::SetCalAnalogStickFactoryCalibration; +using ::SetCalAnalogStickModelParameter; +using ::SetCalBdAddress; +using ::SetCalConfigurationId1; +using ::SetCalConsoleSixAxisSensorHorizontalOffset; +using ::SetCalCountryCode; +using ::SetCalEccB233DeviceCertificate; +using ::SetCalEccB233DeviceKey; +using ::SetCalGameCardCertificate; +using ::SetCalGameCardKey; +using ::SetCalGyroscopeOffset; +using ::SetCalGyroscopeScale; +using ::SetCalMacAddress; +using ::SetCalRegionCode; +using ::SetCalRsa2048DeviceCertificate; +using ::SetCalRsa2048DeviceKey; +using ::SetCalSerialNumber; +using ::SetCalSpeakerParameter; +using ::SetCalSslCertificate; +using ::SetCalSslKey; +/// ChineseTraditionalInputMethod +using ::SetChineseTraditionalInputMethod; +/// KeyboardLayout +using ::SetKeyboardLayout; +/// IDs for Language. +using ::SetLanguage; +/// Region codes. +using ::SetRegion; +/// AccessPointSecurityStandard +using ::SetSysAccessPointSecurityStandard; +/// AccessPointSecurityType +using ::SetSysAccessPointSecurityType; +/// AccountNotificationSettings +using ::SetSysAccountNotificationSettings; +/// AccountOnlineStorageSettings +using ::SetSysAccountOnlineStorageSettings; +/// AccountSettings +using ::SetSysAccountSettings; +/// AllowedSslHosts +using ::SetSysAllowedSslHosts; +/// AnalogStickUserCalibration +using ::SetSysAnalogStickUserCalibration; +/// AudioDevice +using ::SetSysAudioDevice; +/// AudioOutputMode +using ::SetSysAudioOutputMode; +/// AudioOutputModeTarget +using ::SetSysAudioOutputModeTarget; +using ::SetSysAudioVolume; +/// AutoSettings +using ::SetSysAutoSettings; +/// BacklightSettings +using ::SetSysBacklightSettings; +/// BacklightSettingsEx +using ::SetSysBacklightSettingsEx; +/// BlePairingSettings +using ::SetSysBlePairingSettings; +/// BlockType +using ::SetSysBlockType; +/// BluetoothDevicesSettings +using ::SetSysBluetoothDevicesSettings; +/// ButtonConfigRegisteredSettings +using ::SetSysButtonConfigRegisteredSettings; +/// ButtonConfigSettings +using ::SetSysButtonConfigSettings; +/// Actually nn::util::Color4u8Type. +using ::SetSysColor4u8Type; +/// ConnectionFlag +using ::SetSysConnectionFlag; +/// ConsoleSixAxisSensorAccelerationBias +using ::SetSysConsoleSixAxisSensorAccelerationBias; +/// ConsoleSixAxisSensorAccelerationGain +using ::SetSysConsoleSixAxisSensorAccelerationGain; +/// ConsoleSixAxisSensorAngularAcceleration +using ::SetSysConsoleSixAxisSensorAngularAcceleration; +/// ConsoleSixAxisSensorAngularVelocityBias +using ::SetSysConsoleSixAxisSensorAngularVelocityBias; +/// ConsoleSixAxisSensorAngularVelocityGain +using ::SetSysConsoleSixAxisSensorAngularVelocityGain; +/// ConsoleSixAxisSensorAngularVelocityTimeBias +using ::SetSysConsoleSixAxisSensorAngularVelocityTimeBias; +/// ConsoleSleepPlan +using ::SetSysConsoleSleepPlan; +/// ControllerType +using ::SetSysControllerType; +using ::SetSysDataBlock; +/// DataDeletionSettings +using ::SetSysDataDeletionSettings; +/// DeviceNickName +using ::SetSysDeviceNickName; +/// Edid +using ::SetSysEdid; +/// ErrorReportSharePermission +using ::SetSysErrorReportSharePermission; +/// EulaVersion +using ::SetSysEulaVersion; +/// EulaVersionClockType +using ::SetSysEulaVersionClockType; +using ::SetSysExtensionBlock; +/// Structure returned by \ref setsysGetFirmwareVersion. +using ::SetSysFirmwareVersion; +/// Structure returned by \ref setsysGetFirmwareVersionDigest. +using ::SetSysFirmwareVersionDigest; +/// FriendPresenceOverlayPermission +using ::SetSysFriendPresenceOverlayPermission; +/// HandheldSleepPlan +using ::SetSysHandheldSleepPlan; +/// Output from \ref setsysGetHomeMenuScheme. This contains RGBA8 colors which correspond with the physical shell of the system. +using ::SetSysHomeMenuScheme; +/// HostFsMountPoint +using ::SetSysHostFsMountPoint; +/// InitialLaunchSettings +using ::SetSysInitialLaunchSettings; +/// LcdBacklightBrightnessMapping +using ::SetSysLcdBacklightBrightnessMapping; +using ::SetSysModeLine; +/// NetworkSettings +using ::SetSysNetworkSettings; +/// NotificationSettings +using ::SetSysNotificationSettings; +/// NotificationTime +using ::SetSysNotificationTime; +/// NotificationVolume +using ::SetSysNotificationVolume; +/// NxControllerLegacySettings +using ::SetSysNxControllerLegacySettings; +/// NxControllerSettings +using ::SetSysNxControllerSettings; +/// PlatformRegion. Other values not listed here should be handled as "Unknown". +using ::SetSysPlatformRegion; +/// PrimaryAlbumStorage +using ::SetSysPrimaryAlbumStorage; +/// Console Product Models +using ::SetSysProductModel; +/// ProxyFlags +using ::SetSysProxyFlags; +/// PtmCycleCountReliability +using ::SetSysPtmCycleCountReliability; +/// PtmFuelGaugeParameter +using ::SetSysPtmFuelGaugeParameter; +/// RebootlessSystemUpdateVersion. This is the content of the RebootlessSystemUpdateVersion SystemData, in the "/version" file. +using ::SetSysRebootlessSystemUpdateVersion; +/// Structure returned by \ref setsysGetSerialNumber. +using ::SetSysSerialNumber; +/// ServiceDiscoveryControlSettings +using ::SetSysServiceDiscoveryControlSettings; +/// SleepSettings +using ::SetSysSleepSettings; +/// ThemeId +using ::SetSysThemeId; +/// ThemeSettings +using ::SetSysThemeSettings; +/// TouchScreenMode, for "Touch-Screen Sensitivity". +using ::SetSysTouchScreenMode; +/// TvSettings +using ::SetSysTvSettings; +/// UserSelectorFlag +using ::SetSysUserSelectorFlag; +/// UserSelectorSettings +using ::SetSysUserSelectorSettings; + +/// Initialize setcal. +Result Initialize(void); + +/// Exit setcal. +void Exit(void); + +/// Gets the Service object for the actual setcal service session. +Service* GetServiceSession(void); + +/** + * @brief Gets the \ref SetCalBdAddress. + * @param[out] out \ref SetCalBdAddress + */ +Result GetBdAddress(SetCalBdAddress *out); + +/** + * @brief Gets the \ref SetCalConfigurationId1. + * @param[out] out \ref SetCalConfigurationId1 + */ +Result GetConfigurationId1(SetCalConfigurationId1 *out); + +/** + * @brief Gets the \ref SetCalAccelerometerOffset. + * @param[out] out \ref SetCalAccelerometerOffset + */ +Result GetAccelerometerOffset(SetCalAccelerometerOffset *out); + +/** + * @brief Gets the \ref SetCalAccelerometerScale. + * @param[out] out \ref SetCalAccelerometerScale + */ +Result GetAccelerometerScale(SetCalAccelerometerScale *out); + +/** + * @brief Gets the \ref SetCalGyroscopeOffset. + * @param[out] out \ref SetCalGyroscopeOffset + */ +Result GetGyroscopeOffset(SetCalGyroscopeOffset *out); + +/** + * @brief Gets the \ref SetCalGyroscopeScale. + * @param[out] out \ref SetCalGyroscopeScale + */ +Result GetGyroscopeScale(SetCalGyroscopeScale *out); + +/** + * @brief Gets the \ref SetCalMacAddress. + * @param[out] out \ref SetCalMacAddress + */ +Result GetWirelessLanMacAddress(SetCalMacAddress *out); + +/** + * @brief GetWirelessLanCountryCodeCount + * @param[out] out_count Output count + */ +Result GetWirelessLanCountryCodeCount(s32 *out_count); + +/** + * @brief GetWirelessLanCountryCodes + * @param[out] total_out Total output entries. + * @param[out] codes Output array of \ref SetCalCountryCode. + * @param[in] count Size of the versions array in entries. + */ +Result GetWirelessLanCountryCodes(s32 *total_out, SetCalCountryCode *codes, s32 count); + +/** + * @brief Gets the \ref SetCalSerialNumber. + * @param[out] out \ref SetCalSerialNumber + */ +Result GetSerialNumber(SetCalSerialNumber *out); + +/** + * @brief SetInitialSystemAppletProgramId + * @param[in] program_id input ProgramId. + */ +Result SetInitialSystemAppletProgramId(u64 program_id); + +/** + * @brief SetOverlayDispProgramId + * @param[in] program_id input ProgramId. + */ +Result SetOverlayDispProgramId(u64 program_id); + +/** + * @brief Gets the \ref SetBatteryLot. + * @param[out] out \ref SetBatteryLot + */ +Result GetBatteryLot(SetBatteryLot *out); + +/** + * @brief Gets the \ref SetCalEccB233DeviceCertificate. + * @param[out] out \ref SetCalEccB233DeviceCertificate + */ +Result GetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out); + +/** + * @brief Gets the \ref SetCalRsa2048DeviceCertificate. + * @param[out] out \ref SetCalRsa2048DeviceCertificate + */ +Result GetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out); + +/** + * @brief Gets the \ref SetCalSslKey. + * @param[out] out \ref SetCalSslKey + */ +Result GetSslKey(SetCalSslKey *out); + +/** + * @brief Gets the \ref SetCalSslCertificate. + * @param[out] out \ref SetCalSslCertificate + */ +Result GetSslCertificate(SetCalSslCertificate *out); + +/** + * @brief Gets the \ref SetCalGameCardKey. + * @param[out] out \ref SetCalGameCardKey + */ +Result GetGameCardKey(SetCalGameCardKey *out); + +/** + * @brief Gets the \ref SetCalGameCardCertificate. + * @param[out] out \ref SetCalGameCardCertificate + */ +Result GetGameCardCertificate(SetCalGameCardCertificate *out); + +/** + * @brief Gets the \ref SetCalEccB233DeviceKey. + * @param[out] out \ref SetCalEccB233DeviceKey + */ +Result GetEciDeviceKey(SetCalEccB233DeviceKey *out); + +/** + * @brief Gets the \ref SetCalRsa2048DeviceKey. + * @param[out] out \ref SetCalRsa2048DeviceKey + */ +Result GetEticketDeviceKey(SetCalRsa2048DeviceKey *out); + +/** + * @brief Gets the \ref SetCalSpeakerParameter. + * @param[out] out \ref SetCalSpeakerParameter + */ +Result GetSpeakerParameter(SetCalSpeakerParameter *out); + +/** + * @brief GetLcdVendorId + * @note Only available on [4.0.0+]. + * @param[out] out_vendor_id Output LcdVendorId. + */ +Result GetLcdVendorId(u32 *out_vendor_id); + +/** + * @brief Gets the \ref SetCalRsa2048DeviceCertificate. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalRsa2048DeviceCertificate + */ +Result GetEciDeviceCertificate2(SetCalRsa2048DeviceCertificate *out); + +/** + * @brief Gets the \ref SetCalRsa2048DeviceKey. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalRsa2048DeviceKey + */ +Result GetEciDeviceKey2(SetCalRsa2048DeviceKey *out); + +/** + * @brief Gets the \ref SetCalAmiiboKey. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalAmiiboKey + */ +Result GetAmiiboKey(SetCalAmiiboKey *out); + +/** + * @brief Gets the \ref SetCalAmiiboEcqvCertificate. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalAmiiboEcqvCertificate + */ +Result GetAmiiboEcqvCertificate(SetCalAmiiboEcqvCertificate *out); + +/** + * @brief Gets the \ref SetCalAmiiboEcdsaCertificate. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalAmiiboEcdsaCertificate + */ +Result GetAmiiboEcdsaCertificate(SetCalAmiiboEcdsaCertificate *out); + +/** + * @brief Gets the \ref SetCalAmiiboEcqvBlsKey. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalAmiiboEcqvBlsKey + */ +Result GetAmiiboEcqvBlsKey(SetCalAmiiboEcqvBlsKey *out); + +/** + * @brief Gets the \ref SetCalAmiiboEcqvBlsCertificate. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalAmiiboEcqvBlsCertificate + */ +Result GetAmiiboEcqvBlsCertificate(SetCalAmiiboEcqvBlsCertificate *out); + +/** + * @brief Gets the \ref SetCalAmiiboEcqvBlsRootCertificate. + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetCalAmiiboEcqvBlsRootCertificate + */ +Result GetAmiiboEcqvBlsRootCertificate(SetCalAmiiboEcqvBlsRootCertificate *out); + +/** + * @brief GetUsbTypeCPowerSourceCircuitVersion + * @note Only available on [5.0.0+]. + * @param[out] out_version Output UsbTypeCPowerSourceCircuitVersion. + */ +Result GetUsbTypeCPowerSourceCircuitVersion(u8 *out_version); + +/** + * @brief GetAnalogStickModuleTypeL + * @note Only available on [8.1.1+]. + * @param[out] out_version Output AnalogStickModuleType. + */ +Result GetAnalogStickModuleTypeL(u8 *out_type); + +/** + * @brief Gets the \ref SetCalAnalogStickModelParameter. + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetCalAnalogStickModelParameter + */ +Result GetAnalogStickModelParameterL(SetCalAnalogStickModelParameter *out); + +/** + * @brief Gets the \ref SetCalAnalogStickFactoryCalibration. + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetCalAnalogStickFactoryCalibration + */ +Result GetAnalogStickFactoryCalibrationL(SetCalAnalogStickFactoryCalibration *out); + +/** + * @brief GetAnalogStickModuleTypeR + * @note Only available on [8.1.1+]. + * @param[out] out_version Output AnalogStickModuleType. + */ +Result GetAnalogStickModuleTypeR(u8 *out_type); + +/** + * @brief Gets the \ref SetCalAnalogStickModelParameter. + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetCalAnalogStickModelParameter + */ +Result GetAnalogStickModelParameterR(SetCalAnalogStickModelParameter *out); + +/** + * @brief Gets the \ref SetCalAnalogStickFactoryCalibration. + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetCalAnalogStickFactoryCalibration + */ +Result GetAnalogStickFactoryCalibrationR(SetCalAnalogStickFactoryCalibration *out); + +/** + * @brief GetConsoleSixAxisSensorModuleType + * @note Only available on [8.1.1+]. + * @param[out] out_version Output ConsoleSixAxisSensorModuleType. + */ +Result GetConsoleSixAxisSensorModuleType(u8 *out_type); + +/** + * @brief Gets the \ref SetCalConsoleSixAxisSensorHorizontalOffset. + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetCalConsoleSixAxisSensorHorizontalOffset + */ +Result GetConsoleSixAxisSensorHorizontalOffset(SetCalConsoleSixAxisSensorHorizontalOffset *out); + +/** + * @brief GetBatteryVersion + * @note Only available on [6.0.0+]. + * @param[out] out_version Output BatteryVersion. + */ +Result GetBatteryVersion(u8 *out_version); + +/** + * @brief GetDeviceId + * @note Only available on [10.0.0+]. + * @param[out] out_type Output DeviceId. + */ +Result GetDeviceId(u64 *out_device_id); + +/** + * @brief GetConsoleSixAxisSensorMountType + * @note Only available on [10.0.0+]. + * @param[out] out_type Output ConsoleSixAxisSensorMountType. + */ +Result GetConsoleSixAxisSensorMountType(u8 *out_type); + +} // namespace setcal + +/// @brief C++ wrappers for the `setfd` API. +/// @details Wraps: switch/services/set.h. +namespace setfd { + +using ::ColorSetId; +/// BatteryLot +using ::SetBatteryLot; +using ::SetCalAccelerometerOffset; +using ::SetCalAccelerometerScale; +using ::SetCalAmiiboEcdsaCertificate; +using ::SetCalAmiiboEcqvBlsCertificate; +using ::SetCalAmiiboEcqvBlsKey; +using ::SetCalAmiiboEcqvBlsRootCertificate; +using ::SetCalAmiiboEcqvCertificate; +using ::SetCalAmiiboKey; +using ::SetCalAnalogStickFactoryCalibration; +using ::SetCalAnalogStickModelParameter; +using ::SetCalBdAddress; +using ::SetCalConfigurationId1; +using ::SetCalConsoleSixAxisSensorHorizontalOffset; +using ::SetCalCountryCode; +using ::SetCalEccB233DeviceCertificate; +using ::SetCalEccB233DeviceKey; +using ::SetCalGameCardCertificate; +using ::SetCalGameCardKey; +using ::SetCalGyroscopeOffset; +using ::SetCalGyroscopeScale; +using ::SetCalMacAddress; +using ::SetCalRegionCode; +using ::SetCalRsa2048DeviceCertificate; +using ::SetCalRsa2048DeviceKey; +using ::SetCalSerialNumber; +using ::SetCalSpeakerParameter; +using ::SetCalSslCertificate; +using ::SetCalSslKey; +/// ChineseTraditionalInputMethod +using ::SetChineseTraditionalInputMethod; +/// KeyboardLayout +using ::SetKeyboardLayout; +/// IDs for Language. +using ::SetLanguage; +/// Region codes. +using ::SetRegion; +/// AccessPointSecurityStandard +using ::SetSysAccessPointSecurityStandard; +/// AccessPointSecurityType +using ::SetSysAccessPointSecurityType; +/// AccountNotificationSettings +using ::SetSysAccountNotificationSettings; +/// AccountOnlineStorageSettings +using ::SetSysAccountOnlineStorageSettings; +/// AccountSettings +using ::SetSysAccountSettings; +/// AllowedSslHosts +using ::SetSysAllowedSslHosts; +/// AnalogStickUserCalibration +using ::SetSysAnalogStickUserCalibration; +/// AudioDevice +using ::SetSysAudioDevice; +/// AudioOutputMode +using ::SetSysAudioOutputMode; +/// AudioOutputModeTarget +using ::SetSysAudioOutputModeTarget; +using ::SetSysAudioVolume; +/// AutoSettings +using ::SetSysAutoSettings; +/// BacklightSettings +using ::SetSysBacklightSettings; +/// BacklightSettingsEx +using ::SetSysBacklightSettingsEx; +/// BlePairingSettings +using ::SetSysBlePairingSettings; +/// BlockType +using ::SetSysBlockType; +/// BluetoothDevicesSettings +using ::SetSysBluetoothDevicesSettings; +/// ButtonConfigRegisteredSettings +using ::SetSysButtonConfigRegisteredSettings; +/// ButtonConfigSettings +using ::SetSysButtonConfigSettings; +/// Actually nn::util::Color4u8Type. +using ::SetSysColor4u8Type; +/// ConnectionFlag +using ::SetSysConnectionFlag; +/// ConsoleSixAxisSensorAccelerationBias +using ::SetSysConsoleSixAxisSensorAccelerationBias; +/// ConsoleSixAxisSensorAccelerationGain +using ::SetSysConsoleSixAxisSensorAccelerationGain; +/// ConsoleSixAxisSensorAngularAcceleration +using ::SetSysConsoleSixAxisSensorAngularAcceleration; +/// ConsoleSixAxisSensorAngularVelocityBias +using ::SetSysConsoleSixAxisSensorAngularVelocityBias; +/// ConsoleSixAxisSensorAngularVelocityGain +using ::SetSysConsoleSixAxisSensorAngularVelocityGain; +/// ConsoleSixAxisSensorAngularVelocityTimeBias +using ::SetSysConsoleSixAxisSensorAngularVelocityTimeBias; +/// ConsoleSleepPlan +using ::SetSysConsoleSleepPlan; +/// ControllerType +using ::SetSysControllerType; +using ::SetSysDataBlock; +/// DataDeletionSettings +using ::SetSysDataDeletionSettings; +/// DeviceNickName +using ::SetSysDeviceNickName; +/// Edid +using ::SetSysEdid; +/// ErrorReportSharePermission +using ::SetSysErrorReportSharePermission; +/// EulaVersion +using ::SetSysEulaVersion; +/// EulaVersionClockType +using ::SetSysEulaVersionClockType; +using ::SetSysExtensionBlock; +/// Structure returned by \ref setsysGetFirmwareVersion. +using ::SetSysFirmwareVersion; +/// Structure returned by \ref setsysGetFirmwareVersionDigest. +using ::SetSysFirmwareVersionDigest; +/// FriendPresenceOverlayPermission +using ::SetSysFriendPresenceOverlayPermission; +/// HandheldSleepPlan +using ::SetSysHandheldSleepPlan; +/// Output from \ref setsysGetHomeMenuScheme. This contains RGBA8 colors which correspond with the physical shell of the system. +using ::SetSysHomeMenuScheme; +/// HostFsMountPoint +using ::SetSysHostFsMountPoint; +/// InitialLaunchSettings +using ::SetSysInitialLaunchSettings; +/// LcdBacklightBrightnessMapping +using ::SetSysLcdBacklightBrightnessMapping; +using ::SetSysModeLine; +/// NetworkSettings +using ::SetSysNetworkSettings; +/// NotificationSettings +using ::SetSysNotificationSettings; +/// NotificationTime +using ::SetSysNotificationTime; +/// NotificationVolume +using ::SetSysNotificationVolume; +/// NxControllerLegacySettings +using ::SetSysNxControllerLegacySettings; +/// NxControllerSettings +using ::SetSysNxControllerSettings; +/// PlatformRegion. Other values not listed here should be handled as "Unknown". +using ::SetSysPlatformRegion; +/// PrimaryAlbumStorage +using ::SetSysPrimaryAlbumStorage; +/// Console Product Models +using ::SetSysProductModel; +/// ProxyFlags +using ::SetSysProxyFlags; +/// PtmCycleCountReliability +using ::SetSysPtmCycleCountReliability; +/// PtmFuelGaugeParameter +using ::SetSysPtmFuelGaugeParameter; +/// RebootlessSystemUpdateVersion. This is the content of the RebootlessSystemUpdateVersion SystemData, in the "/version" file. +using ::SetSysRebootlessSystemUpdateVersion; +/// Structure returned by \ref setsysGetSerialNumber. +using ::SetSysSerialNumber; +/// ServiceDiscoveryControlSettings +using ::SetSysServiceDiscoveryControlSettings; +/// SleepSettings +using ::SetSysSleepSettings; +/// ThemeId +using ::SetSysThemeId; +/// ThemeSettings +using ::SetSysThemeSettings; +/// TouchScreenMode, for "Touch-Screen Sensitivity". +using ::SetSysTouchScreenMode; +/// TvSettings +using ::SetSysTvSettings; +/// UserSelectorFlag +using ::SetSysUserSelectorFlag; +/// UserSelectorSettings +using ::SetSysUserSelectorSettings; + +/// Initialize setfd. +/// [4.0.0+] Only exposed if in development mode. +Result Initialize(void); + +/// Exit setfd. +void Exit(void); + +/// Gets the Service object for the actual setfd service session. +Service* GetServiceSession(void); + +/** + * @brief Sets the value of a settings item. + * @param name Name string. + * @param item_key Item key string. + * @param value_in Pointer to input value. + * @param value_in_size Size of the value_in buffer. + */ +Result SetSettingsItemValue(const char *name, const char *item_key, const void *value_in, s64 value_in_size); + +/** + * @brief Resets the value of a settings item. + * @param name Name string. + * @param item_key Item key string. + */ +Result ResetSettingsItemValue(const char *name, const char *item_key); + +} // namespace setfd + +/// @brief C++ wrappers for the `setsys` API. +/// @details Wraps: switch/services/set.h. +namespace setsys { + +using ::ColorSetId; +/// BatteryLot +using ::SetBatteryLot; +using ::SetCalAccelerometerOffset; +using ::SetCalAccelerometerScale; +using ::SetCalAmiiboEcdsaCertificate; +using ::SetCalAmiiboEcqvBlsCertificate; +using ::SetCalAmiiboEcqvBlsKey; +using ::SetCalAmiiboEcqvBlsRootCertificate; +using ::SetCalAmiiboEcqvCertificate; +using ::SetCalAmiiboKey; +using ::SetCalAnalogStickFactoryCalibration; +using ::SetCalAnalogStickModelParameter; +using ::SetCalBdAddress; +using ::SetCalConfigurationId1; +using ::SetCalConsoleSixAxisSensorHorizontalOffset; +using ::SetCalCountryCode; +using ::SetCalEccB233DeviceCertificate; +using ::SetCalEccB233DeviceKey; +using ::SetCalGameCardCertificate; +using ::SetCalGameCardKey; +using ::SetCalGyroscopeOffset; +using ::SetCalGyroscopeScale; +using ::SetCalMacAddress; +using ::SetCalRegionCode; +using ::SetCalRsa2048DeviceCertificate; +using ::SetCalRsa2048DeviceKey; +using ::SetCalSerialNumber; +using ::SetCalSpeakerParameter; +using ::SetCalSslCertificate; +using ::SetCalSslKey; +/// IDs for Language. +using ::SetLanguage; +/// Region codes. +using ::SetRegion; +/// AccessPointSecurityStandard +using ::SetSysAccessPointSecurityStandard; +/// AccessPointSecurityType +using ::SetSysAccessPointSecurityType; +/// AccountNotificationSettings +using ::SetSysAccountNotificationSettings; +/// AccountOnlineStorageSettings +using ::SetSysAccountOnlineStorageSettings; +/// AccountSettings +using ::SetSysAccountSettings; +/// AllowedSslHosts +using ::SetSysAllowedSslHosts; +/// AnalogStickUserCalibration +using ::SetSysAnalogStickUserCalibration; +/// AudioDevice +using ::SetSysAudioDevice; +/// AudioOutputMode +using ::SetSysAudioOutputMode; +/// AudioOutputModeTarget +using ::SetSysAudioOutputModeTarget; +using ::SetSysAudioVolume; +/// AutoSettings +using ::SetSysAutoSettings; +/// BacklightSettings +using ::SetSysBacklightSettings; +/// BacklightSettingsEx +using ::SetSysBacklightSettingsEx; +/// BlePairingSettings +using ::SetSysBlePairingSettings; +/// BlockType +using ::SetSysBlockType; +/// BluetoothDevicesSettings +using ::SetSysBluetoothDevicesSettings; +/// ButtonConfigRegisteredSettings +using ::SetSysButtonConfigRegisteredSettings; +/// ButtonConfigSettings +using ::SetSysButtonConfigSettings; +/// Actually nn::util::Color4u8Type. +using ::SetSysColor4u8Type; +/// ConnectionFlag +using ::SetSysConnectionFlag; +/// ConsoleSixAxisSensorAccelerationBias +using ::SetSysConsoleSixAxisSensorAccelerationBias; +/// ConsoleSixAxisSensorAccelerationGain +using ::SetSysConsoleSixAxisSensorAccelerationGain; +/// ConsoleSixAxisSensorAngularAcceleration +using ::SetSysConsoleSixAxisSensorAngularAcceleration; +/// ConsoleSixAxisSensorAngularVelocityBias +using ::SetSysConsoleSixAxisSensorAngularVelocityBias; +/// ConsoleSixAxisSensorAngularVelocityGain +using ::SetSysConsoleSixAxisSensorAngularVelocityGain; +/// ConsoleSixAxisSensorAngularVelocityTimeBias +using ::SetSysConsoleSixAxisSensorAngularVelocityTimeBias; +/// ConsoleSleepPlan +using ::SetSysConsoleSleepPlan; +/// ControllerType +using ::SetSysControllerType; +using ::SetSysDataBlock; +/// DataDeletionSettings +using ::SetSysDataDeletionSettings; +/// DeviceNickName +using ::SetSysDeviceNickName; +/// Edid +using ::SetSysEdid; +/// ErrorReportSharePermission +using ::SetSysErrorReportSharePermission; +/// EulaVersion +using ::SetSysEulaVersion; +/// EulaVersionClockType +using ::SetSysEulaVersionClockType; +using ::SetSysExtensionBlock; +/// Structure returned by \ref setsysGetFirmwareVersion. +using ::SetSysFirmwareVersion; +/// Structure returned by \ref setsysGetFirmwareVersionDigest. +using ::SetSysFirmwareVersionDigest; +/// FriendPresenceOverlayPermission +using ::SetSysFriendPresenceOverlayPermission; +/// HandheldSleepPlan +using ::SetSysHandheldSleepPlan; +/// Output from \ref setsysGetHomeMenuScheme. This contains RGBA8 colors which correspond with the physical shell of the system. +using ::SetSysHomeMenuScheme; +/// HostFsMountPoint +using ::SetSysHostFsMountPoint; +/// InitialLaunchSettings +using ::SetSysInitialLaunchSettings; +/// LcdBacklightBrightnessMapping +using ::SetSysLcdBacklightBrightnessMapping; +using ::SetSysModeLine; +/// NetworkSettings +using ::SetSysNetworkSettings; +/// NotificationSettings +using ::SetSysNotificationSettings; +/// NotificationTime +using ::SetSysNotificationTime; +/// NotificationVolume +using ::SetSysNotificationVolume; +/// NxControllerLegacySettings +using ::SetSysNxControllerLegacySettings; +/// NxControllerSettings +using ::SetSysNxControllerSettings; +/// PlatformRegion. Other values not listed here should be handled as "Unknown". +using ::SetSysPlatformRegion; +/// PrimaryAlbumStorage +using ::SetSysPrimaryAlbumStorage; +/// Console Product Models +using ::SetSysProductModel; +/// ProxyFlags +using ::SetSysProxyFlags; +/// PtmCycleCountReliability +using ::SetSysPtmCycleCountReliability; +/// PtmFuelGaugeParameter +using ::SetSysPtmFuelGaugeParameter; +/// RebootlessSystemUpdateVersion. This is the content of the RebootlessSystemUpdateVersion SystemData, in the "/version" file. +using ::SetSysRebootlessSystemUpdateVersion; +/// Structure returned by \ref setsysGetSerialNumber. +using ::SetSysSerialNumber; +/// ServiceDiscoveryControlSettings +using ::SetSysServiceDiscoveryControlSettings; +/// SleepSettings +using ::SetSysSleepSettings; +/// ThemeId +using ::SetSysThemeId; +/// ThemeSettings +using ::SetSysThemeSettings; +/// TouchScreenMode, for "Touch-Screen Sensitivity". +using ::SetSysTouchScreenMode; +/// TvSettings +using ::SetSysTvSettings; +/// UserSelectorFlag +using ::SetSysUserSelectorFlag; +/// UserSelectorSettings +using ::SetSysUserSelectorSettings; + +/// Initialize setsys. +Result Initialize(void); + +/// Exit setsys. +void Exit(void); + +/// Gets the Service object for the actual setsys service session. +Service* GetServiceSession(void); + +/** + * @brief SetLanguageCode + * @param[in] LanguageCode LanguageCode. + */ +Result SetLanguageCode(u64 LanguageCode); + +/** + * @brief SetNetworkSettings + * @param[in] settings Input array of \ref SetSysNetworkSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetNetworkSettings(const SetSysNetworkSettings *settings, s32 count); + +/** + * @brief GetNetworkSettings + * @param[out] total_out Total output entries. + * @param[out] versions Output array of \ref SetSysNetworkSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetNetworkSettings(s32 *total_out, SetSysNetworkSettings *settings, s32 count); + +/** + * @brief Gets the system firmware version. + * @param[out] out Firmware version to populate. + */ +Result GetFirmwareVersion(SetSysFirmwareVersion *out); + +/** + * @brief GetFirmwareVersionDigest + * @param[out] out \ref SetSysFirmwareVersionDigest + */ +Result GetFirmwareVersionDigest(SetSysFirmwareVersionDigest *out); + +/** + * @brief GetLockScreenFlag + * @param[out] out Output flag. + */ +Result GetLockScreenFlag(bool *out); + +/** + * @brief SetLockScreenFlag + * @param[in] flag Input flag. + */ +Result SetLockScreenFlag(bool flag); + +/** + * @brief GetBacklightSettings + * @param[out] out \ref SetSysBacklightSettings + */ +Result GetBacklightSettings(SetSysBacklightSettings *out); + +/** + * @brief SetBacklightSettings + * @param[in] settings \ref SetSysBacklightSettings + */ +Result SetBacklightSettings(const SetSysBacklightSettings *settings); + +/** + * @brief SetBluetoothDevicesSettings + * @param[in] settings Input array of \ref SetSysBluetoothDevicesSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetBluetoothDevicesSettings(const SetSysBluetoothDevicesSettings *settings, s32 count); + +/** + * @brief GetBluetoothDevicesSettings + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysBluetoothDevicesSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetBluetoothDevicesSettings(s32 *total_out, SetSysBluetoothDevicesSettings *settings, s32 count); + +/** + * @brief GetExternalSteadyClockSourceId + * @param[out] out \ref Uuid + */ +Result GetExternalSteadyClockSourceId(Uuid *out); + +/** + * @brief SetExternalSteadyClockSourceId + * @param[in] uuid \ref Uuid + */ +Result SetExternalSteadyClockSourceId(const Uuid *uuid); + +/** + * @brief GetUserSystemClockContext + * @param[out] out \ref TimeSystemClockContext + */ +Result GetUserSystemClockContext(TimeSystemClockContext *out); + +/** + * @brief SetUserSystemClockContext + * @param[in] context \ref TimeSystemClockContext + */ +Result SetUserSystemClockContext(const TimeSystemClockContext *context); + +/** + * @brief GetAccountSettings + * @param[out] out \ref SetSysAccountSettings + */ +Result GetAccountSettings(SetSysAccountSettings *out); + +/** + * @brief SetAccountSettings + * @param[in] settings \ref SetSysAccountSettings + */ +Result SetAccountSettings(SetSysAccountSettings settings); + +/** + * @brief GetAudioVolume + * @param[in] device \ref SetSysAudioDevice + * @param[out] out \ref SetSysAudioVolume + */ +Result GetAudioVolume(SetSysAudioDevice device, SetSysAudioVolume *out); + +/** + * @brief SetAudioVolume + * @param[in] device \ref SetSysAudioDevice + * @param[in] volume \ref SetSysAudioVolume + */ +Result SetAudioVolume(SetSysAudioDevice device, const SetSysAudioVolume *volume); + +/** + * @brief GetEulaVersions + * @param[out] total_out Total output entries. + * @param[out] versions Output array of \ref SetSysEulaVersion. + * @param[in] count Size of the versions array in entries. + */ +Result GetEulaVersions(s32 *total_out, SetSysEulaVersion *versions, s32 count); + +/** + * @brief SetEulaVersions + * @param[in] versions Input array of \ref SetSysEulaVersion. + * @param[in] count Size of the versions array in entries. + */ +Result SetEulaVersions(const SetSysEulaVersion *versions, s32 count); + +/// Gets the current system theme. +Result GetColorSetId(ColorSetId *out); + +/// Sets the current system theme. +Result SetColorSetId(ColorSetId id); + +/** + * @brief GetConsoleInformationUploadFlag + * @param[out] out Output flag. + */ +Result GetConsoleInformationUploadFlag(bool *out); + +/** + * @brief SetConsoleInformationUploadFlag + * @param[in] flag Input flag. + */ +Result SetConsoleInformationUploadFlag(bool flag); + +/** + * @brief GetAutomaticApplicationDownloadFlag + * @param[out] out Output flag. + */ +Result GetAutomaticApplicationDownloadFlag(bool *out); + +/** + * @brief SetAutomaticApplicationDownloadFlag + * @param[in] flag Input flag. + */ +Result SetAutomaticApplicationDownloadFlag(bool flag); + +/** + * @brief GetNotificationSettings + * @param[out] out \ref SetSysNotificationSettings + */ +Result GetNotificationSettings(SetSysNotificationSettings *out); + +/** + * @brief SetNotificationSettings + * @param[in] settings \ref SetSysNotificationSettings + */ +Result SetNotificationSettings(const SetSysNotificationSettings *settings); + +/** + * @brief GetAccountNotificationSettings + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysAccountNotificationSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetAccountNotificationSettings(s32 *total_out, SetSysAccountNotificationSettings *settings, s32 count); + +/** + * @brief SetAccountNotificationSettings + * @param[in] settings Input array of \ref SetSysAccountNotificationSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetAccountNotificationSettings(const SetSysAccountNotificationSettings *settings, s32 count); + +/** + * @brief GetVibrationMasterVolume + * @param[out] out Output volume. + */ +Result GetVibrationMasterVolume(float *out); + +/** + * @brief SetVibrationMasterVolume + * @param[in] volume Input volume. + */ +Result SetVibrationMasterVolume(float volume); + +/** + * @brief Gets the size of a settings item value. + * @param name Name string. + * @param item_key Item key string. + * @param size_out Pointer to output the size to. + */ +Result GetSettingsItemValueSize(const char *name, const char *item_key, u64 *size_out); + +/** + * @brief Gets the value of a settings item. + * @param name Name string. + * @param item_key Item key string. + * @param value_out Pointer to output the value to. + * @param value_out_size Size of the value_out buffer. + * @param size_out Total size which was copied to value_out. + */ +Result GetSettingsItemValue(const char *name, const char *item_key, void *value_out, size_t value_out_size, u64 *size_out); + +/** + * @brief GetTvSettings + * @param[out] out \ref SetSysTvSettings + */ +Result GetTvSettings(SetSysTvSettings *out); + +/** + * @brief SetTvSettings + * @param[in] settings \ref SetSysTvSettings + */ +Result SetTvSettings(const SetSysTvSettings *settings); + +/** + * @brief GetEdid + * @param[out] out \ref SetSysEdid + */ +Result GetEdid(SetSysEdid *out); + +/** + * @brief SetEdid + * @param[in] edid \ref SetSysEdid + */ +Result SetEdid(const SetSysEdid *edid); + +/** + * @brief GetAudioOutputMode + * @param[in] target \ref SetSysAudioOutputModeTarget + * @param[out] out \ref SetSysAudioOutputMode + */ +Result GetAudioOutputMode(SetSysAudioOutputModeTarget target, SetSysAudioOutputMode *out); + +/** + * @brief SetAudioOutputMode + * @param[in] target \ref SetSysAudioOutputModeTarget + * @param[in] mode \ref SetSysAudioOutputMode + */ +Result SetAudioOutputMode(SetSysAudioOutputModeTarget target, SetSysAudioOutputMode mode); + +/** + * @brief GetSpeakerAutoMuteFlag + * @param[out] out Output flag. + */ +Result GetSpeakerAutoMuteFlag(bool *out); + +/** + * @brief SetSpeakerAutoMuteFlag + * @param[in] flag Input flag. + */ +Result SetSpeakerAutoMuteFlag(bool flag); + +/** + * @brief GetQuestFlag + * @param[out] out Output flag. + */ +Result GetQuestFlag(bool *out); + +/** + * @brief SetQuestFlag + * @param[in] flag Input flag. + */ +Result SetQuestFlag(bool flag); + +/** + * @brief GetDataDeletionSettings + * @param[out] out \ref SetSysDataDeletionSettings + */ +Result GetDataDeletionSettings(SetSysDataDeletionSettings *out); + +/** + * @brief SetDataDeletionSettings + * @param[in] settings \ref SetSysDataDeletionSettings + */ +Result SetDataDeletionSettings(const SetSysDataDeletionSettings *settings); + +/** + * @brief GetInitialSystemAppletProgramId + * @param[out] out output ProgramId. + */ +Result GetInitialSystemAppletProgramId(u64 *out); + +/** + * @brief GetOverlayDispProgramId + * @param[out] out output ProgramId. + */ +Result GetOverlayDispProgramId(u64 *out); + +/** + * @brief GetDeviceTimeZoneLocationName + * @param[out] out \ref TimeLocationName + */ +Result GetDeviceTimeZoneLocationName(TimeLocationName *out); + +/** + * @brief SetDeviceTimeZoneLocationName + * @param[in] name \ref TimeLocationName + */ +Result SetDeviceTimeZoneLocationName(const TimeLocationName *name); + +/** + * @brief GetWirelessCertificationFileSize + * @param[out] out_size Output size. + */ +Result GetWirelessCertificationFileSize(u64 *out_size); + +/** + * @brief GetWirelessCertificationFile + * @param[out] buffer Output buffer. + * @param[in] size Output buffer size. + * @param[out] out_size Output size. + */ +Result GetWirelessCertificationFile(void* buffer, size_t size, u64 *out_size); + +/** + * @brief SetRegionCode + * @param[in] region \ref SetRegion + */ +Result SetRegionCode(SetRegion region); + +/** + * @brief GetNetworkSystemClockContext + * @param[out] out \ref TimeSystemClockContext + */ +Result GetNetworkSystemClockContext(TimeSystemClockContext *out); + +/** + * @brief SetNetworkSystemClockContext + * @param[in] context \ref TimeSystemClockContext + */ +Result SetNetworkSystemClockContext(const TimeSystemClockContext *context); + +/** + * @brief IsUserSystemClockAutomaticCorrectionEnabled + * @param[out] out Output flag. + */ +Result IsUserSystemClockAutomaticCorrectionEnabled(bool *out); + +/** + * @brief SetUserSystemClockAutomaticCorrectionEnabled + * @param[in] flag Input flag. + */ +Result SetUserSystemClockAutomaticCorrectionEnabled(bool flag); + +/** + * @brief GetDebugModeFlag + * @param[out] out Output flag. + */ +Result GetDebugModeFlag(bool *out); + +/** + * @brief GetPrimaryAlbumStorage + * @param[out] out \ref GetPrimaryAlbumStorage + */ +Result GetPrimaryAlbumStorage(SetSysPrimaryAlbumStorage *out); + +/** + * @brief SetPrimaryAlbumStorage + * @param[in] storage \ref SetSysPrimaryAlbumStorage + */ +Result SetPrimaryAlbumStorage(SetSysPrimaryAlbumStorage storage); + +/** + * @brief GetUsb30EnableFlag + * @param[out] out Output flag. + */ +Result GetUsb30EnableFlag(bool *out); + +/** + * @brief SetUsb30EnableFlag + * @param[in] flag Input flag. + */ +Result SetUsb30EnableFlag(bool flag); + +/** + * @brief Gets the \ref SetBatteryLot. + * @param[out] out \ref SetBatteryLot + */ +Result GetBatteryLot(SetBatteryLot *out); + +/** + * @brief Gets the system's serial number. + * @param[out] out \ref SetSysSerialNumber + */ +Result GetSerialNumber(SetSysSerialNumber *out); + +/** + * @brief GetNfcEnableFlag + * @param[out] out Output flag. + */ +Result GetNfcEnableFlag(bool *out); + +/** + * @brief SetNfcEnableFlag + * @param[in] flag Input flag. + */ +Result SetNfcEnableFlag(bool flag); + +/** + * @brief GetSleepSettings + * @param[out] out \ref SetSysSleepSettings + */ +Result GetSleepSettings(SetSysSleepSettings *out); + +/** + * @brief SetSleepSettings + * @param[in] settings \ref SetSysSleepSettings + */ +Result SetSleepSettings(const SetSysSleepSettings *settings); + +/** + * @brief GetWirelessLanEnableFlag + * @param[out] out Output flag. + */ +Result GetWirelessLanEnableFlag(bool *out); + +/** + * @brief SetWirelessLanEnableFlag + * @param[in] flag Input flag. + */ +Result SetWirelessLanEnableFlag(bool flag); + +/** + * @brief GetInitialLaunchSettings + * @param[out] out \ref SetSysInitialLaunchSettings + */ +Result GetInitialLaunchSettings(SetSysInitialLaunchSettings *out); + +/** + * @brief SetInitialLaunchSettings + * @param[in] settings \ref SetSysInitialLaunchSettings + */ +Result SetInitialLaunchSettings(const SetSysInitialLaunchSettings *settings); + +/** + * @brief Gets the system's nickname. + * @note Same as \ref setGetDeviceNickname, which official sw uses instead on [10.1.0+]. + * @param[out] nickname \ref SetSysDeviceNickName + */ +Result GetDeviceNickname(SetSysDeviceNickName *nickname); + +/** + * @brief Sets the system's nickname. + * @param[in] nickname \ref SetSysDeviceNickName + */ +Result SetDeviceNickname(const SetSysDeviceNickName *nickname); + +/** + * @brief GetProductModel + * @param[out] model Output SetSysProductModel. + */ +Result GetProductModel(SetSysProductModel *model); + +/** + * @brief GetLdnChannel + * @param[out] out Output LdnChannel. + */ +Result GetLdnChannel(s32 *out); + +/** + * @brief SetLdnChannel + * @param[in] channel Input LdnChannel. + */ +Result SetLdnChannel(s32 channel); + +/** + * @brief Gets an event that settings will signal on flag change. + * @param out_event Event to bind. Output event will have autoclear=false. + */ +Result AcquireTelemetryDirtyFlagEventHandle(Event *out_event); + +/** + * @brief Gets the settings flags that have changed. + * @param flags_0 Pointer to populate with first 64 flags. + * @param flags_1 Pointer to populate with second 64 flags. + */ +Result GetTelemetryDirtyFlags(u64 *flags_0, u64 *flags_1); + +/** + * @brief GetPtmBatteryLot + * @param[out] out \ref SetBatteryLot + */ +Result GetPtmBatteryLot(SetBatteryLot *out); + +/** + * @brief SetPtmBatteryLot + * @param[in] lot \ref SetBatteryLot + */ +Result SetPtmBatteryLot(const SetBatteryLot *lot); + +/** + * @brief GetPtmFuelGaugeParameter + * @param[out] out \ref SetSysPtmFuelGaugeParameter + */ +Result GetPtmFuelGaugeParameter(SetSysPtmFuelGaugeParameter *out); + +/** + * @brief SetPtmFuelGaugeParameter + * @param[in] parameter \ref SetSysPtmFuelGaugeParameter + */ +Result SetPtmFuelGaugeParameter(const SetSysPtmFuelGaugeParameter *parameter); + +/** + * @brief GetBluetoothEnableFlag + * @param[out] out Output flag. + */ +Result GetBluetoothEnableFlag(bool *out); + +/** + * @brief SetBluetoothEnableFlag + * @param[in] flag Input flag. + */ +Result SetBluetoothEnableFlag(bool flag); + +/** + * @brief GetMiiAuthorId + * @param[out] out Output MiiAuthorId. + */ +Result GetMiiAuthorId(Uuid *out); + +/** + * @brief SetShutdownRtcValue + * @param[in] value Input value. + */ +Result SetShutdownRtcValue(u64 value); + +/** + * @brief GetShutdownRtcValue + * @param[out] out Output value. + */ +Result GetShutdownRtcValue(u64 *out); + +/** + * @brief Gets an event that settings will signal on flag change. + * @param out_event Event to bind. Output event will have autoclear=false. + */ +Result AcquireFatalDirtyFlagEventHandle(Event *out_event); + +/** + * @brief Gets the settings flags that have changed. + * @param flags_0 Pointer to populate with first 64 flags. + * @param flags_1 Pointer to populate with second 64 flags. + */ +Result GetFatalDirtyFlags(u64 *flags_0, u64 *flags_1); + +/** + * @brief GetAutoUpdateEnableFlag + * @note Only available on [2.0.0+]. + * @param[out] out Output flag. + */ +Result GetAutoUpdateEnableFlag(bool *out); + +/** + * @brief SetAutoUpdateEnableFlag + * @note Only available on [2.0.0+]. + * @param[in] flag Input flag. + */ +Result SetAutoUpdateEnableFlag(bool flag); + +/** + * @brief GetNxControllerSettings + * @note On [13.0.0+] \ref setsysGetNxControllerSettingsEx should be used instead. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysNxControllerLegacySettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetNxControllerSettings(s32 *total_out, SetSysNxControllerLegacySettings *settings, s32 count); + +/** + * @brief SetNxControllerSettings + * @note On [13.0.0+] \ref setsysSetNxControllerSettingsEx should be used instead. + * @param[in] settings Input array of \ref SetSysNxControllerLegacySettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetNxControllerSettings(const SetSysNxControllerLegacySettings *settings, s32 count); + +/** + * @brief GetBatteryPercentageFlag + * @note Only available on [2.0.0+]. + * @param[out] out Output flag. + */ +Result GetBatteryPercentageFlag(bool *out); + +/** + * @brief SetBatteryPercentageFlag + * @note Only available on [2.0.0+]. + * @param[in] flag Input flag. + */ +Result SetBatteryPercentageFlag(bool flag); + +/** + * @brief GetExternalRtcResetFlag + * @note Only available on [2.0.0+]. + * @param[out] out Output flag. + */ +Result GetExternalRtcResetFlag(bool *out); + +/** + * @brief SetExternalRtcResetFlag + * @note Only available on [2.0.0+]. + * @param[in] flag Input flag. + */ +Result SetExternalRtcResetFlag(bool flag); + +/** + * @brief GetUsbFullKeyEnableFlag + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result GetUsbFullKeyEnableFlag(bool *out); + +/** + * @brief SetUsbFullKeyEnableFlag + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result SetUsbFullKeyEnableFlag(bool flag); + +/** + * @brief SetExternalSteadyClockInternalOffset + * @note Only available on [3.0.0+]. + * @param[in] offset Input offset. + */ +Result SetExternalSteadyClockInternalOffset(u64 offset); + +/** + * @brief GetExternalSteadyClockInternalOffset + * @note Only available on [3.0.0+]. + * @param[out] out Output offset. + */ +Result GetExternalSteadyClockInternalOffset(u64 *out); + +/** + * @brief GetBacklightSettingsEx + * @note Only available on [3.0.0+]. + * @param[out] out \ref SetSysBacklightSettingsEx + */ +Result GetBacklightSettingsEx(SetSysBacklightSettingsEx *out); + +/** + * @brief SetBacklightSettingsEx + * @note Only available on [3.0.0+]. + * @param[in] settings \ref SetSysBacklightSettingsEx + */ +Result SetBacklightSettingsEx(const SetSysBacklightSettingsEx *settings); + +/** + * @brief GetHeadphoneVolumeWarningCount + * @note Only available on [3.0.0+]. + * @param[out] out Output count. + */ +Result GetHeadphoneVolumeWarningCount(u32 *out); + +/** + * @brief SetHeadphoneVolumeWarningCount + * @note Only available on [3.0.0+]. + * @param[in] count Input count. + */ +Result SetHeadphoneVolumeWarningCount(u32 count); + +/** + * @brief GetBluetoothAfhEnableFlag + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result GetBluetoothAfhEnableFlag(bool *out); + +/** + * @brief SetBluetoothAfhEnableFlag + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result SetBluetoothAfhEnableFlag(bool flag); + +/** + * @brief GetBluetoothBoostEnableFlag + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result GetBluetoothBoostEnableFlag(bool *out); + +/** + * @brief SetBluetoothBoostEnableFlag + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result SetBluetoothBoostEnableFlag(bool flag); + +/** + * @brief GetInRepairProcessEnableFlag + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result GetInRepairProcessEnableFlag(bool *out); + +/** + * @brief SetInRepairProcessEnableFlag + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result SetInRepairProcessEnableFlag(bool flag); + +/** + * @brief GetHeadphoneVolumeUpdateFlag + * @note Only available on [3.0.0+]. + * @param[out] out Output flag. + */ +Result GetHeadphoneVolumeUpdateFlag(bool *out); + +/** + * @brief SetHeadphoneVolumeUpdateFlag + * @note Only available on [3.0.0+]. + * @param[in] flag Input flag. + */ +Result SetHeadphoneVolumeUpdateFlag(bool flag); + +/** + * @brief NeedsToUpdateHeadphoneVolume + * @note Only available on [3.0.0-14.1.2]. + * @param[out] a0 Output arg. + * @param[out] a1 Output arg. + * @param[out] a2 Output arg. + * @param[in] flag Input flag. + */ +Result NeedsToUpdateHeadphoneVolume(u8 *a0, u8 *a1, u8 *a2, bool flag); + +/** + * @brief GetPushNotificationActivityModeOnSleep + * @note Only available on [3.0.0+]. + * @param[out] out Output mode. + */ +Result GetPushNotificationActivityModeOnSleep(u32 *out); + +/** + * @brief SetPushNotificationActivityModeOnSleep + * @note Only available on [3.0.0+]. + * @param[in] mode Input mode. + */ +Result SetPushNotificationActivityModeOnSleep(u32 mode); + +/** + * @brief GetServiceDiscoveryControlSettings + * @note Only available on [4.0.0+]. + * @param[out] out \ref ServiceDiscoveryControlSettings + */ +Result GetServiceDiscoveryControlSettings(SetSysServiceDiscoveryControlSettings *out); + +/** + * @brief SetServiceDiscoveryControlSettings + * @note Only available on [4.0.0+]. + * @param[in] settings \ref ServiceDiscoveryControlSettings + */ +Result SetServiceDiscoveryControlSettings(SetSysServiceDiscoveryControlSettings settings); + +/** + * @brief GetErrorReportSharePermission + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetSysErrorReportSharePermission + */ +Result GetErrorReportSharePermission(SetSysErrorReportSharePermission *out); + +/** + * @brief SetErrorReportSharePermission + * @note Only available on [4.0.0+]. + * @param[in] permission \ref SetSysErrorReportSharePermission + */ +Result SetErrorReportSharePermission(SetSysErrorReportSharePermission permission); + +/** + * @brief GetAppletLaunchFlags + * @note Only available on [4.0.0+]. + * @param[out] out Output AppletLaunchFlags bitmask. + */ +Result GetAppletLaunchFlags(u32 *out); + +/** + * @brief SetAppletLaunchFlags + * @note Only available on [4.0.0+]. + * @param[in] flags Input AppletLaunchFlags bitmask. + */ +Result SetAppletLaunchFlags(u32 flags); + +/** + * @brief GetConsoleSixAxisSensorAccelerationBias + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetSysConsoleSixAxisSensorAccelerationBias + */ +Result GetConsoleSixAxisSensorAccelerationBias(SetSysConsoleSixAxisSensorAccelerationBias *out); + +/** + * @brief SetConsoleSixAxisSensorAccelerationBias + * @note Only available on [4.0.0+]. + * @param[in] bias \ref SetSysConsoleSixAxisSensorAccelerationBias + */ +Result SetConsoleSixAxisSensorAccelerationBias(const SetSysConsoleSixAxisSensorAccelerationBias *bias); + +/** + * @brief GetConsoleSixAxisSensorAngularVelocityBias + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetSysConsoleSixAxisSensorAngularVelocityBias + */ +Result GetConsoleSixAxisSensorAngularVelocityBias(SetSysConsoleSixAxisSensorAngularVelocityBias *out); + +/** + * @brief SetConsoleSixAxisSensorAngularVelocityBias + * @note Only available on [4.0.0+]. + * @param[in] bias \ref SetSysConsoleSixAxisSensorAngularVelocityBias + */ +Result SetConsoleSixAxisSensorAngularVelocityBias(const SetSysConsoleSixAxisSensorAngularVelocityBias *bias); + +/** + * @brief GetConsoleSixAxisSensorAccelerationGain + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetSysConsoleSixAxisSensorAccelerationGain + */ +Result GetConsoleSixAxisSensorAccelerationGain(SetSysConsoleSixAxisSensorAccelerationGain *out); + +/** + * @brief SetConsoleSixAxisSensorAccelerationGain + * @note Only available on [4.0.0+]. + * @param[in] gain \ref SetSysConsoleSixAxisSensorAccelerationGain + */ +Result SetConsoleSixAxisSensorAccelerationGain(const SetSysConsoleSixAxisSensorAccelerationGain *gain); + +/** + * @brief GetConsoleSixAxisSensorAngularVelocityGain + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetSysConsoleSixAxisSensorAngularVelocityGain + */ +Result GetConsoleSixAxisSensorAngularVelocityGain(SetSysConsoleSixAxisSensorAngularVelocityGain *out); + +/** + * @brief SetConsoleSixAxisSensorAngularVelocityGain + * @note Only available on [4.0.0+]. + * @param[in] gain \ref SetSysConsoleSixAxisSensorAngularVelocityGain + */ +Result SetConsoleSixAxisSensorAngularVelocityGain(const SetSysConsoleSixAxisSensorAngularVelocityGain *gain); + +/** + * @brief GetKeyboardLayout + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetKeyboardLayout + */ +Result GetKeyboardLayout(::SetKeyboardLayout *out); + +/** + * @brief SetKeyboardLayout + * @note Only available on [4.0.0+]. + * @param[in] layout \ref SetKeyboardLayout + */ +Result SetKeyboardLayout(::SetKeyboardLayout layout); + +/** + * @brief GetWebInspectorFlag + * @note Only available on [4.0.0+]. + * @param[out] out Output flag. + */ +Result GetWebInspectorFlag(bool *out); + +/** + * @brief GetAllowedSslHosts + * @note Only available on [4.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] out Output array of \ref SetSysAllowedSslHosts. + * @param[in] count Size of the hosts array in entries. + */ +Result GetAllowedSslHosts(s32 *total_out, SetSysAllowedSslHosts *out, s32 count); + +/** + * @brief GetHostFsMountPoint + * @note Only available on [4.0.0+]. + * @param[out] out \ref SetSysHostFsMountPoint + */ +Result GetHostFsMountPoint(SetSysHostFsMountPoint *out); + +/** + * @brief GetRequiresRunRepairTimeReviser + * @note Only available on [5.0.0+]. + * @param[out] out Output flag. + */ +Result GetRequiresRunRepairTimeReviser(bool *out); + +/** + * @brief SetRequiresRunRepairTimeReviser + * @note Only available on [5.0.0+]. + * @param[in] flag Input flag. + */ +Result SetRequiresRunRepairTimeReviser(bool flag); + +/** + * @brief SetBlePairingSettings + * @note Only available on [5.0.0+]. + * @param[in] settings Input array of \ref SetSysBlePairingSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetBlePairingSettings(const SetSysBlePairingSettings *settings, s32 count); + +/** + * @brief GetBlePairingSettings + * @note Only available on [5.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysBlePairingSettings. + * @param[in] count Size of the hosts array in entries. + */ +Result GetBlePairingSettings(s32 *total_out, SetSysBlePairingSettings *settings, s32 count); + +/** + * @brief GetConsoleSixAxisSensorAngularVelocityTimeBias + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetSysConsoleSixAxisSensorAngularVelocityTimeBias + */ +Result GetConsoleSixAxisSensorAngularVelocityTimeBias(SetSysConsoleSixAxisSensorAngularVelocityTimeBias *out); + +/** + * @brief SetConsoleSixAxisSensorAngularVelocityTimeBias + * @note Only available on [5.0.0+]. + * @param[in] bias \ref SetSysConsoleSixAxisSensorAngularVelocityTimeBias + */ +Result SetConsoleSixAxisSensorAngularVelocityTimeBias(const SetSysConsoleSixAxisSensorAngularVelocityTimeBias *bias); + +/** + * @brief GetConsoleSixAxisSensorAngularAcceleration + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetSysConsoleSixAxisSensorAngularAcceleration + */ +Result GetConsoleSixAxisSensorAngularAcceleration(SetSysConsoleSixAxisSensorAngularAcceleration *out); + +/** + * @brief SetConsoleSixAxisSensorAngularAcceleration + * @note Only available on [5.0.0+]. + * @param[in] acceleration \ref SetSysConsoleSixAxisSensorAngularAcceleration + */ +Result SetConsoleSixAxisSensorAngularAcceleration(const SetSysConsoleSixAxisSensorAngularAcceleration *acceleration); + +/** + * @brief GetRebootlessSystemUpdateVersion + * @note Only available on [5.0.0+]. + * @param[out] out \ref SetSysRebootlessSystemUpdateVersion + */ +Result GetRebootlessSystemUpdateVersion(SetSysRebootlessSystemUpdateVersion *out); + +/** + * @brief GetDeviceTimeZoneLocationUpdatedTime + * @note Only available on [5.0.0+]. + * @param[out] out \ref TimeSteadyClockTimePoint + */ +Result GetDeviceTimeZoneLocationUpdatedTime(TimeSteadyClockTimePoint *out); + +/** + * @brief SetDeviceTimeZoneLocationUpdatedTime + * @note Only available on [5.0.0+]. + * @param[in] time_point \ref TimeSteadyClockTimePoint + */ +Result SetDeviceTimeZoneLocationUpdatedTime(const TimeSteadyClockTimePoint *time_point); + +/** + * @brief GetUserSystemClockAutomaticCorrectionUpdatedTime + * @note Only available on [6.0.0+]. + * @param[out] out \ref TimeSteadyClockTimePoint + */ +Result GetUserSystemClockAutomaticCorrectionUpdatedTime(TimeSteadyClockTimePoint *out); + +/** + * @brief SetUserSystemClockAutomaticCorrectionUpdatedTime + * @note Only available on [6.0.0+]. + * @param[in] time_point \ref TimeSteadyClockTimePoint + */ +Result SetUserSystemClockAutomaticCorrectionUpdatedTime(const TimeSteadyClockTimePoint *time_point); + +/** + * @brief GetAccountOnlineStorageSettings + * @note Only available on [6.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysAccountOnlineStorageSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetAccountOnlineStorageSettings(s32 *total_out, SetSysAccountOnlineStorageSettings *settings, s32 count); + +/** + * @brief SetAccountOnlineStorageSettings + * @note Only available on [6.0.0+]. + * @param[in] settings Input array of \ref SetSysAccountOnlineStorageSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetAccountOnlineStorageSettings(const SetSysAccountOnlineStorageSettings *settings, s32 count); + +/** + * @brief GetPctlReadyFlag + * @note Only available on [6.0.0+]. + * @param[out] out Output flag. + */ +Result GetPctlReadyFlag(bool *out); + +/** + * @brief SetPctlReadyFlag + * @note Only available on [6.0.0+]. + * @param[in] flag Input flag. + */ +Result SetPctlReadyFlag(bool flag); + +/** + * @brief GetAnalogStickUserCalibrationL + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetSysAnalogStickUserCalibration + */ +Result GetAnalogStickUserCalibrationL(SetSysAnalogStickUserCalibration *out); + +/** + * @brief SetAnalogStickUserCalibrationL + * @note Only available on [8.1.1+]. + * @param[in] calibration \ref SetSysAnalogStickUserCalibration + */ +Result SetAnalogStickUserCalibrationL(const SetSysAnalogStickUserCalibration *calibration); + +/** + * @brief GetAnalogStickUserCalibrationR + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetSysAnalogStickUserCalibration + */ +Result GetAnalogStickUserCalibrationR(SetSysAnalogStickUserCalibration *out); + +/** + * @brief SetAnalogStickUserCalibrationR + * @note Only available on [8.1.1+]. + * @param[in] calibration \ref SetSysAnalogStickUserCalibration + */ +Result SetAnalogStickUserCalibrationR(const SetSysAnalogStickUserCalibration *calibration); + +/** + * @brief GetPtmBatteryVersion + * @note Only available on [6.0.0+]. + * @param[out] out Output version. + */ +Result GetPtmBatteryVersion(u8 *out); + +/** + * @brief SetPtmBatteryVersion + * @note Only available on [6.0.0+]. + * @param[in] version Input version. + */ +Result SetPtmBatteryVersion(u8 version); + +/** + * @brief GetUsb30HostEnableFlag + * @note Only available on [6.0.0+]. + * @param[out] out Output flag. + */ +Result GetUsb30HostEnableFlag(bool *out); + +/** + * @brief SetUsb30HostEnableFlag + * @note Only available on [6.0.0+]. + * @param[in] flag Input flag. + */ +Result SetUsb30HostEnableFlag(bool flag); + +/** + * @brief GetUsb30DeviceEnableFlag + * @note Only available on [6.0.0+]. + * @param[out] out Output flag. + */ +Result GetUsb30DeviceEnableFlag(bool *out); + +/** + * @brief SetUsb30DeviceEnableFlag + * @note Only available on [6.0.0+]. + * @param[in] flag Input flag. + */ +Result SetUsb30DeviceEnableFlag(bool flag); + +/** + * @brief GetThemeId + * @note Only available on [7.0.0+]. + * @param[in] type Input theme id type. + * @param[out] out \ref SetSysThemeId + */ +Result GetThemeId(s32 type, SetSysThemeId *out); + +/** + * @brief SetThemeId + * @note Only available on [7.0.0+]. + * @param[in] type Input theme id type. + * @param[in] theme_id \ref SetSysThemeId + */ +Result SetThemeId(s32 type, const SetSysThemeId *theme_id); + +/** + * @brief GetChineseTraditionalInputMethod + * @note Only available on [7.0.0+]. + * @param[out] out \ref SetChineseTraditionalInputMethod + */ +Result GetChineseTraditionalInputMethod(::SetChineseTraditionalInputMethod *out); + +/** + * @brief SetChineseTraditionalInputMethod + * @note Only available on [7.0.0+]. + * @param[in] method \ref SetChineseTraditionalInputMethod + */ +Result SetChineseTraditionalInputMethod(::SetChineseTraditionalInputMethod method); + +/** + * @brief GetPtmCycleCountReliability + * @note Only available on [7.0.0+]. + * @param[out] out \ref SetSysPtmCycleCountReliability + */ +Result GetPtmCycleCountReliability(SetSysPtmCycleCountReliability *out); + +/** + * @brief SetPtmCycleCountReliability + * @note Only available on [7.0.0+]. + * @param[in] reliability \ref SetSysPtmCycleCountReliability + */ +Result SetPtmCycleCountReliability(SetSysPtmCycleCountReliability reliability); + +/** + * @brief Gets the \ref SetSysHomeMenuScheme. + * @note Only available on [8.1.1+]. + * @param[out] out \ref SetSysHomeMenuScheme + */ +Result GetHomeMenuScheme(SetSysHomeMenuScheme *out); + +/** + * @brief GetThemeSettings + * @note Only available on [7.0.0+]. + * @param[out] out \ref SetSysThemeSettings + */ +Result GetThemeSettings(SetSysThemeSettings *out); + +/** + * @brief SetThemeSettings + * @note Only available on [7.0.0+]. + * @param[in] settings \ref SetSysThemeSettings + */ +Result SetThemeSettings(const SetSysThemeSettings *settings); + +/** + * @brief GetThemeKey + * @note Only available on [7.0.0+]. + * @param[out] out \ref FsArchiveMacKey + */ +Result GetThemeKey(FsArchiveMacKey *out); + +/** + * @brief SetThemeKey + * @note Only available on [7.0.0+]. + * @param[in] key \ref FsArchiveMacKey + */ +Result SetThemeKey(const FsArchiveMacKey *key); + +/** + * @brief GetZoomFlag + * @note Only available on [8.0.0+]. + * @param[out] out Output flag. + */ +Result GetZoomFlag(bool *out); + +/** + * @brief SetZoomFlag + * @note Only available on [8.0.0+]. + * @param[in] flag Input flag. + */ +Result SetZoomFlag(bool flag); + +/** + * @brief Returns Terra platform type flag. + * @note On [9.0.0+], this is a wrapper for \ref setsysGetPlatFormRegion() == 2. + * @note Only available on [8.0.0+]. + * @param[out] out Output flag. + */ +Result GetT(bool *out); + +/** + * @brief Sets Terra platform type flag. + * @note On [9.0.0+], this is a wrapper for \ref setsysSetPlatFormRegion(1 + (IsT & 1)). + * @note Only available on [8.0.0+]. + * @param[in] flag Input flag. + */ +Result SetT(bool flag); + +/** + * @brief Gets the \ref SetSysPlatformRegion. + * @note This is used internally by \ref appletGetSettingsPlatformRegion. + * @note Only available on [9.0.0+]. + * @param[out] out \ref SetSysPlatformRegion + */ +Result GetPlatformRegion(SetSysPlatformRegion *out); + +/** + * @brief Sets the \ref SetSysPlatformRegion. + * @note Only available on [9.0.0+]. + * @param[in] region \ref SetSysPlatformRegion + */ +Result SetPlatformRegion(SetSysPlatformRegion region); + +/** + * @brief GetHomeMenuSchemeModel + * @note This will throw an error when loading the "settings_debug!{...}" system-setting which is used with this fails. + * @note Only available on [9.0.0+]. + * @param[out] out HomeMenuSchemeModel. + */ +Result GetHomeMenuSchemeModel(u32 *out); + +/** + * @brief GetMemoryUsageRateFlag + * @note Only available on [9.0.0+]. + * @param[out] out Output flag. + */ +Result GetMemoryUsageRateFlag(bool *out); + +/** + * @brief Gets the \ref SetSysTouchScreenMode. + * @note Only available on [9.0.0+]. + * @param[out] out \ref SetSysTouchScreenMode + */ +Result GetTouchScreenMode(SetSysTouchScreenMode *out); + +/** + * @brief Sets the \ref SetSysTouchScreenMode. + * @note Only available on [9.0.0+]. + * @param[in] mode \ref SetSysTouchScreenMode + */ +Result SetTouchScreenMode(SetSysTouchScreenMode mode); + +/** + * @brief GetButtonConfigSettingsFull + * @note Only available on [10.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetButtonConfigSettingsFull(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief SetButtonConfigSettingsFull + * @note Only available on [10.0.0+]. + * @param[in] settings Input array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetButtonConfigSettingsFull(const SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief GetButtonConfigSettingsEmbedded + * @note Only available on [10.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetButtonConfigSettingsEmbedded(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief SetButtonConfigSettingsEmbedded + * @note Only available on [10.0.0+]. + * @param[in] settings Input array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetButtonConfigSettingsEmbedded(const SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief GetButtonConfigSettingsLeft + * @note Only available on [10.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetButtonConfigSettingsLeft(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief SetButtonConfigSettingsLeft + * @note Only available on [10.0.0+]. + * @param[in] settings Input array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetButtonConfigSettingsLeft(const SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief GetButtonConfigSettingsRight + * @note Only available on [10.0.0+]. + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetButtonConfigSettingsRight(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief SetButtonConfigSettingsRight + * @note Only available on [10.0.0+]. + * @param[in] settings Input array of \ref SetSysButtonConfigSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetButtonConfigSettingsRight(const SetSysButtonConfigSettings *settings, s32 count); + +/** + * @brief GetButtonConfigRegisteredSettingsEmbedded + * @note Only available on [10.0.0+]. + * @param[out] settings \ref SetSysButtonConfigRegisteredSettings + */ +Result GetButtonConfigRegisteredSettingsEmbedded(SetSysButtonConfigRegisteredSettings *settings); + +/** + * @brief SetButtonConfigRegisteredSettingsEmbedded + * @note Only available on [10.0.0+]. + * @param[in] settings \ref SetSysButtonConfigRegisteredSettings + */ +Result SetButtonConfigRegisteredSettingsEmbedded(const SetSysButtonConfigRegisteredSettings *settings); + +/** + * @brief GetButtonConfigRegisteredSettings + * @note Only available on [10.0.0+]. + * @param[out] settings \ref SetSysButtonConfigRegisteredSettings + */ +Result GetButtonConfigRegisteredSettings(s32 *total_out, SetSysButtonConfigRegisteredSettings *settings, s32 count); + +/** + * @brief SetButtonConfigRegisteredSettings + * @note Only available on [10.0.0+]. + * @param[in] settings \ref SetSysButtonConfigRegisteredSettings + */ +Result SetButtonConfigRegisteredSettings(const SetSysButtonConfigRegisteredSettings *settings, s32 count); + +/** + * @brief GetFieldTestingFlag + * @note Only available on [10.1.0+]. + * @param[out] out Output flag. + */ +Result GetFieldTestingFlag(bool *out); + +/** + * @brief SetFieldTestingFlag + * @note Only available on [10.1.0+]. + * @param[in] flag Input flag. + */ +Result SetFieldTestingFlag(bool flag); + +/** + * @brief GetNxControllerSettingsEx + * @param[out] total_out Total output entries. + * @param[out] settings Output array of \ref SetSysNxControllerSettings. + * @param[in] count Size of the settings array in entries. + */ +Result GetNxControllerSettingsEx(s32 *total_out, SetSysNxControllerSettings *settings, s32 count); + +/** + * @brief SetNxControllerSettingsEx + * @param[in] settings Input array of \ref SetSysNxControllerSettings. + * @param[in] count Size of the settings array in entries. + */ +Result SetNxControllerSettingsEx(const SetSysNxControllerSettings *settings, s32 count); + +} // namespace setsys + +/// @brief C++ wrappers for the `sha1` API. +/// @details Wraps: switch/crypto/sha1.h. +namespace sha1 { + +/// Context for SHA1 operations. +using ::Sha1Context; + +/// Initialize a SHA1 context. +void ContextCreate(Sha1Context *out); + +/// Updates SHA1 context with data to hash +void ContextUpdate(Sha1Context *ctx, const void *src, size_t size); + +/// Gets the context's output hash, finalizes the context. +void ContextGetHash(Sha1Context *ctx, void *dst); + +/// Simple all-in-one SHA1 calculator. +void CalculateHash(void *dst, const void *src, size_t size); + +} // namespace sha1 + +/// @brief C++ wrappers for the `sha256` API. +/// @details Wraps: switch/crypto/sha256.h. +namespace sha256 { + +/// Context for SHA256 operations. +using ::Sha256Context; + +/// Initialize a SHA256 context. +void ContextCreate(Sha256Context *out); + +/// Updates SHA256 context with data to hash +void ContextUpdate(Sha256Context *ctx, const void *src, size_t size); + +/// Gets the context's output hash, finalizes the context. +void ContextGetHash(Sha256Context *ctx, void *dst); + +/// Simple all-in-one SHA256 calculator. +void CalculateHash(void *dst, const void *src, size_t size); + +} // namespace sha256 + +/// @brief C++ wrappers for the `shmem` API. +/// @details Wraps: switch/kernel/shmem.h. +namespace shmem { + +/// Shared memory information structure. +using ::SharedMemory; + +/** + * @brief Creates a shared memory object. + * @param s Shared memory information structure which will be filled in. + * @param size Size of the shared memory object to create. + * @param local_perm Permissions with which the shared memory object will be mapped in the local process. + * @param remote_perm Permissions with which the shared memory object will be mapped in the remote process (can be Perm_DontCare). + * @return Result code. + * @warning This is a privileged operation; in normal circumstances applications cannot use this function. + */ +Result Create(SharedMemory* s, size_t size, Permission local_perm, Permission remote_perm); + +/** + * @brief Loads a shared memory object coming from a remote process. + * @param s Shared memory information structure which will be filled in. + * @param handle Handle of the shared memory object. + * @param size Size of the shared memory object that is being loaded. + * @param perm Permissions with which the shared memory object will be mapped in the local process. + */ +void LoadRemote(SharedMemory* s, Handle handle, size_t size, Permission perm); + +/** + * @brief Maps a shared memory object. + * @param s Shared memory information structure. + * @return Result code. + */ +Result Map(SharedMemory* s); + +/** + * @brief Unmaps a shared memory object. + * @param s Shared memory information structure. + * @return Result code. + */ +Result Unmap(SharedMemory* s); + +/** + * @brief Retrieves the mapped address of a shared memory object. + * @param s Shared memory information structure. + * @return Mapped address of the shared memory object. + */ +void* GetAddr(SharedMemory* s); + +/** + * @brief Frees up resources used by a shared memory object, unmapping and closing handles, etc. + * @param s Shared memory information structure. + * @return Result code. + */ +Result Close(SharedMemory* s); + +} // namespace shmem + +/// @brief C++ wrappers for the `sm` API. +/// @details Wraps: switch/services/sm.h, switch/services/smm.h. +namespace sm { + +/// Structure representing a service name (null terminated, remaining characters set to zero). +using ::SmServiceName; + +/// Converts a service name into a 64-bit integer. +u64 ServiceNameToU64(SmServiceName name); + +/// Converts a 64-bit integer into a service name. +SmServiceName ServiceNameFromU64(u64 name); + +/** + * @brief Checks whether two service names are equal. + * @param[in] a First name. + * @param[in] b Second name. + * @return Comparison result. + */ +bool ServiceNamesAreEqual(SmServiceName a, SmServiceName b); + +/** + * @brief Encodes a service name string as a \ref SmServiceName structure. + * @param[in] name Name of the service. + * @return Encoded name. + */ +SmServiceName EncodeName(const char* name); + +/** + * @brief Initializes SM. + * @return Result code. + * @note This function is already called in the default application startup code (before main() is called). + */ +Result Initialize(void); + +/** + * @brief Uninitializes SM. + * @return Result code. + * @note This function is already handled in the default application exit code (after main() returns). + */ +void Exit(void); + +/** + * @brief Requests a service from SM, allowing overrides. + * @param[out] service_out Service structure which will be filled in. + * @param[in] name Name of the service to request. + * @return Result code. + */ +Result GetServiceWrapper(Service* service_out, SmServiceName name); + +/** + * @brief Requests a service from SM, as an IPC session handle directly + * @param[out] handle_out Variable containing IPC session handle. + * @param[in] name Name of the service to request. + * @return Result code. + */ +Result GetServiceOriginal(Handle* handle_out, SmServiceName name); + +/** + * @brief Requests a service from SM. + * @param[out] service_out Service structure which will be filled in. + * @param[in] name Name of the service to request (as a string). + * @return Result code. + */ +Result GetService(Service* service_out, const char* name); + +/** + * @brief Retrieves an overriden service in the homebrew environment. + * @param[in] name Name of the service to request. + * @return IPC session handle. + */ +Handle GetServiceOverride(SmServiceName name); + +/** + * @brief Creates and registers a new service within SM. + * @param[out] handle_out Variable containing IPC port handle. + * @param[in] name Name of the service. + * @param[in] is_light "Is light" + * @param[in] max_sessions Maximum number of concurrent sessions that the service will accept. + * @return Result code. + */ +Result RegisterService(Handle* handle_out, SmServiceName name, bool is_light, s32 max_sessions); + +/// Same as \ref smRegisterService, but always using cmif serialization. +Result RegisterServiceCmif(Handle* handle_out, SmServiceName name, bool is_light, s32 max_sessions); + +/// Same as \ref smRegisterService, but always using tipc serialization. +Result RegisterServiceTipc(Handle* handle_out, SmServiceName name, bool is_light, s32 max_sessions); + +/** + * @brief Unregisters a previously registered service in SM. + * @param[in] name Name of the service. + * @return Result code. + */ +Result UnregisterService(SmServiceName name); + +/// Same as \ref smUnregisterService, but always using cmif serialization. +Result UnregisterServiceCmif(SmServiceName name); + +/// Same as \ref smUnregisterService, but always using tipc serialization. +Result UnregisterServiceTipc(SmServiceName name); + +/** + * @brief Detaches the current SM session. + * @note After this function is called, the rest of the SM API cannot be used. + * @note Only available on [11.0.0-11.0.1], or Atmosphère. + */ +Result DetachClient(void); + +/// Same as \ref smDetachClient, but always using cmif serialization. +Result DetachClientCmif(void); + +/// Same as \ref smDetachClient, but always using tipc serialization. +Result DetachClientTipc(void); + +/** + * @brief Gets the Service session used to communicate with SM. + * @return Pointer to service session used to communicate with SM. + */ +Service * GetServiceSession(void); + +/** + * @brief Gets the TipcService session used to communicate with SM. + * @return Pointer to tipc service session used to communicate with SM. + * @note Only available on [12.0.0+], or Atmosphère. + */ +TipcService * GetServiceSessionTipc(void); + +/** + * @brief Overrides a service with a custom IPC service handle. + * @param[in] name Name of the service. + * @param[in] handle IPC session handle. + */ +void AddOverrideHandle(SmServiceName name, Handle handle); + +/// Initialize sm:m. +Result ManagerInitialize(void); + +/// Exit sm:m. +void ManagerExit(void); + +Result ManagerRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size); + +Result ManagerUnregisterProcess(u64 pid); + +/// Initialize sm:m exclusively for tipc (requires <12.0.0 and non-Atmosphere). +Result ManagerCmifInitialize(void); + +/// Exit sm:m exclusively for tipc (requires <12.0.0 and non-Atmosphere). +void ManagerCmifExit(void); + +/// Gets the Service object for the actual sm:m service session (requires <12.0.0 and non-Atmosphere). +Service* ManagerCmifGetServiceSession(void); + +Result ManagerCmifRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size); + +Result ManagerCmifUnregisterProcess(u64 pid); + +/// Initialize sm:m exclusively for tipc (requires 12.0.0+ or Atmosphere). +Result ManagerTipcInitialize(void); + +/// Exit sm:m exclusively for tipc (requires 12.0.0+ or Atmosphere). +void ManagerTipcExit(void); + +/// Gets the TipcService object for the actual sm:m service session (requires 12.0.0+ or Atmosphere). +TipcService* ManagerTipcGetServiceSession(void); + +Result ManagerTipcRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size); + +Result ManagerTipcUnregisterProcess(u64 pid); + +} // namespace sm + +/// @brief C++ wrappers for the `socket` API. +/// @details Wraps: switch/runtime/devices/socket.h. +namespace socket { + +/// BSD service type used by the socket driver. +using ::BsdServiceType; +#ifdef _SOCKLEN_T_DECLARED +using ::sockaddr; +#endif +/// Configuration structure for socketInitalize +using ::SocketInitConfig; + +/// Fetch the default configuration for the socket driver. +const SocketInitConfig * GetDefaultInitConfig(void); + +/// Initalize the socket driver. +Result Initialize(const SocketInitConfig *config); + +/// Fetch the last bsd:u/s Switch result code (thread-local). +Result GetLastResult(void); + +/// Deinitialize the socket driver. +void Exit(void); + +/// Initalize the socket driver using the default configuration. +Result InitializeDefault(void); + +/// 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 SslConnectionSetSocketDescriptor(SslConnection *c, int sockfd); + +/// Wrapper for \ref sslConnectionGetSocketDescriptor. Returns the output sockfd on success and -1 on error. +int SslConnectionGetSocketDescriptor(SslConnection *c); + +#ifdef _SOCKLEN_T_DECLARED +/// 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 SslConnectionSetDtlsSocketDescriptor(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 NifmRequestRegisterSocketDescriptor(NifmRequest* r, int sockfd); + +/// Wrapper for \ref nifmRequestUnregisterSocketDescriptor. Returns 0 on success and -1 on error. +int NifmRequestUnregisterSocketDescriptor(NifmRequest* r, int sockfd); + +} // namespace socket + +/// @brief C++ wrappers for the `spl` API. +/// @details Wraps: switch/services/spl.h. +namespace spl { + +using ::RsaKeyVersion; +using ::SplConfigItem; + +/// Initialize 'spl:'. +Result Initialize(void); + +/// Exit 'spl:'. +void Exit(void); + +/// Gets the Service object for the IGeneralInterface usable with spl*(). +Service* GetServiceSession(void); + +/// Initialize spl:mig. On pre-4.0.0 this just calls \ref splInitialize. +Result CryptoInitialize(void); + +/// Exit spl:mig. On pre-4.0.0 this just calls \ref splExit. +void CryptoExit(void); + +/// Gets the Service object for the IGeneralInterface usable with splCrypto*(). +Service* CryptoGetServiceSession(void); + +/// Initialize spl:ssl. On pre-4.0.0 this just calls \ref splInitialize. +Result SslInitialize(void); + +/// Exit spl:ssl. On pre-4.0.0 this just calls \ref splExit. +void SslExit(void); + +/// Gets the Service object for the IGeneralInterface usable with splSsl*(). +Service* SslGetServiceSession(void); + +/// Initialize spl:es. On pre-4.0.0 this just calls \ref splInitialize. +Result EsInitialize(void); + +/// Exit spl:es. On pre-4.0.0 this just calls \ref splExit. +void EsExit(void); + +/// Gets the Service object for the IGeneralInterface usable with splEs*(). +Service* EsGetServiceSession(void); + +/// Initialize spl:fs. On pre-4.0.0 this just calls \ref splInitialize. +Result FsInitialize(void); + +/// Exit spl:fs. On pre-4.0.0 this just calls \ref splExit. +void FsExit(void); + +/// Gets the Service object for the IGeneralInterface usable with splFs*(). +Service* FsGetServiceSession(void); + +/// Initialize spl:manu. On pre-4.0.0 this just calls \ref splInitialize. +Result ManuInitialize(void); + +/// Exit spl:manu. On pre-4.0.0 this just calls \ref splExit. +void ManuExit(void); + +/// Gets the Service object for the IGeneralInterface usable with splManu*(). +Service* ManuGetServiceSession(void); + +Result GetConfig(SplConfigItem config_item, u64 *out_config); + +Result UserExpMod(const void *input, const void *modulus, const void *exp, size_t exp_size, void *dst); + +Result SetConfig(SplConfigItem config_item, u64 value); + +Result GetRandomBytes(void *out, size_t out_size); + +Result IsDevelopment(bool *out_is_development); + +Result SetBootReason(u32 value); + +Result GetBootReason(u32 *out_value); + +Result CryptoGenerateAesKek(const void *wrapped_kek, u32 key_generation, u32 option, void *out_sealed_kek); + +Result CryptoLoadAesKey(const void *sealed_kek, const void *wrapped_key, u32 keyslot); + +Result CryptoGenerateAesKey(const void *sealed_kek, const void *wrapped_key, void *out_sealed_key); + +Result CryptoDecryptAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key); + +Result CryptoCryptAesCtr(const void *input, void *output, size_t size, u32 keyslot, const void *ctr); + +Result CryptoComputeCmac(const void *input, size_t size, u32 keyslot, void *out_cmac); + +Result CryptoLockAesEngine(u32 *out_keyslot); + +Result CryptoUnlockAesEngine(u32 keyslot); + +Result CryptoGetSecurityEngineEvent(Event *out_event); + +Result RsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size); + +Result SslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size); + +Result SslSecureExpMod(const void *input, const void *modulus, void *dst); + +Result EsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); + +Result EsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey); + +Result EsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_generation, void *out_sealed_titlekey); + +Result EsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size); + +Result EsSecureExpMod(const void *input, const void *modulus, void *dst); + +Result EsUnwrapElicenseKey(const void *rsa_wrapped_elicense_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_elicense_key); + +Result EsLoadElicenseKey(const void *sealed_elicense_key, u32 keyslot); + +Result FsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); + +Result FsSecureExpMod(const void *input, const void *modulus, void *dst); + +Result FsGenerateSpecificAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key); + +Result FsLoadTitlekey(const void *sealed_titlekey, u32 keyslot); + +Result FsGetPackage2Hash(void *out_hash); + +Result ManuEncryptRsaKeyForImport(const void *sealed_kek_pre, const void *wrapped_key_pre, const void *sealed_kek_post, const void *wrapped_kek_post, u32 option, const void *wrapped_rsa_key, void *out_wrapped_rsa_key, size_t rsa_key_size); + +} // namespace spl + +/// @brief C++ wrappers for the `spsm` API. +/// @details Wraps: switch/services/spsm.h. +namespace spsm { + +/// Initialize spsm. +Result Initialize(void); + +/// Exit spsm. +void Exit(void); + +/// Gets the Service object for the actual spsm service session. +Service* GetServiceSession(void); + +Result Shutdown(bool reboot); + +Result PutErrorState(void); + +} // namespace spsm + +/// @brief C++ wrappers for the `ssl` API. +/// @details Wraps: switch/services/ssl.h. +namespace ssl { + +/// AlpnProtoState +using ::SslAlpnProtoState; +/// BuiltInCertificateInfo +using ::SslBuiltInCertificateInfo; +/// CaCertificateId +using ::SslCaCertificateId; +/// CertificateFormat +using ::SslCertificateFormat; +/// CipherInfo +using ::SslCipherInfo; +/// SslConnection +using ::SslConnection; +/// SslContext +using ::SslContext; +/// ContextOption +using ::SslContextOption; +/// DebugOptionType +using ::SslDebugOptionType; +/// FlushSessionCacheOptionType +using ::SslFlushSessionCacheOptionType; +/// InternalPki +using ::SslInternalPki; +/// IoMode. The default value at the time of \ref sslContextCreateConnection is ::SslIoMode_Blocking. +/// The socket non-blocking flag is always set regardless of this field, this is only used internally for calculating the timeout used by various cmds. +using ::SslIoMode; +/// KeyAndCertParams +using ::SslKeyAndCertParams; +/// OptionType. The default bool flags value for these at the time of \ref sslContextCreateConnection is cleared. +using ::SslOptionType; +/// PollEvent +using ::SslPollEvent; +/// PrivateOptionType +using ::SslPrivateOptionType; +/// RenegotiationMode +using ::SslRenegotiationMode; +/// SslServerCertDetailEntry +using ::SslServerCertDetailEntry; +/// SslServerCertDetailHeader +using ::SslServerCertDetailHeader; +/// Values for __nx_ssl_service_type, controls which ssl service to initialize. +using ::SslServiceType; +/// SessionCacheMode +using ::SslSessionCacheMode; +/// TrustedCertStatus +using ::SslTrustedCertStatus; +/// VerifyOption. The default bitmask value at the time of \ref sslContextCreateConnection is ::SslVerifyOption_PeerCa | ::SslVerifyOption_HostName. +/// [5.0.0+] \ref sslConnectionSetVerifyOption: (::SslVerifyOption_PeerCa | ::SslVerifyOption_HostName) must be set, unless: ::SslOptionType_SkipDefaultVerify is set, or [9.0.0+] ::SslDebugOptionType_AllowDisableVerifyOption is set. +/// [6.0.0+] \ref sslConnectionSetVerifyOption: Following that, if ::SslVerifyOption_EvPolicyOid is set, then the following options must be set (besides the previously mentioned one): ::SslVerifyOption_PeerCa and ::SslVerifyOption_DateCheck. +using ::SslVerifyOption; +/// SslVersion. This is a bitmask which controls the min/max TLS versions to use, depending on which lowest/highest bits are set (if Auto* isn't set). +using ::SslVersion; + +/// Initialize ssl. A default value of 0x3 can be used for num_sessions. This must be 0x1-0x4. +Result Initialize(u32 num_sessions); + +/// Exit ssl. +void Exit(void); + +/// Gets the Service object for the actual ssl service session. +Service* GetServiceSession(void); + +/** + * @brief CreateContext + * @note The CertStore is used automatically, regardless of what cmds are used. + * @param[out] c \ref SslContext + * @param[in] ssl_version \ref SslVersion + */ +Result CreateContext(SslContext *c, u32 ssl_version); + +/** + * @brief GetContextCount + * @note Not used by official sw. + * @param[out] out Output value. + */ +Result GetContextCount(u32 *out); + +/** + * @brief GetCertificates + * @param[in] buffer Output buffer. The start of this buffer is an array of \ref SslBuiltInCertificateInfo, with the specified count. The cert data (SslBuiltInCertificateInfo::data) is located after this array. + * @param[in] size Output buffer size, this should be the size from \ref sslGetCertificateBufSize. + * @param[in] ca_cert_ids Input array of \ref SslCaCertificateId. + * @param[in] count Size of the ca_cert_ids array in entries. + * @param[out] total_out [3.0.0+] Total output entries. Will always match count on pre-3.0.0. This will differ from count when ::SslCaCertificateId_All is used. + */ +Result GetCertificates(void* buffer, u32 size, u32 *ca_cert_ids, u32 count, u32 *total_out); + +/** + * @brief GetCertificateBufSize + * @param[in] ca_cert_ids Input array of \ref SslCaCertificateId. + * @param[in] count Size of the ca_cert_ids array in entries. + * @param[out] out Output size. + */ +Result GetCertificateBufSize(u32 *ca_cert_ids, u32 count, u32 *out); + +/** + * @brief FlushSessionCache + * @note Only available on [5.0.0+]. + * @param[in] str Input string. Must be NULL with ::SslFlushSessionCacheOptionType_AllHosts. + * @param[in] str_bufsize String buffer size, excluding NUL-terminator. Hence, this should be actual_bufsize-1. This must be 0 with ::SslFlushSessionCacheOptionType_AllHosts. + * @param[in] type \ref SslFlushSessionCacheOptionType + * @param[out] out Output value. + */ +Result FlushSessionCache(const char *str, size_t str_bufsize, SslFlushSessionCacheOptionType type, u32 *out); + +/** + * @brief SetDebugOption + * @note Only available on [6.0.0+]. + * @note The official impl of this doesn't actually use the cmd. + * @param[in] buffer Input buffer, must not be NULL. The u8 from here is copied to state. + * @param[in] size Buffer size, must not be 0. + * @param[in] type \ref SslDebugOptionType + */ +Result SetDebugOption(const void* buffer, size_t size, SslDebugOptionType type); + +/** + * @brief GetDebugOption + * @note Only available on [6.0.0+]. + * @param[out] buffer Output buffer, must not be NULL. An u8 is written here loaded from state. + * @param[in] size Buffer size, must not be 0. + * @param[in] type \ref SslDebugOptionType + */ +Result GetDebugOption(void* buffer, size_t size, SslDebugOptionType type); + +/** + * @brief ClearTls12FallbackFlag + * @note Only available on [14.0.0+]. + */ +Result ClearTls12FallbackFlag(void); + +/** + * @brief SetThreadCoreMask + * @param[in] mask CoreMask + * @note Only available on [15.0.0+] with ::SslServiceType_System. + */ +Result SetThreadCoreMask(u64 mask); + +/** + * @brief GetThreadCoreMask + * @param[out] out Output CoreMask. + * @note Only available on [15.0.0+] with ::SslServiceType_System. + */ +Result GetThreadCoreMask(u64 *out); + +/** + * @brief Closes a Context object. + * @param c \ref SslContext + */ +void ContextClose(SslContext *c); + +/** + * @brief SetOption + * @note Prior to 4.x this is stubbed. + * @param c \ref SslContext + * @param[in] option \ref SslContextOption + * @param[in] value Value to set. With ::SslContextOption_CrlImportDateCheckEnable, this must be 0 or 1. + */ +Result ContextSetOption(SslContext *c, SslContextOption option, s32 value); + +/** + * @brief GetOption + * @note Prior to 4.x this is stubbed. + * @param c \ref SslContext + * @param[in] option \ref SslContextOption + * @param[out] out Output value. + */ +Result ContextGetOption(SslContext *c, SslContextOption option, s32 *out); + +/** + * @brief CreateConnection + * @param c \ref SslContext + * @param[out] conn Output \ref SslConnection. + */ +Result ContextCreateConnection(SslContext *c, SslConnection *conn); + +/** + * @brief GetConnectionCount + * @note Not exposed by official sw. + * @param c \ref SslContext + * @param[out] out Output value. + */ +Result ContextGetConnectionCount(SslContext *c, u32 *out); + +/** + * @brief ImportServerPki + * @note A maximum of 71 ServerPki objects (associated with the output Id) can be imported. + * @param c \ref SslContext + * @param[in] buffer Input buffer containing the cert data, must not be NULL. This can contain multiple certs. The certs can be CAs or server certs (no pubkeys). + * @param[in] size Input buffer size. + * @param[in] format \ref SslCertificateFormat + * @param[out] id Output Id. Optional, can be NULL. + */ +Result ContextImportServerPki(SslContext *c, const void* buffer, u32 size, SslCertificateFormat format, u64 *id); + +/** + * @brief ImportClientPki + * @note An error is thrown internally if this cmd or \ref sslContextRegisterInternalPki was already used previously. + * @param c \ref SslContext + * @param[in] pkcs12 PKCS#12 input buffer, must not be NULL. + * @param[in] pkcs12_size pkcs12 buffer size. + * @param[in] pw ASCII password string buffer, this can only be NULL if pw_size is 0. This will be internally copied to another buffer which was allocated with size=pw_size+1, for NUL-termination. + * @param[in] pw_size Password buffer size, this can only be 0 if pw is NULL. + * @param[out] id Output Id. Optional, can be NULL. + */ +Result ContextImportClientPki(SslContext *c, const void* pkcs12, u32 pkcs12_size, const char *pw, u32 pw_size, u64 *id); + +/** + * @brief Remove the specified *Pki, or on [3.0.0+] Crl. + * @param c \ref SslContext + * @param[in] id Id + */ +Result ContextRemovePki(SslContext *c, u64 id); + +/** + * @brief RegisterInternalPki + * @note An error is thrown internally if this cmd or \ref sslContextImportClientPki was already used previously. + * @param c \ref SslContext + * @param[in] internal_pki \ref SslInternalPki + * @param[out] id Output Id. Optional, can be NULL. + */ +Result ContextRegisterInternalPki(SslContext *c, SslInternalPki internal_pki, u64 *id); + +/** + * @brief AddPolicyOid + * @param c \ref SslContext + * @param[in] str Input string. + * @param[in] str_bufsize String buffer size, excluding NUL-terminator (must not match the string length). Hence, this should be actual_bufsize-1. This must not be >0xff. + */ +Result ContextAddPolicyOid(SslContext *c, const char *str, u32 str_bufsize); + +/** + * @brief ImportCrl + * @note Only available on [3.0.0+]. + * @param c \ref SslContext + * @param[in] buffer Input buffer, must not be NULL. This contains the DER CRL. + * @param[in] size Input buffer size. + * @param[out] id Output Id. Optional, can be NULL. + */ +Result ContextImportCrl(SslContext *c, const void* buffer, u32 size, u64 *id); + +/** + * @brief ImportClientCertKeyPki + * @note Only available on [16.0.0+]. + * @param c \ref SslContext + * @param[in] cert Input cert buffer, + * @param[in] cert_size Size of the cert buffer. + * @param[in] key Input key buffer. + * @param[in] key_size Size of the key buffer. + * @param[in] format \ref SslCertificateFormat for the cert and key. + * @param[out] id Output Id. Optional, can be NULL. + */ +Result ContextImportClientCertKeyPki(SslContext *c, const void* cert, u32 cert_size, const void* key, u32 key_size, SslCertificateFormat format, u64 *id); + +/** + * @brief GeneratePrivateKeyAndCert + * @note Only available on [16.0.0+]. + * @param c \ref SslContext + * @param[out] cert Output cert buffer, + * @param[in] cert_size Size of the cert buffer. + * @param[out] key Output key buffer. + * @param[in] key_size Size of the key buffer. + * @param[in] val Must be value 1. + * @param[in] params \ref SslKeyAndCertParams + * @param[out] out_certsize Actual size of the generated cert data. + * @param[out] out_keysize Actual size of the generated key data. + */ +Result ContextGeneratePrivateKeyAndCert(SslContext *c, void* cert, u32 cert_size, void* key, u32 key_size, u32 val, const SslKeyAndCertParams *params, u32 *out_certsize, u32 *out_keysize); + +/** + * @brief CreateConnectionForSystem + * @note Only available on [15.0.0+] with ::SslServiceType_System. + * @param c \ref SslContext + * @param[out] conn Output \ref SslConnection. + */ +Result ContextCreateConnectionForSystem(SslContext *c, SslConnection *conn); + +/** + * @brief Closes a Connection object. + * @param c \ref SslConnection + */ +void ConnectionClose(SslConnection *c); + +/** + * @brief SetSocketDescriptor. Do not use directly, use \ref socketSslConnectionSetSocketDescriptor instead. + * @note An error is thrown if this was used previously. + * @param c \ref SslConnection + * @param[in] sockfd sockfd + * @param[out] out_sockfd sockfd. Prior to using \ref sslConnectionClose, this must be closed if it's not negative (it will be -1 if ::SslOptionType_DoNotCloseSocket is set). + */ +Result ConnectionSetSocketDescriptor(SslConnection *c, int sockfd, int *out_sockfd); + +/** + * @brief SetHostName + * @param c \ref SslConnection + * @param[in] str Input string. + * @param[in] str_bufsize String buffer size. This must not be >0xff. + */ +Result ConnectionSetHostName(SslConnection *c, const char* str, u32 str_bufsize); + +/** + * @brief SetVerifyOption + * @param c \ref SslConnection + * @param[in] verify_option Input bitmask of \ref SslVerifyOption. + */ +Result ConnectionSetVerifyOption(SslConnection *c, u32 verify_option); + +/** + * @brief SetIoMode + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[in] mode \ref SslIoMode + */ +Result ConnectionSetIoMode(SslConnection *c, SslIoMode mode); + +/** + * @brief GetSocketDescriptor. Do not use directly, use \ref socketSslConnectionGetSocketDescriptor instead. + * @note This gets the input sockfd which was previously saved in state by \ref sslConnectionSetSocketDescriptor. + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] sockfd Output sockfd. + */ +Result ConnectionGetSocketDescriptor(SslConnection *c, int *sockfd); + +/** + * @brief GetHostName + * @param c \ref SslConnection + * @param[out] str Output string buffer. + * @param[in] str_bufsize String buffer size, must be large enough for the entire output string. + * @param[out] out Output string length. + */ +Result ConnectionGetHostName(SslConnection *c, char *str, u32 str_bufsize, u32 *out); + +/** + * @brief GetVerifyOption + * @param c \ref SslConnection + * @param[out] out Output bitmask of \ref SslVerifyOption. + */ +Result ConnectionGetVerifyOption(SslConnection *c, u32 *out); + +/** + * @brief GetIoMode + * @param c \ref SslConnection + * @param[out] out \ref SslIoMode + */ +Result ConnectionGetIoMode(SslConnection *c, SslIoMode *out); + +/** + * @brief DoHandshake + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @note \ref sslConnectionSetHostName must have been used previously with a non-empty string when ::SslVerifyOption_HostName is set. + * @note The DoHandshakeGetServerCert cmd is only used if both server_certbuf/server_certbuf_size are set, otherwise the DoHandshake cmd is used (in which case out_size/total_certs will be left at value 0). + * @note No certs are returned when ::SslVerifyOption_PeerCa is not set. + * @param c \ref SslConnection + * @param[out] out_size Total data size which was written to server_certbuf. Optional, can be NULL. + * @param[out] total_certs Total certs which were written to server_certbuf, can be NULL. + * @param[out] server_certbuf Optional output server cert buffer, can be NULL. Normally this just contains the server cert DER, however with ::SslOptionType_GetServerCertChain set this will contain the full chain (\ref sslConnectionGetServerCertDetail can be used to parse that). With ::SslIoMode_NonBlocking this buffer will be only filled in once - when this cmd returns successfully the buffer will generally be empty. + * @param[in] server_certbuf_size Optional output server cert buffer size, can be 0. + */ +Result ConnectionDoHandshake(SslConnection *c, u32 *out_size, u32 *total_certs, void* server_certbuf, u32 server_certbuf_size); + +/** + * @brief Parses the output server_certbuf from \ref sslConnectionDoHandshake where ::SslOptionType_GetServerCertChain is set. + * @param[in] certbuf server_certbuf from \ref sslConnectionDoHandshake, must not be NULL. + * @param[in] certbuf_size out_size from \ref sslConnectionDoHandshake. + * @param[in] cert_index Cert index, must be within the range of certs stored in certbuf. + * @param[out] cert Ptr for the ouput DER cert, must not be NULL. + * @param[out] cert_size Size for the ouput cert, must not be NULL. + */ +Result ConnectionGetServerCertDetail(const void* certbuf, u32 certbuf_size, u32 cert_index, void** cert, u32 *cert_size); + +/** + * @brief Read + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] buffer Output buffer, must not be NULL. + * @param[in] size Output buffer size, must not be 0. + * @param[out] out_size Actual transferred size. + */ +Result ConnectionRead(SslConnection *c, void* buffer, u32 size, u32 *out_size); + +/** + * @brief Write + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[in] buffer Input buffer, must not be NULL. + * @param[in] size Input buffer size, must not be 0. + * @param[out] out_size Actual transferred size. + */ +Result ConnectionWrite(SslConnection *c, const void* buffer, u32 size, u32 *out_size); + +/** + * @brief Pending + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] out Output value. + */ +Result ConnectionPending(SslConnection *c, s32 *out); + +/** + * @brief Peek + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] buffer Output buffer, must not be NULL. + * @param[in] size Output buffer size, must not be 0. + * @param[out] out_size Output size. + */ +Result ConnectionPeek(SslConnection *c, void* buffer, u32 size, u32 *out_size); + +/** + * @brief Poll + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[in] in_pollevent Input bitmask of \ref SslPollEvent. + * @param[out] out_pollevent Output bitmask of \ref SslPollEvent. + * @param[in] timeout Timeout in milliseconds. + */ +Result ConnectionPoll(SslConnection *c, u32 in_pollevent, u32 *out_pollevent, u32 timeout); + +/** + * @brief GetVerifyCertError + * @note The value in state is cleared after loading it. + * @param c \ref SslConnection + */ +Result ConnectionGetVerifyCertError(SslConnection *c); + +/** + * @brief GetNeededServerCertBufferSize + * @param c \ref SslConnection + * @param[out] out Output value. + */ +Result ConnectionGetNeededServerCertBufferSize(SslConnection *c, u32 *out); + +/** + * @brief SetSessionCacheMode + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[in] mode \ref SslSessionCacheMode + */ +Result ConnectionSetSessionCacheMode(SslConnection *c, SslSessionCacheMode mode); + +/** + * @brief GetSessionCacheMode + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] out \ref SslSessionCacheMode + */ +Result ConnectionGetSessionCacheMode(SslConnection *c, SslSessionCacheMode *out); + +/** + * @brief GetSessionCacheMode + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + */ +Result ConnectionFlushSessionCache(SslConnection *c); + +/** + * @brief SetRenegotiationMode + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[in] mode \ref SslRenegotiationMode + */ +Result ConnectionSetRenegotiationMode(SslConnection *c, SslRenegotiationMode mode); + +/** + * @brief GetRenegotiationMode + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] out \ref SslRenegotiationMode + */ +Result ConnectionGetRenegotiationMode(SslConnection *c, SslRenegotiationMode *out); + +/** + * @brief SetOption + * @param c \ref SslConnection + * @param[in] option \ref SslOptionType + * @param[in] flag Input flag value. + */ +Result ConnectionSetOption(SslConnection *c, SslOptionType option, bool flag); + +/** + * @brief GetOption + * @param c \ref SslConnection + * @param[in] option \ref SslOptionType + * @param[out] out Output flag value. + */ +Result ConnectionGetOption(SslConnection *c, SslOptionType option, bool *out); + +/** + * @brief GetVerifyCertErrors + * @note An error is thrown when the cmd is successful, if the two output u32s match. + * @param[out] out0 First output value, must not be NULL. + * @param[out] out1 Second output value. + * @param[out] errors Output array of Result, must not be NULL. + * @param[in] count Size of the errors array in entries. + */ +Result ConnectionGetVerifyCertErrors(SslConnection *c, u32 *out0, u32 *out1, Result *errors, u32 count); + +/** + * @brief GetCipherInfo + * @note Only available on [4.0.0+]. + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @param c \ref SslConnection + * @param[out] out \ref SslCipherInfo + */ +Result ConnectionGetCipherInfo(SslConnection *c, SslCipherInfo *out); + +/** + * @brief SetNextAlpnProto + * @note Only available on [9.0.0+]. + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @note ::SslOptionType_EnableAlpn should be set at the time of using \ref sslConnectionDoHandshake, otherwise using this cmd will have no affect. + * @param c \ref SslConnection + * @param[in] buffer Input buffer, must not be NULL. This contains an array of {u8 size, {data with the specified size}}, which must be within the buffer-size bounds. + * @param[in] size Input buffer size, must not be 0. Must be at least 0x2. + */ +Result ConnectionSetNextAlpnProto(SslConnection *c, const u8 *buffer, u32 size); + +/** + * @brief GetNextAlpnProto + * @note Only available on [9.0.0+]. + * @note \ref sslConnectionSetSocketDescriptor must have been used prior to this successfully. + * @note The output will be all-zero/empty if not available - such as when this was used before \ref sslConnectionDoHandshake. + * @param c \ref SslConnection + * @param[out] state \ref SslAlpnProtoState + * @param[out] out Output string length. + * @param[out] buffer Output string buffer, must not be NULL. + * @param[in] size Output buffer size, must not be 0. + */ +Result ConnectionGetNextAlpnProto(SslConnection *c, SslAlpnProtoState *state, u32 *out, u8 *buffer, u32 size); + +/** + * @brief SetDtlsSocketDescriptor. Do not use directly, use \ref socketSslConnectionSetDtlsSocketDescriptor instead. + * @note Only available on [16.0.0+]. + * @note An error is thrown if this was used previously. + * @param c \ref SslConnection + * @param[in] sockfd sockfd + * @param[in] Input sockaddr. + * @param[in] size Input sockaddr size. + * @param[out] out_sockfd sockfd. Prior to using \ref sslConnectionClose, this must be closed if it's not negative (it will be -1 if ::SslOptionType_DoNotCloseSocket is set). + */ +Result ConnectionSetDtlsSocketDescriptor(SslConnection *c, int sockfd, const void* buf, size_t size, int *out_sockfd); + +/** + * @brief GetDtlsHandshakeTimeout + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[out] out Output nanoseconds value. + */ +Result ConnectionGetDtlsHandshakeTimeout(SslConnection *c, u64 *out); + +/** + * @brief SetPrivateOption + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[in] option \ref SslPrivateOptionType + * @param[in] value Input value. + */ +Result ConnectionSetPrivateOption(SslConnection *c, SslPrivateOptionType option, u32 value); + +/** + * @brief SetSrtpCiphers + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[in] ciphers Input array of u16s. Each entry must be value 1-2, otherwise the entry is ignored. + * @param[in] count Total entries in the ciphers array, the maximum is 4. + */ +Result ConnectionSetSrtpCiphers(SslConnection *c, const u16 *ciphers, u32 count); + +/** + * @brief GetSrtpCipher + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[out] out Output value. + */ +Result ConnectionGetSrtpCipher(SslConnection *c, u16 *out); + +/** + * @brief ExportKeyingMaterial + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[out] outbuf Output buffer. + * @param[in] outbuf_size Output buffer size. + * @param[in] label Input label string. + * @param[in] label_size Size of the label buffer excluding NUL-terminator. + * @param[in] context Optional input context buffer, can be NULL. + * @param[in] context_size Size of context, if specified this must be <0xFFFF. + */ +Result ConnectionExportKeyingMaterial(SslConnection *c, u8 *outbuf, u32 outbuf_size, const char *label, u32 label_size, const void* context, u32 context_size); + +/** + * @brief SetIoTimeout + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[in] timeout Input timeout value. + */ +Result ConnectionSetIoTimeout(SslConnection *c, u32 timeout); + +/** + * @brief GetIoTimeout + * @note Only available on [16.0.0+]. + * @param c \ref SslConnection + * @param[out] out Output timeout value. + */ +Result ConnectionGetIoTimeout(SslConnection *c, u32 *out); + +} // namespace ssl + +/// @brief C++ wrappers for the `svc` API. +/// @details Wraps: switch/kernel/svc.h. +namespace svc { + +/// WaitForAddress behaviors. +using ::ArbitrationType; +/// Break point types +using ::BreakPointType; +/// Break reasons +using ::BreakReason; +/// Code memory mapping operations +using ::CodeMapOperation; +/// Address space types for CreateProcessFlags +using ::CreateProcessFlagAddressSpace; +/// Flags for svcCreateProcess and CreateProcess event +using ::CreateProcessFlags; +/// DebugEvent flags +using ::DebugEventFlag; +/// DebugEvent structure +using ::DebugEventInfo; +/// DebugEvent types +using ::DebugEventType; +/// Debug exception types +using ::DebugException; +/// Debug Thread Parameters. +using ::DebugThreadParam; +/// GetInfo IDs. +using ::InfoType; +/// GetInfo InitialProcessIdRange Sub IDs. +using ::InitialProcessIdRangeInfo; +/// Io Pools. +using ::IoPoolType; +/// Context of a scheduled thread. +using ::LastThreadContext; +/// Limitable Resources. +using ::LimitableResource; +/// Memory attribute bitmasks. +using ::MemoryAttribute; +/// Memory information structure. +using ::MemoryInfo; +/// Memory mapping type. +using ::MemoryMapping; +/// Memory regions +using ::MemoryRegion; +/// Memory state bitmasks. +using ::MemoryState; +/// Memory type enumeration (lower 8 bits of \ref MemoryState) +using ::MemoryType; +/// Memory permission bitmasks. +using ::Permission; +/// Physical memory information structure. +using ::PhysicalMemoryInfo; +/// GetSystemInfo PhysicalMemory Sub IDs. +using ::PhysicalMemorySystemInfo; +/// Process Activity. +using ::ProcessActivity; +/// Process exit reasons +using ::ProcessExitReason; +/// Process Information. +using ::ProcessInfoType; +/// Process States. +using ::ProcessState; +/// Secure monitor arguments. +using ::SecmonArgs; +/// SignalToAddress behaviors. +using ::SignalType; +/// GetSystemInfo IDs. +using ::SystemInfoType; +/// Thread Activity. +using ::ThreadActivity; +/// Thread exit reasons +using ::ThreadExitReason; +/// GetInfo Idle/Thread Tick Count Sub IDs. +using ::TickCountInfo; +/// SleepThread yield types. +using ::YieldType; + +/** + * @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. + * @return Result code. + * @note Syscall number 0x01. + */ +Result SetHeapSize(void** out_addr, u64 size); + +/** + * @brief Set the memory permissions of a (page-aligned) range of memory. + * @param[in] addr Start address of the range. + * @param[in] size Size of the range, in bytes. + * @param[in] perm Permissions (see \ref Permission). + * @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. + */ +Result SetMemoryPermission(void* addr, u64 size, u32 perm); + +/** + * @brief Set the memory attributes of a (page-aligned) range of memory. + * @param[in] addr Start address of the range. + * @param[in] size Size of the range, in bytes. + * @param[in] val0 State0 + * @param[in] val1 State1 + * @return Result code. + * @remark See switchbrew.org Wiki for more details. + * @note Syscall number 0x03. + */ +Result SetMemoryAttribute(void* addr, u64 size, u32 val0, u32 val1); + +/** + * @brief Maps a memory range into a different range. Mainly used for adding guard pages around stack. + * Source range gets reprotected to Perm_None (it can no longer be accessed), and \ref MemAttr_IsBorrowed is set in the source \ref MemoryAttribute. + * @param[in] dst_addr Destination address. + * @param[in] src_addr Source address. + * @param[in] size Size of the range. + * @return Result code. + * @note Syscall number 0x04. + */ +Result MapMemory(void* dst_addr, void* src_addr, u64 size); + +/** + * @brief Unmaps a region that was previously mapped with \ref svcMapMemory. + * @param[in] dst_addr Destination address. + * @param[in] src_addr Source address. + * @param[in] size Size of the range. + * @return Result code. + * @note Syscall number 0x05. + */ +Result UnmapMemory(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[in] addr Address to query. + * @return Result code. + * @note Syscall number 0x06. + */ +Result QueryMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, u64 addr); + +/** + * @brief Exits the current process. + * @note Syscall number 0x07. + */ +[[noreturn]] void ExitProcess(void); + +/** + * @brief Creates a thread. + * @return Result code. + * @note Syscall number 0x08. + */ +Result CreateThread(Handle* out, void* entry, void* arg, void* stack_top, int prio, int cpuid); + +/** + * @brief Starts a freshly created thread. + * @return Result code. + * @note Syscall number 0x09. + */ +Result StartThread(Handle handle); + +/** + * @brief Exits the current thread. + * @note Syscall number 0x0A. + */ +[[noreturn]] void ExitThread(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. + * @note Syscall number 0x0B. + */ +void SleepThread(s64 nano); + +/** + * @brief Gets a thread's priority. + * @return Result code. + * @note Syscall number 0x0C. + */ +Result GetThreadPriority(s32* priority, Handle handle); + +/** + * @brief Sets a thread's priority. + * @return Result code. + * @note Syscall number 0x0D. + */ +Result SetThreadPriority(Handle handle, u32 priority); + +/** + * @brief Gets a thread's core mask. + * @return Result code. + * @note Syscall number 0x0E. + */ +Result GetThreadCoreMask(s32* preferred_core, u64* affinity_mask, Handle handle); + +/** + * @brief Sets a thread's core mask. + * @return Result code. + * @note Syscall number 0x0F. + */ +Result SetThreadCoreMask(Handle handle, s32 preferred_core, u32 affinity_mask); + +/** + * @brief Gets the current processor's number. + * @return The current processor's number. + * @note Syscall number 0x10. + */ +u32 GetCurrentProcessorNumber(void); + +/** + * @brief Sets an event's signalled status. + * @return Result code. + * @note Syscall number 0x11. + */ +Result SignalEvent(Handle handle); + +/** + * @brief Clears an event's signalled status. + * @return Result code. + * @note Syscall number 0x12. + */ +Result ClearEvent(Handle handle); + +/** + * @brief Maps a block of shared memory. + * @return Result code. + * @note Syscall number 0x13. + */ +Result MapSharedMemory(Handle handle, void* addr, size_t size, u32 perm); + +/** + * @brief Unmaps a block of shared memory. + * @return Result code. + * @note Syscall number 0x14. + */ +Result UnmapSharedMemory(Handle handle, void* addr, size_t size); + +/** + * @brief Creates a block of transfer memory. + * @return Result code. + * @note Syscall number 0x15. + */ +Result CreateTransferMemory(Handle* out, void* addr, size_t size, u32 perm); + +/** + * @brief Closes a handle, decrementing the reference count of the corresponding kernel object. + * This might result in the kernel freeing the object. + * @param handle Handle to close. + * @return Result code. + * @note Syscall number 0x16. + */ +Result CloseHandle(Handle handle); + +/** + * @brief Resets a signal. + * @return Result code. + * @note Syscall number 0x17. + */ +Result ResetSignal(Handle handle); + +/** + * @brief Waits on one or more synchronization objects, optionally with a timeout. + * @return Result code. + * @note Syscall number 0x18. + * @note \p handleCount must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. + * @note This is the raw syscall, which can be cancelled by \ref svcCancelSynchronization or other means. \ref waitHandles or \ref waitMultiHandle should normally be used instead. + */ +Result WaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout); + +/** + * @brief Waits on a single synchronization object, optionally with a timeout. + * @return Result code. + * @note Wrapper for \ref svcWaitSynchronization. + * @note This is the raw syscall, which can be cancelled by \ref svcCancelSynchronization or other means. \ref waitSingleHandle should normally be used instead. + */ +Result WaitSynchronizationSingle(Handle handle, u64 timeout); + +/** + * @brief Waits a \ref svcWaitSynchronization operation being done on a synchronization object in another thread. + * @return Result code. + * @note Syscall number 0x19. + */ +Result CancelSynchronization(Handle thread); + +/** + * @brief Arbitrates a mutex lock operation in userspace. + * @return Result code. + * @note Syscall number 0x1A. + */ +Result ArbitrateLock(u32 wait_tag, u32* tag_location, u32 self_tag); + +/** + * @brief Arbitrates a mutex unlock operation in userspace. + * @return Result code. + * @note Syscall number 0x1B. + */ +Result ArbitrateUnlock(u32* tag_location); + +/** + * @brief Performs a condition variable wait operation in userspace. + * @return Result code. + * @note Syscall number 0x1C. + */ +Result WaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u64 timeout); + +/** + * @brief Performs a condition variable wake-up operation in userspace. + * @note Syscall number 0x1D. + */ +void SignalProcessWideKey(u32* key, s32 num); + +/** + * @brief Gets the current system tick. + * @return The current system tick. + * @note Syscall number 0x1E. + */ +u64 GetSystemTick(void); + +/** + * @brief Connects to a registered named port. + * @return Result code. + * @note Syscall number 0x1F. + */ +Result ConnectToNamedPort(Handle* session, const char* name); + +/** + * @brief Sends a light IPC synchronization request to a session. + * @return Result code. + * @note Syscall number 0x20. + */ +Result SendSyncRequestLight(Handle session); + +/** + * @brief Sends an IPC synchronization request to a session. + * @return Result code. + * @note Syscall number 0x21. + */ +Result SendSyncRequest(Handle session); + +/** + * @brief Sends an IPC synchronization request to a session from an user allocated buffer. + * @return Result code. + * @remark size must be allocated to 0x1000 bytes. + * @note Syscall number 0x22. + */ +Result SendSyncRequestWithUserBuffer(void* usrBuffer, u64 size, Handle session); + +/** + * @brief Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version). + * @return Result code. + * @remark size must be allocated to 0x1000 bytes. + * @note Syscall number 0x23. + */ +Result SendAsyncRequestWithUserBuffer(Handle* handle, void* usrBuffer, u64 size, Handle session); + +/** + * @brief Gets the PID associated with a process. + * @return Result code. + * @note Syscall number 0x24. + */ +Result GetProcessId(u64 *processID, Handle handle); + +/** + * @brief Gets the TID associated with a process. + * @return Result code. + * @note Syscall number 0x25. + */ +Result GetThreadId(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. + * @return Result code. + * @note Syscall number 0x26. + */ +Result Break(u32 breakReason, uintptr_t address, uintptr_t size); + +/** + * @brief Outputs debug text, if used during debugging. + * @param[in] str Text to output. + * @param[in] size Size of the text in bytes. + * @return Result code. + * @note Syscall number 0x27. + */ +Result OutputDebugString(const char *str, u64 size); + +/** + * @brief Returns from an exception. + * @param[in] res Result code. + * @note Syscall number 0x28. + */ +[[noreturn]] void ReturnFromException(Result res); + +/** + * @brief Retrieves information about the system, or a certain kernel object. + * @param[out] out Variable to which store the information. + * @param[in] id0 First ID of the property to retrieve. + * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. + * @param[in] id1 Second ID of the property to retrieve. + * @return Result code. + * @remark The full list of property IDs can be found on the switchbrew.org wiki. + * @note Syscall number 0x29. + */ +Result GetInfo(u64* out, u32 id0, Handle handle, u64 id1); + +/** + * @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 FlushEntireDataCache(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 FlushDataCache(void *address, size_t size); + +/** + * @brief Maps new heap memory at the desired address. [3.0.0+] + * @return Result code. + * @note Syscall number 0x2C. + */ +Result MapPhysicalMemory(void *address, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+] + * @return Result code. + * @note Syscall number 0x2D. + */ +Result UnmapPhysicalMemory(void *address, u64 size); + +/** + * @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 GetDebugFutureThreadInfo(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 GetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags); + +/** + * @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle. + * @return Result code. + * @note Syscall number 0x30. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetResourceLimitLimitValue(s64 *out, Handle reslimit_h, LimitableResource which); + +/** + * @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle. + * @return Result code. + * @note Syscall number 0x31. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetResourceLimitCurrentValue(s64 *out, Handle reslimit_h, LimitableResource which); + +/** + * @brief Configures the pause/unpause status of a thread. + * @return Result code. + * @note Syscall number 0x32. + */ +Result SetThreadActivity(Handle thread, ThreadActivity paused); + +/** + * @brief Dumps the registers of a thread paused by @ref svcSetThreadActivity (register groups: all). + * @param[out] ctx Output thread context (register dump). + * @param[in] thread Thread handle. + * @return Result code. + * @note Syscall number 0x33. + * @warning Official kernel will not dump x0..x18 if the thread is currently executing a system call, and prior to 6.0.0 doesn't dump TPIDR_EL0. + */ +Result GetThreadContext3(ThreadContext* ctx, Handle thread); + +/** + * @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 WaitForAddress(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 SignalToAddress(void *address, u32 signal_type, s32 value, s32 count); + +/** + * @brief Sets thread preemption state (used during abort/panic). [8.0.0+] + * @note Syscall number 0x36. + */ +void SynchronizePreemptionState(void); + +/** + * @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 GetResourceLimitPeakValue(s64 *out, Handle reslimit_h, LimitableResource which); + +/** + * @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 CreateIoPool(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 CreateIoRegion(Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm); + +/** + * @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 DumpInfo(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 KernelDebug(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 ChangeKernelTraceState(u32 kern_trace_state); + +/** + * @brief Creates an IPC session. + * @return Result code. + * @note Syscall number 0x40. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateSession(Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1); + +/** + * @brief Accepts an IPC session. + * @return Result code. + * @note Syscall number 0x41. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result AcceptSession(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 ReplyAndReceiveLight(Handle handle); + +/** + * @brief Performs IPC input/output. + * @return Result code. + * @note Syscall number 0x43. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout); + +/** + * @brief Performs IPC input/output from an user allocated buffer. + * @return Result code. + * @note Syscall number 0x44. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ReplyAndReceiveWithUserBuffer(s32* index, void* usrBuffer, u64 size, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout); + +/** + * @brief Creates a system event. + * @return Result code. + * @note Syscall number 0x45. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateEvent(Handle* server_handle, Handle* client_handle); + +/** + * @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 MapIoRegion(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 UnmapIoRegion(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. + * @note Syscall number 0x48. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result MapPhysicalMemoryUnsafe(void *address, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] + * @return Result code. + * @note Syscall number 0x49. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result UnmapPhysicalMemoryUnsafe(void *address, u64 size); + +/** + * @brief Sets the system-wide limit for unsafe memory mappable using \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] + * @return Result code. + * @note Syscall number 0x4A. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result SetUnsafeLimit(u64 size); + +/** + * @brief Creates code memory in the caller's address space [4.0.0+]. + * @return Result code. + * @note Syscall number 0x4B. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateCodeMemory(Handle* code_handle, void* src_addr, u64 size); + +/** + * @brief Maps code memory in the caller's address space [4.0.0+]. + * @return Result code. + * @note Syscall number 0x4C. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ControlCodeMemory(Handle code_handle, CodeMapOperation op, void* dst_addr, u64 size, u64 perm); + +/** + * @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 SleepSystem(void); + +/** + * @brief Reads/writes a protected MMIO register. + * @return Result code. + * @note Syscall number 0x4E. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal); + +/** + * @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 SetProcessActivity(Handle process, ProcessActivity paused); + +/** + * @brief Creates a block of shared memory. + * @return Result code. + * @note Syscall number 0x50. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateSharedMemory(Handle* out, size_t size, u32 local_perm, u32 other_perm); + +/** + * @brief Maps a block of transfer memory. + * @return Result code. + * @note Syscall number 0x51. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result MapTransferMemory(Handle tmem_handle, void* addr, size_t size, u32 perm); + +/** + * @brief Unmaps a block of transfer memory. + * @return Result code. + * @note Syscall number 0x52. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result UnmapTransferMemory(Handle tmem_handle, void* addr, size_t size); + +/** + * @brief Creates an event and binds it to a specific hardware interrupt. + * @return Result code. + * @note Syscall number 0x53. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateInterruptEvent(Handle* handle, u64 irqNum, u32 flag); + +/** + * @brief Queries information about a certain virtual address, including its physical address. + * @return Result code. + * @note Syscall number 0x54. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result QueryPhysicalAddress(PhysicalMemoryInfo *out, 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 QueryMemoryMapping(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 LegacyQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size); + +/** + * @brief Creates a virtual address space for binding device address spaces. + * @return Result code. + * @note Syscall number 0x56. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateDeviceAddressSpace(Handle *handle, u64 dev_addr, u64 dev_size); + +/** + * @brief Attaches a device address space to a device. + * @return Result code. + * @note Syscall number 0x57. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result AttachDeviceAddressSpace(u64 device, Handle handle); + +/** + * @brief Detaches a device address space from a device. + * @return Result code. + * @note Syscall number 0x58. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result DetachDeviceAddressSpace(u64 device, Handle handle); + +/** + * @brief Maps an attached device address space to an userspace address. + * @return Result code. + * @remark The userspace destination address must have the \ref MemState_MapDeviceAllowed bit set. + * @note Syscall number 0x59. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result MapDeviceAddressSpaceByForce(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. + * @return Result code. + * @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set. + * @note Syscall number 0x5A. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result MapDeviceAddressSpaceAligned(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 MapDeviceAddressSpace(u64 *out_mapped_size, 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. + * @return Result code. + * @note Syscall number 0x5C. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result UnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr); + +/** + * @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 InvalidateProcessDataCache(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 StoreProcessDataCache(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 FlushProcessDataCache(Handle process, uintptr_t address, size_t size); + +/** + * @brief Debugs an active process. + * @return Result code. + * @note Syscall number 0x60. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result DebugActiveProcess(Handle* debug, u64 processID); + +/** + * @brief Breaks an active debugging session. + * @return Result code. + * @note Syscall number 0x61. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result BreakDebugProcess(Handle debug); + +/** + * @brief Terminates the process of an active debugging session. + * @return Result code. + * @note Syscall number 0x62. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result TerminateDebugProcess(Handle debug); + +/** + * @brief Gets an incoming debug event from a debugging session. + * @return Result code. + * @note Syscall number 0x63. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetDebugEvent(DebugEventInfo* 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. + */ +Result ContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tids); + +/** + * @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 [1.0.0-2.3.0]. For newer versions use \ref svcContinueDebugEvent. + */ +Result LegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID); + +/** + * @brief Gets the context (dump the registers) of a thread in a debugging session. + * @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] 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). + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetDebugThreadContext(ThreadContext* ctx, Handle debug, u64 threadID, u32 flags); + +/** + * @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] ctx Input thread context (register dump). + * @param[in] flags Register groups to select, combination of @ref RegisterGroup flags. + * @note Syscall number 0x68. + * @warning Official kernel will return an error if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException). + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result SetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext* ctx, u32 flags); + +/** + * @brief Retrieves a list of all running processes. + * @return Result code. + * @note Syscall number 0x65. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids); + +/** + * @brief Retrieves a list of all threads for a debug handle (or zero). + * @return Result code. + * @note Syscall number 0x66. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetThreadList(s32 *num_out, u64 *tids_out, u32 max_tids, Handle debug); + +/** + * @brief Queries memory information from a process that is being debugged. + * @return Result code. + * @note Syscall number 0x69. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result QueryDebugProcessMemory(MemoryInfo* meminfo_ptr, u32* pageinfo, Handle debug, u64 addr); + +/** + * @brief Reads memory from a process that is being debugged. + * @return Result code. + * @note Syscall number 0x6A. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size); + +/** + * @brief Writes to memory in a process that is being debugged. + * @return Result code. + * @note Syscall number 0x6B. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result WriteDebugProcessMemory(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 SetHardwareBreakPoint(u32 which, u64 flags, u64 value); + +/** + * @brief Gets parameters from a thread in a debugging session. + * @return Result code. + * @note Syscall number 0x6D. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetDebugThreadParam(u64* out_64, u32* out_32, Handle debug, u64 threadID, DebugThreadParam param); + +/** + * @brief Retrieves privileged information about the system, or a certain kernel object. + * @param[out] out Variable to which store the information. + * @param[in] id0 First ID of the property to retrieve. + * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. + * @param[in] id1 Second ID of the property to retrieve. + * @return Result code. + * @remark The full list of property IDs can be found on the switchbrew.org wiki. + * @note Syscall number 0x6F. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetSystemInfo(u64* out, u64 id0, Handle handle, u64 id1); + +/** + * @brief Creates a port. + * @return Result code. + * @note Syscall number 0x70. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreatePort(Handle* portServer, Handle *portClient, s32 max_sessions, bool is_light, const char* name); + +/** + * @brief Manages a named port. + * @return Result code. + * @note Syscall number 0x71. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ManageNamedPort(Handle* portServer, const char* name, s32 maxSessions); + +/** + * @brief Manages a named port. + * @return Result code. + * @note Syscall number 0x72. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result ConnectToPort(Handle* session, Handle port); + +/** + * @brief Sets the memory permissions for the specified memory with the supplied process handle. + * @param[in] proc Process handle. + * @param[in] addr Address of the memory. + * @param[in] size Size of the memory. + * @param[in] perm Permissions (see \ref Permission). + * @return Result code. + * @remark This returns an error (0xD801) when \p perm is >0x5, hence -WX and RWX are not allowed. + * @note Syscall number 0x73. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result SetProcessMemoryPermission(Handle proc, u64 addr, u64 size, u32 perm); + +/** + * @brief Maps the src address from the supplied process handle into the current process. + * @param[in] dst Address to which map the memory in the current process. + * @param[in] proc Process handle. + * @param[in] src Source mapping address. + * @param[in] size Size of the memory. + * @return Result code. + * @remark This allows mapping code and rodata with RW- permission. + * @note Syscall number 0x74. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result MapProcessMemory(void* dst, Handle proc, u64 src, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapProcessMemory. + * @param[in] dst Destination mapping address + * @param[in] proc Process handle. + * @param[in] src Address of the memory in the process. + * @param[in] size Size of the memory. + * @return Result code. + * @remark This allows mapping code and rodata with RW- permission. + * @note Syscall number 0x75. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result UnmapProcessMemory(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 QueryProcessMemory(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). + * @param[in] dst Destination mapping address. + * @param[in] src Source mapping address. + * @param[in] size Size of the mapping. + * @return Result code. + * @note Syscall number 0x77. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result MapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapProcessCodeMemory. + * @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE). + * @param[in] dst Destination mapping address. + * @param[in] src Source mapping address. + * @param[in] size Size of the mapping. + * @return Result code. + * @note Syscall number 0x78. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result UnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size); + +/** + * @brief Creates a new process. + * @return Result code. + * @note Syscall number 0x79. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateProcess(Handle* out, const void* proc_info, const u32* caps, u64 cap_num); + +/** + * @brief Starts executing a freshly created process. + * @return Result code. + * @note Syscall number 0x7A. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result StartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size); + +/** + * @brief Terminates a running process. + * @return Result code. + * @note Syscall number 0x7B. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result TerminateProcess(Handle proc); + +/** + * @brief Gets a \ref ProcessInfoType for a process. + * @return Result code. + * @note Syscall number 0x7C. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result GetProcessInfo(s64 *out, Handle proc, ProcessInfoType which); + +/** + * @brief Creates a new Resource Limit handle. + * @return Result code. + * @note Syscall number 0x7D. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result CreateResourceLimit(Handle* out); + +/** + * @brief Sets the value for a \ref LimitableResource for a Resource Limit handle. + * @return Result code. + * @note Syscall number 0x7E. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result SetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u64 value); + +/** + * @brief Calls a secure monitor function (TrustZone, EL3). + * @param regs Arguments to pass to the secure monitor. + * @note Syscall number 0x7F. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +void CallSecureMonitor(SecmonArgs* regs); + +/** + * @brief Maps new insecure memory at the desired address. [15.0.0+] + * @return Result code. + * @note Syscall number 0x90. + */ +Result MapInsecurePhysicalMemory(void *address, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapInsecureMemory. [15.0.0+] + * @return Result code. + * @note Syscall number 0x91. + */ +Result UnmapInsecurePhysicalMemory(void *address, u64 size); + +} // namespace svc + +/// @brief C++ wrappers for the `swkbd` API. +/// @details Wraps: switch/applets/swkbd.h. +namespace swkbd { + +using ::SwkbdAppearArg; +/// Base swkbd arg struct. +using ::SwkbdArgCommon; +using ::SwkbdArgV0; +/// Arg struct for version 0x30007+. +using ::SwkbdArgV7; +/// Arg struct for version 0x6000B+. +using ::SwkbdArgVB; +/// Struct data for SwkbdInline Interactive reply storage ChangedString*, at the end following the string. +using ::SwkbdChangedStringArg; +/// 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. +using ::SwkbdChangedStringCb; +/// 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. +using ::SwkbdChangedStringV2Cb; +using ::SwkbdConfig; +using ::SwkbdCustomizedDictionarySet; +/// Input data for SwkbdInline request SetCustomizeDic. +using ::SwkbdCustomizeDicInfo; +/// Struct data for SwkbdInline Interactive reply storage DecidedEnter*, at the end following the string. +using ::SwkbdDecidedEnterArg; +/// 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. +using ::SwkbdDecidedEnterCb; +/// User dictionary word. +using ::SwkbdDictWord; +/// InitializeArg for SwkbdInline. +using ::SwkbdInitializeArg; +/// InlineKeyboard +using ::SwkbdInline; +using ::SwkbdInlineCalcArg; +/// Value for \ref SwkbdInitializeArg mode. Controls the LibAppletMode when launching the applet. +using ::SwkbdInlineMode; +/// Struct data for SwkbdInline Interactive reply storage MovedCursor*, at the end following the string. +using ::SwkbdMovedCursorArg; +/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor* replies. +/// str is the UTF-8 string for the current text. +using ::SwkbdMovedCursorCb; +/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor*V2 replies. +/// str is the UTF-8 string for the current text. +using ::SwkbdMovedCursorV2Cb; +/// Struct data for SwkbdInline Interactive reply storage MovedTab*, at the end following the string. +using ::SwkbdMovedTabArg; +/// This callback is used by \ref swkbdInlineUpdate when handling MovedTab* replies. +/// str is the UTF-8 string for the current text. +using ::SwkbdMovedTabCb; +/// Rect +using ::SwkbdRect; +/// SwkbdInline Interactive output storage reply ID. +using ::SwkbdReplyType; +/// SwkbdInline Interactive input storage request ID. +using ::SwkbdRequestCommand; +/// SwkbdInline State +using ::SwkbdState; +/// 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. +using ::SwkbdTextCheckCb; +/// Output result returned by \ref SwkbdTextCheckCb. +using ::SwkbdTextCheckResult; +/// Value for SwkbdArgCommon::textDrawType. Only applies when stringLenMax is 1..32, otherwise swkbd will only use SwkbdTextDrawType_Box. +using ::SwkbdTextDrawType; +/// Type of keyboard. +using ::SwkbdType; + +/** + * @brief Creates a SwkbdConfig struct. + * @param c SwkbdConfig struct. + * @param max_dictwords Max \ref SwkbdDictWord entries, 0 for none. + */ +Result Create(SwkbdConfig* c, s32 max_dictwords); + +/** + * @brief Closes a SwkbdConfig struct. + * @param c SwkbdConfig struct. + */ +void Close(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. + * @param c SwkbdConfig struct. + */ +void ConfigMakePresetDefault(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. + * @param c SwkbdConfig struct. + */ +void ConfigMakePresetPassword(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. + * @param c SwkbdConfig struct. + */ +void ConfigMakePresetUserName(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. + * @param c SwkbdConfig struct. + */ +void ConfigMakePresetDownloadCode(SwkbdConfig* c); + +/** + * @brief Sets the Ok button text. The default is "". + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetOkButtonText(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the LeftOptionalSymbolKey, for \ref SwkbdType_NumPad. The default is "". + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetLeftOptionalSymbolKey(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the RightOptionalSymbolKey, for \ref SwkbdType_NumPad. The default is "". + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetRightOptionalSymbolKey(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the Header text. The default is "". + * @note See SwkbdArgCommon::stringLenMax. + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetHeaderText(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the Sub text. The default is "". + * @note See SwkbdArgCommon::stringLenMax. + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetSubText(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the Guide text. The default is "". + * @note The swkbd applet only displays this when the current displayed cursor position is 0. + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetGuideText(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the Initial text. The default is "". + * @param c SwkbdConfig struct. + * @param str UTF-8 input string. + */ +void ConfigSetInitialText(SwkbdConfig* c, const char* str); + +/** + * @brief Sets the user dictionary. + * @param c SwkbdConfig struct. + * @param input Input data. + * @param entries Total entries in the buffer. + */ +void ConfigSetDictionary(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 ConfigSetCustomizedDictionaries(SwkbdConfig* c, const SwkbdCustomizedDictionarySet *dic); + +/** + * @brief Sets the TextCheck callback. + * @param c SwkbdConfig struct. + * @param cb \ref SwkbdTextCheckCb callback. + */ +void ConfigSetTextCheckCallback(SwkbdConfig* c, SwkbdTextCheckCb cb); + +/** + * @brief Sets SwkbdArgCommon::SwkbdType. + * @param c SwkbdConfig struct. + * @param type \ref SwkbdType + */ +void ConfigSetType(SwkbdConfig* c, SwkbdType type); + +/** + * @brief Sets SwkbdArgCommon::dicFlag. + * @param c SwkbdConfig struct. + * @param flag Flag + */ +void ConfigSetDicFlag(SwkbdConfig* c, u8 flag); + +/** + * @brief Sets SwkbdArgCommon::keySetDisableBitmask. + * @param c SwkbdConfig struct. + * @param keySetDisableBitmask keySetDisableBitmask + */ +void ConfigSetKeySetDisableBitmask(SwkbdConfig* c, u32 keySetDisableBitmask); + +/** + * @brief Sets SwkbdArgCommon::initialCursorPos. + * @param c SwkbdConfig struct. + * @param initialCursorPos initialCursorPos + */ +void ConfigSetInitialCursorPos(SwkbdConfig* c, u32 initialCursorPos); + +/** + * @brief Sets SwkbdArgCommon::stringLenMax. + * @param c SwkbdConfig struct. + * @param stringLenMax stringLenMax + */ +void ConfigSetStringLenMax(SwkbdConfig* c, u32 stringLenMax); + +/** + * @brief Sets SwkbdArgCommon::stringLenMin. + * @param c SwkbdConfig struct. + * @param stringLenMin stringLenMin + */ +void ConfigSetStringLenMin(SwkbdConfig* c, u32 stringLenMin); + +/** + * @brief Sets SwkbdArgCommon::passwordFlag. + * @param c SwkbdConfig struct. + * @param flag Flag + */ +void ConfigSetPasswordFlag(SwkbdConfig* c, u32 flag); + +/** + * @brief Sets SwkbdArgCommon::textDrawType. + * @param c SwkbdConfig struct. + * @param textDrawType \ref SwkbdTextDrawType + */ +void ConfigSetTextDrawType(SwkbdConfig* c, SwkbdTextDrawType textDrawType); + +/** + * @brief Sets SwkbdArgCommon::returnButtonFlag. + * @param c SwkbdConfig struct. + * @param flag Flag + */ +void ConfigSetReturnButtonFlag(SwkbdConfig* c, u16 flag); + +/** + * @brief Sets SwkbdArgCommon::blurBackground. + * @param c SwkbdConfig struct. + * @param blurBackground blurBackground + */ +void ConfigSetBlurBackground(SwkbdConfig* c, u8 blurBackground); + +/** + * @brief Sets SwkbdArgV7::textGrouping. + * @param index Array index. + * @param value Value to write. + */ +void ConfigSetTextGrouping(SwkbdConfig* c, u32 index, u32 value); + +/** + * @brief Sets SwkbdConfig::unkFlag, default is 0. Copied to SwkbdArgVB::unkFlag with [8.0.0+]. + * @param flag Flag + */ +void ConfigSetUnkFlag(SwkbdConfig* c, u8 flag); + +/** + * @brief Sets SwkbdConfig::trigger, default is 0. Copied to SwkbdArgVB::trigger with [8.0.0+]. + * @param trigger Trigger + */ +void ConfigSetTrigger(SwkbdConfig* c, u8 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. + * @param c SwkbdConfig struct. + * @param out_string UTF-8 Output string buffer. + * @param out_string_size UTF-8 Output string buffer size, including NUL-terminator. + */ +Result Show(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 InlineCreate(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 InlineClose(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 InlineLaunch(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 InlineLaunchForLibraryApplet(SwkbdInline* s, u8 mode, u8 unk_x5); + +/** + * @brief GetWindowSize + * @param[out] width Output width. + * @param[out] height Output height. + */ +void InlineGetWindowSize(s32 *width, s32 *height); + +/** + * @brief GetImageMemoryRequirement + * @note Wrapper for \ref viGetIndirectLayerImageRequiredMemoryInfo. + * @param[out] out_size Output size. + * @param[out] out_alignment Output alignment. + */ +Result InlineGetImageMemoryRequirement(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 InlineGetImage(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 InlineGetMaxHeight(SwkbdInline* s); + +/** + * @brief Gets the MiniaturizedHeight, relative to the bottom of the screen. + * @param s SwkbdInline object. + */ +s32 InlineGetMiniaturizedHeight(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 InlineGetTouchRectangles(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 InlineIsUsedTouchPointByKeyboard(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 InlineUpdate(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 InlineSetFinishedInitializeCallback(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 InlineSetDecidedCancelCallback(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 InlineSetChangedStringCallback(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 InlineSetChangedStringV2Callback(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 InlineSetMovedCursorCallback(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 InlineSetMovedCursorV2Callback(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 InlineSetMovedTabCallback(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 InlineSetDecidedEnterCallback(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 InlineSetReleasedUserWordInfoCallback(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 InlineAppear(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 InlineAppearEx(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 InlineDisappear(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 InlineMakeAppearArg(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 InlineAppearArgSetOkButtonText(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 InlineAppearArgSetLeftButtonText(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 InlineAppearArgSetRightButtonText(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 + */ +void InlineAppearArgSetStringLenMax(SwkbdAppearArg* arg, s32 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 + */ +void InlineAppearArgSetStringLenMin(SwkbdAppearArg* arg, s32 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 InlineSetVolume(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 InlineSetInputText(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 InlineSetCursorPos(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 InlineSetUserWordInfo(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 InlineUnsetUserWordInfo(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 InlineSetUtf8Mode(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 InlineSetCustomizeDic(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 InlineUnsetCustomizeDic(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 InlineSetCustomizedDictionaries(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 InlineUnsetCustomizedDictionaries(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 InlineSetInputModeFadeType(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 InlineSetAlphaEnabledInInputMode(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 InlineSetKeytopBgAlpha(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 InlineSetFooterBgAlpha(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 InlineSetKeytopScale(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 InlineSetKeytopTranslate(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 InlineSetKeytopAsFloating(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 InlineSetFooterScalable(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 InlineSetTouchFlag(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 InlineSetHardwareKeyboardFlag(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 InlineSetDirectionalButtonAssignFlag(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 InlineSetSeGroup(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 InlineSetBackspaceFlag(SwkbdInline* s, bool flag); + +} // namespace swkbd + +/// @brief C++ wrappers for the `tc` API. +/// @details Wraps: switch/services/tc.h. +namespace tc { + +/// Initialize tc. +Result Initialize(void); + +/// Exit tc. +void Exit(void); + +/// Gets the Service for tc. +Service* GetServiceSession(void); + +Result EnableFanControl(void); + +/// @warning Disabling your fan can damage your system. +Result DisableFanControl(void); + +Result IsFanControlEnabled(bool *status); + +/// Only available on [5.0.0+]. +Result GetSkinTemperatureMilliC(s32 *skinTemp); + +} // namespace tc + +/// @brief C++ wrappers for the `thread` API. +/// @details Wraps: switch/arm/thread_context.h, switch/kernel/thread.h. +namespace thread { + +/// Armv8 CPU register. +using ::CpuRegister; +/// Armv8 NEON register. +using ::FpuRegister; +/// Armv8 register group. @ref svcGetThreadContext3 uses @ref RegisterGroup_All. +using ::RegisterGroup; +/// Thread information structure. +using ::Thread; +/// Thread context structure (register dump) +using ::ThreadContext; +/// This is for \ref ThreadExceptionDump error_desc. +using ::ThreadExceptionDesc; +/// Thread exception dump structure. +using ::ThreadExceptionDump; +using ::ThreadExceptionFrameA32; +using ::ThreadExceptionFrameA64; + +/** + * @brief Determines whether a thread context belong to an AArch64 process based on the PSR. + * @param[in] ctx Thread context to which PSTATE/cspr has been dumped to. + * @return true if and only if the thread context belongs to an AArch64 process. + */ +bool ContextIsAArch64(const ThreadContext *ctx); + +/** + * @brief Determines whether a ThreadExceptionDump belongs to an AArch64 process based on the PSTATE. + * @param[in] ctx ThreadExceptionDump. + * @return true if and only if the ThreadExceptionDump belongs to an AArch64 process. + */ +bool ExceptionIsAArch64(const ThreadExceptionDump *ctx); + +/** + * @brief Creates a thread. + * @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 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 Create(Thread* t, ThreadFunc entry, void* arg, void *stack_mem, size_t stack_sz, int prio, int cpuid); + +/** + * @brief Starts the execution of a thread. + * @param t Thread information structure. + * @return Result code. + */ +Result Start(Thread* t); + +/** + * @brief Exits the current thread immediately. + */ +[[noreturn]] void Exit(void); + +/** + * @brief Waits for a thread to finish executing. + * @param t Thread information structure. + * @return Result code. + */ +Result WaitForExit(Thread* t); + +/** + * @brief Frees up resources associated with a thread. + * @param t Thread information structure. + * @return Result code. + */ +Result Close(Thread* t); + +/** + * @brief Pauses the execution of a thread. + * @param t Thread information structure. + * @return Result code. + */ +Result Pause(Thread* t); + +/** + * @brief Resumes the execution of a thread, after having been paused. + * @param t Thread information structure. + * @return Result code. + */ +Result Resume(Thread* t); + +/** + * @brief Dumps the registers of a thread paused by @ref threadPause (register groups: all). + * @param[out] ctx Output thread context (register dump). + * @param t Thread information structure. + * @return Result code. + * @warning Official kernel will not dump x0..x18 if the thread is currently executing a system call, and prior to 6.0.0 doesn't dump TPIDR_EL0. + */ +Result DumpContext(ThreadContext* ctx, Thread* t); + +/** + * @brief Gets a pointer to the current thread structure. + * @return Thread information structure. + */ +Thread * GetSelf(void); + +/** + * @brief Gets the raw handle to the current thread. + * @return The current thread's handle. + */ +Handle GetCurHandle(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 TlsAlloc(void (* destructor)(void*)); + +/** + * @brief Retrieves the value stored in a TLS slot. + * @param slot_id TLS slot ID. + * @return Value. + */ +void* TlsGet(s32 slot_id); + +/** + * @brief Stores the specified value into a TLS slot. + * @param slot_id TLS slot ID. + * @param value Value. + */ +void TlsSet(s32 slot_id, void* value); + +/** + * @brief Frees a TLS slot. + * @param slot_id TLS slot ID. + */ +void TlsFree(s32 slot_id); + +} // namespace thread + +/// @brief C++ wrappers for the `time` API. +/// @details Wraps: switch/services/time.h. +namespace time { + +using ::TimeCalendarAdditionalInfo; +using ::TimeCalendarTime; +using ::TimeLocationName; +/// Values for __nx_time_service_type. +using ::TimeServiceType; +using ::TimeStandardSteadyClockTimePointType; +using ::TimeSteadyClockTimePoint; +using ::TimeSystemClockContext; +/// Time clock type. +using ::TimeType; +using ::TimeZoneRule; + +/// Initialize time. Used automatically during app startup. +Result Initialize(void); + +/// Exit time. Used automatically during app startup. +void Exit(void); + +/// Gets the Service object for the actual time service session. +Service* GetServiceSession(void); + +/// Gets the Service object for ISystemClock with the specified \ref TimeType. This will return NULL when the type is invalid. +Service* GetServiceSession_SystemClock(TimeType type); + +/// Gets the Service object for ISteadyClock. +Service* GetServiceSession_SteadyClock(void); + +/// Gets the Service object for ITimeZoneService. +Service* GetServiceSession_TimeZoneService(void); + +/// [6.0.0+] Gets the address of the SharedMemory. +void* GetSharedmemAddr(void); + +/** + * @brief Gets the timepoint for the standard steady clock. + * @param[out] out Output timepoint (see \ref TimeSteadyClockTimePoint) + * @remark The standard steady clock counts time since the RTC was configured (usually this happens during manufacturing). + * @return Result code. + */ +Result GetStandardSteadyClockTimePoint(TimeSteadyClockTimePoint *out); + +/** + * @brief [3.0.0+] Gets the internal offset for the standard steady clock. + * @param[out] out Output internal offset. + * @return Result code. + */ +Result GetStandardSteadyClockInternalOffset(s64 *out); + +/** + * @brief Gets the time for the specified clock. + * @param[in] type Clock to use. + * @param[out] timestamp POSIX UTC timestamp. + * @return Result code. + */ +Result GetCurrentTime(TimeType type, u64 *timestamp); + +/** + * @brief Sets the time for the specified clock. + * @param[in] type Clock to use. + * @param[in] timestamp POSIX UTC timestamp. + * @return Result code. + */ +Result SetCurrentTime(TimeType type, u64 timestamp); + +Result GetDeviceLocationName(TimeLocationName *name); + +Result SetDeviceLocationName(const TimeLocationName *name); + +Result GetTotalLocationNameCount(s32 *total_location_name_count); + +Result LoadLocationNameList(s32 index, TimeLocationName *location_name_array, s32 location_name_max, s32 *location_name_count); + +Result LoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule); + +Result ToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info); + +Result ToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info); + +Result ToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count); + +Result ToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count); + +} // namespace time + +/// @brief C++ wrappers for the `tipc` API. +/// @details Wraps: switch/sf/tipc.h. +namespace tipc { + +using ::TipcCommandType; +using ::TipcDispatchParams; +using ::TipcRequestFormat; +/// tipc Service object structure +using ::TipcService; + +/** + * @brief Creates a tipc service object from an IPC session handle. + * @param[out] s TIPC service object. + * @param[in] h IPC session handle. + */ +void Create(TipcService* s, Handle h); + +/** + * @brief Closes a tipc service. + * @param[in] s TIPC service object. + */ +void Close(TipcService* s); + +void RequestInBuffer(HipcRequest* req, const void* buffer, size_t size, HipcBufferMode mode); + +void RequestOutBuffer(HipcRequest* req, void* buffer, size_t size, HipcBufferMode mode); + +void RequestInOutBuffer(HipcRequest* req, void* buffer, size_t size, HipcBufferMode mode); + +void RequestHandle(HipcRequest* req, Handle handle); + +void RequestFormatProcessBuffer(TipcRequestFormat* fmt, u32 attr); + +void RequestProcessBuffer(HipcRequest* req, const SfBuffer* buf, u32 attr); + +void* MakeRequest(u32 request_id, u32 data_size, bool send_pid, const SfBufferAttrs buffer_attrs, const SfBuffer* buffers, u32 num_handles, const Handle* handles); + +Handle ResponseGetCopyHandle(HipcResponse* res); + +Handle ResponseGetMoveHandle(HipcResponse* res); + +void ResponseGetHandle(HipcResponse* res, SfOutHandleAttr type, Handle* out); + +Result ParseResponse(u32 out_size, void** out_data, u32 num_out_objects, TipcService* out_objects, const SfOutHandleAttrs out_handle_attrs, Handle* out_handles); + +Result DispatchImpl(TipcService* s, u32 request_id, const void* in_data, u32 in_data_size, void* out_data, u32 out_data_size, TipcDispatchParams disp); + +} // namespace tipc + +/// @brief C++ wrappers for the `tmem` API. +/// @details Wraps: switch/kernel/tmem.h. +namespace tmem { + +/// Transfer memory information structure. +using ::TransferMemory; + +/** + * @brief Creates a transfer memory object. + * @param t Transfer memory information structure that will be filled in. + * @param size Size of the transfer memory object to create. + * @param perm Permissions with which to protect the transfer memory in the local process. + * @return Result code. + */ +Result Create(TransferMemory* t, size_t size, Permission perm); + +/** + * @brief Creates a transfer memory object from existing memory. + * @param t Transfer memory information structure that will be filled in. + * @param buf Pointer to a page-aligned buffer. + * @param size Size of the transfer memory object to create. + * @param perm Permissions with which to protect the transfer memory in the local process. + * @return Result code. + */ +Result CreateFromMemory(TransferMemory* t, void* buf, size_t size, Permission perm); + +/** + * @brief Loads a transfer memory object coming from a remote process. + * @param t Transfer memory information structure which will be filled in. + * @param handle Handle of the transfer memory object. + * @param size Size of the transfer memory object that is being loaded. + * @param perm Permissions which the transfer memory is expected to have in the process that owns the memory. + * @warning This is a privileged operation; in normal circumstances applications shouldn't use this function. + */ +void LoadRemote(TransferMemory* t, Handle handle, size_t size, Permission perm); + +/** + * @brief Maps a transfer memory object. + * @param t Transfer memory information structure. + * @return Result code. + * @warning This is a privileged operation; in normal circumstances applications cannot use this function. + */ +Result Map(TransferMemory* t); + +/** + * @brief Unmaps a transfer memory object. + * @param t Transfer memory information structure. + * @return Result code. + * @warning This is a privileged operation; in normal circumstances applications cannot use this function. + */ +Result Unmap(TransferMemory* t); + +/** + * @brief Retrieves the mapped address of a transfer memory object. + * @param t Transfer memory information structure. + * @return Mapped address of the transfer memory object. + */ +void* GetAddr(TransferMemory* t); + +/** + * @brief Closes handle of a transfer memory object. + * @param t Transfer memory information structure. + * @return Result code. + */ +Result CloseHandle(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 WaitForPermission(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. + * @return Result code. + */ +Result Close(TransferMemory* t); + +} // namespace tmem + +/// @brief C++ wrappers for the `ts` API. +/// @details Wraps: switch/services/ts.h. +namespace ts { + +using ::TsDeviceCode; +/// Location +using ::TsLocation; +using ::TsSession; + +/// Initialize ts. +Result Initialize(void); + +/// Exit ts. +void Exit(void); + +/// Gets the Service for ts. +Service* GetServiceSession(void); + +/** + * @brief Gets the min/max temperature for the specified \ref TsLocation. + * @param[in] location \ref TsLocation + * @param[out] min_temperature Output minimum temperature in Celsius. + * @param[out] max_temperature Output maximum temperature in Celsius. + */ +Result GetTemperatureRange(TsLocation location, s32 *min_temperature, s32 *max_temperature); + +/** + * @brief Gets the temperature for the specified \ref TsLocation. + * @param[in] location \ref TsLocation + * @param[out] temperature Output temperature in Celsius. + */ +Result GetTemperature(TsLocation location, s32 *temperature); + +/** + * @brief Gets the temperature for the specified \ref TsLocation, in MilliC. [1.0.0-13.2.1] + * @param[in] location \ref TsLocation + * @param[out] temperature Output temperature in MilliC. + */ +Result GetTemperatureMilliC(TsLocation location, s32 *temperature); + +Result OpenSession(TsSession *s, u32 device_code); + +///< [8.0.0+] +Result SessionGetTemperature(TsSession *s, float *temperature); + +///< [10.0.0+] +void SessionClose(TsSession *s); + +} // namespace ts + +/// @brief C++ wrappers for the `uart` API. +/// @details Wraps: switch/services/uart.h. +namespace uart { + +/// FlowControlMode +using ::UartFlowControlMode; +/// UartPort +using ::UartPort; +/// PortEventType +using ::UartPortEventType; +/// UartPortForDev +using ::UartPortForDev; +/// PortSession +using ::UartPortSession; + +/// Initialize uart. +Result Initialize(void); + +/// Exit uart. +void Exit(void); + +/// Gets the Service object for the actual uart service session. +Service* GetServiceSession(void); + +/** + * @brief HasPort + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPort + * @param[out] out Output success flag. + */ +Result HasPort(UartPort port, bool *out); + +/** + * @brief HasPortForDev + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPortForDev + * @param[out] out Output success flag. + */ +Result HasPortForDev(UartPortForDev port, bool *out); + +/** + * @brief IsSupportedBaudRate + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPort + * @param[in] baud_rate BaudRate + * @param[out] out Output success flag. + */ +Result IsSupportedBaudRate(UartPort port, u32 baud_rate, bool *out); + +/** + * @brief IsSupportedBaudRateForDev + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPortForDev + * @param[in] baud_rate BaudRate + * @param[out] out Output success flag. + */ +Result IsSupportedBaudRateForDev(UartPortForDev port, u32 baud_rate, bool *out); + +/** + * @brief IsSupportedFlowControlMode + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPort + * @param[in] flow_control_mode \ref UartFlowControlMode + * @param[out] out Output success flag. + */ +Result IsSupportedFlowControlMode(UartPort port, UartFlowControlMode flow_control_mode, bool *out); + +/** + * @brief IsSupportedFlowControlModeForDev + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPortForDev + * @param[in] flow_control_mode \ref UartFlowControlMode + * @param[out] out Output success flag. + */ +Result IsSupportedFlowControlModeForDev(UartPortForDev port, UartFlowControlMode flow_control_mode, bool *out); + +/** + * @brief Creates an \ref UartPortSession. + * @note Use \ref uartPortSessionOpenPort or \ref uartPortSessionOpenPortForDev before using any other cmds. + * @param[out] s \ref UartPortSession + */ +Result CreatePortSession(UartPortSession *s); + +/** + * @brief IsSupportedPortEvent + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPort + * @param[in] port_event_type \ref UartPortEventType + * @param[out] out Output success flag. + */ +Result IsSupportedPortEvent(UartPort port, UartPortEventType port_event_type, bool *out); + +/** + * @brief IsSupportedPortEventForDev + * @note Only available on [1.0.0-16.1.0]. + * @param[in] port \ref UartPortForDev + * @param[in] port_event_type \ref UartPortEventType + * @param[out] out Output success flag. + */ +Result IsSupportedPortEventForDev(UartPortForDev port, UartPortEventType port_event_type, bool *out); + +/** + * @brief IsSupportedDeviceVariation + * @note Only available on [7.0.0-16.1.0]. + * @param[in] port \ref UartPort + * @param[in] device_variation DeviceVariation + * @param[out] out Output success flag. + */ +Result IsSupportedDeviceVariation(UartPort port, u32 device_variation, bool *out); + +/** + * @brief IsSupportedDeviceVariationForDev + * @note Only available on [7.0.0-16.1.0]. + * @param[in] port \ref UartPortForDev + * @param[in] device_variation DeviceVariation + * @param[out] out Output success flag. + */ +Result IsSupportedDeviceVariationForDev(UartPortForDev port, u32 device_variation, bool *out); + +/** + * @brief Close an \ref UartPortSession. + * @param s \ref UartPortSession + */ +void PortSessionClose(UartPortSession* s); + +/** + * @brief OpenPort + * @note This is not usable when the specified \ref UartPort is already being used. + * @param s \ref UartPortSession + * @param[out] out Output success flag. + * @param[in] port \ref UartPort + * @param[in] baud_rate BaudRate + * @param[in] flow_control_mode \ref UartFlowControlMode + * @param[in] device_variation [7.0.0+] DeviceVariation + * @param[in] is_invert_tx [6.0.0+] IsInvertTx + * @param[in] is_invert_rx [6.0.0+] IsInvertRx + * @param[in] is_invert_rts [6.0.0+] IsInvertRts + * @param[in] is_invert_cts [6.0.0+] IsInvertCts + * @param[in] send_buffer Send buffer, must be 0x1000-byte aligned. + * @param[in] send_buffer_length Send buffer size, must be 0x1000-byte aligned. + * @param[in] receive_buffer Receive buffer, must be 0x1000-byte aligned. + * @param[in] receive_buffer_length Receive buffer size, must be 0x1000-byte aligned. + */ +Result PortSessionOpenPort(UartPortSession* s, bool *out, UartPort port, u32 baud_rate, UartFlowControlMode flow_control_mode, u32 device_variation, bool is_invert_tx, bool is_invert_rx, bool is_invert_rts, bool is_invert_cts, void* send_buffer, u64 send_buffer_length, void* receive_buffer, u64 receive_buffer_length); + +/** + * @brief OpenPortForDev + * @note See the notes for \ref uartPortSessionOpenPort. + * @param s \ref UartPortSession + * @param[out] out Output success flag. + * @param[in] port \ref UartPortForDev + * @param[in] baud_rate BaudRate + * @param[in] flow_control_mode \ref UartFlowControlMode + * @param[in] device_variation [7.0.0+] DeviceVariation + * @param[in] is_invert_tx [6.0.0+] IsInvertTx + * @param[in] is_invert_rx [6.0.0+] IsInvertRx + * @param[in] is_invert_rts [6.0.0+] IsInvertRts + * @param[in] is_invert_cts [6.0.0+] IsInvertCts + * @param[in] send_buffer Send buffer, must be 0x1000-byte aligned. + * @param[in] send_buffer_length Send buffer size, must be 0x1000-byte aligned. + * @param[in] receive_buffer Receive buffer, must be 0x1000-byte aligned. + * @param[in] receive_buffer_length Receive buffer size, must be 0x1000-byte aligned. + */ +Result PortSessionOpenPortForDev(UartPortSession* s, bool *out, UartPortForDev port, u32 baud_rate, UartFlowControlMode flow_control_mode, u32 device_variation, bool is_invert_tx, bool is_invert_rx, bool is_invert_rts, bool is_invert_cts, void* send_buffer, u64 send_buffer_length, void* receive_buffer, u64 receive_buffer_length); + +/** + * @brief GetWritableLength + * @param s \ref UartPortSession + * @param[out] out Output WritableLength. + */ +Result PortSessionGetWritableLength(UartPortSession* s, u64 *out); + +/** + * @brief Send + * @param s \ref UartPortSession + * @param[in] in_data Input data buffer. + * @param[in] size Input data buffer size. + * @param[out] out Output size. + */ +Result PortSessionSend(UartPortSession* s, const void* in_data, size_t size, u64 *out); + +/** + * @brief GetReadableLength + * @param s \ref UartPortSession + * @param[out] out Output ReadableLength. + */ +Result PortSessionGetReadableLength(UartPortSession* s, u64 *out); + +/** + * @brief Receive + * @param s \ref UartPortSession + * @param[out] out_data Output data buffer. + * @param[in] size Output data buffer size. + * @param[out] out Output size. + */ +Result PortSessionReceive(UartPortSession* s, void* out_data, size_t size, u64 *out); + +/** + * @brief BindPortEvent + * @note The Event must be closed by the user after using \ref uartPortSessionUnbindPortEvent. + * @param s \ref UartPortSession + * @param[in] port_event_type \ref UartPortEventType + * @param[in] threshold Threshold + * @param[out] out Output success flag. + * @param[out] out_event Output Event with autoclear=false. + */ +Result PortSessionBindPortEvent(UartPortSession* s, UartPortEventType port_event_type, s64 threshold, bool *out, Event *out_event); + +/** + * @brief UnbindPortEvent + * @param s \ref UartPortSession + * @param[in] port_event_type \ref UartPortEventType + * @param[out] out Output success flag. + */ +Result PortSessionUnbindPortEvent(UartPortSession* s, UartPortEventType port_event_type, bool *out); + +} // namespace uart + +/// @brief C++ wrappers for the `uevent` API. +/// @details Wraps: switch/kernel/uevent.h. +namespace uevent { + +using ::UEvent; + +/** + * @brief Creates a user-mode event. + * @param[out] e UEvent object. + * @param[in] 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. + */ +void Create(UEvent* e, bool auto_clear); + +/** + * @brief Clears the event signal. + * @param[in] e UEvent object. + */ +void Clear(UEvent* e); + +/** + * @brief Signals the event. + * @param[in] e UEvent object. + */ +void Signal(UEvent* e); + +} // namespace uevent + +/// @brief C++ wrappers for the `usb` API. +/// @details Wraps: switch/runtime/devices/usb_comms.h, switch/services/usbds.h, switch/services/usbhs.h. +namespace usb { + +/// Imported from libusb, with changed names. +using ::usb_class_code; +/// Imported from libusb, with some adjustments. +using ::usb_config_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_control_setup; +/// Imported from libusb, with changed names. +using ::usb_descriptor_type; +/// Imported from libusb, with some adjustments. +using ::usb_device_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_endpoint_descriptor; +/// Imported from libusb, with changed names. +using ::usb_endpoint_direction; +/// Imported from libusb, with some adjustments. +using ::usb_hid_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_interface_association_descriptor; +/// Imported from libusb, with some adjustments. +using ::usb_interface_descriptor; +/// Imported from libusb, with changed names. +using ::usb_iso_sync_type; +/// Imported from libusb, with changed names. +using ::usb_iso_usage_type; +/// Imported from libusb, with changed names. +using ::usb_request_recipient; +/// Imported from libusb, with changed names. +using ::usb_request_type; +/// Imported from libusb, with some adjustments. +using ::usb_ss_endpoint_companion_descriptor; +/// Imported from libusb, with changed names. +using ::usb_standard_request; +/// Imported from libusb, with some adjustments. +using ::usb_string_descriptor; +/// Imported from libusb, with changed names. +using ::usb_transfer_type; +using ::UsbCommsInterfaceInfo; +using ::UsbComplexId; +using ::UsbDeviceSpeed; +using ::UsbDsDeviceInfo; +using ::UsbDsEndpoint; +using ::UsbDsInterface; +using ::UsbDsReportData; +using ::UsbDsReportEntry; +using ::UsbHsClientEpSession; +/// The interface service object. These Events have autoclear=false. +using ::UsbHsClientIfSession; +/// Interface struct. Note that devices have a seperate \ref UsbHsInterface for each interface. +using ::UsbHsInterface; +/// Interface filtering struct. When the associated flag bit is set, the associated descriptor field and struct field are compared, on mismatch the interface is filtered out. +/// [7.0.0+]: The filter struct has to be unique, it can't be used by anything else (including other processes). Hence, Flags has to be non-zero. When initialized with usb:hs:a and VID and/or PID filtering is enabled, the VID/PID will be checked against a blacklist. +using ::UsbHsInterfaceFilter; +using ::UsbHsInterfaceFilterFlags; +/// Descriptors which are not available are set to all-zero. +/// The INPUT/OUTPUT endpoint descriptors were swapped with [8.0.0+], libnx converts this struct to the newer layout when running on pre-8.0.0. +using ::UsbHsInterfaceInfo; +using ::UsbHsRingHeader; +using ::UsbHsXferReport; +/// USB Device States, per USB 2.0 spec +using ::UsbState; + +/// Initializes usbComms with the default number of interfaces (1) +Result CommsInitialize(void); + +/// Initializes usbComms with a specific number of interfaces. +Result CommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos, u16 idVendor, u16 idProduct); + +/// Exits usbComms. +void CommsExit(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 CommsSetErrorHandling(bool flag); + +/// Read data with the default interface. +size_t CommsRead(void* buffer, size_t size); + +/// Write data with the default interface. +size_t CommsWrite(const void* buffer, size_t size); + +/// Same as usbCommsRead except with the specified interface. +size_t CommsReadEx(void* buffer, size_t size, u32 interface); + +/// Same as usbCommsWrite except with the specified interface. +size_t CommsWriteEx(const void* buffer, size_t size, u32 interface); + +/// Retrieve event used for read completion with the given interface. +Event * CommsGetReadCompletionEvent(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 CommsReadAsync(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 CommsGetReadResult(u32 urbId, u32 *transferredSize, u32 interface); + +/// Retrieve event used for write completion with the given interface. +Event * CommsGetWriteCompletionEvent(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 CommsWriteAsync(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 CommsGetWriteResult(u32 urbId, u32 *transferredSize, u32 interface); + +/// Opens a session with usb:ds. +Result DsInitialize(void); + +/// Closes the usb:ds session. Any interfaces/endpoints which are left open are automatically closed, since otherwise usb-sysmodule won't fully reset usb:ds to defaults. +void DsExit(void); + +/// Gets the Service object for the actual usb:ds service session. +Service* DsGetServiceSession(void); + +/// Helper func. +Result DsWaitReady(u64 timeout); + +/// Helper func. +Result DsParseReportData(UsbDsReportData *reportdata, u32 urbId, u32 *requestedSize, u32 *transferredSize); + +Event* DsGetStateChangeEvent(void); + +/// Gets the device state. See \ref UsbState. +Result DsGetState(UsbState* out); + +/// Removed in [5.0.0+]. +Result DsGetDsInterface(UsbDsInterface** out, struct usb_interface_descriptor* descriptor, const char* interface_name); + +/// Removed in [5.0.0+]. +Result DsSetVidPidBcd(const UsbDsDeviceInfo* deviceinfo); + +/// Only available on [5.0.0+]. +Result DsRegisterInterface(UsbDsInterface** out); + +/// Only available on [5.0.0+]. +Result DsRegisterInterfaceEx(UsbDsInterface** out, u8 intf_num); + +/// Only available on [5.0.0+]. +Result DsClearDeviceData(void); + +/// Only available on [5.0.0+]. +Result DsAddUsbStringDescriptor(u8* out_index, const char* string); + +/// Only available on [5.0.0+]. +Result DsAddUsbLanguageStringDescriptor(u8* out_index, const u16* lang_ids, u16 num_langs); + +/// Only available on [5.0.0+]. +Result DsDeleteUsbStringDescriptor(u8 index); + +/// Only available on [5.0.0+]. +Result DsSetUsbDeviceDescriptor(UsbDeviceSpeed speed, struct usb_device_descriptor* descriptor); + +/// Only available on [5.0.0+]. +Result DsSetBinaryObjectStore(const void* bos, size_t bos_size); + +/// Only available on [5.0.0+]. +Result DsEnable(void); + +/// Only available on [5.0.0+]. +Result DsDisable(void); + +/// Only available on [8.0.0+]. +Result DsGetSpeed(UsbDeviceSpeed *out); + +void DsInterface_Close(UsbDsInterface* interface); + +Result DsInterface_GetSetupPacket(UsbDsInterface* interface, void* buffer, size_t size); + +Result DsInterface_EnableInterface(UsbDsInterface* interface); + +Result DsInterface_DisableInterface(UsbDsInterface* interface); + +Result DsInterface_CtrlInPostBufferAsync(UsbDsInterface* interface, void* buffer, size_t size, u32* urbId); + +Result DsInterface_CtrlOutPostBufferAsync(UsbDsInterface* interface, void* buffer, size_t size, u32* urbId); + +Result DsInterface_GetCtrlInReportData(UsbDsInterface* interface, UsbDsReportData* out); + +Result DsInterface_GetCtrlOutReportData(UsbDsInterface* interface, UsbDsReportData* out); + +Result DsInterface_StallCtrl(UsbDsInterface* interface); + +/// Removed in [5.0.0+]. +Result DsInterface_GetDsEndpoint(UsbDsInterface* interface, UsbDsEndpoint** endpoint, struct usb_endpoint_descriptor* descriptor); + +/// Only available on [5.0.0+]. +Result DsInterface_RegisterEndpoint(UsbDsInterface* interface, UsbDsEndpoint** endpoint, u8 endpoint_address); + +/// Only available on [5.0.0+]. +Result DsInterface_AppendConfigurationData(UsbDsInterface* interface, UsbDeviceSpeed speed, const void* buffer, size_t size); + +void DsEndpoint_Close(UsbDsEndpoint* endpoint); + +Result DsEndpoint_Cancel(UsbDsEndpoint* endpoint); + +Result DsEndpoint_PostBufferAsync(UsbDsEndpoint* endpoint, void* buffer, size_t size, u32* urbId); + +Result DsEndpoint_GetReportData(UsbDsEndpoint* endpoint, UsbDsReportData* out); + +Result DsEndpoint_Stall(UsbDsEndpoint* endpoint); + +Result DsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt); + +/// Initialize usb:hs. +Result HsInitialize(void); + +/// Exit usb:hs. +void HsExit(void); + +/// Gets the Service object for the actual usb:hs service session. +Service* HsGetServiceSession(void); + +/// Returns the Event loaded during init with autoclear=false. +/// Signaled when a device was removed. +/// When signaled, the user should use \ref usbHsQueryAcquiredInterfaces and cleanup state for all interfaces which are not listed in the output interfaces (none of the IDs match \ref usbHsIfGetID output). +Event* HsGetInterfaceStateChangeEvent(void); + +/** + * @brief Returns an array of all \ref UsbHsInterface. Internally this loads the same interfaces as \ref usbHsQueryAvailableInterfaces, followed by \ref usbHsQueryAcquiredInterfaces. However, ID in \ref UsbHsInterface is set to -1, hence the output from this should not be used with \ref usbHsAcquireUsbIf. + * @param[in] filter \ref UsbHsInterfaceFilter. + * @param[out] interfaces Array of output interfaces. + * @param[in] interfaces_maxsize Max byte-size of the interfaces buffer. + * @param[out] total_entries Total number of output interfaces. + */ +Result HsQueryAllInterfaces(const UsbHsInterfaceFilter* filter, UsbHsInterface* interfaces, size_t interfaces_maxsize, s32* total_entries); + +/** + * @brief Returns an array of \ref UsbHsInterface which are available. + * @param[in] filter \ref UsbHsInterfaceFilter. + * @param[out] interfaces Array of output interfaces. + * @param[in] interfaces_maxsize Max byte-size of the interfaces buffer. + * @param[out] total_entries Total number of output interfaces. + */ +Result HsQueryAvailableInterfaces(const UsbHsInterfaceFilter* filter, UsbHsInterface* interfaces, size_t interfaces_maxsize, s32* total_entries); + +/** + * @brief Returns an array of \ref UsbHsInterface which were previously acquired. + * @param[out] interfaces Array of output interfaces. + * @param[in] interfaces_maxsize Max byte-size of the interfaces buffer. + * @param[out] total_entries Total number of output interfaces. + */ +Result HsQueryAcquiredInterfaces(UsbHsInterface* interfaces, size_t interfaces_maxsize, s32* total_entries); + +/** + * @brief Creates an event which is signaled when an interface is available which passes the filtering checks. + * @param[out] out_event Event object. + * @param[in] autoclear Event autoclear. + * @param[in] index Event index, must be 0..2. + * @param[in] filter \ref UsbHsInterfaceFilter. + */ +Result HsCreateInterfaceAvailableEvent(Event* out_event, bool autoclear, u8 index, const UsbHsInterfaceFilter* filter); + +/** + * @brief Destroys an event setup by \ref usbHsCreateInterfaceAvailableEvent. This *must* be used at some point during cleanup. + * @param[in] event Event object to close. + * @param[in] index Event index, must be 0..2. + */ +Result HsDestroyInterfaceAvailableEvent(Event* event, u8 index); + +/** + * @brief Acquires/opens the specified interface. This returns an error if the interface was already acquired by another process. + * @param[in] s The service object. + * @param[in] interface Interface to use. + */ +Result HsAcquireUsbIf(UsbHsClientIfSession* s, UsbHsInterface *interface); + +/// UsbHsClientIfSession +/// Closes the specified interface session. +void HsIfClose(UsbHsClientIfSession* s); + +/// Returns whether the specified interface session was initialized. +bool HsIfIsActive(UsbHsClientIfSession* s); + +/// Returns the ID which can be used for comparing with the ID in the output interfaces from \ref usbHsQueryAcquiredInterfaces. +s32 HsIfGetID(UsbHsClientIfSession* s); + +/** + * @brief Selects an interface. + * @param[in] s The service object. + * @param[out] inf The output interface info. If NULL, the output is stored within s instead. + * @param[in] id ID + */ +Result HsIfSetInterface(UsbHsClientIfSession* s, UsbHsInterfaceInfo* inf, u8 id); + +/** + * @brief Gets an interface. + * @param[in] s The service object. + * @param[out] inf The output interface info. If NULL, the output is stored within s instead. + */ +Result HsIfGetInterface(UsbHsClientIfSession* s, UsbHsInterfaceInfo* inf); + +/** + * @brief Gets an alternate interface. + * @param[in] s The service object. + * @param[out] inf The output interface info. If NULL, the output is stored within s instead. + * @param[in] id ID + */ +Result HsIfGetAlternateInterface(UsbHsClientIfSession* s, UsbHsInterfaceInfo* inf, u8 id); + +/// On [1.0.0] this is stubbed, just returns 0 with out=0. +Result HsIfGetCurrentFrame(UsbHsClientIfSession* s, u32* out); + +/// Uses a control transfer, this will block until the transfer finishes. The buffer address and size should be aligned to 0x1000-bytes, where wLength is the original size. +Result HsIfCtrlXfer(UsbHsClientIfSession* s, u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, void* buffer, u32* transferredSize); + +/** + * @brief Opens an endpoint. maxUrbCount*maxXferSize must be non-zero. + * @param[in] s The interface object. + * @param[out] ep The endpoint object. + * @param[in] maxUrbCount maxUrbCount, must be <0x11. + * @param[in] maxXferSize Max transfer size for a packet. This can be desc->wMaxPacketSize. Must be <=0xFF0000. + * @param[in] desc Endpoint descriptor. + */ +Result HsIfOpenUsbEp(UsbHsClientIfSession* s, UsbHsClientEpSession* ep, u16 maxUrbCount, u32 maxXferSize, struct usb_endpoint_descriptor *desc); + +/// Resets the device: has the same affect as unplugging the device and plugging it back in. +Result HsIfResetDevice(UsbHsClientIfSession* s); + +/// UsbHsClientEpSession +/// Closes the specified endpoint session. +void HsEpClose(UsbHsClientEpSession* s); + +/// Gets the Xfer Event which is signaled when PostBufferAsync finishes. This is only valid for [2.0.0+]. If using \ref eventWait with this, then \ref eventClear should be used if the event was signaled (since the autoclear is false). +Event* HsEpGetXferEvent(UsbHsClientEpSession* s); + +/// Gets the buffer size to use with \ref usbHsEpShareReportRing. +u32 HsEpGetReportRingSize(UsbHsClientEpSession* s); + +/** + * @brief Starts an async data transfer with the specified endpoint. The Event from \ref usbHsEpGetXferEvent can be used to determine when the transfer finished. If you don't need async, \ref usbHsEpPostBuffer can be used instead. + * @note Only available on [2.0.0+]. + * @param[in] s The endpoint object. + * @param buffer Data buffer. The buffer address and size should be aligned to 0x1000-bytes. + * @param[in] size The actual data size. + * @param[in] id This is an arbitrary value which will be later returned in \ref UsbHsXferReport. For example a value starting at 0 can be used, then if sending multiple requests at once this value can be incremented each time (with 0 for the first request in this set of requests). + * @param[out] xferId Output xferId. + */ +Result HsEpPostBufferAsync(UsbHsClientEpSession* s, void* buffer, u32 size, u64 id, u32* xferId); + +/** + * @brief Gets an array of \ref UsbHsXferReport for the specified endpoint. This should be used after waiting on the Event from \ref usbHsEpGetXferEvent. + * @note Only available on [2.0.0+]. + * @param[in] s The endpoint object. + * @param[out] reports Output array of \ref UsbHsXferReport. + * @param[in] max_reports Size of the reports array in entries. + * @param[out] count Number of entries written to the array. + */ +Result HsEpGetXferReport(UsbHsClientEpSession* s, UsbHsXferReport* reports, u32 max_reports, u32* count); + +/** + * @brief Uses a data transfer with the specified endpoint, this will block until the transfer finishes. This wraps \ref usbHsEpPostBufferAsync and \ref usbHsEpGetXferReport, and also handles the Event (on pre-2.0.0 this handles using the relevant cmds instead). If async is needed, use \ref usbHsEpPostBufferAsync instead. + * @param[in] s The endpoint object. + * @param buffer Data buffer. The buffer address and size should be aligned to 0x1000-bytes. + * @param[in] size The actual data size. + * @param[out] transferredSize Output transferred size. + */ +Result HsEpPostBuffer(UsbHsClientEpSession* s, void* buffer, u32 size, u32* transferredSize); + +/** + * @brief This uses the same functionality internally as \ref usbHsEpPostBufferAsync except the urbs array and unk1/unk2 are specified by the user instead. + * @note Only available on [2.0.0+]. + * @param[in] s The endpoint object. + * @param buffer Data buffer. The buffer address and size should be aligned to 0x1000-bytes. + * @param[in] urbs Input array of u32s for the size of each urb. + * @param[in] urbCount Total entries in the urbs array. + * @param[in] id Same as \ref usbHsEpPostBufferAsync. + * @param[in] unk1 \ref usbHsEpPostBufferAsync would internally pass value 0 here. + * @param[in] unk2 \ref usbHsEpPostBufferAsync would internally pass value 0 here. + * @param[out] xferId Output xferId. + */ +Result HsEpBatchBufferAsync(UsbHsClientEpSession* s, void* buffer, u32* urbs, u32 urbCount, u64 id, u32 unk1, u32 unk2, u32* xferId); + +/** + * @brief This can be used to map the specified buffer as devicemem, which can then be used with \ref usbHsEpPostBufferAsync / \ref usbHsEpPostBuffer / \ref usbHsEpBatchBufferAsync. If the buffer address passed to those funcs is within this SmmuSpace, the specified buffer must be within the bounds of the SmmuSpace buffer. + * @note Only available on [4.0.0+]. + * @note A buffer from usbHsEpCreateSmmuSpace can't be reused by another endpoint with the aforementioned funcs. + * @note This can only be used once per UsbHsClientEpSession object. + * @param[in] s The endpoint object. + * @param buffer Buffer address, this must be aligned to 0x1000-bytes. + * @param[in] size Buffer size, this must be aligned to 0x1000-bytes. + */ +Result HsEpCreateSmmuSpace(UsbHsClientEpSession* s, void* buffer, u32 size); + +/** + * @brief This creates TransferMemory which is used to read \ref UsbHsXferReport when \ref usbHsEpGetXferReport is used, instead of using the service cmd. + * @note Only available on [4.0.0+]. + * @param buffer Buffer, must be 0x1000-byte aligned. + * @param[in] size Buffer size, \ref usbHsEpGetReportRingSize can be used to calculate this. + */ +Result HsEpShareReportRing(UsbHsClientEpSession* s, void* buffer, size_t size); + +} // namespace usb + +/// @brief C++ wrappers for the `utf` API. +/// @details Wraps: switch/runtime/util/utf.h. +namespace utf { + +/** Convert a UTF-8 sequence into a UTF-32 codepoint + * + * @param[out] out Output codepoint + * @param[in] in Input sequence + * + * @returns number of input code units consumed + * @returns -1 for error + */ +ssize_t DecodeUtf8(uint32_t *out, const uint8_t *in); + +/** Convert a UTF-16 sequence into a UTF-32 codepoint + * + * @param[out] out Output codepoint + * @param[in] in Input sequence + * + * @returns number of input code units consumed + * @returns -1 for error + */ +ssize_t DecodeUtf16(uint32_t *out, const uint16_t *in); + +/** Convert a UTF-32 codepoint into a UTF-8 sequence + * + * @param[out] out Output sequence + * @param[in] in Input codepoint + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out must be able to store 4 code units + */ +ssize_t EncodeUtf8(uint8_t *out, uint32_t in); + +/** Convert a UTF-32 codepoint into a UTF-16 sequence + * + * @param[out] out Output sequence + * @param[in] in Input codepoint + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out must be able to store 2 code units + */ +ssize_t EncodeUtf16(uint16_t *out, uint32_t in); + +/** Convert a UTF-8 sequence into a UTF-16 sequence + * + * Fills the output buffer up to \a len code units. + * Returns the number of code units that the input would produce; + * if it returns greater than \a len, the output has been + * truncated. + * + * @param[out] out Output sequence + * @param[in] in Input sequence (null-terminated) + * @param[in] len Output length + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out is not null-terminated + */ +ssize_t Utf8ToUtf16(uint16_t *out, const uint8_t *in, size_t len); + +/** Convert a UTF-8 sequence into a UTF-32 sequence + * + * Fills the output buffer up to \a len code units. + * Returns the number of code units that the input would produce; + * if it returns greater than \a len, the output has been + * truncated. + * + * @param[out] out Output sequence + * @param[in] in Input sequence (null-terminated) + * @param[in] len Output length + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out is not null-terminated + */ +ssize_t Utf8ToUtf32(uint32_t *out, const uint8_t *in, size_t len); + +/** Convert a UTF-16 sequence into a UTF-8 sequence + * + * Fills the output buffer up to \a len code units. + * Returns the number of code units that the input would produce; + * if it returns greater than \a len, the output has been + * truncated. + * + * @param[out] out Output sequence + * @param[in] in Input sequence (null-terminated) + * @param[in] len Output length + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out is not null-terminated + */ +ssize_t Utf16ToUtf8(uint8_t *out, const uint16_t *in, size_t len); + +/** Convert a UTF-16 sequence into a UTF-32 sequence + * + * Fills the output buffer up to \a len code units. + * Returns the number of code units that the input would produce; + * if it returns greater than \a len, the output has been + * truncated. + * + * @param[out] out Output sequence + * @param[in] in Input sequence (null-terminated) + * @param[in] len Output length + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out is not null-terminated + */ +ssize_t Utf16ToUtf32(uint32_t *out, const uint16_t *in, size_t len); + +/** Convert a UTF-32 sequence into a UTF-8 sequence + * + * Fills the output buffer up to \a len code units. + * Returns the number of code units that the input would produce; + * if it returns greater than \a len, the output has been + * truncated. + * + * @param[out] out Output sequence + * @param[in] in Input sequence (null-terminated) + * @param[in] len Output length + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out is not null-terminated + */ +ssize_t Utf32ToUtf8(uint8_t *out, const uint32_t *in, size_t len); + +/** Convert a UTF-32 sequence into a UTF-16 sequence + * + * @param[out] out Output sequence + * @param[in] in Input sequence (null-terminated) + * @param[in] len Output length + * + * @returns number of output code units produced + * @returns -1 for error + * + * @note \a out is not null-terminated + */ +ssize_t Utf32ToUtf16(uint16_t *out, const uint32_t *in, size_t len); + +} // namespace utf + +/// @brief C++ wrappers for the `utimer` API. +/// @details Wraps: switch/kernel/utimer.h. +namespace utimer { + +/// Valid types for a user-mode timer. +using ::TimerType; +using ::UTimer; + +/** + * @brief Creates a user-mode timer. + * @param[out] t UTimer object. + * @param[in] interval Interval (in nanoseconds). + * @param[in] type Type of timer to create (see \ref TimerType). + * @note The timer is stopped when it is created. Use \ref utimerStart to start it. + * @note It is safe to wait on this timer 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. + * @note For a repeating timer: If the timer triggers twice before you wait on it, you will only get one signal. + */ +void Create(UTimer* t, u64 interval, TimerType type); + +/** + * @brief Starts the timer. + * @param[in] t UTimer object. + */ +void Start(UTimer* t); + +/** + * @brief Stops the timer. + * @param[in] t UTimer object. + */ +void Stop(UTimer* t); + +} // namespace utimer + +/// @brief C++ wrappers for the `vi` API. +/// @details Wraps: switch/services/vi.h. +namespace vi { + +/// Used as argument for certain drawing commands. +using ::ViColorRgba4444; +using ::ViColorRgba8888; +using ::ViDisplay; +using ::ViDisplayName; +using ::ViLayer; +/// Used by viCreateLayer when CreateStrayLayer is used internally. +using ::ViLayerFlags; +/// Used as argument to many capture functions. +using ::ViLayerStack; +/// Used with viSetDisplayPowerState. +using ::ViPowerState; +/// Used with viSetLayerScalingMode. +using ::ViScalingMode; +using ::ViServiceType; + +Result Initialize(ViServiceType service_type); + +void Exit(void); + +Service* GetSession_IApplicationDisplayService(void); + +Service* GetSession_IHOSBinderDriverRelay(void); + +Service* GetSession_ISystemDisplayService(void); + +Service* GetSession_IManagerDisplayService(void); + +Service* GetSession_IHOSBinderDriverIndirect(void); + +Result SetContentVisibility(bool v); + +Result OpenDisplay(const char *display_name, ViDisplay *display); + +Result CloseDisplay(ViDisplay *display); + +Result OpenDefaultDisplay(ViDisplay *display); + +Result GetDisplayResolution(ViDisplay *display, s32 *width, s32 *height); + +Result GetDisplayLogicalResolution(ViDisplay *display, s32 *width, s32 *height); + +/// Only available on [3.0.0+]. +Result SetDisplayMagnification(ViDisplay *display, s32 x, s32 y, s32 width, s32 height); + +Result GetDisplayVsyncEvent(ViDisplay *display, Event *event_out); + +Result SetDisplayPowerState(ViDisplay *display, ViPowerState state); + +Result SetDisplayAlpha(ViDisplay *display, float alpha); + +Result GetZOrderCountMin(ViDisplay *display, s32 *z); + +Result GetZOrderCountMax(ViDisplay *display, s32 *z); + +Result CreateLayer(const ViDisplay *display, ViLayer *layer); + +Result CreateManagedLayer(const ViDisplay *display, ViLayerFlags layer_flags, u64 aruid, u64 *layer_id); + +Result SetLayerSize(ViLayer *layer, s32 width, s32 height); + +Result SetLayerZ(ViLayer *layer, s32 z); + +Result SetLayerPosition(ViLayer *layer, float x, float y); + +Result CloseLayer(ViLayer *layer); + +Result DestroyManagedLayer(ViLayer *layer); + +Result SetLayerScalingMode(ViLayer *layer, ViScalingMode scaling_mode); + +Result GetIndirectLayerImageMap(void* buffer, size_t size, s32 width, s32 height, u64 IndirectLayerConsumerHandle, u64 *out_size, u64 *out_stride); + +Result GetIndirectLayerImageRequiredMemoryInfo(s32 width, s32 height, u64 *out_size, u64 *out_alignment); + +Result ManagerPrepareFatal(void); + +///< [16.0.0+] +Result ManagerShowFatal(void); + +///< [16.0.0+] +Result ManagerDrawFatalRectangle(s32 x, s32 y, s32 end_x, s32 end_y, ViColorRgba4444 color); + +///< [16.0.0+] +Result ManagerDrawFatalText32(s32 *out_advance, s32 x, s32 y, const u32 *utf32_codepoints, size_t num_codepoints, float scale_x, float scale_y, PlSharedFontType font_type, ViColorRgba8888 bg_color, ViColorRgba8888 fg_color, s32 initial_advance); + +} // namespace vi + +/// @brief C++ wrappers for the `virtmem` API. +/// @details Wraps: switch/kernel/virtmem.h. +namespace virtmem { + +/// Address space reservation type (see \ref virtmemAddReservation) +using ::VirtmemReservation; + +/// Locks the virtual memory manager mutex. +void Lock(void); + +/// Unlocks the virtual memory manager mutex. +void Unlock(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). + * @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* FindAslr(size_t size, size_t guard_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* FindStack(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* FindCodeMemory(size_t size, size_t guard_size); + +/** + * @brief Reserves a range of memory address space. + * @param mem Pointer to the address space 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* AddReservation(void* mem, 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). + */ +void RemoveReservation(VirtmemReservation* rv); + +} // namespace virtmem + +/// @brief C++ wrappers for the `wait` API. +/// @details Wraps: switch/kernel/wait.h. +namespace wait { + +using ::Waitable; +using ::WaitableMethods; +using ::WaitableNode; +/// Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user-mode. +using ::Waiter; +using ::WaiterType; + +/** + * @brief Waits for an arbitrary number of generic waitable synchronization objects, optionally with a timeout. + * @param[out] idx_out Variable that will received the index of the signalled object. + * @param[in] objects Array containing \ref Waiter structures. + * @param[in] num_objects Number of objects in the array. + * @param[in] timeout Timeout (in nanoseconds). + * @return Result code. + * @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. + */ +Result Objects(s32* idx_out, const Waiter* objects, s32 num_objects, u64 timeout); + +/** + * @brief Waits for an arbitrary number of kernel synchronization objects, optionally with a timeout. This function replaces \ref svcWaitSynchronization. + * @param[out] idx_out Variable that will received the index of the signalled object. + * @param[in] handles Array containing handles. + * @param[in] num_handles Number of handles in the array. + * @param[in] timeout Timeout (in nanoseconds). + * @return Result code. + * @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. + */ +Result Handles(s32* idx_out, const Handle* handles, s32 num_handles, u64 timeout); + +/** + * @brief Waits on a single generic waitable synchronization object, optionally with a timeout. + * @param[in] w \ref Waiter structure. + * @param[in] timeout Timeout (in nanoseconds). + */ +Result Single(Waiter w, u64 timeout); + +/** + * @brief Waits for a single kernel synchronization object, optionally with a timeout. + * @param[in] h \ref Handle of the object. + * @param[in] timeout Timeout (in nanoseconds). + */ +Result SingleHandle(Handle h, u64 timeout); + +} // namespace wait + +/// @brief C++ wrappers for the `waiter` API. +/// @details Wraps: switch/kernel/event.h, switch/kernel/thread.h, switch/kernel/uevent.h, switch/kernel/utimer.h, switch/kernel/wait.h. +namespace waiter { + +/// Kernel-mode event structure. +using ::Event; +/// Thread information structure. +using ::Thread; +/// Valid types for a user-mode timer. +using ::TimerType; +using ::UEvent; +using ::UTimer; +using ::Waitable; +using ::WaitableMethods; +using ::WaitableNode; +/// Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user-mode. +using ::Waiter; +using ::WaiterType; + +/// Creates a \ref Waiter for a kernel-mode event. +Waiter ForEvent(Event* t); + +/// Creates a \ref Waiter for a \ref Thread. +Waiter ForThread(Thread* t); + +/// Creates a waiter for a user-mode event. +Waiter ForUEvent(UEvent* e); + +/// Creates a waiter for a user-mode timer. +Waiter ForUTimer(UTimer* t); + +/// Creates a \ref Waiter for a kernel-mode \ref Handle. +Waiter ForHandle(Handle h); + +} // namespace waiter + +/// @brief C++ wrappers for the `web` API. +/// @details Wraps: switch/applets/web.h. +namespace web { + +/// Header struct at offset 0 in the web Arg storage (non-webWifi). +using ::WebArgHeader; +/// Web TLV used in the web Arg storage. +using ::WebArgTLV; +/// Types for \ref WebArgTLV, input storage. +using ::WebArgType; +/// 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. +using ::WebBackgroundKind; +/// 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. +using ::WebBootDisplayKind; +/// Entry data for ::WebArgType_BootFooterButton. +using ::WebBootFooterButtonEntry; +/// Config struct for web applets, non-WebWifi. +using ::WebCommonConfig; +/// Common container struct for applets' reply data, from the output storage. +using ::WebCommonReply; +/// Common struct for the applet output storage, for non-TLV-storage. +using ::WebCommonReturnValue; +/// TLV storage, starts with \ref WebArgHeader followed by \ref WebArgTLV entries. +using ::WebCommonTLVStorage; +/// This controls the kind of content to mount with Offline-applet. +using ::WebDocumentKind; +/// ExitReason +using ::WebExitReason; +/// Button values for \ref webConfigSetBootFooterButtonVisible. +using ::WebFooterButtonId; +/// Kind values for \ref webConfigSetFooterFixedKind. Controls UI footer display behaviour. +using ::WebFooterFixedKind; +/// 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). +using ::WebLeftStickMode; +/// Types for \ref WebArgTLV, output storage. +using ::WebReplyType; +/// WebSession +using ::WebSession; +/// WebSessionBootMode +using ::WebSessionBootMode; +/// SessionMessageHeader +using ::WebSessionMessageHeader; +/// WebSessionReceiveMessageKind +using ::WebSessionReceiveMessageKind; +/// WebSessionSendMessageKind +using ::WebSessionSendMessageKind; +/// StorageHandleQueue +using ::WebSessionStorageHandleQueue; +/// This controls the initial page for ShareApplet, used by \ref webShareCreate. +using ::WebShareStartPage; +/// This indicates the type of web-applet. +using ::WebShimKind; +/// Config for WebWifi. +using ::WebWifiConfig; +/// Struct for the WebWifi applet input storage. +using ::WebWifiPageArg; +/// Struct for the WebWifi applet output storage. +using ::WebWifiReturnValue; + +/** + * @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 WifiCreate(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 WifiShow(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 PageCreate(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 NewsCreate(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 YouTubeVideoCreate(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 OfflineCreate(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 ShareCreate(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 LobbyCreate(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 ConfigSetCallbackUrl(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 ConfigSetCallbackableUrl(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 ConfigSetWhitelist(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 ConfigSetUid(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 ConfigSetAlbumEntry(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 ConfigSetScreenShot(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 ConfigSetEcClientCert(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 ConfigSetPlayReport(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 ConfigSetBootDisplayKind(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 ConfigSetBackgroundKind(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 ConfigSetFooter(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 ConfigSetPointer(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 ConfigSetLeftStickMode(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 ConfigSetKeyRepeatFrame(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 ConfigSetDisplayUrlKind(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 ConfigSetBootAsMediaPlayer(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 ConfigSetShopJump(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 ConfigSetMediaPlayerUserGestureRestriction(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 ConfigSetMediaAutoPlay(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 ConfigSetLobbyParameter(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 ConfigSetApplicationAlbumEntry(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 ConfigSetJsExtension(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 ConfigSetAdditionalCommentText(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 ConfigSetTouchEnabledOnContents(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 ConfigSetUserAgentAdditionalString(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 ConfigSetAdditionalMediaData(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 ConfigSetMediaPlayerAutoClose(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 ConfigSetPageCache(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 ConfigSetWebAudio(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 ConfigSetFooterFixedKind(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 ConfigSetPageFade(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 ConfigSetMediaCreatorApplicationRatingAge(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 ConfigSetBootLoadingIcon(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 ConfigSetPageScrollIndicator(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 ConfigSetMediaPlayerSpeedControl(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 ConfigAddAlbumEntryAndMediaData(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 ConfigSetBootFooterButtonVisible(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 ConfigSetOverrideWebAudioVolume(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 ConfigSetOverrideMediaAudioVolume(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 ConfigSetBootMode(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 ConfigSetMediaPlayerUi(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 ConfigSetTransferMemory(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 ConfigShow(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 ConfigRequestExit(WebCommonConfig* config); + +/** + * @brief Gets the ExitReason from the specified reply. + * @param reply WebCommonReply object. + * @param exitReason Output \ref WebExitReason + */ +Result ReplyGetExitReason(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 ReplyGetLastUrl(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 ReplyGetSharePostResult(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 ReplyGetPostServiceName(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 ReplyGetPostId(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 ReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag); + +/** + * @brief Creates a \ref WebSession object. + * @param s \ref WebSession + * @param config WebCommonConfig object. + */ +void SessionCreate(WebSession *s, WebCommonConfig* config); + +/** + * @brief Closes a \ref WebSession object. + * @param s \ref WebSession + */ +void SessionClose(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 SessionStart(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 SessionWaitForExit(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 SessionRequestExit(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 SessionAppear(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 SessionTrySendContentMessage(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 SessionTryReceiveContentMessage(WebSession *s, char *content, u64 size, u64 *out_size, bool *flag); + +} // namespace web + +/// @brief C++ wrappers for the `wlaninf` API. +/// @details Wraps: switch/services/wlaninf.h. +namespace wlaninf { + +/// WLAN State. +using ::WlanInfState; + +/// [1.0.0-14.1.2] Initialize wlan:inf. +Result Initialize(void); + +/// Exit wlan:inf. +void Exit(void); + +/// Gets the Service object for the actual wlan:inf service session. +Service* GetServiceSession(void); + +/// Gets \ref WlanInfState. +Result GetState(WlanInfState* out); + +/// Value goes from -30 (really good signal) to -90 (barely enough to stay connected) +/// on a logarithmic scale +Result GetRSSI(s32* out); + +} // namespace wlaninf + +} // namespace nx + +} // extern "C++" (linkage guard, do not remove) diff --git a/Source/hoc-clk/common/src/switch.cpp b/Source/hoc-clk/common/src/switch.cpp new file mode 100644 index 00000000..f1884e97 --- /dev/null +++ b/Source/hoc-clk/common/src/switch.cpp @@ -0,0 +1,4804 @@ +/** + * @file switch.hpp + * @brief Libnx C++ bindings (AUTO-GENERATED, do not edit). + * @copyright libnx Authors + */ +#include "switch.hpp" + +namespace nx { + +const char *CppBindingsVersion() { + return "libnx C++ bindings v1.0.0 (libnx feebd026)"; +} + +namespace account { + +Result Initialize(AccountServiceType service_type) { return ::accountInitialize(service_type); } +void Exit(void) { ::accountExit(); } +Service* GetServiceSession(void) { return ::accountGetServiceSession(); } +Result GetUserCount(s32* user_count) { return ::accountGetUserCount(user_count); } +Result ListAllUsers(AccountUid* uids, s32 max_uids, s32 *actual_total) { return ::accountListAllUsers(uids, max_uids, actual_total); } +Result GetLastOpenedUser(AccountUid *uid) { return ::accountGetLastOpenedUser(uid); } +Result GetProfile(AccountProfile* out, AccountUid uid) { return ::accountGetProfile(out, uid); } +Result IsUserRegistrationRequestPermitted(bool *out) { return ::accountIsUserRegistrationRequestPermitted(out); } +Result TrySelectUserWithoutInteraction(AccountUid *uid, bool is_network_service_account_required) { return ::accountTrySelectUserWithoutInteraction(uid, is_network_service_account_required); } +void ProfileClose(AccountProfile* profile) { ::accountProfileClose(profile); } +Result ProfileGet(AccountProfile* profile, AccountUserData* userdata, AccountProfileBase* profilebase) { return ::accountProfileGet(profile, userdata, profilebase); } +Result ProfileGetImageSize(AccountProfile* profile, u32* image_size) { return ::accountProfileGetImageSize(profile, image_size); } +Result ProfileLoadImage(AccountProfile* profile, void* buf, size_t len, u32* image_size) { return ::accountProfileLoadImage(profile, buf, len, image_size); } +Result GetPreselectedUser(AccountUid *uid) { return ::accountGetPreselectedUser(uid); } +bool UidIsValid(const AccountUid *Uid) { return ::accountUidIsValid(Uid); } + +} // namespace account + +namespace aes128 { + +void ContextCreate(Aes128Context *out, const void *key, bool is_encryptor) { ::aes128ContextCreate(out, key, is_encryptor); } +void EncryptBlock(const Aes128Context *ctx, void *dst, const void *src) { ::aes128EncryptBlock(ctx, dst, src); } +void DecryptBlock(const Aes128Context *ctx, void *dst, const void *src) { ::aes128DecryptBlock(ctx, dst, src); } +void CbcContextCreate(Aes128CbcContext *out, const void *key, const void *iv, bool is_encryptor) { ::aes128CbcContextCreate(out, key, iv, is_encryptor); } +void CbcContextResetIv(Aes128CbcContext *ctx, const void *iv) { ::aes128CbcContextResetIv(ctx, iv); } +size_t CbcEncrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size) { return ::aes128CbcEncrypt(ctx, dst, src, size); } +size_t CbcDecrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size) { return ::aes128CbcDecrypt(ctx, dst, src, size); } +void CtrContextCreate(Aes128CtrContext *out, const void *key, const void *ctr) { ::aes128CtrContextCreate(out, key, ctr); } +void CtrContextResetCtr(Aes128CtrContext *ctx, const void *ctr) { ::aes128CtrContextResetCtr(ctx, ctr); } +void CtrCrypt(Aes128CtrContext *ctx, void *dst, const void *src, size_t size) { ::aes128CtrCrypt(ctx, dst, src, size); } +void XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor) { ::aes128XtsContextCreate(out, key0, key1, is_encryptor); } +void XtsContextResetTweak(Aes128XtsContext *ctx, const void *tweak) { ::aes128XtsContextResetTweak(ctx, tweak); } +void XtsContextResetSector(Aes128XtsContext *ctx, uint64_t sector, bool is_nintendo) { ::aes128XtsContextResetSector(ctx, sector, is_nintendo); } +size_t XtsEncrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size) { return ::aes128XtsEncrypt(ctx, dst, src, size); } +size_t XtsDecrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size) { return ::aes128XtsDecrypt(ctx, dst, src, size); } + +} // namespace aes128 + +namespace aes192 { + +void ContextCreate(Aes192Context *out, const void *key, bool is_encryptor) { ::aes192ContextCreate(out, key, is_encryptor); } +void EncryptBlock(const Aes192Context *ctx, void *dst, const void *src) { ::aes192EncryptBlock(ctx, dst, src); } +void DecryptBlock(const Aes192Context *ctx, void *dst, const void *src) { ::aes192DecryptBlock(ctx, dst, src); } +void CbcContextCreate(Aes192CbcContext *out, const void *key, const void *iv, bool is_encryptor) { ::aes192CbcContextCreate(out, key, iv, is_encryptor); } +void CbcContextResetIv(Aes192CbcContext *ctx, const void *iv) { ::aes192CbcContextResetIv(ctx, iv); } +size_t CbcEncrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size) { return ::aes192CbcEncrypt(ctx, dst, src, size); } +size_t CbcDecrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size) { return ::aes192CbcDecrypt(ctx, dst, src, size); } +void CtrContextCreate(Aes192CtrContext *out, const void *key, const void *ctr) { ::aes192CtrContextCreate(out, key, ctr); } +void CtrContextResetCtr(Aes192CtrContext *ctx, const void *ctr) { ::aes192CtrContextResetCtr(ctx, ctr); } +void CtrCrypt(Aes192CtrContext *ctx, void *dst, const void *src, size_t size) { ::aes192CtrCrypt(ctx, dst, src, size); } +void XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor) { ::aes192XtsContextCreate(out, key0, key1, is_encryptor); } +void XtsContextResetTweak(Aes192XtsContext *ctx, const void *tweak) { ::aes192XtsContextResetTweak(ctx, tweak); } +void XtsContextResetSector(Aes192XtsContext *ctx, uint64_t sector, bool is_nintendo) { ::aes192XtsContextResetSector(ctx, sector, is_nintendo); } +size_t XtsEncrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size) { return ::aes192XtsEncrypt(ctx, dst, src, size); } +size_t XtsDecrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size) { return ::aes192XtsDecrypt(ctx, dst, src, size); } + +} // namespace aes192 + +namespace aes256 { + +void ContextCreate(Aes256Context *out, const void *key, bool is_encryptor) { ::aes256ContextCreate(out, key, is_encryptor); } +void EncryptBlock(const Aes256Context *ctx, void *dst, const void *src) { ::aes256EncryptBlock(ctx, dst, src); } +void DecryptBlock(const Aes256Context *ctx, void *dst, const void *src) { ::aes256DecryptBlock(ctx, dst, src); } +void CbcContextCreate(Aes256CbcContext *out, const void *key, const void *iv, bool is_encryptor) { ::aes256CbcContextCreate(out, key, iv, is_encryptor); } +void CbcContextResetIv(Aes256CbcContext *ctx, const void *iv) { ::aes256CbcContextResetIv(ctx, iv); } +size_t CbcEncrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size) { return ::aes256CbcEncrypt(ctx, dst, src, size); } +size_t CbcDecrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size) { return ::aes256CbcDecrypt(ctx, dst, src, size); } +void CtrContextCreate(Aes256CtrContext *out, const void *key, const void *ctr) { ::aes256CtrContextCreate(out, key, ctr); } +void CtrContextResetCtr(Aes256CtrContext *ctx, const void *ctr) { ::aes256CtrContextResetCtr(ctx, ctr); } +void CtrCrypt(Aes256CtrContext *ctx, void *dst, const void *src, size_t size) { ::aes256CtrCrypt(ctx, dst, src, size); } +void XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor) { ::aes256XtsContextCreate(out, key0, key1, is_encryptor); } +void XtsContextResetTweak(Aes256XtsContext *ctx, const void *tweak) { ::aes256XtsContextResetTweak(ctx, tweak); } +void XtsContextResetSector(Aes256XtsContext *ctx, uint64_t sector, bool is_nintendo) { ::aes256XtsContextResetSector(ctx, sector, is_nintendo); } +size_t XtsEncrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size) { return ::aes256XtsEncrypt(ctx, dst, src, size); } +size_t XtsDecrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size) { return ::aes256XtsDecrypt(ctx, dst, src, size); } + +} // namespace aes256 + +namespace album { + +Result LaShowAlbumFiles(void) { return ::albumLaShowAlbumFiles(); } +Result LaShowAllAlbumFiles(void) { return ::albumLaShowAllAlbumFiles(); } +Result LaShowAllAlbumFilesForHomeMenu(void) { return ::albumLaShowAllAlbumFilesForHomeMenu(); } + +} // namespace album + +namespace apm { + +Result Initialize(void) { return ::apmInitialize(); } +void Exit(void) { ::apmExit(); } +Service* GetServiceSession(void) { return ::apmGetServiceSession(); } +Service* GetServiceSession_Session(void) { return ::apmGetServiceSession_Session(); } +Result GetPerformanceMode(ApmPerformanceMode* out_performanceMode) { return ::apmGetPerformanceMode(out_performanceMode); } +Result SetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 PerformanceConfiguration) { return ::apmSetPerformanceConfiguration(PerformanceMode, PerformanceConfiguration); } +Result GetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 *PerformanceConfiguration) { return ::apmGetPerformanceConfiguration(PerformanceMode, PerformanceConfiguration); } + +} // namespace apm + +namespace applet { + +Result Initialize(void) { return ::appletInitialize(); } +void Exit(void) { ::appletExit(); } +Service* GetServiceSession_Proxy(void) { return ::appletGetServiceSession_Proxy(); } +Service* GetServiceSession_AppletCommonFunctions(void) { return ::appletGetServiceSession_AppletCommonFunctions(); } +Service* GetServiceSession_Functions(void) { return ::appletGetServiceSession_Functions(); } +Service* GetServiceSession_GlobalStateController(void) { return ::appletGetServiceSession_GlobalStateController(); } +Service* GetServiceSession_ApplicationCreator(void) { return ::appletGetServiceSession_ApplicationCreator(); } +Service* GetServiceSession_LibraryAppletSelfAccessor(void) { return ::appletGetServiceSession_LibraryAppletSelfAccessor(); } +Service* GetServiceSession_ProcessWindingController(void) { return ::appletGetServiceSession_ProcessWindingController(); } +Service* GetServiceSession_LibraryAppletCreator(void) { return ::appletGetServiceSession_LibraryAppletCreator(); } +Service* GetServiceSession_CommonStateGetter(void) { return ::appletGetServiceSession_CommonStateGetter(); } +Service* GetServiceSession_SelfController(void) { return ::appletGetServiceSession_SelfController(); } +Service* GetServiceSession_WindowController(void) { return ::appletGetServiceSession_WindowController(); } +Service* GetServiceSession_AudioController(void) { return ::appletGetServiceSession_AudioController(); } +Service* GetServiceSession_DisplayController(void) { return ::appletGetServiceSession_DisplayController(); } +Service* GetServiceSession_DebugFunctions(void) { return ::appletGetServiceSession_DebugFunctions(); } +u64 GetAppletResourceUserId(void) { return ::appletGetAppletResourceUserId(); } +AppletType GetAppletType(void) { return ::appletGetAppletType(); } +void SetThemeColorType(AppletThemeColorType theme) { ::appletSetThemeColorType(theme); } +AppletThemeColorType GetThemeColorType(void) { return ::appletGetThemeColorType(); } +Result GetCradleStatus(u8 *status) { return ::appletGetCradleStatus(status); } +Result GetBootMode(PmBootMode *mode) { return ::appletGetBootMode(mode); } +Result RequestToAcquireSleepLock(void) { return ::appletRequestToAcquireSleepLock(); } +Result ReleaseSleepLock(void) { return ::appletReleaseSleepLock(); } +Result ReleaseSleepLockTransiently(void) { return ::appletReleaseSleepLockTransiently(); } +Result GetWakeupCount(u64 *out) { return ::appletGetWakeupCount(out); } +Result PushToGeneralChannel(AppletStorage *s) { return ::appletPushToGeneralChannel(s); } +Result GetHomeButtonReaderLockAccessor(AppletLockAccessor *a) { return ::appletGetHomeButtonReaderLockAccessor(a); } +Result GetReaderLockAccessorEx(AppletLockAccessor *a, u32 inval) { return ::appletGetReaderLockAccessorEx(a, inval); } +Result GetWriterLockAccessorEx(AppletLockAccessor *a, u32 inval) { return ::appletGetWriterLockAccessorEx(a, inval); } +Result GetCradleFwVersion(u32 *out0, u32 *out1, u32 *out2, u32 *out3) { return ::appletGetCradleFwVersion(out0, out1, out2, out3); } +Result IsVrModeEnabled(bool *out) { return ::appletIsVrModeEnabled(out); } +Result SetVrModeEnabled(bool flag) { return ::appletSetVrModeEnabled(flag); } +Result SetLcdBacklightOffEnabled(bool flag) { return ::appletSetLcdBacklightOffEnabled(flag); } +Result IsInControllerFirmwareUpdateSection(bool *out) { return ::appletIsInControllerFirmwareUpdateSection(out); } +Result SetVrPositionForDebug(s32 x, s32 y, s32 width, s32 height) { return ::appletSetVrPositionForDebug(x, y, width, height); } +Result GetDefaultDisplayResolution(s32 *width, s32 *height) { return ::appletGetDefaultDisplayResolution(width, height); } +Result GetDefaultDisplayResolutionChangeEvent(Event *out_event) { return ::appletGetDefaultDisplayResolutionChangeEvent(out_event); } +Result GetHdcpAuthenticationState(s32 *state) { return ::appletGetHdcpAuthenticationState(state); } +Result GetHdcpAuthenticationStateChangeEvent(Event *out_event) { return ::appletGetHdcpAuthenticationStateChangeEvent(out_event); } +Result SetTvPowerStateMatchingMode(AppletTvPowerStateMatchingMode mode) { return ::appletSetTvPowerStateMatchingMode(mode); } +Result GetApplicationIdByContentActionName(u64 *application_id, const char *name) { return ::appletGetApplicationIdByContentActionName(application_id, name); } +Result SetCpuBoostMode(ApmCpuBoostMode mode) { return ::appletSetCpuBoostMode(mode); } +Result CancelCpuBoostMode(void) { return ::appletCancelCpuBoostMode(); } +Result GetBuiltInDisplayType(s32 *out) { return ::appletGetBuiltInDisplayType(out); } +Result PerformSystemButtonPressingIfInFocus(AppletSystemButtonType type) { return ::appletPerformSystemButtonPressingIfInFocus(type); } +Result SetPerformanceConfigurationChangedNotification(bool flag) { return ::appletSetPerformanceConfigurationChangedNotification(flag); } +Result GetCurrentPerformanceConfiguration(u32 *PerformanceConfiguration) { return ::appletGetCurrentPerformanceConfiguration(PerformanceConfiguration); } +Result OpenMyGpuErrorHandler(AppletGpuErrorHandler *g) { return ::appletOpenMyGpuErrorHandler(g); } +Result GetOperationModeSystemInfo(u32 *info) { return ::appletGetOperationModeSystemInfo(info); } +Result GetSettingsPlatformRegion(SetSysPlatformRegion *out) { return ::appletGetSettingsPlatformRegion(out); } +Result ActivateMigrationService(void) { return ::appletActivateMigrationService(); } +Result DeactivateMigrationService(void) { return ::appletDeactivateMigrationService(); } +Result DisableSleepTillShutdown(void) { return ::appletDisableSleepTillShutdown(); } +Result SuppressDisablingSleepTemporarily(u64 val) { return ::appletSuppressDisablingSleepTemporarily(val); } +Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(void) { return ::appletSetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(); } +void GpuErrorHandlerClose(AppletGpuErrorHandler *g) { ::appletGpuErrorHandlerClose(g); } +Result GpuErrorHandlerGetManualGpuErrorInfoSize(AppletGpuErrorHandler *g, u64 *out) { return ::appletGpuErrorHandlerGetManualGpuErrorInfoSize(g, out); } +Result GpuErrorHandlerGetManualGpuErrorInfo(AppletGpuErrorHandler *g, void* buffer, size_t size, u64 *out) { return ::appletGpuErrorHandlerGetManualGpuErrorInfo(g, buffer, size, out); } +Result GpuErrorHandlerGetManualGpuErrorDetectionSystemEvent(AppletGpuErrorHandler *g, Event *out_event) { return ::appletGpuErrorHandlerGetManualGpuErrorDetectionSystemEvent(g, out_event); } +Result GpuErrorHandlerFinishManualGpuErrorHandling(AppletGpuErrorHandler *g) { return ::appletGpuErrorHandlerFinishManualGpuErrorHandling(g); } +Result LockExit(void) { return ::appletLockExit(); } +Result UnlockExit(void) { return ::appletUnlockExit(); } +Result EnterFatalSection(void) { return ::appletEnterFatalSection(); } +Result LeaveFatalSection(void) { return ::appletLeaveFatalSection(); } +Result SetScreenShotPermission(AppletScreenShotPermission permission) { return ::appletSetScreenShotPermission(permission); } +Result SetRestartMessageEnabled(bool flag) { return ::appletSetRestartMessageEnabled(flag); } +Result SetScreenShotAppletIdentityInfo(AppletIdentityInfo *info) { return ::appletSetScreenShotAppletIdentityInfo(info); } +Result SetControllerFirmwareUpdateSection(bool flag) { return ::appletSetControllerFirmwareUpdateSection(flag); } +Result SetRequiresCaptureButtonShortPressedMessage(bool flag) { return ::appletSetRequiresCaptureButtonShortPressedMessage(flag); } +Result SetAlbumImageOrientation(AlbumImageOrientation orientation) { return ::appletSetAlbumImageOrientation(orientation); } +Result SetDesirableKeyboardLayout(SetKeyboardLayout layout) { return ::appletSetDesirableKeyboardLayout(layout); } +Result CreateManagedDisplayLayer(u64 *out) { return ::appletCreateManagedDisplayLayer(out); } +Result IsSystemBufferSharingEnabled(void) { return ::appletIsSystemBufferSharingEnabled(); } +Result GetSystemSharedLayerHandle(u64 *SharedBufferHandle, u64 *SharedLayerHandle) { return ::appletGetSystemSharedLayerHandle(SharedBufferHandle, SharedLayerHandle); } +Result GetSystemSharedBufferHandle(u64 *SharedBufferHandle) { return ::appletGetSystemSharedBufferHandle(SharedBufferHandle); } +Result CreateManagedDisplaySeparableLayer(u64 *display_layer, u64 *recording_layer) { return ::appletCreateManagedDisplaySeparableLayer(display_layer, recording_layer); } +Result SetManagedDisplayLayerSeparationMode(u32 mode) { return ::appletSetManagedDisplayLayerSeparationMode(mode); } +Result SetHandlesRequestToDisplay(bool flag) { return ::appletSetHandlesRequestToDisplay(flag); } +Result ApproveToDisplay(void) { return ::appletApproveToDisplay(); } +Result OverrideAutoSleepTimeAndDimmingTime(s32 inval0, s32 inval1, s32 inval2, s32 inval3) { return ::appletOverrideAutoSleepTimeAndDimmingTime(inval0, inval1, inval2, inval3); } +Result SetIdleTimeDetectionExtension(AppletIdleTimeDetectionExtension ext) { return ::appletSetIdleTimeDetectionExtension(ext); } +Result GetIdleTimeDetectionExtension(AppletIdleTimeDetectionExtension *ext) { return ::appletGetIdleTimeDetectionExtension(ext); } +Result SetInputDetectionSourceSet(u32 val) { return ::appletSetInputDetectionSourceSet(val); } +Result ReportUserIsActive(void) { return ::appletReportUserIsActive(); } +Result GetCurrentIlluminance(float *fLux) { return ::appletGetCurrentIlluminance(fLux); } +Result IsIlluminanceAvailable(bool *out) { return ::appletIsIlluminanceAvailable(out); } +Result SetAutoSleepDisabled(bool flag) { return ::appletSetAutoSleepDisabled(flag); } +Result IsAutoSleepDisabled(bool *out) { return ::appletIsAutoSleepDisabled(out); } +Result GetCurrentIlluminanceEx(bool *bOverLimit, float *fLux) { return ::appletGetCurrentIlluminanceEx(bOverLimit, fLux); } +Result SetInputDetectionPolicy(AppletInputDetectionPolicy policy) { return ::appletSetInputDetectionPolicy(policy); } +Result SetWirelessPriorityMode(AppletWirelessPriorityMode mode) { return ::appletSetWirelessPriorityMode(mode); } +Result GetProgramTotalActiveTime(u64 *activeTime) { return ::appletGetProgramTotalActiveTime(activeTime); } +Result SetAlbumImageTakenNotificationEnabled(bool flag) { return ::appletSetAlbumImageTakenNotificationEnabled(flag); } +Result SetApplicationAlbumUserData(const void* buffer, size_t size) { return ::appletSetApplicationAlbumUserData(buffer, size); } +Result SaveCurrentScreenshot(AlbumReportOption option) { return ::appletSaveCurrentScreenshot(option); } +Result GetAppletResourceUserIdOfCallerApplet(u64 *out) { return ::appletGetAppletResourceUserIdOfCallerApplet(out); } +Result SetAppletWindowVisibility(bool flag) { return ::appletSetAppletWindowVisibility(flag); } +Result SetAppletGpuTimeSlice(s64 val) { return ::appletSetAppletGpuTimeSlice(val); } +Result SetExpectedMasterVolume(float mainAppletVolume, float libraryAppletVolume) { return ::appletSetExpectedMasterVolume(mainAppletVolume, libraryAppletVolume); } +Result GetExpectedMasterVolume(float *mainAppletVolume, float *libraryAppletVolume) { return ::appletGetExpectedMasterVolume(mainAppletVolume, libraryAppletVolume); } +Result ChangeMainAppletMasterVolume(float volume, u64 unk) { return ::appletChangeMainAppletMasterVolume(volume, unk); } +Result SetTransparentVolumeRate(float val) { return ::appletSetTransparentVolumeRate(val); } +Result UpdateLastForegroundCaptureImage(void) { return ::appletUpdateLastForegroundCaptureImage(); } +Result UpdateCallerAppletCaptureImage(void) { return ::appletUpdateCallerAppletCaptureImage(); } +Result GetLastForegroundCaptureImageEx(void* buffer, size_t size, bool *flag) { return ::appletGetLastForegroundCaptureImageEx(buffer, size, flag); } +Result GetLastApplicationCaptureImageEx(void* buffer, size_t size, bool *flag) { return ::appletGetLastApplicationCaptureImageEx(buffer, size, flag); } +Result GetCallerAppletCaptureImageEx(void* buffer, size_t size, bool *flag) { return ::appletGetCallerAppletCaptureImageEx(buffer, size, flag); } +Result TakeScreenShotOfOwnLayer(bool flag, AppletCaptureSharedBuffer captureBuf) { return ::appletTakeScreenShotOfOwnLayer(flag, captureBuf); } +Result CopyBetweenCaptureBuffers(AppletCaptureSharedBuffer dstCaptureBuf, AppletCaptureSharedBuffer srcCaptureBuf) { return ::appletCopyBetweenCaptureBuffers(dstCaptureBuf, srcCaptureBuf); } +Result ClearCaptureBuffer(bool flag, AppletCaptureSharedBuffer captureBuf, u32 color) { return ::appletClearCaptureBuffer(flag, captureBuf, color); } +Result ClearAppletTransitionBuffer(u32 color) { return ::appletClearAppletTransitionBuffer(color); } +Result AcquireLastApplicationCaptureSharedBuffer(bool *flag, s32 *id) { return ::appletAcquireLastApplicationCaptureSharedBuffer(flag, id); } +Result ReleaseLastApplicationCaptureSharedBuffer(void) { return ::appletReleaseLastApplicationCaptureSharedBuffer(); } +Result AcquireLastForegroundCaptureSharedBuffer(bool *flag, s32 *id) { return ::appletAcquireLastForegroundCaptureSharedBuffer(flag, id); } +Result ReleaseLastForegroundCaptureSharedBuffer(void) { return ::appletReleaseLastForegroundCaptureSharedBuffer(); } +Result AcquireCallerAppletCaptureSharedBuffer(bool *flag, s32 *id) { return ::appletAcquireCallerAppletCaptureSharedBuffer(flag, id); } +Result ReleaseCallerAppletCaptureSharedBuffer(void) { return ::appletReleaseCallerAppletCaptureSharedBuffer(); } +Result TakeScreenShotOfOwnLayerEx(bool flag0, bool immediately, AppletCaptureSharedBuffer captureBuf) { return ::appletTakeScreenShotOfOwnLayerEx(flag0, immediately, captureBuf); } +Result PushContext(AppletStorage *s) { return ::appletPushContext(s); } +Result PopContext(AppletStorage *s) { return ::appletPopContext(s); } +void LockAccessorClose(AppletLockAccessor *a) { ::appletLockAccessorClose(a); } +Result LockAccessorTryLock(AppletLockAccessor *a, bool *flag) { return ::appletLockAccessorTryLock(a, flag); } +Result LockAccessorLock(AppletLockAccessor *a) { return ::appletLockAccessorLock(a); } +Result LockAccessorUnlock(AppletLockAccessor *a) { return ::appletLockAccessorUnlock(a); } +Result CreateLibraryApplet(AppletHolder *h, AppletId id, LibAppletMode mode) { return ::appletCreateLibraryApplet(h, id, mode); } +Result CreateLibraryAppletSelf(AppletHolder *h, AppletId id, LibAppletMode mode) { return ::appletCreateLibraryAppletSelf(h, id, mode); } +Result TerminateAllLibraryApplets(void) { return ::appletTerminateAllLibraryApplets(); } +Result AreAnyLibraryAppletsLeft(bool *out) { return ::appletAreAnyLibraryAppletsLeft(out); } +void HolderClose(AppletHolder *h) { ::appletHolderClose(h); } +bool HolderActive(AppletHolder *h) { return ::appletHolderActive(h); } +Result HolderGetIndirectLayerConsumerHandle(AppletHolder *h, u64 *out) { return ::appletHolderGetIndirectLayerConsumerHandle(h, out); } +Result HolderStart(AppletHolder *h) { return ::appletHolderStart(h); } +Result HolderJump(AppletHolder *h) { return ::appletHolderJump(h); } +Result HolderRequestExit(AppletHolder *h) { return ::appletHolderRequestExit(h); } +Result HolderTerminate(AppletHolder *h) { return ::appletHolderTerminate(h); } +Result HolderRequestExitOrTerminate(AppletHolder *h, u64 timeout) { return ::appletHolderRequestExitOrTerminate(h, timeout); } +void HolderJoin(AppletHolder *h) { ::appletHolderJoin(h); } +Event * HolderGetExitEvent(AppletHolder *h) { return ::appletHolderGetExitEvent(h); } +bool HolderCheckFinished(AppletHolder *h) { return ::appletHolderCheckFinished(h); } +LibAppletExitReason HolderGetExitReason(AppletHolder *h) { return ::appletHolderGetExitReason(h); } +Result HolderSetOutOfFocusApplicationSuspendingEnabled(AppletHolder *h, bool flag) { return ::appletHolderSetOutOfFocusApplicationSuspendingEnabled(h, flag); } +Result HolderPresetLibraryAppletGpuTimeSliceZero(AppletHolder *h) { return ::appletHolderPresetLibraryAppletGpuTimeSliceZero(h); } +Result HolderGetPopInteractiveOutDataEvent(AppletHolder *h, Event **out_event) { return ::appletHolderGetPopInteractiveOutDataEvent(h, out_event); } +bool HolderWaitInteractiveOut(AppletHolder *h) { return ::appletHolderWaitInteractiveOut(h); } +Result HolderPushInData(AppletHolder *h, AppletStorage *s) { return ::appletHolderPushInData(h, s); } +Result HolderPopOutData(AppletHolder *h, AppletStorage *s) { return ::appletHolderPopOutData(h, s); } +Result HolderPushExtraStorage(AppletHolder *h, AppletStorage *s) { return ::appletHolderPushExtraStorage(h, s); } +Result HolderPushInteractiveInData(AppletHolder *h, AppletStorage *s) { return ::appletHolderPushInteractiveInData(h, s); } +Result HolderPopInteractiveOutData(AppletHolder *h, AppletStorage *s) { return ::appletHolderPopInteractiveOutData(h, s); } +Result HolderGetLibraryAppletInfo(AppletHolder *h, LibAppletInfo *info) { return ::appletHolderGetLibraryAppletInfo(h, info); } +Result CreateStorage(AppletStorage *s, s64 size) { return ::appletCreateStorage(s, size); } +Result CreateTransferMemoryStorage(AppletStorage *s, void* buffer, s64 size, bool writable) { return ::appletCreateTransferMemoryStorage(s, buffer, size, writable); } +Result CreateHandleStorage(AppletStorage *s, s64 inval, Handle handle) { return ::appletCreateHandleStorage(s, inval, handle); } +Result CreateHandleStorageTmem(AppletStorage *s, void* buffer, s64 size) { return ::appletCreateHandleStorageTmem(s, buffer, size); } +void StorageClose(AppletStorage *s) { ::appletStorageClose(s); } +void StorageCloseTmem(AppletStorage *s) { ::appletStorageCloseTmem(s); } +Result StorageGetSize(AppletStorage *s, s64 *size) { return ::appletStorageGetSize(s, size); } +Result StorageWrite(AppletStorage *s, s64 offset, const void* buffer, size_t size) { return ::appletStorageWrite(s, offset, buffer, size); } +Result StorageRead(AppletStorage *s, s64 offset, void* buffer, size_t size) { return ::appletStorageRead(s, offset, buffer, size); } +Result StorageGetHandle(AppletStorage *s, s64 *out, Handle *handle) { return ::appletStorageGetHandle(s, out, handle); } +Result StorageMap(AppletStorage *s, void** addr, size_t *size) { return ::appletStorageMap(s, addr, size); } +Result PopLaunchParameter(AppletStorage *s, AppletLaunchParameterKind kind) { return ::appletPopLaunchParameter(s, kind); } +Result RequestLaunchApplication(u64 application_id, AppletStorage* s) { return ::appletRequestLaunchApplication(application_id, s); } +Result RequestLaunchApplicationForQuest(u64 application_id, AppletStorage* s, const AppletApplicationAttributeForQuest *attr) { return ::appletRequestLaunchApplicationForQuest(application_id, s, attr); } +Result GetDesiredLanguage(u64 *LanguageCode) { return ::appletGetDesiredLanguage(LanguageCode); } +Result GetDisplayVersion(char *displayVersion) { return ::appletGetDisplayVersion(displayVersion); } +Result BeginBlockingHomeButtonShortAndLongPressed(s64 val) { return ::appletBeginBlockingHomeButtonShortAndLongPressed(val); } +Result EndBlockingHomeButtonShortAndLongPressed(void) { return ::appletEndBlockingHomeButtonShortAndLongPressed(); } +Result BeginBlockingHomeButton(s64 val) { return ::appletBeginBlockingHomeButton(val); } +Result EndBlockingHomeButton(void) { return ::appletEndBlockingHomeButton(); } +void NotifyRunning(bool *out) { ::appletNotifyRunning(out); } +Result GetPseudoDeviceId(Uuid *out) { return ::appletGetPseudoDeviceId(out); } +Result SetMediaPlaybackState(bool state) { return ::appletSetMediaPlaybackState(state); } +Result IsGamePlayRecordingSupported(bool *flag) { return ::appletIsGamePlayRecordingSupported(flag); } +Result SetGamePlayRecordingState(bool state) { return ::appletSetGamePlayRecordingState(state); } +Result InitializeGamePlayRecording(void) { return ::appletInitializeGamePlayRecording(); } +Result RequestFlushGamePlayingMovieForDebug(void) { return ::appletRequestFlushGamePlayingMovieForDebug(); } +Result RequestToShutdown(void) { return ::appletRequestToShutdown(); } +Result RequestToReboot(void) { return ::appletRequestToReboot(); } +Result RequestToSleep(void) { return ::appletRequestToSleep(); } +Result ExitAndRequestToShowThanksMessage(void) { return ::appletExitAndRequestToShowThanksMessage(); } +Result InitializeApplicationCopyrightFrameBuffer(void) { return ::appletInitializeApplicationCopyrightFrameBuffer(); } +Result SetApplicationCopyrightImage(const void* buffer, size_t size, s32 x, s32 y, s32 width, s32 height, AppletWindowOriginMode mode) { return ::appletSetApplicationCopyrightImage(buffer, size, x, y, width, height, mode); } +Result SetApplicationCopyrightVisibility(bool visible) { return ::appletSetApplicationCopyrightVisibility(visible); } +Result QueryApplicationPlayStatistics(PdmApplicationPlayStatistics *stats, const u64 *application_ids, s32 count, s32 *total_out) { return ::appletQueryApplicationPlayStatistics(stats, application_ids, count, total_out); } +Result QueryApplicationPlayStatisticsByUid(AccountUid uid, PdmApplicationPlayStatistics *stats, const u64 *application_ids, s32 count, s32 *total_out) { return ::appletQueryApplicationPlayStatisticsByUid(uid, stats, application_ids, count, total_out); } +Result ExecuteProgram(s32 programIndex, const void* buffer, size_t size) { return ::appletExecuteProgram(programIndex, buffer, size); } +Result JumpToSubApplicationProgramForDevelopment(u64 application_id, const void* buffer, size_t size) { return ::appletJumpToSubApplicationProgramForDevelopment(application_id, buffer, size); } +Result RestartProgram(const void* buffer, size_t size) { return ::appletRestartProgram(buffer, size); } +Result GetPreviousProgramIndex(s32 *programIndex) { return ::appletGetPreviousProgramIndex(programIndex); } +Result SetDelayTimeToAbortOnGpuError(u64 val) { return ::appletSetDelayTimeToAbortOnGpuError(val); } +Result GetFriendInvitationStorageChannelEvent(Event *out_event) { return ::appletGetFriendInvitationStorageChannelEvent(out_event); } +Result TryPopFromFriendInvitationStorageChannel(AppletStorage *s) { return ::appletTryPopFromFriendInvitationStorageChannel(s); } +Result GetNotificationStorageChannelEvent(Event *out_event) { return ::appletGetNotificationStorageChannelEvent(out_event); } +Result TryPopFromNotificationStorageChannel(AppletStorage *s) { return ::appletTryPopFromNotificationStorageChannel(s); } +Result GetHealthWarningDisappearedSystemEvent(Event *out_event) { return ::appletGetHealthWarningDisappearedSystemEvent(out_event); } +Result SetHdcpAuthenticationActivated(bool flag) { return ::appletSetHdcpAuthenticationActivated(flag); } +Result GetLastApplicationExitReason(s32 *out) { return ::appletGetLastApplicationExitReason(out); } +Result CreateMovieMaker(Service* srv_out, TransferMemory *tmem) { return ::appletCreateMovieMaker(srv_out, tmem); } +Result PrepareForJit(void) { return ::appletPrepareForJit(); } +Result RequestToGetForeground(void) { return ::appletRequestToGetForeground(); } +Result LockForeground(void) { return ::appletLockForeground(); } +Result UnlockForeground(void) { return ::appletUnlockForeground(); } +Result PopFromGeneralChannel(AppletStorage *s) { return ::appletPopFromGeneralChannel(s); } +Result GetPopFromGeneralChannelEvent(Event *out_event) { return ::appletGetPopFromGeneralChannelEvent(out_event); } +Result GetHomeButtonWriterLockAccessor(AppletLockAccessor *a) { return ::appletGetHomeButtonWriterLockAccessor(a); } +Result IsSleepEnabled(bool *out) { return ::appletIsSleepEnabled(out); } +Result PopRequestLaunchApplicationForDebug(AccountUid *uids, s32 count, u64 *application_id, s32 *total_out) { return ::appletPopRequestLaunchApplicationForDebug(uids, count, application_id, total_out); } +Result IsForceTerminateApplicationDisabledForDebug(bool *out) { return ::appletIsForceTerminateApplicationDisabledForDebug(out); } +Result LaunchDevMenu(void) { return ::appletLaunchDevMenu(); } +Result SetLastApplicationExitReason(s32 reason) { return ::appletSetLastApplicationExitReason(reason); } +Result StartSleepSequence(bool flag) { return ::appletStartSleepSequence(flag); } +Result StartShutdownSequence(void) { return ::appletStartShutdownSequence(); } +Result StartRebootSequence(void) { return ::appletStartRebootSequence(); } +Result IsAutoPowerDownRequested(bool *out) { return ::appletIsAutoPowerDownRequested(out); } +Result LoadAndApplyIdlePolicySettings(void) { return ::appletLoadAndApplyIdlePolicySettings(); } +Result NotifyCecSettingsChanged(void) { return ::appletNotifyCecSettingsChanged(); } +Result SetDefaultHomeButtonLongPressTime(s64 val) { return ::appletSetDefaultHomeButtonLongPressTime(val); } +Result UpdateDefaultDisplayResolution(void) { return ::appletUpdateDefaultDisplayResolution(); } +Result ShouldSleepOnBoot(bool *out) { return ::appletShouldSleepOnBoot(out); } +Result GetHdcpAuthenticationFailedEvent(Event *out_event) { return ::appletGetHdcpAuthenticationFailedEvent(out_event); } +Result CreateApplication(AppletApplication *a, u64 application_id) { return ::appletCreateApplication(a, application_id); } +Result PopLaunchRequestedApplication(AppletApplication *a) { return ::appletPopLaunchRequestedApplication(a); } +Result CreateSystemApplication(AppletApplication *a, u64 system_application_id) { return ::appletCreateSystemApplication(a, system_application_id); } +Result PopFloatingApplicationForDevelopment(AppletApplication *a) { return ::appletPopFloatingApplicationForDevelopment(a); } +void ApplicationClose(AppletApplication *a) { ::appletApplicationClose(a); } +bool ApplicationActive(AppletApplication *a) { return ::appletApplicationActive(a); } +Result ApplicationStart(AppletApplication *a) { return ::appletApplicationStart(a); } +Result ApplicationRequestExit(AppletApplication *a) { return ::appletApplicationRequestExit(a); } +Result ApplicationTerminate(AppletApplication *a) { return ::appletApplicationTerminate(a); } +void ApplicationJoin(AppletApplication *a) { ::appletApplicationJoin(a); } +bool ApplicationCheckFinished(AppletApplication *a) { return ::appletApplicationCheckFinished(a); } +AppletApplicationExitReason ApplicationGetExitReason(AppletApplication *a) { return ::appletApplicationGetExitReason(a); } +Result ApplicationRequestForApplicationToGetForeground(AppletApplication *a) { return ::appletApplicationRequestForApplicationToGetForeground(a); } +Result ApplicationTerminateAllLibraryApplets(AppletApplication *a) { return ::appletApplicationTerminateAllLibraryApplets(a); } +Result ApplicationAreAnyLibraryAppletsLeft(AppletApplication *a, bool *out) { return ::appletApplicationAreAnyLibraryAppletsLeft(a, out); } +Result ApplicationRequestExitLibraryAppletOrTerminate(AppletApplication *a, u64 timeout) { return ::appletApplicationRequestExitLibraryAppletOrTerminate(a, timeout); } +Result ApplicationGetApplicationId(AppletApplication *a, u64 *application_id) { return ::appletApplicationGetApplicationId(a, application_id); } +Result ApplicationPushLaunchParameter(AppletApplication *a, AppletLaunchParameterKind kind, AppletStorage* s) { return ::appletApplicationPushLaunchParameter(a, kind, s); } +Result ApplicationGetApplicationControlProperty(AppletApplication *a, NacpStruct *nacp) { return ::appletApplicationGetApplicationControlProperty(a, nacp); } +Result ApplicationGetApplicationLaunchProperty(AppletApplication *a, AppletApplicationLaunchProperty *out) { return ::appletApplicationGetApplicationLaunchProperty(a, out); } +Result ApplicationGetApplicationLaunchRequestInfo(AppletApplication *a, AppletApplicationLaunchRequestInfo *out) { return ::appletApplicationGetApplicationLaunchRequestInfo(a, out); } +Result ApplicationSetUsers(AppletApplication *a, const AccountUid *uids, s32 count, bool flag) { return ::appletApplicationSetUsers(a, uids, count, flag); } +Result ApplicationCheckRightsEnvironmentAvailable(AppletApplication *a, bool *out) { return ::appletApplicationCheckRightsEnvironmentAvailable(a, out); } +Result ApplicationGetNsRightsEnvironmentHandle(AppletApplication *a, u64 *handle) { return ::appletApplicationGetNsRightsEnvironmentHandle(a, handle); } +Result ApplicationGetDesirableUids(AppletApplication *a, AccountUid *uids, s32 count, s32 *total_out) { return ::appletApplicationGetDesirableUids(a, uids, count, total_out); } +Result ApplicationReportApplicationExitTimeout(AppletApplication *a) { return ::appletApplicationReportApplicationExitTimeout(a); } +Result ApplicationSetApplicationAttribute(AppletApplication *a, const AppletApplicationAttribute *attr) { return ::appletApplicationSetApplicationAttribute(a, attr); } +Result ApplicationHasSaveDataAccessPermission(AppletApplication *a, u64 application_id, bool *out) { return ::appletApplicationHasSaveDataAccessPermission(a, application_id, out); } +Result ApplicationPushToFriendInvitationStorageChannel(AppletApplication *a, AccountUid uid, const void* buffer, u64 size) { return ::appletApplicationPushToFriendInvitationStorageChannel(a, uid, buffer, size); } +Result ApplicationPushToNotificationStorageChannel(AppletApplication *a, const void* buffer, u64 size) { return ::appletApplicationPushToNotificationStorageChannel(a, buffer, size); } +Result ApplicationRequestApplicationSoftReset(AppletApplication *a) { return ::appletApplicationRequestApplicationSoftReset(a); } +Result ApplicationRestartApplicationTimer(AppletApplication *a) { return ::appletApplicationRestartApplicationTimer(a); } +Result PopInData(AppletStorage *s) { return ::appletPopInData(s); } +Result PushOutData(AppletStorage *s) { return ::appletPushOutData(s); } +Result PopInteractiveInData(AppletStorage *s) { return ::appletPopInteractiveInData(s); } +Result PushInteractiveOutData(AppletStorage *s) { return ::appletPushInteractiveOutData(s); } +Result GetPopInDataEvent(Event *out_event) { return ::appletGetPopInDataEvent(out_event); } +Result GetPopInteractiveInDataEvent(Event *out_event) { return ::appletGetPopInteractiveInDataEvent(out_event); } +Result GetLibraryAppletInfo(LibAppletInfo *info) { return ::appletGetLibraryAppletInfo(info); } +Result GetMainAppletIdentityInfo(AppletIdentityInfo *info) { return ::appletGetMainAppletIdentityInfo(info); } +Result CanUseApplicationCore(bool *out) { return ::appletCanUseApplicationCore(out); } +Result GetCallerAppletIdentityInfo(AppletIdentityInfo *info) { return ::appletGetCallerAppletIdentityInfo(info); } +Result GetMainAppletApplicationControlProperty(NacpStruct *nacp) { return ::appletGetMainAppletApplicationControlProperty(nacp); } +Result GetMainAppletStorageId(NcmStorageId *storageId) { return ::appletGetMainAppletStorageId(storageId); } +Result GetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 count, s32 *total_out) { return ::appletGetCallerAppletIdentityInfoStack(stack, count, total_out); } +Result GetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info) { return ::appletGetNextReturnDestinationAppletIdentityInfo(info); } +Result GetDesirableKeyboardLayout(SetKeyboardLayout *layout) { return ::appletGetDesirableKeyboardLayout(layout); } +Result PopExtraStorage(AppletStorage *s) { return ::appletPopExtraStorage(s); } +Result GetPopExtraStorageEvent(Event *out_event) { return ::appletGetPopExtraStorageEvent(out_event); } +Result UnpopInData(AppletStorage *s) { return ::appletUnpopInData(s); } +Result UnpopExtraStorage(AppletStorage *s) { return ::appletUnpopExtraStorage(s); } +Result GetIndirectLayerProducerHandle(u64 *out) { return ::appletGetIndirectLayerProducerHandle(out); } +Result GetMainAppletApplicationDesiredLanguage(u64 *LanguageCode) { return ::appletGetMainAppletApplicationDesiredLanguage(LanguageCode); } +Result GetCurrentApplicationId(u64 *application_id) { return ::appletGetCurrentApplicationId(application_id); } +Result RequestExitToSelf(void) { return ::appletRequestExitToSelf(); } +Result CreateGameMovieTrimmer(Service* srv_out, TransferMemory *tmem) { return ::appletCreateGameMovieTrimmer(srv_out, tmem); } +Result ReserveResourceForMovieOperation(void) { return ::appletReserveResourceForMovieOperation(); } +Result UnreserveResourceForMovieOperation(void) { return ::appletUnreserveResourceForMovieOperation(); } +Result GetMainAppletAvailableUsers(AccountUid *uids, s32 count, bool *flag, s32 *total_out) { return ::appletGetMainAppletAvailableUsers(uids, count, flag, total_out); } +Result SetApplicationMemoryReservation(u64 val) { return ::appletSetApplicationMemoryReservation(val); } +Result ShouldSetGpuTimeSliceManually(bool *out) { return ::appletShouldSetGpuTimeSliceManually(out); } +Result BeginToWatchShortHomeButtonMessage(void) { return ::appletBeginToWatchShortHomeButtonMessage(); } +Result EndToWatchShortHomeButtonMessage(void) { return ::appletEndToWatchShortHomeButtonMessage(); } +Result GetApplicationIdForLogo(u64 *application_id) { return ::appletGetApplicationIdForLogo(application_id); } +Result SetGpuTimeSliceBoost(u64 val) { return ::appletSetGpuTimeSliceBoost(val); } +Result SetAutoSleepTimeAndDimmingTimeEnabled(bool flag) { return ::appletSetAutoSleepTimeAndDimmingTimeEnabled(flag); } +Result TerminateApplicationAndSetReason(Result reason) { return ::appletTerminateApplicationAndSetReason(reason); } +Result SetScreenShotPermissionGlobally(bool flag) { return ::appletSetScreenShotPermissionGlobally(flag); } +Result StartShutdownSequenceForOverlay(void) { return ::appletStartShutdownSequenceForOverlay(); } +Result StartRebootSequenceForOverlay(void) { return ::appletStartRebootSequenceForOverlay(); } +Result SetHealthWarningShowingState(bool flag) { return ::appletSetHealthWarningShowingState(flag); } +Result IsHealthWarningRequired(bool *out) { return ::appletIsHealthWarningRequired(out); } +Result BeginToObserveHidInputForDevelop(void) { return ::appletBeginToObserveHidInputForDevelop(); } +Result ReadThemeStorage(void* buffer, size_t size, u64 offset, u64 *transfer_size) { return ::appletReadThemeStorage(buffer, size, offset, transfer_size); } +Result WriteThemeStorage(const void* buffer, size_t size, u64 offset) { return ::appletWriteThemeStorage(buffer, size, offset); } +Result PushToAppletBoundChannel(AppletStorage *s) { return ::appletPushToAppletBoundChannel(s); } +Result TryPopFromAppletBoundChannel(AppletStorage *s) { return ::appletTryPopFromAppletBoundChannel(s); } +Result GetDisplayLogicalResolution(s32 *width, s32 *height) { return ::appletGetDisplayLogicalResolution(width, height); } +Result SetDisplayMagnification(float x, float y, float width, float height) { return ::appletSetDisplayMagnification(x, y, width, height); } +Result SetHomeButtonDoubleClickEnabled(bool flag) { return ::appletSetHomeButtonDoubleClickEnabled(flag); } +Result GetHomeButtonDoubleClickEnabled(bool *out) { return ::appletGetHomeButtonDoubleClickEnabled(out); } +Result IsHomeButtonShortPressedBlocked(bool *out) { return ::appletIsHomeButtonShortPressedBlocked(out); } +Result IsVrModeCurtainRequired(bool *out) { return ::appletIsVrModeCurtainRequired(out); } +Result SetCpuBoostRequestPriority(s32 priority) { return ::appletSetCpuBoostRequestPriority(priority); } +Result OpenMainApplication(AppletApplication *a) { return ::appletOpenMainApplication(a); } +Result PerformSystemButtonPressing(AppletSystemButtonType type) { return ::appletPerformSystemButtonPressing(type); } +Result InvalidateTransitionLayer(void) { return ::appletInvalidateTransitionLayer(); } +Result RequestLaunchApplicationWithUserAndArgumentForDebug(u64 application_id, const AccountUid *uids, s32 total_uids, bool flag, const void* buffer, size_t size) { return ::appletRequestLaunchApplicationWithUserAndArgumentForDebug(application_id, uids, total_uids, flag, buffer, size); } +Result GetAppletResourceUsageInfo(AppletResourceUsageInfo *info) { return ::appletGetAppletResourceUsageInfo(info); } +Result PushToAppletBoundChannelForDebug(AppletStorage *s, s32 channel) { return ::appletPushToAppletBoundChannelForDebug(s, channel); } +Result TryPopFromAppletBoundChannelForDebug(AppletStorage *s, s32 channel) { return ::appletTryPopFromAppletBoundChannelForDebug(s, channel); } +Result AlarmSettingNotificationEnableAppEventReserve(AppletStorage *s, u64 application_id) { return ::appletAlarmSettingNotificationEnableAppEventReserve(s, application_id); } +Result AlarmSettingNotificationDisableAppEventReserve(void) { return ::appletAlarmSettingNotificationDisableAppEventReserve(); } +Result AlarmSettingNotificationPushAppEventNotify(const void* buffer, u64 size) { return ::appletAlarmSettingNotificationPushAppEventNotify(buffer, size); } +Result FriendInvitationSetApplicationParameter(AppletStorage *s, u64 application_id) { return ::appletFriendInvitationSetApplicationParameter(s, application_id); } +Result FriendInvitationClearApplicationParameter(void) { return ::appletFriendInvitationClearApplicationParameter(); } +Result FriendInvitationPushApplicationParameter(AccountUid uid, const void* buffer, u64 size) { return ::appletFriendInvitationPushApplicationParameter(uid, buffer, size); } +Result CreateGeneralStorageForDebug(u64 id, u64 size) { return ::appletCreateGeneralStorageForDebug(id, size); } +Result ReadGeneralStorageForDebug(void* buffer, size_t size, u64 id, u64 offset, u64 *out_size) { return ::appletReadGeneralStorageForDebug(buffer, size, id, offset, out_size); } +Result WriteGeneralStorageForDebug(const void* buffer, size_t size, u64 id, u64 offset) { return ::appletWriteGeneralStorageForDebug(buffer, size, id, offset); } +Result SetTerminateResult(Result res) { return ::appletSetTerminateResult(res); } +Result GetLaunchStorageInfoForDebug(NcmStorageId *app_storageId, NcmStorageId *update_storageId) { return ::appletGetLaunchStorageInfoForDebug(app_storageId, update_storageId); } +Result GetGpuErrorDetectedSystemEvent(Event *out_event) { return ::appletGetGpuErrorDetectedSystemEvent(out_event); } +Result SetHandlingHomeButtonShortPressedEnabled(bool flag) { return ::appletSetHandlingHomeButtonShortPressedEnabled(flag); } +AppletInfo * GetAppletInfo(void) { return ::appletGetAppletInfo(); } +Event * GetMessageEvent(void) { return ::appletGetMessageEvent(); } +Result GetMessage(u32 *msg) { return ::appletGetMessage(msg); } +bool ProcessMessage(u32 msg) { return ::appletProcessMessage(msg); } +bool MainLoop(void) { return ::appletMainLoop(); } +void Hook(AppletHookCookie* cookie, AppletHookFn callback, void* param) { ::appletHook(cookie, callback, param); } +void Unhook(AppletHookCookie* cookie) { ::appletUnhook(cookie); } +AppletOperationMode GetOperationMode(void) { return ::appletGetOperationMode(); } +ApmPerformanceMode GetPerformanceMode(void) { return ::appletGetPerformanceMode(); } +AppletFocusState GetFocusState(void) { return ::appletGetFocusState(); } +Result SetFocusHandlingMode(AppletFocusHandlingMode mode) { return ::appletSetFocusHandlingMode(mode); } + +} // namespace applet + +namespace arm { + +void DCacheFlush(void* addr, size_t size) { ::armDCacheFlush(addr, size); } +void DCacheClean(void* addr, size_t size) { ::armDCacheClean(addr, size); } +void ICacheInvalidate(void* addr, size_t size) { ::armICacheInvalidate(addr, size); } +void DCacheZero(void* addr, size_t size) { ::armDCacheZero(addr, size); } +u64 GetSystemTick(void) { return ::armGetSystemTick(); } +u64 GetSystemTickFreq(void) { return ::armGetSystemTickFreq(); } +u64 NsToTicks(u64 ns) { return ::armNsToTicks(ns); } +u64 TicksToNs(u64 tick) { return ::armTicksToNs(tick); } +void* GetTls(void) { return ::armGetTls(); } + +} // namespace arm + +namespace async { + +void ValueClose(AsyncValue *a) { ::asyncValueClose(a); } +Result ValueWait(AsyncValue *a, u64 timeout) { return ::asyncValueWait(a, timeout); } +Result ValueGetSize(AsyncValue *a, u64 *size) { return ::asyncValueGetSize(a, size); } +Result ValueGet(AsyncValue *a, void* buffer, size_t size) { return ::asyncValueGet(a, buffer, size); } +Result ValueCancel(AsyncValue *a) { return ::asyncValueCancel(a); } +Result ValueGetErrorContext(AsyncValue *a, ErrorContext *context) { return ::asyncValueGetErrorContext(a, context); } +void ResultClose(AsyncResult *a) { ::asyncResultClose(a); } +Result ResultWait(AsyncResult *a, u64 timeout) { return ::asyncResultWait(a, timeout); } +Result ResultGet(AsyncResult *a) { return ::asyncResultGet(a); } +Result ResultCancel(AsyncResult *a) { return ::asyncResultCancel(a); } +Result ResultGetErrorContext(AsyncResult *a, ErrorContext *context) { return ::asyncResultGetErrorContext(a, context); } + +} // namespace async + +namespace auda { + +Result Initialize(void) { return ::audaInitialize(); } +void Exit(void) { ::audaExit(); } +Service* GetServiceSession(void) { return ::audaGetServiceSession(); } +Result RequestSuspendAudio(u64 pid, u64 delay) { return ::audaRequestSuspendAudio(pid, delay); } +Result RequestResumeAudio(u64 pid, u64 delay) { return ::audaRequestResumeAudio(pid, delay); } +Result GetAudioOutputProcessMasterVolume(u64 pid, float* volume_out) { return ::audaGetAudioOutputProcessMasterVolume(pid, volume_out); } +Result SetAudioOutputProcessMasterVolume(u64 pid, u64 delay, float volume) { return ::audaSetAudioOutputProcessMasterVolume(pid, delay, volume); } +Result GetAudioInputProcessMasterVolume(u64 pid, float* volume_out) { return ::audaGetAudioInputProcessMasterVolume(pid, volume_out); } +Result SetAudioInputProcessMasterVolume(u64 pid, u64 delay, float volume) { return ::audaSetAudioInputProcessMasterVolume(pid, delay, volume); } +Result GetAudioOutputProcessRecordVolume(u64 pid, float* volume_out) { return ::audaGetAudioOutputProcessRecordVolume(pid, volume_out); } +Result SetAudioOutputProcessRecordVolume(u64 pid, u64 delay, float volume) { return ::audaSetAudioOutputProcessRecordVolume(pid, delay, volume); } + +} // namespace auda + +namespace audctl { + +Result Initialize(void) { return ::audctlInitialize(); } +void Exit(void) { ::audctlExit(); } +Service* GetServiceSession(void) { return ::audctlGetServiceSession(); } +Result GetTargetVolume(s32* volume_out, AudioTarget target) { return ::audctlGetTargetVolume(volume_out, target); } +Result SetTargetVolume(AudioTarget target, s32 volume) { return ::audctlSetTargetVolume(target, volume); } +Result GetTargetVolumeMin(s32* volume_out) { return ::audctlGetTargetVolumeMin(volume_out); } +Result GetTargetVolumeMax(s32* volume_out) { return ::audctlGetTargetVolumeMax(volume_out); } +Result IsTargetMute(bool* mute_out, AudioTarget target) { return ::audctlIsTargetMute(mute_out, target); } +Result SetTargetMute(AudioTarget target, bool mute) { return ::audctlSetTargetMute(target, mute); } +Result IsTargetConnected(bool* connected_out, AudioTarget target) { return ::audctlIsTargetConnected(connected_out, target); } +Result SetDefaultTarget(AudioTarget target, u64 fade_in_ns, u64 fade_out_ns) { return ::audctlSetDefaultTarget(target, fade_in_ns, fade_out_ns); } +Result GetDefaultTarget(AudioTarget* target_out) { return ::audctlGetDefaultTarget(target_out); } +Result GetAudioOutputMode(AudioOutputMode* mode_out, AudioTarget target) { return ::audctlGetAudioOutputMode(mode_out, target); } +Result SetAudioOutputMode(AudioTarget target, AudioOutputMode mode) { return ::audctlSetAudioOutputMode(target, mode); } +Result SetForceMutePolicy(AudioForceMutePolicy policy) { return ::audctlSetForceMutePolicy(policy); } +Result GetForceMutePolicy(AudioForceMutePolicy* policy_out) { return ::audctlGetForceMutePolicy(policy_out); } +Result GetOutputModeSetting(AudioOutputMode* mode_out, AudioTarget target) { return ::audctlGetOutputModeSetting(mode_out, target); } +Result SetOutputModeSetting(AudioTarget target, AudioOutputMode mode) { return ::audctlSetOutputModeSetting(target, mode); } +Result SetOutputTarget(AudioTarget target) { return ::audctlSetOutputTarget(target); } +Result SetInputTargetForceEnabled(bool enable) { return ::audctlSetInputTargetForceEnabled(enable); } +Result SetHeadphoneOutputLevelMode(AudioHeadphoneOutputLevelMode mode) { return ::audctlSetHeadphoneOutputLevelMode(mode); } +Result GetHeadphoneOutputLevelMode(AudioHeadphoneOutputLevelMode* mode_out) { return ::audctlGetHeadphoneOutputLevelMode(mode_out); } +Result AcquireAudioVolumeUpdateEventForPlayReport(Event* event_out) { return ::audctlAcquireAudioVolumeUpdateEventForPlayReport(event_out); } +Result AcquireAudioOutputDeviceUpdateEventForPlayReport(Event* event_out) { return ::audctlAcquireAudioOutputDeviceUpdateEventForPlayReport(event_out); } +Result GetAudioOutputTargetForPlayReport(AudioTarget* target_out) { return ::audctlGetAudioOutputTargetForPlayReport(target_out); } +Result NotifyHeadphoneVolumeWarningDisplayedEvent(void) { return ::audctlNotifyHeadphoneVolumeWarningDisplayedEvent(); } +Result SetSystemOutputMasterVolume(float volume) { return ::audctlSetSystemOutputMasterVolume(volume); } +Result GetSystemOutputMasterVolume(float* volume_out) { return ::audctlGetSystemOutputMasterVolume(volume_out); } +Result GetActiveOutputTarget(AudioTarget* target) { return ::audctlGetActiveOutputTarget(target); } + +} // namespace audctl + +namespace audd { + +Result Initialize(void) { return ::auddInitialize(); } +void Exit(void) { ::auddExit(); } +Service* GetServiceSession(void) { return ::auddGetServiceSession(); } +Result RequestSuspendAudioForDebug(u64 pid, u64 delay) { return ::auddRequestSuspendAudioForDebug(pid, delay); } +Result RequestResumeAudioForDebug(u64 pid, u64 delay) { return ::auddRequestResumeAudioForDebug(pid, delay); } + +} // namespace audd + +namespace auddev { + +Result Initialize(void) { return ::auddevInitialize(); } +void Exit(void) { ::auddevExit(); } +Service* GetServiceSession(void) { return ::auddevGetServiceSession(); } +Result ListAudioDeviceName(AudioDeviceName *DeviceNames, s32 max_names, s32 *total_names) { return ::auddevListAudioDeviceName(DeviceNames, max_names, total_names); } +Result SetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float volume) { return ::auddevSetAudioDeviceOutputVolume(DeviceName, volume); } +Result GetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float *volume) { return ::auddevGetAudioDeviceOutputVolume(DeviceName, volume); } +Result GetActiveAudioDeviceName(AudioDeviceName *DeviceName) { return ::auddevGetActiveAudioDeviceName(DeviceName); } + +} // namespace auddev + +namespace audin { + +Result Initialize(void) { return ::audinInitialize(); } +void Exit(void) { ::audinExit(); } +Service* GetServiceSession(void) { return ::audinGetServiceSession(); } +Service* GetServiceSession_AudioIn(void) { return ::audinGetServiceSession_AudioIn(); } +Result ListAudioIns(char *DeviceNames, s32 count, u32 *DeviceNamesCount) { return ::audinListAudioIns(DeviceNames, count, DeviceNamesCount); } +Result OpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State) { return ::audinOpenAudioIn(DeviceNameIn, DeviceNameOut, SampleRateIn, ChannelCountIn, SampleRateOut, ChannelCountOut, Format, State); } +Result GetAudioInState(AudioInState *State) { return ::audinGetAudioInState(State); } +Result StartAudioIn(void) { return ::audinStartAudioIn(); } +Result StopAudioIn(void) { return ::audinStopAudioIn(); } +Result AppendAudioInBuffer(AudioInBuffer *Buffer) { return ::audinAppendAudioInBuffer(Buffer); } +Result GetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount) { return ::audinGetReleasedAudioInBuffer(Buffer, ReleasedBuffersCount); } +Result ContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer) { return ::audinContainsAudioInBuffer(Buffer, ContainsBuffer); } +Result CaptureBuffer(AudioInBuffer *source, AudioInBuffer **released) { return ::audinCaptureBuffer(source, released); } +Result WaitCaptureFinish(AudioInBuffer **released, u32* released_count, u64 timeout) { return ::audinWaitCaptureFinish(released, released_count, timeout); } +u32 GetSampleRate(void) { return ::audinGetSampleRate(); } +u32 GetChannelCount(void) { return ::audinGetChannelCount(); } +PcmFormat GetPcmFormat(void) { return ::audinGetPcmFormat(); } +AudioInState GetDeviceState(void) { return ::audinGetDeviceState(); } + +} // namespace audin + +namespace audout { + +Result Initialize(void) { return ::audoutInitialize(); } +void Exit(void) { ::audoutExit(); } +Service* GetServiceSession(void) { return ::audoutGetServiceSession(); } +Service* GetServiceSession_AudioOut(void) { return ::audoutGetServiceSession_AudioOut(); } +Result ListAudioOuts(char *DeviceNames, s32 count, u32 *DeviceNamesCount) { return ::audoutListAudioOuts(DeviceNames, count, DeviceNamesCount); } +Result OpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State) { return ::audoutOpenAudioOut(DeviceNameIn, DeviceNameOut, SampleRateIn, ChannelCountIn, SampleRateOut, ChannelCountOut, Format, State); } +Result GetAudioOutState(AudioOutState *State) { return ::audoutGetAudioOutState(State); } +Result StartAudioOut(void) { return ::audoutStartAudioOut(); } +Result StopAudioOut(void) { return ::audoutStopAudioOut(); } +Result AppendAudioOutBuffer(AudioOutBuffer *Buffer) { return ::audoutAppendAudioOutBuffer(Buffer); } +Result GetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount) { return ::audoutGetReleasedAudioOutBuffer(Buffer, ReleasedBuffersCount); } +Result ContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer) { return ::audoutContainsAudioOutBuffer(Buffer, ContainsBuffer); } +Result GetAudioOutBufferCount(u32 *count) { return ::audoutGetAudioOutBufferCount(count); } +Result GetAudioOutPlayedSampleCount(u64 *count) { return ::audoutGetAudioOutPlayedSampleCount(count); } +Result FlushAudioOutBuffers(bool *flushed) { return ::audoutFlushAudioOutBuffers(flushed); } +Result SetAudioOutVolume(float volume) { return ::audoutSetAudioOutVolume(volume); } +Result GetAudioOutVolume(float *volume) { return ::audoutGetAudioOutVolume(volume); } +Result PlayBuffer(AudioOutBuffer *source, AudioOutBuffer **released) { return ::audoutPlayBuffer(source, released); } +Result WaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout) { return ::audoutWaitPlayFinish(released, released_count, timeout); } +u32 GetSampleRate(void) { return ::audoutGetSampleRate(); } +u32 GetChannelCount(void) { return ::audoutGetChannelCount(); } +PcmFormat GetPcmFormat(void) { return ::audoutGetPcmFormat(); } +AudioOutState GetDeviceState(void) { return ::audoutGetDeviceState(); } + +} // namespace audout + +namespace audouta { + +Result Initialize(void) { return ::audoutaInitialize(); } +void Exit(void) { ::audoutaExit(); } +Service* GetServiceSession(void) { return ::audoutaGetServiceSession(); } +Result RequestSuspend(u64 pid, u64 delay) { return ::audoutaRequestSuspend(pid, delay); } +Result RequestResume(u64 pid, u64 delay) { return ::audoutaRequestResume(pid, delay); } +Result GetProcessMasterVolume(u64 pid, float* volume_out) { return ::audoutaGetProcessMasterVolume(pid, volume_out); } +Result SetProcessMasterVolume(u64 pid, u64 delay, float volume) { return ::audoutaSetProcessMasterVolume(pid, delay, volume); } +Result GetProcessRecordVolume(u64 pid, float* volume_out) { return ::audoutaGetProcessRecordVolume(pid, volume_out); } +Result SetProcessRecordVolume(u64 pid, u64 delay, float volume) { return ::audoutaSetProcessRecordVolume(pid, delay, volume); } + +} // namespace audouta + +namespace audoutd { + +Result Initialize(void) { return ::audoutdInitialize(); } +void Exit(void) { ::audoutdExit(); } +Service* GetServiceSession(void) { return ::audoutdGetServiceSession(); } +Result RequestSuspendForDebug(u64 pid, u64 delay) { return ::audoutdRequestSuspendForDebug(pid, delay); } +Result RequestResumeForDebug(u64 pid, u64 delay) { return ::audoutdRequestResumeForDebug(pid, delay); } + +} // namespace audoutd + +namespace audrec { + +Result Initialize(void) { return ::audrecInitialize(); } +void Exit(void) { ::audrecExit(); } +Service* GetServiceSession(void) { return ::audrecGetServiceSession(); } +Result OpenFinalOutputRecorder(AudrecRecorder* recorder_out, FinalOutputRecorderParameter* param_in, u64 aruid, FinalOutputRecorderParameterInternal* param_out) { return ::audrecOpenFinalOutputRecorder(recorder_out, param_in, aruid, param_out); } +Result RecorderStart(AudrecRecorder* recorder) { return ::audrecRecorderStart(recorder); } +Result RecorderStop(AudrecRecorder* recorder) { return ::audrecRecorderStop(recorder); } +Result RecorderRegisterBufferEvent(AudrecRecorder* recorder, Event* out_event) { return ::audrecRecorderRegisterBufferEvent(recorder, out_event); } +Result RecorderAppendFinalOutputRecorderBuffer(AudrecRecorder* recorder, u64 buffer_client_ptr, FinalOutputRecorderBuffer* param) { return ::audrecRecorderAppendFinalOutputRecorderBuffer(recorder, buffer_client_ptr, param); } +Result RecorderGetReleasedFinalOutputRecorderBuffers(AudrecRecorder* recorder, u64* out_buffers, u64* inout_count, u64* out_released) { return ::audrecRecorderGetReleasedFinalOutputRecorderBuffers(recorder, out_buffers, inout_count, out_released); } +void RecorderClose(AudrecRecorder* recorder) { ::audrecRecorderClose(recorder); } + +} // namespace audrec + +namespace audren { + +u32 GetRevision(void) { return ::audrenGetRevision(); } +int GetMemPoolCount(const AudioRendererConfig* config) { return ::audrenGetMemPoolCount(config); } +size_t GetInputParamSize(const AudioRendererConfig* config) { return ::audrenGetInputParamSize(config); } +size_t GetOutputParamSize(const AudioRendererConfig* config) { return ::audrenGetOutputParamSize(config); } +Result Initialize(const AudioRendererConfig* config) { return ::audrenInitialize(config); } +void Exit(void) { ::audrenExit(); } +Service* GetServiceSession_AudioRenderer(void) { return ::audrenGetServiceSession_AudioRenderer(); } +Event* GetFrameEvent(void) { return ::audrenGetFrameEvent(); } +void WaitFrame(void) { ::audrenWaitFrame(); } +Result GetState(u32* out_state) { return ::audrenGetState(out_state); } +Result RequestUpdateAudioRenderer(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) { return ::audrenRequestUpdateAudioRenderer(in_param_buf, in_param_buf_size, out_param_buf, out_param_buf_size, perf_buf, perf_buf_size); } +Result StartAudioRenderer(void) { return ::audrenStartAudioRenderer(); } +Result StopAudioRenderer(void) { return ::audrenStopAudioRenderer(); } +Result SetAudioRendererRenderingTimeLimit(int percent) { return ::audrenSetAudioRendererRenderingTimeLimit(percent); } + +} // namespace audren + +namespace audrv { + +Result Create(AudioDriver* d, const AudioRendererConfig* config, int num_final_mix_channels) { return ::audrvCreate(d, config, num_final_mix_channels); } +Result Update(AudioDriver* d) { return ::audrvUpdate(d); } +void Close(AudioDriver* d) { ::audrvClose(d); } +int MemPoolAdd(AudioDriver* d, void* buffer, size_t size) { return ::audrvMemPoolAdd(d, buffer, size); } +bool MemPoolRemove(AudioDriver* d, int id) { return ::audrvMemPoolRemove(d, id); } +bool MemPoolAttach(AudioDriver* d, int id) { return ::audrvMemPoolAttach(d, id); } +bool MemPoolDetach(AudioDriver* d, int id) { return ::audrvMemPoolDetach(d, id); } +bool VoiceInit(AudioDriver* d, int id, int num_channels, PcmFormat format, int sample_rate) { return ::audrvVoiceInit(d, id, num_channels, format, sample_rate); } +void VoiceDrop(AudioDriver* d, int id) { ::audrvVoiceDrop(d, id); } +void VoiceStop(AudioDriver* d, int id) { ::audrvVoiceStop(d, id); } +bool VoiceIsPaused(AudioDriver* d, int id) { return ::audrvVoiceIsPaused(d, id); } +bool VoiceIsPlaying(AudioDriver* d, int id) { return ::audrvVoiceIsPlaying(d, id); } +bool VoiceAddWaveBuf(AudioDriver* d, int id, AudioDriverWaveBuf* wavebuf) { return ::audrvVoiceAddWaveBuf(d, id, wavebuf); } +u32 VoiceGetWaveBufSeq(AudioDriver* d, int id) { return ::audrvVoiceGetWaveBufSeq(d, id); } +u32 VoiceGetPlayedSampleCount(AudioDriver* d, int id) { return ::audrvVoiceGetPlayedSampleCount(d, id); } +u32 VoiceGetVoiceDropsCount(AudioDriver* d, int id) { return ::audrvVoiceGetVoiceDropsCount(d, id); } +void VoiceSetBiquadFilter(AudioDriver* d, int id, int biquad_id, float a0, float a1, float a2, float b0, float b1, float b2) { ::audrvVoiceSetBiquadFilter(d, id, biquad_id, a0, a1, a2, b0, b1, b2); } +void VoiceSetExtraParams(AudioDriver* d, int id, const void* params, size_t params_size) { ::audrvVoiceSetExtraParams(d, id, params, params_size); } +void VoiceSetDestinationMix(AudioDriver* d, int id, int mix_id) { ::audrvVoiceSetDestinationMix(d, id, mix_id); } +void VoiceSetMixFactor(AudioDriver* d, int id, float factor, int src_channel_id, int dest_channel_id) { ::audrvVoiceSetMixFactor(d, id, factor, src_channel_id, dest_channel_id); } +void VoiceSetVolume(AudioDriver* d, int id, float volume) { ::audrvVoiceSetVolume(d, id, volume); } +void VoiceSetPitch(AudioDriver* d, int id, float pitch) { ::audrvVoiceSetPitch(d, id, pitch); } +void VoiceSetPriority(AudioDriver* d, int id, int priority) { ::audrvVoiceSetPriority(d, id, priority); } +void VoiceClearBiquadFilter(AudioDriver* d, int id, int biquad_id) { ::audrvVoiceClearBiquadFilter(d, id, biquad_id); } +void VoiceSetPaused(AudioDriver* d, int id, bool paused) { ::audrvVoiceSetPaused(d, id, paused); } +void VoiceStart(AudioDriver* d, int id) { ::audrvVoiceStart(d, id); } +int MixAdd(AudioDriver* d, int sample_rate, int num_channels) { return ::audrvMixAdd(d, sample_rate, num_channels); } +void MixRemove(AudioDriver* d, int id) { ::audrvMixRemove(d, id); } +void MixSetDestinationMix(AudioDriver* d, int id, int mix_id) { ::audrvMixSetDestinationMix(d, id, mix_id); } +void MixSetMixFactor(AudioDriver* d, int id, float factor, int src_channel_id, int dest_channel_id) { ::audrvMixSetMixFactor(d, id, factor, src_channel_id, dest_channel_id); } +void MixSetVolume(AudioDriver* d, int id, float volume) { ::audrvMixSetVolume(d, id, volume); } +int DeviceSinkAdd(AudioDriver* d, const char* device_name, int num_channels, const u8* channel_ids) { return ::audrvDeviceSinkAdd(d, device_name, num_channels, channel_ids); } +void SinkRemove(AudioDriver* d, int id) { ::audrvSinkRemove(d, id); } + +} // namespace audrv + +namespace avm { + +Result Initialize(void) { return ::avmInitialize(); } +void Exit(void) { ::avmExit(); } +Service * GetServiceSession(void) { return ::avmGetServiceSession(); } +Result GetHighestAvailableVersion(u64 id_1, u64 id_2, u32 *version) { return ::avmGetHighestAvailableVersion(id_1, id_2, version); } +Result GetHighestRequiredVersion(u64 id_1, u64 id_2, u32 *version) { return ::avmGetHighestRequiredVersion(id_1, id_2, version); } +Result GetVersionListEntry(u64 application_id, AvmVersionListEntry *entry) { return ::avmGetVersionListEntry(application_id, entry); } +Result GetVersionListImporter(AvmVersionListImporter *out) { return ::avmGetVersionListImporter(out); } +Result GetLaunchRequiredVersion(u64 application_id, u32 *version) { return ::avmGetLaunchRequiredVersion(application_id, version); } +Result UpgradeLaunchRequiredVersion(u64 application_id, u32 version) { return ::avmUpgradeLaunchRequiredVersion(application_id, version); } +Result PushLaunchVersion(u64 application_id, u32 version) { return ::avmPushLaunchVersion(application_id, version); } +Result ListVersionList(AvmVersionListEntry *buffer, size_t count, u32 *out) { return ::avmListVersionList(buffer, count, out); } +Result ListRequiredVersion(AvmRequiredVersionEntry *buffer, size_t count, u32 *out) { return ::avmListRequiredVersion(buffer, count, out); } +void VersionListImporterClose(AvmVersionListImporter *srv) { ::avmVersionListImporterClose(srv); } +Result VersionListImporterSetTimestamp(AvmVersionListImporter *srv, u64 timestamp) { return ::avmVersionListImporterSetTimestamp(srv, timestamp); } +Result VersionListImporterSetData(AvmVersionListImporter *srv, const AvmVersionListEntry *entries, u32 count) { return ::avmVersionListImporterSetData(srv, entries, count); } +Result VersionListImporterFlush(AvmVersionListImporter *srv) { return ::avmVersionListImporterFlush(srv); } + +} // namespace avm + +namespace barrier { + +void Init(Barrier *b, u64 thread_count) { ::barrierInit(b, thread_count); } +void Wait(Barrier *b) { ::barrierWait(b); } + +} // namespace barrier + +namespace binder { + +void Create(Binder* b, s32 id) { ::binderCreate(b, id); } +void Close(Binder* b) { ::binderClose(b); } +Result InitSession(Binder* b, Service* relay) { return ::binderInitSession(b, relay); } +Result TransactParcel(Binder* b, u32 code, void* parcel_data, size_t parcel_data_size, void* parcel_reply, size_t parcel_reply_size, u32 flags) { return ::binderTransactParcel(b, code, parcel_data, parcel_data_size, parcel_reply, parcel_reply_size, flags); } +Result ConvertErrorCode(s32 code) { return ::binderConvertErrorCode(code); } +Result AdjustRefcount(Binder* b, s32 addval, s32 type) { return ::binderAdjustRefcount(b, addval, type); } +Result GetNativeHandle(Binder* b, u32 unk0, Event *event_out) { return ::binderGetNativeHandle(b, unk0, event_out); } +Result IncreaseWeakRef(Binder* b) { return ::binderIncreaseWeakRef(b); } +Result DecreaseWeakRef(Binder* b) { return ::binderDecreaseWeakRef(b); } +Result IncreaseStrongRef(Binder* b) { return ::binderIncreaseStrongRef(b); } +Result DecreaseStrongRef(Binder* b) { return ::binderDecreaseStrongRef(b); } + +} // namespace binder + +namespace bpc { + +Result Initialize(void) { return ::bpcInitialize(); } +void Exit(void) { ::bpcExit(); } +Service* GetServiceSession(void) { return ::bpcGetServiceSession(); } +Result ShutdownSystem(void) { return ::bpcShutdownSystem(); } +Result RebootSystem(void) { return ::bpcRebootSystem(); } +Result GetSleepButtonState(BpcSleepButtonState *out) { return ::bpcGetSleepButtonState(out); } +Result GetPowerButton(bool* out_is_pushed) { return ::bpcGetPowerButton(out_is_pushed); } + +} // namespace bpc + +namespace bq { + +Result RequestBuffer(Binder *b, s32 bufferIdx, BqGraphicBuffer *buf) { return ::bqRequestBuffer(b, bufferIdx, buf); } +Result DequeueBuffer(Binder *b, bool async, u32 width, u32 height, s32 format, u32 usage, s32 *buf, NvMultiFence *fence) { return ::bqDequeueBuffer(b, async, width, height, format, usage, buf, fence); } +Result DetachBuffer(Binder *b, s32 slot) { return ::bqDetachBuffer(b, slot); } +Result QueueBuffer(Binder *b, s32 buf, const BqBufferInput *input, BqBufferOutput *output) { return ::bqQueueBuffer(b, buf, input, output); } +Result CancelBuffer(Binder *b, s32 buf, const NvMultiFence *fence) { return ::bqCancelBuffer(b, buf, fence); } +Result Query(Binder *b, s32 what, s32* value) { return ::bqQuery(b, what, value); } +Result Connect(Binder *b, s32 api, bool producerControlledByApp, BqBufferOutput *output) { return ::bqConnect(b, api, producerControlledByApp, output); } +Result Disconnect(Binder *b, s32 api) { return ::bqDisconnect(b, api); } +Result SetPreallocatedBuffer(Binder *b, s32 buf, const BqGraphicBuffer *input) { return ::bqSetPreallocatedBuffer(b, buf, input); } + +} // namespace bq + +namespace bt { + +Result Initialize(void) { return ::btInitialize(); } +void Exit(void) { ::btExit(); } +Service* GetServiceSession(void) { return ::btGetServiceSession(); } +Result LeClientReadCharacteristic(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, u8 auth_req) { return ::btLeClientReadCharacteristic(connection_handle, is_primary, serv_id, char_id, auth_req); } +Result LeClientReadDescriptor(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, u8 auth_req) { return ::btLeClientReadDescriptor(connection_handle, is_primary, serv_id, char_id, desc_id, auth_req); } +Result LeClientWriteCharacteristic(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) { return ::btLeClientWriteCharacteristic(connection_handle, is_primary, serv_id, char_id, buffer, size, auth_req, with_response); } +Result LeClientWriteDescriptor(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) { return ::btLeClientWriteDescriptor(connection_handle, is_primary, serv_id, char_id, desc_id, buffer, size, auth_req); } +Result LeClientRegisterNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id) { return ::btLeClientRegisterNotification(connection_handle, is_primary, serv_id, char_id); } +Result LeClientDeregisterNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id) { return ::btLeClientDeregisterNotification(connection_handle, is_primary, serv_id, char_id); } +Result SetLeResponse(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *char_uuid, const void* buffer, size_t size) { return ::btSetLeResponse(server_if, serv_uuid, char_uuid, buffer, size); } +Result LeSendIndication(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *char_uuid, const void* buffer, size_t size, bool noconfirm) { return ::btLeSendIndication(server_if, serv_uuid, char_uuid, buffer, size, noconfirm); } +Result GetLeEventInfo(void* buffer, size_t size, BtdrvBleEventType *type) { return ::btGetLeEventInfo(buffer, size, type); } +Result RegisterBleEvent(Event* out_event) { return ::btRegisterBleEvent(out_event); } + +} // namespace bt + +namespace btdev { + +Result Initialize(void) { return ::btdevInitialize(); } +void Exit(void) { ::btdevExit(); } +bool GattAttributeUuidIsSame(const BtdrvGattAttributeUuid *a, const BtdrvGattAttributeUuid *b) { return ::btdevGattAttributeUuidIsSame(a, b); } +Result AcquireBleScanEvent(Event* out_event) { return ::btdevAcquireBleScanEvent(out_event); } +Result GetBleScanParameter(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out) { return ::btdevGetBleScanParameter(parameter_id, out); } +Result GetBleScanParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out) { return ::btdevGetBleScanParameter2(parameter_id, out); } +Result StartBleScanGeneral(BtdrvBleAdvertisePacketParameter param) { return ::btdevStartBleScanGeneral(param); } +Result StopBleScanGeneral(void) { return ::btdevStopBleScanGeneral(); } +Result GetBleScanResult(BtdrvBleScanResult *results, u8 count, u8 *total_out) { return ::btdevGetBleScanResult(results, count, total_out); } +Result EnableBleAutoConnection(BtdrvBleAdvertisePacketParameter param) { return ::btdevEnableBleAutoConnection(param); } +Result DisableBleAutoConnection(void) { return ::btdevDisableBleAutoConnection(); } +Result StartBleScanSmartDevice(const BtdrvGattAttributeUuid *uuid) { return ::btdevStartBleScanSmartDevice(uuid); } +Result StopBleScanSmartDevice(void) { return ::btdevStopBleScanSmartDevice(); } +Result AcquireBleConnectionStateChangedEvent(Event* out_event) { return ::btdevAcquireBleConnectionStateChangedEvent(out_event); } +Result ConnectToGattServer(BtdrvAddress addr) { return ::btdevConnectToGattServer(addr); } +Result DisconnectFromGattServer(u32 connection_handle) { return ::btdevDisconnectFromGattServer(connection_handle); } +Result GetBleConnectionInfoList(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out) { return ::btdevGetBleConnectionInfoList(info, count, total_out); } +Result AcquireBleServiceDiscoveryEvent(Event* out_event) { return ::btdevAcquireBleServiceDiscoveryEvent(out_event); } +Result GetGattServices(u32 connection_handle, BtdevGattService *services, u8 count, u8 *total_out) { return ::btdevGetGattServices(connection_handle, services, count, total_out); } +Result GetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtdevGattService *service, bool *flag) { return ::btdevGetGattService(connection_handle, uuid, service, flag); } +Result AcquireBlePairingEvent(Event* out_event) { return ::btdevAcquireBlePairingEvent(out_event); } +Result PairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param) { return ::btdevPairGattServer(connection_handle, param); } +Result UnpairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param) { return ::btdevUnpairGattServer(connection_handle, param); } +Result UnpairGattServer2(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param) { return ::btdevUnpairGattServer2(addr, param); } +Result GetPairedGattServerAddress(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out) { return ::btdevGetPairedGattServerAddress(param, addrs, count, total_out); } +Result AcquireBleMtuConfigEvent(Event* out_event) { return ::btdevAcquireBleMtuConfigEvent(out_event); } +Result ConfigureBleMtu(u32 connection_handle, u16 mtu) { return ::btdevConfigureBleMtu(connection_handle, mtu); } +Result GetBleMtu(u32 connection_handle, u16 *out) { return ::btdevGetBleMtu(connection_handle, out); } +Result AcquireBleGattOperationEvent(Event* out_event) { return ::btdevAcquireBleGattOperationEvent(out_event); } +Result RegisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid) { return ::btdevRegisterGattOperationNotification(uuid); } +Result UnregisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid) { return ::btdevUnregisterGattOperationNotification(uuid); } +Result GetGattOperationResult(BtdrvBleClientGattOperationInfo *out) { return ::btdevGetGattOperationResult(out); } +Result ReadGattCharacteristic(BtdevGattCharacteristic *c) { return ::btdevReadGattCharacteristic(c); } +Result WriteGattCharacteristic(BtdevGattCharacteristic *c) { return ::btdevWriteGattCharacteristic(c); } +Result EnableGattCharacteristicNotification(BtdevGattCharacteristic *c, bool flag) { return ::btdevEnableGattCharacteristicNotification(c, flag); } +Result ReadGattDescriptor(BtdevGattDescriptor *d) { return ::btdevReadGattDescriptor(d); } +Result WriteGattDescriptor(BtdevGattDescriptor *d) { return ::btdevWriteGattDescriptor(d); } +void GattAttributeCreate(BtdevGattAttribute *a, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle) { ::btdevGattAttributeCreate(a, uuid, handle, connection_handle); } +u8 GattAttributeGetType(BtdevGattAttribute *a) { return ::btdevGattAttributeGetType(a); } +void GattAttributeGetUuid(BtdevGattAttribute *a, BtdrvGattAttributeUuid *out) { ::btdevGattAttributeGetUuid(a, out); } +u16 GattAttributeGetHandle(BtdevGattAttribute *a) { return ::btdevGattAttributeGetHandle(a); } +u32 GattAttributeGetConnectionHandle(BtdevGattAttribute *a) { return ::btdevGattAttributeGetConnectionHandle(a); } +void GattServiceCreate(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u16 end_group_handle, bool primary_service) { ::btdevGattServiceCreate(s, uuid, handle, connection_handle, instance_id, end_group_handle, primary_service); } +u16 GattServiceGetInstanceId(BtdevGattService *s) { return ::btdevGattServiceGetInstanceId(s); } +u16 GattServiceGetEndGroupHandle(BtdevGattService *s) { return ::btdevGattServiceGetEndGroupHandle(s); } +u16 GattServiceIsPrimaryService(BtdevGattService *s) { return ::btdevGattServiceIsPrimaryService(s); } +Result GattServiceGetIncludedServices(BtdevGattService *s, BtdevGattService *services, u8 count, u8 *total_out) { return ::btdevGattServiceGetIncludedServices(s, services, count, total_out); } +Result GattServiceGetCharacteristics(BtdevGattService *s, BtdevGattCharacteristic *characteristics, u8 count, u8 *total_out) { return ::btdevGattServiceGetCharacteristics(s, characteristics, count, total_out); } +Result GattServiceGetCharacteristic(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, BtdevGattCharacteristic *characteristic, bool *flag) { return ::btdevGattServiceGetCharacteristic(s, uuid, characteristic, flag); } +void GattCharacteristicCreate(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u8 properties) { ::btdevGattCharacteristicCreate(c, uuid, handle, connection_handle, instance_id, properties); } +u16 GattCharacteristicGetInstanceId(BtdevGattCharacteristic *c) { return ::btdevGattCharacteristicGetInstanceId(c); } +u8 GattCharacteristicGetProperties(BtdevGattCharacteristic *c) { return ::btdevGattCharacteristicGetProperties(c); } +Result GattCharacteristicGetService(BtdevGattCharacteristic *c, BtdevGattService *service) { return ::btdevGattCharacteristicGetService(c, service); } +Result GattCharacteristicGetDescriptors(BtdevGattCharacteristic *c, BtdevGattDescriptor *descriptors, u8 count, u8 *total_out) { return ::btdevGattCharacteristicGetDescriptors(c, descriptors, count, total_out); } +Result GattCharacteristicGetDescriptor(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, BtdevGattDescriptor *descriptor, bool *flag) { return ::btdevGattCharacteristicGetDescriptor(c, uuid, descriptor, flag); } +void GattCharacteristicSetValue(BtdevGattCharacteristic *c, const void* buffer, size_t size) { ::btdevGattCharacteristicSetValue(c, buffer, size); } +u64 GattCharacteristicGetValue(BtdevGattCharacteristic *c, void* buffer, size_t size) { return ::btdevGattCharacteristicGetValue(c, buffer, size); } +void GattDescriptorCreate(BtdevGattDescriptor *d, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle) { ::btdevGattDescriptorCreate(d, uuid, handle, connection_handle); } +Result GattDescriptorGetService(BtdevGattDescriptor *d, BtdevGattService *service) { return ::btdevGattDescriptorGetService(d, service); } +Result GattDescriptorGetCharacteristic(BtdevGattDescriptor *d, BtdevGattCharacteristic *characteristic) { return ::btdevGattDescriptorGetCharacteristic(d, characteristic); } +void GattDescriptorSetValue(BtdevGattDescriptor *d, const void* buffer, size_t size) { ::btdevGattDescriptorSetValue(d, buffer, size); } +u64 GattDescriptorGetValue(BtdevGattDescriptor *d, void* buffer, size_t size) { return ::btdevGattDescriptorGetValue(d, buffer, size); } + +} // namespace btdev + +namespace btdrv { + +Result Initialize(void) { return ::btdrvInitialize(); } +void Exit(void) { ::btdrvExit(); } +Service* GetServiceSession(void) { return ::btdrvGetServiceSession(); } +Result InitializeBluetooth(Event* out_event) { return ::btdrvInitializeBluetooth(out_event); } +Result EnableBluetooth(void) { return ::btdrvEnableBluetooth(); } +Result DisableBluetooth(void) { return ::btdrvDisableBluetooth(); } +Result FinalizeBluetooth(void) { return ::btdrvFinalizeBluetooth(); } +Result LegacyGetAdapterProperties(BtdrvAdapterPropertyOld *properties) { return ::btdrvLegacyGetAdapterProperties(properties); } +Result GetAdapterProperties(BtdrvAdapterPropertySet *properties) { return ::btdrvGetAdapterProperties(properties); } +Result LegacyGetAdapterProperty(BtdrvBluetoothPropertyType type, void* buffer, size_t size) { return ::btdrvLegacyGetAdapterProperty(type, buffer, size); } +Result GetAdapterProperty(BtdrvAdapterPropertyType type, BtdrvAdapterProperty *property) { return ::btdrvGetAdapterProperty(type, property); } +Result LegacySetAdapterProperty(BtdrvBluetoothPropertyType type, const void* buffer, size_t size) { return ::btdrvLegacySetAdapterProperty(type, buffer, size); } +Result SetAdapterProperty(BtdrvAdapterPropertyType type, const BtdrvAdapterProperty *property) { return ::btdrvSetAdapterProperty(type, property); } +Result LegacyStartInquiry(void) { return ::btdrvLegacyStartInquiry(); } +Result StartInquiry(u32 services, s64 duration) { return ::btdrvStartInquiry(services, duration); } +Result StopInquiry(void) { return ::btdrvStopInquiry(); } +Result CreateBond(BtdrvAddress addr, u32 type) { return ::btdrvCreateBond(addr, type); } +Result RemoveBond(BtdrvAddress addr) { return ::btdrvRemoveBond(addr); } +Result CancelBond(BtdrvAddress addr) { return ::btdrvCancelBond(addr); } +Result LegacyRespondToPinRequest(BtdrvAddress addr, bool flag, const BtdrvBluetoothPinCode *pin_code, u8 length) { return ::btdrvLegacyRespondToPinRequest(addr, flag, pin_code, length); } +Result RespondToPinRequest(BtdrvAddress addr, const BtdrvPinCode *pin_code) { return ::btdrvRespondToPinRequest(addr, pin_code); } +Result RespondToSspRequest(BtdrvAddress addr, u32 variant, bool accept, u32 passkey) { return ::btdrvRespondToSspRequest(addr, variant, accept, passkey); } +Result GetEventInfo(void* buffer, size_t size, BtdrvEventType *type) { return ::btdrvGetEventInfo(buffer, size, type); } +Result InitializeHid(Event* out_event) { return ::btdrvInitializeHid(out_event); } +Result OpenHidConnection(BtdrvAddress addr) { return ::btdrvOpenHidConnection(addr); } +Result CloseHidConnection(BtdrvAddress addr) { return ::btdrvCloseHidConnection(addr); } +Result WriteHidData(BtdrvAddress addr, const BtdrvHidReport *buffer) { return ::btdrvWriteHidData(addr, buffer); } +Result WriteHidData2(BtdrvAddress addr, const void* buffer, size_t size) { return ::btdrvWriteHidData2(addr, buffer, size); } +Result SetHidReport(BtdrvAddress addr, BtdrvBluetoothHhReportType type, const BtdrvHidReport *buffer) { return ::btdrvSetHidReport(addr, type, buffer); } +Result GetHidReport(BtdrvAddress addr, u8 report_id, BtdrvBluetoothHhReportType type) { return ::btdrvGetHidReport(addr, report_id, type); } +Result TriggerConnection(BtdrvAddress addr, u16 timeout) { return ::btdrvTriggerConnection(addr, timeout); } +Result AddPairedDeviceInfo(const SetSysBluetoothDevicesSettings *settings) { return ::btdrvAddPairedDeviceInfo(settings); } +Result GetPairedDeviceInfo(BtdrvAddress addr, SetSysBluetoothDevicesSettings *settings) { return ::btdrvGetPairedDeviceInfo(addr, settings); } +Result FinalizeHid(void) { return ::btdrvFinalizeHid(); } +Result GetHidEventInfo(void* buffer, size_t size, BtdrvHidEventType *type) { return ::btdrvGetHidEventInfo(buffer, size, type); } +Result SetTsi(BtdrvAddress addr, u8 tsi) { return ::btdrvSetTsi(addr, tsi); } +Result EnableBurstMode(BtdrvAddress addr, bool flag) { return ::btdrvEnableBurstMode(addr, flag); } +Result SetZeroRetransmission(BtdrvAddress addr, u8 *report_ids, u8 count) { return ::btdrvSetZeroRetransmission(addr, report_ids, count); } +Result EnableMcMode(bool flag) { return ::btdrvEnableMcMode(flag); } +Result EnableLlrScan(void) { return ::btdrvEnableLlrScan(); } +Result DisableLlrScan(void) { return ::btdrvDisableLlrScan(); } +Result EnableRadio(bool flag) { return ::btdrvEnableRadio(flag); } +Result SetVisibility(bool inquiry_scan, bool page_scan) { return ::btdrvSetVisibility(inquiry_scan, page_scan); } +Result EnableTbfcScan(bool flag) { return ::btdrvEnableTbfcScan(flag); } +Result RegisterHidReportEvent(Event* out_event) { return ::btdrvRegisterHidReportEvent(out_event); } +Result GetHidReportEventInfo(void* buffer, size_t size, BtdrvHidEventType *type) { return ::btdrvGetHidReportEventInfo(buffer, size, type); } +void* GetHidReportEventInfoSharedmemAddr(void) { return ::btdrvGetHidReportEventInfoSharedmemAddr(); } +Result GetLatestPlr(BtdrvPlrList *out) { return ::btdrvGetLatestPlr(out); } +Result GetPendingConnections(void) { return ::btdrvGetPendingConnections(); } +Result GetChannelMap(BtdrvChannelMapList *out) { return ::btdrvGetChannelMap(out); } +Result EnableTxPowerBoostSetting(bool flag) { return ::btdrvEnableTxPowerBoostSetting(flag); } +Result IsTxPowerBoostSettingEnabled(bool *out) { return ::btdrvIsTxPowerBoostSettingEnabled(out); } +Result EnableAfhSetting(bool flag) { return ::btdrvEnableAfhSetting(flag); } +Result IsAfhSettingEnabled(bool *out) { return ::btdrvIsAfhSettingEnabled(out); } +Result InitializeBle(Event* out_event) { return ::btdrvInitializeBle(out_event); } +Result EnableBle(void) { return ::btdrvEnableBle(); } +Result DisableBle(void) { return ::btdrvDisableBle(); } +Result FinalizeBle(void) { return ::btdrvFinalizeBle(); } +Result SetBleVisibility(bool discoverable, bool connectable) { return ::btdrvSetBleVisibility(discoverable, connectable); } +Result SetLeConnectionParameter(const BtdrvLeConnectionParams *param) { return ::btdrvSetLeConnectionParameter(param); } +Result SetBleConnectionParameter(BtdrvAddress addr, const BtdrvBleConnectionParameter *param, bool preference) { return ::btdrvSetBleConnectionParameter(addr, param, preference); } +Result SetLeDefaultConnectionParameter(const BtdrvLeConnectionParams *param) { return ::btdrvSetLeDefaultConnectionParameter(param); } +Result SetBleDefaultConnectionParameter(const BtdrvBleConnectionParameter *param) { return ::btdrvSetBleDefaultConnectionParameter(param); } +Result SetBleAdvertiseData(const BtdrvBleAdvertisePacketData *data) { return ::btdrvSetBleAdvertiseData(data); } +Result SetBleAdvertiseParameter(BtdrvAddress addr, u16 min_interval, u16 max_interval) { return ::btdrvSetBleAdvertiseParameter(addr, min_interval, max_interval); } +Result StartBleScan(void) { return ::btdrvStartBleScan(); } +Result StopBleScan(void) { return ::btdrvStopBleScan(); } +Result AddBleScanFilterCondition(const BtdrvBleAdvertiseFilter *filter) { return ::btdrvAddBleScanFilterCondition(filter); } +Result DeleteBleScanFilterCondition(const BtdrvBleAdvertiseFilter *filter) { return ::btdrvDeleteBleScanFilterCondition(filter); } +Result DeleteBleScanFilter(u8 index) { return ::btdrvDeleteBleScanFilter(index); } +Result ClearBleScanFilters(void) { return ::btdrvClearBleScanFilters(); } +Result EnableBleScanFilter(bool flag) { return ::btdrvEnableBleScanFilter(flag); } +Result RegisterGattClient(const BtdrvGattAttributeUuid *uuid) { return ::btdrvRegisterGattClient(uuid); } +Result UnregisterGattClient(u8 client_if) { return ::btdrvUnregisterGattClient(client_if); } +Result UnregisterAllGattClients(void) { return ::btdrvUnregisterAllGattClients(); } +Result ConnectGattServer(u8 client_if, BtdrvAddress addr, bool is_direct, u64 AppletResourceUserId) { return ::btdrvConnectGattServer(client_if, addr, is_direct, AppletResourceUserId); } +Result CancelConnectGattServer(u8 client_if, BtdrvAddress addr, bool is_direct) { return ::btdrvCancelConnectGattServer(client_if, addr, is_direct); } +Result DisconnectGattServer(u32 conn_id) { return ::btdrvDisconnectGattServer(conn_id); } +Result GetGattAttribute(BtdrvAddress addr, u32 conn_id) { return ::btdrvGetGattAttribute(addr, conn_id); } +Result GetGattService(u32 conn_id, const BtdrvGattAttributeUuid *uuid) { return ::btdrvGetGattService(conn_id, uuid); } +Result ConfigureAttMtu(u32 conn_id, u16 mtu) { return ::btdrvConfigureAttMtu(conn_id, mtu); } +Result RegisterGattServer(const BtdrvGattAttributeUuid *uuid) { return ::btdrvRegisterGattServer(uuid); } +Result UnregisterGattServer(u8 server_if) { return ::btdrvUnregisterGattServer(server_if); } +Result ConnectGattClient(u8 server_if, BtdrvAddress addr, bool is_direct) { return ::btdrvConnectGattClient(server_if, addr, is_direct); } +Result DisconnectGattClient(u8 conn_id, BtdrvAddress addr) { return ::btdrvDisconnectGattClient(conn_id, addr); } +Result AddGattService(u8 server_if, const BtdrvGattAttributeUuid *uuid, u8 num_handle, bool is_primary) { return ::btdrvAddGattService(server_if, uuid, num_handle, is_primary); } +Result EnableGattService(u8 server_if, const BtdrvGattAttributeUuid *uuid) { return ::btdrvEnableGattService(server_if, uuid); } +Result AddGattCharacteristic(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *char_uuid, u16 permissions, u8 property) { return ::btdrvAddGattCharacteristic(server_if, serv_uuid, char_uuid, permissions, property); } +Result AddGattDescriptor(u8 server_if, const BtdrvGattAttributeUuid *serv_uuid, const BtdrvGattAttributeUuid *desc_uuid, u16 permissions) { return ::btdrvAddGattDescriptor(server_if, serv_uuid, desc_uuid, permissions); } +Result GetBleManagedEventInfo(void* buffer, size_t size, BtdrvBleEventType *type) { return ::btdrvGetBleManagedEventInfo(buffer, size, type); } +Result GetGattFirstCharacteristic(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattAttributeUuid *filter_uuid, u8 *out_property, BtdrvGattId *out_char_id) { return ::btdrvGetGattFirstCharacteristic(conn_id, serv_id, is_primary, filter_uuid, out_property, out_char_id); } +Result GetGattNextCharacteristic(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattId *char_id, const BtdrvGattAttributeUuid *filter_uuid, u8 *out_property, BtdrvGattId *out_char_id) { return ::btdrvGetGattNextCharacteristic(conn_id, serv_id, is_primary, char_id, filter_uuid, out_property, out_char_id); } +Result GetGattFirstDescriptor(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattId *char_id, const BtdrvGattAttributeUuid *filter_uuid, BtdrvGattId *out_desc_id) { return ::btdrvGetGattFirstDescriptor(conn_id, serv_id, is_primary, char_id, filter_uuid, out_desc_id); } +Result GetGattNextDescriptor(u32 conn_id, const BtdrvGattId *serv_id, bool is_primary, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, const BtdrvGattAttributeUuid *filter_uuid, BtdrvGattId *out_desc_id) { return ::btdrvGetGattNextDescriptor(conn_id, serv_id, is_primary, char_id, desc_id, filter_uuid, out_desc_id); } +Result RegisterGattManagedDataPath(const BtdrvGattAttributeUuid *uuid) { return ::btdrvRegisterGattManagedDataPath(uuid); } +Result UnregisterGattManagedDataPath(const BtdrvGattAttributeUuid *uuid) { return ::btdrvUnregisterGattManagedDataPath(uuid); } +Result RegisterGattHidDataPath(const BtdrvGattAttributeUuid *uuid) { return ::btdrvRegisterGattHidDataPath(uuid); } +Result UnregisterGattHidDataPath(const BtdrvGattAttributeUuid *uuid) { return ::btdrvUnregisterGattHidDataPath(uuid); } +Result RegisterGattDataPath(const BtdrvGattAttributeUuid *uuid) { return ::btdrvRegisterGattDataPath(uuid); } +Result UnregisterGattDataPath(const BtdrvGattAttributeUuid *uuid) { return ::btdrvUnregisterGattDataPath(uuid); } +Result ReadGattCharacteristic(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, u8 auth_req) { return ::btdrvReadGattCharacteristic(connection_handle, is_primary, serv_id, char_id, auth_req); } +Result ReadGattDescriptor(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id, const BtdrvGattId *desc_id, u8 auth_req) { return ::btdrvReadGattDescriptor(connection_handle, is_primary, serv_id, char_id, desc_id, auth_req); } +Result WriteGattCharacteristic(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) { return ::btdrvWriteGattCharacteristic(connection_handle, is_primary, serv_id, char_id, buffer, size, auth_req, with_response); } +Result WriteGattDescriptor(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) { return ::btdrvWriteGattDescriptor(connection_handle, is_primary, serv_id, char_id, desc_id, buffer, size, auth_req); } +Result RegisterGattNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id) { return ::btdrvRegisterGattNotification(connection_handle, is_primary, serv_id, char_id); } +Result UnregisterGattNotification(u32 connection_handle, bool is_primary, const BtdrvGattId *serv_id, const BtdrvGattId *char_id) { return ::btdrvUnregisterGattNotification(connection_handle, is_primary, serv_id, char_id); } +Result GetLeHidEventInfo(void* buffer, size_t size, BtdrvBleEventType *type) { return ::btdrvGetLeHidEventInfo(buffer, size, type); } +Result RegisterBleHidEvent(Event* out_event) { return ::btdrvRegisterBleHidEvent(out_event); } +Result SetBleScanParameter(u16 scan_interval, u16 scan_window) { return ::btdrvSetBleScanParameter(scan_interval, scan_window); } +Result MoveToSecondaryPiconet(BtdrvAddress addr) { return ::btdrvMoveToSecondaryPiconet(addr); } +Result IsBluetoothEnabled(bool *out) { return ::btdrvIsBluetoothEnabled(out); } +Result AcquireAudioEvent(Event* out_event, bool autoclear) { return ::btdrvAcquireAudioEvent(out_event, autoclear); } +Result GetAudioEventInfo(void* buffer, size_t size, BtdrvAudioEventType *type) { return ::btdrvGetAudioEventInfo(buffer, size, type); } +Result OpenAudioConnection(BtdrvAddress addr) { return ::btdrvOpenAudioConnection(addr); } +Result CloseAudioConnection(BtdrvAddress addr) { return ::btdrvCloseAudioConnection(addr); } +Result OpenAudioOut(BtdrvAddress addr, u32 *audio_handle) { return ::btdrvOpenAudioOut(addr, audio_handle); } +Result CloseAudioOut(u32 audio_handle) { return ::btdrvCloseAudioOut(audio_handle); } +Result StartAudioOut(u32 audio_handle, const BtdrvPcmParameter *pcm_param, s64 in_latency, s64 *out_latency, u64 *out1) { return ::btdrvStartAudioOut(audio_handle, pcm_param, in_latency, out_latency, out1); } +Result StopAudioOut(u32 audio_handle) { return ::btdrvStopAudioOut(audio_handle); } +Result GetAudioOutState(u32 audio_handle, BtdrvAudioOutState *out) { return ::btdrvGetAudioOutState(audio_handle, out); } +Result GetAudioOutFeedingCodec(u32 audio_handle, BtdrvAudioCodec *out) { return ::btdrvGetAudioOutFeedingCodec(audio_handle, out); } +Result GetAudioOutFeedingParameter(u32 audio_handle, BtdrvPcmParameter *out) { return ::btdrvGetAudioOutFeedingParameter(audio_handle, out); } +Result AcquireAudioOutStateChangedEvent(u32 audio_handle, Event* out_event, bool autoclear) { return ::btdrvAcquireAudioOutStateChangedEvent(audio_handle, out_event, autoclear); } +Result AcquireAudioOutBufferAvailableEvent(u32 audio_handle, Event* out_event, bool autoclear) { return ::btdrvAcquireAudioOutBufferAvailableEvent(audio_handle, out_event, autoclear); } +Result SendAudioData(u32 audio_handle, const void* buffer, size_t size, u64 *transferred_size) { return ::btdrvSendAudioData(audio_handle, buffer, size, transferred_size); } +Result AcquireAudioControlInputStateChangedEvent(Event* out_event, bool autoclear) { return ::btdrvAcquireAudioControlInputStateChangedEvent(out_event, autoclear); } +Result GetAudioControlInputState(BtdrvAudioControlButtonState *states, s32 count, s32 *total_out) { return ::btdrvGetAudioControlInputState(states, count, total_out); } +Result AcquireAudioConnectionStateChangedEvent(Event* out_event, bool autoclear) { return ::btdrvAcquireAudioConnectionStateChangedEvent(out_event, autoclear); } +Result GetConnectedAudioDevice(BtdrvAddress *addrs, s32 count, s32 *total_out) { return ::btdrvGetConnectedAudioDevice(addrs, count, total_out); } +Result CloseAudioControlInput(BtdrvAddress addr) { return ::btdrvCloseAudioControlInput(addr); } +Result RegisterAudioControlNotification(BtdrvAddress addr, u32 event_type) { return ::btdrvRegisterAudioControlNotification(addr, event_type); } +Result SendAudioControlPassthroughCommand(BtdrvAddress addr, u32 op_id, u32 state_type) { return ::btdrvSendAudioControlPassthroughCommand(addr, op_id, state_type); } +Result SendAudioControlSetAbsoluteVolumeCommand(BtdrvAddress addr, s32 val) { return ::btdrvSendAudioControlSetAbsoluteVolumeCommand(addr, val); } +Result IsManufacturingMode(bool *out) { return ::btdrvIsManufacturingMode(out); } +Result EmulateBluetoothCrash(BtdrvFatalReason reason) { return ::btdrvEmulateBluetoothCrash(reason); } +Result GetBleChannelMap(BtdrvChannelMapList *out) { return ::btdrvGetBleChannelMap(out); } +void* CircularBufferRead(BtdrvCircularBuffer *c) { return ::btdrvCircularBufferRead(c); } +bool CircularBufferFree(BtdrvCircularBuffer *c) { return ::btdrvCircularBufferFree(c); } + +} // namespace btdrv + +namespace btm { + +Result Initialize(void) { return ::btmInitialize(); } +void Exit(void) { ::btmExit(); } +Service* GetServiceSession(void) { return ::btmGetServiceSession(); } +Result GetState(BtmState *out) { return ::btmGetState(out); } +Result GetHostDeviceProperty(BtmHostDeviceProperty *out) { return ::btmGetHostDeviceProperty(out); } +Result AcquireDeviceConditionEvent(Event* out_event) { return ::btmAcquireDeviceConditionEvent(out_event); } +Result LegacyGetDeviceCondition(BtmDeviceConditionList *out) { return ::btmLegacyGetDeviceCondition(out); } +Result GetDeviceCondition(BtmProfile profile, BtmDeviceCondition *out, size_t count, s32 *total_out) { return ::btmGetDeviceCondition(profile, out, count, total_out); } +Result SetBurstMode(BtdrvAddress addr, bool flag) { return ::btmSetBurstMode(addr, flag); } +Result SetSlotMode(const BtmDeviceSlotModeList *list) { return ::btmSetSlotMode(list); } +Result SetBluetoothMode(BtmBluetoothMode mode) { return ::btmSetBluetoothMode(mode); } +Result SetWlanMode(BtmWlanMode mode) { return ::btmSetWlanMode(mode); } +Result AcquireDeviceInfoEvent(Event* out_event) { return ::btmAcquireDeviceInfoEvent(out_event); } +Result LegacyGetDeviceInfo(BtmDeviceInfoList *out) { return ::btmLegacyGetDeviceInfo(out); } +Result GetDeviceInfo(BtmProfile profile, BtmDeviceInfo *out, size_t count, s32 *total_out) { return ::btmGetDeviceInfo(profile, out, count, total_out); } +Result LegacyAddDeviceInfo(const BtmDeviceInfoLegacy *info) { return ::btmLegacyAddDeviceInfo(info); } +Result AddDeviceInfo(const BtmDeviceInfo *info) { return ::btmAddDeviceInfo(info); } +Result RemoveDeviceInfo(BtdrvAddress addr) { return ::btmRemoveDeviceInfo(addr); } +Result IncreaseDeviceInfoOrder(BtdrvAddress addr) { return ::btmIncreaseDeviceInfoOrder(addr); } +Result LlrNotify(BtdrvAddress addr, s32 unk) { return ::btmLlrNotify(addr, unk); } +Result EnableRadio(void) { return ::btmEnableRadio(); } +Result DisableRadio(void) { return ::btmDisableRadio(); } +Result HidDisconnect(BtdrvAddress addr) { return ::btmHidDisconnect(addr); } +Result HidSetRetransmissionMode(BtdrvAddress addr, const BtmZeroRetransmissionList *list) { return ::btmHidSetRetransmissionMode(addr, list); } +Result AcquireAwakeReqEvent(Event* out_event) { return ::btmAcquireAwakeReqEvent(out_event); } +Result AcquireLlrStateEvent(Event* out_event) { return ::btmAcquireLlrStateEvent(out_event); } +Result IsLlrStarted(bool *out) { return ::btmIsLlrStarted(out); } +Result EnableSlotSaving(bool flag) { return ::btmEnableSlotSaving(flag); } +Result ProtectDeviceInfo(BtdrvAddress addr, bool flag) { return ::btmProtectDeviceInfo(addr, flag); } +Result AcquireBleScanEvent(Event* out_event) { return ::btmAcquireBleScanEvent(out_event); } +Result GetBleScanParameterGeneral(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out) { return ::btmGetBleScanParameterGeneral(parameter_id, out); } +Result GetBleScanParameterSmartDevice(u16 parameter_id, BtdrvGattAttributeUuid *out) { return ::btmGetBleScanParameterSmartDevice(parameter_id, out); } +Result StartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param) { return ::btmStartBleScanForGeneral(param); } +Result StopBleScanForGeneral(void) { return ::btmStopBleScanForGeneral(); } +Result GetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out) { return ::btmGetBleScanResultsForGeneral(results, count, total_out); } +Result StartBleScanForPaired(BtdrvBleAdvertisePacketParameter param) { return ::btmStartBleScanForPaired(param); } +Result StopBleScanForPaired(void) { return ::btmStopBleScanForPaired(); } +Result StartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid) { return ::btmStartBleScanForSmartDevice(uuid); } +Result StopBleScanForSmartDevice(void) { return ::btmStopBleScanForSmartDevice(); } +Result GetBleScanResultsForSmartDevice(BtdrvBleScanResult *results, u8 count, u8 *total_out) { return ::btmGetBleScanResultsForSmartDevice(results, count, total_out); } +Result AcquireBleConnectionEvent(Event* out_event) { return ::btmAcquireBleConnectionEvent(out_event); } +Result BleConnect(BtdrvAddress addr) { return ::btmBleConnect(addr); } +Result BleOverrideConnection(u32 id) { return ::btmBleOverrideConnection(id); } +Result BleDisconnect(u32 connection_handle) { return ::btmBleDisconnect(connection_handle); } +Result BleGetConnectionState(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out) { return ::btmBleGetConnectionState(info, count, total_out); } +Result BleGetGattClientConditionList(BtmGattClientConditionList *list) { return ::btmBleGetGattClientConditionList(list); } +Result AcquireBlePairingEvent(Event* out_event) { return ::btmAcquireBlePairingEvent(out_event); } +Result BlePairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param) { return ::btmBlePairDevice(connection_handle, param); } +Result BleUnpairDeviceOnBoth(u32 connection_handle, BtdrvBleAdvertisePacketParameter param) { return ::btmBleUnpairDeviceOnBoth(connection_handle, param); } +Result BleUnPairDevice(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param) { return ::btmBleUnPairDevice(addr, param); } +Result BleGetPairedAddresses(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out) { return ::btmBleGetPairedAddresses(param, addrs, count, total_out); } +Result AcquireBleServiceDiscoveryEvent(Event* out_event) { return ::btmAcquireBleServiceDiscoveryEvent(out_event); } +Result GetGattServices(u32 connection_handle, BtmGattService *services, u8 count, u8 *total_out) { return ::btmGetGattServices(connection_handle, services, count, total_out); } +Result GetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtmGattService *service, bool *flag) { return ::btmGetGattService(connection_handle, uuid, service, flag); } +Result GetGattIncludedServices(u32 connection_handle, u16 service_handle, BtmGattService *services, u8 count, u8 *out) { return ::btmGetGattIncludedServices(connection_handle, service_handle, services, count, out); } +Result GetBelongingService(u32 connection_handle, u16 attribute_handle, BtmGattService *service, bool *flag) { return ::btmGetBelongingService(connection_handle, attribute_handle, service, flag); } +Result GetGattCharacteristics(u32 connection_handle, u16 service_handle, BtmGattCharacteristic *characteristics, u8 count, u8 *total_out) { return ::btmGetGattCharacteristics(connection_handle, service_handle, characteristics, count, total_out); } +Result GetGattDescriptors(u32 connection_handle, u16 char_handle, BtmGattDescriptor *descriptors, u8 count, u8 *total_out) { return ::btmGetGattDescriptors(connection_handle, char_handle, descriptors, count, total_out); } +Result AcquireBleMtuConfigEvent(Event* out_event) { return ::btmAcquireBleMtuConfigEvent(out_event); } +Result ConfigureBleMtu(u32 connection_handle, u16 mtu) { return ::btmConfigureBleMtu(connection_handle, mtu); } +Result GetBleMtu(u32 connection_handle, u16 *out) { return ::btmGetBleMtu(connection_handle, out); } +Result RegisterBleGattDataPath(const BtmBleDataPath *path) { return ::btmRegisterBleGattDataPath(path); } +Result UnregisterBleGattDataPath(const BtmBleDataPath *path) { return ::btmUnregisterBleGattDataPath(path); } +Result RegisterAppletResourceUserId(u64 AppletResourceUserId, u32 unk) { return ::btmRegisterAppletResourceUserId(AppletResourceUserId, unk); } +Result UnregisterAppletResourceUserId(u64 AppletResourceUserId) { return ::btmUnregisterAppletResourceUserId(AppletResourceUserId); } +Result SetAppletResourceUserId(u64 AppletResourceUserId) { return ::btmSetAppletResourceUserId(AppletResourceUserId); } +Result GetShortenedDeviceInfo(BtmProfile profile, BtmShortenedDeviceInfo *out, size_t count, s32 *total_out) { return ::btmGetShortenedDeviceInfo(profile, out, count, total_out); } +Result GetShortenedDeviceCondition(BtmProfile profile, BtmShortenedDeviceCondition *out, size_t count, s32 *total_out) { return ::btmGetShortenedDeviceCondition(profile, out, count, total_out); } + +} // namespace btm + +namespace btmsys { + +Result Initialize(void) { return ::btmsysInitialize(); } +void Exit(void) { ::btmsysExit(); } +Result GetServiceSession(Service* srv_out) { return ::btmsysGetServiceSession(srv_out); } +Service* GetServiceSession_IBtmSystemCore(void) { return ::btmsysGetServiceSession_IBtmSystemCore(); } +Result StartGamepadPairing(void) { return ::btmsysStartGamepadPairing(); } +Result CancelGamepadPairing(void) { return ::btmsysCancelGamepadPairing(); } +Result ClearGamepadPairingDatabase(void) { return ::btmsysClearGamepadPairingDatabase(); } +Result GetPairedGamepadCount(u8 *out) { return ::btmsysGetPairedGamepadCount(out); } +Result EnableRadio(void) { return ::btmsysEnableRadio(); } +Result DisableRadio(void) { return ::btmsysDisableRadio(); } +Result GetRadioOnOff(bool *out) { return ::btmsysGetRadioOnOff(out); } +Result AcquireRadioEvent(Event* out_event) { return ::btmsysAcquireRadioEvent(out_event); } +Result AcquireGamepadPairingEvent(Event* out_event) { return ::btmsysAcquireGamepadPairingEvent(out_event); } +Result IsGamepadPairingStarted(bool *out) { return ::btmsysIsGamepadPairingStarted(out); } +Result StartAudioDeviceDiscovery(void) { return ::btmsysStartAudioDeviceDiscovery(); } +Result StopAudioDeviceDiscovery(void) { return ::btmsysStopAudioDeviceDiscovery(); } +Result IsDiscoveryingAudioDevice(bool *out) { return ::btmsysIsDiscoveryingAudioDevice(out); } +Result GetDiscoveredAudioDevice(BtmAudioDevice *out, s32 count, s32 *total_out) { return ::btmsysGetDiscoveredAudioDevice(out, count, total_out); } +Result AcquireAudioDeviceConnectionEvent(Event* out_event) { return ::btmsysAcquireAudioDeviceConnectionEvent(out_event); } +Result ConnectAudioDevice(BtdrvAddress addr) { return ::btmsysConnectAudioDevice(addr); } +Result IsConnectingAudioDevice(bool *out) { return ::btmsysIsConnectingAudioDevice(out); } +Result GetConnectedAudioDevices(BtmAudioDevice *out, s32 count, s32 *total_out) { return ::btmsysGetConnectedAudioDevices(out, count, total_out); } +Result DisconnectAudioDevice(BtdrvAddress addr) { return ::btmsysDisconnectAudioDevice(addr); } +Result AcquirePairedAudioDeviceInfoChangedEvent(Event* out_event) { return ::btmsysAcquirePairedAudioDeviceInfoChangedEvent(out_event); } +Result GetPairedAudioDevices(BtmAudioDevice *out, s32 count, s32 *total_out) { return ::btmsysGetPairedAudioDevices(out, count, total_out); } +Result RemoveAudioDevicePairing(BtdrvAddress addr) { return ::btmsysRemoveAudioDevicePairing(addr); } +Result RequestAudioDeviceConnectionRejection(void) { return ::btmsysRequestAudioDeviceConnectionRejection(); } +Result CancelAudioDeviceConnectionRejection(void) { return ::btmsysCancelAudioDeviceConnectionRejection(); } + +} // namespace btmsys + +namespace btmu { + +Result Initialize(void) { return ::btmuInitialize(); } +void Exit(void) { ::btmuExit(); } +Result GetServiceSession(Service* srv_out) { return ::btmuGetServiceSession(srv_out); } +Service* GetServiceSession_IBtmUserCore(void) { return ::btmuGetServiceSession_IBtmUserCore(); } +Result AcquireBleScanEvent(Event* out_event) { return ::btmuAcquireBleScanEvent(out_event); } +Result GetBleScanFilterParameter(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out) { return ::btmuGetBleScanFilterParameter(parameter_id, out); } +Result GetBleScanFilterParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out) { return ::btmuGetBleScanFilterParameter2(parameter_id, out); } +Result StartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param) { return ::btmuStartBleScanForGeneral(param); } +Result StopBleScanForGeneral(void) { return ::btmuStopBleScanForGeneral(); } +Result GetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out) { return ::btmuGetBleScanResultsForGeneral(results, count, total_out); } +Result StartBleScanForPaired(BtdrvBleAdvertisePacketParameter param) { return ::btmuStartBleScanForPaired(param); } +Result StopBleScanForPaired(void) { return ::btmuStopBleScanForPaired(); } +Result StartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid) { return ::btmuStartBleScanForSmartDevice(uuid); } +Result StopBleScanForSmartDevice(void) { return ::btmuStopBleScanForSmartDevice(); } +Result GetBleScanResultsForSmartDevice(BtdrvBleScanResult *results, u8 count, u8 *total_out) { return ::btmuGetBleScanResultsForSmartDevice(results, count, total_out); } +Result AcquireBleConnectionEvent(Event* out_event) { return ::btmuAcquireBleConnectionEvent(out_event); } +Result BleConnect(BtdrvAddress addr) { return ::btmuBleConnect(addr); } +Result BleDisconnect(u32 connection_handle) { return ::btmuBleDisconnect(connection_handle); } +Result BleGetConnectionState(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out) { return ::btmuBleGetConnectionState(info, count, total_out); } +Result AcquireBlePairingEvent(Event* out_event) { return ::btmuAcquireBlePairingEvent(out_event); } +Result BlePairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param) { return ::btmuBlePairDevice(connection_handle, param); } +Result BleUnPairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param) { return ::btmuBleUnPairDevice(connection_handle, param); } +Result BleUnPairDevice2(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param) { return ::btmuBleUnPairDevice2(addr, param); } +Result BleGetPairedDevices(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out) { return ::btmuBleGetPairedDevices(param, addrs, count, total_out); } +Result AcquireBleServiceDiscoveryEvent(Event* out_event) { return ::btmuAcquireBleServiceDiscoveryEvent(out_event); } +Result GetGattServices(u32 connection_handle, BtmGattService *services, u8 count, u8 *total_out) { return ::btmuGetGattServices(connection_handle, services, count, total_out); } +Result GetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtmGattService *service, bool *flag) { return ::btmuGetGattService(connection_handle, uuid, service, flag); } +Result GetGattIncludedServices(u32 connection_handle, u16 service_handle, BtmGattService *services, u8 count, u8 *out) { return ::btmuGetGattIncludedServices(connection_handle, service_handle, services, count, out); } +Result GetBelongingGattService(u32 connection_handle, u16 attribute_handle, BtmGattService *service, bool *flag) { return ::btmuGetBelongingGattService(connection_handle, attribute_handle, service, flag); } +Result GetGattCharacteristics(u32 connection_handle, u16 service_handle, BtmGattCharacteristic *characteristics, u8 count, u8 *total_out) { return ::btmuGetGattCharacteristics(connection_handle, service_handle, characteristics, count, total_out); } +Result GetGattDescriptors(u32 connection_handle, u16 char_handle, BtmGattDescriptor *descriptors, u8 count, u8 *total_out) { return ::btmuGetGattDescriptors(connection_handle, char_handle, descriptors, count, total_out); } +Result AcquireBleMtuConfigEvent(Event* out_event) { return ::btmuAcquireBleMtuConfigEvent(out_event); } +Result ConfigureBleMtu(u32 connection_handle, u16 mtu) { return ::btmuConfigureBleMtu(connection_handle, mtu); } +Result GetBleMtu(u32 connection_handle, u16 *out) { return ::btmuGetBleMtu(connection_handle, out); } +Result RegisterBleGattDataPath(const BtmBleDataPath *path) { return ::btmuRegisterBleGattDataPath(path); } +Result UnregisterBleGattDataPath(const BtmBleDataPath *path) { return ::btmuUnregisterBleGattDataPath(path); } + +} // namespace btmu + +namespace capmtp { + +Result Initialize(void* mem, size_t size, u32 app_count, u32 max_img, u32 max_vid, const char *other_name) { return ::capmtpInitialize(mem, size, app_count, max_img, max_vid, other_name); } +void Exit(void) { ::capmtpExit(); } +Service* GetRootServiceSession(void) { return ::capmtpGetRootServiceSession(); } +Service* GetServiceSession(void) { return ::capmtpGetServiceSession(); } +Result StartCommandHandler(void) { return ::capmtpStartCommandHandler(); } +Result StopCommandHandler(void) { return ::capmtpStopCommandHandler(); } +bool IsRunning(void) { return ::capmtpIsRunning(); } +Event * GetConnectionEvent(void) { return ::capmtpGetConnectionEvent(); } +bool IsConnected(void) { return ::capmtpIsConnected(); } +Event * GetScanErrorEvent(void) { return ::capmtpGetScanErrorEvent(); } +Result GetScanError(void) { return ::capmtpGetScanError(); } + +} // namespace capmtp + +namespace caps { + +u64 GetShimLibraryVersion(void) { return ::capsGetShimLibraryVersion(); } +CapsAlbumFileDateTime GetDefaultStartDateTime(void) { return ::capsGetDefaultStartDateTime(); } +CapsAlbumFileDateTime GetDefaultEndDateTime(void) { return ::capsGetDefaultEndDateTime(); } +void ConvertApplicationAlbumFileEntryToApplicationAlbumEntry(CapsApplicationAlbumEntry *out, CapsApplicationAlbumFileEntry *in) { ::capsConvertApplicationAlbumFileEntryToApplicationAlbumEntry(out, in); } +void ConvertApplicationAlbumEntryToApplicationAlbumFileEntry(CapsApplicationAlbumFileEntry *out, CapsApplicationAlbumEntry *in) { ::capsConvertApplicationAlbumEntryToApplicationAlbumFileEntry(out, in); } +Result LoadAlbumScreenShotThumbnailImageEx0(u64 *width, u64 *height, CapsScreenShotAttribute *attr, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsLoadAlbumScreenShotThumbnailImageEx0(width, height, attr, file_id, opts, image, image_size, workbuf, workbuf_size); } + +} // namespace caps + +namespace capsa { + +Result Initialize(void) { return ::capsaInitialize(); } +void Exit(void) { ::capsaExit(); } +Service* GetServiceSession(void) { return ::capsaGetServiceSession(); } +Service* GetServiceSession_Accessor(void) { return ::capsaGetServiceSession_Accessor(); } +Result GetAlbumFileCount(CapsAlbumStorage storage, u64 *count) { return ::capsaGetAlbumFileCount(storage, count); } +Result GetAlbumFileList(CapsAlbumStorage storage, u64 *out, CapsAlbumEntry *entries, u64 count) { return ::capsaGetAlbumFileList(storage, out, entries, count); } +Result LoadAlbumFile(const CapsAlbumFileId *file_id, u64 *out_size, void* filebuf, u64 filebuf_size) { return ::capsaLoadAlbumFile(file_id, out_size, filebuf, filebuf_size); } +Result DeleteAlbumFile(const CapsAlbumFileId *file_id) { return ::capsaDeleteAlbumFile(file_id); } +Result StorageCopyAlbumFile(const CapsAlbumFileId *file_id, CapsAlbumStorage dst_storage) { return ::capsaStorageCopyAlbumFile(file_id, dst_storage); } +Result IsAlbumMounted(CapsAlbumStorage storage, bool *is_mounted) { return ::capsaIsAlbumMounted(storage, is_mounted); } +Result GetAlbumUsage(CapsAlbumStorage storage, CapsAlbumUsage2 *out) { return ::capsaGetAlbumUsage(storage, out); } +Result GetAlbumFileSize(const CapsAlbumFileId *file_id, u64 *size) { return ::capsaGetAlbumFileSize(file_id, size); } +Result LoadAlbumFileThumbnail(const CapsAlbumFileId *file_id, u64 *out_size, void* image, u64 image_size) { return ::capsaLoadAlbumFileThumbnail(file_id, out_size, image, image_size); } +Result LoadAlbumScreenShotImage(u64 *width, u64 *height, const CapsAlbumFileId *file_id, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotImage(width, height, file_id, image, image_size, workbuf, workbuf_size); } +Result LoadAlbumScreenShotThumbnailImage(u64 *width, u64 *height, const CapsAlbumFileId *file_id, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotThumbnailImage(width, height, file_id, image, image_size, workbuf, workbuf_size); } +Result GetAlbumEntryFromApplicationAlbumEntry(CapsAlbumEntry *entry, const CapsApplicationAlbumEntry *application_entry, u64 application_id) { return ::capsaGetAlbumEntryFromApplicationAlbumEntry(entry, application_entry, application_id); } +Result LoadAlbumScreenShotImageEx(u64 *width, u64 *height, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotImageEx(width, height, file_id, opts, image, image_size, workbuf, workbuf_size); } +Result LoadAlbumScreenShotThumbnailImageEx(u64 *width, u64 *height, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotThumbnailImageEx(width, height, file_id, opts, image, image_size, workbuf, workbuf_size); } +Result LoadAlbumScreenShotImageEx0(u64 *width, u64 *height, CapsScreenShotAttribute *attr, const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotImageEx0(width, height, attr, file_id, opts, image, image_size, workbuf, workbuf_size); } +Result GetAlbumUsage3(CapsAlbumStorage storage, CapsAlbumUsage3 *out) { return ::capsaGetAlbumUsage3(storage, out); } +Result GetAlbumMountResult(CapsAlbumStorage storage) { return ::capsaGetAlbumMountResult(storage); } +Result GetAlbumUsage16(CapsAlbumStorage storage, u8 flags, CapsAlbumUsage16 *out) { return ::capsaGetAlbumUsage16(storage, flags, out); } +Result GetMinMaxAppletId(bool* success, u64* min, u64* max) { return ::capsaGetMinMaxAppletId(success, min, max); } +Result GetAlbumFileCountEx0(CapsAlbumStorage storage, u8 flags, u64 *count) { return ::capsaGetAlbumFileCountEx0(storage, flags, count); } +Result GetAlbumFileListEx0(CapsAlbumStorage storage, u8 flags, u64 *out, CapsAlbumEntry *entries, u64 count) { return ::capsaGetAlbumFileListEx0(storage, flags, out, entries, count); } +Result GetLastOverlayScreenShotThumbnail(CapsAlbumFileId *file_id, u64 *out_size, void* image, u64 image_size) { return ::capsaGetLastOverlayScreenShotThumbnail(file_id, out_size, image, image_size); } +Result GetLastOverlayMovieThumbnail(CapsAlbumFileId *file_id, u64 *out_size, void* image, u64 image_size) { return ::capsaGetLastOverlayMovieThumbnail(file_id, out_size, image, image_size); } +Result GetAutoSavingStorage(CapsAlbumStorage *storage) { return ::capsaGetAutoSavingStorage(storage); } +Result GetRequiredStorageSpaceSizeToCopyAll(CapsAlbumStorage dst_storage, CapsAlbumStorage src_storage, u64 *out) { return ::capsaGetRequiredStorageSpaceSizeToCopyAll(dst_storage, src_storage, out); } +Result LoadAlbumScreenShotImageEx1(const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, CapsLoadAlbumScreenShotImageOutput *out, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotImageEx1(file_id, opts, out, image, image_size, workbuf, workbuf_size); } +Result LoadAlbumScreenShotThumbnailImageEx1(const CapsAlbumFileId *file_id, const CapsScreenShotDecodeOption *opts, CapsLoadAlbumScreenShotImageOutput *out, void* image, u64 image_size, void* workbuf, u64 workbuf_size) { return ::capsaLoadAlbumScreenShotThumbnailImageEx1(file_id, opts, out, image, image_size, workbuf, workbuf_size); } +Result ForceAlbumUnmounted(CapsAlbumStorage storage) { return ::capsaForceAlbumUnmounted(storage); } +Result ResetAlbumMountStatus(CapsAlbumStorage storage) { return ::capsaResetAlbumMountStatus(storage); } +Result RefreshAlbumCache(CapsAlbumStorage storage) { return ::capsaRefreshAlbumCache(storage); } +Result GetAlbumCache(CapsAlbumStorage storage, CapsAlbumCache *cache) { return ::capsaGetAlbumCache(storage, cache); } +Result GetAlbumCacheEx(CapsAlbumStorage storage, CapsAlbumFileContents contents, CapsAlbumCache *cache) { return ::capsaGetAlbumCacheEx(storage, contents, cache); } +Result GetAlbumEntryFromApplicationAlbumEntryAruid(CapsAlbumEntry *entry, const CapsApplicationAlbumEntry *application_entry) { return ::capsaGetAlbumEntryFromApplicationAlbumEntryAruid(entry, application_entry); } +Result OpenAlbumMovieStream(u64 *stream, const CapsAlbumFileId *file_id) { return ::capsaOpenAlbumMovieStream(stream, file_id); } +Result CloseAlbumMovieStream(u64 stream) { return ::capsaCloseAlbumMovieStream(stream); } +Result GetAlbumMovieStreamSize(u64 stream, u64 *size) { return ::capsaGetAlbumMovieStreamSize(stream, size); } +Result ReadMovieDataFromAlbumMovieReadStream(u64 stream, s64 offset, void* buffer, size_t size, u64 *actual_size) { return ::capsaReadMovieDataFromAlbumMovieReadStream(stream, offset, buffer, size, actual_size); } +Result GetAlbumMovieReadStreamBrokenReason(u64 stream) { return ::capsaGetAlbumMovieReadStreamBrokenReason(stream); } +Result GetAlbumMovieReadStreamImageDataSize(u64 stream, u64 *size) { return ::capsaGetAlbumMovieReadStreamImageDataSize(stream, size); } +Result ReadImageDataFromAlbumMovieReadStream(u64 stream, s64 offset, void* buffer, size_t size, u64 *actual_size) { return ::capsaReadImageDataFromAlbumMovieReadStream(stream, offset, buffer, size, actual_size); } +Result ReadFileAttributeFromAlbumMovieReadStream(u64 stream, CapsScreenShotAttribute *attr) { return ::capsaReadFileAttributeFromAlbumMovieReadStream(stream, attr); } + +} // namespace capsa + +namespace capsc { + +Result Initialize(void) { return ::capscInitialize(); } +void Exit(void) { ::capscExit(); } +Service* GetServiceSession(void) { return ::capscGetServiceSession(); } +Result NotifyAlbumStorageIsAvailable(CapsAlbumStorage storage) { return ::capscNotifyAlbumStorageIsAvailable(storage); } +Result NotifyAlbumStorageIsUnAvailable(CapsAlbumStorage storage) { return ::capscNotifyAlbumStorageIsUnAvailable(storage); } +Result RegisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id) { return ::capscRegisterAppletResourceUserId(appletResourceUserId, application_id); } +Result UnregisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id) { return ::capscUnregisterAppletResourceUserId(appletResourceUserId, application_id); } +Result GetApplicationIdFromAruid(CapsApplicationId *application_id, u64 aruid) { return ::capscGetApplicationIdFromAruid(application_id, aruid); } +Result CheckApplicationIdRegistered(u64 application_id) { return ::capscCheckApplicationIdRegistered(application_id); } +Result GenerateCurrentAlbumFileId(const CapsApplicationId *application_id, CapsAlbumFileContents contents, CapsAlbumFileId *file_id) { return ::capscGenerateCurrentAlbumFileId(application_id, contents, file_id); } +Result GenerateApplicationAlbumEntry(CapsApplicationAlbumEntry *appEntry, const CapsAlbumEntry *entry, u64 application_id) { return ::capscGenerateApplicationAlbumEntry(appEntry, entry, application_id); } +Result SaveAlbumScreenShotFile(const CapsAlbumFileId *file_id, const void* buffer, u64 buffer_size) { return ::capscSaveAlbumScreenShotFile(file_id, buffer, buffer_size); } +Result SaveAlbumScreenShotFileEx(const CapsAlbumFileId *file_id, u64 version, u64 makernote_offset, u64 makernote_size, const void* buffer, u64 buffer_size) { return ::capscSaveAlbumScreenShotFileEx(file_id, version, makernote_offset, makernote_size, buffer, buffer_size); } +Result SetOverlayScreenShotThumbnailData(const CapsAlbumFileId *file_id, const void* image, u64 image_size) { return ::capscSetOverlayScreenShotThumbnailData(file_id, image, image_size); } +Result SetOverlayMovieThumbnailData(const CapsAlbumFileId *file_id, const void* image, u64 image_size) { return ::capscSetOverlayMovieThumbnailData(file_id, image, image_size); } +Result OpenAlbumMovieReadStream(u64 *stream, const CapsAlbumFileId *file_id) { return ::capscOpenAlbumMovieReadStream(stream, file_id); } +Result CloseAlbumMovieStream(u64 stream) { return ::capscCloseAlbumMovieStream(stream); } +Result GetAlbumMovieStreamSize(u64 stream, u64 *size) { return ::capscGetAlbumMovieStreamSize(stream, size); } +Result ReadMovieDataFromAlbumMovieReadStream(u64 stream, u64 offset, void* buffer, size_t size, u64 *actual_size) { return ::capscReadMovieDataFromAlbumMovieReadStream(stream, offset, buffer, size, actual_size); } +Result GetAlbumMovieReadStreamBrokenReason(u64 stream) { return ::capscGetAlbumMovieReadStreamBrokenReason(stream); } +Result GetAlbumMovieReadStreamImageDataSize(u64 stream, u64 *size) { return ::capscGetAlbumMovieReadStreamImageDataSize(stream, size); } +Result ReadImageDataFromAlbumMovieReadStream(u64 stream, u64 offset, void* buffer, size_t size, u64 *actual_size) { return ::capscReadImageDataFromAlbumMovieReadStream(stream, offset, buffer, size, actual_size); } +Result ReadFileAttributeFromAlbumMovieReadStream(u64 stream, CapsScreenShotAttribute *attribute) { return ::capscReadFileAttributeFromAlbumMovieReadStream(stream, attribute); } +Result OpenAlbumMovieWriteStream(u64 *stream, const CapsAlbumFileId *file_id) { return ::capscOpenAlbumMovieWriteStream(stream, file_id); } +Result FinishAlbumMovieWriteStream(u64 stream) { return ::capscFinishAlbumMovieWriteStream(stream); } +Result CommitAlbumMovieWriteStream(u64 stream) { return ::capscCommitAlbumMovieWriteStream(stream); } +Result DiscardAlbumMovieWriteStream(u64 stream) { return ::capscDiscardAlbumMovieWriteStream(stream); } +Result DiscardAlbumMovieWriteStreamNoDelete(u64 stream) { return ::capscDiscardAlbumMovieWriteStreamNoDelete(stream); } +Result CommitAlbumMovieWriteStreamEx(u64 stream, CapsAlbumEntry *entry) { return ::capscCommitAlbumMovieWriteStreamEx(stream, entry); } +Result StartAlbumMovieWriteStreamDataSection(u64 stream) { return ::capscStartAlbumMovieWriteStreamDataSection(stream); } +Result EndAlbumMovieWriteStreamDataSection(u64 stream) { return ::capscEndAlbumMovieWriteStreamDataSection(stream); } +Result StartAlbumMovieWriteStreamMetaSection(u64 stream) { return ::capscStartAlbumMovieWriteStreamMetaSection(stream); } +Result EndAlbumMovieWriteStreamMetaSection(u64 stream) { return ::capscEndAlbumMovieWriteStreamMetaSection(stream); } +Result ReadDataFromAlbumMovieWriteStream(u64 stream, u64 offset, void* buffer, u64 size, u64 *actual_size) { return ::capscReadDataFromAlbumMovieWriteStream(stream, offset, buffer, size, actual_size); } +Result WriteDataToAlbumMovieWriteStream(u64 stream, u64 offset, const void* buffer, u64 size) { return ::capscWriteDataToAlbumMovieWriteStream(stream, offset, buffer, size); } +Result WriteMetaToAlbumMovieWriteStream(u64 stream, u64 offset, const void* buffer, u64 size) { return ::capscWriteMetaToAlbumMovieWriteStream(stream, offset, buffer, size); } +Result GetAlbumMovieWriteStreamBrokenReason(u64 stream) { return ::capscGetAlbumMovieWriteStreamBrokenReason(stream); } +Result GetAlbumMovieWriteStreamDataSize(u64 stream, u64 *size) { return ::capscGetAlbumMovieWriteStreamDataSize(stream, size); } +Result SetAlbumMovieWriteStreamDataSize(u64 stream, u64 size) { return ::capscSetAlbumMovieWriteStreamDataSize(stream, size); } + +} // namespace capsc + +namespace capsdc { + +Result Initialize(void) { return ::capsdcInitialize(); } +void Exit(void) { ::capsdcExit(); } +Service* GetServiceSession(void) { return ::capsdcGetServiceSession(); } +Result DecodeJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_image, size_t out_image_size) { return ::capsdcDecodeJpeg(width, height, opts, jpeg, jpeg_size, out_image, out_image_size); } +Result ShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size) { return ::capsdcShrinkJpeg(width, height, opts, jpeg, jpeg_size, out_jpeg, out_jpeg_size, out_result_size); } +Result ShrinkJpegEx(u32 scaled_width, u32 scaled_height, u32 jpeg_quality, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size) { return ::capsdcShrinkJpegEx(scaled_width, scaled_height, jpeg_quality, opts, jpeg, jpeg_size, out_jpeg, out_jpeg_size, out_result_size); } + +} // namespace capsdc + +namespace capssc { + +Result Initialize(void) { return ::capsscInitialize(); } +void Exit(void) { ::capsscExit(); } +Service* GetServiceSession(void) { return ::capsscGetServiceSession(); } +Result CaptureRawImageWithTimeout(void* buf, size_t size, ViLayerStack layer_stack, u64 width, u64 height, s64 buffer_count, s64 buffer_index, s64 timeout) { return ::capsscCaptureRawImageWithTimeout(buf, size, layer_stack, width, height, buffer_count, buffer_index, timeout); } +Result OpenRawScreenShotReadStream(u64 *out_size, u64 *out_width, u64 *out_height, ViLayerStack layer_stack, s64 timeout) { return ::capsscOpenRawScreenShotReadStream(out_size, out_width, out_height, layer_stack, timeout); } +Result CloseRawScreenShotReadStream(void) { return ::capsscCloseRawScreenShotReadStream(); } +Result ReadRawScreenShotReadStream(u64 *bytes_read, void* buf, size_t size, u64 offset) { return ::capsscReadRawScreenShotReadStream(bytes_read, buf, size, offset); } +Result CaptureJpegScreenShot(u64* out_jpeg_size, void* jpeg_buf, size_t jpeg_buf_size, ViLayerStack layer_stack, s64 timeout) { return ::capsscCaptureJpegScreenShot(out_jpeg_size, jpeg_buf, jpeg_buf_size, layer_stack, timeout); } + +} // namespace capssc + +namespace capssu { + +Result Initialize(void) { return ::capssuInitialize(); } +void Exit(void) { ::capssuExit(); } +Service* GetServiceSession(void) { return ::capssuGetServiceSession(); } +Result SaveScreenShot(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, CapsApplicationAlbumEntry *out) { return ::capssuSaveScreenShot(buffer, size, reportoption, orientation, out); } +Result SaveScreenShotWithUserData(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, const void* userdata, size_t userdata_size, CapsApplicationAlbumEntry *out) { return ::capssuSaveScreenShotWithUserData(buffer, size, reportoption, orientation, userdata, userdata_size, out); } +Result SaveScreenShotWithUserIds(const void* buffer, size_t size, AlbumReportOption reportoption, AlbumImageOrientation orientation, const AccountUid* uids, size_t uid_count, CapsApplicationAlbumEntry *out) { return ::capssuSaveScreenShotWithUserIds(buffer, size, reportoption, orientation, uids, uid_count, out); } +Result SaveScreenShotEx0(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsApplicationAlbumEntry *out) { return ::capssuSaveScreenShotEx0(buffer, size, attr, reportoption, out); } +Result SaveScreenShotEx1(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsApplicationData *appdata, CapsApplicationAlbumEntry *out) { return ::capssuSaveScreenShotEx1(buffer, size, attr, reportoption, appdata, out); } +Result SaveScreenShotEx2(const void* buffer, size_t size, const CapsScreenShotAttribute *attr, AlbumReportOption reportoption, CapsUserIdList *list, CapsApplicationAlbumEntry *out) { return ::capssuSaveScreenShotEx2(buffer, size, attr, reportoption, list, out); } + +} // namespace capssu + +namespace capsu { + +Result Initialize(void) { return ::capsuInitialize(); } +void Exit(void) { ::capsuExit(); } +Service* GetServiceSession(void) { return ::capsuGetServiceSession(); } +Service* GetServiceSession_Accessor(void) { return ::capsuGetServiceSession_Accessor(); } +Result GetAlbumFileListDeprecated1(CapsApplicationAlbumFileEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, s32 *total_entries) { return ::capsuGetAlbumFileListDeprecated1(entries, count, type, start_datetime, end_datetime, total_entries); } +Result GetAlbumFileListDeprecated2(CapsApplicationAlbumFileEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, AccountUid uid, s32 *total_entries) { return ::capsuGetAlbumFileListDeprecated2(entries, count, type, start_datetime, end_datetime, uid, total_entries); } +Result GetAlbumFileList3(CapsApplicationAlbumEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, s32 *total_entries) { return ::capsuGetAlbumFileList3(entries, count, type, start_datetime, end_datetime, total_entries); } +Result GetAlbumFileList4(CapsApplicationAlbumEntry *entries, s32 count, CapsContentType type, const CapsAlbumFileDateTime *start_datetime, const CapsAlbumFileDateTime *end_datetime, AccountUid uid, s32 *total_entries) { return ::capsuGetAlbumFileList4(entries, count, type, start_datetime, end_datetime, uid, total_entries); } +Result DeleteAlbumFile(CapsContentType type, const CapsApplicationAlbumFileEntry *entry) { return ::capsuDeleteAlbumFile(type, entry); } +Result GetAlbumFileSize(const CapsApplicationAlbumFileEntry *entry, u64 *size) { return ::capsuGetAlbumFileSize(entry, size); } +Result LoadAlbumScreenShotImage(s32 *width, s32 *height, CapsScreenShotAttributeForApplication *attr, void* userdata, size_t userdata_maxsize, u32 *userdata_size, void* image, size_t image_size, void* workbuf, size_t workbuf_size, const CapsApplicationAlbumFileEntry *entry, const CapsScreenShotDecodeOption *option) { return ::capsuLoadAlbumScreenShotImage(width, height, attr, userdata, userdata_maxsize, userdata_size, image, image_size, workbuf, workbuf_size, entry, option); } +Result LoadAlbumScreenShotThumbnailImage(s32 *width, s32 *height, CapsScreenShotAttributeForApplication *attr, void* userdata, size_t userdata_maxsize, u32 *userdata_size, void* image, size_t image_size, void* workbuf, size_t workbuf_size, const CapsApplicationAlbumFileEntry *entry, const CapsScreenShotDecodeOption *option) { return ::capsuLoadAlbumScreenShotThumbnailImage(width, height, attr, userdata, userdata_maxsize, userdata_size, image, image_size, workbuf, workbuf_size, entry, option); } +Result PrecheckToCreateContents(CapsContentType type, u64 unk) { return ::capsuPrecheckToCreateContents(type, unk); } +Result OpenAlbumMovieStream(u64 *stream, const CapsApplicationAlbumFileEntry *entry) { return ::capsuOpenAlbumMovieStream(stream, entry); } +Result CloseAlbumMovieStream(u64 stream) { return ::capsuCloseAlbumMovieStream(stream); } +Result GetAlbumMovieStreamSize(u64 stream, u64 *size) { return ::capsuGetAlbumMovieStreamSize(stream, size); } +Result ReadAlbumMovieStream(u64 stream, s64 offset, void* buffer, size_t size, u64 *actual_size) { return ::capsuReadAlbumMovieStream(stream, offset, buffer, size, actual_size); } +Result GetAlbumMovieStreamBrokenReason(u64 stream) { return ::capsuGetAlbumMovieStreamBrokenReason(stream); } + +} // namespace capsu + +namespace clkrst { + +Result Initialize(void) { return ::clkrstInitialize(); } +void Exit(void) { ::clkrstExit(); } +Service* GetServiceSession(void) { return ::clkrstGetServiceSession(); } +Result OpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32 unk) { return ::clkrstOpenSession(session_out, module_id, unk); } +void CloseSession(ClkrstSession* session) { ::clkrstCloseSession(session); } +Result SetClockRate(ClkrstSession* session, u32 hz) { return ::clkrstSetClockRate(session, hz); } +Result GetClockRate(ClkrstSession* session, u32 *out_hz) { return ::clkrstGetClockRate(session, out_hz); } +// Result SetMinimumVoltageClockRate(ClkrstSession *session, u32 hz) { return ::clkrstSetMinimumVoltageClockRate(session, hz); } +Result GetPossibleClockRates(ClkrstSession *session, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count) { return ::clkrstGetPossibleClockRates(session, rates, max_count, out_type, out_count); } +// Result GetDvfsTable(ClkrstSession *session, u32 *out_rate_table, s32 in_rate_count, u32 *out_voltage_table, s32 in_voltage_count, s32 *out_count) { return ::clkrstGetDvfsTable(session, out_rate_table, in_rate_count, out_voltage_table, in_voltage_count, out_count); } + +} // namespace clkrst + +namespace cmac { + +void Aes128ContextCreate(Aes128CmacContext *out, const void *key) { ::cmacAes128ContextCreate(out, key); } +void Aes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size) { ::cmacAes128ContextUpdate(ctx, src, size); } +void Aes128ContextGetMac(Aes128CmacContext *ctx, void *dst) { ::cmacAes128ContextGetMac(ctx, dst); } +void Aes128CalculateMac(void *dst, const void *key, const void *src, size_t size) { ::cmacAes128CalculateMac(dst, key, src, size); } +void Aes192ContextCreate(Aes192CmacContext *out, const void *key) { ::cmacAes192ContextCreate(out, key); } +void Aes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size) { ::cmacAes192ContextUpdate(ctx, src, size); } +void Aes192ContextGetMac(Aes192CmacContext *ctx, void *dst) { ::cmacAes192ContextGetMac(ctx, dst); } +void Aes192CalculateMac(void *dst, const void *key, const void *src, size_t size) { ::cmacAes192CalculateMac(dst, key, src, size); } +void Aes256ContextCreate(Aes256CmacContext *out, const void *key) { ::cmacAes256ContextCreate(out, key); } +void Aes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size) { ::cmacAes256ContextUpdate(ctx, src, size); } +void Aes256ContextGetMac(Aes256CmacContext *ctx, void *dst) { ::cmacAes256ContextGetMac(ctx, dst); } +void Aes256CalculateMac(void *dst, const void *key, const void *src, size_t size) { ::cmacAes256CalculateMac(dst, key, src, size); } + +} // namespace cmac + +namespace cmif { + +void* GetAlignedDataStart(u32* data_words, void* base) { return ::cmifGetAlignedDataStart(data_words, base); } +CmifRequest MakeRequest(void* base, CmifRequestFormat fmt) { return ::cmifMakeRequest(base, fmt); } +void* MakeControlRequest(void* base, u32 request_id, u32 size) { return ::cmifMakeControlRequest(base, request_id, size); } +void MakeCloseRequest(void* base, u32 object_id) { ::cmifMakeCloseRequest(base, object_id); } +void RequestInBuffer(CmifRequest* req, const void* buffer, size_t size, HipcBufferMode mode) { ::cmifRequestInBuffer(req, buffer, size, mode); } +void RequestOutBuffer(CmifRequest* req, void* buffer, size_t size, HipcBufferMode mode) { ::cmifRequestOutBuffer(req, buffer, size, mode); } +void RequestInOutBuffer(CmifRequest* req, void* buffer, size_t size, HipcBufferMode mode) { ::cmifRequestInOutBuffer(req, buffer, size, mode); } +void RequestInPointer(CmifRequest* req, const void* buffer, size_t size) { ::cmifRequestInPointer(req, buffer, size); } +void RequestOutFixedPointer(CmifRequest* req, void* buffer, size_t size) { ::cmifRequestOutFixedPointer(req, buffer, size); } +void RequestOutPointer(CmifRequest* req, void* buffer, size_t size) { ::cmifRequestOutPointer(req, buffer, size); } +void RequestInAutoBuffer(CmifRequest* req, const void* buffer, size_t size, HipcBufferMode mode) { ::cmifRequestInAutoBuffer(req, buffer, size, mode); } +void RequestOutAutoBuffer(CmifRequest* req, void* buffer, size_t size, HipcBufferMode mode) { ::cmifRequestOutAutoBuffer(req, buffer, size, mode); } +void RequestObject(CmifRequest* req, u32 object_id) { ::cmifRequestObject(req, object_id); } +void RequestHandle(CmifRequest* req, Handle handle) { ::cmifRequestHandle(req, handle); } +Result ParseResponse(CmifResponse* res, void* base, bool is_domain, u32 size) { return ::cmifParseResponse(res, base, is_domain, size); } +u32 ResponseGetObject(CmifResponse* res) { return ::cmifResponseGetObject(res); } +Handle ResponseGetCopyHandle(CmifResponse* res) { return ::cmifResponseGetCopyHandle(res); } +Handle ResponseGetMoveHandle(CmifResponse* res) { return ::cmifResponseGetMoveHandle(res); } +Result ConvertCurrentObjectToDomain(Handle h, u32* out_object_id) { return ::cmifConvertCurrentObjectToDomain(h, out_object_id); } +Result CopyFromCurrentDomain(Handle h, u32 object_id, Handle* out_h) { return ::cmifCopyFromCurrentDomain(h, object_id, out_h); } +Result CloneCurrentObject(Handle h, Handle* out_h) { return ::cmifCloneCurrentObject(h, out_h); } +Result QueryPointerBufferSize(Handle h, u16* out_size) { return ::cmifQueryPointerBufferSize(h, out_size); } +Result CloneCurrentObjectEx(Handle h, u32 tag, Handle* out_h) { return ::cmifCloneCurrentObjectEx(h, tag, out_h); } + +} // namespace cmif + +namespace condvar { + +void Init(CondVar* c) { ::condvarInit(c); } +Result WaitTimeout(CondVar* c, Mutex* m, u64 timeout) { return ::condvarWaitTimeout(c, m, timeout); } +Result Wait(CondVar* c, Mutex* m) { return ::condvarWait(c, m); } +Result Wake(CondVar* c, int num) { return ::condvarWake(c, num); } +Result WakeOne(CondVar* c) { return ::condvarWakeOne(c); } +Result WakeAll(CondVar* c) { return ::condvarWakeAll(c); } + +} // namespace condvar + +namespace console { + +void SetFont(PrintConsole* console, ConsoleFont* font) { ::consoleSetFont(console, font); } +void SetWindow(PrintConsole* console, int x, int y, int width, int height) { ::consoleSetWindow(console, x, y, width, height); } +PrintConsole* GetDefault(void) { return ::consoleGetDefault(); } +PrintConsole * Select(PrintConsole* console) { return ::consoleSelect(console); } +PrintConsole* Init(PrintConsole* console) { return ::consoleInit(console); } +void Exit(PrintConsole* console) { ::consoleExit(console); } +void Update(PrintConsole* console) { ::consoleUpdate(console); } +void DebugInit(debugDevice device) { ::consoleDebugInit(device); } +void Clear(void) { ::consoleClear(); } + +} // namespace console + +namespace crc32 { + +u32 CalculateWithSeed(u32 seed, const void *src, size_t size) { return ::crc32CalculateWithSeed(seed, src, size); } +u32 Calculate(const void *src, size_t size) { return ::crc32Calculate(src, size); } + +} // namespace crc32 + +namespace crc32c { + +u32 CalculateWithSeed(u32 seed, const void *src, size_t size) { return ::crc32cCalculateWithSeed(seed, src, size); } +u32 Calculate(const void *src, size_t size) { return ::crc32cCalculate(src, size); } + +} // namespace crc32c + +namespace csrng { + +Result Initialize(void) { return ::csrngInitialize(); } +void Exit(void) { ::csrngExit(); } +Service* GetServiceSession(void) { return ::csrngGetServiceSession(); } +Result GetRandomBytes(void *out, size_t out_size) { return ::csrngGetRandomBytes(out, out_size); } + +} // namespace csrng + +namespace detect { + +bool Debugger(void) { return ::detectDebugger(); } +bool Mesosphere(void) { return ::detectMesosphere(); } + +} // namespace detect + +namespace diag { + +[[noreturn]] void AbortWithResult(Result res) { ::diagAbortWithResult(res); } + +} // namespace diag + +namespace ectxr { + +Result Initialize(void) { return ::ectxrInitialize(); } +void Exit(void) { ::ectxrExit(); } +Service* GetServiceSession(void) { return ::ectxrGetServiceSession(); } +Result PullContext(s32 *out0, u32 *out_total_size, u32 *out_size, void *dst, size_t dst_size, u32 descriptor, Result result) { return ::ectxrPullContext(out0, out_total_size, out_size, dst, dst_size, descriptor, result); } + +} // namespace ectxr + +namespace env { + +void Setup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr) { ::envSetup(ctx, main_thread, saved_lr); } +const char* GetLoaderInfo(void) { return ::envGetLoaderInfo(); } +u64 GetLoaderInfoSize(void) { return ::envGetLoaderInfoSize(); } +Handle GetMainThreadHandle(void) { return ::envGetMainThreadHandle(); } +bool IsNso(void) { return ::envIsNso(); } +bool HasHeapOverride(void) { return ::envHasHeapOverride(); } +void* GetHeapOverrideAddr(void) { return ::envGetHeapOverrideAddr(); } +u64 GetHeapOverrideSize(void) { return ::envGetHeapOverrideSize(); } +bool HasArgv(void) { return ::envHasArgv(); } +void* GetArgv(void) { return ::envGetArgv(); } +bool IsSyscallHinted(unsigned svc) { return ::envIsSyscallHinted(svc); } +Handle GetOwnProcessHandle(void) { return ::envGetOwnProcessHandle(); } +LoaderReturnFn GetExitFuncPtr(void) { return ::envGetExitFuncPtr(); } +void SetExitFuncPtr(LoaderReturnFn addr) { ::envSetExitFuncPtr(addr); } +Result SetNextLoad(const char* path, const char* argv) { return ::envSetNextLoad(path, argv); } +bool HasNextLoad(void) { return ::envHasNextLoad(); } +Result GetLastLoadResult(void) { return ::envGetLastLoadResult(); } +bool HasRandomSeed(void) { return ::envHasRandomSeed(); } +void GetRandomSeed(u64 out[2]) { ::envGetRandomSeed(out); } +AccountUid* GetUserIdStorage(void) { return ::envGetUserIdStorage(); } + +} // namespace env + +namespace error { + +ErrorCode CodeCreate(u32 low, u32 desc) { return ::errorCodeCreate(low, desc); } +ErrorCode CodeCreateResult(Result res) { return ::errorCodeCreateResult(res); } +ErrorCode CodeCreateInvalid(void) { return ::errorCodeCreateInvalid(); } +bool CodeIsValid(ErrorCode errorCode) { return ::errorCodeIsValid(errorCode); } +Result ResultShow(Result res, bool jumpFlag, const ErrorContext* ctx) { return ::errorResultShow(res, jumpFlag, ctx); } +Result CodeShow(ErrorCode errorCode, bool jumpFlag, const ErrorContext* ctx) { return ::errorCodeShow(errorCode, jumpFlag, ctx); } +Result ResultBacktraceCreate(ErrorResultBacktrace* backtrace, s32 count, const Result* entries) { return ::errorResultBacktraceCreate(backtrace, count, entries); } +Result ResultBacktraceShow(Result res, const ErrorResultBacktrace* backtrace) { return ::errorResultBacktraceShow(res, backtrace); } +Result EulaShow(SetRegion RegionCode) { return ::errorEulaShow(RegionCode); } +Result SystemUpdateEulaShow(SetRegion RegionCode, const ErrorEulaData* eula) { return ::errorSystemUpdateEulaShow(RegionCode, eula); } +Result CodeRecordShow(ErrorCode errorCode, u64 timestamp) { return ::errorCodeRecordShow(errorCode, timestamp); } +Result ResultRecordShow(Result res, u64 timestamp) { return ::errorResultRecordShow(res, timestamp); } +Result SystemCreate(ErrorSystemConfig* c, const char* dialog_message, const char* fullscreen_message) { return ::errorSystemCreate(c, dialog_message, fullscreen_message); } +Result SystemShow(ErrorSystemConfig* c) { return ::errorSystemShow(c); } +void SystemSetCode(ErrorSystemConfig* c, ErrorCode errorCode) { ::errorSystemSetCode(c, errorCode); } +void SystemSetResult(ErrorSystemConfig* c, Result res) { ::errorSystemSetResult(c, res); } +void SystemSetLanguageCode(ErrorSystemConfig* c, u64 LanguageCode) { ::errorSystemSetLanguageCode(c, LanguageCode); } +void SystemSetContext(ErrorSystemConfig* c, const ErrorContext* ctx) { ::errorSystemSetContext(c, ctx); } +Result ApplicationCreate(ErrorApplicationConfig* c, const char* dialog_message, const char* fullscreen_message) { return ::errorApplicationCreate(c, dialog_message, fullscreen_message); } +Result ApplicationShow(ErrorApplicationConfig* c) { return ::errorApplicationShow(c); } +void ApplicationSetNumber(ErrorApplicationConfig* c, u32 errorNumber) { ::errorApplicationSetNumber(c, errorNumber); } +void ApplicationSetLanguageCode(ErrorApplicationConfig* c, u64 LanguageCode) { ::errorApplicationSetLanguageCode(c, LanguageCode); } + +} // namespace error + +namespace event { + +Result Create(Event* t, bool autoclear) { return ::eventCreate(t, autoclear); } +void LoadRemote(Event* t, Handle handle, bool autoclear) { ::eventLoadRemote(t, handle, autoclear); } +void Close(Event* t) { ::eventClose(t); } +bool Active(Event* t) { return ::eventActive(t); } +Result Wait(Event* t, u64 timeout) { return ::eventWait(t, timeout); } +Result Fire(Event* t) { return ::eventFire(t); } +Result Clear(Event* t) { return ::eventClear(t); } + +} // namespace event + +namespace fan { + +Result Initialize(void) { return ::fanInitialize(); } +void Exit(void) { ::fanExit(); } +Service* GetServiceSession(void) { return ::fanGetServiceSession(); } +Result OpenController(FanController *out, u32 device_code) { return ::fanOpenController(out, device_code); } +void ControllerClose(FanController *controller) { ::fanControllerClose(controller); } +Result ControllerSetRotationSpeedLevel(FanController *controller, float level) { return ::fanControllerSetRotationSpeedLevel(controller, level); } +Result ControllerGetRotationSpeedLevel(FanController *controller, float *level) { return ::fanControllerGetRotationSpeedLevel(controller, level); } + +} // namespace fan + +namespace fatal { + +[[noreturn]] void Throw(Result err) { ::fatalThrow(err); } +void ThrowWithPolicy(Result err, FatalPolicy type) { ::fatalThrowWithPolicy(err, type); } +void ThrowWithContext(Result err, FatalPolicy type, FatalCpuContext *ctx) { ::fatalThrowWithContext(err, type, ctx); } + +} // namespace fatal + +namespace framebuffer { + +Result Create(Framebuffer* fb, NWindow *win, u32 width, u32 height, u32 format, u32 num_fbs) { return ::framebufferCreate(fb, win, width, height, format, num_fbs); } +Result MakeLinear(Framebuffer* fb) { return ::framebufferMakeLinear(fb); } +void Close(Framebuffer* fb) { ::framebufferClose(fb); } +void* Begin(Framebuffer* fb, u32* out_stride) { return ::framebufferBegin(fb, out_stride); } +void End(Framebuffer* fb) { ::framebufferEnd(fb); } + +} // namespace framebuffer + +namespace friends { + +Result LaShowFriendList(AccountUid uid) { return ::friendsLaShowFriendList(uid); } +Result LaShowUserDetailInfo(AccountUid uid, AccountNetworkServiceAccountId id, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName) { return ::friendsLaShowUserDetailInfo(uid, id, first_inAppScreenName, second_inAppScreenName); } +Result LaStartSendingFriendRequest(AccountUid uid, AccountNetworkServiceAccountId id, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName) { return ::friendsLaStartSendingFriendRequest(uid, id, first_inAppScreenName, second_inAppScreenName); } +Result LaShowMethodsOfSendingFriendRequest(AccountUid uid) { return ::friendsLaShowMethodsOfSendingFriendRequest(uid); } +Result LaStartFacedFriendRequest(AccountUid uid) { return ::friendsLaStartFacedFriendRequest(uid); } +Result LaShowReceivedFriendRequestList(AccountUid uid) { return ::friendsLaShowReceivedFriendRequestList(uid); } +Result LaShowBlockedUserList(AccountUid uid) { return ::friendsLaShowBlockedUserList(uid); } +Result LaShowMyProfile(AccountUid uid) { return ::friendsLaShowMyProfile(uid); } +Result LaShowMyProfileForHomeMenu(AccountUid uid) { return ::friendsLaShowMyProfileForHomeMenu(uid); } +Result LaStartFriendInvitation(AccountUid uid, s32 id_count, const FriendsFriendInvitationGameModeDescription *desc, const void* userdata, u64 userdata_size) { return ::friendsLaStartFriendInvitation(uid, id_count, desc, userdata, userdata_size); } +Result LaStartSendingFriendInvitation(AccountUid uid, const AccountNetworkServiceAccountId *id_list, s32 id_count, const FriendsFriendInvitationGameModeDescription *desc, const void* userdata, u64 userdata_size) { return ::friendsLaStartSendingFriendInvitation(uid, id_list, id_count, desc, userdata, userdata_size); } +Result LaShowReceivedInvitationDetail(AccountUid uid, FriendsFriendInvitationId invitation_id, FriendsFriendInvitationGroupId invitation_group_id) { return ::friendsLaShowReceivedInvitationDetail(uid, invitation_id, invitation_group_id); } +Result Initialize(FriendsServiceType service_type) { return ::friendsInitialize(service_type); } +void Exit(void) { ::friendsExit(); } +Service* GetServiceSession(void) { return ::friendsGetServiceSession(); } +Service* GetServiceSession_IFriendsService(void) { return ::friendsGetServiceSession_IFriendsService(); } +Result GetUserSetting(AccountUid uid, FriendsUserSetting *user_setting) { return ::friendsGetUserSetting(uid, user_setting); } +Result GetFriendInvitationNotificationEvent(Event *out_event) { return ::friendsGetFriendInvitationNotificationEvent(out_event); } +Result TryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buffer, u64 size, u64 *out_size) { return ::friendsTryPopFriendInvitationNotificationInfo(uid, buffer, size, out_size); } + +} // namespace friends + +namespace fs { + +Result Initialize(void) { return ::fsInitialize(); } +void Exit(void) { ::fsExit(); } +Service* GetServiceSession(void) { return ::fsGetServiceSession(); } +void SetPriority(FsPriority prio) { ::fsSetPriority(prio); } +Result OpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) { return ::fsOpenFileSystem(out, fsType, contentPath); } +Result OpenDataFileSystemByCurrentProcess(FsFileSystem *out) { return ::fsOpenDataFileSystemByCurrentProcess(out); } +Result OpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsType) { return ::fsOpenFileSystemWithPatch(out, id, fsType); } +Result OpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath, FsContentAttributes attr) { return ::fsOpenFileSystemWithId(out, id, fsType, contentPath, attr); } +Result OpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id) { return ::fsOpenDataFileSystemByProgramId(out, program_id); } +Result OpenBisFileSystem(FsFileSystem* out, FsBisPartitionId partitionId, const char* string) { return ::fsOpenBisFileSystem(out, partitionId, string); } +Result OpenBisStorage(FsStorage* out, FsBisPartitionId partitionId) { return ::fsOpenBisStorage(out, partitionId); } +Result OpenSdCardFileSystem(FsFileSystem* out) { return ::fsOpenSdCardFileSystem(out); } +Result OpenHostFileSystem(FsFileSystem* out, const char *path) { return ::fsOpenHostFileSystem(out, path); } +Result OpenHostFileSystemWithOption(FsFileSystem* out, const char *path, u32 flags) { return ::fsOpenHostFileSystemWithOption(out, path, flags); } +Result DeleteSaveDataFileSystem(u64 application_id) { return ::fsDeleteSaveDataFileSystem(application_id); } +Result CreateSaveDataFileSystem(const FsSaveDataAttribute* attr, const FsSaveDataCreationInfo* creation_info, const FsSaveDataMetaInfo* meta) { return ::fsCreateSaveDataFileSystem(attr, creation_info, meta); } +Result CreateSaveDataFileSystemBySystemSaveDataId(const FsSaveDataAttribute* attr, const FsSaveDataCreationInfo* creation_info) { return ::fsCreateSaveDataFileSystemBySystemSaveDataId(attr, creation_info); } +Result DeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId save_data_space_id, u64 saveID) { return ::fsDeleteSaveDataFileSystemBySaveDataSpaceId(save_data_space_id, saveID); } +Result DeleteSaveDataFileSystemBySaveDataAttribute(FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute* attr) { return ::fsDeleteSaveDataFileSystemBySaveDataAttribute(save_data_space_id, attr); } +Result IsExFatSupported(bool* out) { return ::fsIsExFatSupported(out); } +Result OpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handle, FsGameCardPartition partition) { return ::fsOpenGameCardFileSystem(out, handle, partition); } +Result ExtendSaveDataFileSystem(FsSaveDataSpaceId save_data_space_id, u64 saveID, s64 dataSize, s64 journalSize) { return ::fsExtendSaveDataFileSystem(save_data_space_id, saveID, dataSize, journalSize); } +Result OpenSaveDataFileSystem(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute *attr) { return ::fsOpenSaveDataFileSystem(out, save_data_space_id, attr); } +Result OpenSaveDataFileSystemBySystemSaveDataId(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute *attr) { return ::fsOpenSaveDataFileSystemBySystemSaveDataId(out, save_data_space_id, attr); } +Result OpenReadOnlySaveDataFileSystem(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataAttribute *attr) { return ::fsOpenReadOnlySaveDataFileSystem(out, save_data_space_id, attr); } +Result ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(void* buf, size_t len, FsSaveDataSpaceId save_data_space_id, u64 saveID) { return ::fsReadSaveDataFileSystemExtraDataBySaveDataSpaceId(buf, len, save_data_space_id, saveID); } +Result ReadSaveDataFileSystemExtraData(void* buf, size_t len, u64 saveID) { return ::fsReadSaveDataFileSystemExtraData(buf, len, saveID); } +Result WriteSaveDataFileSystemExtraData(const void* buf, size_t len, FsSaveDataSpaceId save_data_space_id, u64 saveID) { return ::fsWriteSaveDataFileSystemExtraData(buf, len, save_data_space_id, saveID); } +Result OpenSaveDataInfoReader(FsSaveDataInfoReader* out, FsSaveDataSpaceId save_data_space_id) { return ::fsOpenSaveDataInfoReader(out, save_data_space_id); } +Result OpenSaveDataInfoReaderWithFilter(FsSaveDataInfoReader* out, FsSaveDataSpaceId save_data_space_id, const FsSaveDataFilter *save_data_filter) { return ::fsOpenSaveDataInfoReaderWithFilter(out, save_data_space_id, save_data_filter); } +Result OpenImageDirectoryFileSystem(FsFileSystem* out, FsImageDirectoryId image_directory_id) { return ::fsOpenImageDirectoryFileSystem(out, image_directory_id); } +Result OpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id) { return ::fsOpenContentStorageFileSystem(out, content_storage_id); } +Result OpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id) { return ::fsOpenCustomStorageFileSystem(out, custom_storage_id); } +Result OpenDataStorageByCurrentProcess(FsStorage* out) { return ::fsOpenDataStorageByCurrentProcess(out); } +Result OpenDataStorageByProgramId(FsStorage *out, u64 program_id) { return ::fsOpenDataStorageByProgramId(out, program_id); } +Result OpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId) { return ::fsOpenDataStorageByDataId(out, dataId, storageId); } +Result OpenPatchDataStorageByCurrentProcess(FsStorage* out) { return ::fsOpenPatchDataStorageByCurrentProcess(out); } +Result OpenDataStorageByCurrentProcessForBatchRead(FsStorageForBatchRead* out) { return ::fsOpenDataStorageByCurrentProcessForBatchRead(out); } +Result OpenDataStorageByProgramIdForBatchRead(FsStorageForBatchRead* out, u64 id) { return ::fsOpenDataStorageByProgramIdForBatchRead(out, id); } +Result OpenDataStorageWithProgramIndexForBatchRead(FsStorageForBatchRead* out, u8 program_index) { return ::fsOpenDataStorageWithProgramIndexForBatchRead(out, program_index); } +Result OpenDataStorageByPathForBatchRead(FsStorageForBatchRead* out, const char* contentPath, FsContentAttributes attributes, FsFileSystemType fsType) { return ::fsOpenDataStorageByPathForBatchRead(out, contentPath, attributes, fsType); } +Result OpenDeviceOperator(FsDeviceOperator* out) { return ::fsOpenDeviceOperator(out); } +Result OpenSdCardDetectionEventNotifier(FsEventNotifier* out) { return ::fsOpenSdCardDetectionEventNotifier(out); } +Result IsSignedSystemPartitionOnSdCardValid(bool *out) { return ::fsIsSignedSystemPartitionOnSdCardValid(out); } +Result GetProgramId(u64* out, const char *path, FsContentAttributes attr) { return ::fsGetProgramId(out, path, attr); } +Result GetRightsIdByPath(const char* path, FsRightsId* out_rights_id) { return ::fsGetRightsIdByPath(path, out_rights_id); } +Result GetRightsIdAndKeyGenerationByPath(const char* path, FsContentAttributes attr, u8* out_key_generation, FsRightsId* out_rights_id) { return ::fsGetRightsIdAndKeyGenerationByPath(path, attr, out_key_generation, out_rights_id); } +Result GetContentStorageInfoIndex(s32 *out) { return ::fsGetContentStorageInfoIndex(out); } +Result DisableAutoSaveDataCreation(void) { return ::fsDisableAutoSaveDataCreation(); } +Result SetGlobalAccessLogMode(u32 mode) { return ::fsSetGlobalAccessLogMode(mode); } +Result GetGlobalAccessLogMode(u32* out_mode) { return ::fsGetGlobalAccessLogMode(out_mode); } +Result OutputAccessLogToSdCard(const char *log, size_t size) { return ::fsOutputAccessLogToSdCard(log, size); } +Result GetAndClearErrorInfo(FsFileSystemProxyErrorInfo *out) { return ::fsGetAndClearErrorInfo(out); } +Result GetAndClearMemoryReportInfo(FsMemoryReportInfo* out) { return ::fsGetAndClearMemoryReportInfo(out); } +Result GetProgramIndexForAccessLog(u32 *out_program_index, u32 *out_program_count) { return ::fsGetProgramIndexForAccessLog(out_program_index, out_program_count); } +Result Create_TemporaryStorage(u64 application_id, u64 owner_id, s64 size, u32 flags) { return ::fsCreate_TemporaryStorage(application_id, owner_id, size, flags); } +Result Create_SystemSaveDataWithOwner(FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid, u64 owner_id, s64 size, s64 journal_size, u32 flags) { return ::fsCreate_SystemSaveDataWithOwner(save_data_space_id, system_save_data_id, uid, owner_id, size, journal_size, flags); } +Result Create_SystemSaveData(FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, s64 size, s64 journal_size, u32 flags) { return ::fsCreate_SystemSaveData(save_data_space_id, system_save_data_id, size, journal_size, flags); } +Result Open_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid) { return ::fsOpen_SaveData(out, application_id, uid); } +Result Open_SaveDataReadOnly(FsFileSystem* out, u64 application_id, AccountUid uid) { return ::fsOpen_SaveDataReadOnly(out, application_id, uid); } +Result Open_BcatSaveData(FsFileSystem* out, u64 application_id) { return ::fsOpen_BcatSaveData(out, application_id); } +Result Open_DeviceSaveData(FsFileSystem* out, u64 application_id) { return ::fsOpen_DeviceSaveData(out, application_id); } +Result Open_TemporaryStorage(FsFileSystem* out) { return ::fsOpen_TemporaryStorage(out); } +Result Open_CacheStorage(FsFileSystem* out, u64 application_id, u16 save_data_index) { return ::fsOpen_CacheStorage(out, application_id, save_data_index); } +Result Open_SystemSaveData(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid) { return ::fsOpen_SystemSaveData(out, save_data_space_id, system_save_data_id, uid); } +Result Open_SystemBcatSaveData(FsFileSystem* out, u64 system_save_data_id) { return ::fsOpen_SystemBcatSaveData(out, system_save_data_id); } +Result FsCreateFile(FsFileSystem* fs, const char* path, s64 size, u32 option) { return ::fsFsCreateFile(fs, path, size, option); } +Result FsDeleteFile(FsFileSystem* fs, const char* path) { return ::fsFsDeleteFile(fs, path); } +Result FsCreateDirectory(FsFileSystem* fs, const char* path) { return ::fsFsCreateDirectory(fs, path); } +Result FsDeleteDirectory(FsFileSystem* fs, const char* path) { return ::fsFsDeleteDirectory(fs, path); } +Result FsDeleteDirectoryRecursively(FsFileSystem* fs, const char* path) { return ::fsFsDeleteDirectoryRecursively(fs, path); } +Result FsRenameFile(FsFileSystem* fs, const char* cur_path, const char* new_path) { return ::fsFsRenameFile(fs, cur_path, new_path); } +Result FsRenameDirectory(FsFileSystem* fs, const char* cur_path, const char* new_path) { return ::fsFsRenameDirectory(fs, cur_path, new_path); } +Result FsGetEntryType(FsFileSystem* fs, const char* path, FsDirEntryType* out) { return ::fsFsGetEntryType(fs, path, out); } +Result FsOpenFile(FsFileSystem* fs, const char* path, u32 mode, FsFile* out) { return ::fsFsOpenFile(fs, path, mode, out); } +Result FsOpenDirectory(FsFileSystem* fs, const char* path, u32 mode, FsDir* out) { return ::fsFsOpenDirectory(fs, path, mode, out); } +Result FsCommit(FsFileSystem* fs) { return ::fsFsCommit(fs); } +Result FsGetFreeSpace(FsFileSystem* fs, const char* path, s64* out) { return ::fsFsGetFreeSpace(fs, path, out); } +Result FsGetTotalSpace(FsFileSystem* fs, const char* path, s64* out) { return ::fsFsGetTotalSpace(fs, path, out); } +Result FsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out) { return ::fsFsGetFileTimeStampRaw(fs, path, out); } +Result FsCleanDirectoryRecursively(FsFileSystem* fs, const char* path) { return ::fsFsCleanDirectoryRecursively(fs, path); } +Result FsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryId query_id) { return ::fsFsQueryEntry(fs, out, out_size, in, in_size, path, query_id); } +Result FsGetFileSystemAttribute(FsFileSystem* fs, FsFileSystemAttribute *out) { return ::fsFsGetFileSystemAttribute(fs, out); } +void FsClose(FsFileSystem* fs) { ::fsFsClose(fs); } +Result FsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path) { return ::fsFsSetConcatenationFileAttribute(fs, path); } +Result FsIsValidSignedSystemPartitionOnSdCard(FsFileSystem* fs, bool *out) { return ::fsFsIsValidSignedSystemPartitionOnSdCard(fs, out); } +Result FileRead(FsFile* f, s64 off, void* buf, u64 read_size, u32 option, u64* bytes_read) { return ::fsFileRead(f, off, buf, read_size, option, bytes_read); } +Result FileWrite(FsFile* f, s64 off, const void* buf, u64 write_size, u32 option) { return ::fsFileWrite(f, off, buf, write_size, option); } +Result FileFlush(FsFile* f) { return ::fsFileFlush(f); } +Result FileSetSize(FsFile* f, s64 sz) { return ::fsFileSetSize(f, sz); } +Result FileGetSize(FsFile* f, s64* out) { return ::fsFileGetSize(f, out); } +Result FileOperateRange(FsFile* f, FsOperationId op_id, s64 off, s64 len, FsRangeInfo* out) { return ::fsFileOperateRange(f, op_id, off, len, out); } +void FileClose(FsFile* f) { ::fsFileClose(f); } +Result DirRead(FsDir* d, s64* total_entries, size_t max_entries, FsDirectoryEntry *buf) { return ::fsDirRead(d, total_entries, max_entries, buf); } +Result DirGetEntryCount(FsDir* d, s64* count) { return ::fsDirGetEntryCount(d, count); } +void DirClose(FsDir* d) { ::fsDirClose(d); } +Result StorageRead(FsStorage* s, s64 off, void* buf, u64 read_size) { return ::fsStorageRead(s, off, buf, read_size); } +Result StorageWrite(FsStorage* s, s64 off, const void* buf, u64 write_size) { return ::fsStorageWrite(s, off, buf, write_size); } +Result StorageFlush(FsStorage* s) { return ::fsStorageFlush(s); } +Result StorageSetSize(FsStorage* s, s64 sz) { return ::fsStorageSetSize(s, sz); } +Result StorageGetSize(FsStorage* s, s64* out) { return ::fsStorageGetSize(s, out); } +Result StorageOperateRange(FsStorage* s, FsOperationId op_id, s64 off, s64 len, FsRangeInfo* out) { return ::fsStorageOperateRange(s, op_id, off, len, out); } +void StorageClose(FsStorage* s) { ::fsStorageClose(s); } +Result StorageForBatchReadRead(FsStorageForBatchRead* s, s64 off, void* buf, u64 read_size) { return ::fsStorageForBatchReadRead(s, off, buf, read_size); } +Result StorageForBatchReadWrite(FsStorageForBatchRead* s, s64 off, const void* buf, u64 write_size) { return ::fsStorageForBatchReadWrite(s, off, buf, write_size); } +Result StorageForBatchReadFlush(FsStorageForBatchRead* s) { return ::fsStorageForBatchReadFlush(s); } +Result StorageForBatchReadSetSize(FsStorageForBatchRead* s, s64 sz) { return ::fsStorageForBatchReadSetSize(s, sz); } +Result StorageForBatchReadGetSize(FsStorageForBatchRead* s, s64* out) { return ::fsStorageForBatchReadGetSize(s, out); } +Result StorageForBatchReadOperateRange(FsStorageForBatchRead* s, FsOperationId op_id, s64 off, s64 len, FsRangeInfo* out) { return ::fsStorageForBatchReadOperateRange(s, op_id, off, len, out); } +Result StorageForBatchReadBatchRead(FsStorageForBatchRead* s, void* out0, void* out1, void* out2, void* out3, void* out4, void* out5, void* out6, const void* in) { return ::fsStorageForBatchReadBatchRead(s, out0, out1, out2, out3, out4, out5, out6, in); } +void StorageForBatchReadClose(FsStorageForBatchRead* s) { ::fsStorageForBatchReadClose(s); } +Result SaveDataInfoReaderRead(FsSaveDataInfoReader *s, FsSaveDataInfo* buf, size_t max_entries, s64* total_entries) { return ::fsSaveDataInfoReaderRead(s, buf, max_entries, total_entries); } +void SaveDataInfoReaderClose(FsSaveDataInfoReader *s) { ::fsSaveDataInfoReaderClose(s); } +Result EventNotifierGetEventHandle(FsEventNotifier* e, Event* out, bool autoclear) { return ::fsEventNotifierGetEventHandle(e, out, autoclear); } +void EventNotifierClose(FsEventNotifier* e) { ::fsEventNotifierClose(e); } +Result DeviceOperatorIsSdCardInserted(FsDeviceOperator* d, bool* out) { return ::fsDeviceOperatorIsSdCardInserted(d, out); } +Result DeviceOperatorGetSdCardSpeedMode(FsDeviceOperator* d, s64* out) { return ::fsDeviceOperatorGetSdCardSpeedMode(d, out); } +Result DeviceOperatorGetSdCardCid(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetSdCardCid(d, dst, dst_size, size); } +Result DeviceOperatorGetSdCardUserAreaSize(FsDeviceOperator* d, s64* out) { return ::fsDeviceOperatorGetSdCardUserAreaSize(d, out); } +Result DeviceOperatorGetSdCardProtectedAreaSize(FsDeviceOperator* d, s64* out) { return ::fsDeviceOperatorGetSdCardProtectedAreaSize(d, out); } +Result DeviceOperatorGetAndClearSdCardErrorInfo(FsDeviceOperator* d, FsStorageErrorInfo* out, s64 *out_log_size, void *dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetAndClearSdCardErrorInfo(d, out, out_log_size, dst, dst_size, size); } +Result DeviceOperatorGetMmcCid(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetMmcCid(d, dst, dst_size, size); } +Result DeviceOperatorGetMmcSpeedMode(FsDeviceOperator* d, s64* out) { return ::fsDeviceOperatorGetMmcSpeedMode(d, out); } +Result DeviceOperatorGetMmcPatrolCount(FsDeviceOperator* d, u32* out) { return ::fsDeviceOperatorGetMmcPatrolCount(d, out); } +Result DeviceOperatorGetAndClearMmcErrorInfo(FsDeviceOperator* d, FsStorageErrorInfo* out, s64 *out_log_size, void *dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetAndClearMmcErrorInfo(d, out, out_log_size, dst, dst_size, size); } +Result DeviceOperatorGetMmcExtendedCsd(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetMmcExtendedCsd(d, dst, dst_size, size); } +Result DeviceOperatorIsGameCardInserted(FsDeviceOperator* d, bool* out) { return ::fsDeviceOperatorIsGameCardInserted(d, out); } +Result DeviceOperatorGetGameCardHandle(FsDeviceOperator* d, FsGameCardHandle* out) { return ::fsDeviceOperatorGetGameCardHandle(d, out); } +Result DeviceOperatorGetGameCardUpdatePartitionInfo(FsDeviceOperator* d, const FsGameCardHandle* handle, FsGameCardUpdatePartitionInfo* out) { return ::fsDeviceOperatorGetGameCardUpdatePartitionInfo(d, handle, out); } +Result DeviceOperatorGetGameCardAttribute(FsDeviceOperator* d, const FsGameCardHandle* handle, u8 *out) { return ::fsDeviceOperatorGetGameCardAttribute(d, handle, out); } +Result DeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, s64* out_size, s64 size) { return ::fsDeviceOperatorGetGameCardDeviceCertificate(d, handle, dst, dst_size, out_size, size); } +Result DeviceOperatorGetGameCardIdSet(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetGameCardIdSet(d, dst, dst_size, size); } +Result DeviceOperatorGetGameCardErrorReportInfo(FsDeviceOperator* d, FsGameCardErrorReportInfo* out) { return ::fsDeviceOperatorGetGameCardErrorReportInfo(d, out); } +Result DeviceOperatorGetGameCardDeviceId(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) { return ::fsDeviceOperatorGetGameCardDeviceId(d, dst, dst_size, size); } +Result DeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size) { return ::fsDeviceOperatorChallengeCardExistence(d, handle, dst, dst_size, seed, seed_size, value, value_size); } +void DeviceOperatorClose(FsDeviceOperator* d) { ::fsDeviceOperatorClose(d); } + +} // namespace fs + +namespace fsdev { + +FsDirectoryEntry* DirGetEntries(fsdev_dir_t *dir) { return ::fsdevDirGetEntries(dir); } +Result MountSdmc(void) { return ::fsdevMountSdmc(); } +Result MountSaveData(const char *name, u64 application_id, AccountUid uid) { return ::fsdevMountSaveData(name, application_id, uid); } +Result MountSaveDataReadOnly(const char *name, u64 application_id, AccountUid uid) { return ::fsdevMountSaveDataReadOnly(name, application_id, uid); } +Result MountBcatSaveData(const char *name, u64 application_id) { return ::fsdevMountBcatSaveData(name, application_id); } +Result MountDeviceSaveData(const char *name, u64 application_id) { return ::fsdevMountDeviceSaveData(name, application_id); } +Result MountTemporaryStorage(const char *name) { return ::fsdevMountTemporaryStorage(name); } +Result MountCacheStorage(const char *name, u64 application_id, u16 save_data_index) { return ::fsdevMountCacheStorage(name, application_id, save_data_index); } +Result MountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid) { return ::fsdevMountSystemSaveData(name, save_data_space_id, system_save_data_id, uid); } +Result MountSystemBcatSaveData(const char *name, u64 system_save_data_id) { return ::fsdevMountSystemBcatSaveData(name, system_save_data_id); } +int MountDevice(const char *name, FsFileSystem fs) { return ::fsdevMountDevice(name, fs); } +int UnmountDevice(const char *name) { return ::fsdevUnmountDevice(name); } +Result CommitDevice(const char *name) { return ::fsdevCommitDevice(name); } +FsFileSystem* GetDeviceFileSystem(const char *name) { return ::fsdevGetDeviceFileSystem(name); } +int TranslatePath(const char *path, FsFileSystem** device, char *outpath) { return ::fsdevTranslatePath(path, device, outpath); } +Result SetConcatenationFileAttribute(const char *path) { return ::fsdevSetConcatenationFileAttribute(path); } +Result IsValidSignedSystemPartitionOnSdCard(const char *name, bool *out) { return ::fsdevIsValidSignedSystemPartitionOnSdCard(name, out); } +Result CreateFile(const char* path, size_t size, u32 flags) { return ::fsdevCreateFile(path, size, flags); } +Result DeleteDirectoryRecursively(const char *path) { return ::fsdevDeleteDirectoryRecursively(path); } +Result UnmountAll(void) { return ::fsdevUnmountAll(); } +Result GetLastResult(void) { return ::fsdevGetLastResult(); } + +} // namespace fsdev + +namespace fsldr { + +Result Initialize(void) { return ::fsldrInitialize(); } +void Exit(void) { ::fsldrExit(); } +Service* GetServiceSession(void) { return ::fsldrGetServiceSession(); } +Result OpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, NcmStorageId storage_id, const char *path, FsContentAttributes attr, FsFileSystem* out) { return ::fsldrOpenCodeFileSystem(out_code_info, tid, storage_id, path, attr, out); } +Result IsArchivedProgram(u64 pid, bool *out) { return ::fsldrIsArchivedProgram(pid, out); } + +} // namespace fsldr + +namespace fspr { + +Result Initialize(void) { return ::fsprInitialize(); } +void Exit(void) { ::fsprExit(); } +Service* GetServiceSession(void) { return ::fsprGetServiceSession(); } +Result RegisterProgram(u64 pid, u64 tid, NcmStorageId sid, const void *fs_access_header, size_t fah_size, const void *fs_access_control, size_t fac_size, u8 fs_access_control_restriction_mode) { return ::fsprRegisterProgram(pid, tid, sid, fs_access_header, fah_size, fs_access_control, fac_size, fs_access_control_restriction_mode); } +Result UnregisterProgram(u64 pid) { return ::fsprUnregisterProgram(pid); } +Result SetCurrentProcess(void) { return ::fsprSetCurrentProcess(); } +Result SetEnabledProgramVerification(bool enabled) { return ::fsprSetEnabledProgramVerification(enabled); } + +} // namespace fspr + +namespace gpio { + +Result Initialize(void) { return ::gpioInitialize(); } +void Exit(void) { ::gpioExit(); } +Service* GetServiceSession(void) { return ::gpioGetServiceSession(); } +Result OpenSession(GpioPadSession *out, GpioPadName name) { return ::gpioOpenSession(out, name); } +Result OpenSession2(GpioPadSession *out, u32 device_code, u32 access_mode) { return ::gpioOpenSession2(out, device_code, access_mode); } +Result IsWakeEventActive(bool *out, GpioPadName name) { return ::gpioIsWakeEventActive(out, name); } +Result IsWakeEventActive2(bool *out, u32 device_code) { return ::gpioIsWakeEventActive2(out, device_code); } +Result PadSetDirection(GpioPadSession *p, GpioDirection dir) { return ::gpioPadSetDirection(p, dir); } +Result PadGetDirection(GpioPadSession *p, GpioDirection *out) { return ::gpioPadGetDirection(p, out); } +Result PadSetInterruptMode(GpioPadSession *p, GpioInterruptMode mode) { return ::gpioPadSetInterruptMode(p, mode); } +Result PadGetInterruptMode(GpioPadSession *p, GpioInterruptMode *out) { return ::gpioPadGetInterruptMode(p, out); } +Result PadSetInterruptEnable(GpioPadSession *p, bool en) { return ::gpioPadSetInterruptEnable(p, en); } +Result PadGetInterruptEnable(GpioPadSession *p, bool *out) { return ::gpioPadGetInterruptEnable(p, out); } +Result PadGetInterruptStatus(GpioPadSession *p, GpioInterruptStatus *out) { return ::gpioPadGetInterruptStatus(p, out); } +Result PadClearInterruptStatus(GpioPadSession *p) { return ::gpioPadClearInterruptStatus(p); } +Result PadSetValue(GpioPadSession *p, GpioValue val) { return ::gpioPadSetValue(p, val); } +Result PadGetValue(GpioPadSession *p, GpioValue *out) { return ::gpioPadGetValue(p, out); } +Result PadBindInterrupt(GpioPadSession *p, Event *out) { return ::gpioPadBindInterrupt(p, out); } +Result PadUnbindInterrupt(GpioPadSession *p) { return ::gpioPadUnbindInterrupt(p); } +Result PadSetDebounceEnabled(GpioPadSession *p, bool en) { return ::gpioPadSetDebounceEnabled(p, en); } +Result PadGetDebounceEnabled(GpioPadSession *p, bool *out) { return ::gpioPadGetDebounceEnabled(p, out); } +Result PadSetDebounceTime(GpioPadSession *p, s32 ms) { return ::gpioPadSetDebounceTime(p, ms); } +Result PadGetDebounceTime(GpioPadSession *p, s32 *out) { return ::gpioPadGetDebounceTime(p, out); } +void PadClose(GpioPadSession *p) { ::gpioPadClose(p); } + +} // namespace gpio + +namespace grc { + +Result TrimGameMovie(GrcGameMovieId *dst_movieid, const GrcGameMovieId *src_movieid, size_t tmem_size, const void* thumbnail, s32 start, s32 end) { return ::grcTrimGameMovie(dst_movieid, src_movieid, tmem_size, thumbnail, start, end); } +void CreateOffscreenRecordingParameter(GrcOffscreenRecordingParameter *param) { ::grcCreateOffscreenRecordingParameter(param); } +Result CreateMovieMaker(GrcMovieMaker *m, size_t size) { return ::grcCreateMovieMaker(m, size); } +void MovieMakerClose(GrcMovieMaker *m) { ::grcMovieMakerClose(m); } +NWindow* MovieMakerGetNWindow(GrcMovieMaker *m) { return ::grcMovieMakerGetNWindow(m); } +Result MovieMakerAbort(GrcMovieMaker *m) { return ::grcMovieMakerAbort(m); } +Result MovieMakerStart(GrcMovieMaker *m, const GrcOffscreenRecordingParameter *param) { return ::grcMovieMakerStart(m, param); } +Result MovieMakerFinish(GrcMovieMaker *m, s32 width, s32 height, const void* userdata, size_t userdata_size, const void* thumbnail, size_t thumbnail_size, CapsApplicationAlbumEntry *entry) { return ::grcMovieMakerFinish(m, width, height, userdata, userdata_size, thumbnail, thumbnail_size, entry); } +Result MovieMakerGetError(GrcMovieMaker *m) { return ::grcMovieMakerGetError(m); } +Result MovieMakerEncodeAudioSample(GrcMovieMaker *m, const void* buffer, size_t size) { return ::grcMovieMakerEncodeAudioSample(m, buffer, size); } + +} // namespace grc + +namespace grcd { + +Result Initialize(void) { return ::grcdInitialize(); } +void Exit(void) { ::grcdExit(); } +Service* GetServiceSession(void) { return ::grcdGetServiceSession(); } +Result Begin(void) { return ::grcdBegin(); } +Result Transfer(GrcStream stream, void* buffer, size_t size, u32 *num_frames, u32 *data_size, u64 *start_timestamp) { return ::grcdTransfer(stream, buffer, size, num_frames, data_size, start_timestamp); } + +} // namespace grcd + +namespace hid { + +void LaCreateControllerSupportArg(HidLaControllerSupportArg *arg) { ::hidLaCreateControllerSupportArg(arg); } +void LaCreateControllerFirmwareUpdateArg(HidLaControllerFirmwareUpdateArg *arg) { ::hidLaCreateControllerFirmwareUpdateArg(arg); } +void LaCreateControllerKeyRemappingArg(HidLaControllerKeyRemappingArg *arg) { ::hidLaCreateControllerKeyRemappingArg(arg); } +Result LaSetExplainText(HidLaControllerSupportArg *arg, const char *str, HidNpadIdType id) { return ::hidLaSetExplainText(arg, str, id); } +Result LaShowControllerSupport(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg) { return ::hidLaShowControllerSupport(result_info, arg); } +Result LaShowControllerStrapGuide(void) { return ::hidLaShowControllerStrapGuide(); } +Result LaShowControllerFirmwareUpdate(const HidLaControllerFirmwareUpdateArg *arg) { return ::hidLaShowControllerFirmwareUpdate(arg); } +Result LaShowControllerSupportForSystem(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg, bool flag) { return ::hidLaShowControllerSupportForSystem(result_info, arg, flag); } +Result LaShowControllerFirmwareUpdateForSystem(const HidLaControllerFirmwareUpdateArg *arg, HidLaControllerSupportCaller caller) { return ::hidLaShowControllerFirmwareUpdateForSystem(arg, caller); } +Result LaShowControllerKeyRemappingForSystem(const HidLaControllerKeyRemappingArg *arg, HidLaControllerSupportCaller caller) { return ::hidLaShowControllerKeyRemappingForSystem(arg, caller); } +Result Initialize(void) { return ::hidInitialize(); } +void Exit(void) { ::hidExit(); } +Service* GetServiceSession(void) { return ::hidGetServiceSession(); } +void* GetSharedmemAddr(void) { return ::hidGetSharedmemAddr(); } +void InitializeTouchScreen(void) { ::hidInitializeTouchScreen(); } +size_t GetTouchScreenStates(HidTouchScreenState *states, size_t count) { return ::hidGetTouchScreenStates(states, count); } +void InitializeMouse(void) { ::hidInitializeMouse(); } +size_t GetMouseStates(HidMouseState *states, size_t count) { return ::hidGetMouseStates(states, count); } +void InitializeKeyboard(void) { ::hidInitializeKeyboard(); } +size_t GetKeyboardStates(HidKeyboardState *states, size_t count) { return ::hidGetKeyboardStates(states, count); } +bool KeyboardStateGetKey(const HidKeyboardState *state, HidKeyboardKey key) { return ::hidKeyboardStateGetKey(state, key); } +size_t GetHomeButtonStates(HidHomeButtonState *states, size_t count) { return ::hidGetHomeButtonStates(states, count); } +size_t GetSleepButtonStates(HidSleepButtonState *states, size_t count) { return ::hidGetSleepButtonStates(states, count); } +size_t GetCaptureButtonStates(HidCaptureButtonState *states, size_t count) { return ::hidGetCaptureButtonStates(states, count); } +void InitializeNpad(void) { ::hidInitializeNpad(); } +u32 GetNpadStyleSet(HidNpadIdType id) { return ::hidGetNpadStyleSet(id); } +HidNpadJoyAssignmentMode GetNpadJoyAssignment(HidNpadIdType id) { return ::hidGetNpadJoyAssignment(id); } +Result GetNpadControllerColorSingle(HidNpadIdType id, HidNpadControllerColor *color) { return ::hidGetNpadControllerColorSingle(id, color); } +Result GetNpadControllerColorSplit(HidNpadIdType id, HidNpadControllerColor *color_left, HidNpadControllerColor *color_right) { return ::hidGetNpadControllerColorSplit(id, color_left, color_right); } +u32 GetNpadDeviceType(HidNpadIdType id) { return ::hidGetNpadDeviceType(id); } +void GetNpadSystemProperties(HidNpadIdType id, HidNpadSystemProperties *out) { ::hidGetNpadSystemProperties(id, out); } +void GetNpadSystemButtonProperties(HidNpadIdType id, HidNpadSystemButtonProperties *out) { ::hidGetNpadSystemButtonProperties(id, out); } +void GetNpadPowerInfoSingle(HidNpadIdType id, HidPowerInfo *info) { ::hidGetNpadPowerInfoSingle(id, info); } +void GetNpadPowerInfoSplit(HidNpadIdType id, HidPowerInfo *info_left, HidPowerInfo *info_right) { ::hidGetNpadPowerInfoSplit(id, info_left, info_right); } +u32 GetAppletFooterUiAttributesSet(HidNpadIdType id) { return ::hidGetAppletFooterUiAttributesSet(id); } +HidAppletFooterUiType GetAppletFooterUiTypes(HidNpadIdType id) { return ::hidGetAppletFooterUiTypes(id); } +HidNpadLagerType GetNpadLagerType(HidNpadIdType id) { return ::hidGetNpadLagerType(id); } +size_t GetNpadStatesFullKey(HidNpadIdType id, HidNpadFullKeyState *states, size_t count) { return ::hidGetNpadStatesFullKey(id, states, count); } +size_t GetNpadStatesHandheld(HidNpadIdType id, HidNpadHandheldState *states, size_t count) { return ::hidGetNpadStatesHandheld(id, states, count); } +size_t GetNpadStatesJoyDual(HidNpadIdType id, HidNpadJoyDualState *states, size_t count) { return ::hidGetNpadStatesJoyDual(id, states, count); } +size_t GetNpadStatesJoyLeft(HidNpadIdType id, HidNpadJoyLeftState *states, size_t count) { return ::hidGetNpadStatesJoyLeft(id, states, count); } +size_t GetNpadStatesJoyRight(HidNpadIdType id, HidNpadJoyRightState *states, size_t count) { return ::hidGetNpadStatesJoyRight(id, states, count); } +size_t GetNpadStatesGc(HidNpadIdType id, HidNpadGcState *states, size_t count) { return ::hidGetNpadStatesGc(id, states, count); } +size_t GetNpadStatesPalma(HidNpadIdType id, HidNpadPalmaState *states, size_t count) { return ::hidGetNpadStatesPalma(id, states, count); } +size_t GetNpadStatesLark(HidNpadIdType id, HidNpadLarkState *states, size_t count) { return ::hidGetNpadStatesLark(id, states, count); } +size_t GetNpadStatesHandheldLark(HidNpadIdType id, HidNpadHandheldLarkState *states, size_t count) { return ::hidGetNpadStatesHandheldLark(id, states, count); } +size_t GetNpadStatesLucia(HidNpadIdType id, HidNpadLuciaState *states, size_t count) { return ::hidGetNpadStatesLucia(id, states, count); } +size_t GetNpadStatesLager(HidNpadIdType id, HidNpadLagerState *states, size_t count) { return ::hidGetNpadStatesLager(id, states, count); } +size_t GetNpadStatesSystemExt(HidNpadIdType id, HidNpadSystemExtState *states, size_t count) { return ::hidGetNpadStatesSystemExt(id, states, count); } +size_t GetNpadStatesSystem(HidNpadIdType id, HidNpadSystemState *states, size_t count) { return ::hidGetNpadStatesSystem(id, states, count); } +size_t GetSixAxisSensorStates(HidSixAxisSensorHandle handle, HidSixAxisSensorState *states, size_t count) { return ::hidGetSixAxisSensorStates(handle, states, count); } +void InitializeGesture(void) { ::hidInitializeGesture(); } +size_t GetGestureStates(HidGestureState *states, size_t count) { return ::hidGetGestureStates(states, count); } +Result SendKeyboardLockKeyEvent(u32 events) { return ::hidSendKeyboardLockKeyEvent(events); } +Result GetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style) { return ::hidGetSixAxisSensorHandles(handles, total_handles, id, style); } +Result StartSixAxisSensor(HidSixAxisSensorHandle handle) { return ::hidStartSixAxisSensor(handle); } +Result StopSixAxisSensor(HidSixAxisSensorHandle handle) { return ::hidStopSixAxisSensor(handle); } +Result IsSixAxisSensorFusionEnabled(HidSixAxisSensorHandle handle, bool *out) { return ::hidIsSixAxisSensorFusionEnabled(handle, out); } +Result EnableSixAxisSensorFusion(HidSixAxisSensorHandle handle, bool flag) { return ::hidEnableSixAxisSensorFusion(handle, flag); } +Result SetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle, float unk0, float unk1) { return ::hidSetSixAxisSensorFusionParameters(handle, unk0, unk1); } +Result GetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle, float *unk0, float *unk1) { return ::hidGetSixAxisSensorFusionParameters(handle, unk0, unk1); } +Result ResetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle) { return ::hidResetSixAxisSensorFusionParameters(handle); } +Result SetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle, HidGyroscopeZeroDriftMode mode) { return ::hidSetGyroscopeZeroDriftMode(handle, mode); } +Result GetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle, HidGyroscopeZeroDriftMode *mode) { return ::hidGetGyroscopeZeroDriftMode(handle, mode); } +Result ResetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle) { return ::hidResetGyroscopeZeroDriftMode(handle); } +Result IsSixAxisSensorAtRest(HidSixAxisSensorHandle handle, bool *out) { return ::hidIsSixAxisSensorAtRest(handle, out); } +Result IsFirmwareUpdateAvailableForSixAxisSensor(HidSixAxisSensorHandle handle, bool *out) { return ::hidIsFirmwareUpdateAvailableForSixAxisSensor(handle, out); } +Result SetSupportedNpadStyleSet(u32 style_set) { return ::hidSetSupportedNpadStyleSet(style_set); } +Result GetSupportedNpadStyleSet(u32 *style_set) { return ::hidGetSupportedNpadStyleSet(style_set); } +Result SetSupportedNpadIdType(const HidNpadIdType *ids, size_t count) { return ::hidSetSupportedNpadIdType(ids, count); } +Result AcquireNpadStyleSetUpdateEventHandle(HidNpadIdType id, Event* out_event, bool autoclear) { return ::hidAcquireNpadStyleSetUpdateEventHandle(id, out_event, autoclear); } +Result DisconnectNpad(HidNpadIdType id) { return ::hidDisconnectNpad(id); } +Result GetPlayerLedPattern(HidNpadIdType id, u8 *out) { return ::hidGetPlayerLedPattern(id, out); } +Result SetNpadJoyHoldType(HidNpadJoyHoldType type) { return ::hidSetNpadJoyHoldType(type); } +Result GetNpadJoyHoldType(HidNpadJoyHoldType *type) { return ::hidGetNpadJoyHoldType(type); } +Result SetNpadJoyAssignmentModeSingleByDefault(HidNpadIdType id) { return ::hidSetNpadJoyAssignmentModeSingleByDefault(id); } +Result SetNpadJoyAssignmentModeSingle(HidNpadIdType id, HidNpadJoyDeviceType type) { return ::hidSetNpadJoyAssignmentModeSingle(id, type); } +Result SetNpadJoyAssignmentModeDual(HidNpadIdType id) { return ::hidSetNpadJoyAssignmentModeDual(id); } +Result MergeSingleJoyAsDualJoy(HidNpadIdType id0, HidNpadIdType id1) { return ::hidMergeSingleJoyAsDualJoy(id0, id1); } +Result StartLrAssignmentMode(void) { return ::hidStartLrAssignmentMode(); } +Result StopLrAssignmentMode(void) { return ::hidStopLrAssignmentMode(); } +Result SetNpadHandheldActivationMode(HidNpadHandheldActivationMode mode) { return ::hidSetNpadHandheldActivationMode(mode); } +Result GetNpadHandheldActivationMode(HidNpadHandheldActivationMode *out) { return ::hidGetNpadHandheldActivationMode(out); } +Result SwapNpadAssignment(HidNpadIdType id0, HidNpadIdType id1) { return ::hidSwapNpadAssignment(id0, id1); } +Result EnableUnintendedHomeButtonInputProtection(HidNpadIdType id, bool flag) { return ::hidEnableUnintendedHomeButtonInputProtection(id, flag); } +Result SetNpadJoyAssignmentModeSingleWithDestination(HidNpadIdType id, HidNpadJoyDeviceType type, bool *flag, HidNpadIdType *dest) { return ::hidSetNpadJoyAssignmentModeSingleWithDestination(id, type, flag, dest); } +Result SetNpadAnalogStickUseCenterClamp(bool flag) { return ::hidSetNpadAnalogStickUseCenterClamp(flag); } +Result SetNpadCaptureButtonAssignment(HidNpadStyleTag style, u64 buttons) { return ::hidSetNpadCaptureButtonAssignment(style, buttons); } +Result ClearNpadCaptureButtonAssignment(void) { return ::hidClearNpadCaptureButtonAssignment(); } +Result InitializeVibrationDevices(HidVibrationDeviceHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style) { return ::hidInitializeVibrationDevices(handles, total_handles, id, style); } +Result GetVibrationDeviceInfo(HidVibrationDeviceHandle handle, HidVibrationDeviceInfo *out) { return ::hidGetVibrationDeviceInfo(handle, out); } +Result SendVibrationValue(HidVibrationDeviceHandle handle, const HidVibrationValue *value) { return ::hidSendVibrationValue(handle, value); } +Result GetActualVibrationValue(HidVibrationDeviceHandle handle, HidVibrationValue *out) { return ::hidGetActualVibrationValue(handle, out); } +Result PermitVibration(bool flag) { return ::hidPermitVibration(flag); } +Result IsVibrationPermitted(bool *flag) { return ::hidIsVibrationPermitted(flag); } +Result SendVibrationValues(const HidVibrationDeviceHandle *handles, const HidVibrationValue *values, s32 count) { return ::hidSendVibrationValues(handles, values, count); } +Result SendVibrationGcErmCommand(HidVibrationDeviceHandle handle, HidVibrationGcErmCommand cmd) { return ::hidSendVibrationGcErmCommand(handle, cmd); } +Result GetActualVibrationGcErmCommand(HidVibrationDeviceHandle handle, HidVibrationGcErmCommand *out) { return ::hidGetActualVibrationGcErmCommand(handle, out); } +Result BeginPermitVibrationSession(void) { return ::hidBeginPermitVibrationSession(); } +Result EndPermitVibrationSession(void) { return ::hidEndPermitVibrationSession(); } +Result IsVibrationDeviceMounted(HidVibrationDeviceHandle handle, bool *flag) { return ::hidIsVibrationDeviceMounted(handle, flag); } +Result StartSevenSixAxisSensor(void) { return ::hidStartSevenSixAxisSensor(); } +Result StopSevenSixAxisSensor(void) { return ::hidStopSevenSixAxisSensor(); } +Result InitializeSevenSixAxisSensor(void) { return ::hidInitializeSevenSixAxisSensor(); } +Result FinalizeSevenSixAxisSensor(void) { return ::hidFinalizeSevenSixAxisSensor(); } +Result SetSevenSixAxisSensorFusionStrength(float strength) { return ::hidSetSevenSixAxisSensorFusionStrength(strength); } +Result GetSevenSixAxisSensorFusionStrength(float *strength) { return ::hidGetSevenSixAxisSensorFusionStrength(strength); } +Result ResetSevenSixAxisSensorTimestamp(void) { return ::hidResetSevenSixAxisSensorTimestamp(); } +Result GetSevenSixAxisSensorStates(HidSevenSixAxisSensorState *states, size_t count, size_t *total_out) { return ::hidGetSevenSixAxisSensorStates(states, count, total_out); } +Result IsSevenSixAxisSensorAtRest(bool *out) { return ::hidIsSevenSixAxisSensorAtRest(out); } +Result GetSensorFusionError(float *out) { return ::hidGetSensorFusionError(out); } +Result GetGyroBias(UtilFloat3 *out) { return ::hidGetGyroBias(out); } +Result IsUsbFullKeyControllerEnabled(bool *out) { return ::hidIsUsbFullKeyControllerEnabled(out); } +Result EnableUsbFullKeyController(bool flag) { return ::hidEnableUsbFullKeyController(flag); } +Result IsUsbFullKeyControllerConnected(HidNpadIdType id, bool *out) { return ::hidIsUsbFullKeyControllerConnected(id, out); } +Result GetNpadInterfaceType(HidNpadIdType id, u8 *out) { return ::hidGetNpadInterfaceType(id, out); } +Result GetNpadOfHighestBatteryLevel(const HidNpadIdType *ids, size_t count, HidNpadIdType *out) { return ::hidGetNpadOfHighestBatteryLevel(ids, count, out); } +Result GetPalmaConnectionHandle(HidNpadIdType id, HidPalmaConnectionHandle *out) { return ::hidGetPalmaConnectionHandle(id, out); } +Result InitializePalma(HidPalmaConnectionHandle handle) { return ::hidInitializePalma(handle); } +Result AcquirePalmaOperationCompleteEvent(HidPalmaConnectionHandle handle, Event* out_event, bool autoclear) { return ::hidAcquirePalmaOperationCompleteEvent(handle, out_event, autoclear); } +Result GetPalmaOperationInfo(HidPalmaConnectionHandle handle, HidPalmaOperationInfo *out) { return ::hidGetPalmaOperationInfo(handle, out); } +Result PlayPalmaActivity(HidPalmaConnectionHandle handle, u16 val) { return ::hidPlayPalmaActivity(handle, val); } +Result SetPalmaFrModeType(HidPalmaConnectionHandle handle, HidPalmaFrModeType type) { return ::hidSetPalmaFrModeType(handle, type); } +Result ReadPalmaStep(HidPalmaConnectionHandle handle) { return ::hidReadPalmaStep(handle); } +Result EnablePalmaStep(HidPalmaConnectionHandle handle, bool flag) { return ::hidEnablePalmaStep(handle, flag); } +Result ResetPalmaStep(HidPalmaConnectionHandle handle) { return ::hidResetPalmaStep(handle); } +Result ReadPalmaApplicationSection(HidPalmaConnectionHandle handle, s32 inval0, u64 size) { return ::hidReadPalmaApplicationSection(handle, inval0, size); } +Result WritePalmaApplicationSection(HidPalmaConnectionHandle handle, s32 inval0, u64 size, const HidPalmaApplicationSectionAccessBuffer *buf) { return ::hidWritePalmaApplicationSection(handle, inval0, size, buf); } +Result ReadPalmaUniqueCode(HidPalmaConnectionHandle handle) { return ::hidReadPalmaUniqueCode(handle); } +Result SetPalmaUniqueCodeInvalid(HidPalmaConnectionHandle handle) { return ::hidSetPalmaUniqueCodeInvalid(handle); } +Result WritePalmaActivityEntry(HidPalmaConnectionHandle handle, u16 unk, const HidPalmaActivityEntry *entry) { return ::hidWritePalmaActivityEntry(handle, unk, entry); } +Result WritePalmaRgbLedPatternEntry(HidPalmaConnectionHandle handle, u16 unk, const void* buffer, size_t size) { return ::hidWritePalmaRgbLedPatternEntry(handle, unk, buffer, size); } +Result WritePalmaWaveEntry(HidPalmaConnectionHandle handle, HidPalmaWaveSet wave_set, u16 unk, const void* buffer, size_t tmem_size, size_t size) { return ::hidWritePalmaWaveEntry(handle, wave_set, unk, buffer, tmem_size, size); } +Result SetPalmaDataBaseIdentificationVersion(HidPalmaConnectionHandle handle, s32 version) { return ::hidSetPalmaDataBaseIdentificationVersion(handle, version); } +Result GetPalmaDataBaseIdentificationVersion(HidPalmaConnectionHandle handle) { return ::hidGetPalmaDataBaseIdentificationVersion(handle); } +Result SuspendPalmaFeature(HidPalmaConnectionHandle handle, u32 features) { return ::hidSuspendPalmaFeature(handle, features); } +Result ReadPalmaPlayLog(HidPalmaConnectionHandle handle, u16 unk) { return ::hidReadPalmaPlayLog(handle, unk); } +Result ResetPalmaPlayLog(HidPalmaConnectionHandle handle, u16 unk) { return ::hidResetPalmaPlayLog(handle, unk); } +Result SetIsPalmaAllConnectable(bool flag) { return ::hidSetIsPalmaAllConnectable(flag); } +Result SetIsPalmaPairedConnectable(bool flag) { return ::hidSetIsPalmaPairedConnectable(flag); } +Result PairPalma(HidPalmaConnectionHandle handle) { return ::hidPairPalma(handle); } +Result CancelWritePalmaWaveEntry(HidPalmaConnectionHandle handle) { return ::hidCancelWritePalmaWaveEntry(handle); } +Result EnablePalmaBoostMode(bool flag) { return ::hidEnablePalmaBoostMode(flag); } +Result GetPalmaBluetoothAddress(HidPalmaConnectionHandle handle, BtdrvAddress *out) { return ::hidGetPalmaBluetoothAddress(handle, out); } +Result SetDisallowedPalmaConnection(const BtdrvAddress *addrs, s32 count) { return ::hidSetDisallowedPalmaConnection(addrs, count); } +Result SetNpadCommunicationMode(HidNpadCommunicationMode mode) { return ::hidSetNpadCommunicationMode(mode); } +Result GetNpadCommunicationMode(HidNpadCommunicationMode *out) { return ::hidGetNpadCommunicationMode(out); } +Result SetTouchScreenConfiguration(const HidTouchScreenConfigurationForNx *config) { return ::hidSetTouchScreenConfiguration(config); } +Result IsFirmwareUpdateNeededForNotification(bool *out) { return ::hidIsFirmwareUpdateNeededForNotification(out); } + +} // namespace hid + +namespace hidbus { + +Result GetServiceSession(Service* srv_out) { return ::hidbusGetServiceSession(srv_out); } +void* GetSharedmemAddr(void) { return ::hidbusGetSharedmemAddr(); } +Result GetBusHandle(HidbusBusHandle *handle, bool *flag, HidNpadIdType id, HidbusBusType bus_type) { return ::hidbusGetBusHandle(handle, flag, id, bus_type); } +Result Initialize(HidbusBusHandle handle) { return ::hidbusInitialize(handle); } +Result Finalize(HidbusBusHandle handle) { return ::hidbusFinalize(handle); } +Result EnableExternalDevice(HidbusBusHandle handle, bool flag, u32 device_id) { return ::hidbusEnableExternalDevice(handle, flag, device_id); } +Result SendAndReceive(HidbusBusHandle handle, const void* inbuf, size_t inbuf_size, void* outbuf, size_t outbuf_size, u64 *out_size) { return ::hidbusSendAndReceive(handle, inbuf, inbuf_size, outbuf, outbuf_size, out_size); } +Result EnableJoyPollingReceiveMode(HidbusBusHandle handle, const void* inbuf, size_t inbuf_size, void* workbuf, size_t workbuf_size, HidbusJoyPollingMode polling_mode) { return ::hidbusEnableJoyPollingReceiveMode(handle, inbuf, inbuf_size, workbuf, workbuf_size, polling_mode); } +Result DisableJoyPollingReceiveMode(HidbusBusHandle handle) { return ::hidbusDisableJoyPollingReceiveMode(handle); } +Result GetJoyPollingReceivedData(HidbusBusHandle handle, HidbusJoyPollingReceivedData *recv_data, s32 count) { return ::hidbusGetJoyPollingReceivedData(handle, recv_data, count); } + +} // namespace hidbus + +namespace hiddbg { + +Result Initialize(void) { return ::hiddbgInitialize(); } +void Exit(void) { ::hiddbgExit(); } +Service* GetServiceSession(void) { return ::hiddbgGetServiceSession(); } +Result SetDebugPadAutoPilotState(const HiddbgDebugPadAutoPilotState *state) { return ::hiddbgSetDebugPadAutoPilotState(state); } +Result UnsetDebugPadAutoPilotState(void) { return ::hiddbgUnsetDebugPadAutoPilotState(); } +Result SetTouchScreenAutoPilotState(const HidTouchState *states, s32 count) { return ::hiddbgSetTouchScreenAutoPilotState(states, count); } +Result UnsetTouchScreenAutoPilotState(void) { return ::hiddbgUnsetTouchScreenAutoPilotState(); } +Result SetMouseAutoPilotState(const HiddbgMouseAutoPilotState *state) { return ::hiddbgSetMouseAutoPilotState(state); } +Result UnsetMouseAutoPilotState(void) { return ::hiddbgUnsetMouseAutoPilotState(); } +Result SetKeyboardAutoPilotState(const HiddbgKeyboardAutoPilotState *state) { return ::hiddbgSetKeyboardAutoPilotState(state); } +Result UnsetKeyboardAutoPilotState(void) { return ::hiddbgUnsetKeyboardAutoPilotState(); } +Result DeactivateHomeButton(void) { return ::hiddbgDeactivateHomeButton(); } +Result SetSleepButtonAutoPilotState(const HiddbgSleepButtonAutoPilotState *state) { return ::hiddbgSetSleepButtonAutoPilotState(state); } +Result UnsetSleepButtonAutoPilotState(void) { return ::hiddbgUnsetSleepButtonAutoPilotState(); } +Result UpdateControllerColor(u32 colorBody, u32 colorButtons, HidsysUniquePadId unique_pad_id) { return ::hiddbgUpdateControllerColor(colorBody, colorButtons, unique_pad_id); } +Result UpdateDesignInfo(u32 colorBody, u32 colorButtons, u32 colorLeftGrip, u32 colorRightGrip, u8 inval, HidsysUniquePadId unique_pad_id) { return ::hiddbgUpdateDesignInfo(colorBody, colorButtons, colorLeftGrip, colorRightGrip, inval, unique_pad_id); } +Result AcquireOperationEventHandle(Event* out_event, bool autoclear, HidsysUniquePadId unique_pad_id) { return ::hiddbgAcquireOperationEventHandle(out_event, autoclear, unique_pad_id); } +Result ReadSerialFlash(u32 offset, void* buffer, size_t size, HidsysUniquePadId unique_pad_id) { return ::hiddbgReadSerialFlash(offset, buffer, size, unique_pad_id); } +Result WriteSerialFlash(u32 offset, void* buffer, size_t tmem_size, size_t size, HidsysUniquePadId unique_pad_id) { return ::hiddbgWriteSerialFlash(offset, buffer, tmem_size, size, unique_pad_id); } +Result GetOperationResult(HidsysUniquePadId unique_pad_id) { return ::hiddbgGetOperationResult(unique_pad_id); } +Result GetUniquePadDeviceTypeSetInternal(HidsysUniquePadId unique_pad_id, u32 *out) { return ::hiddbgGetUniquePadDeviceTypeSetInternal(unique_pad_id, out); } +Result GetAbstractedPadHandles(HiddbgAbstractedPadHandle *handles, s32 count, s32 *total_out) { return ::hiddbgGetAbstractedPadHandles(handles, count, total_out); } +Result GetAbstractedPadState(HiddbgAbstractedPadHandle handle, HiddbgAbstractedPadState *state) { return ::hiddbgGetAbstractedPadState(handle, state); } +Result GetAbstractedPadsState(HiddbgAbstractedPadHandle *handles, HiddbgAbstractedPadState *states, s32 count, s32 *total_out) { return ::hiddbgGetAbstractedPadsState(handles, states, count, total_out); } +Result SetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const HiddbgAbstractedPadState *state) { return ::hiddbgSetAutoPilotVirtualPadState(AbstractedVirtualPadId, state); } +Result UnsetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId) { return ::hiddbgUnsetAutoPilotVirtualPadState(AbstractedVirtualPadId); } +Result UnsetAllAutoPilotVirtualPadState(void) { return ::hiddbgUnsetAllAutoPilotVirtualPadState(); } +Result AttachHdlsWorkBuffer(HiddbgHdlsSessionId *session_id, void *buffer, size_t size) { return ::hiddbgAttachHdlsWorkBuffer(session_id, buffer, size); } +Result ReleaseHdlsWorkBuffer(HiddbgHdlsSessionId session_id) { return ::hiddbgReleaseHdlsWorkBuffer(session_id); } +Result IsHdlsVirtualDeviceAttached(HiddbgHdlsSessionId session_id, HiddbgHdlsHandle handle, bool *out) { return ::hiddbgIsHdlsVirtualDeviceAttached(session_id, handle, out); } +Result DumpHdlsNpadAssignmentState(HiddbgHdlsSessionId session_id, HiddbgHdlsNpadAssignment *state) { return ::hiddbgDumpHdlsNpadAssignmentState(session_id, state); } +Result DumpHdlsStates(HiddbgHdlsSessionId session_id, HiddbgHdlsStateList *state) { return ::hiddbgDumpHdlsStates(session_id, state); } +Result ApplyHdlsNpadAssignmentState(HiddbgHdlsSessionId session_id, const HiddbgHdlsNpadAssignment *state, bool flag) { return ::hiddbgApplyHdlsNpadAssignmentState(session_id, state, flag); } +Result ApplyHdlsStateList(HiddbgHdlsSessionId session_id, const HiddbgHdlsStateList *state) { return ::hiddbgApplyHdlsStateList(session_id, state); } +Result AttachHdlsVirtualDevice(HiddbgHdlsHandle *handle, const HiddbgHdlsDeviceInfo *info) { return ::hiddbgAttachHdlsVirtualDevice(handle, info); } +Result DetachHdlsVirtualDevice(HiddbgHdlsHandle handle) { return ::hiddbgDetachHdlsVirtualDevice(handle); } +Result SetHdlsState(HiddbgHdlsHandle handle, const HiddbgHdlsState *state) { return ::hiddbgSetHdlsState(handle, state); } + +} // namespace hiddbg + +namespace hidsys { + +Result Initialize(void) { return ::hidsysInitialize(); } +void Exit(void) { ::hidsysExit(); } +Service* GetServiceSession(void) { return ::hidsysGetServiceSession(); } +Result SendKeyboardLockKeyEvent(u32 events) { return ::hidsysSendKeyboardLockKeyEvent(events); } +Result AcquireHomeButtonEventHandle(Event* out_event, bool autoclear) { return ::hidsysAcquireHomeButtonEventHandle(out_event, autoclear); } +Result ActivateHomeButton(void) { return ::hidsysActivateHomeButton(); } +Result AcquireSleepButtonEventHandle(Event* out_event, bool autoclear) { return ::hidsysAcquireSleepButtonEventHandle(out_event, autoclear); } +Result ActivateSleepButton(void) { return ::hidsysActivateSleepButton(); } +Result AcquireCaptureButtonEventHandle(Event* out_event, bool autoclear) { return ::hidsysAcquireCaptureButtonEventHandle(out_event, autoclear); } +Result ActivateCaptureButton(void) { return ::hidsysActivateCaptureButton(); } +Result ApplyNpadSystemCommonPolicy(void) { return ::hidsysApplyNpadSystemCommonPolicy(); } +Result GetLastActiveNpad(u32 *out) { return ::hidsysGetLastActiveNpad(out); } +Result GetSupportedNpadStyleSetOfCallerApplet(u32 *out) { return ::hidsysGetSupportedNpadStyleSetOfCallerApplet(out); } +Result GetNpadInterfaceType(HidNpadIdType id, u8 *out) { return ::hidsysGetNpadInterfaceType(id, out); } +Result GetNpadLeftRightInterfaceType(HidNpadIdType id, u8 *out0, u8 *out1) { return ::hidsysGetNpadLeftRightInterfaceType(id, out0, out1); } +Result HasBattery(HidNpadIdType id, bool *out) { return ::hidsysHasBattery(id, out); } +Result HasLeftRightBattery(HidNpadIdType id, bool *out0, bool *out1) { return ::hidsysHasLeftRightBattery(id, out0, out1); } +Result GetUniquePadsFromNpad(HidNpadIdType id, HidsysUniquePadId *unique_pad_ids, s32 count, s32 *total_out) { return ::hidsysGetUniquePadsFromNpad(id, unique_pad_ids, count, total_out); } +Result SetAppletResourceUserId(void) { return ::hidsysSetAppletResourceUserId(); } +Result EnableAppletToGetInput(bool enable) { return ::hidsysEnableAppletToGetInput(enable); } +Result EnableHandheldHids(void) { return ::hidsysEnableHandheldHids(); } +Result DisableHandheldHids(void) { return ::hidsysDisableHandheldHids(); } +Result SetJoyConRailEnabled(bool enable) { return ::hidsysSetJoyConRailEnabled(enable); } +Result IsJoyConRailEnabled(bool *out) { return ::hidsysIsJoyConRailEnabled(out); } +Result IsHandheldHidsEnabled(bool *out) { return ::hidsysIsHandheldHidsEnabled(out); } +Result IsJoyConAttachedOnAllRail(bool *out) { return ::hidsysIsJoyConAttachedOnAllRail(out); } +Result IsInvertedControllerConnectedOnRail(bool *out) { return ::hidsysIsInvertedControllerConnectedOnRail(out); } +Result AcquireUniquePadConnectionEventHandle(Event *out_event) { return ::hidsysAcquireUniquePadConnectionEventHandle(out_event); } +Result GetUniquePadIds(HidsysUniquePadId *unique_pad_ids, s32 count, s32 *total_out) { return ::hidsysGetUniquePadIds(unique_pad_ids, count, total_out); } +Result AcquireJoyDetachOnBluetoothOffEventHandle(Event *out_event, bool autoclear) { return ::hidsysAcquireJoyDetachOnBluetoothOffEventHandle(out_event, autoclear); } +Result GetUniquePadBluetoothAddress(HidsysUniquePadId unique_pad_id, BtdrvAddress *address) { return ::hidsysGetUniquePadBluetoothAddress(unique_pad_id, address); } +Result DisconnectUniquePad(HidsysUniquePadId unique_pad_id) { return ::hidsysDisconnectUniquePad(unique_pad_id); } +Result GetUniquePadType(HidsysUniquePadId unique_pad_id, HidsysUniquePadType *pad_type) { return ::hidsysGetUniquePadType(unique_pad_id, pad_type); } +Result GetUniquePadInterface(HidsysUniquePadId unique_pad_id, HidNpadInterfaceType *interface) { return ::hidsysGetUniquePadInterface(unique_pad_id, interface); } +Result GetUniquePadSerialNumber(HidsysUniquePadId unique_pad_id, HidsysUniquePadSerialNumber *serial) { return ::hidsysGetUniquePadSerialNumber(unique_pad_id, serial); } +Result GetUniquePadControllerNumber(HidsysUniquePadId unique_pad_id, u64 *number) { return ::hidsysGetUniquePadControllerNumber(unique_pad_id, number); } +Result SetNotificationLedPattern(const HidsysNotificationLedPattern *pattern, HidsysUniquePadId unique_pad_id) { return ::hidsysSetNotificationLedPattern(pattern, unique_pad_id); } +Result SetNotificationLedPatternWithTimeout(const HidsysNotificationLedPattern *pattern, HidsysUniquePadId unique_pad_id, u64 timeout) { return ::hidsysSetNotificationLedPatternWithTimeout(pattern, unique_pad_id, timeout); } +Result IsUsbFullKeyControllerEnabled(bool *out) { return ::hidsysIsUsbFullKeyControllerEnabled(out); } +Result EnableUsbFullKeyController(bool flag) { return ::hidsysEnableUsbFullKeyController(flag); } +Result IsUsbConnected(HidsysUniquePadId unique_pad_id, bool *out) { return ::hidsysIsUsbConnected(unique_pad_id, out); } +Result GetTouchScreenDefaultConfiguration(HidTouchScreenConfigurationForNx *touch_screen_configuration) { return ::hidsysGetTouchScreenDefaultConfiguration(touch_screen_configuration); } +Result IsFirmwareUpdateNeededForNotification(HidsysUniquePadId unique_pad_id, bool *out) { return ::hidsysIsFirmwareUpdateNeededForNotification(unique_pad_id, out); } +Result LegacyIsButtonConfigSupported(HidsysUniquePadId unique_pad_id, bool *out) { return ::hidsysLegacyIsButtonConfigSupported(unique_pad_id, out); } +Result IsButtonConfigSupported(BtdrvAddress addr, bool *out) { return ::hidsysIsButtonConfigSupported(addr, out); } +Result IsButtonConfigEmbeddedSupported(bool *out) { return ::hidsysIsButtonConfigEmbeddedSupported(out); } +Result LegacyDeleteButtonConfig(HidsysUniquePadId unique_pad_id) { return ::hidsysLegacyDeleteButtonConfig(unique_pad_id); } +Result DeleteButtonConfig(BtdrvAddress addr) { return ::hidsysDeleteButtonConfig(addr); } +Result DeleteButtonConfigEmbedded(void) { return ::hidsysDeleteButtonConfigEmbedded(); } +Result LegacySetButtonConfigEnabled(HidsysUniquePadId unique_pad_id, bool flag) { return ::hidsysLegacySetButtonConfigEnabled(unique_pad_id, flag); } +Result SetButtonConfigEnabled(BtdrvAddress addr, bool flag) { return ::hidsysSetButtonConfigEnabled(addr, flag); } +Result SetButtonConfigEmbeddedEnabled(bool flag) { return ::hidsysSetButtonConfigEmbeddedEnabled(flag); } +Result LegacyIsButtonConfigEnabled(HidsysUniquePadId unique_pad_id, bool *out) { return ::hidsysLegacyIsButtonConfigEnabled(unique_pad_id, out); } +Result IsButtonConfigEnabled(BtdrvAddress addr, bool *out) { return ::hidsysIsButtonConfigEnabled(addr, out); } +Result IsButtonConfigEmbeddedEnabled(bool *out) { return ::hidsysIsButtonConfigEmbeddedEnabled(out); } +Result LegacySetButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigEmbedded *config) { return ::hidsysLegacySetButtonConfigEmbedded(unique_pad_id, config); } +Result SetButtonConfigEmbedded(const HidsysButtonConfigEmbedded *config) { return ::hidsysSetButtonConfigEmbedded(config); } +Result LegacySetButtonConfigFull(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigFull *config) { return ::hidsysLegacySetButtonConfigFull(unique_pad_id, config); } +Result SetButtonConfigFull(BtdrvAddress addr, const HidsysButtonConfigFull *config) { return ::hidsysSetButtonConfigFull(addr, config); } +Result LegacySetButtonConfigLeft(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigLeft *config) { return ::hidsysLegacySetButtonConfigLeft(unique_pad_id, config); } +Result SetButtonConfigLeft(BtdrvAddress addr, const HidsysButtonConfigLeft *config) { return ::hidsysSetButtonConfigLeft(addr, config); } +Result LegacySetButtonConfigRight(HidsysUniquePadId unique_pad_id, const HidsysButtonConfigRight *config) { return ::hidsysLegacySetButtonConfigRight(unique_pad_id, config); } +Result SetButtonConfigRight(BtdrvAddress addr, const HidsysButtonConfigRight *config) { return ::hidsysSetButtonConfigRight(addr, config); } +Result LegacyGetButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, HidsysButtonConfigEmbedded *config) { return ::hidsysLegacyGetButtonConfigEmbedded(unique_pad_id, config); } +Result GetButtonConfigEmbedded(HidsysButtonConfigEmbedded *config) { return ::hidsysGetButtonConfigEmbedded(config); } +Result LegacyGetButtonConfigFull(HidsysUniquePadId unique_pad_id, HidsysButtonConfigFull *config) { return ::hidsysLegacyGetButtonConfigFull(unique_pad_id, config); } +Result GetButtonConfigFull(BtdrvAddress addr, HidsysButtonConfigFull *config) { return ::hidsysGetButtonConfigFull(addr, config); } +Result LegacyGetButtonConfigLeft(HidsysUniquePadId unique_pad_id, HidsysButtonConfigLeft *config) { return ::hidsysLegacyGetButtonConfigLeft(unique_pad_id, config); } +Result GetButtonConfigLeft(BtdrvAddress addr, HidsysButtonConfigLeft *config) { return ::hidsysGetButtonConfigLeft(addr, config); } +Result LegacyGetButtonConfigRight(HidsysUniquePadId unique_pad_id, HidsysButtonConfigRight *config) { return ::hidsysLegacyGetButtonConfigRight(unique_pad_id, config); } +Result GetButtonConfigRight(BtdrvAddress addr, HidsysButtonConfigRight *config) { return ::hidsysGetButtonConfigRight(addr, config); } +Result IsCustomButtonConfigSupported(HidsysUniquePadId unique_pad_id, bool *out) { return ::hidsysIsCustomButtonConfigSupported(unique_pad_id, out); } +Result IsDefaultButtonConfigEmbedded(const HidcfgButtonConfigEmbedded *config, bool *out) { return ::hidsysIsDefaultButtonConfigEmbedded(config, out); } +Result IsDefaultButtonConfigFull(const HidcfgButtonConfigFull *config, bool *out) { return ::hidsysIsDefaultButtonConfigFull(config, out); } +Result IsDefaultButtonConfigLeft(const HidcfgButtonConfigLeft *config, bool *out) { return ::hidsysIsDefaultButtonConfigLeft(config, out); } +Result IsDefaultButtonConfigRight(const HidcfgButtonConfigRight *config, bool *out) { return ::hidsysIsDefaultButtonConfigRight(config, out); } +Result IsButtonConfigStorageEmbeddedEmpty(s32 index, bool *out) { return ::hidsysIsButtonConfigStorageEmbeddedEmpty(index, out); } +Result IsButtonConfigStorageFullEmpty(s32 index, bool *out) { return ::hidsysIsButtonConfigStorageFullEmpty(index, out); } +Result IsButtonConfigStorageLeftEmpty(s32 index, bool *out) { return ::hidsysIsButtonConfigStorageLeftEmpty(index, out); } +Result IsButtonConfigStorageRightEmpty(s32 index, bool *out) { return ::hidsysIsButtonConfigStorageRightEmpty(index, out); } +Result GetButtonConfigStorageEmbeddedDeprecated(s32 index, HidcfgButtonConfigEmbedded *config) { return ::hidsysGetButtonConfigStorageEmbeddedDeprecated(index, config); } +Result GetButtonConfigStorageFullDeprecated(s32 index, HidcfgButtonConfigFull *config) { return ::hidsysGetButtonConfigStorageFullDeprecated(index, config); } +Result GetButtonConfigStorageLeftDeprecated(s32 index, HidcfgButtonConfigLeft *config) { return ::hidsysGetButtonConfigStorageLeftDeprecated(index, config); } +Result GetButtonConfigStorageRightDeprecated(s32 index, HidcfgButtonConfigRight *config) { return ::hidsysGetButtonConfigStorageRightDeprecated(index, config); } +Result SetButtonConfigStorageEmbeddedDeprecated(s32 index, const HidcfgButtonConfigEmbedded *config) { return ::hidsysSetButtonConfigStorageEmbeddedDeprecated(index, config); } +Result SetButtonConfigStorageFullDeprecated(s32 index, const HidcfgButtonConfigFull *config) { return ::hidsysSetButtonConfigStorageFullDeprecated(index, config); } +Result SetButtonConfigStorageLeftDeprecated(s32 index, const HidcfgButtonConfigLeft *config) { return ::hidsysSetButtonConfigStorageLeftDeprecated(index, config); } +Result SetButtonConfigStorageRightDeprecated(s32 index, const HidcfgButtonConfigRight *config) { return ::hidsysSetButtonConfigStorageRightDeprecated(index, config); } +Result DeleteButtonConfigStorageEmbedded(s32 index) { return ::hidsysDeleteButtonConfigStorageEmbedded(index); } +Result DeleteButtonConfigStorageFull(s32 index) { return ::hidsysDeleteButtonConfigStorageFull(index); } +Result DeleteButtonConfigStorageLeft(s32 index) { return ::hidsysDeleteButtonConfigStorageLeft(index); } +Result DeleteButtonConfigStorageRight(s32 index) { return ::hidsysDeleteButtonConfigStorageRight(index); } +Result IsUsingCustomButtonConfig(HidsysUniquePadId unique_pad_id, bool *out) { return ::hidsysIsUsingCustomButtonConfig(unique_pad_id, out); } +Result IsAnyCustomButtonConfigEnabled(bool *out) { return ::hidsysIsAnyCustomButtonConfigEnabled(out); } +Result SetAllCustomButtonConfigEnabled(u64 AppletResourceUserId, bool flag) { return ::hidsysSetAllCustomButtonConfigEnabled(AppletResourceUserId, flag); } +Result SetAllDefaultButtonConfig(void) { return ::hidsysSetAllDefaultButtonConfig(); } +Result SetHidButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigEmbedded *config) { return ::hidsysSetHidButtonConfigEmbedded(unique_pad_id, config); } +Result SetHidButtonConfigFull(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigFull *config) { return ::hidsysSetHidButtonConfigFull(unique_pad_id, config); } +Result SetHidButtonConfigLeft(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigLeft *config) { return ::hidsysSetHidButtonConfigLeft(unique_pad_id, config); } +Result SetHidButtonConfigRight(HidsysUniquePadId unique_pad_id, const HidcfgButtonConfigRight *config) { return ::hidsysSetHidButtonConfigRight(unique_pad_id, config); } +Result GetHidButtonConfigEmbedded(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigEmbedded *config) { return ::hidsysGetHidButtonConfigEmbedded(unique_pad_id, config); } +Result GetHidButtonConfigFull(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigFull *config) { return ::hidsysGetHidButtonConfigFull(unique_pad_id, config); } +Result GetHidButtonConfigLeft(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigLeft *config) { return ::hidsysGetHidButtonConfigLeft(unique_pad_id, config); } +Result GetHidButtonConfigRight(HidsysUniquePadId unique_pad_id, HidcfgButtonConfigRight *config) { return ::hidsysGetHidButtonConfigRight(unique_pad_id, config); } +Result GetButtonConfigStorageEmbedded(s32 index, HidcfgButtonConfigEmbedded *config, HidcfgStorageName *name) { return ::hidsysGetButtonConfigStorageEmbedded(index, config, name); } +Result GetButtonConfigStorageFull(s32 index, HidcfgButtonConfigFull *config, HidcfgStorageName *name) { return ::hidsysGetButtonConfigStorageFull(index, config, name); } +Result GetButtonConfigStorageLeft(s32 index, HidcfgButtonConfigLeft *config, HidcfgStorageName *name) { return ::hidsysGetButtonConfigStorageLeft(index, config, name); } +Result GetButtonConfigStorageRight(s32 index, HidcfgButtonConfigRight *config, HidcfgStorageName *name) { return ::hidsysGetButtonConfigStorageRight(index, config, name); } +Result SetButtonConfigStorageEmbedded(s32 index, const HidcfgButtonConfigEmbedded *config, const HidcfgStorageName *name) { return ::hidsysSetButtonConfigStorageEmbedded(index, config, name); } +Result SetButtonConfigStorageFull(s32 index, const HidcfgButtonConfigFull *config, const HidcfgStorageName *name) { return ::hidsysSetButtonConfigStorageFull(index, config, name); } +Result SetButtonConfigStorageLeft(s32 index, const HidcfgButtonConfigLeft *config, const HidcfgStorageName *name) { return ::hidsysSetButtonConfigStorageLeft(index, config, name); } +Result SetButtonConfigStorageRight(s32 index, const HidcfgButtonConfigRight *config, const HidcfgStorageName *name) { return ::hidsysSetButtonConfigStorageRight(index, config, name); } + +} // namespace hidsys + +namespace hipc { + +HipcStaticDescriptor MakeSendStatic(const void* buffer, size_t size, u8 index) { return ::hipcMakeSendStatic(buffer, size, index); } +HipcBufferDescriptor MakeBuffer(const void* buffer, size_t size, HipcBufferMode mode) { return ::hipcMakeBuffer(buffer, size, mode); } +HipcRecvListEntry MakeRecvStatic(void* buffer, size_t size) { return ::hipcMakeRecvStatic(buffer, size); } +void* GetStaticAddress(const HipcStaticDescriptor* desc) { return ::hipcGetStaticAddress(desc); } +size_t GetStaticSize(const HipcStaticDescriptor* desc) { return ::hipcGetStaticSize(desc); } +void* GetBufferAddress(const HipcBufferDescriptor* desc) { return ::hipcGetBufferAddress(desc); } +size_t GetBufferSize(const HipcBufferDescriptor* desc) { return ::hipcGetBufferSize(desc); } +HipcRequest CalcRequestLayout(HipcMetadata meta, void* base) { return ::hipcCalcRequestLayout(meta, base); } +HipcRequest MakeRequest(void* base, HipcMetadata meta) { return ::hipcMakeRequest(base, meta); } +HipcParsedRequest ParseRequest(void* base) { return ::hipcParseRequest(base); } +HipcResponse ParseResponse(void* base) { return ::hipcParseResponse(base); } + +} // namespace hipc + +namespace hmac { + +void Sha256ContextCreate(HmacSha256Context *out, const void *key, size_t key_size) { ::hmacSha256ContextCreate(out, key, key_size); } +void Sha256ContextUpdate(HmacSha256Context *ctx, const void *src, size_t size) { ::hmacSha256ContextUpdate(ctx, src, size); } +void Sha256ContextGetMac(HmacSha256Context *ctx, void *dst) { ::hmacSha256ContextGetMac(ctx, dst); } +void Sha256CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size) { ::hmacSha256CalculateMac(dst, key, key_size, src, size); } +void Sha1ContextCreate(HmacSha1Context *out, const void *key, size_t key_size) { ::hmacSha1ContextCreate(out, key, key_size); } +void Sha1ContextUpdate(HmacSha1Context *ctx, const void *src, size_t size) { ::hmacSha1ContextUpdate(ctx, src, size); } +void Sha1ContextGetMac(HmacSha1Context *ctx, void *dst) { ::hmacSha1ContextGetMac(ctx, dst); } +void Sha1CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size) { ::hmacSha1CalculateMac(dst, key, key_size, src, size); } + +} // namespace hmac + +namespace hosversion { + +u32 Get(void) { return ::hosversionGet(); } +void Set(u32 version) { ::hosversionSet(version); } +bool IsAtmosphere(void) { return ::hosversionIsAtmosphere(); } +bool AtLeast(u8 major, u8 minor, u8 micro) { return ::hosversionAtLeast(major, minor, micro); } +bool Before(u8 major, u8 minor, u8 micro) { return ::hosversionBefore(major, minor, micro); } +bool Between(u8 major1, u8 major2) { return ::hosversionBetween(major1, major2); } + +} // namespace hosversion + +namespace hwopus { + +Result DecoderInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount) { return ::hwopusDecoderInitialize(decoder, SampleRate, ChannelCount); } +void DecoderExit(HwopusDecoder* decoder) { ::hwopusDecoderExit(decoder); } +Result DecoderMultistreamInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount, s32 TotalStreamCount, s32 StereoStreamCount, u8 *channel_mapping) { return ::hwopusDecoderMultistreamInitialize(decoder, SampleRate, ChannelCount, TotalStreamCount, StereoStreamCount, channel_mapping); } +Result DecodeInterleaved(HwopusDecoder* decoder, s32 *DecodedDataSize, s32 *DecodedSampleCount, const void* opusin, size_t opusin_size, s16 *pcmbuf, size_t pcmbuf_size) { return ::hwopusDecodeInterleaved(decoder, DecodedDataSize, DecodedSampleCount, opusin, opusin_size, pcmbuf, pcmbuf_size); } + +} // namespace hwopus + +namespace i2c { + +Result Initialize(void) { return ::i2cInitialize(); } +void Exit(void) { ::i2cExit(); } +Service* GetServiceSession(void) { return ::i2cGetServiceSession(); } +Result OpenSession(I2cSession *out, I2cDevice dev) { return ::i2cOpenSession(out, dev); } + +} // namespace i2c + +namespace i2csession { + +Result SendAuto(I2cSession *s, const void *buf, size_t size, I2cTransactionOption option) { return ::i2csessionSendAuto(s, buf, size, option); } +Result ReceiveAuto(I2cSession *s, void *buf, size_t size, I2cTransactionOption option) { return ::i2csessionReceiveAuto(s, buf, size, option); } +Result ExecuteCommandList(I2cSession *s, void *dst, size_t dst_size, const void *cmd_list, size_t cmd_list_size) { return ::i2csessionExecuteCommandList(s, dst, dst_size, cmd_list, cmd_list_size); } +void Close(I2cSession *s) { ::i2csessionClose(s); } + +} // namespace i2csession + +namespace idlesys { + +Result Initialize(void) { return ::idlesysInitialize(); } +void Exit(void) { ::idlesysExit(); } +Service* GetServiceSession(void) { return ::idlesysGetServiceSession(); } +Result ReportUserIsActive(void) { return ::idlesysReportUserIsActive(); } + +} // namespace idlesys + +namespace insr { + +Result Initialize(void) { return ::insrInitialize(); } +void Exit(void) { ::insrExit(); } +Service* GetServiceSession(void) { return ::insrGetServiceSession(); } +Result GetLastTick(u32 id, u64 *tick) { return ::insrGetLastTick(id, tick); } +Result GetReadableEvent(u32 id, Event *out) { return ::insrGetReadableEvent(id, out); } + +} // namespace insr + +namespace inss { + +Result Initialize(void) { return ::inssInitialize(); } +void Exit(void) { ::inssExit(); } +Service* GetServiceSession(void) { return ::inssGetServiceSession(); } +Result GetWritableEvent(u32 id, Event *out) { return ::inssGetWritableEvent(id, out); } + +} // namespace inss + +namespace irs { + +Result Initialize(void) { return ::irsInitialize(); } +void Exit(void) { ::irsExit(); } +Service* GetServiceSession(void) { return ::irsGetServiceSession(); } +void* GetSharedmemAddr(void) { return ::irsGetSharedmemAddr(); } +Result GetIrCameraHandle(IrsIrCameraHandle *handle, HidNpadIdType id) { return ::irsGetIrCameraHandle(handle, id); } +Result GetIrCameraStatus(IrsIrCameraHandle handle, IrsIrCameraStatus *out) { return ::irsGetIrCameraStatus(handle, out); } +Result CheckFirmwareUpdateNecessity(IrsIrCameraHandle handle, bool *out) { return ::irsCheckFirmwareUpdateNecessity(handle, out); } +Result GetImageProcessorStatus(IrsIrCameraHandle handle, IrsImageProcessorStatus *out) { return ::irsGetImageProcessorStatus(handle, out); } +Result StopImageProcessor(IrsIrCameraHandle handle) { return ::irsStopImageProcessor(handle); } +Result StopImageProcessorAsync(IrsIrCameraHandle handle) { return ::irsStopImageProcessorAsync(handle); } +Result RunMomentProcessor(IrsIrCameraHandle handle, const IrsMomentProcessorConfig *config) { return ::irsRunMomentProcessor(handle, config); } +Result GetMomentProcessorStates(IrsIrCameraHandle handle, IrsMomentProcessorState *states, s32 count, s32 *total_out) { return ::irsGetMomentProcessorStates(handle, states, count, total_out); } +IrsMomentStatistic CalculateMomentRegionStatistic(const IrsMomentProcessorState *state, IrsRect rect, s32 region_x, s32 region_y, s32 region_width, s32 region_height) { return ::irsCalculateMomentRegionStatistic(state, rect, region_x, region_y, region_width, region_height); } +Result RunClusteringProcessor(IrsIrCameraHandle handle, const IrsClusteringProcessorConfig *config) { return ::irsRunClusteringProcessor(handle, config); } +Result GetClusteringProcessorStates(IrsIrCameraHandle handle, IrsClusteringProcessorState *states, s32 count, s32 *total_out) { return ::irsGetClusteringProcessorStates(handle, states, count, total_out); } +Result RunImageTransferProcessor(IrsIrCameraHandle handle, const IrsImageTransferProcessorConfig *config, size_t size) { return ::irsRunImageTransferProcessor(handle, config, size); } +Result RunImageTransferExProcessor(IrsIrCameraHandle handle, const IrsImageTransferProcessorExConfig *config, size_t size) { return ::irsRunImageTransferExProcessor(handle, config, size); } +Result GetImageTransferProcessorState(IrsIrCameraHandle handle, void* buffer, size_t size, IrsImageTransferProcessorState *state) { return ::irsGetImageTransferProcessorState(handle, buffer, size, state); } +Result RunPointingProcessor(IrsIrCameraHandle handle) { return ::irsRunPointingProcessor(handle); } +Result GetPointingProcessorMarkerStates(IrsIrCameraHandle handle, IrsPointingProcessorMarkerState *states, s32 count, s32 *total_out) { return ::irsGetPointingProcessorMarkerStates(handle, states, count, total_out); } +Result GetPointingProcessorStates(IrsIrCameraHandle handle, IrsPointingProcessorState *states, s32 count, s32 *total_out) { return ::irsGetPointingProcessorStates(handle, states, count, total_out); } +Result RunTeraPluginProcessor(IrsIrCameraHandle handle, const IrsTeraPluginProcessorConfig *config) { return ::irsRunTeraPluginProcessor(handle, config); } +Result GetTeraPluginProcessorStates(IrsIrCameraHandle handle, IrsTeraPluginProcessorState *states, s32 count, s64 sampling_number, u32 prefix_data, u32 prefix_bitcount, s32 *total_out) { return ::irsGetTeraPluginProcessorStates(handle, states, count, sampling_number, prefix_data, prefix_bitcount, total_out); } +Result RunIrLedProcessor(IrsIrCameraHandle handle, const IrsIrLedProcessorConfig *config) { return ::irsRunIrLedProcessor(handle, config); } +Result RunAdaptiveClusteringProcessor(IrsIrCameraHandle handle, const IrsAdaptiveClusteringProcessorConfig *config) { return ::irsRunAdaptiveClusteringProcessor(handle, config); } +Result RunHandAnalysis(IrsIrCameraHandle handle, const IrsHandAnalysisConfig *config) { return ::irsRunHandAnalysis(handle, config); } +void GetMomentProcessorDefaultConfig(IrsMomentProcessorConfig *config) { ::irsGetMomentProcessorDefaultConfig(config); } +void GetClusteringProcessorDefaultConfig(IrsClusteringProcessorConfig *config) { ::irsGetClusteringProcessorDefaultConfig(config); } +void GetDefaultImageTransferProcessorConfig(IrsImageTransferProcessorConfig *config) { ::irsGetDefaultImageTransferProcessorConfig(config); } +void GetDefaultImageTransferProcessorExConfig(IrsImageTransferProcessorExConfig *config) { ::irsGetDefaultImageTransferProcessorExConfig(config); } +void GetIrLedProcessorDefaultConfig(IrsIrLedProcessorConfig *config) { ::irsGetIrLedProcessorDefaultConfig(config); } + +} // namespace irs + +namespace jit { + +Result Create(Jit* j, size_t size) { return ::jitCreate(j, size); } +Result TransitionToWritable(Jit* j) { return ::jitTransitionToWritable(j); } +Result TransitionToExecutable(Jit* j) { return ::jitTransitionToExecutable(j); } +Result Close(Jit* j) { return ::jitClose(j); } +void* GetRwAddr(Jit* j) { return ::jitGetRwAddr(j); } +void* GetRxAddr(Jit* j) { return ::jitGetRxAddr(j); } + +} // namespace jit + +namespace lbl { + +Result Initialize(void) { return ::lblInitialize(); } +void Exit(void) { ::lblExit(); } +Service* GetServiceSession(void) { return ::lblGetServiceSession(); } +Result SaveCurrentSetting(void) { return ::lblSaveCurrentSetting(); } +Result LoadCurrentSetting(void) { return ::lblLoadCurrentSetting(); } +Result SetCurrentBrightnessSetting(float brightness) { return ::lblSetCurrentBrightnessSetting(brightness); } +Result GetCurrentBrightnessSetting(float *out_value) { return ::lblGetCurrentBrightnessSetting(out_value); } +Result ApplyCurrentBrightnessSettingToBacklight(void) { return ::lblApplyCurrentBrightnessSettingToBacklight(); } +Result GetBrightnessSettingAppliedToBacklight(float *out_value) { return ::lblGetBrightnessSettingAppliedToBacklight(out_value); } +Result SwitchBacklightOn(u64 fade_time) { return ::lblSwitchBacklightOn(fade_time); } +Result SwitchBacklightOff(u64 fade_time) { return ::lblSwitchBacklightOff(fade_time); } +Result GetBacklightSwitchStatus(LblBacklightSwitchStatus *out_value) { return ::lblGetBacklightSwitchStatus(out_value); } +Result EnableDimming(void) { return ::lblEnableDimming(); } +Result DisableDimming(void) { return ::lblDisableDimming(); } +Result IsDimmingEnabled(bool *out_value) { return ::lblIsDimmingEnabled(out_value); } +Result EnableAutoBrightnessControl(void) { return ::lblEnableAutoBrightnessControl(); } +Result DisableAutoBrightnessControl(void) { return ::lblDisableAutoBrightnessControl(); } +Result IsAutoBrightnessControlEnabled(bool *out_value) { return ::lblIsAutoBrightnessControlEnabled(out_value); } +Result SetAmbientLightSensorValue(float value) { return ::lblSetAmbientLightSensorValue(value); } +Result GetAmbientLightSensorValue(bool *over_limit, float *lux) { return ::lblGetAmbientLightSensorValue(over_limit, lux); } +Result IsAmbientLightSensorAvailable(bool *out_value) { return ::lblIsAmbientLightSensorAvailable(out_value); } +Result SetCurrentBrightnessSettingForVrMode(float brightness) { return ::lblSetCurrentBrightnessSettingForVrMode(brightness); } +Result GetCurrentBrightnessSettingForVrMode(float *out_value) { return ::lblGetCurrentBrightnessSettingForVrMode(out_value); } +Result EnableVrMode(void) { return ::lblEnableVrMode(); } +Result DisableVrMode(void) { return ::lblDisableVrMode(); } +Result IsVrModeEnabled(bool *out_value) { return ::lblIsVrModeEnabled(out_value); } + +} // namespace lbl + +namespace ldn { + +Result Initialize(LdnServiceType service_type) { return ::ldnInitialize(service_type); } +void Exit(void) { ::ldnExit(); } +Service* GetServiceSession_LocalCommunicationService(void) { return ::ldnGetServiceSession_LocalCommunicationService(); } +Service* GetServiceSession_IClientProcessMonitor(void) { return ::ldnGetServiceSession_IClientProcessMonitor(); } +Result GetState(LdnState *out) { return ::ldnGetState(out); } +Result GetNetworkInfo(LdnNetworkInfo *out) { return ::ldnGetNetworkInfo(out); } +Result GetIpv4Address(LdnIpv4Address *addr, LdnSubnetMask *mask) { return ::ldnGetIpv4Address(addr, mask); } +Result GetDisconnectReason(LdnDisconnectReason *out) { return ::ldnGetDisconnectReason(out); } +Result GetSecurityParameter(LdnSecurityParameter *out) { return ::ldnGetSecurityParameter(out); } +Result GetNetworkConfig(LdnNetworkConfig *out) { return ::ldnGetNetworkConfig(out); } +Result GetStateChangeEvent(Event* out_event) { return ::ldnGetStateChangeEvent(out_event); } +Result GetNetworkInfoAndHistory(LdnNetworkInfo *network_info, LdnNodeLatestUpdate *nodes, s32 count) { return ::ldnGetNetworkInfoAndHistory(network_info, nodes, count); } +Result Scan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out) { return ::ldnScan(channel, filter, network_info, count, total_out); } +Result ScanPrivate(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out) { return ::ldnScanPrivate(channel, filter, network_info, count, total_out); } +Result SetWirelessControllerRestriction(LdnWirelessControllerRestriction restriction) { return ::ldnSetWirelessControllerRestriction(restriction); } +Result SetProtocol(LdnProtocol protocol) { return ::ldnSetProtocol(protocol); } +Result OpenAccessPoint(void) { return ::ldnOpenAccessPoint(); } +Result CloseAccessPoint(void) { return ::ldnCloseAccessPoint(); } +Result CreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config) { return ::ldnCreateNetwork(sec_config, user_config, network_config); } +Result CreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count) { return ::ldnCreateNetworkPrivate(sec_config, sec_param, user_config, network_config, addrs, count); } +Result DestroyNetwork(void) { return ::ldnDestroyNetwork(); } +Result Reject(LdnIpv4Address addr) { return ::ldnReject(addr); } +Result SetAdvertiseData(const void* buffer, size_t size) { return ::ldnSetAdvertiseData(buffer, size); } +Result SetStationAcceptPolicy(LdnAcceptPolicy policy) { return ::ldnSetStationAcceptPolicy(policy); } +Result AddAcceptFilterEntry(LdnMacAddress addr) { return ::ldnAddAcceptFilterEntry(addr); } +Result ClearAcceptFilter(void) { return ::ldnClearAcceptFilter(); } +Result OpenStation(void) { return ::ldnOpenStation(); } +Result CloseStation(void) { return ::ldnCloseStation(); } +Result Connect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info) { return ::ldnConnect(sec_config, user_config, version, option, network_info); } +Result ConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config) { return ::ldnConnectPrivate(sec_config, sec_param, user_config, version, option, network_config); } +Result Disconnect(void) { return ::ldnDisconnect(); } +Result SetOperationMode(LdnOperationMode mode) { return ::ldnSetOperationMode(mode); } +Result EnableActionFrame(const LdnActionFrameSettings *settings) { return ::ldnEnableActionFrame(settings); } +Result DisableActionFrame(void) { return ::ldnDisableActionFrame(); } +Result SendActionFrame(const void* data, size_t size, LdnMacAddress destination, LdnMacAddress bssid, s16 channel, u32 flags) { return ::ldnSendActionFrame(data, size, destination, bssid, channel, flags); } +Result RecvActionFrame(void* data, size_t size, LdnMacAddress *addr0, LdnMacAddress *addr1, s16 *channel, u32 *out_size, s32 *link_level, u32 flags) { return ::ldnRecvActionFrame(data, size, addr0, addr1, channel, out_size, link_level, flags); } +Result SetHomeChannel(s16 channel) { return ::ldnSetHomeChannel(channel); } +Result SetTxPower(s16 power) { return ::ldnSetTxPower(power); } +Result ResetTxPower(void) { return ::ldnResetTxPower(); } + +} // namespace ldn + +namespace ldnm { + +Result Initialize(void) { return ::ldnmInitialize(); } +void Exit(void) { ::ldnmExit(); } +Service* GetServiceSession_MonitorService(void) { return ::ldnmGetServiceSession_MonitorService(); } +Result GetState(LdnState *out) { return ::ldnmGetState(out); } +Result GetNetworkInfo(LdnNetworkInfo *out) { return ::ldnmGetNetworkInfo(out); } +Result GetIpv4Address(LdnIpv4Address *addr, LdnSubnetMask *mask) { return ::ldnmGetIpv4Address(addr, mask); } +Result GetSecurityParameter(LdnSecurityParameter *out) { return ::ldnmGetSecurityParameter(out); } +Result GetNetworkConfig(LdnNetworkConfig *out) { return ::ldnmGetNetworkConfig(out); } + +} // namespace ldnm + +namespace ldr { + +Result ShellInitialize(void) { return ::ldrShellInitialize(); } +void ShellExit(void) { ::ldrShellExit(); } +Service* ShellGetServiceSession(void) { return ::ldrShellGetServiceSession(); } +Result DmntInitialize(void) { return ::ldrDmntInitialize(); } +void DmntExit(void) { ::ldrDmntExit(); } +Service* DmntGetServiceSession(void) { return ::ldrDmntGetServiceSession(); } +Result PmInitialize(void) { return ::ldrPmInitialize(); } +void PmExit(void) { ::ldrPmExit(); } +Service* PmGetServiceSession(void) { return ::ldrPmGetServiceSession(); } +Result ShellSetProgramArguments(u64 program_id, const void *args, size_t args_size) { return ::ldrShellSetProgramArguments(program_id, args, args_size); } +Result ShellFlushArguments(void) { return ::ldrShellFlushArguments(); } +Result DmntSetProgramArguments(u64 program_id, const void *args, size_t args_size) { return ::ldrDmntSetProgramArguments(program_id, args, args_size); } +Result DmntFlushArguments(void) { return ::ldrDmntFlushArguments(); } +Result DmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, s32 *num_out) { return ::ldrDmntGetProcessModuleInfo(pid, out_module_infos, max_out_modules, num_out); } +Result PmCreateProcess(u64 pin_id, u32 flags, Handle reslimit_h, const LoaderProgramAttributes *attrs, Handle *out_process_h) { return ::ldrPmCreateProcess(pin_id, flags, reslimit_h, attrs, out_process_h); } +Result PmGetProgramInfo(const NcmProgramLocation *loc, const LoaderProgramAttributes *attrs, LoaderProgramInfo *out_program_info) { return ::ldrPmGetProgramInfo(loc, attrs, out_program_info); } +Result PmGetProgramInfoV1(const NcmProgramLocation *loc, LoaderProgramInfoV1 *out_program_info) { return ::ldrPmGetProgramInfoV1(loc, out_program_info); } +Result PmPinProgram(const NcmProgramLocation *loc, u64 *out_pin_id) { return ::ldrPmPinProgram(loc, out_pin_id); } +Result PmUnpinProgram(u64 pin_id) { return ::ldrPmUnpinProgram(pin_id); } +Result PmSetEnabledProgramVerification(bool enabled) { return ::ldrPmSetEnabledProgramVerification(enabled); } +Result RoInitialize(void) { return ::ldrRoInitialize(); } +void RoExit(void) { ::ldrRoExit(); } +Service* RoGetServiceSession(void) { return ::ldrRoGetServiceSession(); } +Result RoLoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { return ::ldrRoLoadNro(out_address, nro_address, nro_size, bss_address, bss_size); } +Result RoUnloadNro(u64 nro_address) { return ::ldrRoUnloadNro(nro_address); } +Result RoLoadNrr(u64 nrr_address, u64 nrr_size) { return ::ldrRoLoadNrr(nrr_address, nrr_size); } +Result RoUnloadNrr(u64 nrr_address) { return ::ldrRoUnloadNrr(nrr_address); } +Result RoLoadNrrEx(u64 nrr_address, u64 nrr_size) { return ::ldrRoLoadNrrEx(nrr_address, nrr_size); } + +} // namespace ldr + +namespace levent { + +void Init(LEvent* le, bool signaled, bool autoclear) { ::leventInit(le, signaled, autoclear); } +bool Wait(LEvent* le, u64 timeout_ns) { return ::leventWait(le, timeout_ns); } +bool TryWait(LEvent* le) { return ::leventTryWait(le); } +void Signal(LEvent* le) { ::leventSignal(le); } +void Clear(LEvent* le) { ::leventClear(le); } + +} // namespace levent + +namespace libapplet { + +void ArgsCreate(LibAppletArgs* a, u32 version) { ::libappletArgsCreate(a, version); } +void ArgsSetPlayStartupSound(LibAppletArgs* a, bool flag) { ::libappletArgsSetPlayStartupSound(a, flag); } +Result CreateWriteStorage(AppletStorage* s, const void* buffer, size_t size) { return ::libappletCreateWriteStorage(s, buffer, size); } +Result ReadStorage(AppletStorage* s, void* buffer, size_t size, size_t *transfer_size) { return ::libappletReadStorage(s, buffer, size, transfer_size); } +Result ArgsPush(LibAppletArgs* a, AppletHolder *h) { return ::libappletArgsPush(a, h); } +Result ArgsPop(LibAppletArgs* a) { return ::libappletArgsPop(a); } +Result PushInData(AppletHolder *h, const void* buffer, size_t size) { return ::libappletPushInData(h, buffer, size); } +Result PopOutData(AppletHolder *h, void* buffer, size_t size, size_t *transfer_size) { return ::libappletPopOutData(h, buffer, size, transfer_size); } +void SetJumpFlag(bool flag) { ::libappletSetJumpFlag(flag); } +Result Start(AppletHolder *h) { return ::libappletStart(h); } +Result Launch(AppletId id, LibAppletArgs *commonargs, const void* arg, size_t arg_size, void* reply, size_t reply_size, size_t *out_reply_size) { return ::libappletLaunch(id, commonargs, arg, arg_size, reply, reply_size, out_reply_size); } +Result RequestHomeMenu(void) { return ::libappletRequestHomeMenu(); } +Result RequestJumpToSystemUpdate(void) { return ::libappletRequestJumpToSystemUpdate(); } +Result RequestToLaunchApplication(u64 application_id, AccountUid uid, const void* buffer, size_t size, u32 sender) { return ::libappletRequestToLaunchApplication(application_id, uid, buffer, size, sender); } +Result RequestJumpToStory(AccountUid uid, u64 application_id) { return ::libappletRequestJumpToStory(uid, application_id); } + +} // namespace libapplet + +namespace lp2p { + +Result Initialize(Lp2pServiceType service_type) { return ::lp2pInitialize(service_type); } +void Exit(void) { ::lp2pExit(); } +Service* GetServiceSession_INetworkService(void) { return ::lp2pGetServiceSession_INetworkService(); } +Service* GetServiceSession_INetworkServiceMonitor(void) { return ::lp2pGetServiceSession_INetworkServiceMonitor(); } +void CreateGroupInfo(Lp2pGroupInfo *info) { ::lp2pCreateGroupInfo(info); } +void CreateGroupInfoScan(Lp2pGroupInfo *info) { ::lp2pCreateGroupInfoScan(info); } +void GroupInfoSetServiceName(Lp2pGroupInfo *info, const char *name) { ::lp2pGroupInfoSetServiceName(info, name); } +void GroupInfoSetFlags(Lp2pGroupInfo *info, s8 *flags, size_t count) { ::lp2pGroupInfoSetFlags(info, flags, count); } +void GroupInfoSetMemberCountMax(Lp2pGroupInfo *info, size_t count) { ::lp2pGroupInfoSetMemberCountMax(info, count); } +void GroupInfoSetFrequencyChannel(Lp2pGroupInfo *info, u16 frequency, s16 channel) { ::lp2pGroupInfoSetFrequencyChannel(info, frequency, channel); } +void GroupInfoSetStealthEnabled(Lp2pGroupInfo *info, bool flag) { ::lp2pGroupInfoSetStealthEnabled(info, flag); } +void GroupInfoSetPresharedKey(Lp2pGroupInfo *info, const void* key, size_t size) { ::lp2pGroupInfoSetPresharedKey(info, key, size); } +Result GroupInfoSetPassphrase(Lp2pGroupInfo *info, const char *passphrase) { return ::lp2pGroupInfoSetPassphrase(info, passphrase); } +Result Scan(const Lp2pGroupInfo *info, Lp2pScanResult *results, s32 count, s32 *total_out) { return ::lp2pScan(info, results, count, total_out); } +Result CreateGroup(const Lp2pGroupInfo *info) { return ::lp2pCreateGroup(info); } +Result DestroyGroup(void) { return ::lp2pDestroyGroup(); } +Result SetAdvertiseData(const void* buffer, size_t size) { return ::lp2pSetAdvertiseData(buffer, size); } +Result SendToOtherGroup(const void* buffer, size_t size, Lp2pMacAddress addr, Lp2pGroupId group_id, s16 frequency, s16 channel, u32 flags) { return ::lp2pSendToOtherGroup(buffer, size, addr, group_id, frequency, channel, flags); } +Result RecvFromOtherGroup(void* buffer, size_t size, u32 flags, Lp2pMacAddress *addr, u16 *unk0, s32 *unk1, u64 *out_size, s32 *unk2) { return ::lp2pRecvFromOtherGroup(buffer, size, flags, addr, unk0, unk1, out_size, unk2); } +Result AddAcceptableGroupId(Lp2pGroupId group_id) { return ::lp2pAddAcceptableGroupId(group_id); } +Result RemoveAcceptableGroupId(void) { return ::lp2pRemoveAcceptableGroupId(); } +Result AttachNetworkInterfaceStateChangeEvent(Event* out_event) { return ::lp2pAttachNetworkInterfaceStateChangeEvent(out_event); } +Result GetNetworkInterfaceLastError(void) { return ::lp2pGetNetworkInterfaceLastError(); } +Result GetRole(u8 *out) { return ::lp2pGetRole(out); } +Result GetAdvertiseData(void* buffer, size_t size, u16 *transfer_size, u16 *original_size) { return ::lp2pGetAdvertiseData(buffer, size, transfer_size, original_size); } +Result GetAdvertiseData2(void* buffer, size_t size, u16 *transfer_size, u16 *original_size) { return ::lp2pGetAdvertiseData2(buffer, size, transfer_size, original_size); } +Result GetGroupInfo(Lp2pGroupInfo *out) { return ::lp2pGetGroupInfo(out); } +Result Join(Lp2pGroupInfo *out, const Lp2pGroupInfo *info) { return ::lp2pJoin(out, info); } +Result GetGroupOwner(Lp2pNodeInfo *out) { return ::lp2pGetGroupOwner(out); } +Result GetIpConfig(Lp2pIpConfig *out) { return ::lp2pGetIpConfig(out); } +Result Leave(u32 *out) { return ::lp2pLeave(out); } +Result AttachJoinEvent(Event* out_event) { return ::lp2pAttachJoinEvent(out_event); } +Result GetMembers(Lp2pNodeInfo *members, s32 count, s32 *total_out) { return ::lp2pGetMembers(members, count, total_out); } + +} // namespace lp2p + +namespace lr { + +Result Initialize(void) { return ::lrInitialize(); } +void Exit(void) { ::lrExit(); } +Service* GetServiceSession(void) { return ::lrGetServiceSession(); } +Result OpenLocationResolver(NcmStorageId storage, LrLocationResolver* out) { return ::lrOpenLocationResolver(storage, out); } +Result OpenRegisteredLocationResolver(LrRegisteredLocationResolver* out) { return ::lrOpenRegisteredLocationResolver(out); } +Result LrResolveProgramPath(LrLocationResolver* lr, u64 tid, char *out) { return ::lrLrResolveProgramPath(lr, tid, out); } +Result LrRedirectProgramPath(LrLocationResolver* lr, u64 tid, const char *path) { return ::lrLrRedirectProgramPath(lr, tid, path); } +Result LrResolveApplicationControlPath(LrLocationResolver* lr, u64 tid, char *out) { return ::lrLrResolveApplicationControlPath(lr, tid, out); } +Result LrResolveApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, char *out) { return ::lrLrResolveApplicationHtmlDocumentPath(lr, tid, out); } +Result LrResolveDataPath(LrLocationResolver* lr, u64 tid, char *out) { return ::lrLrResolveDataPath(lr, tid, out); } +Result LrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path) { return ::lrLrRedirectApplicationControlPath(lr, tid, tid2, path); } +Result LrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path) { return ::lrLrRedirectApplicationHtmlDocumentPath(lr, tid, tid2, path); } +Result LrResolveApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out) { return ::lrLrResolveApplicationLegalInformationPath(lr, tid, out); } +Result LrRedirectApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path) { return ::lrLrRedirectApplicationLegalInformationPath(lr, tid, tid2, path); } +Result LrRefresh(LrLocationResolver* lr) { return ::lrLrRefresh(lr); } +Result LrEraseProgramRedirection(LrLocationResolver* lr, u64 tid) { return ::lrLrEraseProgramRedirection(lr, tid); } +Result RegLrResolveProgramPath(LrRegisteredLocationResolver* reg, u64 tid, char *out) { return ::lrRegLrResolveProgramPath(reg, tid, out); } + +} // namespace lr + +namespace mii { + +Result LaShowMiiEdit(MiiSpecialKeyCode special_key_code) { return ::miiLaShowMiiEdit(special_key_code); } +Result LaAppendMii(MiiSpecialKeyCode special_key_code, s32 *index) { return ::miiLaAppendMii(special_key_code, index); } +Result LaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index) { return ::miiLaAppendMiiImage(special_key_code, valid_uuid_array, count, index); } +Result LaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index) { return ::miiLaUpdateMiiImage(special_key_code, valid_uuid_array, count, used_uuid, index); } +Result LaCreateMii(MiiSpecialKeyCode special_key_code, MiiCharInfo *out_char) { return ::miiLaCreateMii(special_key_code, out_char); } +Result LaEditMii(MiiSpecialKeyCode special_key_code, const MiiCharInfo *in_char, MiiCharInfo *out_char) { return ::miiLaEditMii(special_key_code, in_char, out_char); } +Result Initialize(MiiServiceType service_type) { return ::miiInitialize(service_type); } +void Exit(void) { ::miiExit(); } +Service* GetServiceSession(void) { return ::miiGetServiceSession(); } +Result OpenDatabase(MiiDatabase *out, MiiSpecialKeyCode key_code) { return ::miiOpenDatabase(out, key_code); } +Result DatabaseIsUpdated(MiiDatabase *db, bool *out_updated, MiiSourceFlag flag) { return ::miiDatabaseIsUpdated(db, out_updated, flag); } +Result DatabaseIsFull(MiiDatabase *db, bool *out_full) { return ::miiDatabaseIsFull(db, out_full); } +Result DatabaseGetCount(MiiDatabase *db, s32 *out_count, MiiSourceFlag flag) { return ::miiDatabaseGetCount(db, out_count, flag); } +Result DatabaseGet1(MiiDatabase *db, MiiSourceFlag flag, MiiCharInfo *out_infos, s32 count, s32 *total_out) { return ::miiDatabaseGet1(db, flag, out_infos, count, total_out); } +Result DatabaseBuildRandom(MiiDatabase *db, MiiAge age, MiiGender gender, MiiFaceColor face_color, MiiCharInfo *out_info) { return ::miiDatabaseBuildRandom(db, age, gender, face_color, out_info); } +void DatabaseClose(MiiDatabase *db) { ::miiDatabaseClose(db); } + +} // namespace mii + +namespace miiimg { + +Result Initialize(void) { return ::miiimgInitialize(); } +void Exit(void) { ::miiimgExit(); } +Service* GetServiceSession(void) { return ::miiimgGetServiceSession(); } +Result Reload(void) { return ::miiimgReload(); } +Result GetCount(s32 *out_count) { return ::miiimgGetCount(out_count); } +Result IsEmpty(bool *out_empty) { return ::miiimgIsEmpty(out_empty); } +Result IsFull(bool *out_full) { return ::miiimgIsFull(out_full); } +Result GetAttribute(s32 index, MiiimgImageAttribute *out_attr) { return ::miiimgGetAttribute(index, out_attr); } +Result LoadImage(MiiimgImageId id, void* out_image, size_t out_image_size) { return ::miiimgLoadImage(id, out_image, out_image_size); } + +} // namespace miiimg + +namespace mmu { + +Result Initialize(void) { return ::mmuInitialize(); } +void Exit(void) { ::mmuExit(); } +Service* GetServiceSession(void) { return ::mmuGetServiceSession(); } +Result RequestInitialize(MmuRequest *request, MmuModuleId module, u32 unk, bool autoclear) { return ::mmuRequestInitialize(request, module, unk, autoclear); } +Result RequestFinalize(const MmuRequest *request) { return ::mmuRequestFinalize(request); } +Result RequestGet(const MmuRequest *request, u32 *out_freq_hz) { return ::mmuRequestGet(request, out_freq_hz); } +Result RequestSetAndWait(const MmuRequest *request, u32 freq_hz, s32 timeout) { return ::mmuRequestSetAndWait(request, freq_hz, timeout); } + +} // namespace mmu + +namespace mutex { + +void Init(Mutex* m) { ::mutexInit(m); } +void Lock(Mutex* m) { ::mutexLock(m); } +bool TryLock(Mutex* m) { return ::mutexTryLock(m); } +void Unlock(Mutex* m) { ::mutexUnlock(m); } +bool IsLockedByCurrentThread(const Mutex* m) { return ::mutexIsLockedByCurrentThread(m); } + +} // namespace mutex + +namespace nacp { + +Result GetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry) { return ::nacpGetLanguageEntry(nacp, langentry); } + +} // namespace nacp + +namespace ncm { + +Result Initialize(void) { return ::ncmInitialize(); } +void Exit(void) { ::ncmExit(); } +Service* GetServiceSession(void) { return ::ncmGetServiceSession(); } +Result CreateContentStorage(NcmStorageId storage_id) { return ::ncmCreateContentStorage(storage_id); } +Result CreateContentMetaDatabase(NcmStorageId storage_id) { return ::ncmCreateContentMetaDatabase(storage_id); } +Result VerifyContentStorage(NcmStorageId storage_id) { return ::ncmVerifyContentStorage(storage_id); } +Result VerifyContentMetaDatabase(NcmStorageId storage_id) { return ::ncmVerifyContentMetaDatabase(storage_id); } +Result OpenContentStorage(NcmContentStorage* out_content_storage, NcmStorageId storage_id) { return ::ncmOpenContentStorage(out_content_storage, storage_id); } +Result OpenContentMetaDatabase(NcmContentMetaDatabase* out_content_meta_database, NcmStorageId storage_id) { return ::ncmOpenContentMetaDatabase(out_content_meta_database, storage_id); } +Result CloseContentStorageForcibly(NcmStorageId storage_id) { return ::ncmCloseContentStorageForcibly(storage_id); } +Result CloseContentMetaDatabaseForcibly(NcmStorageId storage_id) { return ::ncmCloseContentMetaDatabaseForcibly(storage_id); } +Result CleanupContentMetaDatabase(NcmStorageId storage_id) { return ::ncmCleanupContentMetaDatabase(storage_id); } +Result ActivateContentStorage(NcmStorageId storage_id) { return ::ncmActivateContentStorage(storage_id); } +Result InactivateContentStorage(NcmStorageId storage_id) { return ::ncmInactivateContentStorage(storage_id); } +Result ActivateContentMetaDatabase(NcmStorageId storage_id) { return ::ncmActivateContentMetaDatabase(storage_id); } +Result InactivateContentMetaDatabase(NcmStorageId storage_id) { return ::ncmInactivateContentMetaDatabase(storage_id); } +Result InvalidateRightsIdCache(void) { return ::ncmInvalidateRightsIdCache(); } +Result ActivateFsContentStorage(FsContentStorageId fs_storage_id) { return ::ncmActivateFsContentStorage(fs_storage_id); } +void ContentStorageClose(NcmContentStorage* cs) { ::ncmContentStorageClose(cs); } +Result ContentStorageGeneratePlaceHolderId(NcmContentStorage* cs, NcmPlaceHolderId* out_id) { return ::ncmContentStorageGeneratePlaceHolderId(cs, out_id); } +Result ContentStorageCreatePlaceHolder(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id, s64 size) { return ::ncmContentStorageCreatePlaceHolder(cs, content_id, placeholder_id, size); } +Result ContentStorageDeletePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id) { return ::ncmContentStorageDeletePlaceHolder(cs, placeholder_id); } +Result ContentStorageHasPlaceHolder(NcmContentStorage* cs, bool* out, const NcmPlaceHolderId* placeholder_id) { return ::ncmContentStorageHasPlaceHolder(cs, out, placeholder_id); } +Result ContentStorageWritePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, u64 offset, const void* data, size_t data_size) { return ::ncmContentStorageWritePlaceHolder(cs, placeholder_id, offset, data, data_size); } +Result ContentStorageRegister(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id) { return ::ncmContentStorageRegister(cs, content_id, placeholder_id); } +Result ContentStorageDelete(NcmContentStorage* cs, const NcmContentId* content_id) { return ::ncmContentStorageDelete(cs, content_id); } +Result ContentStorageHas(NcmContentStorage* cs, bool* out, const NcmContentId* content_id) { return ::ncmContentStorageHas(cs, out, content_id); } +Result ContentStorageGetPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmContentId* content_id) { return ::ncmContentStorageGetPath(cs, out_path, out_size, content_id); } +Result ContentStorageGetPlaceHolderPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmPlaceHolderId* placeholder_id) { return ::ncmContentStorageGetPlaceHolderPath(cs, out_path, out_size, placeholder_id); } +Result ContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs) { return ::ncmContentStorageCleanupAllPlaceHolder(cs); } +Result ContentStorageListPlaceHolder(NcmContentStorage* cs, NcmPlaceHolderId* out_ids, s32 count, s32* out_count) { return ::ncmContentStorageListPlaceHolder(cs, out_ids, count, out_count); } +Result ContentStorageGetContentCount(NcmContentStorage* cs, s32* out_count) { return ::ncmContentStorageGetContentCount(cs, out_count); } +Result ContentStorageListContentId(NcmContentStorage* cs, NcmContentId* out_ids, s32 count, s32* out_count, s32 start_offset) { return ::ncmContentStorageListContentId(cs, out_ids, count, out_count, start_offset); } +Result ContentStorageGetSizeFromContentId(NcmContentStorage* cs, s64* out_size, const NcmContentId* content_id) { return ::ncmContentStorageGetSizeFromContentId(cs, out_size, content_id); } +Result ContentStorageDisableForcibly(NcmContentStorage* cs) { return ::ncmContentStorageDisableForcibly(cs); } +Result ContentStorageRevertToPlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, const NcmContentId* old_content_id, const NcmContentId* new_content_id) { return ::ncmContentStorageRevertToPlaceHolder(cs, placeholder_id, old_content_id, new_content_id); } +Result ContentStorageSetPlaceHolderSize(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, s64 size) { return ::ncmContentStorageSetPlaceHolderSize(cs, placeholder_id, size); } +Result ContentStorageReadContentIdFile(NcmContentStorage* cs, void* out_data, size_t out_data_size, const NcmContentId* content_id, s64 offset) { return ::ncmContentStorageReadContentIdFile(cs, out_data, out_data_size, content_id, offset); } +Result ContentStorageGetRightsIdFromPlaceHolderId(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id, FsContentAttributes attr) { return ::ncmContentStorageGetRightsIdFromPlaceHolderId(cs, out_rights_id, placeholder_id, attr); } +Result ContentStorageGetRightsIdFromContentId(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmContentId* content_id, FsContentAttributes attr) { return ::ncmContentStorageGetRightsIdFromContentId(cs, out_rights_id, content_id, attr); } +Result ContentStorageWriteContentForDebug(NcmContentStorage* cs, const NcmContentId* content_id, s64 offset, const void* data, size_t data_size) { return ::ncmContentStorageWriteContentForDebug(cs, content_id, offset, data, data_size); } +Result ContentStorageGetFreeSpaceSize(NcmContentStorage* cs, s64* out_size) { return ::ncmContentStorageGetFreeSpaceSize(cs, out_size); } +Result ContentStorageGetTotalSpaceSize(NcmContentStorage* cs, s64* out_size) { return ::ncmContentStorageGetTotalSpaceSize(cs, out_size); } +Result ContentStorageFlushPlaceHolder(NcmContentStorage* cs) { return ::ncmContentStorageFlushPlaceHolder(cs); } +Result ContentStorageGetSizeFromPlaceHolderId(NcmContentStorage* cs, s64* out_size, const NcmPlaceHolderId* placeholder_id) { return ::ncmContentStorageGetSizeFromPlaceHolderId(cs, out_size, placeholder_id); } +Result ContentStorageRepairInvalidFileAttribute(NcmContentStorage* cs) { return ::ncmContentStorageRepairInvalidFileAttribute(cs); } +Result ContentStorageGetRightsIdFromPlaceHolderIdWithCache(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id, const NcmContentId* cache_content_id, FsContentAttributes attr) { return ::ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(cs, out_rights_id, placeholder_id, cache_content_id, attr); } +Result ContentStorageRegisterPath(NcmContentStorage* cs, const NcmContentId* content_id, const char *path) { return ::ncmContentStorageRegisterPath(cs, content_id, path); } +Result ContentStorageClearRegisteredPath(NcmContentStorage* cs) { return ::ncmContentStorageClearRegisteredPath(cs); } +Result ContentStorageGetProgramId(NcmContentStorage* cs, u64* out, const NcmContentId* content_id, FsContentAttributes attr) { return ::ncmContentStorageGetProgramId(cs, out, content_id, attr); } +void ContentMetaDatabaseClose(NcmContentMetaDatabase* db) { ::ncmContentMetaDatabaseClose(db); } +Result ContentMetaDatabaseSet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, const void* data, u64 data_size) { return ::ncmContentMetaDatabaseSet(db, key, data, data_size); } +Result ContentMetaDatabaseGet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u64* out_size, void* out_data, u64 out_data_size) { return ::ncmContentMetaDatabaseGet(db, key, out_size, out_data, out_data_size); } +Result ContentMetaDatabaseRemove(NcmContentMetaDatabase* db, const NcmContentMetaKey *key) { return ::ncmContentMetaDatabaseRemove(db, key); } +Result ContentMetaDatabaseGetContentIdByType(NcmContentMetaDatabase* db, NcmContentId* out_content_id, const NcmContentMetaKey* key, NcmContentType type) { return ::ncmContentMetaDatabaseGetContentIdByType(db, out_content_id, key, type); } +Result ContentMetaDatabaseListContentInfo(NcmContentMetaDatabase* db, s32* out_entries_written, NcmContentInfo* out_info, s32 count, const NcmContentMetaKey* key, s32 start_index) { return ::ncmContentMetaDatabaseListContentInfo(db, out_entries_written, out_info, count, key, start_index); } +Result ContentMetaDatabaseList(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type, u64 id, u64 id_min, u64 id_max, NcmContentInstallType install_type) { return ::ncmContentMetaDatabaseList(db, out_entries_total, out_entries_written, out_keys, count, meta_type, id, id_min, id_max, install_type); } +Result ContentMetaDatabaseGetLatestContentMetaKey(NcmContentMetaDatabase* db, NcmContentMetaKey* out_key, u64 id) { return ::ncmContentMetaDatabaseGetLatestContentMetaKey(db, out_key, id); } +Result ContentMetaDatabaseListApplication(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmApplicationContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type) { return ::ncmContentMetaDatabaseListApplication(db, out_entries_total, out_entries_written, out_keys, count, meta_type); } +Result ContentMetaDatabaseHas(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key) { return ::ncmContentMetaDatabaseHas(db, out, key); } +Result ContentMetaDatabaseHasAll(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* keys, s32 count) { return ::ncmContentMetaDatabaseHasAll(db, out, keys, count); } +Result ContentMetaDatabaseGetSize(NcmContentMetaDatabase* db, u64* out_size, const NcmContentMetaKey* key) { return ::ncmContentMetaDatabaseGetSize(db, out_size, key); } +Result ContentMetaDatabaseGetRequiredSystemVersion(NcmContentMetaDatabase* db, u32* out_version, const NcmContentMetaKey* key) { return ::ncmContentMetaDatabaseGetRequiredSystemVersion(db, out_version, key); } +Result ContentMetaDatabaseGetPatchContentMetaId(NcmContentMetaDatabase* db, u64* out_patch_id, const NcmContentMetaKey* key) { return ::ncmContentMetaDatabaseGetPatchContentMetaId(db, out_patch_id, key); } +Result ContentMetaDatabaseDisableForcibly(NcmContentMetaDatabase* db) { return ::ncmContentMetaDatabaseDisableForcibly(db); } +Result ContentMetaDatabaseLookupOrphanContent(NcmContentMetaDatabase* db, bool* out_orphaned, const NcmContentId* content_ids, s32 count) { return ::ncmContentMetaDatabaseLookupOrphanContent(db, out_orphaned, content_ids, count); } +Result ContentMetaDatabaseCommit(NcmContentMetaDatabase* db) { return ::ncmContentMetaDatabaseCommit(db); } +Result ContentMetaDatabaseHasContent(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key, const NcmContentId* content_id) { return ::ncmContentMetaDatabaseHasContent(db, out, key, content_id); } +Result ContentMetaDatabaseListContentMetaInfo(NcmContentMetaDatabase* db, s32* out_entries_written, void* out_meta_info, s32 count, const NcmContentMetaKey* key, s32 start_index) { return ::ncmContentMetaDatabaseListContentMetaInfo(db, out_entries_written, out_meta_info, count, key, start_index); } +Result ContentMetaDatabaseGetAttributes(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u8* out) { return ::ncmContentMetaDatabaseGetAttributes(db, key, out); } +Result ContentMetaDatabaseGetRequiredApplicationVersion(NcmContentMetaDatabase* db, u32* out_version, const NcmContentMetaKey* key) { return ::ncmContentMetaDatabaseGetRequiredApplicationVersion(db, out_version, key); } +Result ContentMetaDatabaseGetContentIdByTypeAndIdOffset(NcmContentMetaDatabase* db, NcmContentId* out_content_id, const NcmContentMetaKey* key, NcmContentType type, u8 id_offset) { return ::ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(db, out_content_id, key, type, id_offset); } +Result ContentMetaDatabaseGetPlatform(NcmContentMetaDatabase* db, u8* out, const NcmContentMetaKey* key) { return ::ncmContentMetaDatabaseGetPlatform(db, out, key); } +void ContentInfoSizeToU64(const NcmContentInfo *info, u64 *out) { ::ncmContentInfoSizeToU64(info, out); } +void U64ToContentInfoSize(const u64 size, NcmContentInfo *info) { ::ncmU64ToContentInfoSize(size, info); } + +} // namespace ncm + +namespace news { + +Result Initialize(NewsServiceType service_type) { return ::newsInitialize(service_type); } +void Exit(void) { ::newsExit(); } +Service * GetServiceSession(void) { return ::newsGetServiceSession(); } +Result CreateNewlyArrivedEventHolder(NewsNewlyArrivedEventHolder *out) { return ::newsCreateNewlyArrivedEventHolder(out); } +Result CreateNewsDataService(NewsDataService *out) { return ::newsCreateNewsDataService(out); } +Result CreateNewsDatabaseService(NewsDatabaseService *out) { return ::newsCreateNewsDatabaseService(out); } +Result CreateOverwriteEventHolder(NewsOverwriteEventHolder *out) { return ::newsCreateOverwriteEventHolder(out); } +Result PostLocalNews(const void *news, size_t size) { return ::newsPostLocalNews(news, size); } +Result SetPassphrase(u64 program_id, const char *passphrase) { return ::newsSetPassphrase(program_id, passphrase); } +Result GetSubscriptionStatus(const char *filter, u32 *status) { return ::newsGetSubscriptionStatus(filter, status); } +Result GetTopicList(u32 channel, u32 *out_count, NewsTopicName *out, u32 max_count) { return ::newsGetTopicList(channel, out_count, out, max_count); } +Result GetSavedataUsage(u64 *current, u64 *total) { return ::newsGetSavedataUsage(current, total); } +Result IsSystemUpdateRequired(bool *out) { return ::newsIsSystemUpdateRequired(out); } +Result GetDatabaseVersion(u32 *version) { return ::newsGetDatabaseVersion(version); } +Result RequestImmediateReception(const char *filter) { return ::newsRequestImmediateReception(filter); } +Result SetSubscriptionStatus(const char *filter, u32 status) { return ::newsSetSubscriptionStatus(filter, status); } +Result ClearStorage(void) { return ::newsClearStorage(); } +Result ClearSubscriptionStatusAll(void) { return ::newsClearSubscriptionStatusAll(); } +Result GetNewsDatabaseDump(void *buffer, u64 size, u64 *out) { return ::newsGetNewsDatabaseDump(buffer, size, out); } +void NewlyArrivedEventHolderClose(NewsNewlyArrivedEventHolder *srv) { ::newsNewlyArrivedEventHolderClose(srv); } +Result NewlyArrivedEventHolderGet(NewsNewlyArrivedEventHolder *srv, Event *out) { return ::newsNewlyArrivedEventHolderGet(srv, out); } +void DataClose(NewsDataService *srv) { ::newsDataClose(srv); } +Result DataOpen(NewsDataService *srv, const char *file_name) { return ::newsDataOpen(srv, file_name); } +Result DataOpenWithNewsRecordV1(NewsDataService *srv, NewsRecordV1 *record) { return ::newsDataOpenWithNewsRecordV1(srv, record); } +Result DataRead(NewsDataService *srv, u64 *bytes_read, u64 offset, void *out, size_t out_size) { return ::newsDataRead(srv, bytes_read, offset, out, out_size); } +Result DataGetSize(NewsDataService *srv, u64 *size) { return ::newsDataGetSize(srv, size); } +Result DataOpenWithNewsRecord(NewsDataService *srv, NewsRecord *record) { return ::newsDataOpenWithNewsRecord(srv, record); } +void DatabaseClose(NewsDatabaseService *srv) { ::newsDatabaseClose(srv); } +Result DatabaseGetListV1(NewsDatabaseService *srv, NewsRecordV1 *out, u32 max_count, const char *where, const char *order, u32 *count, u32 offset) { return ::newsDatabaseGetListV1(srv, out, max_count, where, order, count, offset); } +Result DatabaseCount(NewsDatabaseService *srv, const char *filter, u32 *count) { return ::newsDatabaseCount(srv, filter, count); } +Result DatabaseGetList(NewsDatabaseService *srv, NewsRecord *out, u32 max_count, const char *where, const char *order, u32 *count, u32 offset) { return ::newsDatabaseGetList(srv, out, max_count, where, order, count, offset); } +void OverwriteEventHolderClose(NewsOverwriteEventHolder *srv) { ::newsOverwriteEventHolderClose(srv); } +Result OverwriteEventHolderGet(NewsOverwriteEventHolder *srv, Event *out) { return ::newsOverwriteEventHolderGet(srv, out); } + +} // namespace news + +namespace nfc { + +Result Initialize(NfcServiceType service_type) { return ::nfcInitialize(service_type); } +void Exit(void) { ::nfcExit(); } +Result MfInitialize(void) { return ::nfcMfInitialize(); } +void MfExit(void) { ::nfcMfExit(); } +Service* GetServiceSession(void) { return ::nfcGetServiceSession(); } +Service* GetServiceSession_Interface(void) { return ::nfcGetServiceSession_Interface(); } +Service* MfGetServiceSession(void) { return ::nfcMfGetServiceSession(); } +Service* MfGetServiceSession_Interface(void) { return ::nfcMfGetServiceSession_Interface(); } +Result ListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count) { return ::nfcListDevices(total_out, out, count); } +Result StartDetection(const NfcDeviceHandle *handle, NfcProtocol protocol) { return ::nfcStartDetection(handle, protocol); } +Result StopDetection(const NfcDeviceHandle *handle) { return ::nfcStopDetection(handle); } +Result MfListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count) { return ::nfcMfListDevices(total_out, out, count); } +Result MfStartDetection(const NfcDeviceHandle *handle) { return ::nfcMfStartDetection(handle); } +Result MfStopDetection(const NfcDeviceHandle *handle) { return ::nfcMfStopDetection(handle); } +Result GetTagInfo(const NfcDeviceHandle *handle, NfcTagInfo *out) { return ::nfcGetTagInfo(handle, out); } +Result MfGetTagInfo(const NfcDeviceHandle *handle, NfcTagInfo *out) { return ::nfcMfGetTagInfo(handle, out); } +Result AttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event) { return ::nfcAttachActivateEvent(handle, out_event); } +Result AttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event) { return ::nfcAttachDeactivateEvent(handle, out_event); } +Result MfAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event) { return ::nfcMfAttachActivateEvent(handle, out_event); } +Result MfAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event) { return ::nfcMfAttachDeactivateEvent(handle, out_event); } +Result GetState(NfcState *out) { return ::nfcGetState(out); } +Result GetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out) { return ::nfcGetDeviceState(handle, out); } +Result GetNpadId(const NfcDeviceHandle *handle, u32 *out) { return ::nfcGetNpadId(handle, out); } +Result MfGetState(NfcState *out) { return ::nfcMfGetState(out); } +Result MfGetDeviceState(const NfcDeviceHandle *handle, NfcMifareDeviceState *out) { return ::nfcMfGetDeviceState(handle, out); } +Result MfGetNpadId(const NfcDeviceHandle *handle, u32 *out) { return ::nfcMfGetNpadId(handle, out); } +Result AttachAvailabilityChangeEvent(Event *out_event) { return ::nfcAttachAvailabilityChangeEvent(out_event); } +Result MfAttachAvailabilityChangeEvent(Event *out_event) { return ::nfcMfAttachAvailabilityChangeEvent(out_event); } +Result IsNfcEnabled(bool *out) { return ::nfcIsNfcEnabled(out); } +Result ReadMifare(const NfcDeviceHandle *handle, NfcMifareReadBlockData *out_block_data, const NfcMifareReadBlockParameter *read_block_parameter, s32 count) { return ::nfcReadMifare(handle, out_block_data, read_block_parameter, count); } +Result WriteMifare(const NfcDeviceHandle *handle, const NfcMifareWriteBlockParameter *write_block_parameter, s32 count) { return ::nfcWriteMifare(handle, write_block_parameter, count); } +Result MfReadMifare(const NfcDeviceHandle *handle, NfcMifareReadBlockData *out_block_data, const NfcMifareReadBlockParameter *read_block_parameter, s32 count) { return ::nfcMfReadMifare(handle, out_block_data, read_block_parameter, count); } +Result MfWriteMifare(const NfcDeviceHandle *handle, const NfcMifareWriteBlockParameter *write_block_parameter, s32 count) { return ::nfcMfWriteMifare(handle, write_block_parameter, count); } +Result SendCommandByPassThrough(const NfcDeviceHandle *handle, u64 timeout, const void* cmd_buf, size_t cmd_buf_size, void* reply_buf, size_t reply_buf_size, u64 *out_size) { return ::nfcSendCommandByPassThrough(handle, timeout, cmd_buf, cmd_buf_size, reply_buf, reply_buf_size, out_size); } +Result KeepPassThroughSession(const NfcDeviceHandle *handle) { return ::nfcKeepPassThroughSession(handle); } +Result ReleasePassThroughSession(const NfcDeviceHandle *handle) { return ::nfcReleasePassThroughSession(handle); } + +} // namespace nfc + +namespace nfp { + +Result LaStartNicknameAndOwnerSettings(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) { return ::nfpLaStartNicknameAndOwnerSettings(in_param, in_tag_info, in_reg_info, out_tag_info, handle, reg_info_flag, out_reg_info); } +Result LaStartGameDataEraser(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle) { return ::nfpLaStartGameDataEraser(in_param, in_tag_info, out_tag_info, handle); } +Result LaStartRestorer(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle) { return ::nfpLaStartRestorer(in_param, in_tag_info, out_tag_info, handle); } +Result LaStartFormatter(const NfpLaAmiiboSettingsStartParam *in_param, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle) { return ::nfpLaStartFormatter(in_param, out_tag_info, handle); } +Result Initialize(NfpServiceType service_type) { return ::nfpInitialize(service_type); } +void Exit(void) { ::nfpExit(); } +Service* GetServiceSession(void) { return ::nfpGetServiceSession(); } +Service* GetServiceSession_Interface(void) { return ::nfpGetServiceSession_Interface(); } +Result ListDevices(s32 *total_out, NfcDeviceHandle *out, s32 count) { return ::nfpListDevices(total_out, out, count); } +Result StartDetection(const NfcDeviceHandle *handle) { return ::nfpStartDetection(handle); } +Result StopDetection(const NfcDeviceHandle *handle) { return ::nfpStopDetection(handle); } +Result Mount(const NfcDeviceHandle *handle, NfpDeviceType device_type, NfpMountTarget mount_target) { return ::nfpMount(handle, device_type, mount_target); } +Result Unmount(const NfcDeviceHandle *handle) { return ::nfpUnmount(handle); } +Result OpenApplicationArea(const NfcDeviceHandle *handle, u32 app_id) { return ::nfpOpenApplicationArea(handle, app_id); } +Result GetApplicationArea(const NfcDeviceHandle *handle, void* buf, size_t buf_size, u32 *out_size) { return ::nfpGetApplicationArea(handle, buf, buf_size, out_size); } +Result SetApplicationArea(const NfcDeviceHandle *handle, const void* buf, size_t buf_size) { return ::nfpSetApplicationArea(handle, buf, buf_size); } +Result Flush(const NfcDeviceHandle *handle) { return ::nfpFlush(handle); } +Result Restore(const NfcDeviceHandle *handle) { return ::nfpRestore(handle); } +Result CreateApplicationArea(const NfcDeviceHandle *handle, u32 app_id, const void* buf, size_t buf_size) { return ::nfpCreateApplicationArea(handle, app_id, buf, buf_size); } +Result RecreateApplicationArea(const NfcDeviceHandle *handle, u32 app_id, const void* buf, size_t buf_size) { return ::nfpRecreateApplicationArea(handle, app_id, buf, buf_size); } +Result GetApplicationAreaSize(const NfcDeviceHandle *handle, u32 *out_app_area_size) { return ::nfpGetApplicationAreaSize(handle, out_app_area_size); } +Result DeleteApplicationArea(const NfcDeviceHandle *handle) { return ::nfpDeleteApplicationArea(handle); } +Result ExistsApplicationArea(const NfcDeviceHandle *handle, bool *out) { return ::nfpExistsApplicationArea(handle, out); } +Result GetTagInfo(const NfcDeviceHandle *handle, NfpTagInfo *out) { return ::nfpGetTagInfo(handle, out); } +Result GetRegisterInfo(const NfcDeviceHandle *handle, NfpRegisterInfo *out) { return ::nfpGetRegisterInfo(handle, out); } +Result GetCommonInfo(const NfcDeviceHandle *handle, NfpCommonInfo *out) { return ::nfpGetCommonInfo(handle, out); } +Result GetModelInfo(const NfcDeviceHandle *handle, NfpModelInfo *out) { return ::nfpGetModelInfo(handle, out); } +Result GetAdminInfo(const NfcDeviceHandle *handle, NfpAdminInfo *out) { return ::nfpGetAdminInfo(handle, out); } +Result AttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event) { return ::nfpAttachActivateEvent(handle, out_event); } +Result AttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event) { return ::nfpAttachDeactivateEvent(handle, out_event); } +Result GetState(NfcState *out) { return ::nfpGetState(out); } +Result GetDeviceState(const NfcDeviceHandle *handle, NfpDeviceState *out) { return ::nfpGetDeviceState(handle, out); } +Result GetNpadId(const NfcDeviceHandle *handle, u32 *out) { return ::nfpGetNpadId(handle, out); } +Result AttachAvailabilityChangeEvent(Event *out_event) { return ::nfpAttachAvailabilityChangeEvent(out_event); } +Result Format(const NfcDeviceHandle *handle) { return ::nfpFormat(handle); } +Result GetRegisterInfoPrivate(const NfcDeviceHandle *handle, NfpRegisterInfoPrivate *out) { return ::nfpGetRegisterInfoPrivate(handle, out); } +Result SetRegisterInfoPrivate(const NfcDeviceHandle *handle, const NfpRegisterInfoPrivate *register_info_private) { return ::nfpSetRegisterInfoPrivate(handle, register_info_private); } +Result DeleteRegisterInfo(const NfcDeviceHandle *handle) { return ::nfpDeleteRegisterInfo(handle); } +Result GetAll(const NfcDeviceHandle *handle, NfpData *out) { return ::nfpGetAll(handle, out); } +Result SetAll(const NfcDeviceHandle *handle, const NfpData *nfp_data) { return ::nfpSetAll(handle, nfp_data); } +Result FlushDebug(const NfcDeviceHandle *handle) { return ::nfpFlushDebug(handle); } +Result BreakTag(const NfcDeviceHandle *handle, NfpBreakType break_type) { return ::nfpBreakTag(handle, break_type); } +Result ReadBackupData(const NfcDeviceHandle *handle, void* out_buf, size_t buf_size, u32 *out_size) { return ::nfpReadBackupData(handle, out_buf, buf_size, out_size); } +Result WriteBackupData(const NfcDeviceHandle *handle, const void* buf, size_t buf_size) { return ::nfpWriteBackupData(handle, buf, buf_size); } +Result WriteNtf(const NfcDeviceHandle *handle, u32 write_type, const void* buf, size_t buf_size) { return ::nfpWriteNtf(handle, write_type, buf, buf_size); } + +} // namespace nfp + +namespace nifm { + +Result LaHandleNetworkRequestResult(NifmRequest* r) { return ::nifmLaHandleNetworkRequestResult(r); } +Result Initialize(NifmServiceType service_type) { return ::nifmInitialize(service_type); } +void Exit(void) { ::nifmExit(); } +Service* GetServiceSession_StaticService(void) { return ::nifmGetServiceSession_StaticService(); } +Service* GetServiceSession_GeneralService(void) { return ::nifmGetServiceSession_GeneralService(); } +NifmClientId GetClientId(void) { return ::nifmGetClientId(); } +Result CreateRequest(NifmRequest* r, bool autoclear) { return ::nifmCreateRequest(r, autoclear); } +Result GetCurrentNetworkProfile(NifmNetworkProfileData *profile) { return ::nifmGetCurrentNetworkProfile(profile); } +Result EnumerateNetworkProfiles(NifmNetworkProfileType type, NifmNetworkProfileBasicInfo* buffer, s32 max_entries, s32* total_entries) { return ::nifmEnumerateNetworkProfiles(type, buffer, max_entries, total_entries); } +Result GetNetworkProfile(Uuid uuid, NifmNetworkProfileData *profile) { return ::nifmGetNetworkProfile(uuid, profile); } +Result SetNetworkProfile(const NifmNetworkProfileData *profile, Uuid *uuid) { return ::nifmSetNetworkProfile(profile, uuid); } +Result GetCurrentIpAddress(u32* out) { return ::nifmGetCurrentIpAddress(out); } +Result GetCurrentIpConfigInfo(u32 *current_addr, u32 *subnet_mask, u32 *gateway, u32 *primary_dns_server, u32 *secondary_dns_server) { return ::nifmGetCurrentIpConfigInfo(current_addr, subnet_mask, gateway, primary_dns_server, secondary_dns_server); } +Result SetWirelessCommunicationEnabled(bool enable) { return ::nifmSetWirelessCommunicationEnabled(enable); } +Result IsWirelessCommunicationEnabled(bool* out) { return ::nifmIsWirelessCommunicationEnabled(out); } +Result GetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus) { return ::nifmGetInternetConnectionStatus(connectionType, wifiStrength, connectionStatus); } +Result IsEthernetCommunicationEnabled(bool* out) { return ::nifmIsEthernetCommunicationEnabled(out); } +bool IsAnyInternetRequestAccepted(NifmClientId id) { return ::nifmIsAnyInternetRequestAccepted(id); } +Result IsAnyForegroundRequestAccepted(bool* out) { return ::nifmIsAnyForegroundRequestAccepted(out); } +Result PutToSleep(void) { return ::nifmPutToSleep(); } +Result WakeUp(void) { return ::nifmWakeUp(); } +Result SetWowlDelayedWakeTime(s32 val) { return ::nifmSetWowlDelayedWakeTime(val); } +void RequestClose(NifmRequest* r) { ::nifmRequestClose(r); } +Result GetRequestState(NifmRequest* r, NifmRequestState *out) { return ::nifmGetRequestState(r, out); } +Result GetResult(NifmRequest* r) { return ::nifmGetResult(r); } +Result RequestCancel(NifmRequest* r) { return ::nifmRequestCancel(r); } +Result RequestSubmit(NifmRequest* r) { return ::nifmRequestSubmit(r); } +Result RequestSubmitAndWait(NifmRequest* r) { return ::nifmRequestSubmitAndWait(r); } +Result RequestGetAppletInfo(NifmRequest* r, u32 theme_color, void* buffer, size_t size, u32 *applet_id, u32 *mode, u32 *out_size) { return ::nifmRequestGetAppletInfo(r, theme_color, buffer, size, applet_id, mode, out_size); } +Result RequestSetKeptInSleep(NifmRequest* r, bool flag) { return ::nifmRequestSetKeptInSleep(r, flag); } +Result RequestRegisterSocketDescriptor(NifmRequest* r, int sockfd) { return ::nifmRequestRegisterSocketDescriptor(r, sockfd); } +Result RequestUnregisterSocketDescriptor(NifmRequest* r, int sockfd) { return ::nifmRequestUnregisterSocketDescriptor(r, sockfd); } +Result RequestSetNetworkProfileId(NifmRequest* r, Uuid uuid) { return ::nifmRequestSetNetworkProfileId(r, uuid); } + +} // namespace nifm + +namespace nim { + +Result Initialize(void) { return ::nimInitialize(); } +void Exit(void) { ::nimExit(); } +Service* GetServiceSession(void) { return ::nimGetServiceSession(); } +Result ListSystemUpdateTask(s32 *out_count, NimSystemUpdateTaskId *out_task_ids, size_t max_task_ids) { return ::nimListSystemUpdateTask(out_count, out_task_ids, max_task_ids); } +Result DestroySystemUpdateTask(const NimSystemUpdateTaskId *task_id) { return ::nimDestroySystemUpdateTask(task_id); } + +} // namespace nim + +namespace notif { + +Result Initialize(NotifServiceType service_type) { return ::notifInitialize(service_type); } +void Exit(void) { ::notifExit(); } +Service* GetServiceSession(void) { return ::notifGetServiceSession(); } +void AlarmSettingCreate(NotifAlarmSetting *alarm_setting) { ::notifAlarmSettingCreate(alarm_setting); } +void AlarmSettingSetIsMuted(NotifAlarmSetting *alarm_setting, bool flag) { ::notifAlarmSettingSetIsMuted(alarm_setting, flag); } +void AlarmSettingSetUid(NotifAlarmSetting *alarm_setting, AccountUid uid) { ::notifAlarmSettingSetUid(alarm_setting, uid); } +Result AlarmSettingIsEnabled(NotifAlarmSetting *alarm_setting, u32 day_of_week, bool *out) { return ::notifAlarmSettingIsEnabled(alarm_setting, day_of_week, out); } +Result AlarmSettingGet(NotifAlarmSetting *alarm_setting, u32 day_of_week, NotifAlarmTime *out) { return ::notifAlarmSettingGet(alarm_setting, day_of_week, out); } +Result AlarmSettingEnable(NotifAlarmSetting *alarm_setting, u32 day_of_week, s32 hour, s32 minute) { return ::notifAlarmSettingEnable(alarm_setting, day_of_week, hour, minute); } +Result AlarmSettingDisable(NotifAlarmSetting *alarm_setting, u32 day_of_week) { return ::notifAlarmSettingDisable(alarm_setting, day_of_week); } +Result RegisterAlarmSetting(u16 *alarm_setting_id, const NotifAlarmSetting *alarm_setting, const void* buffer, size_t size) { return ::notifRegisterAlarmSetting(alarm_setting_id, alarm_setting, buffer, size); } +Result UpdateAlarmSetting(const NotifAlarmSetting *alarm_setting, const void* buffer, size_t size) { return ::notifUpdateAlarmSetting(alarm_setting, buffer, size); } +Result ListAlarmSettings(NotifAlarmSetting *alarm_settings, s32 count, s32 *total_out) { return ::notifListAlarmSettings(alarm_settings, count, total_out); } +Result LoadApplicationParameter(u16 alarm_setting_id, void* buffer, size_t size, u32 *actual_size) { return ::notifLoadApplicationParameter(alarm_setting_id, buffer, size, actual_size); } +Result DeleteAlarmSetting(u16 alarm_setting_id) { return ::notifDeleteAlarmSetting(alarm_setting_id); } +Result GetNotificationSystemEvent(Event *out_event) { return ::notifGetNotificationSystemEvent(out_event); } +Result TryPopNotifiedApplicationParameter(void* buffer, u64 size, u64 *out_size) { return ::notifTryPopNotifiedApplicationParameter(buffer, size, out_size); } + +} // namespace notif + +namespace ns { + +Result Initialize(void) { return ::nsInitialize(); } +void Exit(void) { ::nsExit(); } +Service* GetServiceSession_GetterInterface(void) { return ::nsGetServiceSession_GetterInterface(); } +Service* GetServiceSession_ApplicationManagerInterface(void) { return ::nsGetServiceSession_ApplicationManagerInterface(); } +Result GetDynamicRightsInterface(Service* srv_out) { return ::nsGetDynamicRightsInterface(srv_out); } +Result GetReadOnlyApplicationControlDataInterface(Service* srv_out) { return ::nsGetReadOnlyApplicationControlDataInterface(srv_out); } +Result GetReadOnlyApplicationRecordInterface(Service* srv_out) { return ::nsGetReadOnlyApplicationRecordInterface(srv_out); } +Result GetECommerceInterface(Service* srv_out) { return ::nsGetECommerceInterface(srv_out); } +Result GetApplicationVersionInterface(Service* srv_out) { return ::nsGetApplicationVersionInterface(srv_out); } +Result GetFactoryResetInterface(Service* srv_out) { return ::nsGetFactoryResetInterface(srv_out); } +Result GetAccountProxyInterface(Service* srv_out) { return ::nsGetAccountProxyInterface(srv_out); } +Result GetApplicationManagerInterface(Service* srv_out) { return ::nsGetApplicationManagerInterface(srv_out); } +Result GetDownloadTaskInterface(Service* srv_out) { return ::nsGetDownloadTaskInterface(srv_out); } +Result GetContentManagementInterface(Service* srv_out) { return ::nsGetContentManagementInterface(srv_out); } +Result GetDocumentInterface(Service* srv_out) { return ::nsGetDocumentInterface(srv_out); } +Result GetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size) { return ::nsGetApplicationControlData(source, application_id, buffer, size, actual_size); } +Result GetApplicationControlData2(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u8 flag1, u8 acd_idx, u64* actual_size, u32* unk) { return ::nsGetApplicationControlData2(source, application_id, buffer, size, flag1, acd_idx, actual_size, unk); } +Result GetApplicationDesiredLanguage(NacpStruct *nacp, NacpLanguageEntry **langentry) { return ::nsGetApplicationDesiredLanguage(nacp, langentry); } +Result RequestLinkDevice(AsyncResult *a, AccountUid uid) { return ::nsRequestLinkDevice(a, uid); } +Result RequestSyncRights(AsyncResult *a) { return ::nsRequestSyncRights(a); } +Result RequestUnlinkDevice(AsyncResult *a, AccountUid uid) { return ::nsRequestUnlinkDevice(a, uid); } +Result ResetToFactorySettings(void) { return ::nsResetToFactorySettings(); } +Result ResetToFactorySettingsWithoutUserSaveData(void) { return ::nsResetToFactorySettingsWithoutUserSaveData(); } +Result ResetToFactorySettingsForRefurbishment(void) { return ::nsResetToFactorySettingsForRefurbishment(); } +Result ResetToFactorySettingsWithPlatformRegion(void) { return ::nsResetToFactorySettingsWithPlatformRegion(); } +Result ResetToFactorySettingsWithPlatformRegionAuthentication(void) { return ::nsResetToFactorySettingsWithPlatformRegionAuthentication(); } +Result ListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount) { return ::nsListApplicationRecord(records, count, entry_offset, out_entrycount); } +Result GetApplicationRecordUpdateSystemEvent(Event* out_event) { return ::nsGetApplicationRecordUpdateSystemEvent(out_event); } +Result GetApplicationViewDeprecated(NsApplicationViewDeprecated *views, const u64 *application_ids, s32 count) { return ::nsGetApplicationViewDeprecated(views, application_ids, count); } +Result DeleteApplicationEntity(u64 application_id) { return ::nsDeleteApplicationEntity(application_id); } +Result DeleteApplicationCompletely(u64 application_id) { return ::nsDeleteApplicationCompletely(application_id); } +Result DeleteRedundantApplicationEntity(void) { return ::nsDeleteRedundantApplicationEntity(); } +Result IsApplicationEntityMovable(u64 application_id, NcmStorageId storage_id, bool *out) { return ::nsIsApplicationEntityMovable(application_id, storage_id, out); } +Result MoveApplicationEntity(u64 application_id, NcmStorageId storage_id) { return ::nsMoveApplicationEntity(application_id, storage_id); } +Result RequestApplicationUpdateInfo(AsyncValue *a, u64 application_id) { return ::nsRequestApplicationUpdateInfo(a, application_id); } +Result CancelApplicationDownload(u64 application_id) { return ::nsCancelApplicationDownload(application_id); } +Result ResumeApplicationDownload(u64 application_id) { return ::nsResumeApplicationDownload(application_id); } +Result CheckApplicationLaunchVersion(u64 application_id) { return ::nsCheckApplicationLaunchVersion(application_id); } +Result CalculateApplicationDownloadRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size) { return ::nsCalculateApplicationDownloadRequiredSize(application_id, storage_id, size); } +Result CleanupSdCard(void) { return ::nsCleanupSdCard(); } +Result GetSdCardMountStatusChangedEvent(Event* out_event) { return ::nsGetSdCardMountStatusChangedEvent(out_event); } +Result GetGameCardUpdateDetectionEvent(Event* out_event) { return ::nsGetGameCardUpdateDetectionEvent(out_event); } +Result DisableApplicationAutoDelete(u64 application_id) { return ::nsDisableApplicationAutoDelete(application_id); } +Result EnableApplicationAutoDelete(u64 application_id) { return ::nsEnableApplicationAutoDelete(application_id); } +Result SetApplicationTerminateResult(u64 application_id, Result res) { return ::nsSetApplicationTerminateResult(application_id, res); } +Result ClearApplicationTerminateResult(u64 application_id) { return ::nsClearApplicationTerminateResult(application_id); } +Result GetLastSdCardMountUnexpectedResult(void) { return ::nsGetLastSdCardMountUnexpectedResult(); } +Result GetRequestServerStopper(NsRequestServerStopper *r) { return ::nsGetRequestServerStopper(r); } +Result CancelApplicationApplyDelta(u64 application_id) { return ::nsCancelApplicationApplyDelta(application_id); } +Result ResumeApplicationApplyDelta(u64 application_id) { return ::nsResumeApplicationApplyDelta(application_id); } +Result CalculateApplicationApplyDeltaRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size) { return ::nsCalculateApplicationApplyDeltaRequiredSize(application_id, storage_id, size); } +Result ResumeAll(void) { return ::nsResumeAll(); } +Result GetStorageSize(NcmStorageId storage_id, s64 *total_space_size, s64 *free_space_size) { return ::nsGetStorageSize(storage_id, total_space_size, free_space_size); } +Result RequestUpdateApplication2(AsyncResult *a, u64 application_id) { return ::nsRequestUpdateApplication2(a, application_id); } +Result DeleteUserSaveDataAll(NsProgressMonitorForDeleteUserSaveDataAll *p, AccountUid uid) { return ::nsDeleteUserSaveDataAll(p, uid); } +Result DeleteUserSystemSaveData(AccountUid uid, u64 system_save_data_id) { return ::nsDeleteUserSystemSaveData(uid, system_save_data_id); } +Result DeleteSaveData(FsSaveDataSpaceId save_data_space_id, u64 save_data_id) { return ::nsDeleteSaveData(save_data_space_id, save_data_id); } +Result UnregisterNetworkServiceAccount(AccountUid uid) { return ::nsUnregisterNetworkServiceAccount(uid); } +Result UnregisterNetworkServiceAccountWithUserSaveDataDeletion(AccountUid uid) { return ::nsUnregisterNetworkServiceAccountWithUserSaveDataDeletion(uid); } +Result RequestDownloadApplicationControlData(AsyncResult *a, u64 application_id) { return ::nsRequestDownloadApplicationControlData(a, application_id); } +Result ListApplicationTitle(AsyncValue *a, NsApplicationControlSource source, const u64 *application_ids, s32 count, void* buffer, size_t size) { return ::nsListApplicationTitle(a, source, application_ids, count, buffer, size); } +Result ListApplicationTitle2(AsyncValue *a, NsApplicationControlSource source, const u64 *application_ids, s32 count, void* buffer, size_t size) { return ::nsListApplicationTitle2(a, source, application_ids, count, buffer, size); } +Result ListApplicationIcon(AsyncValue *a, NsApplicationControlSource source, const u64 *application_ids, s32 count, void* buffer, size_t size) { return ::nsListApplicationIcon(a, source, application_ids, count, buffer, size); } +Result RequestCheckGameCardRegistration(AsyncResult *a, u64 application_id) { return ::nsRequestCheckGameCardRegistration(a, application_id); } +Result RequestGameCardRegistrationGoldPoint(AsyncValue *a, AccountUid uid, u64 application_id) { return ::nsRequestGameCardRegistrationGoldPoint(a, uid, application_id); } +Result RequestRegisterGameCard(AsyncResult *a, AccountUid uid, u64 application_id, s32 inval) { return ::nsRequestRegisterGameCard(a, uid, application_id, inval); } +Result GetGameCardMountFailureEvent(Event* out_event) { return ::nsGetGameCardMountFailureEvent(out_event); } +Result IsGameCardInserted(bool *out) { return ::nsIsGameCardInserted(out); } +Result EnsureGameCardAccess(void) { return ::nsEnsureGameCardAccess(); } +Result GetLastGameCardMountFailureResult(void) { return ::nsGetLastGameCardMountFailureResult(); } +Result ListApplicationIdOnGameCard(u64 *application_ids, s32 count, s32 *total_out) { return ::nsListApplicationIdOnGameCard(application_ids, count, total_out); } +Result TouchApplication(u64 application_id) { return ::nsTouchApplication(application_id); } +Result IsApplicationUpdateRequested(u64 application_id, bool *flag, u32 *out) { return ::nsIsApplicationUpdateRequested(application_id, flag, out); } +Result WithdrawApplicationUpdateRequest(u64 application_id) { return ::nsWithdrawApplicationUpdateRequest(application_id); } +Result RequestVerifyAddOnContentsRights(NsProgressAsyncResult *a, u64 application_id) { return ::nsRequestVerifyAddOnContentsRights(a, application_id); } +Result RequestVerifyApplication(NsProgressAsyncResult *a, u64 application_id, u32 unk, void* buffer, size_t size) { return ::nsRequestVerifyApplication(a, application_id, unk, buffer, size); } +Result IsAnyApplicationEntityInstalled(u64 application_id, bool *out) { return ::nsIsAnyApplicationEntityInstalled(application_id, out); } +Result CleanupUnavailableAddOnContents(u64 application_id, AccountUid uid) { return ::nsCleanupUnavailableAddOnContents(application_id, uid); } +Result EstimateSizeToMove(u8 *storage_ids, s32 count, NcmStorageId storage_id, u32 flags, u64 application_id, s64 *out) { return ::nsEstimateSizeToMove(storage_ids, count, storage_id, flags, application_id, out); } +Result FormatSdCard(void) { return ::nsFormatSdCard(); } +Result NeedsSystemUpdateToFormatSdCard(bool *out) { return ::nsNeedsSystemUpdateToFormatSdCard(out); } +Result GetLastSdCardFormatUnexpectedResult(void) { return ::nsGetLastSdCardFormatUnexpectedResult(); } +Result GetApplicationView(NsApplicationView *views, const u64 *application_ids, s32 count) { return ::nsGetApplicationView(views, application_ids, count); } +Result GetApplicationViewDownloadErrorContext(u64 application_id, ErrorContext *context) { return ::nsGetApplicationViewDownloadErrorContext(application_id, context); } +Result GetApplicationViewWithPromotionInfo(NsApplicationViewWithPromotionInfo *out, const u64 *application_ids, s32 count) { return ::nsGetApplicationViewWithPromotionInfo(out, application_ids, count); } +Result RequestDownloadApplicationPrepurchasedRights(AsyncResult *a, u64 application_id) { return ::nsRequestDownloadApplicationPrepurchasedRights(a, application_id); } +Result GetSystemDeliveryInfo(NsSystemDeliveryInfo *info) { return ::nsGetSystemDeliveryInfo(info); } +Result SelectLatestSystemDeliveryInfo(const NsSystemDeliveryInfo *sys_list, s32 sys_count, const NsSystemDeliveryInfo *base_info, const NsApplicationDeliveryInfo *app_list, s32 app_count, s32 *index) { return ::nsSelectLatestSystemDeliveryInfo(sys_list, sys_count, base_info, app_list, app_count, index); } +Result VerifyDeliveryProtocolVersion(const NsSystemDeliveryInfo *info) { return ::nsVerifyDeliveryProtocolVersion(info); } +Result GetApplicationDeliveryInfo(NsApplicationDeliveryInfo *info, s32 count, u64 application_id, u32 attr, s32 *total_out) { return ::nsGetApplicationDeliveryInfo(info, count, application_id, attr, total_out); } +Result HasAllContentsToDeliver(const NsApplicationDeliveryInfo* info, s32 count, bool *out) { return ::nsHasAllContentsToDeliver(info, count, out); } +Result CompareApplicationDeliveryInfo(const NsApplicationDeliveryInfo *info0, s32 count0, const NsApplicationDeliveryInfo *info1, s32 count1, s32 *out) { return ::nsCompareApplicationDeliveryInfo(info0, count0, info1, count1, out); } +Result CanDeliverApplication(const NsApplicationDeliveryInfo *info0, s32 count0, const NsApplicationDeliveryInfo *info1, s32 count1, bool *out) { return ::nsCanDeliverApplication(info0, count0, info1, count1, out); } +Result ListContentMetaKeyToDeliverApplication(NcmContentMetaKey *meta, s32 meta_count, s32 meta_index, const NsApplicationDeliveryInfo *info, s32 info_count, s32 *total_out) { return ::nsListContentMetaKeyToDeliverApplication(meta, meta_count, meta_index, info, info_count, total_out); } +Result NeedsSystemUpdateToDeliverApplication(const NsApplicationDeliveryInfo *info, s32 count, const NsSystemDeliveryInfo *sys_info, bool *out) { return ::nsNeedsSystemUpdateToDeliverApplication(info, count, sys_info, out); } +Result EstimateRequiredSize(const NcmContentMetaKey *meta, s32 count, s64 *out) { return ::nsEstimateRequiredSize(meta, count, out); } +Result RequestReceiveApplication(AsyncResult *a, u32 addr, u16 port, u64 application_id, const NcmContentMetaKey *meta, s32 count, NcmStorageId storage_id) { return ::nsRequestReceiveApplication(a, addr, port, application_id, meta, count, storage_id); } +Result CommitReceiveApplication(u64 application_id) { return ::nsCommitReceiveApplication(application_id); } +Result GetReceiveApplicationProgress(u64 application_id, NsReceiveApplicationProgress *out) { return ::nsGetReceiveApplicationProgress(application_id, out); } +Result RequestSendApplication(AsyncResult *a, u32 addr, u16 port, u64 application_id, const NcmContentMetaKey *meta, s32 count) { return ::nsRequestSendApplication(a, addr, port, application_id, meta, count); } +Result GetSendApplicationProgress(u64 application_id, NsSendApplicationProgress *out) { return ::nsGetSendApplicationProgress(application_id, out); } +Result CompareSystemDeliveryInfo(const NsSystemDeliveryInfo *info0, const NsSystemDeliveryInfo *info1, s32 *out) { return ::nsCompareSystemDeliveryInfo(info0, info1, out); } +Result ListNotCommittedContentMeta(NcmContentMetaKey *meta, s32 count, u64 application_id, s32 unk, s32 *total_out) { return ::nsListNotCommittedContentMeta(meta, count, application_id, unk, total_out); } +Result GetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s32 count, u8 *out_hash) { return ::nsGetApplicationDeliveryInfoHash(info, count, out_hash); } +Result GetApplicationTerminateResult(u64 application_id, Result *res) { return ::nsGetApplicationTerminateResult(application_id, res); } +Result GetApplicationRightsOnClient(NsApplicationRightsOnClient *rights, s32 count, u64 application_id, AccountUid uid, u32 flags, s32 *total_out) { return ::nsGetApplicationRightsOnClient(rights, count, application_id, uid, flags, total_out); } +Result RequestNoDownloadRightsErrorResolution(AsyncValue *a, u64 application_id) { return ::nsRequestNoDownloadRightsErrorResolution(a, application_id); } +Result RequestResolveNoDownloadRightsError(AsyncValue *a, u64 application_id) { return ::nsRequestResolveNoDownloadRightsError(a, application_id); } +Result GetPromotionInfo(NsPromotionInfo *promotion, u64 application_id, AccountUid uid) { return ::nsGetPromotionInfo(promotion, application_id, uid); } +Result ClearTaskStatusList(void) { return ::nsClearTaskStatusList(); } +Result RequestDownloadTaskList(void) { return ::nsRequestDownloadTaskList(); } +Result RequestEnsureDownloadTask(AsyncResult *a) { return ::nsRequestEnsureDownloadTask(a); } +Result ListDownloadTaskStatus(NsDownloadTaskStatus* tasks, s32 count, s32 *total_out) { return ::nsListDownloadTaskStatus(tasks, count, total_out); } +Result RequestDownloadTaskListData(AsyncValue *a) { return ::nsRequestDownloadTaskListData(a); } +Result TryCommitCurrentApplicationDownloadTask(void) { return ::nsTryCommitCurrentApplicationDownloadTask(); } +Result EnableAutoCommit(void) { return ::nsEnableAutoCommit(); } +Result DisableAutoCommit(void) { return ::nsDisableAutoCommit(); } +Result TriggerDynamicCommitEvent(void) { return ::nsTriggerDynamicCommitEvent(); } +Result CalculateApplicationOccupiedSize(u64 application_id, NsApplicationOccupiedSize *out) { return ::nsCalculateApplicationOccupiedSize(application_id, out); } +Result CheckSdCardMountStatus(void) { return ::nsCheckSdCardMountStatus(); } +Result GetTotalSpaceSize(NcmStorageId storage_id, s64 *size) { return ::nsGetTotalSpaceSize(storage_id, size); } +Result GetFreeSpaceSize(NcmStorageId storage_id, s64 *size) { return ::nsGetFreeSpaceSize(storage_id, size); } +Result CountApplicationContentMeta(u64 application_id, s32 *out) { return ::nsCountApplicationContentMeta(application_id, out); } +Result ListApplicationContentMetaStatus(u64 application_id, s32 index, NsApplicationContentMetaStatus* list, s32 count, s32* out_entrycount) { return ::nsListApplicationContentMetaStatus(application_id, index, list, count, out_entrycount); } +Result IsAnyApplicationRunning(bool *out) { return ::nsIsAnyApplicationRunning(out); } +void RequestServerStopperClose(NsRequestServerStopper *r) { ::nsRequestServerStopperClose(r); } +Result ProgressMonitorForDeleteUserSaveDataAllClose(NsProgressMonitorForDeleteUserSaveDataAll *p) { return ::nsProgressMonitorForDeleteUserSaveDataAllClose(p); } +Result ProgressMonitorForDeleteUserSaveDataAllGetSystemEvent(NsProgressMonitorForDeleteUserSaveDataAll *p, Event* out_event) { return ::nsProgressMonitorForDeleteUserSaveDataAllGetSystemEvent(p, out_event); } +Result ProgressMonitorForDeleteUserSaveDataAllIsFinished(NsProgressMonitorForDeleteUserSaveDataAll *p, bool *out) { return ::nsProgressMonitorForDeleteUserSaveDataAllIsFinished(p, out); } +Result ProgressMonitorForDeleteUserSaveDataAllGetResult(NsProgressMonitorForDeleteUserSaveDataAll *p) { return ::nsProgressMonitorForDeleteUserSaveDataAllGetResult(p); } +Result ProgressMonitorForDeleteUserSaveDataAllGetProgress(NsProgressMonitorForDeleteUserSaveDataAll *p, NsProgressForDeleteUserSaveDataAll *progress) { return ::nsProgressMonitorForDeleteUserSaveDataAllGetProgress(p, progress); } +void ProgressAsyncResultClose(NsProgressAsyncResult *a) { ::nsProgressAsyncResultClose(a); } +Result ProgressAsyncResultWait(NsProgressAsyncResult *a, u64 timeout) { return ::nsProgressAsyncResultWait(a, timeout); } +Result ProgressAsyncResultGet(NsProgressAsyncResult *a) { return ::nsProgressAsyncResultGet(a); } +Result ProgressAsyncResultCancel(NsProgressAsyncResult *a) { return ::nsProgressAsyncResultCancel(a); } +Result ProgressAsyncResultGetProgress(NsProgressAsyncResult *a, void* buffer, size_t size) { return ::nsProgressAsyncResultGetProgress(a, buffer, size); } +Result ProgressAsyncResultGetDetailResult(NsProgressAsyncResult *a) { return ::nsProgressAsyncResultGetDetailResult(a); } +Result ProgressAsyncResultGetErrorContext(NsProgressAsyncResult *a, ErrorContext *context) { return ::nsProgressAsyncResultGetErrorContext(a, context); } + +} // namespace ns + +namespace nsdev { + +Result Initialize(void) { return ::nsdevInitialize(); } +void Exit(void) { ::nsdevExit(); } +Service* GetServiceSession(void) { return ::nsdevGetServiceSession(); } +Result LaunchProgram(u64* out_pid, const NsLaunchProperties* properties, u32 flags) { return ::nsdevLaunchProgram(out_pid, properties, flags); } +Result TerminateProcess(u64 pid) { return ::nsdevTerminateProcess(pid); } +Result TerminateProgram(u64 tid) { return ::nsdevTerminateProgram(tid); } +Result GetShellEvent(Event* out_event) { return ::nsdevGetShellEvent(out_event); } +Result GetShellEventInfo(NsShellEventInfo* out) { return ::nsdevGetShellEventInfo(out); } +Result TerminateApplication(void) { return ::nsdevTerminateApplication(); } +Result PrepareLaunchProgramFromHost(NsLaunchProperties* out, const char* path, size_t path_len) { return ::nsdevPrepareLaunchProgramFromHost(out, path, path_len); } +Result LaunchApplicationForDevelop(u64* out_pid, u64 application_id, u32 flags) { return ::nsdevLaunchApplicationForDevelop(out_pid, application_id, flags); } +Result LaunchApplicationFromHost(u64* out_pid, const char* path, size_t path_len, u32 flags) { return ::nsdevLaunchApplicationFromHost(out_pid, path, path_len, flags); } +Result LaunchApplicationWithStorageIdForDevelop(u64* out_pid, u64 application_id, u32 flags, u8 app_storage_id, u8 patch_storage_id) { return ::nsdevLaunchApplicationWithStorageIdForDevelop(out_pid, application_id, flags, app_storage_id, patch_storage_id); } +Result IsSystemMemoryResourceLimitBoosted(bool* out) { return ::nsdevIsSystemMemoryResourceLimitBoosted(out); } +Result GetRunningApplicationProcessIdForDevelop(u64* out_pid) { return ::nsdevGetRunningApplicationProcessIdForDevelop(out_pid); } +Result SetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop(bool can_be_active) { return ::nsdevSetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop(can_be_active); } + +} // namespace nsdev + +namespace nssu { + +Result Initialize(void) { return ::nssuInitialize(); } +void Exit(void) { ::nssuExit(); } +Service* GetServiceSession(void) { return ::nssuGetServiceSession(); } +Result GetBackgroundNetworkUpdateState(NsBackgroundNetworkUpdateState *out) { return ::nssuGetBackgroundNetworkUpdateState(out); } +Result OpenSystemUpdateControl(NsSystemUpdateControl *c) { return ::nssuOpenSystemUpdateControl(c); } +Result NotifyExFatDriverRequired(void) { return ::nssuNotifyExFatDriverRequired(); } +Result ClearExFatDriverStatusForDebug(void) { return ::nssuClearExFatDriverStatusForDebug(); } +Result RequestBackgroundNetworkUpdate(void) { return ::nssuRequestBackgroundNetworkUpdate(); } +Result NotifyBackgroundNetworkUpdate(const NcmContentMetaKey *key) { return ::nssuNotifyBackgroundNetworkUpdate(key); } +Result NotifyExFatDriverDownloadedForDebug(void) { return ::nssuNotifyExFatDriverDownloadedForDebug(); } +Result GetSystemUpdateNotificationEventForContentDelivery(Event* out_event) { return ::nssuGetSystemUpdateNotificationEventForContentDelivery(out_event); } +Result NotifySystemUpdateForContentDelivery(void) { return ::nssuNotifySystemUpdateForContentDelivery(); } +Result PrepareShutdown(void) { return ::nssuPrepareShutdown(); } +Result DestroySystemUpdateTask(void) { return ::nssuDestroySystemUpdateTask(); } +Result RequestSendSystemUpdate(AsyncResult *a, u32 addr, u16 port, NsSystemDeliveryInfo *info) { return ::nssuRequestSendSystemUpdate(a, addr, port, info); } +Result GetSendSystemUpdateProgress(NsSystemUpdateProgress *out) { return ::nssuGetSendSystemUpdateProgress(out); } +void ControlClose(NsSystemUpdateControl *c) { ::nssuControlClose(c); } +Result ControlHasDownloaded(NsSystemUpdateControl *c, bool* out) { return ::nssuControlHasDownloaded(c, out); } +Result ControlRequestCheckLatestUpdate(NsSystemUpdateControl *c, AsyncValue *a) { return ::nssuControlRequestCheckLatestUpdate(c, a); } +Result ControlRequestDownloadLatestUpdate(NsSystemUpdateControl *c, AsyncResult *a) { return ::nssuControlRequestDownloadLatestUpdate(c, a); } +Result ControlGetDownloadProgress(NsSystemUpdateControl *c, NsSystemUpdateProgress *out) { return ::nssuControlGetDownloadProgress(c, out); } +Result ControlApplyDownloadedUpdate(NsSystemUpdateControl *c) { return ::nssuControlApplyDownloadedUpdate(c); } +Result ControlRequestPrepareCardUpdate(NsSystemUpdateControl *c, AsyncResult *a) { return ::nssuControlRequestPrepareCardUpdate(c, a); } +Result ControlGetPrepareCardUpdateProgress(NsSystemUpdateControl *c, NsSystemUpdateProgress *out) { return ::nssuControlGetPrepareCardUpdateProgress(c, out); } +Result ControlHasPreparedCardUpdate(NsSystemUpdateControl *c, bool* out) { return ::nssuControlHasPreparedCardUpdate(c, out); } +Result ControlApplyCardUpdate(NsSystemUpdateControl *c) { return ::nssuControlApplyCardUpdate(c); } +Result ControlGetDownloadedEulaDataSize(NsSystemUpdateControl *c, const char* path, u64 *filesize) { return ::nssuControlGetDownloadedEulaDataSize(c, path, filesize); } +Result ControlGetDownloadedEulaData(NsSystemUpdateControl *c, const char* path, void* buffer, size_t size, u64 *filesize) { return ::nssuControlGetDownloadedEulaData(c, path, buffer, size, filesize); } +Result ControlSetupCardUpdate(NsSystemUpdateControl *c, void* buffer, size_t size) { return ::nssuControlSetupCardUpdate(c, buffer, size); } +Result ControlGetPreparedCardUpdateEulaDataSize(NsSystemUpdateControl *c, const char* path, u64 *filesize) { return ::nssuControlGetPreparedCardUpdateEulaDataSize(c, path, filesize); } +Result ControlGetPreparedCardUpdateEulaData(NsSystemUpdateControl *c, const char* path, void* buffer, size_t size, u64 *filesize) { return ::nssuControlGetPreparedCardUpdateEulaData(c, path, buffer, size, filesize); } +Result ControlSetupCardUpdateViaSystemUpdater(NsSystemUpdateControl *c, void* buffer, size_t size) { return ::nssuControlSetupCardUpdateViaSystemUpdater(c, buffer, size); } +Result ControlHasReceived(NsSystemUpdateControl *c, bool* out) { return ::nssuControlHasReceived(c, out); } +Result ControlRequestReceiveSystemUpdate(NsSystemUpdateControl *c, AsyncResult *a, u32 addr, u16 port, NsSystemDeliveryInfo *info) { return ::nssuControlRequestReceiveSystemUpdate(c, a, addr, port, info); } +Result ControlGetReceiveProgress(NsSystemUpdateControl *c, NsSystemUpdateProgress *out) { return ::nssuControlGetReceiveProgress(c, out); } +Result ControlApplyReceivedUpdate(NsSystemUpdateControl *c) { return ::nssuControlApplyReceivedUpdate(c); } +Result ControlGetReceivedEulaDataSize(NsSystemUpdateControl *c, const char* path, u64 *filesize) { return ::nssuControlGetReceivedEulaDataSize(c, path, filesize); } +Result ControlGetReceivedEulaData(NsSystemUpdateControl *c, const char* path, void* buffer, size_t size, u64 *filesize) { return ::nssuControlGetReceivedEulaData(c, path, buffer, size, filesize); } +Result ControlSetupToReceiveSystemUpdate(NsSystemUpdateControl *c) { return ::nssuControlSetupToReceiveSystemUpdate(c); } +Result ControlRequestCheckLatestUpdateIncludesRebootlessUpdate(NsSystemUpdateControl *c, AsyncValue *a) { return ::nssuControlRequestCheckLatestUpdateIncludesRebootlessUpdate(c, a); } + +} // namespace nssu + +namespace nsvm { + +Result Initialize(void) { return ::nsvmInitialize(); } +void Exit(void) { ::nsvmExit(); } +Service* GetServiceSession(void) { return ::nsvmGetServiceSession(); } +Result NeedsUpdateVulnerability(bool *out) { return ::nsvmNeedsUpdateVulnerability(out); } +Result GetSafeSystemVersion(NcmContentMetaKey *out) { return ::nsvmGetSafeSystemVersion(out); } + +} // namespace nsvm + +namespace nv { + +Result AddressSpaceCreate(NvAddressSpace* a, u32 page_size) { return ::nvAddressSpaceCreate(a, page_size); } +void AddressSpaceClose(NvAddressSpace* a) { ::nvAddressSpaceClose(a); } +Result AddressSpaceAlloc(NvAddressSpace* a, bool sparse, u64 size, iova_t* iova_out) { return ::nvAddressSpaceAlloc(a, sparse, size, iova_out); } +Result AddressSpaceAllocFixed(NvAddressSpace* a, bool sparse, u64 size, iova_t iova) { return ::nvAddressSpaceAllocFixed(a, sparse, size, iova); } +Result AddressSpaceFree(NvAddressSpace* a, iova_t iova, u64 size) { return ::nvAddressSpaceFree(a, iova, size); } +Result AddressSpaceMap(NvAddressSpace* a, u32 nvmap_handle, bool is_gpu_cacheable, NvKind kind, iova_t* iova_out) { return ::nvAddressSpaceMap(a, nvmap_handle, is_gpu_cacheable, kind, iova_out); } +Result AddressSpaceMapFixed(NvAddressSpace* a, u32 nvmap_handle, bool is_gpu_cacheable, NvKind kind, iova_t iova) { return ::nvAddressSpaceMapFixed(a, nvmap_handle, is_gpu_cacheable, kind, iova); } +Result AddressSpaceModify(NvAddressSpace* a, iova_t iova, u64 offset, u64 size, NvKind kind) { return ::nvAddressSpaceModify(a, iova, offset, size, kind); } +Result AddressSpaceUnmap(NvAddressSpace* a, iova_t iova) { return ::nvAddressSpaceUnmap(a, iova); } +Result ChannelCreate(NvChannel* c, const char* dev) { return ::nvChannelCreate(c, dev); } +void ChannelClose(NvChannel* c) { ::nvChannelClose(c); } +Result ChannelSetPriority(NvChannel* c, NvChannelPriority prio) { return ::nvChannelSetPriority(c, prio); } +Result ChannelSetTimeout(NvChannel* c, u32 timeout) { return ::nvChannelSetTimeout(c, timeout); } +Result FenceInit(void) { return ::nvFenceInit(); } +void FenceExit(void) { ::nvFenceExit(); } +u32 FenceGetFd(void) { return ::nvFenceGetFd(); } +Result FenceWait(NvFence* f, s32 timeout_us) { return ::nvFenceWait(f, timeout_us); } +void MultiFenceCreate(NvMultiFence* mf, const NvFence* fence) { ::nvMultiFenceCreate(mf, fence); } +Result MultiFenceWait(NvMultiFence* mf, s32 timeout_us) { return ::nvMultiFenceWait(mf, timeout_us); } +Result GpuInit(void) { return ::nvGpuInit(); } +void GpuExit(void) { ::nvGpuExit(); } +const nvioctl_gpu_characteristics* GpuGetCharacteristics(void) { return ::nvGpuGetCharacteristics(); } +u32 GpuGetZcullCtxSize(void) { return ::nvGpuGetZcullCtxSize(); } +const nvioctl_zcull_info* GpuGetZcullInfo(void) { return ::nvGpuGetZcullInfo(); } +const u32* GpuGetTpcMasks(u32 *num_masks_out) { return ::nvGpuGetTpcMasks(num_masks_out); } +Result GpuZbcGetActiveSlotMask(u32 *out_slot, u32 *out_mask) { return ::nvGpuZbcGetActiveSlotMask(out_slot, out_mask); } +Result GpuZbcAddColor(const u32 color_l2[4], const u32 color_ds[4], u32 format) { return ::nvGpuZbcAddColor(color_l2, color_ds, format); } +Result GpuZbcAddDepth(float depth) { return ::nvGpuZbcAddDepth(depth); } +Result GpuGetTimestamp(u64 *ts) { return ::nvGpuGetTimestamp(ts); } +Result GpuChannelCreate(NvGpuChannel* c, struct NvAddressSpace* as, NvChannelPriority prio) { return ::nvGpuChannelCreate(c, as, prio); } +void GpuChannelClose(NvGpuChannel* c) { ::nvGpuChannelClose(c); } +Result GpuChannelZcullBind(NvGpuChannel* c, iova_t iova) { return ::nvGpuChannelZcullBind(c, iova); } +Result GpuChannelAppendEntry(NvGpuChannel* c, iova_t start, size_t num_cmds, u32 flags, u32 flush_threshold) { return ::nvGpuChannelAppendEntry(c, start, num_cmds, flags, flush_threshold); } +Result GpuChannelKickoff(NvGpuChannel* c) { return ::nvGpuChannelKickoff(c); } +Result GpuChannelGetErrorNotification(NvGpuChannel* c, NvNotification* notif) { return ::nvGpuChannelGetErrorNotification(c, notif); } +Result GpuChannelGetErrorInfo(NvGpuChannel* c, NvError* error) { return ::nvGpuChannelGetErrorInfo(c, error); } +u32 GpuChannelGetSyncpointId(NvGpuChannel* c) { return ::nvGpuChannelGetSyncpointId(c); } +void GpuChannelGetFence(NvGpuChannel* c, NvFence* fence_out) { ::nvGpuChannelGetFence(c, fence_out); } +void GpuChannelIncrFence(NvGpuChannel* c) { ::nvGpuChannelIncrFence(c); } +Result MapInit(void) { return ::nvMapInit(); } +u32 MapGetFd(void) { return ::nvMapGetFd(); } +void MapExit(void) { ::nvMapExit(); } +Result MapCreate(NvMap* m, void* cpu_addr, u32 size, u32 align, NvKind kind, bool is_cpu_cacheable) { return ::nvMapCreate(m, cpu_addr, size, align, kind, is_cpu_cacheable); } +Result MapLoadRemote(NvMap* m, u32 id) { return ::nvMapLoadRemote(m, id); } +void MapClose(NvMap* m) { ::nvMapClose(m); } +u32 MapGetHandle(NvMap* m) { return ::nvMapGetHandle(m); } +u32 MapGetId(NvMap* m) { return ::nvMapGetId(m); } +u32 MapGetSize(NvMap* m) { return ::nvMapGetSize(m); } +void* MapGetCpuAddr(NvMap* m) { return ::nvMapGetCpuAddr(m); } +bool MapIsRemote(NvMap* m) { return ::nvMapIsRemote(m); } +NvKind MapGetKind(NvMap* m) { return ::nvMapGetKind(m); } +Result Initialize(void) { return ::nvInitialize(); } +void Exit(void) { ::nvExit(); } +Service* GetServiceSession(void) { return ::nvGetServiceSession(); } +Result Open(u32 *fd, const char *devicepath) { return ::nvOpen(fd, devicepath); } +Result Ioctl(u32 fd, u32 request, void* argp) { return ::nvIoctl(fd, request, argp); } +Result Ioctl2(u32 fd, u32 request, void* argp, const void* inbuf, size_t inbuf_size) { return ::nvIoctl2(fd, request, argp, inbuf, inbuf_size); } +Result Ioctl3(u32 fd, u32 request, void* argp, void* outbuf, size_t outbuf_size) { return ::nvIoctl3(fd, request, argp, outbuf, outbuf_size); } +Result Close(u32 fd) { return ::nvClose(fd); } +Result QueryEvent(u32 fd, u32 event_id, Event *event_out) { return ::nvQueryEvent(fd, event_id, event_out); } +Result ConvertError(int rc) { return ::nvConvertError(rc); } + +} // namespace nv + +namespace nvioctl { + +Result NvhostCtrl_SyncptRead(u32 fd, u32 id, u32* out) { return ::nvioctlNvhostCtrl_SyncptRead(fd, id, out); } +Result NvhostCtrl_SyncptIncr(u32 fd, u32 id) { return ::nvioctlNvhostCtrl_SyncptIncr(fd, id); } +Result NvhostCtrl_SyncptWait(u32 fd, u32 id, u32 threshold, u32 timeout) { return ::nvioctlNvhostCtrl_SyncptWait(fd, id, threshold, timeout); } +Result NvhostCtrl_EventSignal(u32 fd, u32 event_id) { return ::nvioctlNvhostCtrl_EventSignal(fd, event_id); } +Result NvhostCtrl_EventWait(u32 fd, u32 syncpt_id, u32 threshold, s32 timeout, u32 event_id, u32 *out) { return ::nvioctlNvhostCtrl_EventWait(fd, syncpt_id, threshold, timeout, event_id, out); } +Result NvhostCtrl_EventWaitAsync(u32 fd, u32 syncpt_id, u32 threshold, s32 timeout, u32 event_id) { return ::nvioctlNvhostCtrl_EventWaitAsync(fd, syncpt_id, threshold, timeout, event_id); } +Result NvhostCtrl_EventRegister(u32 fd, u32 event_id) { return ::nvioctlNvhostCtrl_EventRegister(fd, event_id); } +Result NvhostCtrl_EventUnregister(u32 fd, u32 event_id) { return ::nvioctlNvhostCtrl_EventUnregister(fd, event_id); } +Result NvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out) { return ::nvioctlNvhostCtrlGpu_ZCullGetCtxSize(fd, out); } +Result NvhostCtrlGpu_ZCullGetInfo(u32 fd, nvioctl_zcull_info *out) { return ::nvioctlNvhostCtrlGpu_ZCullGetInfo(fd, out); } +Result NvhostCtrlGpu_ZbcSetTable(u32 fd, const u32 color_ds[4], const u32 color_l2[4], u32 depth, u32 format, u32 type) { return ::nvioctlNvhostCtrlGpu_ZbcSetTable(fd, color_ds, color_l2, depth, format, type); } +Result NvhostCtrlGpu_ZbcQueryTable(u32 fd, u32 index, nvioctl_zbc_entry *out) { return ::nvioctlNvhostCtrlGpu_ZbcQueryTable(fd, index, out); } +Result NvhostCtrlGpu_GetCharacteristics(u32 fd, nvioctl_gpu_characteristics *out) { return ::nvioctlNvhostCtrlGpu_GetCharacteristics(fd, out); } +Result NvhostCtrlGpu_GetTpcMasks(u32 fd, void *buffer, size_t size) { return ::nvioctlNvhostCtrlGpu_GetTpcMasks(fd, buffer, size); } +Result NvhostCtrlGpu_ZbcGetActiveSlotMask(u32 fd, nvioctl_zbc_slot_mask *out) { return ::nvioctlNvhostCtrlGpu_ZbcGetActiveSlotMask(fd, out); } +Result NvhostCtrlGpu_GetGpuTime(u32 fd, nvioctl_gpu_time *out) { return ::nvioctlNvhostCtrlGpu_GetGpuTime(fd, out); } +Result NvhostAsGpu_BindChannel(u32 fd, u32 channel_fd) { return ::nvioctlNvhostAsGpu_BindChannel(fd, channel_fd); } +Result NvhostAsGpu_AllocSpace(u32 fd, u32 pages, u32 page_size, u32 flags, u64 align_or_offset, u64 *offset) { return ::nvioctlNvhostAsGpu_AllocSpace(fd, pages, page_size, flags, align_or_offset, offset); } +Result NvhostAsGpu_FreeSpace(u32 fd, u64 offset, u32 pages, u32 page_size) { return ::nvioctlNvhostAsGpu_FreeSpace(fd, offset, pages, page_size); } +Result NvhostAsGpu_MapBufferEx(u32 fd, u32 flags, u32 kind, u32 nvmap_handle, u32 page_size, u64 buffer_offset, u64 mapping_size, u64 input_offset, u64 *offset) { return ::nvioctlNvhostAsGpu_MapBufferEx(fd, flags, kind, nvmap_handle, page_size, buffer_offset, mapping_size, input_offset, offset); } +Result NvhostAsGpu_UnmapBuffer(u32 fd, u64 offset) { return ::nvioctlNvhostAsGpu_UnmapBuffer(fd, offset); } +Result NvhostAsGpu_GetVARegions(u32 fd, nvioctl_va_region regions[2]) { return ::nvioctlNvhostAsGpu_GetVARegions(fd, regions); } +Result NvhostAsGpu_InitializeEx(u32 fd, u32 flags, u32 big_page_size) { return ::nvioctlNvhostAsGpu_InitializeEx(fd, flags, big_page_size); } +Result Nvmap_Create(u32 fd, u32 size, u32 *nvmap_handle) { return ::nvioctlNvmap_Create(fd, size, nvmap_handle); } +Result Nvmap_FromId(u32 fd, u32 id, u32 *nvmap_handle) { return ::nvioctlNvmap_FromId(fd, id, nvmap_handle); } +Result Nvmap_Alloc(u32 fd, u32 nvmap_handle, u32 heapmask, u32 flags, u32 align, u8 kind, void* addr) { return ::nvioctlNvmap_Alloc(fd, nvmap_handle, heapmask, flags, align, kind, addr); } +Result Nvmap_Free(u32 fd, u32 nvmap_handle) { return ::nvioctlNvmap_Free(fd, nvmap_handle); } +Result Nvmap_Param(u32 fd, u32 nvmap_handle, NvMapParam param, u32 *result) { return ::nvioctlNvmap_Param(fd, nvmap_handle, param, result); } +Result Nvmap_GetId(u32 fd, u32 nvmap_handle, u32 *id) { return ::nvioctlNvmap_GetId(fd, nvmap_handle, id); } +Result Channel_SetNvmapFd(u32 fd, u32 nvmap_fd) { return ::nvioctlChannel_SetNvmapFd(fd, nvmap_fd); } +Result Channel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_inout) { return ::nvioctlChannel_SubmitGpfifo(fd, entries, num_entries, flags, fence_inout); } +Result Channel_KickoffPb(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_inout) { return ::nvioctlChannel_KickoffPb(fd, entries, num_entries, flags, fence_inout); } +Result Channel_AllocObjCtx(u32 fd, u32 class_num, u32 flags, u64* id_out) { return ::nvioctlChannel_AllocObjCtx(fd, class_num, flags, id_out); } +Result Channel_ZCullBind(u32 fd, u64 gpu_va, u32 mode) { return ::nvioctlChannel_ZCullBind(fd, gpu_va, mode); } +Result Channel_SetErrorNotifier(u32 fd, u32 enable) { return ::nvioctlChannel_SetErrorNotifier(fd, enable); } +Result Channel_GetErrorInfo(u32 fd, NvError* out) { return ::nvioctlChannel_GetErrorInfo(fd, out); } +Result Channel_GetErrorNotification(u32 fd, NvNotification* out) { return ::nvioctlChannel_GetErrorNotification(fd, out); } +Result Channel_SetPriority(u32 fd, u32 priority) { return ::nvioctlChannel_SetPriority(fd, priority); } +Result Channel_SetTimeout(u32 fd, u32 timeout) { return ::nvioctlChannel_SetTimeout(fd, timeout); } +Result Channel_AllocGpfifoEx2(u32 fd, u32 num_entries, u32 flags, u32 unk0, u32 unk1, u32 unk2, u32 unk3, nvioctl_fence *fence_out) { return ::nvioctlChannel_AllocGpfifoEx2(fd, num_entries, flags, unk0, unk1, unk2, unk3, fence_out); } +Result Channel_SetUserData(u32 fd, void* addr) { return ::nvioctlChannel_SetUserData(fd, addr); } +Result Channel_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) { return ::nvioctlChannel_Submit(fd, cmdbufs, num_cmdbufs, relocs, reloc_shifts, num_relocs, syncpt_incrs, num_syncpt_incrs, fences, num_fences); } +Result Channel_GetSyncpt(u32 fd, u32 module_id, u32 *syncpt) { return ::nvioctlChannel_GetSyncpt(fd, module_id, syncpt); } +Result Channel_GetModuleClockRate(u32 fd, u32 module_id, u32 *freq) { return ::nvioctlChannel_GetModuleClockRate(fd, module_id, freq); } +Result Channel_SetModuleClockRate(u32 fd, u32 module_id, u32 freq) { return ::nvioctlChannel_SetModuleClockRate(fd, module_id, freq); } +Result Channel_MapCommandBuffer(u32 fd, nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed) { return ::nvioctlChannel_MapCommandBuffer(fd, maps, num_maps, compressed); } +Result Channel_UnmapCommandBuffer(u32 fd, const nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed) { return ::nvioctlChannel_UnmapCommandBuffer(fd, maps, num_maps, compressed); } +Result Channel_SetSubmitTimeout(u32 fd, u32 timeout) { return ::nvioctlChannel_SetSubmitTimeout(fd, timeout); } + +} // namespace nvioctl + +namespace nwindow { + +bool IsValid(NWindow* nw) { return ::nwindowIsValid(nw); } +NWindow* GetDefault(void) { return ::nwindowGetDefault(); } +Result Create(NWindow* nw, Service* binder_session, s32 binder_id, bool producer_controlled_by_app) { return ::nwindowCreate(nw, binder_session, binder_id, producer_controlled_by_app); } +Result CreateFromLayer(NWindow* nw, const ViLayer* layer) { return ::nwindowCreateFromLayer(nw, layer); } +void Close(NWindow* nw) { ::nwindowClose(nw); } +Result GetDimensions(NWindow* nw, u32* out_width, u32* out_height) { return ::nwindowGetDimensions(nw, out_width, out_height); } +Result SetDimensions(NWindow* nw, u32 width, u32 height) { return ::nwindowSetDimensions(nw, width, height); } +Result SetCrop(NWindow* nw, s32 left, s32 top, s32 right, s32 bottom) { return ::nwindowSetCrop(nw, left, top, right, bottom); } +Result SetTransform(NWindow* nw, u32 transform) { return ::nwindowSetTransform(nw, transform); } +Result SetSwapInterval(NWindow* nw, u32 swap_interval) { return ::nwindowSetSwapInterval(nw, swap_interval); } +bool IsConsumerRunningBehind(NWindow* nw) { return ::nwindowIsConsumerRunningBehind(nw); } +Result ConfigureBuffer(NWindow* nw, s32 slot, NvGraphicBuffer* buf) { return ::nwindowConfigureBuffer(nw, slot, buf); } +Result DequeueBuffer(NWindow* nw, s32* out_slot, NvMultiFence* out_fence) { return ::nwindowDequeueBuffer(nw, out_slot, out_fence); } +Result CancelBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence) { return ::nwindowCancelBuffer(nw, slot, fence); } +Result QueueBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence) { return ::nwindowQueueBuffer(nw, slot, fence); } +Result ReleaseBuffers(NWindow* nw) { return ::nwindowReleaseBuffers(nw); } + +} // namespace nwindow + +namespace nxlink { + +int ConnectToHost(bool redirStdout, bool redirStderr) { return ::nxlinkConnectToHost(redirStdout, redirStderr); } +int Stdio(void) { return ::nxlinkStdio(); } +int StdioForDebug(void) { return ::nxlinkStdioForDebug(); } + +} // namespace nxlink + +namespace omm { + +Result Initialize(void) { return ::ommInitialize(); } +void Exit(void) { ::ommExit(); } +Service* GetServiceSession(void) { return ::ommGetServiceSession(); } +Result GetDefaultDisplayResolution(s32* width, s32* height) { return ::ommGetDefaultDisplayResolution(width, height); } +Result GetOperationMode(OmmOperationMode* s) { return ::ommGetOperationMode(s); } +Result SetOperationModePolicy(OmmOperationModePolicy value) { return ::ommSetOperationModePolicy(value); } + +} // namespace omm + +namespace ovlnrcv { + +Result Initialize(void) { return ::ovlnrcvInitialize(); } +void Exit(void) { ::ovlnrcvExit(); } +Service* GetServiceSession(void) { return ::ovlnrcvGetServiceSession(); } +Result OpenReceiver(OvlnReceiver *r) { return ::ovlnrcvOpenReceiver(r); } +void CloseReceiver(OvlnReceiver *r) { ::ovlnrcvCloseReceiver(r); } +Result AddSource(OvlnReceiver *r, const OvlnSourceName *name) { return ::ovlnrcvAddSource(r, name); } +Result RemoveSource(OvlnReceiver *r, const OvlnSourceName *name) { return ::ovlnrcvRemoveSource(r, name); } +Result GetReceiveEventHandle(OvlnReceiver *r, Event* out_event) { return ::ovlnrcvGetReceiveEventHandle(r, out_event); } +Result Receive(OvlnReceiver *r, OvlnRawMessage *message) { return ::ovlnrcvReceive(r, message); } +Result ReceiveWithTick(OvlnReceiver *r, OvlnRawMessage *message, s64 *tick) { return ::ovlnrcvReceiveWithTick(r, message, tick); } + +} // namespace ovlnrcv + +namespace ovlnsnd { + +Result Initialize(void) { return ::ovlnsndInitialize(); } +void Exit(void) { ::ovlnsndExit(); } +Service* GetServiceSession(void) { return ::ovlnsndGetServiceSession(); } +Result OpenSender(OvlnSender *s, const OvlnSourceName *name, OvlnQueueAttribute attribute) { return ::ovlnsndOpenSender(s, name, attribute); } +void CloseSender(OvlnSender *s) { ::ovlnsndCloseSender(s); } +Result Send(OvlnSender *s, OvlnSendOption option, const OvlnRawMessage *message) { return ::ovlnsndSend(s, option, message); } +Result GetUnreceivedMessageCount(OvlnSender *s, u32 *count) { return ::ovlnsndGetUnreceivedMessageCount(s, count); } + +} // namespace ovlnsnd + +namespace pad { + +void ConfigureInput(u32 max_players, u32 style_set) { ::padConfigureInput(max_players, style_set); } +void InitializeWithMask(PadState* pad, u64 mask) { ::padInitializeWithMask(pad, mask); } +void InitializeAny(PadState* pad) { ::padInitializeAny(pad); } +void InitializeDefault(PadState* pad) { ::padInitializeDefault(pad); } +void Update(PadState* pad) { ::padUpdate(pad); } +bool IsHandheld(const PadState* pad) { return ::padIsHandheld(pad); } +bool IsNpadActive(const PadState* pad, HidNpadIdType id) { return ::padIsNpadActive(pad, id); } +u32 GetStyleSet(const PadState* pad) { return ::padGetStyleSet(pad); } +u32 GetAttributes(const PadState* pad) { return ::padGetAttributes(pad); } +bool IsConnected(const PadState* pad) { return ::padIsConnected(pad); } +u64 GetButtons(const PadState* pad) { return ::padGetButtons(pad); } +u64 GetButtonsDown(const PadState* pad) { return ::padGetButtonsDown(pad); } +u64 GetButtonsUp(const PadState* pad) { return ::padGetButtonsUp(pad); } +HidAnalogStickState GetStickPos(const PadState* pad, unsigned i) { return ::padGetStickPos(pad, i); } +u32 GetGcTriggerPos(const PadState* pad, unsigned i) { return ::padGetGcTriggerPos(pad, i); } +void RepeaterInitialize(PadRepeater* r, u16 delay, u16 repeat) { ::padRepeaterInitialize(r, delay, repeat); } +void RepeaterUpdate(PadRepeater* r, u64 button_mask) { ::padRepeaterUpdate(r, button_mask); } +u64 RepeaterGetButtons(const PadRepeater* r) { return ::padRepeaterGetButtons(r); } + +} // namespace pad + +namespace parcel { + +void Create(Parcel *ctx) { ::parcelCreate(ctx); } +Result Transact(Binder *session, u32 code, Parcel *in_parcel, Parcel *reply_parcel) { return ::parcelTransact(session, code, in_parcel, reply_parcel); } +void* WriteData(Parcel *ctx, const void* data, size_t data_size) { return ::parcelWriteData(ctx, data, data_size); } +void* ReadData(Parcel *ctx, void* data, size_t data_size) { return ::parcelReadData(ctx, data, data_size); } +void WriteInt32(Parcel *ctx, s32 val) { ::parcelWriteInt32(ctx, val); } +void WriteUInt32(Parcel *ctx, u32 val) { ::parcelWriteUInt32(ctx, val); } +void WriteString16(Parcel *ctx, const char *str) { ::parcelWriteString16(ctx, str); } +s32 ReadInt32(Parcel *ctx) { return ::parcelReadInt32(ctx); } +u32 ReadUInt32(Parcel *ctx) { return ::parcelReadUInt32(ctx); } +void WriteInterfaceToken(Parcel *ctx, const char *str) { ::parcelWriteInterfaceToken(ctx, str); } +void* ReadFlattenedObject(Parcel *ctx, size_t *size) { return ::parcelReadFlattenedObject(ctx, size); } +void* WriteFlattenedObject(Parcel *ctx, const void* data, size_t size) { return ::parcelWriteFlattenedObject(ctx, data, size); } + +} // namespace parcel + +namespace pctl { + +Result Initialize(void) { return ::pctlInitialize(); } +void Exit(void) { ::pctlExit(); } +Service* GetServiceSession(void) { return ::pctlGetServiceSession(); } +Service* GetServiceSession_Service(void) { return ::pctlGetServiceSession_Service(); } +Result IsRestrictionTemporaryUnlocked(bool *flag) { return ::pctlIsRestrictionTemporaryUnlocked(flag); } +Result ConfirmStereoVisionPermission(void) { return ::pctlConfirmStereoVisionPermission(); } +Result IsRestrictionEnabled(bool *flag) { return ::pctlIsRestrictionEnabled(flag); } +Result GetSafetyLevel(u32 *safety_level) { return ::pctlGetSafetyLevel(safety_level); } +Result GetCurrentSettings(PctlRestrictionSettings *settings) { return ::pctlGetCurrentSettings(settings); } +Result GetFreeCommunicationApplicationListCount(u32 *count) { return ::pctlGetFreeCommunicationApplicationListCount(count); } +Result ResetConfirmedStereoVisionPermission(void) { return ::pctlResetConfirmedStereoVisionPermission(); } +Result IsStereoVisionPermitted(bool *flag) { return ::pctlIsStereoVisionPermitted(flag); } +Result IsPairingActive(bool *flag) { return ::pctlIsPairingActive(flag); } +Result GetSynchronizationEvent(Event* out_event) { return ::pctlGetSynchronizationEvent(out_event); } +Result GetPlayTimerEventToRequestSuspension(Event* out_event) { return ::pctlGetPlayTimerEventToRequestSuspension(out_event); } +Result IsPlayTimerAlarmDisabled(bool *flag) { return ::pctlIsPlayTimerAlarmDisabled(flag); } +Result GetUnlinkedEvent(Event* out_event) { return ::pctlGetUnlinkedEvent(out_event); } + +} // namespace pctl + +namespace pctlauth { + +Result Show(bool flag) { return ::pctlauthShow(flag); } +Result ShowEx(u8 arg0, u8 arg1, u8 arg2) { return ::pctlauthShowEx(arg0, arg1, arg2); } +Result ShowForConfiguration(void) { return ::pctlauthShowForConfiguration(); } +Result RegisterPasscode(void) { return ::pctlauthRegisterPasscode(); } +Result ChangePasscode(void) { return ::pctlauthChangePasscode(); } + +} // namespace pctlauth + +namespace pcv { + +Result Initialize(void) { return ::pcvInitialize(); } +void Exit(void) { ::pcvExit(); } +Service* GetServiceSession(void) { return ::pcvGetServiceSession(); } +Result GetModuleId(PcvModuleId *module_id, PcvModule module) { return ::pcvGetModuleId(module_id, module); } +Result GetClockRate(PcvModule module, u32 *out_hz) { return ::pcvGetClockRate(module, out_hz); } +Result SetClockRate(PcvModule module, u32 hz) { return ::pcvSetClockRate(module, hz); } +Result SetVoltageEnabled(u32 power_domain, bool state) { return ::pcvSetVoltageEnabled(power_domain, state); } +Result GetVoltageEnabled(bool *isEnabled, u32 power_domain) { return ::pcvGetVoltageEnabled(isEnabled, power_domain); } +Result GetPossibleClockRates(PcvModule module, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count) { return ::pcvGetPossibleClockRates(module, rates, max_count, out_type, out_count); } + +} // namespace pcv + +namespace pdm { + +u64 PlayTimestampToPosix(u32 timestamp) { return ::pdmPlayTimestampToPosix(timestamp); } + +} // namespace pdm + +namespace pdmqry { + +Result Initialize(void) { return ::pdmqryInitialize(); } +void Exit(void) { ::pdmqryExit(); } +Service* GetServiceSession(void) { return ::pdmqryGetServiceSession(); } +Result QueryAppletEvent(s32 entry_index, bool flag, PdmAppletEvent *events, s32 count, s32 *total_out) { return ::pdmqryQueryAppletEvent(entry_index, flag, events, count, total_out); } +Result QueryPlayStatisticsByApplicationId(u64 application_id, bool flag, PdmPlayStatistics *stats) { return ::pdmqryQueryPlayStatisticsByApplicationId(application_id, flag, stats); } +Result QueryPlayStatisticsByApplicationIdAndUserAccountId(u64 application_id, AccountUid uid, bool flag, PdmPlayStatistics *stats) { return ::pdmqryQueryPlayStatisticsByApplicationIdAndUserAccountId(application_id, uid, flag, stats); } +Result QueryLastPlayTime(bool flag, PdmLastPlayTime *playtimes, const u64 *application_ids, s32 count, s32 *total_out) { return ::pdmqryQueryLastPlayTime(flag, playtimes, application_ids, count, total_out); } +Result QueryPlayEvent(s32 entry_index, PdmPlayEvent *events, s32 count, s32 *total_out) { return ::pdmqryQueryPlayEvent(entry_index, events, count, total_out); } +Result GetAvailablePlayEventRange(s32 *total_entries, s32 *start_entry_index, s32 *end_entry_index) { return ::pdmqryGetAvailablePlayEventRange(total_entries, start_entry_index, end_entry_index); } +Result QueryAccountEvent(s32 entry_index, PdmAccountEvent *events, s32 count, s32 *total_out) { return ::pdmqryQueryAccountEvent(entry_index, events, count, total_out); } +Result QueryAccountPlayEvent(s32 entry_index, AccountUid uid, PdmAccountPlayEvent *events, s32 count, s32 *total_out) { return ::pdmqryQueryAccountPlayEvent(entry_index, uid, events, count, total_out); } +Result GetAvailableAccountPlayEventRange(AccountUid uid, s32 *total_entries, s32 *start_entry_index, s32 *end_entry_index) { return ::pdmqryGetAvailableAccountPlayEventRange(uid, total_entries, start_entry_index, end_entry_index); } +Result QueryRecentlyPlayedApplication(AccountUid uid, bool flag, u64 *application_ids, s32 count, s32 *total_out) { return ::pdmqryQueryRecentlyPlayedApplication(uid, flag, application_ids, count, total_out); } +Result GetRecentlyPlayedApplicationUpdateEvent(Event* out_event) { return ::pdmqryGetRecentlyPlayedApplicationUpdateEvent(out_event); } + +} // namespace pdmqry + +namespace pgl { + +Result Initialize(void) { return ::pglInitialize(); } +void Exit(void) { ::pglExit(); } +Service* GetServiceSessionCmif(void) { return ::pglGetServiceSessionCmif(); } +TipcService* GetServiceSessionTipc(void) { return ::pglGetServiceSessionTipc(); } +Result LaunchProgram(u64 *out_pid, const NcmProgramLocation *loc, u32 pm_launch_flags, u8 pgl_launch_flags) { return ::pglLaunchProgram(out_pid, loc, pm_launch_flags, pgl_launch_flags); } +Result TerminateProcess(u64 pid) { return ::pglTerminateProcess(pid); } +Result LaunchProgramFromHost(u64 *out_pid, const char *content_path, u32 pm_launch_flags) { return ::pglLaunchProgramFromHost(out_pid, content_path, pm_launch_flags); } +Result GetHostProgramLaunchProperty(PglProgramLaunchProperty *out, const char *content_path) { return ::pglGetHostProgramLaunchProperty(out, content_path); } +Result GetRunningApplicationProcessId(u64 *out_pid) { return ::pglGetRunningApplicationProcessId(out_pid); } +Result BoostSystemMemoryResourceLimit(u64 size) { return ::pglBoostSystemMemoryResourceLimit(size); } +Result IsRunningProcess(bool *out, u64 pid) { return ::pglIsRunningProcess(out, pid); } +Result EnableApplicationCrashReport(bool en) { return ::pglEnableApplicationCrashReport(en); } +Result IsApplicationCrashReportEnabled(bool *out) { return ::pglIsApplicationCrashReportEnabled(out); } +Result EnableApplicationAllThreadDumpOnCrash(bool en) { return ::pglEnableApplicationAllThreadDumpOnCrash(en); } +Result GetProcessId(u64 *out_pid, u64 program_id) { return ::pglGetProcessId(out_pid, program_id); } +Result TriggerSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg) { return ::pglTriggerSnapShotDumper(dump_type, arg); } +Result CreateShellEvent(PglEventObserver *out) { return ::pglCreateShellEvent(out); } +Result EnableApplicationCrashReport2(u64 pid, bool en) { return ::pglEnableApplicationCrashReport2(pid, en); } +Result EventObserverGetShellEvent(PglEventObserver *observer, Event *out) { return ::pglEventObserverGetShellEvent(observer, out); } +Result EventObserverGetShellEventInfo(PglEventObserver *observer, PmProcessEventInfo *out) { return ::pglEventObserverGetShellEventInfo(observer, out); } +void EventObserverClose(PglEventObserver *observer) { ::pglEventObserverClose(observer); } + +} // namespace pgl + +namespace pl { + +Result Initialize(PlServiceType service_type) { return ::plInitialize(service_type); } +void Exit(void) { ::plExit(); } +Service* GetServiceSession(void) { return ::plGetServiceSession(); } +void* GetSharedmemAddr(void) { return ::plGetSharedmemAddr(); } +Result GetSharedFontByType(PlFontData* font, PlSharedFontType SharedFontType) { return ::plGetSharedFontByType(font, SharedFontType); } +Result GetSharedFont(u64 LanguageCode, PlFontData* fonts, s32 max_fonts, s32* total_fonts) { return ::plGetSharedFont(LanguageCode, fonts, max_fonts, total_fonts); } + +} // namespace pl + +namespace pmbm { + +Result Initialize(void) { return ::pmbmInitialize(); } +void Exit(void) { ::pmbmExit(); } +Service* GetServiceSession(void) { return ::pmbmGetServiceSession(); } +Result GetBootMode(PmBootMode *out) { return ::pmbmGetBootMode(out); } +Result SetMaintenanceBoot(void) { return ::pmbmSetMaintenanceBoot(); } + +} // namespace pmbm + +namespace pmdmnt { + +Result Initialize(void) { return ::pmdmntInitialize(); } +void Exit(void) { ::pmdmntExit(); } +Service* GetServiceSession(void) { return ::pmdmntGetServiceSession(); } +Result GetJitDebugProcessIdList(u32* out_count, u64* out_pids, size_t max_pids) { return ::pmdmntGetJitDebugProcessIdList(out_count, out_pids, max_pids); } +Result StartProcess(u64 pid) { return ::pmdmntStartProcess(pid); } +Result GetProcessId(u64* pid_out, u64 program_id) { return ::pmdmntGetProcessId(pid_out, program_id); } +Result HookToCreateProcess(Event* out, u64 program_id) { return ::pmdmntHookToCreateProcess(out, program_id); } +Result GetApplicationProcessId(u64* pid_out) { return ::pmdmntGetApplicationProcessId(pid_out); } +Result HookToCreateApplicationProcess(Event* out) { return ::pmdmntHookToCreateApplicationProcess(out); } +Result ClearHook(u32 which) { return ::pmdmntClearHook(which); } +Result GetProgramId(u64* program_id_out, u64 pid) { return ::pmdmntGetProgramId(program_id_out, pid); } + +} // namespace pmdmnt + +namespace pminfo { + +Result Initialize(void) { return ::pminfoInitialize(); } +void Exit(void) { ::pminfoExit(); } +Service* GetServiceSession(void) { return ::pminfoGetServiceSession(); } +Result GetProgramId(u64* program_id_out, u64 pid) { return ::pminfoGetProgramId(program_id_out, pid); } +Result GetAppletCurrentResourceLimitValues(PmResourceLimitValues* out) { return ::pminfoGetAppletCurrentResourceLimitValues(out); } +Result GetAppletPeakResourceLimitValues(PmResourceLimitValues* out) { return ::pminfoGetAppletPeakResourceLimitValues(out); } + +} // namespace pminfo + +namespace pmshell { + +Result Initialize(void) { return ::pmshellInitialize(); } +void Exit(void) { ::pmshellExit(); } +Service* GetServiceSession(void) { return ::pmshellGetServiceSession(); } +Result LaunchProgram(u32 launch_flags, const NcmProgramLocation *location, u64 *pid) { return ::pmshellLaunchProgram(launch_flags, location, pid); } +Result TerminateProcess(u64 processID) { return ::pmshellTerminateProcess(processID); } +Result TerminateProgram(u64 program_id) { return ::pmshellTerminateProgram(program_id); } +Result GetProcessEventHandle(Event* out) { return ::pmshellGetProcessEventHandle(out); } +Result GetProcessEventInfo(PmProcessEventInfo* out) { return ::pmshellGetProcessEventInfo(out); } +Result CleanupProcess(u64 pid) { return ::pmshellCleanupProcess(pid); } +Result ClearJitDebugOccured(u64 pid) { return ::pmshellClearJitDebugOccured(pid); } +Result NotifyBootFinished(void) { return ::pmshellNotifyBootFinished(); } +Result GetApplicationProcessIdForShell(u64* pid_out) { return ::pmshellGetApplicationProcessIdForShell(pid_out); } +Result BoostSystemMemoryResourceLimit(u64 boost_size) { return ::pmshellBoostSystemMemoryResourceLimit(boost_size); } +Result BoostApplicationThreadResourceLimit(void) { return ::pmshellBoostApplicationThreadResourceLimit(); } +Result BoostSystemThreadResourceLimit(void) { return ::pmshellBoostSystemThreadResourceLimit(); } +Result GetProcessId(u64* pid_out, u64 program_id) { return ::pmshellGetProcessId(pid_out, program_id); } + +} // namespace pmshell + +namespace psc { + +Result PmModuleGetRequest(PscPmModule *module, PscPmState *out_state, u32 *out_flags) { return ::pscPmModuleGetRequest(module, out_state, out_flags); } +Result PmModuleAcknowledge(PscPmModule *module, PscPmState state) { return ::pscPmModuleAcknowledge(module, state); } +Result PmModuleFinalize(PscPmModule *module) { return ::pscPmModuleFinalize(module); } +void PmModuleClose(PscPmModule *module) { ::pscPmModuleClose(module); } + +} // namespace psc + +namespace pscm { + +Result Initialize(void) { return ::pscmInitialize(); } +void Exit(void) { ::pscmExit(); } +Service* GetServiceSession(void) { return ::pscmGetServiceSession(); } +Result GetPmModule(PscPmModule *out, PscPmModuleId module_id, const u32 *dependencies, size_t dependency_count, bool autoclear) { return ::pscmGetPmModule(out, module_id, dependencies, dependency_count, autoclear); } + +} // namespace pscm + +namespace psel { + +Result UiCreate(PselUiSettings *ui, PselUiMode mode) { return ::pselUiCreate(ui, mode); } +void UiAddUser(PselUiSettings *ui, AccountUid user_id) { ::pselUiAddUser(ui, user_id); } +void UiSetAllowUserCreation(PselUiSettings *ui, bool flag) { ::pselUiSetAllowUserCreation(ui, flag); } +void UiSetNetworkServiceRequired(PselUiSettings *ui, bool flag) { ::pselUiSetNetworkServiceRequired(ui, flag); } +void UiSetSkipButtonEnabled(PselUiSettings *ui, bool flag) { ::pselUiSetSkipButtonEnabled(ui, flag); } +Result UiShow(PselUiSettings *ui, AccountUid *out_user) { return ::pselUiShow(ui, out_user); } +Result ShowUserSelectorForSystem(AccountUid *out_user, const PselUserSelectionSettings *settings, const PselUserSelectionSettingsForSystemService *settings_system) { return ::pselShowUserSelectorForSystem(out_user, settings, settings_system); } +Result ShowUserSelectorForLauncher(AccountUid *out_user, const PselUserSelectionSettings *settings, u64 application_id) { return ::pselShowUserSelectorForLauncher(out_user, settings, application_id); } +Result ShowUserSelector(AccountUid *out_user, const PselUserSelectionSettings *settings) { return ::pselShowUserSelector(out_user, settings); } +Result ShowUserCreator(void) { return ::pselShowUserCreator(); } +Result ShowUserIconEditor(AccountUid user) { return ::pselShowUserIconEditor(user); } +Result ShowUserNicknameEditor(AccountUid user) { return ::pselShowUserNicknameEditor(user); } +Result ShowUserCreatorForStarter(void) { return ::pselShowUserCreatorForStarter(); } +Result ShowNintendoAccountNnidLinker(AccountUid user) { return ::pselShowNintendoAccountNnidLinker(user); } +Result ShowUserQualificationPromoter(AccountUid user) { return ::pselShowUserQualificationPromoter(user); } + +} // namespace psel + +namespace psm { + +Result Initialize(void) { return ::psmInitialize(); } +void Exit(void) { ::psmExit(); } +Service* GetServiceSession(void) { return ::psmGetServiceSession(); } +Result GetBatteryChargePercentage(u32 *out) { return ::psmGetBatteryChargePercentage(out); } +Result GetChargerType(PsmChargerType *out) { return ::psmGetChargerType(out); } +Result EnableBatteryCharging(void) { return ::psmEnableBatteryCharging(); } +Result DisableBatteryCharging(void) { return ::psmDisableBatteryCharging(); } +Result IsBatteryChargingEnabled(bool *out) { return ::psmIsBatteryChargingEnabled(out); } +Result AcquireControllerPowerSupply(void) { return ::psmAcquireControllerPowerSupply(); } +Result ReleaseControllerPowerSupply(void) { return ::psmReleaseControllerPowerSupply(); } +Result EnableEnoughPowerChargeEmulation(void) { return ::psmEnableEnoughPowerChargeEmulation(); } +Result DisableEnoughPowerChargeEmulation(void) { return ::psmDisableEnoughPowerChargeEmulation(); } +Result EnableFastBatteryCharging(void) { return ::psmEnableFastBatteryCharging(); } +Result DisableFastBatteryCharging(void) { return ::psmDisableFastBatteryCharging(); } +Result GetBatteryVoltageState(PsmBatteryVoltageState *out) { return ::psmGetBatteryVoltageState(out); } +Result GetRawBatteryChargePercentage(double *out) { return ::psmGetRawBatteryChargePercentage(out); } +Result IsEnoughPowerSupplied(bool *out) { return ::psmIsEnoughPowerSupplied(out); } +Result GetBatteryAgePercentage(double *out) { return ::psmGetBatteryAgePercentage(out); } +Result GetBatteryChargeInfoEvent(Event* out_event, bool autoclear) { return ::psmGetBatteryChargeInfoEvent(out_event, autoclear); } +Result GetBatteryChargeInfoFields(PsmBatteryChargeInfoFields *out_fields) { return ::psmGetBatteryChargeInfoFields(out_fields); } +Result GetBatteryChargeCalibratedEvent(Event* out_event, bool autoclear) { return ::psmGetBatteryChargeCalibratedEvent(out_event, autoclear); } +Result BindStateChangeEvent(PsmSession* s, bool ChargerType, bool PowerSupply, bool BatteryVoltage) { return ::psmBindStateChangeEvent(s, ChargerType, PowerSupply, BatteryVoltage); } +Result WaitStateChangeEvent(PsmSession* s, u64 timeout) { return ::psmWaitStateChangeEvent(s, timeout); } +Result UnbindStateChangeEvent(PsmSession* s) { return ::psmUnbindStateChangeEvent(s); } + +} // namespace psm + +namespace random { + +void Get(void* buf, size_t len) { ::randomGet(buf, len); } +u64 Get64(void) { return ::randomGet64(); } + +} // namespace random + +namespace resolver { + +Result GetLastResult(void) { return ::resolverGetLastResult(); } +u32 GetCancelHandle(void) { return ::resolverGetCancelHandle(); } +bool GetEnableServiceDiscovery(void) { return ::resolverGetEnableServiceDiscovery(); } +bool GetEnableDnsCache(void) { return ::resolverGetEnableDnsCache(); } +void SetEnableServiceDiscovery(bool enable) { ::resolverSetEnableServiceDiscovery(enable); } +void SetEnableDnsCache(bool enable) { ::resolverSetEnableDnsCache(enable); } +Result Cancel(u32 handle) { return ::resolverCancel(handle); } +Result RemoveHostnameFromCache(const char* hostname) { return ::resolverRemoveHostnameFromCache(hostname); } +Result RemoveIpAddressFromCache(u32 ip) { return ::resolverRemoveIpAddressFromCache(ip); } + +} // namespace resolver + +namespace ringcon { + +Result Create(RingCon *c, HidNpadIdType id) { return ::ringconCreate(c, id); } +void Close(RingCon *c) { ::ringconClose(c); } +u32 GetErrorFlags(RingCon *c) { return ::ringconGetErrorFlags(c); } +bool GetErrorFlag(RingCon *c, RingConErrorFlag flag) { return ::ringconGetErrorFlag(c, flag); } +RingConFwVersion GetFwVersion(RingCon *c) { return ::ringconGetFwVersion(c); } +void GetId(RingCon *c, u64 *id_l, u64 *id_h) { ::ringconGetId(c, id_l, id_h); } +s16 GetUnkCal(RingCon *c) { return ::ringconGetUnkCal(c); } +s32 GetTotalPushCount(RingCon *c) { return ::ringconGetTotalPushCount(c); } +void GetManuCal(RingCon *c, RingConManuCal *out) { ::ringconGetManuCal(c, out); } +void GetUserCal(RingCon *c, RingConUserCal *out) { ::ringconGetUserCal(c, out); } +Result UpdateUserCal(RingCon *c, RingConUserCal cal) { return ::ringconUpdateUserCal(c, cal); } +Result ReadFwVersion(RingCon *c, RingConFwVersion *out) { return ::ringconReadFwVersion(c, out); } +Result ReadId(RingCon *c, u64 *id_l, u64 *id_h) { return ::ringconReadId(c, id_l, id_h); } +Result GetPollingData(RingCon *c, RingConPollingData *out, s32 count, s32 *total_out) { return ::ringconGetPollingData(c, out, count, total_out); } +Result Cmdx00020105(RingCon *c, u32 *out) { return ::ringconCmdx00020105(c, out); } +Result ReadManuCal(RingCon *c, RingConManuCal *out) { return ::ringconReadManuCal(c, out); } +Result ReadUnkCal(RingCon *c, s16 *out) { return ::ringconReadUnkCal(c, out); } +Result ReadUserCal(RingCon *c, RingConUserCal *out) { return ::ringconReadUserCal(c, out); } +Result ReadRepCount(RingCon *c, s32 *out, RingConDataValid *data_valid) { return ::ringconReadRepCount(c, out, data_valid); } +Result ReadTotalPushCount(RingCon *c, s32 *out, RingConDataValid *data_valid) { return ::ringconReadTotalPushCount(c, out, data_valid); } +Result ResetRepCount(RingCon *c) { return ::ringconResetRepCount(c); } +Result WriteUserCal(RingCon *c, RingConUserCal cal) { return ::ringconWriteUserCal(c, cal); } + +} // namespace ringcon + +namespace rmutex { + +void Init(RMutex* m) { ::rmutexInit(m); } +void Lock(RMutex* m) { ::rmutexLock(m); } +bool TryLock(RMutex* m) { return ::rmutexTryLock(m); } +void Unlock(RMutex* m) { ::rmutexUnlock(m); } + +} // namespace rmutex + +namespace ro { + +Result DmntInitialize(void) { return ::roDmntInitialize(); } +void DmntExit(void) { ::roDmntExit(); } +Service* DmntGetServiceSession(void) { return ::roDmntGetServiceSession(); } +Result DmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, s32 *num_out) { return ::roDmntGetProcessModuleInfo(pid, out_module_infos, max_out_modules, num_out); } + +} // namespace ro + +namespace ro1 { + +Result Initialize(void) { return ::ro1Initialize(); } +void Exit(void) { ::ro1Exit(); } +Service* GetServiceSession(void) { return ::ro1GetServiceSession(); } +Result LoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { return ::ro1LoadNro(out_address, nro_address, nro_size, bss_address, bss_size); } +Result UnloadNro(u64 nro_address) { return ::ro1UnloadNro(nro_address); } +Result LoadNrr(u64 nrr_address, u64 nrr_size) { return ::ro1LoadNrr(nrr_address, nrr_size); } +Result UnloadNrr(u64 nrr_address) { return ::ro1UnloadNrr(nrr_address); } +Result LoadNrrEx(u64 nrr_address, u64 nrr_size) { return ::ro1LoadNrrEx(nrr_address, nrr_size); } + +} // namespace ro1 + +namespace romfs { + +Result MountSelf(const char *name) { return ::romfsMountSelf(name); } +Result MountFromFile(FsFile file, u64 offset, const char *name) { return ::romfsMountFromFile(file, offset, name); } +Result MountFromStorage(FsStorage storage, u64 offset, const char *name) { return ::romfsMountFromStorage(storage, offset, name); } +Result MountFromCurrentProcess(const char *name) { return ::romfsMountFromCurrentProcess(name); } +Result MountDataStorageFromProgram(u64 program_id, const char *name) { return ::romfsMountDataStorageFromProgram(program_id, name); } +Result MountFromFsdev(const char *path, u64 offset, const char *name) { return ::romfsMountFromFsdev(path, offset, name); } +Result MountFromDataArchive(u64 dataId, NcmStorageId storageId, const char *name) { return ::romfsMountFromDataArchive(dataId, storageId, name); } +Result Unmount(const char *name) { return ::romfsUnmount(name); } +Result Init(void) { return ::romfsInit(); } +Result Exit(void) { return ::romfsExit(); } + +} // namespace romfs + +namespace rwlock { + +void Init(RwLock* r) { ::rwlockInit(r); } +void ReadLock(RwLock* r) { ::rwlockReadLock(r); } +bool TryReadLock(RwLock* r) { return ::rwlockTryReadLock(r); } +void ReadUnlock(RwLock* r) { ::rwlockReadUnlock(r); } +void WriteLock(RwLock* r) { ::rwlockWriteLock(r); } +bool TryWriteLock(RwLock* r) { return ::rwlockTryWriteLock(r); } +void WriteUnlock(RwLock* r) { ::rwlockWriteUnlock(r); } +bool IsWriteLockHeldByCurrentThread(RwLock* r) { return ::rwlockIsWriteLockHeldByCurrentThread(r); } +bool IsOwnedByCurrentThread(RwLock* r) { return ::rwlockIsOwnedByCurrentThread(r); } + +} // namespace rwlock + +namespace semaphore { + +void Init(Semaphore *s, u64 initial_count) { ::semaphoreInit(s, initial_count); } +void Signal(Semaphore *s) { ::semaphoreSignal(s); } +void Wait(Semaphore *s) { ::semaphoreWait(s); } +bool TryWait(Semaphore *s) { return ::semaphoreTryWait(s); } + +} // namespace semaphore + +namespace service { + +bool IsActive(Service* s) { return ::serviceIsActive(s); } +bool IsOverride(Service* s) { return ::serviceIsOverride(s); } +bool IsDomain(Service* s) { return ::serviceIsDomain(s); } +bool IsDomainSubservice(Service* s) { return ::serviceIsDomainSubservice(s); } +u32 GetObjectId(Service* s) { return ::serviceGetObjectId(s); } +void Create(Service* s, Handle h) { ::serviceCreate(s, h); } +void CreateNonDomainSubservice(Service* s, Service* parent, Handle h) { ::serviceCreateNonDomainSubservice(s, parent, h); } +void CreateDomainSubservice(Service* s, Service* parent, u32 object_id) { ::serviceCreateDomainSubservice(s, parent, object_id); } +void Close(Service* s) { ::serviceClose(s); } +Result Clone(Service* s, Service* out_s) { return ::serviceClone(s, out_s); } +Result CloneEx(Service* s, u32 tag, Service* out_s) { return ::serviceCloneEx(s, tag, out_s); } +Result ConvertToDomain(Service* s) { return ::serviceConvertToDomain(s); } +void RequestFormatProcessBuffer(CmifRequestFormat* fmt, u32 attr) { ::_serviceRequestFormatProcessBuffer(fmt, attr); } +void RequestProcessBuffer(CmifRequest* req, const SfBuffer* buf, u32 attr) { ::_serviceRequestProcessBuffer(req, buf, attr); } +void* MakeRequest(Service* s, u32 request_id, u32 context, u32 data_size, bool send_pid, const SfBufferAttrs buffer_attrs, const SfBuffer* buffers, u32 num_objects, const Service* const* objects, u32 num_handles, const Handle* handles) { return ::serviceMakeRequest(s, request_id, context, data_size, send_pid, buffer_attrs, buffers, num_objects, objects, num_handles, handles); } +void ResponseGetHandle(CmifResponse* res, SfOutHandleAttr type, Handle* out) { ::_serviceResponseGetHandle(res, type, out); } +Result ParseResponse(Service* s, u32 out_size, void** out_data, u32 num_out_objects, Service* out_objects, const SfOutHandleAttrs out_handle_attrs, Handle* out_handles) { return ::serviceParseResponse(s, out_size, out_data, num_out_objects, out_objects, out_handle_attrs, out_handles); } +Result DispatchImpl(Service* s, u32 request_id, const void* in_data, u32 in_data_size, void* out_data, u32 out_data_size, SfDispatchParams disp) { return ::serviceDispatchImpl(s, request_id, in_data, in_data_size, out_data, out_data_size, disp); } + +} // namespace service + +namespace sessionmgr { + +Result Create(SessionMgr* mgr, Handle root_session, u32 num_sessions) { return ::sessionmgrCreate(mgr, root_session, num_sessions); } +void Close(SessionMgr* mgr) { ::sessionmgrClose(mgr); } +int AttachClient(SessionMgr* mgr) { return ::sessionmgrAttachClient(mgr); } +void DetachClient(SessionMgr* mgr, int slot) { ::sessionmgrDetachClient(mgr, slot); } +Handle GetClientSession(SessionMgr* mgr, int slot) { return ::sessionmgrGetClientSession(mgr, slot); } + +} // namespace sessionmgr + +namespace set { + +Result Initialize(void) { return ::setInitialize(); } +void Exit(void) { ::setExit(); } +Service* GetServiceSession(void) { return ::setGetServiceSession(); } +Result MakeLanguage(u64 LanguageCode, SetLanguage *Language) { return ::setMakeLanguage(LanguageCode, Language); } +Result MakeLanguageCode(SetLanguage Language, u64 *LanguageCode) { return ::setMakeLanguageCode(Language, LanguageCode); } +Result GetSystemLanguage(u64 *LanguageCode) { return ::setGetSystemLanguage(LanguageCode); } +Result GetLanguageCode(u64 *LanguageCode) { return ::setGetLanguageCode(LanguageCode); } +Result GetAvailableLanguageCodes(s32 *total_entries, u64 *LanguageCodes, size_t max_entries) { return ::setGetAvailableLanguageCodes(total_entries, LanguageCodes, max_entries); } +Result GetAvailableLanguageCodeCount(s32 *total) { return ::setGetAvailableLanguageCodeCount(total); } +Result GetRegionCode(SetRegion *out) { return ::setGetRegionCode(out); } +Result GetQuestFlag(bool *out) { return ::setGetQuestFlag(out); } +Result GetDeviceNickname(SetSysDeviceNickName *nickname) { return ::setGetDeviceNickname(nickname); } + +} // namespace set + +namespace setcal { + +Result Initialize(void) { return ::setcalInitialize(); } +void Exit(void) { ::setcalExit(); } +Service* GetServiceSession(void) { return ::setcalGetServiceSession(); } +Result GetBdAddress(SetCalBdAddress *out) { return ::setcalGetBdAddress(out); } +Result GetConfigurationId1(SetCalConfigurationId1 *out) { return ::setcalGetConfigurationId1(out); } +Result GetAccelerometerOffset(SetCalAccelerometerOffset *out) { return ::setcalGetAccelerometerOffset(out); } +Result GetAccelerometerScale(SetCalAccelerometerScale *out) { return ::setcalGetAccelerometerScale(out); } +Result GetGyroscopeOffset(SetCalGyroscopeOffset *out) { return ::setcalGetGyroscopeOffset(out); } +Result GetGyroscopeScale(SetCalGyroscopeScale *out) { return ::setcalGetGyroscopeScale(out); } +Result GetWirelessLanMacAddress(SetCalMacAddress *out) { return ::setcalGetWirelessLanMacAddress(out); } +Result GetWirelessLanCountryCodeCount(s32 *out_count) { return ::setcalGetWirelessLanCountryCodeCount(out_count); } +Result GetWirelessLanCountryCodes(s32 *total_out, SetCalCountryCode *codes, s32 count) { return ::setcalGetWirelessLanCountryCodes(total_out, codes, count); } +Result GetSerialNumber(SetCalSerialNumber *out) { return ::setcalGetSerialNumber(out); } +Result SetInitialSystemAppletProgramId(u64 program_id) { return ::setcalSetInitialSystemAppletProgramId(program_id); } +Result SetOverlayDispProgramId(u64 program_id) { return ::setcalSetOverlayDispProgramId(program_id); } +Result GetBatteryLot(SetBatteryLot *out) { return ::setcalGetBatteryLot(out); } +Result GetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out) { return ::setcalGetEciDeviceCertificate(out); } +Result GetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out) { return ::setcalGetEticketDeviceCertificate(out); } +Result GetSslKey(SetCalSslKey *out) { return ::setcalGetSslKey(out); } +Result GetSslCertificate(SetCalSslCertificate *out) { return ::setcalGetSslCertificate(out); } +Result GetGameCardKey(SetCalGameCardKey *out) { return ::setcalGetGameCardKey(out); } +Result GetGameCardCertificate(SetCalGameCardCertificate *out) { return ::setcalGetGameCardCertificate(out); } +Result GetEciDeviceKey(SetCalEccB233DeviceKey *out) { return ::setcalGetEciDeviceKey(out); } +Result GetEticketDeviceKey(SetCalRsa2048DeviceKey *out) { return ::setcalGetEticketDeviceKey(out); } +Result GetSpeakerParameter(SetCalSpeakerParameter *out) { return ::setcalGetSpeakerParameter(out); } +Result GetLcdVendorId(u32 *out_vendor_id) { return ::setcalGetLcdVendorId(out_vendor_id); } +Result GetEciDeviceCertificate2(SetCalRsa2048DeviceCertificate *out) { return ::setcalGetEciDeviceCertificate2(out); } +Result GetEciDeviceKey2(SetCalRsa2048DeviceKey *out) { return ::setcalGetEciDeviceKey2(out); } +Result GetAmiiboKey(SetCalAmiiboKey *out) { return ::setcalGetAmiiboKey(out); } +Result GetAmiiboEcqvCertificate(SetCalAmiiboEcqvCertificate *out) { return ::setcalGetAmiiboEcqvCertificate(out); } +Result GetAmiiboEcdsaCertificate(SetCalAmiiboEcdsaCertificate *out) { return ::setcalGetAmiiboEcdsaCertificate(out); } +Result GetAmiiboEcqvBlsKey(SetCalAmiiboEcqvBlsKey *out) { return ::setcalGetAmiiboEcqvBlsKey(out); } +Result GetAmiiboEcqvBlsCertificate(SetCalAmiiboEcqvBlsCertificate *out) { return ::setcalGetAmiiboEcqvBlsCertificate(out); } +Result GetAmiiboEcqvBlsRootCertificate(SetCalAmiiboEcqvBlsRootCertificate *out) { return ::setcalGetAmiiboEcqvBlsRootCertificate(out); } +Result GetUsbTypeCPowerSourceCircuitVersion(u8 *out_version) { return ::setcalGetUsbTypeCPowerSourceCircuitVersion(out_version); } +Result GetAnalogStickModuleTypeL(u8 *out_type) { return ::setcalGetAnalogStickModuleTypeL(out_type); } +Result GetAnalogStickModelParameterL(SetCalAnalogStickModelParameter *out) { return ::setcalGetAnalogStickModelParameterL(out); } +Result GetAnalogStickFactoryCalibrationL(SetCalAnalogStickFactoryCalibration *out) { return ::setcalGetAnalogStickFactoryCalibrationL(out); } +Result GetAnalogStickModuleTypeR(u8 *out_type) { return ::setcalGetAnalogStickModuleTypeR(out_type); } +Result GetAnalogStickModelParameterR(SetCalAnalogStickModelParameter *out) { return ::setcalGetAnalogStickModelParameterR(out); } +Result GetAnalogStickFactoryCalibrationR(SetCalAnalogStickFactoryCalibration *out) { return ::setcalGetAnalogStickFactoryCalibrationR(out); } +Result GetConsoleSixAxisSensorModuleType(u8 *out_type) { return ::setcalGetConsoleSixAxisSensorModuleType(out_type); } +Result GetConsoleSixAxisSensorHorizontalOffset(SetCalConsoleSixAxisSensorHorizontalOffset *out) { return ::setcalGetConsoleSixAxisSensorHorizontalOffset(out); } +Result GetBatteryVersion(u8 *out_version) { return ::setcalGetBatteryVersion(out_version); } +Result GetDeviceId(u64 *out_device_id) { return ::setcalGetDeviceId(out_device_id); } +Result GetConsoleSixAxisSensorMountType(u8 *out_type) { return ::setcalGetConsoleSixAxisSensorMountType(out_type); } + +} // namespace setcal + +namespace setfd { + +Result Initialize(void) { return ::setfdInitialize(); } +void Exit(void) { ::setfdExit(); } +Service* GetServiceSession(void) { return ::setfdGetServiceSession(); } +Result SetSettingsItemValue(const char *name, const char *item_key, const void *value_in, s64 value_in_size) { return ::setfdSetSettingsItemValue(name, item_key, value_in, value_in_size); } +Result ResetSettingsItemValue(const char *name, const char *item_key) { return ::setfdResetSettingsItemValue(name, item_key); } + +} // namespace setfd + +namespace setsys { + +Result Initialize(void) { return ::setsysInitialize(); } +void Exit(void) { ::setsysExit(); } +Service* GetServiceSession(void) { return ::setsysGetServiceSession(); } +Result SetLanguageCode(u64 LanguageCode) { return ::setsysSetLanguageCode(LanguageCode); } +Result SetNetworkSettings(const SetSysNetworkSettings *settings, s32 count) { return ::setsysSetNetworkSettings(settings, count); } +Result GetNetworkSettings(s32 *total_out, SetSysNetworkSettings *settings, s32 count) { return ::setsysGetNetworkSettings(total_out, settings, count); } +Result GetFirmwareVersion(SetSysFirmwareVersion *out) { return ::setsysGetFirmwareVersion(out); } +Result GetFirmwareVersionDigest(SetSysFirmwareVersionDigest *out) { return ::setsysGetFirmwareVersionDigest(out); } +Result GetLockScreenFlag(bool *out) { return ::setsysGetLockScreenFlag(out); } +Result SetLockScreenFlag(bool flag) { return ::setsysSetLockScreenFlag(flag); } +Result GetBacklightSettings(SetSysBacklightSettings *out) { return ::setsysGetBacklightSettings(out); } +Result SetBacklightSettings(const SetSysBacklightSettings *settings) { return ::setsysSetBacklightSettings(settings); } +Result SetBluetoothDevicesSettings(const SetSysBluetoothDevicesSettings *settings, s32 count) { return ::setsysSetBluetoothDevicesSettings(settings, count); } +Result GetBluetoothDevicesSettings(s32 *total_out, SetSysBluetoothDevicesSettings *settings, s32 count) { return ::setsysGetBluetoothDevicesSettings(total_out, settings, count); } +Result GetExternalSteadyClockSourceId(Uuid *out) { return ::setsysGetExternalSteadyClockSourceId(out); } +Result SetExternalSteadyClockSourceId(const Uuid *uuid) { return ::setsysSetExternalSteadyClockSourceId(uuid); } +Result GetUserSystemClockContext(TimeSystemClockContext *out) { return ::setsysGetUserSystemClockContext(out); } +Result SetUserSystemClockContext(const TimeSystemClockContext *context) { return ::setsysSetUserSystemClockContext(context); } +Result GetAccountSettings(SetSysAccountSettings *out) { return ::setsysGetAccountSettings(out); } +Result SetAccountSettings(SetSysAccountSettings settings) { return ::setsysSetAccountSettings(settings); } +Result GetAudioVolume(SetSysAudioDevice device, SetSysAudioVolume *out) { return ::setsysGetAudioVolume(device, out); } +Result SetAudioVolume(SetSysAudioDevice device, const SetSysAudioVolume *volume) { return ::setsysSetAudioVolume(device, volume); } +Result GetEulaVersions(s32 *total_out, SetSysEulaVersion *versions, s32 count) { return ::setsysGetEulaVersions(total_out, versions, count); } +Result SetEulaVersions(const SetSysEulaVersion *versions, s32 count) { return ::setsysSetEulaVersions(versions, count); } +Result GetColorSetId(ColorSetId *out) { return ::setsysGetColorSetId(out); } +Result SetColorSetId(ColorSetId id) { return ::setsysSetColorSetId(id); } +Result GetConsoleInformationUploadFlag(bool *out) { return ::setsysGetConsoleInformationUploadFlag(out); } +Result SetConsoleInformationUploadFlag(bool flag) { return ::setsysSetConsoleInformationUploadFlag(flag); } +Result GetAutomaticApplicationDownloadFlag(bool *out) { return ::setsysGetAutomaticApplicationDownloadFlag(out); } +Result SetAutomaticApplicationDownloadFlag(bool flag) { return ::setsysSetAutomaticApplicationDownloadFlag(flag); } +Result GetNotificationSettings(SetSysNotificationSettings *out) { return ::setsysGetNotificationSettings(out); } +Result SetNotificationSettings(const SetSysNotificationSettings *settings) { return ::setsysSetNotificationSettings(settings); } +Result GetAccountNotificationSettings(s32 *total_out, SetSysAccountNotificationSettings *settings, s32 count) { return ::setsysGetAccountNotificationSettings(total_out, settings, count); } +Result SetAccountNotificationSettings(const SetSysAccountNotificationSettings *settings, s32 count) { return ::setsysSetAccountNotificationSettings(settings, count); } +Result GetVibrationMasterVolume(float *out) { return ::setsysGetVibrationMasterVolume(out); } +Result SetVibrationMasterVolume(float volume) { return ::setsysSetVibrationMasterVolume(volume); } +Result GetSettingsItemValueSize(const char *name, const char *item_key, u64 *size_out) { return ::setsysGetSettingsItemValueSize(name, item_key, size_out); } +Result GetSettingsItemValue(const char *name, const char *item_key, void *value_out, size_t value_out_size, u64 *size_out) { return ::setsysGetSettingsItemValue(name, item_key, value_out, value_out_size, size_out); } +Result GetTvSettings(SetSysTvSettings *out) { return ::setsysGetTvSettings(out); } +Result SetTvSettings(const SetSysTvSettings *settings) { return ::setsysSetTvSettings(settings); } +Result GetEdid(SetSysEdid *out) { return ::setsysGetEdid(out); } +Result SetEdid(const SetSysEdid *edid) { return ::setsysSetEdid(edid); } +Result GetAudioOutputMode(SetSysAudioOutputModeTarget target, SetSysAudioOutputMode *out) { return ::setsysGetAudioOutputMode(target, out); } +Result SetAudioOutputMode(SetSysAudioOutputModeTarget target, SetSysAudioOutputMode mode) { return ::setsysSetAudioOutputMode(target, mode); } +Result GetSpeakerAutoMuteFlag(bool *out) { return ::setsysGetSpeakerAutoMuteFlag(out); } +Result SetSpeakerAutoMuteFlag(bool flag) { return ::setsysSetSpeakerAutoMuteFlag(flag); } +Result GetQuestFlag(bool *out) { return ::setsysGetQuestFlag(out); } +Result SetQuestFlag(bool flag) { return ::setsysSetQuestFlag(flag); } +Result GetDataDeletionSettings(SetSysDataDeletionSettings *out) { return ::setsysGetDataDeletionSettings(out); } +Result SetDataDeletionSettings(const SetSysDataDeletionSettings *settings) { return ::setsysSetDataDeletionSettings(settings); } +Result GetInitialSystemAppletProgramId(u64 *out) { return ::setsysGetInitialSystemAppletProgramId(out); } +Result GetOverlayDispProgramId(u64 *out) { return ::setsysGetOverlayDispProgramId(out); } +Result GetDeviceTimeZoneLocationName(TimeLocationName *out) { return ::setsysGetDeviceTimeZoneLocationName(out); } +Result SetDeviceTimeZoneLocationName(const TimeLocationName *name) { return ::setsysSetDeviceTimeZoneLocationName(name); } +Result GetWirelessCertificationFileSize(u64 *out_size) { return ::setsysGetWirelessCertificationFileSize(out_size); } +Result GetWirelessCertificationFile(void* buffer, size_t size, u64 *out_size) { return ::setsysGetWirelessCertificationFile(buffer, size, out_size); } +Result SetRegionCode(SetRegion region) { return ::setsysSetRegionCode(region); } +Result GetNetworkSystemClockContext(TimeSystemClockContext *out) { return ::setsysGetNetworkSystemClockContext(out); } +Result SetNetworkSystemClockContext(const TimeSystemClockContext *context) { return ::setsysSetNetworkSystemClockContext(context); } +Result IsUserSystemClockAutomaticCorrectionEnabled(bool *out) { return ::setsysIsUserSystemClockAutomaticCorrectionEnabled(out); } +Result SetUserSystemClockAutomaticCorrectionEnabled(bool flag) { return ::setsysSetUserSystemClockAutomaticCorrectionEnabled(flag); } +Result GetDebugModeFlag(bool *out) { return ::setsysGetDebugModeFlag(out); } +Result GetPrimaryAlbumStorage(SetSysPrimaryAlbumStorage *out) { return ::setsysGetPrimaryAlbumStorage(out); } +Result SetPrimaryAlbumStorage(SetSysPrimaryAlbumStorage storage) { return ::setsysSetPrimaryAlbumStorage(storage); } +Result GetUsb30EnableFlag(bool *out) { return ::setsysGetUsb30EnableFlag(out); } +Result SetUsb30EnableFlag(bool flag) { return ::setsysSetUsb30EnableFlag(flag); } +Result GetBatteryLot(SetBatteryLot *out) { return ::setsysGetBatteryLot(out); } +Result GetSerialNumber(SetSysSerialNumber *out) { return ::setsysGetSerialNumber(out); } +Result GetNfcEnableFlag(bool *out) { return ::setsysGetNfcEnableFlag(out); } +Result SetNfcEnableFlag(bool flag) { return ::setsysSetNfcEnableFlag(flag); } +Result GetSleepSettings(SetSysSleepSettings *out) { return ::setsysGetSleepSettings(out); } +Result SetSleepSettings(const SetSysSleepSettings *settings) { return ::setsysSetSleepSettings(settings); } +Result GetWirelessLanEnableFlag(bool *out) { return ::setsysGetWirelessLanEnableFlag(out); } +Result SetWirelessLanEnableFlag(bool flag) { return ::setsysSetWirelessLanEnableFlag(flag); } +Result GetInitialLaunchSettings(SetSysInitialLaunchSettings *out) { return ::setsysGetInitialLaunchSettings(out); } +Result SetInitialLaunchSettings(const SetSysInitialLaunchSettings *settings) { return ::setsysSetInitialLaunchSettings(settings); } +Result GetDeviceNickname(SetSysDeviceNickName *nickname) { return ::setsysGetDeviceNickname(nickname); } +Result SetDeviceNickname(const SetSysDeviceNickName *nickname) { return ::setsysSetDeviceNickname(nickname); } +Result GetProductModel(SetSysProductModel *model) { return ::setsysGetProductModel(model); } +Result GetLdnChannel(s32 *out) { return ::setsysGetLdnChannel(out); } +Result SetLdnChannel(s32 channel) { return ::setsysSetLdnChannel(channel); } +Result AcquireTelemetryDirtyFlagEventHandle(Event *out_event) { return ::setsysAcquireTelemetryDirtyFlagEventHandle(out_event); } +Result GetTelemetryDirtyFlags(u64 *flags_0, u64 *flags_1) { return ::setsysGetTelemetryDirtyFlags(flags_0, flags_1); } +Result GetPtmBatteryLot(SetBatteryLot *out) { return ::setsysGetPtmBatteryLot(out); } +Result SetPtmBatteryLot(const SetBatteryLot *lot) { return ::setsysSetPtmBatteryLot(lot); } +Result GetPtmFuelGaugeParameter(SetSysPtmFuelGaugeParameter *out) { return ::setsysGetPtmFuelGaugeParameter(out); } +Result SetPtmFuelGaugeParameter(const SetSysPtmFuelGaugeParameter *parameter) { return ::setsysSetPtmFuelGaugeParameter(parameter); } +Result GetBluetoothEnableFlag(bool *out) { return ::setsysGetBluetoothEnableFlag(out); } +Result SetBluetoothEnableFlag(bool flag) { return ::setsysSetBluetoothEnableFlag(flag); } +Result GetMiiAuthorId(Uuid *out) { return ::setsysGetMiiAuthorId(out); } +Result SetShutdownRtcValue(u64 value) { return ::setsysSetShutdownRtcValue(value); } +Result GetShutdownRtcValue(u64 *out) { return ::setsysGetShutdownRtcValue(out); } +Result AcquireFatalDirtyFlagEventHandle(Event *out_event) { return ::setsysAcquireFatalDirtyFlagEventHandle(out_event); } +Result GetFatalDirtyFlags(u64 *flags_0, u64 *flags_1) { return ::setsysGetFatalDirtyFlags(flags_0, flags_1); } +Result GetAutoUpdateEnableFlag(bool *out) { return ::setsysGetAutoUpdateEnableFlag(out); } +Result SetAutoUpdateEnableFlag(bool flag) { return ::setsysSetAutoUpdateEnableFlag(flag); } +Result GetNxControllerSettings(s32 *total_out, SetSysNxControllerLegacySettings *settings, s32 count) { return ::setsysGetNxControllerSettings(total_out, settings, count); } +Result SetNxControllerSettings(const SetSysNxControllerLegacySettings *settings, s32 count) { return ::setsysSetNxControllerSettings(settings, count); } +Result GetBatteryPercentageFlag(bool *out) { return ::setsysGetBatteryPercentageFlag(out); } +Result SetBatteryPercentageFlag(bool flag) { return ::setsysSetBatteryPercentageFlag(flag); } +Result GetExternalRtcResetFlag(bool *out) { return ::setsysGetExternalRtcResetFlag(out); } +Result SetExternalRtcResetFlag(bool flag) { return ::setsysSetExternalRtcResetFlag(flag); } +Result GetUsbFullKeyEnableFlag(bool *out) { return ::setsysGetUsbFullKeyEnableFlag(out); } +Result SetUsbFullKeyEnableFlag(bool flag) { return ::setsysSetUsbFullKeyEnableFlag(flag); } +Result SetExternalSteadyClockInternalOffset(u64 offset) { return ::setsysSetExternalSteadyClockInternalOffset(offset); } +Result GetExternalSteadyClockInternalOffset(u64 *out) { return ::setsysGetExternalSteadyClockInternalOffset(out); } +Result GetBacklightSettingsEx(SetSysBacklightSettingsEx *out) { return ::setsysGetBacklightSettingsEx(out); } +Result SetBacklightSettingsEx(const SetSysBacklightSettingsEx *settings) { return ::setsysSetBacklightSettingsEx(settings); } +Result GetHeadphoneVolumeWarningCount(u32 *out) { return ::setsysGetHeadphoneVolumeWarningCount(out); } +Result SetHeadphoneVolumeWarningCount(u32 count) { return ::setsysSetHeadphoneVolumeWarningCount(count); } +Result GetBluetoothAfhEnableFlag(bool *out) { return ::setsysGetBluetoothAfhEnableFlag(out); } +Result SetBluetoothAfhEnableFlag(bool flag) { return ::setsysSetBluetoothAfhEnableFlag(flag); } +Result GetBluetoothBoostEnableFlag(bool *out) { return ::setsysGetBluetoothBoostEnableFlag(out); } +Result SetBluetoothBoostEnableFlag(bool flag) { return ::setsysSetBluetoothBoostEnableFlag(flag); } +Result GetInRepairProcessEnableFlag(bool *out) { return ::setsysGetInRepairProcessEnableFlag(out); } +Result SetInRepairProcessEnableFlag(bool flag) { return ::setsysSetInRepairProcessEnableFlag(flag); } +Result GetHeadphoneVolumeUpdateFlag(bool *out) { return ::setsysGetHeadphoneVolumeUpdateFlag(out); } +Result SetHeadphoneVolumeUpdateFlag(bool flag) { return ::setsysSetHeadphoneVolumeUpdateFlag(flag); } +Result NeedsToUpdateHeadphoneVolume(u8 *a0, u8 *a1, u8 *a2, bool flag) { return ::setsysNeedsToUpdateHeadphoneVolume(a0, a1, a2, flag); } +Result GetPushNotificationActivityModeOnSleep(u32 *out) { return ::setsysGetPushNotificationActivityModeOnSleep(out); } +Result SetPushNotificationActivityModeOnSleep(u32 mode) { return ::setsysSetPushNotificationActivityModeOnSleep(mode); } +Result GetServiceDiscoveryControlSettings(SetSysServiceDiscoveryControlSettings *out) { return ::setsysGetServiceDiscoveryControlSettings(out); } +Result SetServiceDiscoveryControlSettings(SetSysServiceDiscoveryControlSettings settings) { return ::setsysSetServiceDiscoveryControlSettings(settings); } +Result GetErrorReportSharePermission(SetSysErrorReportSharePermission *out) { return ::setsysGetErrorReportSharePermission(out); } +Result SetErrorReportSharePermission(SetSysErrorReportSharePermission permission) { return ::setsysSetErrorReportSharePermission(permission); } +Result GetAppletLaunchFlags(u32 *out) { return ::setsysGetAppletLaunchFlags(out); } +Result SetAppletLaunchFlags(u32 flags) { return ::setsysSetAppletLaunchFlags(flags); } +Result GetConsoleSixAxisSensorAccelerationBias(SetSysConsoleSixAxisSensorAccelerationBias *out) { return ::setsysGetConsoleSixAxisSensorAccelerationBias(out); } +Result SetConsoleSixAxisSensorAccelerationBias(const SetSysConsoleSixAxisSensorAccelerationBias *bias) { return ::setsysSetConsoleSixAxisSensorAccelerationBias(bias); } +Result GetConsoleSixAxisSensorAngularVelocityBias(SetSysConsoleSixAxisSensorAngularVelocityBias *out) { return ::setsysGetConsoleSixAxisSensorAngularVelocityBias(out); } +Result SetConsoleSixAxisSensorAngularVelocityBias(const SetSysConsoleSixAxisSensorAngularVelocityBias *bias) { return ::setsysSetConsoleSixAxisSensorAngularVelocityBias(bias); } +Result GetConsoleSixAxisSensorAccelerationGain(SetSysConsoleSixAxisSensorAccelerationGain *out) { return ::setsysGetConsoleSixAxisSensorAccelerationGain(out); } +Result SetConsoleSixAxisSensorAccelerationGain(const SetSysConsoleSixAxisSensorAccelerationGain *gain) { return ::setsysSetConsoleSixAxisSensorAccelerationGain(gain); } +Result GetConsoleSixAxisSensorAngularVelocityGain(SetSysConsoleSixAxisSensorAngularVelocityGain *out) { return ::setsysGetConsoleSixAxisSensorAngularVelocityGain(out); } +Result SetConsoleSixAxisSensorAngularVelocityGain(const SetSysConsoleSixAxisSensorAngularVelocityGain *gain) { return ::setsysSetConsoleSixAxisSensorAngularVelocityGain(gain); } +Result GetKeyboardLayout(::SetKeyboardLayout *out) { return ::setsysGetKeyboardLayout(out); } +Result SetKeyboardLayout(::SetKeyboardLayout layout) { return ::setsysSetKeyboardLayout(layout); } +Result GetWebInspectorFlag(bool *out) { return ::setsysGetWebInspectorFlag(out); } +Result GetAllowedSslHosts(s32 *total_out, SetSysAllowedSslHosts *out, s32 count) { return ::setsysGetAllowedSslHosts(total_out, out, count); } +Result GetHostFsMountPoint(SetSysHostFsMountPoint *out) { return ::setsysGetHostFsMountPoint(out); } +Result GetRequiresRunRepairTimeReviser(bool *out) { return ::setsysGetRequiresRunRepairTimeReviser(out); } +Result SetRequiresRunRepairTimeReviser(bool flag) { return ::setsysSetRequiresRunRepairTimeReviser(flag); } +Result SetBlePairingSettings(const SetSysBlePairingSettings *settings, s32 count) { return ::setsysSetBlePairingSettings(settings, count); } +Result GetBlePairingSettings(s32 *total_out, SetSysBlePairingSettings *settings, s32 count) { return ::setsysGetBlePairingSettings(total_out, settings, count); } +Result GetConsoleSixAxisSensorAngularVelocityTimeBias(SetSysConsoleSixAxisSensorAngularVelocityTimeBias *out) { return ::setsysGetConsoleSixAxisSensorAngularVelocityTimeBias(out); } +Result SetConsoleSixAxisSensorAngularVelocityTimeBias(const SetSysConsoleSixAxisSensorAngularVelocityTimeBias *bias) { return ::setsysSetConsoleSixAxisSensorAngularVelocityTimeBias(bias); } +Result GetConsoleSixAxisSensorAngularAcceleration(SetSysConsoleSixAxisSensorAngularAcceleration *out) { return ::setsysGetConsoleSixAxisSensorAngularAcceleration(out); } +Result SetConsoleSixAxisSensorAngularAcceleration(const SetSysConsoleSixAxisSensorAngularAcceleration *acceleration) { return ::setsysSetConsoleSixAxisSensorAngularAcceleration(acceleration); } +Result GetRebootlessSystemUpdateVersion(SetSysRebootlessSystemUpdateVersion *out) { return ::setsysGetRebootlessSystemUpdateVersion(out); } +Result GetDeviceTimeZoneLocationUpdatedTime(TimeSteadyClockTimePoint *out) { return ::setsysGetDeviceTimeZoneLocationUpdatedTime(out); } +Result SetDeviceTimeZoneLocationUpdatedTime(const TimeSteadyClockTimePoint *time_point) { return ::setsysSetDeviceTimeZoneLocationUpdatedTime(time_point); } +Result GetUserSystemClockAutomaticCorrectionUpdatedTime(TimeSteadyClockTimePoint *out) { return ::setsysGetUserSystemClockAutomaticCorrectionUpdatedTime(out); } +Result SetUserSystemClockAutomaticCorrectionUpdatedTime(const TimeSteadyClockTimePoint *time_point) { return ::setsysSetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); } +Result GetAccountOnlineStorageSettings(s32 *total_out, SetSysAccountOnlineStorageSettings *settings, s32 count) { return ::setsysGetAccountOnlineStorageSettings(total_out, settings, count); } +Result SetAccountOnlineStorageSettings(const SetSysAccountOnlineStorageSettings *settings, s32 count) { return ::setsysSetAccountOnlineStorageSettings(settings, count); } +Result GetPctlReadyFlag(bool *out) { return ::setsysGetPctlReadyFlag(out); } +Result SetPctlReadyFlag(bool flag) { return ::setsysSetPctlReadyFlag(flag); } +Result GetAnalogStickUserCalibrationL(SetSysAnalogStickUserCalibration *out) { return ::setsysGetAnalogStickUserCalibrationL(out); } +Result SetAnalogStickUserCalibrationL(const SetSysAnalogStickUserCalibration *calibration) { return ::setsysSetAnalogStickUserCalibrationL(calibration); } +Result GetAnalogStickUserCalibrationR(SetSysAnalogStickUserCalibration *out) { return ::setsysGetAnalogStickUserCalibrationR(out); } +Result SetAnalogStickUserCalibrationR(const SetSysAnalogStickUserCalibration *calibration) { return ::setsysSetAnalogStickUserCalibrationR(calibration); } +Result GetPtmBatteryVersion(u8 *out) { return ::setsysGetPtmBatteryVersion(out); } +Result SetPtmBatteryVersion(u8 version) { return ::setsysSetPtmBatteryVersion(version); } +Result GetUsb30HostEnableFlag(bool *out) { return ::setsysGetUsb30HostEnableFlag(out); } +Result SetUsb30HostEnableFlag(bool flag) { return ::setsysSetUsb30HostEnableFlag(flag); } +Result GetUsb30DeviceEnableFlag(bool *out) { return ::setsysGetUsb30DeviceEnableFlag(out); } +Result SetUsb30DeviceEnableFlag(bool flag) { return ::setsysSetUsb30DeviceEnableFlag(flag); } +Result GetThemeId(s32 type, SetSysThemeId *out) { return ::setsysGetThemeId(type, out); } +Result SetThemeId(s32 type, const SetSysThemeId *theme_id) { return ::setsysSetThemeId(type, theme_id); } +Result GetChineseTraditionalInputMethod(::SetChineseTraditionalInputMethod *out) { return ::setsysGetChineseTraditionalInputMethod(out); } +Result SetChineseTraditionalInputMethod(::SetChineseTraditionalInputMethod method) { return ::setsysSetChineseTraditionalInputMethod(method); } +Result GetPtmCycleCountReliability(SetSysPtmCycleCountReliability *out) { return ::setsysGetPtmCycleCountReliability(out); } +Result SetPtmCycleCountReliability(SetSysPtmCycleCountReliability reliability) { return ::setsysSetPtmCycleCountReliability(reliability); } +Result GetHomeMenuScheme(SetSysHomeMenuScheme *out) { return ::setsysGetHomeMenuScheme(out); } +Result GetThemeSettings(SetSysThemeSettings *out) { return ::setsysGetThemeSettings(out); } +Result SetThemeSettings(const SetSysThemeSettings *settings) { return ::setsysSetThemeSettings(settings); } +Result GetThemeKey(FsArchiveMacKey *out) { return ::setsysGetThemeKey(out); } +Result SetThemeKey(const FsArchiveMacKey *key) { return ::setsysSetThemeKey(key); } +Result GetZoomFlag(bool *out) { return ::setsysGetZoomFlag(out); } +Result SetZoomFlag(bool flag) { return ::setsysSetZoomFlag(flag); } +Result GetT(bool *out) { return ::setsysGetT(out); } +Result SetT(bool flag) { return ::setsysSetT(flag); } +Result GetPlatformRegion(SetSysPlatformRegion *out) { return ::setsysGetPlatformRegion(out); } +Result SetPlatformRegion(SetSysPlatformRegion region) { return ::setsysSetPlatformRegion(region); } +Result GetHomeMenuSchemeModel(u32 *out) { return ::setsysGetHomeMenuSchemeModel(out); } +Result GetMemoryUsageRateFlag(bool *out) { return ::setsysGetMemoryUsageRateFlag(out); } +Result GetTouchScreenMode(SetSysTouchScreenMode *out) { return ::setsysGetTouchScreenMode(out); } +Result SetTouchScreenMode(SetSysTouchScreenMode mode) { return ::setsysSetTouchScreenMode(mode); } +Result GetButtonConfigSettingsFull(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) { return ::setsysGetButtonConfigSettingsFull(total_out, settings, count); } +Result SetButtonConfigSettingsFull(const SetSysButtonConfigSettings *settings, s32 count) { return ::setsysSetButtonConfigSettingsFull(settings, count); } +Result GetButtonConfigSettingsEmbedded(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) { return ::setsysGetButtonConfigSettingsEmbedded(total_out, settings, count); } +Result SetButtonConfigSettingsEmbedded(const SetSysButtonConfigSettings *settings, s32 count) { return ::setsysSetButtonConfigSettingsEmbedded(settings, count); } +Result GetButtonConfigSettingsLeft(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) { return ::setsysGetButtonConfigSettingsLeft(total_out, settings, count); } +Result SetButtonConfigSettingsLeft(const SetSysButtonConfigSettings *settings, s32 count) { return ::setsysSetButtonConfigSettingsLeft(settings, count); } +Result GetButtonConfigSettingsRight(s32 *total_out, SetSysButtonConfigSettings *settings, s32 count) { return ::setsysGetButtonConfigSettingsRight(total_out, settings, count); } +Result SetButtonConfigSettingsRight(const SetSysButtonConfigSettings *settings, s32 count) { return ::setsysSetButtonConfigSettingsRight(settings, count); } +Result GetButtonConfigRegisteredSettingsEmbedded(SetSysButtonConfigRegisteredSettings *settings) { return ::setsysGetButtonConfigRegisteredSettingsEmbedded(settings); } +Result SetButtonConfigRegisteredSettingsEmbedded(const SetSysButtonConfigRegisteredSettings *settings) { return ::setsysSetButtonConfigRegisteredSettingsEmbedded(settings); } +Result GetButtonConfigRegisteredSettings(s32 *total_out, SetSysButtonConfigRegisteredSettings *settings, s32 count) { return ::setsysGetButtonConfigRegisteredSettings(total_out, settings, count); } +Result SetButtonConfigRegisteredSettings(const SetSysButtonConfigRegisteredSettings *settings, s32 count) { return ::setsysSetButtonConfigRegisteredSettings(settings, count); } +Result GetFieldTestingFlag(bool *out) { return ::setsysGetFieldTestingFlag(out); } +Result SetFieldTestingFlag(bool flag) { return ::setsysSetFieldTestingFlag(flag); } +Result GetNxControllerSettingsEx(s32 *total_out, SetSysNxControllerSettings *settings, s32 count) { return ::setsysGetNxControllerSettingsEx(total_out, settings, count); } +Result SetNxControllerSettingsEx(const SetSysNxControllerSettings *settings, s32 count) { return ::setsysSetNxControllerSettingsEx(settings, count); } + +} // namespace setsys + +namespace sha1 { + +void ContextCreate(Sha1Context *out) { ::sha1ContextCreate(out); } +void ContextUpdate(Sha1Context *ctx, const void *src, size_t size) { ::sha1ContextUpdate(ctx, src, size); } +void ContextGetHash(Sha1Context *ctx, void *dst) { ::sha1ContextGetHash(ctx, dst); } +void CalculateHash(void *dst, const void *src, size_t size) { ::sha1CalculateHash(dst, src, size); } + +} // namespace sha1 + +namespace sha256 { + +void ContextCreate(Sha256Context *out) { ::sha256ContextCreate(out); } +void ContextUpdate(Sha256Context *ctx, const void *src, size_t size) { ::sha256ContextUpdate(ctx, src, size); } +void ContextGetHash(Sha256Context *ctx, void *dst) { ::sha256ContextGetHash(ctx, dst); } +void CalculateHash(void *dst, const void *src, size_t size) { ::sha256CalculateHash(dst, src, size); } + +} // namespace sha256 + +namespace shmem { + +Result Create(SharedMemory* s, size_t size, Permission local_perm, Permission remote_perm) { return ::shmemCreate(s, size, local_perm, remote_perm); } +void LoadRemote(SharedMemory* s, Handle handle, size_t size, Permission perm) { ::shmemLoadRemote(s, handle, size, perm); } +Result Map(SharedMemory* s) { return ::shmemMap(s); } +Result Unmap(SharedMemory* s) { return ::shmemUnmap(s); } +void* GetAddr(SharedMemory* s) { return ::shmemGetAddr(s); } +Result Close(SharedMemory* s) { return ::shmemClose(s); } + +} // namespace shmem + +namespace sm { + +u64 ServiceNameToU64(SmServiceName name) { return ::smServiceNameToU64(name); } +SmServiceName ServiceNameFromU64(u64 name) { return ::smServiceNameFromU64(name); } +bool ServiceNamesAreEqual(SmServiceName a, SmServiceName b) { return ::smServiceNamesAreEqual(a, b); } +SmServiceName EncodeName(const char* name) { return ::smEncodeName(name); } +Result Initialize(void) { return ::smInitialize(); } +void Exit(void) { ::smExit(); } +Result GetServiceWrapper(Service* service_out, SmServiceName name) { return ::smGetServiceWrapper(service_out, name); } +Result GetServiceOriginal(Handle* handle_out, SmServiceName name) { return ::smGetServiceOriginal(handle_out, name); } +Result GetService(Service* service_out, const char* name) { return ::smGetService(service_out, name); } +Handle GetServiceOverride(SmServiceName name) { return ::smGetServiceOverride(name); } +Result RegisterService(Handle* handle_out, SmServiceName name, bool is_light, s32 max_sessions) { return ::smRegisterService(handle_out, name, is_light, max_sessions); } +Result RegisterServiceCmif(Handle* handle_out, SmServiceName name, bool is_light, s32 max_sessions) { return ::smRegisterServiceCmif(handle_out, name, is_light, max_sessions); } +Result RegisterServiceTipc(Handle* handle_out, SmServiceName name, bool is_light, s32 max_sessions) { return ::smRegisterServiceTipc(handle_out, name, is_light, max_sessions); } +Result UnregisterService(SmServiceName name) { return ::smUnregisterService(name); } +Result UnregisterServiceCmif(SmServiceName name) { return ::smUnregisterServiceCmif(name); } +Result UnregisterServiceTipc(SmServiceName name) { return ::smUnregisterServiceTipc(name); } +Result DetachClient(void) { return ::smDetachClient(); } +Result DetachClientCmif(void) { return ::smDetachClientCmif(); } +Result DetachClientTipc(void) { return ::smDetachClientTipc(); } +Service * GetServiceSession(void) { return ::smGetServiceSession(); } +TipcService * GetServiceSessionTipc(void) { return ::smGetServiceSessionTipc(); } +void AddOverrideHandle(SmServiceName name, Handle handle) { ::smAddOverrideHandle(name, handle); } +Result ManagerInitialize(void) { return ::smManagerInitialize(); } +void ManagerExit(void) { ::smManagerExit(); } +Result ManagerRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size) { return ::smManagerRegisterProcess(pid, acid_sac, acid_sac_size, aci0_sac, aci0_sac_size); } +Result ManagerUnregisterProcess(u64 pid) { return ::smManagerUnregisterProcess(pid); } +Result ManagerCmifInitialize(void) { return ::smManagerCmifInitialize(); } +void ManagerCmifExit(void) { ::smManagerCmifExit(); } +Service* ManagerCmifGetServiceSession(void) { return ::smManagerCmifGetServiceSession(); } +Result ManagerCmifRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size) { return ::smManagerCmifRegisterProcess(pid, acid_sac, acid_sac_size, aci0_sac, aci0_sac_size); } +Result ManagerCmifUnregisterProcess(u64 pid) { return ::smManagerCmifUnregisterProcess(pid); } +Result ManagerTipcInitialize(void) { return ::smManagerTipcInitialize(); } +void ManagerTipcExit(void) { ::smManagerTipcExit(); } +TipcService* ManagerTipcGetServiceSession(void) { return ::smManagerTipcGetServiceSession(); } +Result ManagerTipcRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size) { return ::smManagerTipcRegisterProcess(pid, acid_sac, acid_sac_size, aci0_sac, aci0_sac_size); } +Result ManagerTipcUnregisterProcess(u64 pid) { return ::smManagerTipcUnregisterProcess(pid); } + +} // namespace sm + +namespace socket { + +const SocketInitConfig * GetDefaultInitConfig(void) { return ::socketGetDefaultInitConfig(); } +Result Initialize(const SocketInitConfig *config) { return ::socketInitialize(config); } +Result GetLastResult(void) { return ::socketGetLastResult(); } +void Exit(void) { ::socketExit(); } +Result InitializeDefault(void) { return ::socketInitializeDefault(); } +int SslConnectionSetSocketDescriptor(SslConnection *c, int sockfd) { return ::socketSslConnectionSetSocketDescriptor(c, sockfd); } +int SslConnectionGetSocketDescriptor(SslConnection *c) { return ::socketSslConnectionGetSocketDescriptor(c); } +#ifdef _SOCKLEN_T_DECLARED +int SslConnectionSetDtlsSocketDescriptor(SslConnection *c, int sockfd, const struct sockaddr *addr, socklen_t addrlen) { return ::socketSslConnectionSetDtlsSocketDescriptor(c, sockfd, addr, addrlen); } +#endif +int NifmRequestRegisterSocketDescriptor(NifmRequest* r, int sockfd) { return ::socketNifmRequestRegisterSocketDescriptor(r, sockfd); } +int NifmRequestUnregisterSocketDescriptor(NifmRequest* r, int sockfd) { return ::socketNifmRequestUnregisterSocketDescriptor(r, sockfd); } + +} // namespace socket + +namespace spl { + +Result Initialize(void) { return ::splInitialize(); } +void Exit(void) { ::splExit(); } +Service* GetServiceSession(void) { return ::splGetServiceSession(); } +Result CryptoInitialize(void) { return ::splCryptoInitialize(); } +void CryptoExit(void) { ::splCryptoExit(); } +Service* CryptoGetServiceSession(void) { return ::splCryptoGetServiceSession(); } +Result SslInitialize(void) { return ::splSslInitialize(); } +void SslExit(void) { ::splSslExit(); } +Service* SslGetServiceSession(void) { return ::splSslGetServiceSession(); } +Result EsInitialize(void) { return ::splEsInitialize(); } +void EsExit(void) { ::splEsExit(); } +Service* EsGetServiceSession(void) { return ::splEsGetServiceSession(); } +Result FsInitialize(void) { return ::splFsInitialize(); } +void FsExit(void) { ::splFsExit(); } +Service* FsGetServiceSession(void) { return ::splFsGetServiceSession(); } +Result ManuInitialize(void) { return ::splManuInitialize(); } +void ManuExit(void) { ::splManuExit(); } +Service* ManuGetServiceSession(void) { return ::splManuGetServiceSession(); } +Result GetConfig(SplConfigItem config_item, u64 *out_config) { return ::splGetConfig(config_item, out_config); } +Result UserExpMod(const void *input, const void *modulus, const void *exp, size_t exp_size, void *dst) { return ::splUserExpMod(input, modulus, exp, exp_size, dst); } +Result SetConfig(SplConfigItem config_item, u64 value) { return ::splSetConfig(config_item, value); } +Result GetRandomBytes(void *out, size_t out_size) { return ::splGetRandomBytes(out, out_size); } +Result IsDevelopment(bool *out_is_development) { return ::splIsDevelopment(out_is_development); } +Result SetBootReason(u32 value) { return ::splSetBootReason(value); } +Result GetBootReason(u32 *out_value) { return ::splGetBootReason(out_value); } +Result CryptoGenerateAesKek(const void *wrapped_kek, u32 key_generation, u32 option, void *out_sealed_kek) { return ::splCryptoGenerateAesKek(wrapped_kek, key_generation, option, out_sealed_kek); } +Result CryptoLoadAesKey(const void *sealed_kek, const void *wrapped_key, u32 keyslot) { return ::splCryptoLoadAesKey(sealed_kek, wrapped_key, keyslot); } +Result CryptoGenerateAesKey(const void *sealed_kek, const void *wrapped_key, void *out_sealed_key) { return ::splCryptoGenerateAesKey(sealed_kek, wrapped_key, out_sealed_key); } +Result CryptoDecryptAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key) { return ::splCryptoDecryptAesKey(wrapped_key, key_generation, option, out_sealed_key); } +Result CryptoCryptAesCtr(const void *input, void *output, size_t size, u32 keyslot, const void *ctr) { return ::splCryptoCryptAesCtr(input, output, size, keyslot, ctr); } +Result CryptoComputeCmac(const void *input, size_t size, u32 keyslot, void *out_cmac) { return ::splCryptoComputeCmac(input, size, keyslot, out_cmac); } +Result CryptoLockAesEngine(u32 *out_keyslot) { return ::splCryptoLockAesEngine(out_keyslot); } +Result CryptoUnlockAesEngine(u32 keyslot) { return ::splCryptoUnlockAesEngine(keyslot); } +Result CryptoGetSecurityEngineEvent(Event *out_event) { return ::splCryptoGetSecurityEngineEvent(out_event); } +Result RsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size) { return ::splRsaDecryptPrivateKey(sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version, dst, dst_size); } +Result SslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size) { return ::splSslLoadSecureExpModKey(sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size); } +Result SslSecureExpMod(const void *input, const void *modulus, void *dst) { return ::splSslSecureExpMod(input, modulus, dst); } +Result EsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { return ::splEsLoadRsaOaepKey(sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version); } +Result EsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey) { return ::splEsUnwrapRsaOaepWrappedTitlekey(rsa_wrapped_titlekey, modulus, label_hash, label_hash_size, key_generation, out_sealed_titlekey); } +Result EsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_generation, void *out_sealed_titlekey) { return ::splEsUnwrapAesWrappedTitlekey(aes_wrapped_titlekey, key_generation, out_sealed_titlekey); } +Result EsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size) { return ::splEsLoadSecureExpModKey(sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size); } +Result EsSecureExpMod(const void *input, const void *modulus, void *dst) { return ::splEsSecureExpMod(input, modulus, dst); } +Result EsUnwrapElicenseKey(const void *rsa_wrapped_elicense_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_elicense_key) { return ::splEsUnwrapElicenseKey(rsa_wrapped_elicense_key, modulus, label_hash, label_hash_size, key_generation, out_sealed_elicense_key); } +Result EsLoadElicenseKey(const void *sealed_elicense_key, u32 keyslot) { return ::splEsLoadElicenseKey(sealed_elicense_key, keyslot); } +Result FsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { return ::splFsLoadSecureExpModKey(sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version); } +Result FsSecureExpMod(const void *input, const void *modulus, void *dst) { return ::splFsSecureExpMod(input, modulus, dst); } +Result FsGenerateSpecificAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key) { return ::splFsGenerateSpecificAesKey(wrapped_key, key_generation, option, out_sealed_key); } +Result FsLoadTitlekey(const void *sealed_titlekey, u32 keyslot) { return ::splFsLoadTitlekey(sealed_titlekey, keyslot); } +Result FsGetPackage2Hash(void *out_hash) { return ::splFsGetPackage2Hash(out_hash); } +Result ManuEncryptRsaKeyForImport(const void *sealed_kek_pre, const void *wrapped_key_pre, const void *sealed_kek_post, const void *wrapped_kek_post, u32 option, const void *wrapped_rsa_key, void *out_wrapped_rsa_key, size_t rsa_key_size) { return ::splManuEncryptRsaKeyForImport(sealed_kek_pre, wrapped_key_pre, sealed_kek_post, wrapped_kek_post, option, wrapped_rsa_key, out_wrapped_rsa_key, rsa_key_size); } + +} // namespace spl + +namespace spsm { + +Result Initialize(void) { return ::spsmInitialize(); } +void Exit(void) { ::spsmExit(); } +Service* GetServiceSession(void) { return ::spsmGetServiceSession(); } +Result Shutdown(bool reboot) { return ::spsmShutdown(reboot); } +Result PutErrorState(void) { return ::spsmPutErrorState(); } + +} // namespace spsm + +namespace ssl { + +Result Initialize(u32 num_sessions) { return ::sslInitialize(num_sessions); } +void Exit(void) { ::sslExit(); } +Service* GetServiceSession(void) { return ::sslGetServiceSession(); } +Result CreateContext(SslContext *c, u32 ssl_version) { return ::sslCreateContext(c, ssl_version); } +Result GetContextCount(u32 *out) { return ::sslGetContextCount(out); } +Result GetCertificates(void* buffer, u32 size, u32 *ca_cert_ids, u32 count, u32 *total_out) { return ::sslGetCertificates(buffer, size, ca_cert_ids, count, total_out); } +Result GetCertificateBufSize(u32 *ca_cert_ids, u32 count, u32 *out) { return ::sslGetCertificateBufSize(ca_cert_ids, count, out); } +Result FlushSessionCache(const char *str, size_t str_bufsize, SslFlushSessionCacheOptionType type, u32 *out) { return ::sslFlushSessionCache(str, str_bufsize, type, out); } +Result SetDebugOption(const void* buffer, size_t size, SslDebugOptionType type) { return ::sslSetDebugOption(buffer, size, type); } +Result GetDebugOption(void* buffer, size_t size, SslDebugOptionType type) { return ::sslGetDebugOption(buffer, size, type); } +Result ClearTls12FallbackFlag(void) { return ::sslClearTls12FallbackFlag(); } +Result SetThreadCoreMask(u64 mask) { return ::sslSetThreadCoreMask(mask); } +Result GetThreadCoreMask(u64 *out) { return ::sslGetThreadCoreMask(out); } +void ContextClose(SslContext *c) { ::sslContextClose(c); } +Result ContextSetOption(SslContext *c, SslContextOption option, s32 value) { return ::sslContextSetOption(c, option, value); } +Result ContextGetOption(SslContext *c, SslContextOption option, s32 *out) { return ::sslContextGetOption(c, option, out); } +Result ContextCreateConnection(SslContext *c, SslConnection *conn) { return ::sslContextCreateConnection(c, conn); } +Result ContextGetConnectionCount(SslContext *c, u32 *out) { return ::sslContextGetConnectionCount(c, out); } +Result ContextImportServerPki(SslContext *c, const void* buffer, u32 size, SslCertificateFormat format, u64 *id) { return ::sslContextImportServerPki(c, buffer, size, format, id); } +Result ContextImportClientPki(SslContext *c, const void* pkcs12, u32 pkcs12_size, const char *pw, u32 pw_size, u64 *id) { return ::sslContextImportClientPki(c, pkcs12, pkcs12_size, pw, pw_size, id); } +Result ContextRemovePki(SslContext *c, u64 id) { return ::sslContextRemovePki(c, id); } +Result ContextRegisterInternalPki(SslContext *c, SslInternalPki internal_pki, u64 *id) { return ::sslContextRegisterInternalPki(c, internal_pki, id); } +Result ContextAddPolicyOid(SslContext *c, const char *str, u32 str_bufsize) { return ::sslContextAddPolicyOid(c, str, str_bufsize); } +Result ContextImportCrl(SslContext *c, const void* buffer, u32 size, u64 *id) { return ::sslContextImportCrl(c, buffer, size, id); } +Result ContextImportClientCertKeyPki(SslContext *c, const void* cert, u32 cert_size, const void* key, u32 key_size, SslCertificateFormat format, u64 *id) { return ::sslContextImportClientCertKeyPki(c, cert, cert_size, key, key_size, format, id); } +Result ContextGeneratePrivateKeyAndCert(SslContext *c, void* cert, u32 cert_size, void* key, u32 key_size, u32 val, const SslKeyAndCertParams *params, u32 *out_certsize, u32 *out_keysize) { return ::sslContextGeneratePrivateKeyAndCert(c, cert, cert_size, key, key_size, val, params, out_certsize, out_keysize); } +Result ContextCreateConnectionForSystem(SslContext *c, SslConnection *conn) { return ::sslContextCreateConnectionForSystem(c, conn); } +void ConnectionClose(SslConnection *c) { ::sslConnectionClose(c); } +Result ConnectionSetSocketDescriptor(SslConnection *c, int sockfd, int *out_sockfd) { return ::sslConnectionSetSocketDescriptor(c, sockfd, out_sockfd); } +Result ConnectionSetHostName(SslConnection *c, const char* str, u32 str_bufsize) { return ::sslConnectionSetHostName(c, str, str_bufsize); } +Result ConnectionSetVerifyOption(SslConnection *c, u32 verify_option) { return ::sslConnectionSetVerifyOption(c, verify_option); } +Result ConnectionSetIoMode(SslConnection *c, SslIoMode mode) { return ::sslConnectionSetIoMode(c, mode); } +Result ConnectionGetSocketDescriptor(SslConnection *c, int *sockfd) { return ::sslConnectionGetSocketDescriptor(c, sockfd); } +Result ConnectionGetHostName(SslConnection *c, char *str, u32 str_bufsize, u32 *out) { return ::sslConnectionGetHostName(c, str, str_bufsize, out); } +Result ConnectionGetVerifyOption(SslConnection *c, u32 *out) { return ::sslConnectionGetVerifyOption(c, out); } +Result ConnectionGetIoMode(SslConnection *c, SslIoMode *out) { return ::sslConnectionGetIoMode(c, out); } +Result ConnectionDoHandshake(SslConnection *c, u32 *out_size, u32 *total_certs, void* server_certbuf, u32 server_certbuf_size) { return ::sslConnectionDoHandshake(c, out_size, total_certs, server_certbuf, server_certbuf_size); } +Result ConnectionGetServerCertDetail(const void* certbuf, u32 certbuf_size, u32 cert_index, void** cert, u32 *cert_size) { return ::sslConnectionGetServerCertDetail(certbuf, certbuf_size, cert_index, cert, cert_size); } +Result ConnectionRead(SslConnection *c, void* buffer, u32 size, u32 *out_size) { return ::sslConnectionRead(c, buffer, size, out_size); } +Result ConnectionWrite(SslConnection *c, const void* buffer, u32 size, u32 *out_size) { return ::sslConnectionWrite(c, buffer, size, out_size); } +Result ConnectionPending(SslConnection *c, s32 *out) { return ::sslConnectionPending(c, out); } +Result ConnectionPeek(SslConnection *c, void* buffer, u32 size, u32 *out_size) { return ::sslConnectionPeek(c, buffer, size, out_size); } +Result ConnectionPoll(SslConnection *c, u32 in_pollevent, u32 *out_pollevent, u32 timeout) { return ::sslConnectionPoll(c, in_pollevent, out_pollevent, timeout); } +Result ConnectionGetVerifyCertError(SslConnection *c) { return ::sslConnectionGetVerifyCertError(c); } +Result ConnectionGetNeededServerCertBufferSize(SslConnection *c, u32 *out) { return ::sslConnectionGetNeededServerCertBufferSize(c, out); } +Result ConnectionSetSessionCacheMode(SslConnection *c, SslSessionCacheMode mode) { return ::sslConnectionSetSessionCacheMode(c, mode); } +Result ConnectionGetSessionCacheMode(SslConnection *c, SslSessionCacheMode *out) { return ::sslConnectionGetSessionCacheMode(c, out); } +Result ConnectionFlushSessionCache(SslConnection *c) { return ::sslConnectionFlushSessionCache(c); } +Result ConnectionSetRenegotiationMode(SslConnection *c, SslRenegotiationMode mode) { return ::sslConnectionSetRenegotiationMode(c, mode); } +Result ConnectionGetRenegotiationMode(SslConnection *c, SslRenegotiationMode *out) { return ::sslConnectionGetRenegotiationMode(c, out); } +Result ConnectionSetOption(SslConnection *c, SslOptionType option, bool flag) { return ::sslConnectionSetOption(c, option, flag); } +Result ConnectionGetOption(SslConnection *c, SslOptionType option, bool *out) { return ::sslConnectionGetOption(c, option, out); } +Result ConnectionGetVerifyCertErrors(SslConnection *c, u32 *out0, u32 *out1, Result *errors, u32 count) { return ::sslConnectionGetVerifyCertErrors(c, out0, out1, errors, count); } +Result ConnectionGetCipherInfo(SslConnection *c, SslCipherInfo *out) { return ::sslConnectionGetCipherInfo(c, out); } +Result ConnectionSetNextAlpnProto(SslConnection *c, const u8 *buffer, u32 size) { return ::sslConnectionSetNextAlpnProto(c, buffer, size); } +Result ConnectionGetNextAlpnProto(SslConnection *c, SslAlpnProtoState *state, u32 *out, u8 *buffer, u32 size) { return ::sslConnectionGetNextAlpnProto(c, state, out, buffer, size); } +Result ConnectionSetDtlsSocketDescriptor(SslConnection *c, int sockfd, const void* buf, size_t size, int *out_sockfd) { return ::sslConnectionSetDtlsSocketDescriptor(c, sockfd, buf, size, out_sockfd); } +Result ConnectionGetDtlsHandshakeTimeout(SslConnection *c, u64 *out) { return ::sslConnectionGetDtlsHandshakeTimeout(c, out); } +Result ConnectionSetPrivateOption(SslConnection *c, SslPrivateOptionType option, u32 value) { return ::sslConnectionSetPrivateOption(c, option, value); } +Result ConnectionSetSrtpCiphers(SslConnection *c, const u16 *ciphers, u32 count) { return ::sslConnectionSetSrtpCiphers(c, ciphers, count); } +Result ConnectionGetSrtpCipher(SslConnection *c, u16 *out) { return ::sslConnectionGetSrtpCipher(c, out); } +Result ConnectionExportKeyingMaterial(SslConnection *c, u8 *outbuf, u32 outbuf_size, const char *label, u32 label_size, const void* context, u32 context_size) { return ::sslConnectionExportKeyingMaterial(c, outbuf, outbuf_size, label, label_size, context, context_size); } +Result ConnectionSetIoTimeout(SslConnection *c, u32 timeout) { return ::sslConnectionSetIoTimeout(c, timeout); } +Result ConnectionGetIoTimeout(SslConnection *c, u32 *out) { return ::sslConnectionGetIoTimeout(c, out); } + +} // namespace ssl + +namespace svc { + +Result SetHeapSize(void** out_addr, u64 size) { return ::svcSetHeapSize(out_addr, size); } +Result SetMemoryPermission(void* addr, u64 size, u32 perm) { return ::svcSetMemoryPermission(addr, size, perm); } +Result SetMemoryAttribute(void* addr, u64 size, u32 val0, u32 val1) { return ::svcSetMemoryAttribute(addr, size, val0, val1); } +Result MapMemory(void* dst_addr, void* src_addr, u64 size) { return ::svcMapMemory(dst_addr, src_addr, size); } +Result UnmapMemory(void* dst_addr, void* src_addr, u64 size) { return ::svcUnmapMemory(dst_addr, src_addr, size); } +Result QueryMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, u64 addr) { return ::svcQueryMemory(meminfo_ptr, pageinfo, addr); } +[[noreturn]] void ExitProcess(void) { ::svcExitProcess(); } +Result CreateThread(Handle* out, void* entry, void* arg, void* stack_top, int prio, int cpuid) { return ::svcCreateThread(out, entry, arg, stack_top, prio, cpuid); } +Result StartThread(Handle handle) { return ::svcStartThread(handle); } +[[noreturn]] void ExitThread(void) { ::svcExitThread(); } +void SleepThread(s64 nano) { ::svcSleepThread(nano); } +Result GetThreadPriority(s32* priority, Handle handle) { return ::svcGetThreadPriority(priority, handle); } +Result SetThreadPriority(Handle handle, u32 priority) { return ::svcSetThreadPriority(handle, priority); } +Result GetThreadCoreMask(s32* preferred_core, u64* affinity_mask, Handle handle) { return ::svcGetThreadCoreMask(preferred_core, affinity_mask, handle); } +Result SetThreadCoreMask(Handle handle, s32 preferred_core, u32 affinity_mask) { return ::svcSetThreadCoreMask(handle, preferred_core, affinity_mask); } +u32 GetCurrentProcessorNumber(void) { return ::svcGetCurrentProcessorNumber(); } +Result SignalEvent(Handle handle) { return ::svcSignalEvent(handle); } +Result ClearEvent(Handle handle) { return ::svcClearEvent(handle); } +Result MapSharedMemory(Handle handle, void* addr, size_t size, u32 perm) { return ::svcMapSharedMemory(handle, addr, size, perm); } +Result UnmapSharedMemory(Handle handle, void* addr, size_t size) { return ::svcUnmapSharedMemory(handle, addr, size); } +Result CreateTransferMemory(Handle* out, void* addr, size_t size, u32 perm) { return ::svcCreateTransferMemory(out, addr, size, perm); } +Result CloseHandle(Handle handle) { return ::svcCloseHandle(handle); } +Result ResetSignal(Handle handle) { return ::svcResetSignal(handle); } +Result WaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout) { return ::svcWaitSynchronization(index, handles, handleCount, timeout); } +Result WaitSynchronizationSingle(Handle handle, u64 timeout) { return ::svcWaitSynchronizationSingle(handle, timeout); } +Result CancelSynchronization(Handle thread) { return ::svcCancelSynchronization(thread); } +Result ArbitrateLock(u32 wait_tag, u32* tag_location, u32 self_tag) { return ::svcArbitrateLock(wait_tag, tag_location, self_tag); } +Result ArbitrateUnlock(u32* tag_location) { return ::svcArbitrateUnlock(tag_location); } +Result WaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u64 timeout) { return ::svcWaitProcessWideKeyAtomic(key, tag_location, self_tag, timeout); } +void SignalProcessWideKey(u32* key, s32 num) { ::svcSignalProcessWideKey(key, num); } +u64 GetSystemTick(void) { return ::svcGetSystemTick(); } +Result ConnectToNamedPort(Handle* session, const char* name) { return ::svcConnectToNamedPort(session, name); } +Result SendSyncRequestLight(Handle session) { return ::svcSendSyncRequestLight(session); } +Result SendSyncRequest(Handle session) { return ::svcSendSyncRequest(session); } +Result SendSyncRequestWithUserBuffer(void* usrBuffer, u64 size, Handle session) { return ::svcSendSyncRequestWithUserBuffer(usrBuffer, size, session); } +Result SendAsyncRequestWithUserBuffer(Handle* handle, void* usrBuffer, u64 size, Handle session) { return ::svcSendAsyncRequestWithUserBuffer(handle, usrBuffer, size, session); } +Result GetProcessId(u64 *processID, Handle handle) { return ::svcGetProcessId(processID, handle); } +Result GetThreadId(u64 *threadID, Handle handle) { return ::svcGetThreadId(threadID, handle); } +Result Break(u32 breakReason, uintptr_t address, uintptr_t size) { return ::svcBreak(breakReason, address, size); } +Result OutputDebugString(const char *str, u64 size) { return ::svcOutputDebugString(str, size); } +[[noreturn]] void ReturnFromException(Result res) { ::svcReturnFromException(res); } +Result GetInfo(u64* out, u32 id0, Handle handle, u64 id1) { return ::svcGetInfo(out, id0, handle, id1); } +void FlushEntireDataCache(void) { ::svcFlushEntireDataCache(); } +Result FlushDataCache(void *address, size_t size) { return ::svcFlushDataCache(address, size); } +Result MapPhysicalMemory(void *address, u64 size) { return ::svcMapPhysicalMemory(address, size); } +Result UnmapPhysicalMemory(void *address, u64 size) { return ::svcUnmapPhysicalMemory(address, size); } +Result GetDebugFutureThreadInfo(LastThreadContext *out_context, u64 *out_thread_id, Handle debug, s64 ns) { return ::svcGetDebugFutureThreadInfo(out_context, out_thread_id, debug, ns); } +Result GetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags) { return ::svcGetLastThreadInfo(out_context, out_tls_address, out_flags); } +Result GetResourceLimitLimitValue(s64 *out, Handle reslimit_h, LimitableResource which) { return ::svcGetResourceLimitLimitValue(out, reslimit_h, which); } +Result GetResourceLimitCurrentValue(s64 *out, Handle reslimit_h, LimitableResource which) { return ::svcGetResourceLimitCurrentValue(out, reslimit_h, which); } +Result SetThreadActivity(Handle thread, ThreadActivity paused) { return ::svcSetThreadActivity(thread, paused); } +Result GetThreadContext3(ThreadContext* ctx, Handle thread) { return ::svcGetThreadContext3(ctx, thread); } +Result WaitForAddress(void *address, u32 arb_type, s64 value, s64 timeout) { return ::svcWaitForAddress(address, arb_type, value, timeout); } +Result SignalToAddress(void *address, u32 signal_type, s32 value, s32 count) { return ::svcSignalToAddress(address, signal_type, value, count); } +void SynchronizePreemptionState(void) { ::svcSynchronizePreemptionState(); } +Result GetResourceLimitPeakValue(s64 *out, Handle reslimit_h, LimitableResource which) { return ::svcGetResourceLimitPeakValue(out, reslimit_h, which); } +Result CreateIoPool(Handle *out_handle, u32 pool_type) { return ::svcCreateIoPool(out_handle, pool_type); } +Result CreateIoRegion(Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm) { return ::svcCreateIoRegion(out_handle, io_pool_h, physical_address, size, memory_mapping, perm); } +void DumpInfo(u32 dump_info_type, u64 arg0) { ::svcDumpInfo(dump_info_type, arg0); } +void KernelDebug(u32 kern_debug_type, u64 arg0, u64 arg1, u64 arg2) { ::svcKernelDebug(kern_debug_type, arg0, arg1, arg2); } +void ChangeKernelTraceState(u32 kern_trace_state) { ::svcChangeKernelTraceState(kern_trace_state); } +Result CreateSession(Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1) { return ::svcCreateSession(server_handle, client_handle, unk0, unk1); } +Result AcceptSession(Handle *session_handle, Handle port_handle) { return ::svcAcceptSession(session_handle, port_handle); } +Result ReplyAndReceiveLight(Handle handle) { return ::svcReplyAndReceiveLight(handle); } +Result ReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout) { return ::svcReplyAndReceive(index, handles, handleCount, replyTarget, timeout); } +Result ReplyAndReceiveWithUserBuffer(s32* index, void* usrBuffer, u64 size, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout) { return ::svcReplyAndReceiveWithUserBuffer(index, usrBuffer, size, handles, handleCount, replyTarget, timeout); } +Result CreateEvent(Handle* server_handle, Handle* client_handle) { return ::svcCreateEvent(server_handle, client_handle); } +Result MapIoRegion(Handle io_region_h, void *address, u64 size, u32 perm) { return ::svcMapIoRegion(io_region_h, address, size, perm); } +Result UnmapIoRegion(Handle io_region_h, void *address, u64 size) { return ::svcUnmapIoRegion(io_region_h, address, size); } +Result MapPhysicalMemoryUnsafe(void *address, u64 size) { return ::svcMapPhysicalMemoryUnsafe(address, size); } +Result UnmapPhysicalMemoryUnsafe(void *address, u64 size) { return ::svcUnmapPhysicalMemoryUnsafe(address, size); } +Result SetUnsafeLimit(u64 size) { return ::svcSetUnsafeLimit(size); } +Result CreateCodeMemory(Handle* code_handle, void* src_addr, u64 size) { return ::svcCreateCodeMemory(code_handle, src_addr, size); } +Result ControlCodeMemory(Handle code_handle, CodeMapOperation op, void* dst_addr, u64 size, u64 perm) { return ::svcControlCodeMemory(code_handle, op, dst_addr, size, perm); } +void SleepSystem(void) { ::svcSleepSystem(); } +Result ReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal) { return ::svcReadWriteRegister(outVal, regAddr, rwMask, inVal); } +Result SetProcessActivity(Handle process, ProcessActivity paused) { return ::svcSetProcessActivity(process, paused); } +Result CreateSharedMemory(Handle* out, size_t size, u32 local_perm, u32 other_perm) { return ::svcCreateSharedMemory(out, size, local_perm, other_perm); } +Result MapTransferMemory(Handle tmem_handle, void* addr, size_t size, u32 perm) { return ::svcMapTransferMemory(tmem_handle, addr, size, perm); } +Result UnmapTransferMemory(Handle tmem_handle, void* addr, size_t size) { return ::svcUnmapTransferMemory(tmem_handle, addr, size); } +Result CreateInterruptEvent(Handle* handle, u64 irqNum, u32 flag) { return ::svcCreateInterruptEvent(handle, irqNum, flag); } +Result QueryPhysicalAddress(PhysicalMemoryInfo *out, u64 virtaddr) { return ::svcQueryPhysicalAddress(out, virtaddr); } +Result QueryMemoryMapping(u64* virtaddr, u64* out_size, u64 physaddr, u64 size) { return ::svcQueryMemoryMapping(virtaddr, out_size, physaddr, size); } +Result LegacyQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size) { return ::svcLegacyQueryIoMapping(virtaddr, physaddr, size); } +Result CreateDeviceAddressSpace(Handle *handle, u64 dev_addr, u64 dev_size) { return ::svcCreateDeviceAddressSpace(handle, dev_addr, dev_size); } +Result AttachDeviceAddressSpace(u64 device, Handle handle) { return ::svcAttachDeviceAddressSpace(device, handle); } +Result DetachDeviceAddressSpace(u64 device, Handle handle) { return ::svcDetachDeviceAddressSpace(device, handle); } +Result MapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option) { return ::svcMapDeviceAddressSpaceByForce(handle, proc_handle, map_addr, dev_size, dev_addr, option); } +Result MapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option) { return ::svcMapDeviceAddressSpaceAligned(handle, proc_handle, map_addr, dev_size, dev_addr, option); } +Result MapDeviceAddressSpace(u64 *out_mapped_size, Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm) { return ::svcMapDeviceAddressSpace(out_mapped_size, handle, proc_handle, map_addr, dev_size, dev_addr, perm); } +Result UnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr) { return ::svcUnmapDeviceAddressSpace(handle, proc_handle, map_addr, map_size, dev_addr); } +Result InvalidateProcessDataCache(Handle process, uintptr_t address, size_t size) { return ::svcInvalidateProcessDataCache(process, address, size); } +Result StoreProcessDataCache(Handle process, uintptr_t address, size_t size) { return ::svcStoreProcessDataCache(process, address, size); } +Result FlushProcessDataCache(Handle process, uintptr_t address, size_t size) { return ::svcFlushProcessDataCache(process, address, size); } +Result DebugActiveProcess(Handle* debug, u64 processID) { return ::svcDebugActiveProcess(debug, processID); } +Result BreakDebugProcess(Handle debug) { return ::svcBreakDebugProcess(debug); } +Result TerminateDebugProcess(Handle debug) { return ::svcTerminateDebugProcess(debug); } +Result GetDebugEvent(DebugEventInfo* event_out, Handle debug) { return ::svcGetDebugEvent(event_out, debug); } +Result ContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tids) { return ::svcContinueDebugEvent(debug, flags, tid_list, num_tids); } +Result LegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID) { return ::svcLegacyContinueDebugEvent(debug, flags, threadID); } +Result GetDebugThreadContext(ThreadContext* ctx, Handle debug, u64 threadID, u32 flags) { return ::svcGetDebugThreadContext(ctx, debug, threadID, flags); } +Result SetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext* ctx, u32 flags) { return ::svcSetDebugThreadContext(debug, threadID, ctx, flags); } +Result GetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids) { return ::svcGetProcessList(num_out, pids_out, max_pids); } +Result GetThreadList(s32 *num_out, u64 *tids_out, u32 max_tids, Handle debug) { return ::svcGetThreadList(num_out, tids_out, max_tids, debug); } +Result QueryDebugProcessMemory(MemoryInfo* meminfo_ptr, u32* pageinfo, Handle debug, u64 addr) { return ::svcQueryDebugProcessMemory(meminfo_ptr, pageinfo, debug, addr); } +Result ReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size) { return ::svcReadDebugProcessMemory(buffer, debug, addr, size); } +Result WriteDebugProcessMemory(Handle debug, const void* buffer, u64 addr, u64 size) { return ::svcWriteDebugProcessMemory(debug, buffer, addr, size); } +Result SetHardwareBreakPoint(u32 which, u64 flags, u64 value) { return ::svcSetHardwareBreakPoint(which, flags, value); } +Result GetDebugThreadParam(u64* out_64, u32* out_32, Handle debug, u64 threadID, DebugThreadParam param) { return ::svcGetDebugThreadParam(out_64, out_32, debug, threadID, param); } +Result GetSystemInfo(u64* out, u64 id0, Handle handle, u64 id1) { return ::svcGetSystemInfo(out, id0, handle, id1); } +Result CreatePort(Handle* portServer, Handle *portClient, s32 max_sessions, bool is_light, const char* name) { return ::svcCreatePort(portServer, portClient, max_sessions, is_light, name); } +Result ManageNamedPort(Handle* portServer, const char* name, s32 maxSessions) { return ::svcManageNamedPort(portServer, name, maxSessions); } +Result ConnectToPort(Handle* session, Handle port) { return ::svcConnectToPort(session, port); } +Result SetProcessMemoryPermission(Handle proc, u64 addr, u64 size, u32 perm) { return ::svcSetProcessMemoryPermission(proc, addr, size, perm); } +Result MapProcessMemory(void* dst, Handle proc, u64 src, u64 size) { return ::svcMapProcessMemory(dst, proc, src, size); } +Result UnmapProcessMemory(void* dst, Handle proc, u64 src, u64 size) { return ::svcUnmapProcessMemory(dst, proc, src, size); } +Result QueryProcessMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, Handle proc, u64 addr) { return ::svcQueryProcessMemory(meminfo_ptr, pageinfo, proc, addr); } +Result MapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size) { return ::svcMapProcessCodeMemory(proc, dst, src, size); } +Result UnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size) { return ::svcUnmapProcessCodeMemory(proc, dst, src, size); } +Result CreateProcess(Handle* out, const void* proc_info, const u32* caps, u64 cap_num) { return ::svcCreateProcess(out, proc_info, caps, cap_num); } +Result StartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size) { return ::svcStartProcess(proc, main_prio, default_cpu, stack_size); } +Result TerminateProcess(Handle proc) { return ::svcTerminateProcess(proc); } +Result GetProcessInfo(s64 *out, Handle proc, ProcessInfoType which) { return ::svcGetProcessInfo(out, proc, which); } +Result CreateResourceLimit(Handle* out) { return ::svcCreateResourceLimit(out); } +Result SetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u64 value) { return ::svcSetResourceLimitLimitValue(reslimit, which, value); } +void CallSecureMonitor(SecmonArgs* regs) { ::svcCallSecureMonitor(regs); } +Result MapInsecurePhysicalMemory(void *address, u64 size) { return ::svcMapInsecurePhysicalMemory(address, size); } +Result UnmapInsecurePhysicalMemory(void *address, u64 size) { return ::svcUnmapInsecurePhysicalMemory(address, size); } + +} // namespace svc + +namespace swkbd { + +Result Create(SwkbdConfig* c, s32 max_dictwords) { return ::swkbdCreate(c, max_dictwords); } +void Close(SwkbdConfig* c) { ::swkbdClose(c); } +void ConfigMakePresetDefault(SwkbdConfig* c) { ::swkbdConfigMakePresetDefault(c); } +void ConfigMakePresetPassword(SwkbdConfig* c) { ::swkbdConfigMakePresetPassword(c); } +void ConfigMakePresetUserName(SwkbdConfig* c) { ::swkbdConfigMakePresetUserName(c); } +void ConfigMakePresetDownloadCode(SwkbdConfig* c) { ::swkbdConfigMakePresetDownloadCode(c); } +void ConfigSetOkButtonText(SwkbdConfig* c, const char* str) { ::swkbdConfigSetOkButtonText(c, str); } +void ConfigSetLeftOptionalSymbolKey(SwkbdConfig* c, const char* str) { ::swkbdConfigSetLeftOptionalSymbolKey(c, str); } +void ConfigSetRightOptionalSymbolKey(SwkbdConfig* c, const char* str) { ::swkbdConfigSetRightOptionalSymbolKey(c, str); } +void ConfigSetHeaderText(SwkbdConfig* c, const char* str) { ::swkbdConfigSetHeaderText(c, str); } +void ConfigSetSubText(SwkbdConfig* c, const char* str) { ::swkbdConfigSetSubText(c, str); } +void ConfigSetGuideText(SwkbdConfig* c, const char* str) { ::swkbdConfigSetGuideText(c, str); } +void ConfigSetInitialText(SwkbdConfig* c, const char* str) { ::swkbdConfigSetInitialText(c, str); } +void ConfigSetDictionary(SwkbdConfig* c, const SwkbdDictWord *input, s32 entries) { ::swkbdConfigSetDictionary(c, input, entries); } +Result ConfigSetCustomizedDictionaries(SwkbdConfig* c, const SwkbdCustomizedDictionarySet *dic) { return ::swkbdConfigSetCustomizedDictionaries(c, dic); } +void ConfigSetTextCheckCallback(SwkbdConfig* c, SwkbdTextCheckCb cb) { ::swkbdConfigSetTextCheckCallback(c, cb); } +void ConfigSetType(SwkbdConfig* c, SwkbdType type) { ::swkbdConfigSetType(c, type); } +void ConfigSetDicFlag(SwkbdConfig* c, u8 flag) { ::swkbdConfigSetDicFlag(c, flag); } +void ConfigSetKeySetDisableBitmask(SwkbdConfig* c, u32 keySetDisableBitmask) { ::swkbdConfigSetKeySetDisableBitmask(c, keySetDisableBitmask); } +void ConfigSetInitialCursorPos(SwkbdConfig* c, u32 initialCursorPos) { ::swkbdConfigSetInitialCursorPos(c, initialCursorPos); } +void ConfigSetStringLenMax(SwkbdConfig* c, u32 stringLenMax) { ::swkbdConfigSetStringLenMax(c, stringLenMax); } +void ConfigSetStringLenMin(SwkbdConfig* c, u32 stringLenMin) { ::swkbdConfigSetStringLenMin(c, stringLenMin); } +void ConfigSetPasswordFlag(SwkbdConfig* c, u32 flag) { ::swkbdConfigSetPasswordFlag(c, flag); } +void ConfigSetTextDrawType(SwkbdConfig* c, SwkbdTextDrawType textDrawType) { ::swkbdConfigSetTextDrawType(c, textDrawType); } +void ConfigSetReturnButtonFlag(SwkbdConfig* c, u16 flag) { ::swkbdConfigSetReturnButtonFlag(c, flag); } +void ConfigSetBlurBackground(SwkbdConfig* c, u8 blurBackground) { ::swkbdConfigSetBlurBackground(c, blurBackground); } +void ConfigSetTextGrouping(SwkbdConfig* c, u32 index, u32 value) { ::swkbdConfigSetTextGrouping(c, index, value); } +void ConfigSetUnkFlag(SwkbdConfig* c, u8 flag) { ::swkbdConfigSetUnkFlag(c, flag); } +void ConfigSetTrigger(SwkbdConfig* c, u8 trigger) { ::swkbdConfigSetTrigger(c, trigger); } +Result Show(SwkbdConfig* c, char* out_string, size_t out_string_size) { return ::swkbdShow(c, out_string, out_string_size); } +Result InlineCreate(SwkbdInline* s) { return ::swkbdInlineCreate(s); } +Result InlineClose(SwkbdInline* s) { return ::swkbdInlineClose(s); } +Result InlineLaunch(SwkbdInline* s) { return ::swkbdInlineLaunch(s); } +Result InlineLaunchForLibraryApplet(SwkbdInline* s, u8 mode, u8 unk_x5) { return ::swkbdInlineLaunchForLibraryApplet(s, mode, unk_x5); } +void InlineGetWindowSize(s32 *width, s32 *height) { ::swkbdInlineGetWindowSize(width, height); } +Result InlineGetImageMemoryRequirement(u64 *out_size, u64 *out_alignment) { return ::swkbdInlineGetImageMemoryRequirement(out_size, out_alignment); } +Result InlineGetImage(SwkbdInline* s, void* buffer, u64 size, bool *data_available) { return ::swkbdInlineGetImage(s, buffer, size, data_available); } +s32 InlineGetMaxHeight(SwkbdInline* s) { return ::swkbdInlineGetMaxHeight(s); } +s32 InlineGetMiniaturizedHeight(SwkbdInline* s) { return ::swkbdInlineGetMiniaturizedHeight(s); } +s32 InlineGetTouchRectangles(SwkbdInline* s, SwkbdRect *keytop, SwkbdRect *footer) { return ::swkbdInlineGetTouchRectangles(s, keytop, footer); } +bool InlineIsUsedTouchPointByKeyboard(SwkbdInline* s, s32 x, s32 y) { return ::swkbdInlineIsUsedTouchPointByKeyboard(s, x, y); } +Result InlineUpdate(SwkbdInline* s, SwkbdState* out_state) { return ::swkbdInlineUpdate(s, out_state); } +void InlineSetFinishedInitializeCallback(SwkbdInline* s, VoidFn cb) { ::swkbdInlineSetFinishedInitializeCallback(s, cb); } +void InlineSetDecidedCancelCallback(SwkbdInline* s, VoidFn cb) { ::swkbdInlineSetDecidedCancelCallback(s, cb); } +void InlineSetChangedStringCallback(SwkbdInline* s, SwkbdChangedStringCb cb) { ::swkbdInlineSetChangedStringCallback(s, cb); } +void InlineSetChangedStringV2Callback(SwkbdInline* s, SwkbdChangedStringV2Cb cb) { ::swkbdInlineSetChangedStringV2Callback(s, cb); } +void InlineSetMovedCursorCallback(SwkbdInline* s, SwkbdMovedCursorCb cb) { ::swkbdInlineSetMovedCursorCallback(s, cb); } +void InlineSetMovedCursorV2Callback(SwkbdInline* s, SwkbdMovedCursorV2Cb cb) { ::swkbdInlineSetMovedCursorV2Callback(s, cb); } +void InlineSetMovedTabCallback(SwkbdInline* s, SwkbdMovedTabCb cb) { ::swkbdInlineSetMovedTabCallback(s, cb); } +void InlineSetDecidedEnterCallback(SwkbdInline* s, SwkbdDecidedEnterCb cb) { ::swkbdInlineSetDecidedEnterCallback(s, cb); } +void InlineSetReleasedUserWordInfoCallback(SwkbdInline* s, VoidFn cb) { ::swkbdInlineSetReleasedUserWordInfoCallback(s, cb); } +void InlineAppear(SwkbdInline* s, const SwkbdAppearArg* arg) { ::swkbdInlineAppear(s, arg); } +void InlineAppearEx(SwkbdInline* s, const SwkbdAppearArg* arg, u8 trigger) { ::swkbdInlineAppearEx(s, arg, trigger); } +void InlineDisappear(SwkbdInline* s) { ::swkbdInlineDisappear(s); } +void InlineMakeAppearArg(SwkbdAppearArg* arg, SwkbdType type) { ::swkbdInlineMakeAppearArg(arg, type); } +void InlineAppearArgSetOkButtonText(SwkbdAppearArg* arg, const char* str) { ::swkbdInlineAppearArgSetOkButtonText(arg, str); } +void InlineAppearArgSetLeftButtonText(SwkbdAppearArg* arg, const char* str) { ::swkbdInlineAppearArgSetLeftButtonText(arg, str); } +void InlineAppearArgSetRightButtonText(SwkbdAppearArg* arg, const char* str) { ::swkbdInlineAppearArgSetRightButtonText(arg, str); } +void InlineAppearArgSetStringLenMax(SwkbdAppearArg* arg, s32 stringLenMax) { ::swkbdInlineAppearArgSetStringLenMax(arg, stringLenMax); } +void InlineAppearArgSetStringLenMin(SwkbdAppearArg* arg, s32 stringLenMin) { ::swkbdInlineAppearArgSetStringLenMin(arg, stringLenMin); } +void InlineSetVolume(SwkbdInline* s, float volume) { ::swkbdInlineSetVolume(s, volume); } +void InlineSetInputText(SwkbdInline* s, const char* str) { ::swkbdInlineSetInputText(s, str); } +void InlineSetCursorPos(SwkbdInline* s, s32 pos) { ::swkbdInlineSetCursorPos(s, pos); } +Result InlineSetUserWordInfo(SwkbdInline* s, const SwkbdDictWord *input, s32 entries) { return ::swkbdInlineSetUserWordInfo(s, input, entries); } +Result InlineUnsetUserWordInfo(SwkbdInline* s) { return ::swkbdInlineUnsetUserWordInfo(s); } +void InlineSetUtf8Mode(SwkbdInline* s, bool flag) { ::swkbdInlineSetUtf8Mode(s, flag); } +Result InlineSetCustomizeDic(SwkbdInline* s, void* buffer, size_t size, SwkbdCustomizeDicInfo *info) { return ::swkbdInlineSetCustomizeDic(s, buffer, size, info); } +void InlineUnsetCustomizeDic(SwkbdInline* s) { ::swkbdInlineUnsetCustomizeDic(s); } +Result InlineSetCustomizedDictionaries(SwkbdInline* s, const SwkbdCustomizedDictionarySet *dic) { return ::swkbdInlineSetCustomizedDictionaries(s, dic); } +Result InlineUnsetCustomizedDictionaries(SwkbdInline* s) { return ::swkbdInlineUnsetCustomizedDictionaries(s); } +void InlineSetInputModeFadeType(SwkbdInline* s, u8 type) { ::swkbdInlineSetInputModeFadeType(s, type); } +void InlineSetAlphaEnabledInInputMode(SwkbdInline* s, bool flag) { ::swkbdInlineSetAlphaEnabledInInputMode(s, flag); } +void InlineSetKeytopBgAlpha(SwkbdInline* s, float alpha) { ::swkbdInlineSetKeytopBgAlpha(s, alpha); } +void InlineSetFooterBgAlpha(SwkbdInline* s, float alpha) { ::swkbdInlineSetFooterBgAlpha(s, alpha); } +void InlineSetKeytopScale(SwkbdInline* s, float scale) { ::swkbdInlineSetKeytopScale(s, scale); } +void InlineSetKeytopTranslate(SwkbdInline* s, float x, float y) { ::swkbdInlineSetKeytopTranslate(s, x, y); } +void InlineSetKeytopAsFloating(SwkbdInline* s, bool flag) { ::swkbdInlineSetKeytopAsFloating(s, flag); } +void InlineSetFooterScalable(SwkbdInline* s, bool flag) { ::swkbdInlineSetFooterScalable(s, flag); } +void InlineSetTouchFlag(SwkbdInline* s, bool flag) { ::swkbdInlineSetTouchFlag(s, flag); } +void InlineSetHardwareKeyboardFlag(SwkbdInline* s, bool flag) { ::swkbdInlineSetHardwareKeyboardFlag(s, flag); } +void InlineSetDirectionalButtonAssignFlag(SwkbdInline* s, bool flag) { ::swkbdInlineSetDirectionalButtonAssignFlag(s, flag); } +void InlineSetSeGroup(SwkbdInline* s, u8 seGroup, bool flag) { ::swkbdInlineSetSeGroup(s, seGroup, flag); } +void InlineSetBackspaceFlag(SwkbdInline* s, bool flag) { ::swkbdInlineSetBackspaceFlag(s, flag); } + +} // namespace swkbd + +namespace tc { + +Result Initialize(void) { return ::tcInitialize(); } +void Exit(void) { ::tcExit(); } +Service* GetServiceSession(void) { return ::tcGetServiceSession(); } +Result EnableFanControl(void) { return ::tcEnableFanControl(); } +Result DisableFanControl(void) { return ::tcDisableFanControl(); } +Result IsFanControlEnabled(bool *status) { return ::tcIsFanControlEnabled(status); } +Result GetSkinTemperatureMilliC(s32 *skinTemp) { return ::tcGetSkinTemperatureMilliC(skinTemp); } + +} // namespace tc + +namespace thread { + +bool ContextIsAArch64(const ThreadContext *ctx) { return ::threadContextIsAArch64(ctx); } +bool ExceptionIsAArch64(const ThreadExceptionDump *ctx) { return ::threadExceptionIsAArch64(ctx); } +Result Create(Thread* t, ThreadFunc entry, void* arg, void *stack_mem, size_t stack_sz, int prio, int cpuid) { return ::threadCreate(t, entry, arg, stack_mem, stack_sz, prio, cpuid); } +Result Start(Thread* t) { return ::threadStart(t); } +[[noreturn]] void Exit(void) { ::threadExit(); } +Result WaitForExit(Thread* t) { return ::threadWaitForExit(t); } +Result Close(Thread* t) { return ::threadClose(t); } +Result Pause(Thread* t) { return ::threadPause(t); } +Result Resume(Thread* t) { return ::threadResume(t); } +Result DumpContext(ThreadContext* ctx, Thread* t) { return ::threadDumpContext(ctx, t); } +Thread * GetSelf(void) { return ::threadGetSelf(); } +Handle GetCurHandle(void) { return ::threadGetCurHandle(); } +s32 TlsAlloc(void (* destructor)(void*)) { return ::threadTlsAlloc(destructor); } +void* TlsGet(s32 slot_id) { return ::threadTlsGet(slot_id); } +void TlsSet(s32 slot_id, void* value) { ::threadTlsSet(slot_id, value); } +void TlsFree(s32 slot_id) { ::threadTlsFree(slot_id); } + +} // namespace thread + +namespace time { + +Result Initialize(void) { return ::timeInitialize(); } +void Exit(void) { ::timeExit(); } +Service* GetServiceSession(void) { return ::timeGetServiceSession(); } +Service* GetServiceSession_SystemClock(TimeType type) { return ::timeGetServiceSession_SystemClock(type); } +Service* GetServiceSession_SteadyClock(void) { return ::timeGetServiceSession_SteadyClock(); } +Service* GetServiceSession_TimeZoneService(void) { return ::timeGetServiceSession_TimeZoneService(); } +void* GetSharedmemAddr(void) { return ::timeGetSharedmemAddr(); } +Result GetStandardSteadyClockTimePoint(TimeSteadyClockTimePoint *out) { return ::timeGetStandardSteadyClockTimePoint(out); } +Result GetStandardSteadyClockInternalOffset(s64 *out) { return ::timeGetStandardSteadyClockInternalOffset(out); } +Result GetCurrentTime(TimeType type, u64 *timestamp) { return ::timeGetCurrentTime(type, timestamp); } +Result SetCurrentTime(TimeType type, u64 timestamp) { return ::timeSetCurrentTime(type, timestamp); } +Result GetDeviceLocationName(TimeLocationName *name) { return ::timeGetDeviceLocationName(name); } +Result SetDeviceLocationName(const TimeLocationName *name) { return ::timeSetDeviceLocationName(name); } +Result GetTotalLocationNameCount(s32 *total_location_name_count) { return ::timeGetTotalLocationNameCount(total_location_name_count); } +Result LoadLocationNameList(s32 index, TimeLocationName *location_name_array, s32 location_name_max, s32 *location_name_count) { return ::timeLoadLocationNameList(index, location_name_array, location_name_max, location_name_count); } +Result LoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule) { return ::timeLoadTimeZoneRule(name, rule); } +Result ToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info) { return ::timeToCalendarTime(rule, timestamp, caltime, info); } +Result ToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info) { return ::timeToCalendarTimeWithMyRule(timestamp, caltime, info); } +Result ToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count) { return ::timeToPosixTime(rule, caltime, timestamp_list, timestamp_list_count, timestamp_count); } +Result ToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count) { return ::timeToPosixTimeWithMyRule(caltime, timestamp_list, timestamp_list_count, timestamp_count); } + +} // namespace time + +namespace tipc { + +void Create(TipcService* s, Handle h) { ::tipcCreate(s, h); } +void Close(TipcService* s) { ::tipcClose(s); } +void RequestInBuffer(HipcRequest* req, const void* buffer, size_t size, HipcBufferMode mode) { ::tipcRequestInBuffer(req, buffer, size, mode); } +void RequestOutBuffer(HipcRequest* req, void* buffer, size_t size, HipcBufferMode mode) { ::tipcRequestOutBuffer(req, buffer, size, mode); } +void RequestInOutBuffer(HipcRequest* req, void* buffer, size_t size, HipcBufferMode mode) { ::tipcRequestInOutBuffer(req, buffer, size, mode); } +void RequestHandle(HipcRequest* req, Handle handle) { ::tipcRequestHandle(req, handle); } +void RequestFormatProcessBuffer(TipcRequestFormat* fmt, u32 attr) { ::_tipcRequestFormatProcessBuffer(fmt, attr); } +void RequestProcessBuffer(HipcRequest* req, const SfBuffer* buf, u32 attr) { ::_tipcRequestProcessBuffer(req, buf, attr); } +void* MakeRequest(u32 request_id, u32 data_size, bool send_pid, const SfBufferAttrs buffer_attrs, const SfBuffer* buffers, u32 num_handles, const Handle* handles) { return ::tipcMakeRequest(request_id, data_size, send_pid, buffer_attrs, buffers, num_handles, handles); } +Handle ResponseGetCopyHandle(HipcResponse* res) { return ::tipcResponseGetCopyHandle(res); } +Handle ResponseGetMoveHandle(HipcResponse* res) { return ::tipcResponseGetMoveHandle(res); } +void ResponseGetHandle(HipcResponse* res, SfOutHandleAttr type, Handle* out) { ::_tipcResponseGetHandle(res, type, out); } +Result ParseResponse(u32 out_size, void** out_data, u32 num_out_objects, TipcService* out_objects, const SfOutHandleAttrs out_handle_attrs, Handle* out_handles) { return ::tipcParseResponse(out_size, out_data, num_out_objects, out_objects, out_handle_attrs, out_handles); } +Result DispatchImpl(TipcService* s, u32 request_id, const void* in_data, u32 in_data_size, void* out_data, u32 out_data_size, TipcDispatchParams disp) { return ::tipcDispatchImpl(s, request_id, in_data, in_data_size, out_data, out_data_size, disp); } + +} // namespace tipc + +namespace tmem { + +Result Create(TransferMemory* t, size_t size, Permission perm) { return ::tmemCreate(t, size, perm); } +Result CreateFromMemory(TransferMemory* t, void* buf, size_t size, Permission perm) { return ::tmemCreateFromMemory(t, buf, size, perm); } +void LoadRemote(TransferMemory* t, Handle handle, size_t size, Permission perm) { ::tmemLoadRemote(t, handle, size, perm); } +Result Map(TransferMemory* t) { return ::tmemMap(t); } +Result Unmap(TransferMemory* t) { return ::tmemUnmap(t); } +void* GetAddr(TransferMemory* t) { return ::tmemGetAddr(t); } +Result CloseHandle(TransferMemory* t) { return ::tmemCloseHandle(t); } +Result WaitForPermission(TransferMemory* t, Permission perm) { return ::tmemWaitForPermission(t, perm); } +Result Close(TransferMemory* t) { return ::tmemClose(t); } + +} // namespace tmem + +namespace ts { + +Result Initialize(void) { return ::tsInitialize(); } +void Exit(void) { ::tsExit(); } +Service* GetServiceSession(void) { return ::tsGetServiceSession(); } +Result GetTemperatureRange(TsLocation location, s32 *min_temperature, s32 *max_temperature) { return ::tsGetTemperatureRange(location, min_temperature, max_temperature); } +Result GetTemperature(TsLocation location, s32 *temperature) { return ::tsGetTemperature(location, temperature); } +Result GetTemperatureMilliC(TsLocation location, s32 *temperature) { return ::tsGetTemperatureMilliC(location, temperature); } +Result OpenSession(TsSession *s, u32 device_code) { return ::tsOpenSession(s, device_code); } +Result SessionGetTemperature(TsSession *s, float *temperature) { return ::tsSessionGetTemperature(s, temperature); } +void SessionClose(TsSession *s) { ::tsSessionClose(s); } + +} // namespace ts + +namespace uart { + +Result Initialize(void) { return ::uartInitialize(); } +void Exit(void) { ::uartExit(); } +Service* GetServiceSession(void) { return ::uartGetServiceSession(); } +Result HasPort(UartPort port, bool *out) { return ::uartHasPort(port, out); } +Result HasPortForDev(UartPortForDev port, bool *out) { return ::uartHasPortForDev(port, out); } +Result IsSupportedBaudRate(UartPort port, u32 baud_rate, bool *out) { return ::uartIsSupportedBaudRate(port, baud_rate, out); } +Result IsSupportedBaudRateForDev(UartPortForDev port, u32 baud_rate, bool *out) { return ::uartIsSupportedBaudRateForDev(port, baud_rate, out); } +Result IsSupportedFlowControlMode(UartPort port, UartFlowControlMode flow_control_mode, bool *out) { return ::uartIsSupportedFlowControlMode(port, flow_control_mode, out); } +Result IsSupportedFlowControlModeForDev(UartPortForDev port, UartFlowControlMode flow_control_mode, bool *out) { return ::uartIsSupportedFlowControlModeForDev(port, flow_control_mode, out); } +Result CreatePortSession(UartPortSession *s) { return ::uartCreatePortSession(s); } +Result IsSupportedPortEvent(UartPort port, UartPortEventType port_event_type, bool *out) { return ::uartIsSupportedPortEvent(port, port_event_type, out); } +Result IsSupportedPortEventForDev(UartPortForDev port, UartPortEventType port_event_type, bool *out) { return ::uartIsSupportedPortEventForDev(port, port_event_type, out); } +Result IsSupportedDeviceVariation(UartPort port, u32 device_variation, bool *out) { return ::uartIsSupportedDeviceVariation(port, device_variation, out); } +Result IsSupportedDeviceVariationForDev(UartPortForDev port, u32 device_variation, bool *out) { return ::uartIsSupportedDeviceVariationForDev(port, device_variation, out); } +void PortSessionClose(UartPortSession* s) { ::uartPortSessionClose(s); } +Result PortSessionOpenPort(UartPortSession* s, bool *out, UartPort port, u32 baud_rate, UartFlowControlMode flow_control_mode, u32 device_variation, bool is_invert_tx, bool is_invert_rx, bool is_invert_rts, bool is_invert_cts, void* send_buffer, u64 send_buffer_length, void* receive_buffer, u64 receive_buffer_length) { return ::uartPortSessionOpenPort(s, out, port, baud_rate, flow_control_mode, device_variation, is_invert_tx, is_invert_rx, is_invert_rts, is_invert_cts, send_buffer, send_buffer_length, receive_buffer, receive_buffer_length); } +Result PortSessionOpenPortForDev(UartPortSession* s, bool *out, UartPortForDev port, u32 baud_rate, UartFlowControlMode flow_control_mode, u32 device_variation, bool is_invert_tx, bool is_invert_rx, bool is_invert_rts, bool is_invert_cts, void* send_buffer, u64 send_buffer_length, void* receive_buffer, u64 receive_buffer_length) { return ::uartPortSessionOpenPortForDev(s, out, port, baud_rate, flow_control_mode, device_variation, is_invert_tx, is_invert_rx, is_invert_rts, is_invert_cts, send_buffer, send_buffer_length, receive_buffer, receive_buffer_length); } +Result PortSessionGetWritableLength(UartPortSession* s, u64 *out) { return ::uartPortSessionGetWritableLength(s, out); } +Result PortSessionSend(UartPortSession* s, const void* in_data, size_t size, u64 *out) { return ::uartPortSessionSend(s, in_data, size, out); } +Result PortSessionGetReadableLength(UartPortSession* s, u64 *out) { return ::uartPortSessionGetReadableLength(s, out); } +Result PortSessionReceive(UartPortSession* s, void* out_data, size_t size, u64 *out) { return ::uartPortSessionReceive(s, out_data, size, out); } +Result PortSessionBindPortEvent(UartPortSession* s, UartPortEventType port_event_type, s64 threshold, bool *out, Event *out_event) { return ::uartPortSessionBindPortEvent(s, port_event_type, threshold, out, out_event); } +Result PortSessionUnbindPortEvent(UartPortSession* s, UartPortEventType port_event_type, bool *out) { return ::uartPortSessionUnbindPortEvent(s, port_event_type, out); } + +} // namespace uart + +namespace uevent { + +void Create(UEvent* e, bool auto_clear) { ::ueventCreate(e, auto_clear); } +void Clear(UEvent* e) { ::ueventClear(e); } +void Signal(UEvent* e) { ::ueventSignal(e); } + +} // namespace uevent + +namespace usb { + +Result CommsInitialize(void) { return ::usbCommsInitialize(); } +Result CommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos, u16 idVendor, u16 idProduct) { return ::usbCommsInitializeEx(num_interfaces, infos, idVendor, idProduct); } +void CommsExit(void) { ::usbCommsExit(); } +void CommsSetErrorHandling(bool flag) { ::usbCommsSetErrorHandling(flag); } +size_t CommsRead(void* buffer, size_t size) { return ::usbCommsRead(buffer, size); } +size_t CommsWrite(const void* buffer, size_t size) { return ::usbCommsWrite(buffer, size); } +size_t CommsReadEx(void* buffer, size_t size, u32 interface) { return ::usbCommsReadEx(buffer, size, interface); } +size_t CommsWriteEx(const void* buffer, size_t size, u32 interface) { return ::usbCommsWriteEx(buffer, size, interface); } +Event * CommsGetReadCompletionEvent(u32 interface) { return ::usbCommsGetReadCompletionEvent(interface); } +Result CommsReadAsync(void *buffer, size_t size, u32 *urbId, u32 interface) { return ::usbCommsReadAsync(buffer, size, urbId, interface); } +Result CommsGetReadResult(u32 urbId, u32 *transferredSize, u32 interface) { return ::usbCommsGetReadResult(urbId, transferredSize, interface); } +Event * CommsGetWriteCompletionEvent(u32 interface) { return ::usbCommsGetWriteCompletionEvent(interface); } +Result CommsWriteAsync(void *buffer, size_t size, u32 *urbId, u32 interface) { return ::usbCommsWriteAsync(buffer, size, urbId, interface); } +Result CommsGetWriteResult(u32 urbId, u32 *transferredSize, u32 interface) { return ::usbCommsGetWriteResult(urbId, transferredSize, interface); } +Result DsInitialize(void) { return ::usbDsInitialize(); } +void DsExit(void) { ::usbDsExit(); } +Service* DsGetServiceSession(void) { return ::usbDsGetServiceSession(); } +Result DsWaitReady(u64 timeout) { return ::usbDsWaitReady(timeout); } +Result DsParseReportData(UsbDsReportData *reportdata, u32 urbId, u32 *requestedSize, u32 *transferredSize) { return ::usbDsParseReportData(reportdata, urbId, requestedSize, transferredSize); } +Event* DsGetStateChangeEvent(void) { return ::usbDsGetStateChangeEvent(); } +Result DsGetState(UsbState* out) { return ::usbDsGetState(out); } +Result DsGetDsInterface(UsbDsInterface** out, struct usb_interface_descriptor* descriptor, const char* interface_name) { return ::usbDsGetDsInterface(out, descriptor, interface_name); } +Result DsSetVidPidBcd(const UsbDsDeviceInfo* deviceinfo) { return ::usbDsSetVidPidBcd(deviceinfo); } +Result DsRegisterInterface(UsbDsInterface** out) { return ::usbDsRegisterInterface(out); } +Result DsRegisterInterfaceEx(UsbDsInterface** out, u8 intf_num) { return ::usbDsRegisterInterfaceEx(out, intf_num); } +Result DsClearDeviceData(void) { return ::usbDsClearDeviceData(); } +Result DsAddUsbStringDescriptor(u8* out_index, const char* string) { return ::usbDsAddUsbStringDescriptor(out_index, string); } +Result DsAddUsbLanguageStringDescriptor(u8* out_index, const u16* lang_ids, u16 num_langs) { return ::usbDsAddUsbLanguageStringDescriptor(out_index, lang_ids, num_langs); } +Result DsDeleteUsbStringDescriptor(u8 index) { return ::usbDsDeleteUsbStringDescriptor(index); } +Result DsSetUsbDeviceDescriptor(UsbDeviceSpeed speed, struct usb_device_descriptor* descriptor) { return ::usbDsSetUsbDeviceDescriptor(speed, descriptor); } +Result DsSetBinaryObjectStore(const void* bos, size_t bos_size) { return ::usbDsSetBinaryObjectStore(bos, bos_size); } +Result DsEnable(void) { return ::usbDsEnable(); } +Result DsDisable(void) { return ::usbDsDisable(); } +Result DsGetSpeed(UsbDeviceSpeed *out) { return ::usbDsGetSpeed(out); } +void DsInterface_Close(UsbDsInterface* interface) { ::usbDsInterface_Close(interface); } +Result DsInterface_GetSetupPacket(UsbDsInterface* interface, void* buffer, size_t size) { return ::usbDsInterface_GetSetupPacket(interface, buffer, size); } +Result DsInterface_EnableInterface(UsbDsInterface* interface) { return ::usbDsInterface_EnableInterface(interface); } +Result DsInterface_DisableInterface(UsbDsInterface* interface) { return ::usbDsInterface_DisableInterface(interface); } +Result DsInterface_CtrlInPostBufferAsync(UsbDsInterface* interface, void* buffer, size_t size, u32* urbId) { return ::usbDsInterface_CtrlInPostBufferAsync(interface, buffer, size, urbId); } +Result DsInterface_CtrlOutPostBufferAsync(UsbDsInterface* interface, void* buffer, size_t size, u32* urbId) { return ::usbDsInterface_CtrlOutPostBufferAsync(interface, buffer, size, urbId); } +Result DsInterface_GetCtrlInReportData(UsbDsInterface* interface, UsbDsReportData* out) { return ::usbDsInterface_GetCtrlInReportData(interface, out); } +Result DsInterface_GetCtrlOutReportData(UsbDsInterface* interface, UsbDsReportData* out) { return ::usbDsInterface_GetCtrlOutReportData(interface, out); } +Result DsInterface_StallCtrl(UsbDsInterface* interface) { return ::usbDsInterface_StallCtrl(interface); } +Result DsInterface_GetDsEndpoint(UsbDsInterface* interface, UsbDsEndpoint** endpoint, struct usb_endpoint_descriptor* descriptor) { return ::usbDsInterface_GetDsEndpoint(interface, endpoint, descriptor); } +Result DsInterface_RegisterEndpoint(UsbDsInterface* interface, UsbDsEndpoint** endpoint, u8 endpoint_address) { return ::usbDsInterface_RegisterEndpoint(interface, endpoint, endpoint_address); } +Result DsInterface_AppendConfigurationData(UsbDsInterface* interface, UsbDeviceSpeed speed, const void* buffer, size_t size) { return ::usbDsInterface_AppendConfigurationData(interface, speed, buffer, size); } +void DsEndpoint_Close(UsbDsEndpoint* endpoint) { ::usbDsEndpoint_Close(endpoint); } +Result DsEndpoint_Cancel(UsbDsEndpoint* endpoint) { return ::usbDsEndpoint_Cancel(endpoint); } +Result DsEndpoint_PostBufferAsync(UsbDsEndpoint* endpoint, void* buffer, size_t size, u32* urbId) { return ::usbDsEndpoint_PostBufferAsync(endpoint, buffer, size, urbId); } +Result DsEndpoint_GetReportData(UsbDsEndpoint* endpoint, UsbDsReportData* out) { return ::usbDsEndpoint_GetReportData(endpoint, out); } +Result DsEndpoint_Stall(UsbDsEndpoint* endpoint) { return ::usbDsEndpoint_Stall(endpoint); } +Result DsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt) { return ::usbDsEndpoint_SetZlt(endpoint, zlt); } +Result HsInitialize(void) { return ::usbHsInitialize(); } +void HsExit(void) { ::usbHsExit(); } +Service* HsGetServiceSession(void) { return ::usbHsGetServiceSession(); } +Event* HsGetInterfaceStateChangeEvent(void) { return ::usbHsGetInterfaceStateChangeEvent(); } +Result HsQueryAllInterfaces(const UsbHsInterfaceFilter* filter, UsbHsInterface* interfaces, size_t interfaces_maxsize, s32* total_entries) { return ::usbHsQueryAllInterfaces(filter, interfaces, interfaces_maxsize, total_entries); } +Result HsQueryAvailableInterfaces(const UsbHsInterfaceFilter* filter, UsbHsInterface* interfaces, size_t interfaces_maxsize, s32* total_entries) { return ::usbHsQueryAvailableInterfaces(filter, interfaces, interfaces_maxsize, total_entries); } +Result HsQueryAcquiredInterfaces(UsbHsInterface* interfaces, size_t interfaces_maxsize, s32* total_entries) { return ::usbHsQueryAcquiredInterfaces(interfaces, interfaces_maxsize, total_entries); } +Result HsCreateInterfaceAvailableEvent(Event* out_event, bool autoclear, u8 index, const UsbHsInterfaceFilter* filter) { return ::usbHsCreateInterfaceAvailableEvent(out_event, autoclear, index, filter); } +Result HsDestroyInterfaceAvailableEvent(Event* event, u8 index) { return ::usbHsDestroyInterfaceAvailableEvent(event, index); } +Result HsAcquireUsbIf(UsbHsClientIfSession* s, UsbHsInterface *interface) { return ::usbHsAcquireUsbIf(s, interface); } +void HsIfClose(UsbHsClientIfSession* s) { ::usbHsIfClose(s); } +bool HsIfIsActive(UsbHsClientIfSession* s) { return ::usbHsIfIsActive(s); } +s32 HsIfGetID(UsbHsClientIfSession* s) { return ::usbHsIfGetID(s); } +Result HsIfSetInterface(UsbHsClientIfSession* s, UsbHsInterfaceInfo* inf, u8 id) { return ::usbHsIfSetInterface(s, inf, id); } +Result HsIfGetInterface(UsbHsClientIfSession* s, UsbHsInterfaceInfo* inf) { return ::usbHsIfGetInterface(s, inf); } +Result HsIfGetAlternateInterface(UsbHsClientIfSession* s, UsbHsInterfaceInfo* inf, u8 id) { return ::usbHsIfGetAlternateInterface(s, inf, id); } +Result HsIfGetCurrentFrame(UsbHsClientIfSession* s, u32* out) { return ::usbHsIfGetCurrentFrame(s, out); } +Result HsIfCtrlXfer(UsbHsClientIfSession* s, u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, void* buffer, u32* transferredSize) { return ::usbHsIfCtrlXfer(s, bmRequestType, bRequest, wValue, wIndex, wLength, buffer, transferredSize); } +Result HsIfOpenUsbEp(UsbHsClientIfSession* s, UsbHsClientEpSession* ep, u16 maxUrbCount, u32 maxXferSize, struct usb_endpoint_descriptor *desc) { return ::usbHsIfOpenUsbEp(s, ep, maxUrbCount, maxXferSize, desc); } +Result HsIfResetDevice(UsbHsClientIfSession* s) { return ::usbHsIfResetDevice(s); } +void HsEpClose(UsbHsClientEpSession* s) { ::usbHsEpClose(s); } +Event* HsEpGetXferEvent(UsbHsClientEpSession* s) { return ::usbHsEpGetXferEvent(s); } +u32 HsEpGetReportRingSize(UsbHsClientEpSession* s) { return ::usbHsEpGetReportRingSize(s); } +Result HsEpPostBufferAsync(UsbHsClientEpSession* s, void* buffer, u32 size, u64 id, u32* xferId) { return ::usbHsEpPostBufferAsync(s, buffer, size, id, xferId); } +Result HsEpGetXferReport(UsbHsClientEpSession* s, UsbHsXferReport* reports, u32 max_reports, u32* count) { return ::usbHsEpGetXferReport(s, reports, max_reports, count); } +Result HsEpPostBuffer(UsbHsClientEpSession* s, void* buffer, u32 size, u32* transferredSize) { return ::usbHsEpPostBuffer(s, buffer, size, transferredSize); } +Result HsEpBatchBufferAsync(UsbHsClientEpSession* s, void* buffer, u32* urbs, u32 urbCount, u64 id, u32 unk1, u32 unk2, u32* xferId) { return ::usbHsEpBatchBufferAsync(s, buffer, urbs, urbCount, id, unk1, unk2, xferId); } +Result HsEpCreateSmmuSpace(UsbHsClientEpSession* s, void* buffer, u32 size) { return ::usbHsEpCreateSmmuSpace(s, buffer, size); } +Result HsEpShareReportRing(UsbHsClientEpSession* s, void* buffer, size_t size) { return ::usbHsEpShareReportRing(s, buffer, size); } + +} // namespace usb + +namespace utf { + +ssize_t DecodeUtf8(uint32_t *out, const uint8_t *in) { return ::decode_utf8(out, in); } +ssize_t DecodeUtf16(uint32_t *out, const uint16_t *in) { return ::decode_utf16(out, in); } +ssize_t EncodeUtf8(uint8_t *out, uint32_t in) { return ::encode_utf8(out, in); } +ssize_t EncodeUtf16(uint16_t *out, uint32_t in) { return ::encode_utf16(out, in); } +ssize_t Utf8ToUtf16(uint16_t *out, const uint8_t *in, size_t len) { return ::utf8_to_utf16(out, in, len); } +ssize_t Utf8ToUtf32(uint32_t *out, const uint8_t *in, size_t len) { return ::utf8_to_utf32(out, in, len); } +ssize_t Utf16ToUtf8(uint8_t *out, const uint16_t *in, size_t len) { return ::utf16_to_utf8(out, in, len); } +ssize_t Utf16ToUtf32(uint32_t *out, const uint16_t *in, size_t len) { return ::utf16_to_utf32(out, in, len); } +ssize_t Utf32ToUtf8(uint8_t *out, const uint32_t *in, size_t len) { return ::utf32_to_utf8(out, in, len); } +ssize_t Utf32ToUtf16(uint16_t *out, const uint32_t *in, size_t len) { return ::utf32_to_utf16(out, in, len); } + +} // namespace utf + +namespace utimer { + +void Create(UTimer* t, u64 interval, TimerType type) { ::utimerCreate(t, interval, type); } +void Start(UTimer* t) { ::utimerStart(t); } +void Stop(UTimer* t) { ::utimerStop(t); } + +} // namespace utimer + +namespace vi { + +Result Initialize(ViServiceType service_type) { return ::viInitialize(service_type); } +void Exit(void) { ::viExit(); } +Service* GetSession_IApplicationDisplayService(void) { return ::viGetSession_IApplicationDisplayService(); } +Service* GetSession_IHOSBinderDriverRelay(void) { return ::viGetSession_IHOSBinderDriverRelay(); } +Service* GetSession_ISystemDisplayService(void) { return ::viGetSession_ISystemDisplayService(); } +Service* GetSession_IManagerDisplayService(void) { return ::viGetSession_IManagerDisplayService(); } +Service* GetSession_IHOSBinderDriverIndirect(void) { return ::viGetSession_IHOSBinderDriverIndirect(); } +Result SetContentVisibility(bool v) { return ::viSetContentVisibility(v); } +Result OpenDisplay(const char *display_name, ViDisplay *display) { return ::viOpenDisplay(display_name, display); } +Result CloseDisplay(ViDisplay *display) { return ::viCloseDisplay(display); } +Result OpenDefaultDisplay(ViDisplay *display) { return ::viOpenDefaultDisplay(display); } +Result GetDisplayResolution(ViDisplay *display, s32 *width, s32 *height) { return ::viGetDisplayResolution(display, width, height); } +Result GetDisplayLogicalResolution(ViDisplay *display, s32 *width, s32 *height) { return ::viGetDisplayLogicalResolution(display, width, height); } +Result SetDisplayMagnification(ViDisplay *display, s32 x, s32 y, s32 width, s32 height) { return ::viSetDisplayMagnification(display, x, y, width, height); } +Result GetDisplayVsyncEvent(ViDisplay *display, Event *event_out) { return ::viGetDisplayVsyncEvent(display, event_out); } +Result SetDisplayPowerState(ViDisplay *display, ViPowerState state) { return ::viSetDisplayPowerState(display, state); } +Result SetDisplayAlpha(ViDisplay *display, float alpha) { return ::viSetDisplayAlpha(display, alpha); } +Result GetZOrderCountMin(ViDisplay *display, s32 *z) { return ::viGetZOrderCountMin(display, z); } +Result GetZOrderCountMax(ViDisplay *display, s32 *z) { return ::viGetZOrderCountMax(display, z); } +Result CreateLayer(const ViDisplay *display, ViLayer *layer) { return ::viCreateLayer(display, layer); } +Result CreateManagedLayer(const ViDisplay *display, ViLayerFlags layer_flags, u64 aruid, u64 *layer_id) { return ::viCreateManagedLayer(display, layer_flags, aruid, layer_id); } +Result SetLayerSize(ViLayer *layer, s32 width, s32 height) { return ::viSetLayerSize(layer, width, height); } +Result SetLayerZ(ViLayer *layer, s32 z) { return ::viSetLayerZ(layer, z); } +Result SetLayerPosition(ViLayer *layer, float x, float y) { return ::viSetLayerPosition(layer, x, y); } +Result CloseLayer(ViLayer *layer) { return ::viCloseLayer(layer); } +Result DestroyManagedLayer(ViLayer *layer) { return ::viDestroyManagedLayer(layer); } +Result SetLayerScalingMode(ViLayer *layer, ViScalingMode scaling_mode) { return ::viSetLayerScalingMode(layer, scaling_mode); } +Result GetIndirectLayerImageMap(void* buffer, size_t size, s32 width, s32 height, u64 IndirectLayerConsumerHandle, u64 *out_size, u64 *out_stride) { return ::viGetIndirectLayerImageMap(buffer, size, width, height, IndirectLayerConsumerHandle, out_size, out_stride); } +Result GetIndirectLayerImageRequiredMemoryInfo(s32 width, s32 height, u64 *out_size, u64 *out_alignment) { return ::viGetIndirectLayerImageRequiredMemoryInfo(width, height, out_size, out_alignment); } +Result ManagerPrepareFatal(void) { return ::viManagerPrepareFatal(); } +Result ManagerShowFatal(void) { return ::viManagerShowFatal(); } +Result ManagerDrawFatalRectangle(s32 x, s32 y, s32 end_x, s32 end_y, ViColorRgba4444 color) { return ::viManagerDrawFatalRectangle(x, y, end_x, end_y, color); } +Result ManagerDrawFatalText32(s32 *out_advance, s32 x, s32 y, const u32 *utf32_codepoints, size_t num_codepoints, float scale_x, float scale_y, PlSharedFontType font_type, ViColorRgba8888 bg_color, ViColorRgba8888 fg_color, s32 initial_advance) { return ::viManagerDrawFatalText32(out_advance, x, y, utf32_codepoints, num_codepoints, scale_x, scale_y, font_type, bg_color, fg_color, initial_advance); } + +} // namespace vi + +namespace virtmem { + +void Lock(void) { ::virtmemLock(); } +void Unlock(void) { ::virtmemUnlock(); } +void* FindAslr(size_t size, size_t guard_size) { return ::virtmemFindAslr(size, guard_size); } +void* FindStack(size_t size, size_t guard_size) { return ::virtmemFindStack(size, guard_size); } +void* FindCodeMemory(size_t size, size_t guard_size) { return ::virtmemFindCodeMemory(size, guard_size); } +VirtmemReservation* AddReservation(void* mem, size_t size) { return ::virtmemAddReservation(mem, size); } +void RemoveReservation(VirtmemReservation* rv) { ::virtmemRemoveReservation(rv); } + +} // namespace virtmem + +namespace wait { + +Result Objects(s32* idx_out, const Waiter* objects, s32 num_objects, u64 timeout) { return ::waitObjects(idx_out, objects, num_objects, timeout); } +Result Handles(s32* idx_out, const Handle* handles, s32 num_handles, u64 timeout) { return ::waitHandles(idx_out, handles, num_handles, timeout); } +Result Single(Waiter w, u64 timeout) { return ::waitSingle(w, timeout); } +Result SingleHandle(Handle h, u64 timeout) { return ::waitSingleHandle(h, timeout); } + +} // namespace wait + +namespace waiter { + +Waiter ForEvent(Event* t) { return ::waiterForEvent(t); } +Waiter ForThread(Thread* t) { return ::waiterForThread(t); } +Waiter ForUEvent(UEvent* e) { return ::waiterForUEvent(e); } +Waiter ForUTimer(UTimer* t) { return ::waiterForUTimer(t); } +Waiter ForHandle(Handle h) { return ::waiterForHandle(h); } + +} // namespace waiter + +namespace web { + +void WifiCreate(WebWifiConfig* config, const char* conntest_url, const char* initial_url, Uuid uuid, u32 rev) { ::webWifiCreate(config, conntest_url, initial_url, uuid, rev); } +Result WifiShow(WebWifiConfig* config, WebWifiReturnValue *out) { return ::webWifiShow(config, out); } +Result PageCreate(WebCommonConfig* config, const char* url) { return ::webPageCreate(config, url); } +Result NewsCreate(WebCommonConfig* config, const char* url) { return ::webNewsCreate(config, url); } +Result YouTubeVideoCreate(WebCommonConfig* config, const char* url) { return ::webYouTubeVideoCreate(config, url); } +Result OfflineCreate(WebCommonConfig* config, WebDocumentKind docKind, u64 id, const char* docPath) { return ::webOfflineCreate(config, docKind, id, docPath); } +Result ShareCreate(WebCommonConfig* config, WebShareStartPage page) { return ::webShareCreate(config, page); } +Result LobbyCreate(WebCommonConfig* config) { return ::webLobbyCreate(config); } +Result ConfigSetCallbackUrl(WebCommonConfig* config, const char* url) { return ::webConfigSetCallbackUrl(config, url); } +Result ConfigSetCallbackableUrl(WebCommonConfig* config, const char* url) { return ::webConfigSetCallbackableUrl(config, url); } +Result ConfigSetWhitelist(WebCommonConfig* config, const char* whitelist) { return ::webConfigSetWhitelist(config, whitelist); } +Result ConfigSetUid(WebCommonConfig* config, AccountUid uid) { return ::webConfigSetUid(config, uid); } +Result ConfigSetAlbumEntry(WebCommonConfig* config, const CapsAlbumEntry *entry) { return ::webConfigSetAlbumEntry(config, entry); } +Result ConfigSetScreenShot(WebCommonConfig* config, bool flag) { return ::webConfigSetScreenShot(config, flag); } +Result ConfigSetEcClientCert(WebCommonConfig* config, bool flag) { return ::webConfigSetEcClientCert(config, flag); } +Result ConfigSetPlayReport(WebCommonConfig* config, bool flag) { return ::webConfigSetPlayReport(config, flag); } +Result ConfigSetBootDisplayKind(WebCommonConfig* config, WebBootDisplayKind kind) { return ::webConfigSetBootDisplayKind(config, kind); } +Result ConfigSetBackgroundKind(WebCommonConfig* config, WebBackgroundKind kind) { return ::webConfigSetBackgroundKind(config, kind); } +Result ConfigSetFooter(WebCommonConfig* config, bool flag) { return ::webConfigSetFooter(config, flag); } +Result ConfigSetPointer(WebCommonConfig* config, bool flag) { return ::webConfigSetPointer(config, flag); } +Result ConfigSetLeftStickMode(WebCommonConfig* config, WebLeftStickMode mode) { return ::webConfigSetLeftStickMode(config, mode); } +Result ConfigSetKeyRepeatFrame(WebCommonConfig* config, s32 inval0, s32 inval1) { return ::webConfigSetKeyRepeatFrame(config, inval0, inval1); } +Result ConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind) { return ::webConfigSetDisplayUrlKind(config, kind); } +Result ConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag) { return ::webConfigSetBootAsMediaPlayer(config, flag); } +Result ConfigSetShopJump(WebCommonConfig* config, bool flag) { return ::webConfigSetShopJump(config, flag); } +Result ConfigSetMediaPlayerUserGestureRestriction(WebCommonConfig* config, bool flag) { return ::webConfigSetMediaPlayerUserGestureRestriction(config, flag); } +Result ConfigSetMediaAutoPlay(WebCommonConfig* config, bool flag) { return ::webConfigSetMediaAutoPlay(config, flag); } +Result ConfigSetLobbyParameter(WebCommonConfig* config, const char* str) { return ::webConfigSetLobbyParameter(config, str); } +Result ConfigSetApplicationAlbumEntry(WebCommonConfig* config, CapsApplicationAlbumEntry *entry) { return ::webConfigSetApplicationAlbumEntry(config, entry); } +Result ConfigSetJsExtension(WebCommonConfig* config, bool flag) { return ::webConfigSetJsExtension(config, flag); } +Result ConfigSetAdditionalCommentText(WebCommonConfig* config, const char* str) { return ::webConfigSetAdditionalCommentText(config, str); } +Result ConfigSetTouchEnabledOnContents(WebCommonConfig* config, bool flag) { return ::webConfigSetTouchEnabledOnContents(config, flag); } +Result ConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char* str) { return ::webConfigSetUserAgentAdditionalString(config, str); } +Result ConfigSetAdditionalMediaData(WebCommonConfig* config, const u8* data, size_t size) { return ::webConfigSetAdditionalMediaData(config, data, size); } +Result ConfigSetMediaPlayerAutoClose(WebCommonConfig* config, bool flag) { return ::webConfigSetMediaPlayerAutoClose(config, flag); } +Result ConfigSetPageCache(WebCommonConfig* config, bool flag) { return ::webConfigSetPageCache(config, flag); } +Result ConfigSetWebAudio(WebCommonConfig* config, bool flag) { return ::webConfigSetWebAudio(config, flag); } +Result ConfigSetFooterFixedKind(WebCommonConfig* config, WebFooterFixedKind kind) { return ::webConfigSetFooterFixedKind(config, kind); } +Result ConfigSetPageFade(WebCommonConfig* config, bool flag) { return ::webConfigSetPageFade(config, flag); } +Result ConfigSetMediaCreatorApplicationRatingAge(WebCommonConfig* config, const s8 *data) { return ::webConfigSetMediaCreatorApplicationRatingAge(config, data); } +Result ConfigSetBootLoadingIcon(WebCommonConfig* config, bool flag) { return ::webConfigSetBootLoadingIcon(config, flag); } +Result ConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag) { return ::webConfigSetPageScrollIndicator(config, flag); } +Result ConfigSetMediaPlayerSpeedControl(WebCommonConfig* config, bool flag) { return ::webConfigSetMediaPlayerSpeedControl(config, flag); } +Result ConfigAddAlbumEntryAndMediaData(WebCommonConfig* config, const CapsAlbumEntry *entry, const u8* data, size_t size) { return ::webConfigAddAlbumEntryAndMediaData(config, entry, data, size); } +Result ConfigSetBootFooterButtonVisible(WebCommonConfig* config, WebFooterButtonId button, bool visible) { return ::webConfigSetBootFooterButtonVisible(config, button, visible); } +Result ConfigSetOverrideWebAudioVolume(WebCommonConfig* config, float value) { return ::webConfigSetOverrideWebAudioVolume(config, value); } +Result ConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value) { return ::webConfigSetOverrideMediaAudioVolume(config, value); } +Result ConfigSetBootMode(WebCommonConfig* config, WebSessionBootMode mode) { return ::webConfigSetBootMode(config, mode); } +Result ConfigSetMediaPlayerUi(WebCommonConfig* config, bool flag) { return ::webConfigSetMediaPlayerUi(config, flag); } +Result ConfigSetTransferMemory(WebCommonConfig* config, bool flag) { return ::webConfigSetTransferMemory(config, flag); } +Result ConfigShow(WebCommonConfig* config, WebCommonReply *out) { return ::webConfigShow(config, out); } +Result ConfigRequestExit(WebCommonConfig* config) { return ::webConfigRequestExit(config); } +Result ReplyGetExitReason(WebCommonReply *reply, WebExitReason *exitReason) { return ::webReplyGetExitReason(reply, exitReason); } +Result ReplyGetLastUrl(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) { return ::webReplyGetLastUrl(reply, outstr, outstr_maxsize, out_size); } +Result ReplyGetSharePostResult(WebCommonReply *reply, u32 *sharePostResult) { return ::webReplyGetSharePostResult(reply, sharePostResult); } +Result ReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) { return ::webReplyGetPostServiceName(reply, outstr, outstr_maxsize, out_size); } +Result ReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) { return ::webReplyGetPostId(reply, outstr, outstr_maxsize, out_size); } +Result ReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag) { return ::webReplyGetMediaPlayerAutoClosedByCompletion(reply, flag); } +void SessionCreate(WebSession *s, WebCommonConfig* config) { ::webSessionCreate(s, config); } +void SessionClose(WebSession *s) { ::webSessionClose(s); } +Result SessionStart(WebSession *s, Event **out_event) { return ::webSessionStart(s, out_event); } +Result SessionWaitForExit(WebSession *s, WebCommonReply *out) { return ::webSessionWaitForExit(s, out); } +Result SessionRequestExit(WebSession *s) { return ::webSessionRequestExit(s); } +Result SessionAppear(WebSession *s, bool *flag) { return ::webSessionAppear(s, flag); } +Result SessionTrySendContentMessage(WebSession *s, const char *content, u32 size, bool *flag) { return ::webSessionTrySendContentMessage(s, content, size, flag); } +Result SessionTryReceiveContentMessage(WebSession *s, char *content, u64 size, u64 *out_size, bool *flag) { return ::webSessionTryReceiveContentMessage(s, content, size, out_size, flag); } + +} // namespace web + +namespace wlaninf { + +Result Initialize(void) { return ::wlaninfInitialize(); } +void Exit(void) { ::wlaninfExit(); } +Service* GetServiceSession(void) { return ::wlaninfGetServiceSession(); } +Result GetState(WlanInfState* out) { return ::wlaninfGetState(out); } +Result GetRSSI(s32* out) { return ::wlaninfGetRSSI(out); } + +} // namespace wlaninf + +} // namespace nx + diff --git a/Source/hoc-clk/overlay/Makefile b/Source/hoc-clk/overlay/Makefile index 9b9be7a2..11427b48 100644 --- a/Source/hoc-clk/overlay/Makefile +++ b/Source/hoc-clk/overlay/Makefile @@ -71,6 +71,8 @@ CFLAGS += -DUI_OVERRIDE_PATH="\"$(UI_OVERRIDE_PATH)\"" CXXFLAGS := $(CFLAGS) -fno-exceptions -std=gnu++23 +switch.o: CXXFLAGS += -fno-lto + ASFLAGS := -g $(ARCH) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),-wrap,__cxa_throw -Wl,-wrap,_Unwind_Resume -Wl,-wrap,__gxx_personality_v0 diff --git a/Source/hoc-clk/overlay/src/ipc.h b/Source/hoc-clk/overlay/src/ipc.h index 7f514aaa..db4a256c 100644 --- a/Source/hoc-clk/overlay/src/ipc.h +++ b/Source/hoc-clk/overlay/src/ipc.h @@ -26,14 +26,14 @@ #pragma once +#include + #if defined(__cplusplus) #include "cpp_util.hpp" extern "C" { #endif -#include - #include #if defined(__cplusplus) diff --git a/Source/hoc-clk/sysmodule/Makefile b/Source/hoc-clk/sysmodule/Makefile index 03b7eb07..6999308e 100644 --- a/Source/hoc-clk/sysmodule/Makefile +++ b/Source/hoc-clk/sysmodule/Makefile @@ -22,7 +22,7 @@ CONFIG_DIR := horizon-oc BUILD := build OUTDIR := out RESOURCES := res -SOURCES := src src/hos src/i2c src/ipc src/board src/display src/tsensor src/mgr src/file src/soc src/mapping src/pwr src/util +SOURCES := src src/hos src/i2c src/ipc src/board src/display src/tsensor src/mgr src/file src/soc src/mapping src/pwr src/util ../common/src DATA := data INCLUDES := ../common/include src/hos src/soc src/i2c src/util src/pwr src/ipc EXEFS_SRC := exefs_src diff --git a/Source/hoc-clk/sysmodule/src/board/board_freq.cpp b/Source/hoc-clk/sysmodule/src/board/board_freq.cpp index 0e8944aa..2af89827 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_freq.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_freq.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include "../display/display_refresh_rate.hpp" @@ -42,6 +42,7 @@ #include "board_name.hpp" #include #include +#include namespace board { static u32 currentInjectedHz = 0; @@ -67,18 +68,18 @@ namespace board { PcvModuleId GetPcvModuleId(HocClkModule hocclkModule) { PcvModuleId pcvModuleId; - Result rc = pcvGetModuleId(&pcvModuleId, GetPcvModule(hocclkModule)); + Result rc = nx::pcv::GetModuleId(&pcvModuleId, GetPcvModule(hocclkModule)); ASSERT_RESULT_OK(rc, "pcvGetModuleId"); return pcvModuleId; } void ClkrstSetHz(ClkrstSession &session, u32 hz) { - ASSERT_RESULT_OK(clkrstSetClockRate(&session, hz), "clkrstSetClockRate"); + ASSERT_RESULT_OK(nx::clkrst::SetClockRate(&session, hz), "clkrstSetClockRate"); } void PcvSetHz(PcvModule moduleID, u32 hz) { - ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate"); + ASSERT_RESULT_OK(nx::pcv::SetClockRate(moduleID, hz), "pcvSetClockRate"); } void HandleCpuUv() { @@ -112,22 +113,22 @@ namespace board { if (HOSSVC_HAS_CLKRST) { ClkrstSession session = {}; - rc = clkrstOpenSession(&session, GetPcvModuleId(module), 3); + rc = nx::clkrst::OpenSession(&session, GetPcvModuleId(module), 3); ASSERT_RESULT_OK(rc, "clkrstOpenSession"); ClkrstSetHz(session, pcvHz); /* Voltage bug workaround. */ if (module == HocClkModule_CPU) { - svcSleepThread(300'000); + nx::svc::SleepThread(300'000); ClkrstSetHz(session, pcvHz); } - clkrstCloseSession(&session); + nx::clkrst::CloseSession(&session); } else { PcvSetHz(GetPcvModule(module), pcvHz); if (module == HocClkModule_CPU) { - svcSleepThread(300'000); + nx::svc::SleepThread(300'000); PcvSetHz(GetPcvModule(module), pcvHz); } } diff --git a/Source/hoc-clk/sysmodule/src/board/board_load.cpp b/Source/hoc-clk/sysmodule/src/board/board_load.cpp index bf814453..f5327e5f 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_load.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_load.cpp @@ -33,8 +33,9 @@ #include #include #include -#include +#include #include +#include #include "../hos/apm_ext.h" #include "board.hpp" @@ -74,7 +75,7 @@ namespace board { gpu_load_array[i++ % gpu_samples_average] = temp; gpuLoad = std::accumulate(&gpu_load_array[0], &gpu_load_array[gpu_samples_average], 0) / gpu_samples_average; } - svcSleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate) + nx::svc::SleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate) } while (true); } diff --git a/Source/hoc-clk/sysmodule/src/board/board_misc.cpp b/Source/hoc-clk/sysmodule/src/board/board_misc.cpp index b2315cf1..fe1bbdfb 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_misc.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_misc.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include namespace board { @@ -50,7 +52,7 @@ namespace board { } fanLevel = static_cast(rotationDuty); - svcSleepThread(300'000'000); + nx::svc::SleepThread(300'000'000); } } diff --git a/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp b/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp index 2bdf42ae..896732a0 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_sensor.cpp @@ -53,7 +53,7 @@ namespace board { u32 gDramMr4Tick = DramMr4PollDivisor; s32 gDramMr4Millis = 30000; /* 4x refresh default */ - s32 PollDramMr4TempMilli() { + [[maybe_unused]] s32 PollDramMr4TempMilli() { u8 mr4 = 0; if (!soc::ReadRamMr4(&mr4)) return 0; /* stock exosphere */ diff --git a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp index 6a1b8639..b4b83867 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp @@ -657,7 +657,7 @@ namespace board { constexpr u32 KNOWN_GOOD_WAR_FREQUENCY = 1'785'000'000; u32 hz = board::GetHz(HocClkModule_CPU); board::SetHz(HocClkModule_CPU, KNOWN_GOOD_WAR_FREQUENCY); - svcSleepThread(5'000'000); + nx::svc::SleepThread(5'000'000); board::SetHz(HocClkModule_CPU, hz); } diff --git a/Source/hoc-clk/sysmodule/src/display/aula.cpp b/Source/hoc-clk/sysmodule/src/display/aula.cpp index bb8e4eca..4d5c720b 100644 --- a/Source/hoc-clk/sysmodule/src/display/aula.cpp +++ b/Source/hoc-clk/sysmodule/src/display/aula.cpp @@ -19,6 +19,7 @@ #include "aula.hpp" #include "common.hpp" +#include // I *think* HOS changes this in some ways, so look into it more @@ -31,7 +32,7 @@ namespace display { DSI(DSI_TRIGGER) = DSI_TRIGGER_HOST; if (wait) - svcSleepThread(wait * 1000); // usleep-equivalant + nx::svc::SleepThread(wait * 1000); // usleep-equivalant } void SetDisplayColorMode(AulaColorMode mode) { diff --git a/Source/hoc-clk/sysmodule/src/display/common.hpp b/Source/hoc-clk/sysmodule/src/display/common.hpp index b88ac496..a96a773d 100644 --- a/Source/hoc-clk/sysmodule/src/display/common.hpp +++ b/Source/hoc-clk/sysmodule/src/display/common.hpp @@ -15,6 +15,9 @@ * along with this program. If not, see . */ +#pragma once +#include + #ifndef _DI_H_ #define _DI_H_ diff --git a/Source/hoc-clk/sysmodule/src/display/display_refresh_rate.cpp b/Source/hoc-clk/sysmodule/src/display/display_refresh_rate.cpp index 50ea9caa..08e35186 100644 --- a/Source/hoc-clk/sysmodule/src/display/display_refresh_rate.cpp +++ b/Source/hoc-clk/sysmodule/src/display/display_refresh_rate.cpp @@ -19,8 +19,9 @@ #include #include #include - +#include #include "display_refresh_rate.hpp" +#include namespace display { #define DSI_CLOCK_HZ 234000000llu @@ -142,7 +143,7 @@ namespace display { #define MIPI_DCS_PRIV_SM_SET_ELVSS 0xB1 dsi[DSI_VIDEO_MODE_CONTROL] = true; - svcSleepThread(20000000); + nx::svc::SleepThread(20000000); dsi[DSI_WR_DATA] = MIPI_DSI_DCS_LONG_WRITE | (5 << 8); dsi[DSI_WR_DATA] = 0x5A5A5AE2; @@ -162,7 +163,7 @@ namespace display { dsi[DSI_TRIGGER] = 0; dsi[DSI_VIDEO_MODE_CONTROL] = false; - svcSleepThread(20000000); + nx::svc::SleepThread(20000000); } void SetDockedState(bool isDocked) { g_config.isDocked = isDocked; @@ -493,11 +494,11 @@ namespace display { if (!g_config.displaySync) { g_wasRetroSuperTurnedOff = false; } else if (g_wasRetroSuperTurnedOff) { - svcSleepThread(2000000000); + nx::svc::SleepThread(2000000000); g_wasRetroSuperTurnedOff = false; } - svcSleepThread(1000000000); + nx::svc::SleepThread(1000000000); uint32_t fd = 0; if (nvOpen(&fd, "/dev/nvdisp-disp0")) { @@ -693,7 +694,7 @@ namespace display { _getDockedHighestRefreshRate(0); g_canChangeRefreshRateDocked = true; } else { - svcSleepThread(1000000000); + nx::svc::SleepThread(1000000000); return false; } } else { diff --git a/Source/hoc-clk/sysmodule/src/file/file_utils.hpp b/Source/hoc-clk/sysmodule/src/file/file_utils.hpp index 1ffc5c27..2f47e2c6 100644 --- a/Source/hoc-clk/sysmodule/src/file/file_utils.hpp +++ b/Source/hoc-clk/sysmodule/src/file/file_utils.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #define FILE_CONFIG_DIR "/config/" CONFIG_DIR #define FILE_CONTEXT_CSV_PATH FILE_CONFIG_DIR "/context.csv" diff --git a/Source/hoc-clk/sysmodule/src/hos/clkrst_ext.cpp b/Source/hoc-clk/sysmodule/src/hos/clkrst_ext.cpp new file mode 100644 index 00000000..6e653444 --- /dev/null +++ b/Source/hoc-clk/sysmodule/src/hos/clkrst_ext.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "clkrst_ext.hpp" + +namespace hos::clkrst { + /// @brief Sets the minimum voltage for a session's module to the one required for @param hz. Does not work with cpu module + /// @param session A ClkrstSession pointer + /// @param hz The hz to set the vmin for + /// @return Result code + Result SetMinimumVoltageClockRate(ClkrstSession *session, u32 hz) { + return serviceDispatchIn(&session->s, 9, hz); + } + + Result GetDvfsTable(ClkrstSession *session, u32 *out_rate_table, s32 in_rate_count, u32 *out_voltage_table, s32 in_voltage_count, s32 *out_count) { + const struct { + s32 rate_count; + s32 voltage_count; + } in = { in_rate_count, in_voltage_count }; + + s32 out = 0; + Result rc = serviceDispatchInOut(&session->s, 11, in, out, + .buffer_attrs = { + SfBufferAttr_Out | SfBufferAttr_HipcAutoSelect, + SfBufferAttr_Out | SfBufferAttr_HipcAutoSelect, + }, + .buffers = { + { out_rate_table, in_rate_count * sizeof(u32) }, + { out_voltage_table, in_voltage_count * sizeof(u32) }, + }, + ); + + if (R_SUCCEEDED(rc) && out_count) { + *out_count = out; + } + + return rc; + } +} // namespace hos::clkrst diff --git a/Source/hoc-clk/sysmodule/src/hos/clkrst_ext.hpp b/Source/hoc-clk/sysmodule/src/hos/clkrst_ext.hpp new file mode 100644 index 00000000..39650641 --- /dev/null +++ b/Source/hoc-clk/sysmodule/src/hos/clkrst_ext.hpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +namespace hos::clkrst { + Result SetMinimumVoltageClockRate(ClkrstSession *session, u32 hz); + Result GetDvfsTable(ClkrstSession *session, u32 *out_rate_table, s32 in_rate_count, u32 *out_voltage_table, s32 in_voltage_count, s32 *out_count); +} // namespace hos::clkrst \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/hos/integrations.cpp b/Source/hoc-clk/sysmodule/src/hos/integrations.cpp index 2398d44b..fc72c455 100644 --- a/Source/hoc-clk/sysmodule/src/hos/integrations.cpp +++ b/Source/hoc-clk/sysmodule/src/hos/integrations.cpp @@ -20,6 +20,7 @@ #include "integrations.hpp" #include "process_management.hpp" #include +#include namespace hos { @@ -41,7 +42,7 @@ namespace hos { } if (i == 66) return false; - svcSleepThread(1'000'000); + nx::svc::SleepThread(1'000'000); } for (int i = 0; i < 67; i++) { @@ -49,7 +50,7 @@ namespace hos { svcCloseHandle(saltysd); return true; } - svcSleepThread(1'000'000); + nx::svc::SleepThread(1'000'000); } return false; diff --git a/Source/hoc-clk/sysmodule/src/hos/process_management.cpp b/Source/hoc-clk/sysmodule/src/hos/process_management.cpp index 7c9e4654..7641e2f0 100644 --- a/Source/hoc-clk/sysmodule/src/hos/process_management.cpp +++ b/Source/hoc-clk/sysmodule/src/hos/process_management.cpp @@ -62,7 +62,7 @@ namespace hos { u64 pid = 0; do { rc = pmdmntGetProcessId(&pid, Qlaunch); - svcSleepThread(50 * 1000000ULL); // 50ms + nx::svc::SleepThread(50 * 1000000ULL); // 50ms } while (R_FAILED(rc)); } diff --git a/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.cpp b/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.cpp index 93222148..e74b1988 100644 --- a/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.cpp +++ b/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.cpp @@ -15,6 +15,7 @@ * */ #include "i2cDrv.h" +#include Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) { // ams::fatal::srv::StopSoundTask::StopSound() @@ -133,7 +134,7 @@ u32 I2c_BuckConverter_GetMvOut(const I2c_BuckConverter_Domain *domain) { return 0u; // Wait 1us - svcSleepThread(1E3); + nx::svc::SleepThread(1E3); if (!domain->por_val || val != domain->por_val) break; @@ -149,7 +150,7 @@ u32 I2c_BuckConverter_GetUvOut(const I2c_BuckConverter_Domain *domain) { return 0u; // Wait 1us - svcSleepThread(1E3); + nx::svc::SleepThread(1E3); if (!domain->por_val || val != domain->por_val) break; @@ -172,7 +173,7 @@ Result I2c_BuckConverter_SetMvOut(const I2c_BuckConverter_Domain *domain, u32 mv return res; // 5ms Ramp delay - svcSleepThread(5E6); + nx::svc::SleepThread(5E6); u8 new_val; res = I2cRead_OutU8(domain->device, domain->reg, &new_val); if (R_FAILED(res)) diff --git a/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.h b/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.h index 3f561045..40f9c4d0 100644 --- a/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.h +++ b/Source/hoc-clk/sysmodule/src/i2c/i2cDrv.h @@ -6,7 +6,7 @@ #pragma once #include - +#include // To use i2c service, sm and i2c should be intialized via smInitialize() and i2cInitialize(). Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val); diff --git a/Source/hoc-clk/sysmodule/src/main.cpp b/Source/hoc-clk/sysmodule/src/main.cpp index 2a785506..f717610c 100644 --- a/Source/hoc-clk/sysmodule/src/main.cpp +++ b/Source/hoc-clk/sysmodule/src/main.cpp @@ -28,7 +28,7 @@ #include #include #include - +#include #include "board/board.hpp" #include "file/config.hpp" #include "file/errors.hpp" @@ -156,7 +156,7 @@ int main(int argc, char **argv) { board::Exit(); file::config::Exit(); file::utils::LogLine("Exiting hoc-clk"); - svcSleepThread(1000000ULL); + nx::svc::SleepThread(1000000ULL); file::utils::Exit(); return 0; diff --git a/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp b/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp index 8c7865e1..230d4190 100644 --- a/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp +++ b/Source/hoc-clk/sysmodule/src/mgr/clock_manager.cpp @@ -45,7 +45,8 @@ #include "clock_manager.hpp" #include "governor.hpp" #include "../i2c/max77620_wdt.hpp" - +#include "../hos/clkrst_ext.hpp" +#include #define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0)) @@ -868,6 +869,7 @@ namespace mgr { } mgr::StartThreads(); + } void Exit() { @@ -914,6 +916,6 @@ namespace mgr { void WaitForNextTick() { i2c::wdt::Pet(); - svcSleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL); + nx::svc::SleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL); } } // namespace mgr diff --git a/Source/hoc-clk/sysmodule/src/mgr/governor.cpp b/Source/hoc-clk/sysmodule/src/mgr/governor.cpp index 8ab39d21..5677249f 100644 --- a/Source/hoc-clk/sysmodule/src/mgr/governor.cpp +++ b/Source/hoc-clk/sysmodule/src/mgr/governor.cpp @@ -140,7 +140,7 @@ namespace mgr { cpuLastHz = 0; gpuDownHoldRemaining = 0; gpuLastHz = 0; - svcSleepThread(pollNs); + nx::svc::SleepThread(pollNs); continue; } @@ -302,14 +302,14 @@ namespace mgr { if (++vrrTick > 50) { vrrTick = 0; board::SetHz(HocClkModule_Display, maxDisplay); - svcSleepThread(50'000'000); + nx::svc::SleepThread(50'000'000); } } } } } - svcSleepThread(pollNs); + nx::svc::SleepThread(pollNs); } } diff --git a/Source/hoc-clk/sysmodule/src/soc/t210.c b/Source/hoc-clk/sysmodule/src/soc/t210.cpp similarity index 98% rename from Source/hoc-clk/sysmodule/src/soc/t210.c rename to Source/hoc-clk/sysmodule/src/soc/t210.cpp index d787976f..4da17e41 100644 --- a/Source/hoc-clk/sysmodule/src/soc/t210.c +++ b/Source/hoc-clk/sysmodule/src/soc/t210.cpp @@ -17,11 +17,13 @@ * along with this program. If not, see . */ -#include "t210.h" +#include "t210.hpp" +#include +#include #define WAIT_NS 1000000000UL -#define usleep(x) svcSleepThread(1000UL * x) +#define usleep(x) (nx::svc::SleepThread(1000UL * x)) #define GPU_TRIM_SYS_GPCPLL_COEFF 0x4 #define GPU_TRIM_SYS_GPCPLL(x) (*(volatile u32 *)(g_gpu_base + 0x137000ul + (x))) diff --git a/Source/hoc-clk/sysmodule/src/soc/t210.h b/Source/hoc-clk/sysmodule/src/soc/t210.hpp similarity index 100% rename from Source/hoc-clk/sysmodule/src/soc/t210.h rename to Source/hoc-clk/sysmodule/src/soc/t210.hpp diff --git a/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp b/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp index b483e8cf..c1190832 100644 --- a/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp +++ b/Source/hoc-clk/sysmodule/src/tsensor/soctherm.cpp @@ -505,7 +505,7 @@ namespace tsensor { } /* Wait for HW recalibration */ - svcSleepThread(25'000); + nx::svc::SleepThread(25'000); temps.cpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) >> 16); temps.gpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) & SENSOR_TEMP1_GPU_TEMP_MASK); @@ -528,7 +528,7 @@ namespace tsensor { WriteReg(carVa, CAR_CLK_SOURCE_TSENSOR, CAR_CLK_SOURCE_TSENSOR_VAL); SetBits(carVa, CAR_CLK_OUT_ENB_V, 0x10); - svcSleepThread(2000); + nx::svc::SleepThread(2000); TSensorSharedCalib sharedCal = {}; CalcSharedCal(&tfuse, &sharedCal, fuseVa);