module Sound.PortMidi.DeviceInfo (
DeviceInfo(..)
, peekDeviceInfo
) where
import Foreign
import Foreign.C
data DeviceInfo
= DeviceInfo
{ interface :: String
, name :: String
, input :: Bool
, output :: Bool
, opened :: Bool
} deriving (Eq, Show)
peekDeviceInfo ptr = do
s <- (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr >>= peekCString
u <- (\hsc_ptr -> peekByteOff hsc_ptr 16) ptr >>= peekCString
i <- (\hsc_ptr -> peekByteOff hsc_ptr 24) ptr
o <- (\hsc_ptr -> peekByteOff hsc_ptr 28) ptr
d <- (\hsc_ptr -> peekByteOff hsc_ptr 32) ptr
return $ DeviceInfo s u (asBool i) (asBool o) (asBool d)
where
asBool :: Int32 -> Bool
asBool = (/= 0)