{-# LINE 1 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

{-# LINE 2 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

{-# LINE 3 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

-- | <http://libusb.sourceforge.net/api-1.0/group__poll.html>

module Bindings.Libusb.PollingAndTiming where
import Foreign.Ptr (Ptr,FunPtr,plusPtr)
import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)
import Foreign.Storable
import Foreign.C.Types
import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)
import Foreign.Marshal.Array (peekArray,pokeArray)
import Data.Int
import Data.Word

{-# LINE 8 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
import Bindings.Libusb.InitializationDeinitialization

data C'timeval = C'timeval

{-# LINE 11 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

data C'libusb_pollfd = C'libusb_pollfd{
{-# LINE 13 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

  c'libusb_pollfd'fd :: CInt
{-# LINE 14 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
,
  c'libusb_pollfd'events :: CShort
{-# LINE 15 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

 } deriving (Eq,Show)
instance Storable C'libusb_pollfd where
  sizeOf _ = 8
  alignment = sizeOf
  peek p = do
    v0 <- peekByteOff p 0
    v1 <- peekByteOff p 4
    return $ C'libusb_pollfd v0 v1
  poke p (C'libusb_pollfd v0 v1) = do
    pokeByteOff p 0 v0
    pokeByteOff p 4 v1
    return ()

{-# LINE 16 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

type C'libusb_pollfd_added_cb = FunPtr (CInt -> CShort -> Ptr () -> IO ())
foreign import ccall "wrapper" mk'libusb_pollfd_added_cb
  :: (CInt -> CShort -> Ptr () -> IO ()) -> IO C'libusb_pollfd_added_cb

{-# LINE 18 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
type C'libusb_pollfd_removed_cb = FunPtr (CInt -> Ptr () -> IO ())
foreign import ccall "wrapper" mk'libusb_pollfd_removed_cb
  :: (CInt -> Ptr () -> IO ()) -> IO C'libusb_pollfd_removed_cb

{-# LINE 19 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}

foreign import ccall "libusb_try_lock_events" c'libusb_try_lock_events
  :: Ptr C'libusb_context -> IO CInt
foreign import ccall "&libusb_try_lock_events" p'libusb_try_lock_events
  :: FunPtr (Ptr C'libusb_context -> IO CInt)

{-# LINE 21 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_lock_events" c'libusb_lock_events
  :: Ptr C'libusb_context -> IO ()
foreign import ccall "&libusb_lock_events" p'libusb_lock_events
  :: FunPtr (Ptr C'libusb_context -> IO ())

{-# LINE 22 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_unlock_events" c'libusb_unlock_events
  :: Ptr C'libusb_context -> IO ()
foreign import ccall "&libusb_unlock_events" p'libusb_unlock_events
  :: FunPtr (Ptr C'libusb_context -> IO ())

{-# LINE 23 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_event_handling_ok" c'libusb_event_handling_ok
  :: Ptr C'libusb_context -> IO CInt
foreign import ccall "&libusb_event_handling_ok" p'libusb_event_handling_ok
  :: FunPtr (Ptr C'libusb_context -> IO CInt)

{-# LINE 24 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_event_handler_active" c'libusb_event_handler_active
  :: Ptr C'libusb_context -> IO CInt
foreign import ccall "&libusb_event_handler_active" p'libusb_event_handler_active
  :: FunPtr (Ptr C'libusb_context -> IO CInt)

{-# LINE 25 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_lock_event_waiters" c'libusb_lock_event_waiters
  :: Ptr C'libusb_context -> IO ()
foreign import ccall "&libusb_lock_event_waiters" p'libusb_lock_event_waiters
  :: FunPtr (Ptr C'libusb_context -> IO ())

{-# LINE 26 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_unlock_event_waiters" c'libusb_unlock_event_waiters
  :: Ptr C'libusb_context -> IO ()
foreign import ccall "&libusb_unlock_event_waiters" p'libusb_unlock_event_waiters
  :: FunPtr (Ptr C'libusb_context -> IO ())

{-# LINE 27 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_wait_for_event" c'libusb_wait_for_event
  :: Ptr C'libusb_context -> Ptr C'timeval -> IO CInt
foreign import ccall "&libusb_wait_for_event" p'libusb_wait_for_event
  :: FunPtr (Ptr C'libusb_context -> Ptr C'timeval -> IO CInt)

{-# LINE 29 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_handle_events_timeout" c'libusb_handle_events_timeout
  :: Ptr C'libusb_context -> Ptr C'timeval -> IO CInt
foreign import ccall "&libusb_handle_events_timeout" p'libusb_handle_events_timeout
  :: FunPtr (Ptr C'libusb_context -> Ptr C'timeval -> IO CInt)

{-# LINE 31 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_handle_events" c'libusb_handle_events
  :: Ptr C'libusb_context -> IO CInt
foreign import ccall "&libusb_handle_events" p'libusb_handle_events
  :: FunPtr (Ptr C'libusb_context -> IO CInt)

{-# LINE 32 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_handle_events_locked" c'libusb_handle_events_locked
  :: Ptr C'libusb_context -> Ptr C'timeval -> IO CInt
foreign import ccall "&libusb_handle_events_locked" p'libusb_handle_events_locked
  :: FunPtr (Ptr C'libusb_context -> Ptr C'timeval -> IO CInt)

{-# LINE 34 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_get_next_timeout" c'libusb_get_next_timeout
  :: Ptr C'libusb_context -> Ptr C'timeval -> IO CInt
foreign import ccall "&libusb_get_next_timeout" p'libusb_get_next_timeout
  :: FunPtr (Ptr C'libusb_context -> Ptr C'timeval -> IO CInt)

{-# LINE 36 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_set_pollfd_notifiers" c'libusb_set_pollfd_notifiers
  :: Ptr C'libusb_context -> C'libusb_pollfd_added_cb -> C'libusb_pollfd_removed_cb -> Ptr () -> IO ()
foreign import ccall "&libusb_set_pollfd_notifiers" p'libusb_set_pollfd_notifiers
  :: FunPtr (Ptr C'libusb_context -> C'libusb_pollfd_added_cb -> C'libusb_pollfd_removed_cb -> Ptr () -> IO ())

{-# LINE 39 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}
foreign import ccall "libusb_get_pollfds" c'libusb_get_pollfds
  :: Ptr C'libusb_context -> IO (Ptr (Ptr C'libusb_pollfd))
foreign import ccall "&libusb_get_pollfds" p'libusb_get_pollfds
  :: FunPtr (Ptr C'libusb_context -> IO (Ptr (Ptr C'libusb_pollfd)))

{-# LINE 41 "src/Bindings/Libusb/PollingAndTiming.hsc" #-}