-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Library to interface with the wiimote
--   
--   HCWiid is a working userspace driver along with various applications
--   implementing event drivers, multiple wiimote connectivity, gesture
--   recognition, and other Wiimote-based functionality.
@package hcwiid
@version 0.0.6.1


-- | Bindings for the cwiid library, a working userspace driver along with
--   various applications implementing event drivers, multiple Wiimote
--   connectivity, gesture recognition, and other Wiimote-based
--   functionality.
--   
--   The current implementation is rather incomplete. In particular:
--   
--   <ul>
--   <li>Some Haskell functions (those related to rpt mode, rumble, leds)
--   had hard-coded values in them. Therefore, they implemented only a very
--   partial interface to their C counterparts. The new versions should be
--   tested and, if any other function is like this, then exported
--   properly.</li>
--   <li>Not all functions/wiimote fields are accessible. In particular,
--   acceleromoter and IR is in testing stage. Nunchuck, calibration,
--   wiimote plus are not handled at all (but will be in the future).</li>
--   </ul>
--   
--   All in all, the code works quite well and is currently being used to
--   implement several real games.
module System.CWiid

-- | Try to establish a connection to any existing Wiimote using any
--   existing bluetooth interface.
--   
--   The function returns <a>Nothing</a> if there is no bluetooth interface
--   or if no wiimote can be located. If the connection succeeds, a
--   <a>CWiidWiimote</a> is returned (inside a <a>Just</a>), which can be
--   used to poll the wiimote using other functions.
--   
--   There is a default timeout of 5 seconds.
--   
--   <ul>
--   <li>TODO: export cwiid_open_time and cwiid_close as well.</li>
--   </ul>
cwiidOpen :: IO (Maybe CWiidWiimote)

-- | A connection to an existing wiimote. Use <a>cwiidOpen</a> to connect
--   to a wiimote and obtain one of these.
data CWiidWiimote

-- | The state of the wiimote. Use <a>cwiidSetRptMode</a> to enable/disable
--   sensors.
--   
--   <ul>
--   <li>FIXME: incomplete state</li>
--   <li>FIXME: export get_state</li>
--   </ul>
data CWiidState
CWiidState :: Int -> Int -> Int -> Int -> Int -> [Int] -> [CWiidIRSrc] -> CWiidState
[rptMode] :: CWiidState -> Int
[led] :: CWiidState -> Int
[rumble] :: CWiidState -> Int
[battery] :: CWiidState -> Int
[buttons] :: CWiidState -> Int
[acc] :: CWiidState -> [Int]
[irSrc] :: CWiidState -> [CWiidIRSrc]

-- | Enable/disable reception of certain sensors. Use 2 to enable buttons.
cwiidSetRptMode :: CWiidWiimote -> CUChar -> IO CInt
data CWiidLedFlag

-- | Flag with exactly led 1 enabled. Use <a>combineCwiidLedFlag</a> to
--   create flags with several leds enabled.
cwiidLed1 :: CWiidLedFlag

-- | Flag with exactly led 2 enabled. Use <a>combineCwiidLedFlag</a> to
--   create flags with several leds enabled.
cwiidLed2 :: CWiidLedFlag

-- | Flag with exactly led 2 enabled. Use <a>combineCwiidLedFlag</a> to
--   create flags with several leds enabled.
cwiidLed3 :: CWiidLedFlag

-- | Flag with exactly led 4 enabled. Use <a>combineCwiidLedFlag</a> to
--   create flags with several leds enabled.
cwiidLed4 :: CWiidLedFlag

-- | Enable/disable certain leds.
--   
--   Use <a>cwiidLed1</a> .. <a>cwiidLed4</a> together with
--   <a>combineCwiidLedFlag</a> to create a flag with just the leds you
--   want enabled and change all at once with one operation.
cwiidSetLed :: CWiidWiimote -> CWiidLedFlag -> IO CInt

