diff --git a/libctru/include/3ds/services/uds.h b/libctru/include/3ds/services/uds.h index e04388f..208235e 100644 --- a/libctru/include/3ds/services/uds.h +++ b/libctru/include/3ds/services/uds.h @@ -29,7 +29,7 @@ typedef struct { /// Connection status struct. typedef struct { - u32 event_type; + u32 status; u32 unk_x4[0x28>>2]; u8 id8; u8 pad_x2d[3]; @@ -305,6 +305,14 @@ Result udsSetNewConnectionsBlocked(bool block, bool clients, bool spectators); */ Result udsGetConnectionStatus(udsConnectionStatus *output); +/** + * @brief Waits for the ConnectionStatus event to occur, or checks if the event was signalled. This event is signalled when the data from udsGetConnectionStatus() was updated internally. + * @return Always true. However if wait=false, this will return false if the event wasn't signalled. + * @param nextEvent Whether to discard the current event and wait for the next event. + * @param wait When true this will not return until the event is signalled. When false this checks if the event was signalled without waiting for it. + */ +bool udsWaitConnectionStatusEvent(bool nextEvent, bool wait); + /** * @brief This loads a NodeInfo struct for the specified NetworkNodeID. The broadcast alias can't be used with this. * @param NetworkNodeID Target NetworkNodeID. diff --git a/libctru/source/services/uds.c b/libctru/source/services/uds.c index 788f15d..70d1a74 100644 --- a/libctru/source/services/uds.c +++ b/libctru/source/services/uds.c @@ -389,6 +389,22 @@ Result udsGetConnectionStatus(udsConnectionStatus *output) return ret; } +bool udsWaitConnectionStatusEvent(bool nextEvent, bool wait) +{ + bool ret = true; + u64 delayvalue = U64_MAX; + + if(!wait)delayvalue = 0; + + if(nextEvent)svcClearEvent(__uds_connectionstatus_event); + + if(svcWaitSynchronization(__uds_connectionstatus_event, delayvalue)!=0 && !wait)ret = false; + + if(!nextEvent)svcClearEvent(__uds_connectionstatus_event); + + return ret; +} + Result udsGetNodeInformation(u16 NetworkNodeID, udsNodeInfo *output) { u32* cmdbuf=getThreadCommandBuffer();