/*---------------------------------------------------------------------------* Project: Horizon File: applet_API.h Copyright (C)2010 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 38552 $ *---------------------------------------------------------------------------*/ #ifndef NN_APPLET_CTR_APPLET_API_H_ #define NN_APPLET_CTR_APPLET_API_H_ #include #include #include #include #include /* Please see man pages for details */ namespace nn { namespace applet { namespace CTR { namespace detail { using namespace nn::applet::CTR; //----Initialization and termination Result Initialize( AppletAttr appletAttr = DEFAULT_APPLET_ATTRIBUTE ); void Enable(bool isSleepEnabled=true); void Lock(void); bool TryLock( nn::fnd::TimeSpan timeout=NO_WAIT); void Unlock(void); int CountRegisteredApplet(void); bool IsRegistered( AppletId appletId ); bool WaitForRegister( AppletId appletId, nn::fnd::TimeSpan span ); bool IsActive(void); void SetActive(void); void SetInactive(void); nn::Result SaveVramSysArea(void); nn::Result RestoreVramSysArea(void); //================ // GPU rights void AssignGpuRight( bool flag=true ); inline void ReleaseGpuRight(void) { AssignGpuRight(false); } bool IsGpuRightGiven(void); //================ // DSP rights void AssignDspRight( bool flag = true ); inline void ReleaseDspRight( void ) { AssignDspRight(false); } //================ // Camera launch control void AssignCameraRight( bool flag = true ); inline void ReleaseCameraRight( void ) { AssignCameraRight(false); } //================ // Attach sharedMemory void AttachTransferMemoryHandle( os::TransferMemoryBlock* transferMemory, nn::Handle handle, size_t size, bit32 otherPermission ); //================ // Send user message to applet Result SendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE, nn::fnd::TimeSpan timeout=WAIT_INFINITE ); Result TrySendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE ); //================ // HOME Button state AppletHomeButtonState GetAbsoluteHomeButtonState(void); void ClearAbsoluteHomeButtonState(void); // Shutdown notification state AppletShutdownState GetShutdownState(void); void ClearShutdownState(void); // Power button click notification AppletPowerButtonState GetPowerButtonState(void); void ClearPowerButtonState(void); // Termination request AppletOrderToCloseState GetOrderToCloseState(void); void ClearOrderToCloseState(void); //================ // Preload library applet Result PreloadLibraryApplet( AppletId id ); // Launch library applet Result PrepareToStartLibraryApplet( AppletId id ); Result StartLibraryApplet( AppletId id, const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ); // Cancel launch Result CancelLibraryApplet( bool isApplicationEnd=false ); Result CancelLibraryAppletIfRegistered( bool isApplicationEnd=false, AppletWakeupState *pWakeupState=NULL ); // Quit the application Result PrepareToCloseApplication( bool isCancelPreload=false ); Result CloseApplication( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ); // Prepare transition to HOME Menu Result PrepareToJumpToHomeMenu(void); Result JumpToHomeMenu( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ); // Application jump Result PrepareToJumpToOtherApplication( ProgramId programId, nn::fs::MediaType mediaType=nn::fs::MEDIA_TYPE_NAND ); Result PrepareToJumpToCallerApplication(void); Result PrepareToJumpToSelfApplication(void); Result JumpToOtherApplication( const u8 pParam[], size_t paramSize, const u8 pHmacBuf[], size_t hmacBufSize ); Result JumpToOtherApplication( const u8 pParam[], const u8 pHmacBuf[] ); Result JumpToCallerApplication( const u8 pParam[], size_t paramSize, const u8 pHmacBuf[], size_t hmacBufSize ); Result JumpToCallerApplication( const u8 pParam[], const u8 pHmacBuf[] ); Result JumpToSelfApplication( const u8 pParam[], size_t paramSize, const u8 pHmacBuf[], size_t hmacBufSize ); Result JumpToSelfApplication( const u8 pParam[], const u8 pHmacBuf[] ); //================ // Receive arguments bool ReceiveDeliverArg( u8 pParam[], size_t paramSize, u8 pHmacBuf[], size_t hmacBufSize, bit32* pUniqueId ); bool ReceiveDeliverArg( u8 pParam[], u8 pHmacBuf[], bit32* pUniqueId ); AppletWakeupState GetInitialWakeupState(void); bool GetInitialParam( AppletId* pSenderId, u8* pParam, size_t paramSize, s32* pReadSize ); //================ Result GetSharedFont(Handle* pHandle, uptr* pAddr); Result GetWirelessRebootInfo(u8* pInfo, size_t size); Result Wrap(void* pWrappedBuffer, const void* pData, size_t dataSize, s32 idOffset, size_t idSize); Result Unwrap(void* pData, const void* pWrapped, size_t wrappedSize, s32 idOffset, size_t idSize); } } } } namespace nn { namespace applet { namespace CTR { using namespace nn::applet::CTR; //================================================================ // Initialization //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline Result Initialize(AppletAttr appletAttr = NN_APPLET_DEFAULT_APPLET_ATTRIBUTE ) { return detail::Initialize( appletAttr ); } /* Please see man pages for details */ inline void Enable(bool isSleepEnabled=true) { detail::Enable(isSleepEnabled); } /* */ //================================================================ // Mutex //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline void Lock(void) { detail::Lock(); } /* Please see man pages for details */ inline bool TryLock(nn::fnd::TimeSpan timeout = NN_APPLET_NO_WAIT) { return detail::TryLock(timeout); } /* Please see man pages for details */ inline void Unlock(void) { detail::Unlock(); } /* */ //================================================================ // Get Information //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline bool ReceiveDeliverArg( u8 pParam[], size_t paramSize, u8 pHmacBuf[], size_t hmacBufSize, bit32* pUniqueId ) { return detail::ReceiveDeliverArg( pParam, paramSize, pHmacBuf, hmacBufSize, pUniqueId ); } inline bool ReceiveDeliverArg( u8 pParam[], u8 pHmacBuf[], bit32* pUniqueId ) { return detail::ReceiveDeliverArg( pParam, pHmacBuf, pUniqueId ); } /* Please see man pages for details */ inline AppletWakeupState GetInitialWakeupState(void) { return detail::GetInitialWakeupState(); } // Get initialization arguments. // (Not yet used) inline bool GetInitialParam( AppletId* pSenderId, u8* pParam, size_t paramSize, s32* pReadSize ) { return detail::GetInitialParam( pSenderId, pParam, paramSize, pReadSize ); } /* Please see man pages for details */ inline int CountRegisteredApplet(void) { return detail::CountRegisteredApplet(); } /* Please see man pages for details */ inline bool IsRegistered( AppletId appletId ) { return detail::IsRegistered( appletId ); } /* Please see man pages for details */ inline bool IsActive(void) { return detail::IsActive(); } /* Please see man pages for details */ inline void SetActive(void) { detail::SetActive(); } /* Please see man pages for details */ inline void SetInactive(void) { detail::SetInactive(); } /* Please see man pages for details */ bool IsInitialized(); /* Please see man pages for details */ AppletId GetId(void); /* Please see man pages for details */ AppletAttr GetAttribute(void); /* */ // :private AppletAttr GetAppletType(void); //================================================================ // Operation control //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline bool WaitForRegister( AppletId appletId, nn::fnd::TimeSpan span = NN_APPLET_WAIT_INFINITE ) { return detail::WaitForRegister( appletId, span ); } //================================================================ // Render rights //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline bool IsGpuRightGiven(void) { return detail::IsGpuRightGiven(); } /* Please see man pages for details */ inline void AssignGpuRight( bool flag = true ) { detail::AssignGpuRight(flag); } /* Please see man pages for details */ inline void ReleaseGpuRight(void) { detail::AssignGpuRight(false); } /* */ //================================================================ // DSP usage rights //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline void AssignDspRight( bool flag = true ) { detail::AssignDspRight(flag); } /* Please see man pages for details */ inline void ReleaseDspRight( void ) { detail::AssignDspRight(false); } /* */ /* Please see man pages for details */ inline void AttachTransferMemoryHandle( os::TransferMemoryBlock* transferMemory, nn::Handle handle, size_t size, bit32 otherPermission ) { detail::AttachTransferMemoryHandle( transferMemory, handle, size, otherPermission ); } //================================================================ // Camera launch control //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline void AssignCameraRight( bool flag = true ) { detail::AssignCameraRight(flag); } /* Please see man pages for details */ inline void ReleaseCameraRight( void ) { detail::AssignCameraRight(false); } /* */ //================================================================ // Message //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline Result SendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE, nn::fnd::TimeSpan timeout=WAIT_INFINITE ) { return detail::SendMessage( receiverId, pParam, paramSize, handle, timeout ); } /* Please see man pages for details */ inline Result TrySendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE ) { return detail::TrySendMessage( receiverId, pParam, paramSize, handle ); } /* */ /* Please see man pages for details */ inline AppletHomeButtonState GetAbsoluteHomeButtonState(void) { return detail::GetAbsoluteHomeButtonState(); } /* Please see man pages for details */ inline void ClearAbsoluteHomeButtonState(void) { return detail::ClearAbsoluteHomeButtonState(); } //================================================================ // shutdown //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline AppletShutdownState GetShutdownState(void) { return detail::GetShutdownState(); } /* Please see man pages for details */ inline void ClearShutdownState(void) { detail::ClearShutdownState(); } /* */ //================================================================ // Power Button //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline AppletPowerButtonState GetPowerButtonState(void) { return detail::GetPowerButtonState(); } /* Please see man pages for details */ inline void ClearPowerButtonState(void) { detail::ClearPowerButtonState(); } bool IsReceivedWakeupByCancel(void); /* Please see man pages for details */ inline bool IsExpectedToProcessPowerButton(void) { return ( GetPowerButtonState() != POWER_BUTTON_STATE_NONE )? true: false; } /* */ //================================================================ // Termination request //================================================================ inline AppletOrderToCloseState GetOrderToCloseState(void) { return detail::GetOrderToCloseState(); } inline void ClearOrderToCloseState(void) { detail::ClearOrderToCloseState(); } /* Please see man pages for details */ /* Please see man pages for details */ inline bool IsExpectedToCloseApplication(void) { return ( GetOrderToCloseState() != ORDER_TO_CLOSE_STATE_NONE || IsReceivedWakeupByCancel() )? true: false; } //================================================================ // Preload and terminate library applet //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline Result PreloadLibraryApplet( AppletId id ) { return detail::PreloadLibraryApplet(id); } /* */ /* Please see man pages for details */ inline Result CancelLibraryAppletIfRegistered( bool isApplicationEnd, AppletWakeupState *pWakeupState=NULL ) { return detail::CancelLibraryAppletIfRegistered( isApplicationEnd, pWakeupState ); } /* */ //================================================================ // Library applet/launch //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline Result PrepareToStartLibraryApplet( AppletId id ) { return detail::PrepareToStartLibraryApplet(id); } /* Please see man pages for details */ inline Result StartLibraryApplet( AppletId id, const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ) { return detail::StartLibraryApplet(id, pParam, paramSize, handle); } /* */ //================================================================ // Quit the application //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline Result PrepareToCloseApplication(void) { return detail::PrepareToCloseApplication(); } /* Please see man pages for details */ inline Result CloseApplication( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ) { return detail::CloseApplication( pParam, paramSize, handle ); } /* */ // Obsolete function. inline Result PrepareToClosePreloadedApplication(void) { return detail::PrepareToCloseApplication( true ); } inline Result ClosePreloadedApplication( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ) { return detail::CloseApplication( pParam, paramSize, handle ); } //================================================================ // Home menu //================================================================ /* Please see man pages for details */ /* Please see man pages for details */ inline Result PrepareToJumpToHomeMenu(void) { return detail::PrepareToJumpToHomeMenu(); } /* Please see man pages for details */ inline Result JumpToHomeMenu( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE ) { return detail::JumpToHomeMenu( pParam, paramSize, handle ); } /* */ //================================================================ // Application jump //================================================================ /* Please see man pages for details */ inline Result PrepareToJumpToOtherApplication( ProgramId programId, nn::fs::MediaType mediaType=nn::fs::MEDIA_TYPE_NAND ) { return detail::PrepareToJumpToOtherApplication( programId, mediaType ); } inline Result PrepareToJumpToCallerApplication(void) { return detail::PrepareToJumpToCallerApplication(); } inline Result PrepareToJumpToSelfApplication(void) { return detail::PrepareToJumpToSelfApplication(); } /* Please see man pages for details */ inline Result JumpToOtherApplication( const u8 pParam[], size_t paramSize, const u8 pHmacBuf[], size_t hmacBufSize ) { return detail::JumpToOtherApplication( pParam, paramSize, pHmacBuf, hmacBufSize ); } inline Result JumpToOtherApplication( const u8 pParam[]=NULL, const u8 pHmacBuf[]=NULL ) { return detail::JumpToOtherApplication( pParam, pHmacBuf ); } /* Please see man pages for details */ inline Result JumpToCallerApplication( const u8 pParam[], size_t paramSize, const u8 pHmacBuf[], size_t hmacBufSize ) { return detail::JumpToCallerApplication( pParam, paramSize, pHmacBuf, hmacBufSize ); } inline Result JumpToCallerApplication( const u8 pParam[]=NULL, const u8 pHmacBuf[]=NULL ) { return detail::JumpToCallerApplication( pParam, pHmacBuf ); } /* Please see man pages for details */ inline Result JumpToSelfApplication( const u8 pParam[], size_t paramSize, const u8 pHmacBuf[], size_t hmacBufSize ) { return detail::JumpToSelfApplication( pParam, paramSize, pHmacBuf, hmacBufSize ); } inline Result JumpToSelfApplication( const u8 pParam[]=NULL, const u8 pHmacBuf[]=NULL ) { return detail::JumpToSelfApplication( pParam, pHmacBuf ); } /* */ //================================================================ // non-public //================================================================ /* Please see man pages for details */ inline nn::Result SaveVramSysArea(void) { return detail::SaveVramSysArea(); } /* Please see man pages for details */ inline nn::Result RestoreVramSysArea(void) { return detail::RestoreVramSysArea(); } /* */ /* Please see man pages for details */ bool IsApplicationExisting( u32 titleCode, u32 flag ); } } } /* Please see man pages for details */ #include /* Please see man pages for details */ NN_EXTERN_C inline nn::Result nnappletInitialize( AppletAttr appletAttr = NN_APPLET_DEFAULT_APPLET_ATTRIBUTE) { return nn::applet::CTR::Initialize(appletAttr); } /* Please see man pages for details */ NN_EXTERN_C inline void nnappletLock(void) { nn::applet::CTR::Lock(); } /* Please see man pages for details */ NN_EXTERN_C inline bool nnappletTryLock(nn::fnd::TimeSpan timeout=NN_APPLET_NO_WAIT) { return nn::applet::CTR::TryLock(timeout); } /* Please see man pages for details */ NN_EXTERN_C inline void nnappletUnlock(void) { nn::applet::CTR::Unlock(); } //---------------------------------------------------------------- /* Please see man pages for details */ NN_EXTERN_C inline int nnappletCountRegisteredApplet(void) { return nn::applet::CTR::CountRegisteredApplet(); } /* Please see man pages for details */ NN_EXTERN_C inline bool nnappletIsRegistered( AppletId appletId ) { return nn::applet::CTR::IsRegistered( appletId ); } NN_EXTERN_C inline bool nnappletWaitForRegister( AppletId appletId, nn::fnd::TimeSpan span=NN_APPLET_WAIT_INFINITE ) { return nn::applet::CTR::WaitForRegister( appletId, span ); } /* Please see man pages for details */ NN_EXTERN_C inline bool nnappletIsActive(void) { return nn::applet::CTR::IsActive(); } NN_EXTERN_C inline void nnappletAssignGpuRight(bool flag=true) { nn::applet::CTR::AssignGpuRight(flag); } NN_EXTERN_C inline void nnappletReleaseGpuRight(void) { nn::applet::CTR::AssignGpuRight(false); } /* Please see man pages for details */ NN_EXTERN_C inline bool nnappletIsGpuRightGiven(void) { return nn::applet::CTR::IsGpuRightGiven(); } NN_EXTERN_C inline void nnappletAttachTransferMemoryHandle( nn::os::TransferMemoryBlock* transferMemory, nn::Handle handle, size_t size, bit32 otherPermission ) { nn::applet::CTR::AttachTransferMemoryHandle( transferMemory, handle, size, otherPermission ); } /* */ #endif // ifndef NN_APPLET_CTR_APPLET_API_H_