summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 []