module SDL.Raw.Basic (
  -- * Initialization and Shutdown
  init,
  initSubSystem,
  quit,
  quitSubSystem,
  setMainReady,
  wasInit,

  -- * Memory Management
  free,

  -- * Configuration Variables
  addHintCallback,
  clearHints,
  delHintCallback,
  getHint,
  setHint,
  setHintWithPriority,

  -- * Log Handling
  log,
  logCritical,
  logDebug,
  logError,
  logGetOutputFunction,
  logGetPriority,
  logInfo,
  logMessage,
  logResetPriorities,
  logSetAllPriority,
  logSetOutputFunction,
  logSetPriority,
  logVerbose,
  logWarn,

  -- * Assertions
  -- | Use Haskell's own assertion primitives rather than SDL's.

  -- * Querying SDL Version
  getRevision,
  getRevisionNumber,
  getVersion
) where

import Control.Monad.IO.Class
import Foreign.C.String
import Foreign.C.Types
import Foreign.Ptr
import SDL.Raw.Enum
import SDL.Raw.Types
import Prelude hiding (init, log)

foreign import ccall "SDL.h SDL_Init" initFFI :: InitFlag -> IO CInt
foreign import ccall "SDL.h SDL_InitSubSystem" initSubSystemFFI :: InitFlag -> IO CInt
foreign import ccall "SDL.h SDL_Quit" quitFFI :: IO ()
foreign import ccall "SDL.h SDL_QuitSubSystem" quitSubSystemFFI :: InitFlag -> IO ()
foreign import ccall "SDL.h SDL_SetMainReady" setMainReadyFFI :: IO ()
foreign import ccall "SDL.h SDL_WasInit" wasInitFFI :: InitFlag -> IO InitFlag

foreign import ccall "SDL.h SDL_free" freeFFI :: Ptr () -> IO ()

foreign import ccall "SDL.h SDL_AddHintCallback" addHintCallbackFFI :: CString -> HintCallback -> Ptr () -> IO ()
foreign import ccall "SDL.h SDL_ClearHints" clearHintsFFI :: IO ()
foreign import ccall "SDL.h SDL_DelHintCallback" delHintCallbackFFI :: CString -> HintCallback -> Ptr () -> IO ()
foreign import ccall "SDL.h SDL_GetHint" getHintFFI :: CString -> IO CString
foreign import ccall "SDL.h SDL_SetHint" setHintFFI :: CString -> CString -> IO Bool
foreign import ccall "SDL.h SDL_SetHintWithPriority" setHintWithPriorityFFI :: CString -> CString -> HintPriority -> IO Bool

foreign import ccall "SDL.h SDL_LogGetOutputFunction" logGetOutputFunctionFFI :: Ptr LogOutputFunction -> Ptr (Ptr ()) -> IO ()
foreign import ccall "SDL.h SDL_LogGetPriority" logGetPriorityFFI :: CInt -> IO LogPriority
foreign import ccall "sdlhelper.c SDLHelper_LogMessage" logMessageFFI :: CInt -> LogPriority -> CString -> IO ()
foreign import ccall "SDL.h SDL_LogResetPriorities" logResetPrioritiesFFI :: IO ()
foreign import ccall "SDL.h SDL_LogSetAllPriority" logSetAllPriorityFFI :: LogPriority -> IO ()
foreign import ccall "SDL.h SDL_LogSetOutputFunction" logSetOutputFunctionFFI :: LogOutputFunction -> Ptr () -> IO ()
foreign import ccall "SDL.h SDL_LogSetPriority" logSetPriorityFFI :: CInt -> LogPriority -> IO ()

foreign import ccall "SDL.h SDL_GetRevision" getRevisionFFI :: IO CString
foreign import ccall "SDL.h SDL_GetRevisionNumber" getRevisionNumberFFI :: IO CInt
foreign import ccall "SDL.h SDL_GetVersion" getVersionFFI :: Ptr Version -> IO ()

