]> Chaos Git - corbenik/ctrulib.git/commitdiff
APT && HID && GSP : don't ignore errors yo
authorsmea <smealum@gmail.com>
Mon, 17 Mar 2014 17:38:20 +0000 (18:38 +0100)
committersmea <smealum@gmail.com>
Mon, 17 Mar 2014 17:38:20 +0000 (18:38 +0100)
libctru/include/ctr/APT.h
libctru/include/ctr/GSP.h
libctru/include/ctr/HID.h
libctru/source/APT.c
libctru/source/GSP.c
libctru/source/HID.c

index 505d7cda0970507353bfb3ed91bb0a05a833badd..06a24f9e0fbaf5d1e832a26985b0e7bde2812626 100644 (file)
@@ -16,7 +16,7 @@ typedef enum{
 
 extern Handle aptEvents[3];
 
-void aptInit(NS_APPID appID);
+Result aptInit(NS_APPID appID);
 void aptExit();
 void aptOpenSession();
 void aptCloseSession();
index db31ab18e04a4935bb36ceb44990decb888699b8..b38bd23767ce5bedb0d9fb84218fa703c2d95640 100644 (file)
@@ -3,7 +3,7 @@
 
 #define GSP_REBASE_REG(r) ((r)-0x1EB00000)
 
-void gspInit();
+Result gspInit();
 void gspExit();
 
 Result GSPGPU_AcquireRight(Handle *handle, u8 flags);
index 7487651023ca4a390e7fd82983ae299313df0910..79a5e8a360048036a6ffe6e0bfcf2f9177405f5e 100644 (file)
@@ -28,10 +28,10 @@ typedef enum
 extern Handle hidMemHandle;
 extern vu32* hidSharedMem;
 
-void hidInit(u32* sharedMem);
+Result hidInit(u32* sharedMem);
 void hidExit();
 
 Result HIDUSER_GetInfo(Handle* handle, Handle* outMemHandle);
-Result HIDUSER_Init(Handle* handle);
+Result HIDUSER_EnableAccelerometer(Handle* handle);
 
 #endif
index 753219d6c84c287433da4b74354d95a55ef5f0da..63ece7f7655e5a4935808ebf4154ff50190fb166 100644 (file)
@@ -94,26 +94,30 @@ void aptEventHandler(u32 arg)
        svc_exitThread();
 }
 
-void aptInit(NS_APPID appID)
+Result aptInit(NS_APPID appID)
 {
+       Result ret=0;
+
        //initialize APT stuff, escape load screen
        srv_getServiceHandle(NULL, &aptuHandle, "APT:U");
-       APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle);
+       if((ret=APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle)))return ret;
        svc_closeHandle(aptuHandle);
 
        currentAppId=appID;
 
        aptOpenSession();
-       APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1]);
+       if((ret=APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
        aptCloseSession();
        
        aptOpenSession();
-       APT_Enable(NULL, 0x0);
+       if((ret=APT_Enable(NULL, 0x0)))return ret;
        aptCloseSession();
        
        aptOpenSession();
-       APT_NotifyToWait(NULL, currentAppId);
+       if((ret=APT_NotifyToWait(NULL, currentAppId)))return ret;
        aptCloseSession();
+       
+       return 0;
 }
 
 void aptExit()
index 310707ad9a4c988fda692a8a864080e39d765fb5..8e59b0d92d77e59e739b94171f8f9c2d16a719fa 100644 (file)
@@ -8,10 +8,9 @@
 
 Handle gspGpuHandle=0;
 
-void gspInit()
+Result gspInit()
 {
-       //do stuff with GPU...
-       srv_getServiceHandle(NULL, &gspGpuHandle, "gsp::Gpu");
+       return srv_getServiceHandle(NULL, &gspGpuHandle, "gsp::Gpu");
 }
 
 void gspExit()
index 58eaf5fdc5936e3e5caae74dc225312d29954706..c94d2c18ac906ba496adca19b80e6945d97b0844 100644 (file)
@@ -11,17 +11,20 @@ Handle hidMemHandle;
 
 vu32* hidSharedMem;
 
-void hidInit(u32* sharedMem)
+Result hidInit(u32* sharedMem)
 {
        if(!sharedMem)sharedMem=(u32*)HID_SHAREDMEM_DEFAULT;
+       Result ret=0;
 
-       srv_getServiceHandle(NULL, &hidHandle, "hid:USER");
+       if((ret=srv_getServiceHandle(NULL, &hidHandle, "hid:USER")))return ret;
        
-       HIDUSER_GetInfo(NULL, &hidMemHandle);
+       if((ret=HIDUSER_GetInfo(NULL, &hidMemHandle)))return ret;
        hidSharedMem=sharedMem;
        svc_mapMemoryBlock(hidMemHandle, (u32)hidSharedMem, 0x1, 0x10000000);
 
-       HIDUSER_Init(NULL);
+       if((ret=HIDUSER_EnableAccelerometer(NULL)))return ret;
+
+       return 0;
 }
 
 void hidExit()
@@ -45,7 +48,7 @@ Result HIDUSER_GetInfo(Handle* handle, Handle* outMemHandle)
        return cmdbuf[1];
 }
 
-Result HIDUSER_Init(Handle* handle)
+Result HIDUSER_EnableAccelerometer(Handle* handle)
 {
        if(!handle)handle=&hidHandle;
        u32* cmdbuf=getThreadCommandBuffer();