From 2836b696bd954da2220cdd12bdc0115744dba4a5 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Tue, 22 Sep 2015 19:12:52 -0700 Subject: [PATCH 1/3] Fix reading accelerometer and gyroscope entries. --- libctru/source/services/hid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libctru/source/services/hid.c b/libctru/source/services/hid.c index 8367e8d..7eeb29d 100644 --- a/libctru/source/services/hid.c +++ b/libctru/source/services/hid.c @@ -149,14 +149,14 @@ void hidScanInput() if(Id>7)Id=7; if(hidCheckSectionUpdateTime(&hidSharedMem[66], Id)==0) { - aVec = *(accelVector*)&hidSharedMem[66 + 8 + Id*2]; + aVec = ((accelVector*)&hidSharedMem[66 + 8])[Id]; } Id = hidSharedMem[86 + 4];//Gyroscope if(Id>31)Id=31; if(hidCheckSectionUpdateTime(&hidSharedMem[86], Id)==0) { - gRate = *(angularRate*)&hidSharedMem[86 + 8 + Id*2]; + gRate = ((angularRate*)&hidSharedMem[86 + 8])[Id]; } } From 31b724a431e94f6946d37112cf416282864227e3 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 24 Sep 2015 04:26:48 -0400 Subject: [PATCH 2/3] Added APT_GetAppletProgramInfo. --- libctru/include/3ds/services/apt.h | 1 + libctru/source/services/apt.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 33de846..133abcb 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -97,6 +97,7 @@ Result APT_Finalize(Handle* handle, NS_APPID appId); Result APT_HardwareResetAsync(Handle* handle); Result APT_Enable(Handle* handle, u32 a); Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid); +Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion); Result APT_PrepareToJumpToHomeMenu(Handle* handle); Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c); Result APT_PrepareToJumpToApplication(Handle* handle, u32 a); diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index 41a5228..644f181 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -798,6 +798,22 @@ Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32 return cmdbuf[1]; } +Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion) +{ + if(!handle)handle=&aptuHandle; + u32* cmdbuf=getThreadCommandBuffer(); + cmdbuf[0]=0x004D0080; //request header code + cmdbuf[1]=id; + cmdbuf[2]=flags; + + Result ret=0; + if((ret=svcSendSyncRequest(*handle)))return ret; + + if(titleversion)*titleversion=cmdbuf[2]; + + return cmdbuf[1]; +} + Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out) { if(!handle)handle=&aptuHandle; From 2b467b48b877b8e4d7b39c871401871f10f95b7b Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 24 Sep 2015 13:04:18 -0400 Subject: [PATCH 3/3] Implemented http service-cmd code for GetResponseHeader. --- libctru/include/3ds/services/httpc.h | 3 ++- libctru/source/services/httpc.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libctru/include/3ds/services/httpc.h b/libctru/include/3ds/services/httpc.h index 6e1c0ed..4a16702 100644 --- a/libctru/include/3ds/services/httpc.h +++ b/libctru/include/3ds/services/httpc.h @@ -23,7 +23,7 @@ Result httpcReceiveData(httpcContext *context, u8* buffer, u32 size); Result httpcGetRequestState(httpcContext *context, httpcReqStatus* out); Result httpcGetDownloadSizeState(httpcContext *context, u32* downloadedsize, u32* contentsize); Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay);//delay isn't used yet. This writes the HTTP status code from the server to out. - +Result httpcGetResponseHeader(httpcContext *context, char* name, char* value, u32 valuebuf_maxsize); Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downloadedsize);//The *entire* content must be downloaded before using httpcCloseContext(), otherwise httpcCloseContext() will hang. //Using the below functions directly is not recommended, use the above functions. See also the http example. @@ -38,5 +38,6 @@ Result HTTPC_BeginRequest(Handle handle, Handle contextHandle); Result HTTPC_ReceiveData(Handle handle, Handle contextHandle, u8* buffer, u32 size); Result HTTPC_GetRequestState(Handle handle, Handle contextHandle, httpcReqStatus* out); Result HTTPC_GetDownloadSizeState(Handle handle, Handle contextHandle, u32* downloadedsize, u32* contentsize); +Result HTTPC_GetResponseHeader(Handle handle, Handle contextHandle, char* name, char* value, u32 valuebuf_maxsize); Result HTTPC_GetResponseStatusCode(Handle handle, Handle contextHandle, u32* out); diff --git a/libctru/source/services/httpc.c b/libctru/source/services/httpc.c index 8b839e8..c8863e8 100644 --- a/libctru/source/services/httpc.c +++ b/libctru/source/services/httpc.c @@ -95,6 +95,11 @@ Result httpcGetDownloadSizeState(httpcContext *context, u32* downloadedsize, u32 return HTTPC_GetDownloadSizeState(context->servhandle, context->httphandle, downloadedsize, contentsize); } +Result httpcGetResponseHeader(httpcContext *context, char* name, char* value, u32 valuebuf_maxsize) +{ + return HTTPC_GetResponseHeader(context->servhandle, context->httphandle, name, value, valuebuf_maxsize); +} + Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay) { return HTTPC_GetResponseStatusCode(context->servhandle, context->httphandle, out); @@ -294,6 +299,27 @@ Result HTTPC_GetDownloadSizeState(Handle handle, Handle contextHandle, u32* down return cmdbuf[1]; } +Result HTTPC_GetResponseHeader(Handle handle, Handle contextHandle, char* name, char* value, u32 valuebuf_maxsize) +{ + u32* cmdbuf=getThreadCommandBuffer(); + + int name_len=strlen(name)+1; + + cmdbuf[0]=0x001e00c4; //request header code + cmdbuf[1]=contextHandle; + cmdbuf[2]=name_len; + cmdbuf[3]=valuebuf_maxsize; + cmdbuf[4]=(name_len<<14)|0xC02; + cmdbuf[5]=(u32)name; + cmdbuf[6]=(valuebuf_maxsize<<4)|0xC; + cmdbuf[7]=(u32)value; + + Result ret=0; + if((ret=svcSendSyncRequest(handle)))return ret; + + return cmdbuf[1]; +} + Result HTTPC_GetResponseStatusCode(Handle handle, Handle contextHandle, u32* out) { u32* cmdbuf=getThreadCommandBuffer();