summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-04-07 13:27:10 +0200
committerMatthias Schiffer <matthias@gamezock.de>2010-04-07 13:27:10 +0200
commit1bd17e699320099996a4ee7f31acf20c3bab135b (patch)
tree6e648c107fc8cb09595967635e31b5d44e658427
parent1b4d7204a8f0842dd0cde5c79e124dd21508526a (diff)
downloadhwiid-1bd17e699320099996a4ee7f31acf20c3bab135b.tar
hwiid-1bd17e699320099996a4ee7f31acf20c3bab135b.zip
Corrected nonblocking messages
-rw-r--r--src/HWiid.hsc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/HWiid.hsc b/src/HWiid.hsc
index 994aca1..56d87c6 100644
--- a/src/HWiid.hsc
+++ b/src/HWiid.hsc
@@ -27,6 +27,8 @@ module HWiid ( BDAddr(..)
, hwiidButtonPlus
, hwiidNunchukButtonZ
, hwiidNunchukButtonC
+ , hwiidMesgTypeStatus
+ , hwiidMesgTypeButton
, hwiidOpen
, hwiidOpenTimeout
, hwiidClose
@@ -48,7 +50,6 @@ import Foreign.Ptr
import Foreign.Storable
import System.Posix.Clock (TimeSpec)
-
#include <cwiid.h>
hwiidFlagMesgInterface :: CInt
@@ -244,11 +245,12 @@ foreign import ccall unsafe "cwiid.h cwiid_get_mesg"
hwiidGetMesg :: Wiimote -> IO [WiimoteMesg]
hwiidGetMesg wiimote = alloca $ \countptr -> alloca $ \arrayptr -> alloca $ \timestamp -> do
- cwiid_get_mesg wiimote countptr arrayptr timestamp
+ ret <- cwiid_get_mesg wiimote countptr arrayptr timestamp
count <- peek countptr
array <- peek arrayptr
- ret <- peekArray (fromIntegral count) array
- free array
-
- return ret \ No newline at end of file
+ if (ret == 0) then do
+ list <- peekArray (fromIntegral count) array
+ free array
+ return list
+ else return []