-- | Combine several led flags into one led flag with those leds enabled
--   and all other leds disabled.
combineCwiidLedFlag :: [CWiidLedFlag] -> CWiidLedFlag
cwiidSetRumble :: CWiidWiimote -> CUChar -> IO CInt

-- | Returns a mask with the buttons that are currently pushed.
cwiidGetBtnState :: CWiidWiimote -> IO CWiidBtnFlag

-- | Returns <a>True</a> if the button indicated by the flag is pushed,
--   <a>False</a> otherwise.
--   
--   This is a pure function, so the first argument must be the button
--   flags as returned by <a>cwiidGetBtnState</a>.
cwiidIsBtnPushed :: CWiidBtnFlag -> CWiidBtnFlag -> Bool
cwiidBtn2 :: CWiidBtnFlag
cwiidBtn1 :: CWiidBtnFlag
cwiidBtnB :: CWiidBtnFlag
cwiidBtnA :: CWiidBtnFlag
cwiidBtnMinus :: CWiidBtnFlag
cwiidBtnHome :: CWiidBtnFlag
cwiidBtnLeft :: CWiidBtnFlag
cwiidBtnRight :: CWiidBtnFlag
cwiidBtnDown :: CWiidBtnFlag
cwiidBtnUp :: CWiidBtnFlag
cwiidBtnPlus :: CWiidBtnFlag
combineCwiidBtnFlag :: [CWiidBtnFlag] -> CWiidBtnFlag
diffCwiidBtnFlag :: CWiidBtnFlag -> CWiidBtnFlag -> CWiidBtnFlag
newtype CWiidBtnFlag
CWiidBtnFlag :: Int -> CWiidBtnFlag
[unCWiidBtnFlag] :: CWiidBtnFlag -> Int

-- | Obtain accelerometer information. FIXME: read
--   wmgui/main.c:cwiid_acc(1119) to understand how to use this
--   information, what else might need to be exported, and how to calibrate
--   the accelerometers.
cwiidGetAcc :: CWiidWiimote -> IO CWiidAcc

-- | Array of accelerometer information. It will always contain exactly
--   three elements.
--   
--   <ul>
--   <li>TODO: provide a more informative and restrictive interface with
--   exactly three named Int (byte?) fields.</li>
--   </ul>
newtype CWiidAcc
CWiidAcc :: [Int] -> CWiidAcc
[unCWiidAcc] :: CWiidAcc -> [Int]

-- | Internal representation of an infrared point. You should no use it
--   unless you know what you are doing; use <tt>CWiidIR</tt> instead.
data CWiidIRSrc
CWiidIRSrc :: Bool -> Int -> Int -> Int -> CWiidIRSrc
[cwiidIRSrcValid] :: CWiidIRSrc -> Bool
[cwiidIRSrcPosX] :: CWiidIRSrc -> Int
[cwiidIRSrcPosY] :: CWiidIRSrc -> Int
[cwiidIRSrcSize] :: CWiidIRSrc -> Int
cwiidGetIR :: CWiidWiimote -> IO [CWiidIRSrc]
instance GHC.Show.Show System.CWiid.CWiidIRSrc
instance GHC.Show.Show System.CWiid.CWiidState
instance GHC.Show.Show System.CWiid.CWiidLedFlag
instance GHC.Classes.Eq System.CWiid.CWiidLedFlag
instance GHC.Show.Show System.CWiid.CWiidBtnFlag
instance GHC.Classes.Eq System.CWiid.CWiidBtnFlag
instance GHC.Show.Show System.CWiid.CWiidRptMode
instance GHC.Classes.Eq System.CWiid.CWiidRptMode
instance GHC.Show.Show System.CWiid.CWiidAcc
instance GHC.Classes.Eq System.CWiid.CWiidAcc
instance Foreign.Storable.Storable System.CWiid.CWiidState
instance Foreign.Storable.Storable System.CWiid.CWiidIRSrc
instance Foreign.Storable.Storable System.CWiid.CWiidBdaddr
