{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK prune #-}

module SDL3.Sys.Bindgen.Pen.Unsafe (
  SDL3.Sys.Bindgen.Pen.Unsafe.sDL_GetPenDeviceType,
)
where

import Prelude (IO, fmap)

import HsBindgen.Runtime.LibC qualified
import HsBindgen.Runtime.Support qualified as BG
import HsBindgen.Runtime.Support.CAPI qualified
import SDL3.Sys.Bindgen.Pen

$( HsBindgen.Runtime.Support.CAPI.addCSource
     ( HsBindgen.Runtime.Support.CAPI.unlines
         [ "#define SDL_MAIN_HANDLED"
         , "#define SDL_SLOW_MEMCPY"
         , "#define SDL_SLOW_MEMMOVE"
         , "#define SDL_SLOW_MEMSET"
         , "#include <SDL3/SDL_pen.h>"
         , "#include <SDL3/SDL_version.h>"
         , "#include <SDL3/SDL_error.h>"
         , "#include <SDL3/SDL_version.h>"
         , "#if !SDL_VERSION_ATLEAST(3, 4, 0)"
         , "typedef int SDL_PenDeviceType;"
         , "#endif"
         , "SDL_PenDeviceType hs_bindgen_c3c39a594724cad9 ("
         , "  SDL_PenID arg1"
         , ")"
         , "{"
         , "#if SDL_VERSION_ATLEAST(3, 4, 0)"
         , "  return (SDL_GetPenDeviceType)(arg1);"
         , "#else"
         , "  (void)arg1; SDL_SetError(\"SDL_GetPenDeviceType requires SDL >= 3.4.0\"); return 0;"
         , "#endif"
         , "}"
         ]
     )
 )

-- __unique:__ @sdl3bindgensys_SDL3.Sys.Bindgen.Pen_Unsafe_SDL_GetPenDeviceType@
foreign import ccall unsafe "hs_bindgen_c3c39a594724cad9"
  hs_bindgen_c3c39a594724cad9_base
    :: HsBindgen.Runtime.LibC.Word32
    -> IO BG.CInt

-- __unique:__ @sdl3bindgensys_SDL3.Sys.Bindgen.Pen_Unsafe_SDL_GetPenDeviceType@
hs_bindgen_c3c39a594724cad9
  :: SDL_PenID
  -> IO SDL_PenDeviceType
hs_bindgen_c3c39a594724cad9 :: SDL_PenID -> IO SDL_PenDeviceType
hs_bindgen_c3c39a594724cad9 =
  \SDL_PenID
x0 ->
    (CInt -> SDL_PenDeviceType) -> IO CInt -> IO SDL_PenDeviceType
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CInt -> SDL_PenDeviceType
FFIType SDL_PenDeviceType -> SDL_PenDeviceType
forall a. HasFFIType a => FFIType a -> a
BG.fromFFIType (Word32 -> IO CInt
hs_bindgen_c3c39a594724cad9_base (SDL_PenID -> FFIType SDL_PenID
forall a. HasFFIType a => a -> FFIType a
BG.toFFIType SDL_PenID
x0))

-- | Get the device type of the given pen.
--
--     Many platforms do not supply this information, so an app must always be prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result.
--
--     [Returns]: the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID on failure; call SDL_GetError() for more information.
--
--     [Thread safety]: It is safe to call this function from any thread.
--
--     @since 3.4.0
--
--     [C declaration]: @SDL_GetPenDeviceType@, defined at @SDL3\/SDL_pen.h 189:47@
sDL_GetPenDeviceType
  :: SDL_PenID
  -- ^
  --
  --           [@instance_id@]: the pen instance ID.
  -> IO SDL_PenDeviceType
sDL_GetPenDeviceType :: SDL_PenID -> IO SDL_PenDeviceType
sDL_GetPenDeviceType = SDL_PenID -> IO SDL_PenDeviceType
hs_bindgen_c3c39a594724cad9