summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-04-10 15:43:20 +0200
committerMatthias Schiffer <matthias@gamezock.de>2010-04-10 15:43:20 +0200
commit0dfe13e11fbf12e120e9f626d2f6ba5a5764159a (patch)
tree74c2cebda9b81301bfb4873b9d9225418a2cf06a
parent1a31573eb8b6a6c02536279d77f6232981155958 (diff)
downloadhwiid-master.tar
hwiid-master.zip
Renamed most functionsHEADmaster
-rw-r--r--src/HWiid.hsc260
1 files changed, 130 insertions, 130 deletions
diff --git a/src/HWiid.hsc b/src/HWiid.hsc
index 46340b3..1d9d4c6 100644
--- a/src/HWiid.hsc
+++ b/src/HWiid.hsc
@@ -11,45 +11,45 @@ module HWiid ( BDAddr(..)
, WiimoteAccCal(..)
, nullWiimote
, bdAddrAny
- , hwiidFlagMesgInterface
- , hwiidFlagNonblock
- , hwiidReportStatus
- , hwiidReportButtons
- , hwiidReportAcc
- , hwiidReportIR
- , hwiidReportNunchuk
- , hwiidReportExt
- , hwiidLed1
- , hwiidLed2
- , hwiidLed3
- , hwiidLed4
- , hwiidButton2
- , hwiidButton1
- , hwiidButtonB
- , hwiidButtonA
- , hwiidButtonMinus
- , hwiidButtonHome
- , hwiidButtonLeft
- , hwiidButtonRight
- , hwiidButtonDown
- , hwiidButtonUp
- , hwiidButtonPlus
- , hwiidNunchukButtonZ
- , hwiidNunchukButtonC
- , hwiidIRMaxX
- , hwiidIRMaxY
- , hwiidMesgTypeStatus
- , hwiidMesgTypeButton
- , hwiidExtNone
- , hwiidExtNunchuk
- , hwiidOpen
- , hwiidOpenTimeout
- , hwiidClose
- , hwiidGetState
- , hwiidSetReportMode
- , hwiidSetLed
- , hwiidGetMesg
- , hwiidGetAccCal
+ , flagMesgInterface
+ , flagNonblock
+ , reportStatus
+ , reportButtons
+ , reportAcc
+ , reportIR
+ , reportNunchuk
+ , reportExt
+ , led1
+ , led2
+ , led3
+ , led4
+ , button2
+ , button1
+ , buttonB
+ , buttonA
+ , buttonMinus
+ , buttonHome
+ , buttonLeft
+ , buttonRight
+ , buttonDown
+ , buttonUp
+ , buttonPlus
+ , nunchukButtonZ
+ , nunchukButtonC
+ , irMaxX
+ , irMaxY
+ , mesgTypeStatus
+ , mesgTypeButton
+ , extNone
+ , extNunchuk
+ , open
+ , openTimeout
+ , close
+ , getState
+ , setReportMode
+ , setLed
+ , getMesg
+ , getAccCal
) where
@@ -67,109 +67,109 @@ import System.Posix.Clock (TimeSpec)
#include <cwiid.h>
-hwiidFlagMesgInterface :: CInt
-hwiidFlagMesgInterface = (#const CWIID_FLAG_MESG_IFC)
+flagMesgInterface :: CInt
+flagMesgInterface = (#const CWIID_FLAG_MESG_IFC)
-hwiidFlagNonblock :: CInt
-hwiidFlagNonblock = (#const CWIID_FLAG_NONBLOCK)
+flagNonblock :: CInt
+flagNonblock = (#const CWIID_FLAG_NONBLOCK)
-hwiidReportStatus :: Word8
-hwiidReportStatus = (#const CWIID_RPT_STATUS)
+reportStatus :: Word8
+reportStatus = (#const CWIID_RPT_STATUS)
-hwiidReportButtons :: Word8
-hwiidReportButtons = (#const CWIID_RPT_BTN)
+reportButtons :: Word8
+reportButtons = (#const CWIID_RPT_BTN)
-hwiidReportAcc :: Word8
-hwiidReportAcc = (#const CWIID_RPT_ACC)
+reportAcc :: Word8
+reportAcc = (#const CWIID_RPT_ACC)
-hwiidReportIR :: Word8
-hwiidReportIR = (#const CWIID_RPT_IR)
+reportIR :: Word8
+reportIR = (#const CWIID_RPT_IR)
-hwiidReportNunchuk :: Word8
-hwiidReportNunchuk = (#const CWIID_RPT_NUNCHUK)
+reportNunchuk :: Word8
+reportNunchuk = (#const CWIID_RPT_NUNCHUK)
-hwiidReportExt :: Word8
-hwiidReportExt = hwiidReportNunchuk
+reportExt :: Word8
+reportExt = reportNunchuk
-hwiidLed1 :: Word8
-hwiidLed1 = (#const CWIID_LED1_ON)
+led1 :: Word8
+led1 = (#const CWIID_LED1_ON)
-hwiidLed2 :: Word8
-hwiidLed2 = (#const CWIID_LED2_ON)
+led2 :: Word8
+led2 = (#const CWIID_LED2_ON)
-hwiidLed3 :: Word8
-hwiidLed3 = (#const CWIID_LED3_ON)
+led3 :: Word8
+led3 = (#const CWIID_LED3_ON)
-hwiidLed4 :: Word8
-hwiidLed4 = (#const CWIID_LED4_ON)
+led4 :: Word8
+led4 = (#const CWIID_LED4_ON)
-hwiidButton2 :: Word16
-hwiidButton2 = (#const CWIID_BTN_2)
+button2 :: Word16
+button2 = (#const CWIID_BTN_2)
-hwiidButton1 :: Word16
-hwiidButton1 = (#const CWIID_BTN_1)
+button1 :: Word16
+button1 = (#const CWIID_BTN_1)
-hwiidButtonB :: Word16
-hwiidButtonB = (#const CWIID_BTN_B)
+buttonB :: Word16
+buttonB = (#const CWIID_BTN_B)
-hwiidButtonA :: Word16
-hwiidButtonA = (#const CWIID_BTN_A)
+buttonA :: Word16
+buttonA = (#const CWIID_BTN_A)
-hwiidButtonMinus :: Word16
-hwiidButtonMinus = (#const CWIID_BTN_MINUS)
+buttonMinus :: Word16
+buttonMinus = (#const CWIID_BTN_MINUS)
-hwiidButtonHome :: Word16
-hwiidButtonHome = (#const CWIID_BTN_HOME)
+buttonHome :: Word16
+buttonHome = (#const CWIID_BTN_HOME)
-hwiidButtonLeft :: Word16
-hwiidButtonLeft = (#const CWIID_BTN_LEFT)
+buttonLeft :: Word16
+buttonLeft = (#const CWIID_BTN_LEFT)
-hwiidButtonRight :: Word16
-hwiidButtonRight = (#const CWIID_BTN_RIGHT)
+buttonRight :: Word16
+buttonRight = (#const CWIID_BTN_RIGHT)
-hwiidButtonDown :: Word16
-hwiidButtonDown = (#const CWIID_BTN_DOWN)
+buttonDown :: Word16
+buttonDown = (#const CWIID_BTN_DOWN)
-hwiidButtonUp :: Word16
-hwiidButtonUp = (#const CWIID_BTN_UP)
+buttonUp :: Word16
+buttonUp = (#const CWIID_BTN_UP)
-hwiidButtonPlus :: Word16
-hwiidButtonPlus = (#const CWIID_BTN_PLUS)
+buttonPlus :: Word16
+buttonPlus = (#const CWIID_BTN_PLUS)
-hwiidNunchukButtonZ :: Word16
-hwiidNunchukButtonZ = (#const CWIID_NUNCHUK_BTN_Z)
+nunchukButtonZ :: Word16
+nunchukButtonZ = (#const CWIID_NUNCHUK_BTN_Z)
-hwiidNunchukButtonC :: Word16
-hwiidNunchukButtonC = (#const CWIID_NUNCHUK_BTN_C)
+nunchukButtonC :: Word16
+nunchukButtonC = (#const CWIID_NUNCHUK_BTN_C)
-hwiidIRMaxX :: CInt
-hwiidIRMaxX = (#const CWIID_IR_X_MAX)
+irMaxX :: CInt
+irMaxX = (#const CWIID_IR_X_MAX)
-hwiidIRMaxY :: CInt
-hwiidIRMaxY = (#const CWIID_IR_Y_MAX)
+irMaxY :: CInt
+irMaxY = (#const CWIID_IR_Y_MAX)
type WiimoteMesgType = (#type enum cwiid_mesg_type)
-hwiidMesgTypeStatus :: WiimoteMesgType
-hwiidMesgTypeStatus = (#const CWIID_MESG_STATUS)
+mesgTypeStatus :: WiimoteMesgType
+mesgTypeStatus = (#const CWIID_MESG_STATUS)
-hwiidMesgTypeButton :: WiimoteMesgType
-hwiidMesgTypeButton = (#const CWIID_MESG_BTN)
+mesgTypeButton :: WiimoteMesgType
+mesgTypeButton = (#const CWIID_MESG_BTN)
type WiimoteExtType = (#type enum cwiid_ext_type)
-hwiidExtNone :: WiimoteExtType
-hwiidExtNone = (#const CWIID_EXT_NONE)
+extNone :: WiimoteExtType
+extNone = (#const CWIID_EXT_NONE)
-hwiidExtNunchuk :: WiimoteExtType
-hwiidExtNunchuk = (#const CWIID_EXT_NUNCHUK)
+extNunchuk :: WiimoteExtType
+extNunchuk = (#const CWIID_EXT_NUNCHUK)
data BDAddr = BDAddr (Word8, Word8, Word8, Word8, Word8, Word8)
@@ -272,10 +272,10 @@ instance Storable WiimoteMesg where
mesgtype <- (#peek union cwiid_mesg, type) mesg
case () of
- _ | mesgtype == hwiidMesgTypeStatus -> do
+ _ | mesgtype == mesgTypeStatus -> do
battery <- (#peek struct cwiid_status_mesg, battery) mesg
return $ WiimoteStatusMesg mesgtype battery
- | mesgtype == hwiidMesgTypeButton -> do
+ | mesgtype == mesgTypeButton -> do
buttons <- (#peek struct cwiid_btn_mesg, buttons) mesg
return $ WiimoteButtonMesg mesgtype buttons
| otherwise -> return $ WiimoteMesgOther mesgtype
@@ -297,7 +297,7 @@ data WiimoteExtState = WiimoteNunchukState
peekExtState :: WiimoteExtType -> Ptr WiimoteExtState -> IO WiimoteExtState
peekExtState exttype state
- | exttype == hwiidExtNunchuk = do
+ | exttype == extNunchuk = do
posx <- (#peek struct nunchuk_state, stick[0]) state
posy <- (#peek struct nunchuk_state, stick[1]) state
buttons <- (#peek struct nunchuk_state, buttons) state
@@ -341,50 +341,50 @@ nullWiimote = Wiimote nullPtr
foreign import ccall unsafe "cwiid.h cwiid_open_timeout"
cwiid_open_timeout :: Ptr BDAddr -> CInt -> CInt -> IO Wiimote
-hwiidOpenTimeout :: BDAddr -> CInt -> CInt -> IO Wiimote
-hwiidOpenTimeout addr flags timeout = with addr $ \addrptr -> cwiid_open_timeout addrptr flags timeout
+openTimeout :: BDAddr -> CInt -> CInt -> IO Wiimote
+openTimeout addr flags timeout = with addr $ \addrptr -> cwiid_open_timeout addrptr flags timeout
defaultTimeout :: CInt
defaultTimeout = 5
-hwiidOpen :: BDAddr -> CInt -> IO Wiimote
-hwiidOpen addr flags = hwiidOpenTimeout addr flags defaultTimeout
+open :: BDAddr -> CInt -> IO Wiimote
+open addr flags = openTimeout addr flags defaultTimeout
foreign import ccall unsafe "cwiid.h cwiid_close"
- hwiidClose :: Wiimote -> IO CInt
+ close :: Wiimote -> IO CInt
foreign import ccall unsafe "cwiid.h cwiid_get_state"
cwiid_get_state :: Wiimote -> Ptr WiimoteState -> IO CInt
-hwiidGetState :: Wiimote -> IO WiimoteState
-hwiidGetState wiimote = alloca $ \state -> do
- cwiid_get_state wiimote state
- peek state
+getState :: Wiimote -> IO WiimoteState
+getState wiimote = alloca $ \state -> do
+ cwiid_get_state wiimote state
+ peek state
foreign import ccall unsafe "cwiid.h cwiid_set_rpt_mode"
- hwiidSetReportMode :: Wiimote -> Word8 -> IO CInt
+ setReportMode :: Wiimote -> Word8 -> IO CInt
foreign import ccall unsafe "cwiid.h cwiid_set_led"
- hwiidSetLed :: Wiimote -> Word8 -> IO CInt
+ setLed :: Wiimote -> Word8 -> IO CInt
foreign import ccall unsafe "cwiid.h cwiid_get_mesg"
cwiid_get_mesg :: Wiimote -> Ptr CInt -> Ptr (Ptr WiimoteMesg) -> Ptr TimeSpec -> IO CInt
-hwiidGetMesg :: Wiimote -> IO [WiimoteMesg]
-hwiidGetMesg wiimote = alloca $ \countptr -> alloca $ \arrayptr -> alloca $ \timestamp -> do
- ret <- cwiid_get_mesg wiimote countptr arrayptr timestamp
- count <- peek countptr
- array <- peek arrayptr
-
- if (ret == 0) then do
- list <- peekArray (fromIntegral count) array
- free array
- return list
- else return []
+getMesg :: Wiimote -> IO [WiimoteMesg]
+getMesg wiimote = alloca $ \countptr -> alloca $ \arrayptr -> alloca $ \timestamp -> do
+ ret <- cwiid_get_mesg wiimote countptr arrayptr timestamp
+ count <- peek countptr
+ array <- peek arrayptr
+
+ if (ret == 0) then do
+ list <- peekArray (fromIntegral count) array
+ free array
+ return list
+ else return []
foreign import ccall unsafe "cwiid.h cwiid_get_acc_cal"
cwiid_get_acc_cal :: Wiimote -> WiimoteExtType -> Ptr WiimoteAccCal -> IO CInt
-hwiidGetAccCal wiimote exttype = alloca $ \calptr -> do
- cwiid_get_acc_cal wiimote exttype calptr
- cal <- peek calptr
- return cal
+getAccCal wiimote exttype = alloca $ \calptr -> do
+ cwiid_get_acc_cal wiimote exttype calptr
+ cal <- peek calptr
+ return cal