init :: MonadIO m => InitFlag -> m CInt
init :: forall (m :: Type -> Type). MonadIO m => InitFlag -> m CInt
init InitFlag
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitFlag -> IO CInt
initFFI InitFlag
v1
{-# INLINE init #-}

initSubSystem :: MonadIO m => InitFlag -> m CInt
initSubSystem :: forall (m :: Type -> Type). MonadIO m => InitFlag -> m CInt
initSubSystem InitFlag
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitFlag -> IO CInt
initSubSystemFFI InitFlag
v1
{-# INLINE initSubSystem #-}

quit :: MonadIO m => m ()
quit :: forall (m :: Type -> Type). MonadIO m => m ()
quit = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
quitFFI
{-# INLINE quit #-}

quitSubSystem :: MonadIO m => InitFlag -> m ()
quitSubSystem :: forall (m :: Type -> Type). MonadIO m => InitFlag -> m ()
quitSubSystem InitFlag
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitFlag -> IO ()
quitSubSystemFFI InitFlag
v1
{-# INLINE quitSubSystem #-}

setMainReady :: MonadIO m => m ()
setMainReady :: forall (m :: Type -> Type). MonadIO m => m ()
setMainReady = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
setMainReadyFFI
{-# INLINE setMainReady #-}

wasInit :: MonadIO m => InitFlag -> m InitFlag
wasInit :: forall (m :: Type -> Type). MonadIO m => InitFlag -> m InitFlag
wasInit InitFlag
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitFlag -> IO InitFlag
wasInitFFI InitFlag
v1
{-# INLINE wasInit #-}

free :: MonadIO m => Ptr () -> m ()
free :: forall (m :: Type -> Type). MonadIO m => Ptr () -> m ()
free Ptr ()
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr () -> IO ()
freeFFI Ptr ()
v1
{-# INLINE free #-}

addHintCallback :: MonadIO m => CString -> HintCallback -> Ptr () -> m ()
addHintCallback :: forall (m :: Type -> Type).
MonadIO m =>
CString -> HintCallback -> Ptr () -> m ()
addHintCallback CString
v1 HintCallback
v2 Ptr ()
v3 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString -> HintCallback -> Ptr () -> IO ()
addHintCallbackFFI CString
v1 HintCallback
v2 Ptr ()
v3
{-# INLINE addHintCallback #-}

clearHints :: MonadIO m => m ()
clearHints :: forall (m :: Type -> Type). MonadIO m => m ()
clearHints = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
clearHintsFFI
{-# INLINE clearHints #-}

delHintCallback :: MonadIO m => CString -> HintCallback -> Ptr () -> m ()
delHintCallback :: forall (m :: Type -> Type).
MonadIO m =>
CString -> HintCallback -> Ptr () -> m ()
delHintCallback CString
v1 HintCallback
v2 Ptr ()
v3 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString -> HintCallback -> Ptr () -> IO ()
delHintCallbackFFI CString
v1 HintCallback
v2 Ptr ()
v3
{-# INLINE delHintCallback #-}

getHint :: MonadIO m => CString -> m CString
getHint :: forall (m :: Type -> Type). MonadIO m => CString -> m CString
getHint CString
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString -> IO CString
getHintFFI CString
v1
{-# INLINE getHint #-}

setHint :: MonadIO m => CString -> CString -> m Bool
setHint :: forall (m :: Type -> Type).
MonadIO m =>
CString -> CString -> m Bool
setHint CString
v1 CString
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString -> CString -> IO Bool
setHintFFI CString
v1 CString
v2
{-# INLINE setHint #-}

setHintWithPriority :: MonadIO m => CString -> CString -> HintPriority -> m Bool
setHintWithPriority :: forall (m :: Type -> Type).
MonadIO m =>
CString -> CString -> InitFlag -> m Bool
setHintWithPriority CString
v1 CString
v2 InitFlag
v3 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString -> CString -> InitFlag -> IO Bool
setHintWithPriorityFFI CString
v1 CString
v2 InitFlag
v3
{-# INLINE setHintWithPriority #-}

log :: CString -> IO ()
log :: CString -> IO ()
log = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage forall {a}. (Eq a, Num a) => a
SDL_LOG_CATEGORY_APPLICATION InitFlag
SDL_LOG_PRIORITY_INFO
{-# INLINE log #-}

logCritical :: CInt -> CString -> IO ()
logCritical :: CInt -> CString -> IO ()
logCritical CInt
category = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
category InitFlag
SDL_LOG_PRIORITY_CRITICAL
{-# INLINE logCritical #-}

logDebug :: CInt -> CString -> IO ()
logDebug :: CInt -> CString -> IO ()
logDebug CInt
category = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
category InitFlag
SDL_LOG_PRIORITY_DEBUG
{-# INLINE logDebug #-}

logError :: CInt -> CString -> IO ()
logError :: CInt -> CString -> IO ()
logError CInt
category = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
category InitFlag
SDL_LOG_PRIORITY_ERROR
{-# INLINE logError #-}

logGetOutputFunction :: MonadIO m => Ptr LogOutputFunction -> Ptr (Ptr ()) -> m ()
logGetOutputFunction :: forall (m :: Type -> Type).
MonadIO m =>
Ptr LogOutputFunction -> Ptr (Ptr ()) -> m ()
logGetOutputFunction Ptr LogOutputFunction
v1 Ptr (Ptr ())
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr LogOutputFunction -> Ptr (Ptr ()) -> IO ()
logGetOutputFunctionFFI Ptr LogOutputFunction
v1 Ptr (Ptr ())
v2
{-# INLINE logGetOutputFunction #-}

logGetPriority :: MonadIO m => CInt -> m LogPriority
logGetPriority :: forall (m :: Type -> Type). MonadIO m => CInt -> m InitFlag
logGetPriority CInt
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> IO InitFlag
logGetPriorityFFI CInt
v1
{-# INLINE logGetPriority #-}

logInfo :: CInt -> CString -> IO ()
logInfo :: CInt -> CString -> IO ()
logInfo CInt
category = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
category InitFlag
SDL_LOG_PRIORITY_INFO
{-# INLINE logInfo #-}

logMessage :: MonadIO m => CInt -> LogPriority -> CString -> m ()
logMessage :: forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
v1 InitFlag
v2 CString
v3 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> InitFlag -> CString -> IO ()
logMessageFFI CInt
v1 InitFlag
v2 CString
v3
{-# INLINE logMessage #-}

logResetPriorities :: MonadIO m => m ()
logResetPriorities :: forall (m :: Type -> Type). MonadIO m => m ()
logResetPriorities = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
logResetPrioritiesFFI
{-# INLINE logResetPriorities #-}

logSetAllPriority :: MonadIO m => LogPriority -> m ()
logSetAllPriority :: forall (m :: Type -> Type). MonadIO m => InitFlag -> m ()
logSetAllPriority InitFlag
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitFlag -> IO ()
logSetAllPriorityFFI InitFlag
v1
{-# INLINE logSetAllPriority #-}

logSetOutputFunction :: MonadIO m => LogOutputFunction -> Ptr () -> m ()
logSetOutputFunction :: forall (m :: Type -> Type).
MonadIO m =>
LogOutputFunction -> Ptr () -> m ()
logSetOutputFunction LogOutputFunction
v1 Ptr ()
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ LogOutputFunction -> Ptr () -> IO ()
logSetOutputFunctionFFI LogOutputFunction
v1 Ptr ()
v2
{-# INLINE logSetOutputFunction #-}

logSetPriority :: MonadIO m => CInt -> LogPriority -> m ()
logSetPriority :: forall (m :: Type -> Type). MonadIO m => CInt -> InitFlag -> m ()
logSetPriority CInt
v1 InitFlag
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> InitFlag -> IO ()
logSetPriorityFFI CInt
v1 InitFlag
v2
{-# INLINE logSetPriority #-}

logVerbose :: CInt -> CString -> IO ()
logVerbose :: CInt -> CString -> IO ()
logVerbose CInt
category = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
category InitFlag
SDL_LOG_PRIORITY_VERBOSE
{-# INLINE logVerbose #-}

logWarn :: CInt -> CString -> IO ()
logWarn :: CInt -> CString -> IO ()
logWarn CInt
category = forall (m :: Type -> Type).
MonadIO m =>
CInt -> InitFlag -> CString -> m ()
logMessage CInt
category InitFlag
SDL_LOG_PRIORITY_WARN
{-# INLINE logWarn #-}

getRevision :: MonadIO m => m CString
getRevision :: forall (m :: Type -> Type). MonadIO m => m CString
getRevision = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO CString
getRevisionFFI
{-# INLINE getRevision #-}

getRevisionNumber :: MonadIO m => m CInt
getRevisionNumber :: forall (m :: Type -> Type). MonadIO m => m CInt
getRevisionNumber = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO CInt
getRevisionNumberFFI
{-# INLINE getRevisionNumber #-}

getVersion :: MonadIO m => Ptr Version -> m ()
getVersion :: forall (m :: Type -> Type). MonadIO m => Ptr Version -> m ()
getVersion Ptr Version
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr Version -> IO ()
getVersionFFI Ptr Version
v1
{-# INLINE getVersion #-}