]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added udsWaitDataAvailable(), based on gspWaitForEvent().
authoryellows8 <yellows8@users.noreply.github.com>
Tue, 5 Apr 2016 16:07:24 +0000 (12:07 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Tue, 5 Apr 2016 16:07:24 +0000 (12:07 -0400)
libctru/include/3ds/services/uds.h
libctru/source/services/uds.c

index 608783b3a1eca327bb5ab1d4de1c3eeebea0c735..a34e6bc86bfe10b35c5eff36964c1332a1ee64d3 100644 (file)
@@ -182,6 +182,15 @@ Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID);
  */
 Result udsUnbind(udsBindContext *bindcontext);
 
+/**
+ * @brief Waits for the bind event to occur, or checks if the event was signalled. This event is signalled every time new data is available via udsPullPacket().
+ * @return Always true. However if wait=false, this will return false if the event wasn't signalled.
+ * @param bindcontext The bind context.
+ * @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 udsWaitDataAvailable(udsBindContext *bindcontext, bool nextEvent, bool wait);
+
 /**
  * @brief Receives data over the network.
  * @param bindcontext Bind context.
index fef849be56449abb998ad8f82e646a7327266987..bce9bb4cf52f9e72d93807c277875ef133e1c2bf 100644 (file)
@@ -458,6 +458,22 @@ Result udsUnbind(udsBindContext *bindcontext)
        return ret;
 }
 
+bool udsWaitDataAvailable(udsBindContext *bindcontext, bool nextEvent, bool wait)
+{
+       bool ret = true;
+       u64 delayvalue = U64_MAX;
+
+       if(!wait)delayvalue = 0;
+
+       if(nextEvent)svcClearEvent(bindcontext->event);
+
+       if(svcWaitSynchronization(bindcontext->event, delayvalue)!=0 && !wait)ret = false;
+
+       if(!nextEvent)svcClearEvent(bindcontext->event);
+
+       return ret;
+}
+
 static Result usd_parsebeacon(u8 *buf, u32 size, udsNetworkScanInfo *networkscan)
 {
        Result ret=0;