module SDL.Raw.Timer (
  -- * Timer Support
  addTimer,
  delay,
  getPerformanceCounter,
  getPerformanceFrequency,
  getTicks,
  removeTimer
) where

import Control.Monad.IO.Class
import Data.Word
import Foreign.C.Types
import Foreign.Ptr
import SDL.Raw.Types

foreign import ccall "SDL.h SDL_AddTimer" addTimerFFI :: Word32 -> TimerCallback -> Ptr () -> IO TimerID
foreign import ccall "SDL.h SDL_Delay" delayFFI :: Word32 -> IO ()
foreign import ccall "SDL.h SDL_GetPerformanceCounter" getPerformanceCounterFFI :: IO Word64
foreign import ccall "SDL.h SDL_GetPerformanceFrequency" getPerformanceFrequencyFFI :: IO Word64
foreign import ccall "SDL.h SDL_GetTicks" getTicksFFI :: IO Word32
foreign import ccall "SDL.h SDL_RemoveTimer" removeTimerFFI :: TimerID -> IO Bool

addTimer :: MonadIO m => Word32 -> TimerCallback -> Ptr () -> m TimerID
addTimer :: forall (m :: Type -> Type).
MonadIO m =>
Word32 -> TimerCallback -> Ptr () -> m TimerID
addTimer Word32
v1 TimerCallback
v2 Ptr ()
v3 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Word32 -> TimerCallback -> Ptr () -> IO TimerID
addTimerFFI Word32
v1 TimerCallback
v2 Ptr ()
v3
{-# INLINE addTimer #-}

delay :: MonadIO m => Word32 -> m ()
delay :: forall (m :: Type -> Type). MonadIO m => Word32 -> m ()
delay Word32
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Word32 -> IO ()
delayFFI Word32
v1
{-# INLINE delay #-}

getPerformanceCounter :: MonadIO m => m Word64
getPerformanceCounter :: forall (m :: Type -> Type). MonadIO m => m Word64
getPerformanceCounter = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO Word64
getPerformanceCounterFFI
{-# INLINE getPerformanceCounter #-}

getPerformanceFrequency :: MonadIO m => m Word64
getPerformanceFrequency :: forall (m :: Type -> Type). MonadIO m => m Word64
getPerformanceFrequency = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO Word64
getPerformanceFrequencyFFI
{-# INLINE getPerformanceFrequency #-}

getTicks :: MonadIO m => m Word32
getTicks :: forall (m :: Type -> Type). MonadIO m => m Word32
getTicks = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO Word32
getTicksFFI
{-# INLINE getTicks #-}

removeTimer :: MonadIO m => TimerID -> m Bool
removeTimer :: forall (m :: Type -> Type). MonadIO m => TimerID -> m Bool
removeTimer TimerID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ TimerID -> IO Bool
removeTimerFFI TimerID
v1
{-# INLINE removeTimer #-}