module SFML.Window.JoystickIdentification
(
JoystickIdentification(..)
)
where
import Control.Applicative ((<$>), (<*>))
import Foreign.C.String
import Foreign.C.Types
import Foreign.Storable
import Foreign.Ptr (Ptr, castPtr)
data JoystickIdentification = JoystickIdentification
{ name :: String
, vendorId :: Int
, productId :: Int
} deriving (Eq, Show)
instance Storable JoystickIdentification where
sizeOf _ = (16)
alignment _ = 8
peek ptr = JoystickIdentification
<$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) ptr >>= peekCString)
<*> fmap fromIntegral ((\hsc_ptr -> peekByteOff hsc_ptr 8) ptr :: IO CUInt)
<*> fmap fromIntegral ((\hsc_ptr -> peekByteOff hsc_ptr 12) ptr :: IO CUInt)
poke ptr ji = do
withCString (name ji) $ (\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr
(\hsc_ptr -> pokeByteOff hsc_ptr 8) ptr ((fromIntegral . vendorId) ji :: CUInt)
(\hsc_ptr -> pokeByteOff hsc_ptr 12) ptr ((fromIntegral . productId) ji :: CUInt)