{-# language CPP #-}
-- | = Name
--
-- XR_FB_display_refresh_rate - instance extension
--
-- = Specification
--
-- See
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_FB_display_refresh_rate  XR_FB_display_refresh_rate>
-- in the main specification for complete information.
--
-- = Registered Extension Number
--
-- 102
--
-- = Revision
--
-- 1
--
-- = Extension and Version Dependencies
--
-- -   Requires OpenXR 1.0
--
-- = See Also
--
-- 'EventDataDisplayRefreshRateChangedFB',
-- 'enumerateDisplayRefreshRatesFB', 'getDisplayRefreshRateFB',
-- 'requestDisplayRefreshRateFB'
--
-- = Document Notes
--
-- For more information, see the
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_FB_display_refresh_rate OpenXR Specification>
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module OpenXR.Extensions.XR_FB_display_refresh_rate  ( enumerateDisplayRefreshRatesFB
                                                     , getDisplayRefreshRateFB
                                                     , requestDisplayRefreshRateFB
                                                     , EventDataDisplayRefreshRateChangedFB(..)
                                                     , FB_display_refresh_rate_SPEC_VERSION
                                                     , pattern FB_display_refresh_rate_SPEC_VERSION
                                                     , FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME
                                                     , pattern FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME
                                                     ) where

import OpenXR.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.Coerce (coerce)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import Foreign.C.Types (CFloat(..))
import OpenXR.CStruct (FromCStruct)
import OpenXR.CStruct (FromCStruct(..))
import OpenXR.CStruct (ToCStruct)
import OpenXR.CStruct (ToCStruct(..))
import OpenXR.Zero (Zero(..))
import Control.Monad.IO.Class (MonadIO)
import Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.C.Types (CFloat)
import Foreign.C.Types (CFloat(..))
import Foreign.C.Types (CFloat(CFloat))
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import OpenXR.CStruct.Utils (advancePtrBytes)
import OpenXR.NamedType ((:::))
import OpenXR.Core10.OtherTypes (EventDataBaseHeader(..))
import OpenXR.Dynamic (InstanceCmds(pXrEnumerateDisplayRefreshRatesFB))
import OpenXR.Dynamic (InstanceCmds(pXrGetDisplayRefreshRateFB))
import OpenXR.Dynamic (InstanceCmds(pXrRequestDisplayRefreshRateFB))
import OpenXR.Core10.OtherTypes (IsEventData(..))
import OpenXR.Exception (OpenXrException(..))
import OpenXR.Core10.Enums.Result (Result)
import OpenXR.Core10.Enums.Result (Result(..))
import OpenXR.Core10.Handles (Session)
import OpenXR.Core10.Handles (Session(..))
import OpenXR.Core10.Handles (Session_T)
import OpenXR.Core10.Enums.StructureType (StructureType)
import OpenXR.Core10.Enums.Result (Result(SUCCESS))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkXrEnumerateDisplayRefreshRatesFB
  :: FunPtr (Ptr Session_T -> Word32 -> Ptr Word32 -> Ptr CFloat -> IO Result) -> Ptr Session_T -> Word32 -> Ptr Word32 -> Ptr CFloat -> IO Result

-- | xrEnumerateDisplayRefreshRatesFB - Enumerates display refresh rates
--
-- == Parameter Descriptions
--
-- -   @session@ is the session that enumerates the supported display
--     refresh rates.
--
-- -   @displayRefreshRateCapacityInput@ is the capacity of the
--     @displayRefreshRates@, or 0 to retrieve the required capacity.
--
-- -   @displayRefreshRateCountOutput@ is a pointer to the count of @float@
--     @displayRefreshRates@ written, or a pointer to the required capacity
--     in the case that @displayRefreshRateCapacityInput@ is @0@.
--
-- -   @displayRefreshRates@ is a pointer to an array of @float@ display
--     refresh rates, but /can/ be @NULL@ if
--     @displayRefreshRateCapacityInput@ is @0@.
--
-- -   See
--     <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#buffer-size-parameters Buffer Size Parameters>
--     chapter for a detailed description of retrieving the required
--     @displayRefreshRates@ size.
--
-- = Description
--
-- 'enumerateDisplayRefreshRatesFB' enumerates the display refresh rates
-- supported by the current session. Display refresh rates /must/ be in
-- order from lowest to highest supported display refresh rates. Runtimes
-- /must/ always return identical buffer contents from this enumeration for
-- the lifetime of the session.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrEnumerateDisplayRefreshRatesFB-extension-notenabled# The @@
--     extension /must/ be enabled prior to calling
--     'enumerateDisplayRefreshRatesFB'
--
-- -   #VUID-xrEnumerateDisplayRefreshRatesFB-session-parameter# @session@
--     /must/ be a valid 'OpenXR.Core10.Handles.Session' handle
--
-- -   #VUID-xrEnumerateDisplayRefreshRatesFB-displayRefreshRateCountOutput-parameter#
--     @displayRefreshRateCountOutput@ /must/ be a pointer to a @uint32_t@
--     value
--
-- -   #VUID-xrEnumerateDisplayRefreshRatesFB-displayRefreshRates-parameter#
--     If @displayRefreshRateCapacityInput@ is not @0@,
--     @displayRefreshRates@ /must/ be a pointer to an array of
--     @displayRefreshRateCapacityInput@ @float@ values
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
--     -   'OpenXR.Core10.Enums.Result.SESSION_LOSS_PENDING'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_SESSION_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_SIZE_INSUFFICIENT'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Session', 'getDisplayRefreshRateFB',
-- 'requestDisplayRefreshRateFB'
enumerateDisplayRefreshRatesFB :: forall io
                                . (MonadIO io)
                               => -- No documentation found for Nested "xrEnumerateDisplayRefreshRatesFB" "session"
                                  Session
                               -> io (Result, ("displayRefreshRates" ::: Vector Float))
enumerateDisplayRefreshRatesFB :: Session -> io (Result, "displayRefreshRates" ::: Vector Float)
enumerateDisplayRefreshRatesFB session :: Session
session = IO (Result, "displayRefreshRates" ::: Vector Float)
-> io (Result, "displayRefreshRates" ::: Vector Float)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "displayRefreshRates" ::: Vector Float)
 -> io (Result, "displayRefreshRates" ::: Vector Float))
-> (ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      (Result, "displayRefreshRates" ::: Vector Float)
    -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     (Result, "displayRefreshRates" ::: Vector Float)
-> io (Result, "displayRefreshRates" ::: Vector Float)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Result, "displayRefreshRates" ::: Vector Float)
  IO
  (Result, "displayRefreshRates" ::: Vector Float)
-> IO (Result, "displayRefreshRates" ::: Vector Float)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Result, "displayRefreshRates" ::: Vector Float)
   IO
   (Result, "displayRefreshRates" ::: Vector Float)
 -> io (Result, "displayRefreshRates" ::: Vector Float))
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     (Result, "displayRefreshRates" ::: Vector Float)
-> io (Result, "displayRefreshRates" ::: Vector Float)
forall a b. (a -> b) -> a -> b
$ do
  let xrEnumerateDisplayRefreshRatesFBPtr :: FunPtr
  (Ptr Session_T
   -> ("displayRefreshRateCapacityInput" ::: Word32)
   -> ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> ("displayRefreshRates" ::: Ptr CFloat)
   -> IO Result)
xrEnumerateDisplayRefreshRatesFBPtr = InstanceCmds
-> FunPtr
     (Ptr Session_T
      -> ("displayRefreshRateCapacityInput" ::: Word32)
      -> ("displayRefreshRateCountOutput"
          ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
      -> ("displayRefreshRates" ::: Ptr CFloat)
      -> IO Result)
pXrEnumerateDisplayRefreshRatesFB (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
  IO ()
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ())
-> IO ()
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Session_T
   -> ("displayRefreshRateCapacityInput" ::: Word32)
   -> ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> ("displayRefreshRates" ::: Ptr CFloat)
   -> IO Result)
xrEnumerateDisplayRefreshRatesFBPtr FunPtr
  (Ptr Session_T
   -> ("displayRefreshRateCapacityInput" ::: Word32)
   -> ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> ("displayRefreshRates" ::: Ptr CFloat)
   -> IO Result)
-> FunPtr
     (Ptr Session_T
      -> ("displayRefreshRateCapacityInput" ::: Word32)
      -> ("displayRefreshRateCountOutput"
          ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
      -> ("displayRefreshRates" ::: Ptr CFloat)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Session_T
   -> ("displayRefreshRateCapacityInput" ::: Word32)
   -> ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> ("displayRefreshRates" ::: Ptr CFloat)
   -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrEnumerateDisplayRefreshRatesFB is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrEnumerateDisplayRefreshRatesFB' :: Ptr Session_T
-> ("displayRefreshRateCapacityInput" ::: Word32)
-> ("displayRefreshRateCountOutput"
    ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> ("displayRefreshRates" ::: Ptr CFloat)
-> IO Result
xrEnumerateDisplayRefreshRatesFB' = FunPtr
  (Ptr Session_T
   -> ("displayRefreshRateCapacityInput" ::: Word32)
   -> ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> ("displayRefreshRates" ::: Ptr CFloat)
   -> IO Result)
-> Ptr Session_T
-> ("displayRefreshRateCapacityInput" ::: Word32)
-> ("displayRefreshRateCountOutput"
    ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> ("displayRefreshRates" ::: Ptr CFloat)
-> IO Result
mkXrEnumerateDisplayRefreshRatesFB FunPtr
  (Ptr Session_T
   -> ("displayRefreshRateCapacityInput" ::: Word32)
   -> ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> ("displayRefreshRates" ::: Ptr CFloat)
   -> IO Result)
xrEnumerateDisplayRefreshRatesFBPtr
  let session' :: Ptr Session_T
session' = Session -> Ptr Session_T
sessionHandle (Session
session)
  "displayRefreshRateCountOutput"
::: Ptr ("displayRefreshRateCapacityInput" ::: Word32)
pDisplayRefreshRateCountOutput <- ((("displayRefreshRateCountOutput"
   ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
  -> IO (Result, "displayRefreshRates" ::: Vector Float))
 -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRateCountOutput"
      ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("displayRefreshRateCountOutput"
    ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
   -> IO (Result, "displayRefreshRates" ::: Vector Float))
  -> IO (Result, "displayRefreshRates" ::: Vector Float))
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      ("displayRefreshRateCountOutput"
       ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32)))
-> ((("displayRefreshRateCountOutput"
      ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
     -> IO (Result, "displayRefreshRates" ::: Vector Float))
    -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRateCountOutput"
      ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO
  ("displayRefreshRateCountOutput"
   ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> (("displayRefreshRateCountOutput"
     ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
    -> IO ())
-> (("displayRefreshRateCountOutput"
     ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
    -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> IO (Result, "displayRefreshRates" ::: Vector Float)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
     ("displayRefreshRateCountOutput"
      ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("displayRefreshRateCountOutput"
 ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float) IO Result)
-> IO Result
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateDisplayRefreshRatesFB" (Ptr Session_T
-> ("displayRefreshRateCapacityInput" ::: Word32)
-> ("displayRefreshRateCountOutput"
    ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> ("displayRefreshRates" ::: Ptr CFloat)
-> IO Result
xrEnumerateDisplayRefreshRatesFB' Ptr Session_T
session' (0) ("displayRefreshRateCountOutput"
::: Ptr ("displayRefreshRateCapacityInput" ::: Word32)
pDisplayRefreshRateCountOutput) ("displayRefreshRates" ::: Ptr CFloat
forall a. Ptr a
nullPtr))
  IO ()
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ())
-> IO ()
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
  "displayRefreshRateCapacityInput" ::: Word32
displayRefreshRateCountOutput <- IO ("displayRefreshRateCapacityInput" ::: Word32)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRateCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("displayRefreshRateCapacityInput" ::: Word32)
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      ("displayRefreshRateCapacityInput" ::: Word32))
-> IO ("displayRefreshRateCapacityInput" ::: Word32)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRateCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("displayRefreshRateCountOutput"
 ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> IO ("displayRefreshRateCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "displayRefreshRateCountOutput"
::: Ptr ("displayRefreshRateCapacityInput" ::: Word32)
pDisplayRefreshRateCountOutput
  "displayRefreshRates" ::: Ptr CFloat
pDisplayRefreshRates <- ((("displayRefreshRates" ::: Ptr CFloat)
  -> IO (Result, "displayRefreshRates" ::: Vector Float))
 -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRates" ::: Ptr CFloat)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("displayRefreshRates" ::: Ptr CFloat)
   -> IO (Result, "displayRefreshRates" ::: Vector Float))
  -> IO (Result, "displayRefreshRates" ::: Vector Float))
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      ("displayRefreshRates" ::: Ptr CFloat))
-> ((("displayRefreshRates" ::: Ptr CFloat)
     -> IO (Result, "displayRefreshRates" ::: Vector Float))
    -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRates" ::: Ptr CFloat)
forall a b. (a -> b) -> a -> b
$ IO ("displayRefreshRates" ::: Ptr CFloat)
-> (("displayRefreshRates" ::: Ptr CFloat) -> IO ())
-> (("displayRefreshRates" ::: Ptr CFloat)
    -> IO (Result, "displayRefreshRates" ::: Vector Float))
-> IO (Result, "displayRefreshRates" ::: Vector Float)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("displayRefreshRates" ::: Ptr CFloat)
forall a. Int -> IO (Ptr a)
callocBytes @CFloat ((("displayRefreshRateCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("displayRefreshRateCapacityInput" ::: Word32
displayRefreshRateCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 4)) ("displayRefreshRates" ::: Ptr CFloat) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r' <- IO Result
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float) IO Result)
-> IO Result
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateDisplayRefreshRatesFB" (Ptr Session_T
-> ("displayRefreshRateCapacityInput" ::: Word32)
-> ("displayRefreshRateCountOutput"
    ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> ("displayRefreshRates" ::: Ptr CFloat)
-> IO Result
xrEnumerateDisplayRefreshRatesFB' Ptr Session_T
session' (("displayRefreshRateCapacityInput" ::: Word32
displayRefreshRateCountOutput)) ("displayRefreshRateCountOutput"
::: Ptr ("displayRefreshRateCapacityInput" ::: Word32)
pDisplayRefreshRateCountOutput) ("displayRefreshRates" ::: Ptr CFloat
pDisplayRefreshRates))
  IO ()
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ())
-> IO ()
-> ContT (Result, "displayRefreshRates" ::: Vector Float) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r' Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r'))
  "displayRefreshRateCapacityInput" ::: Word32
displayRefreshRateCountOutput' <- IO ("displayRefreshRateCapacityInput" ::: Word32)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRateCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("displayRefreshRateCapacityInput" ::: Word32)
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      ("displayRefreshRateCapacityInput" ::: Word32))
-> IO ("displayRefreshRateCapacityInput" ::: Word32)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRateCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("displayRefreshRateCountOutput"
 ::: Ptr ("displayRefreshRateCapacityInput" ::: Word32))
-> IO ("displayRefreshRateCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "displayRefreshRateCountOutput"
::: Ptr ("displayRefreshRateCapacityInput" ::: Word32)
pDisplayRefreshRateCountOutput
  "displayRefreshRates" ::: Vector Float
displayRefreshRates' <- IO ("displayRefreshRates" ::: Vector Float)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRates" ::: Vector Float)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("displayRefreshRates" ::: Vector Float)
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      ("displayRefreshRates" ::: Vector Float))
-> IO ("displayRefreshRates" ::: Vector Float)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     ("displayRefreshRates" ::: Vector Float)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO Float) -> IO ("displayRefreshRates" ::: Vector Float)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("displayRefreshRateCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("displayRefreshRateCapacityInput" ::: Word32
displayRefreshRateCountOutput')) (\i :: Int
i -> do
    CFloat
displayRefreshRatesElem <- ("displayRefreshRates" ::: Ptr CFloat) -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat (("displayRefreshRates" ::: Ptr CFloat
pDisplayRefreshRates ("displayRefreshRates" ::: Ptr CFloat)
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr CFloat))
    Float -> IO Float
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Float -> IO Float) -> Float -> IO Float
forall a b. (a -> b) -> a -> b
$ CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
displayRefreshRatesElem)
  (Result, "displayRefreshRates" ::: Vector Float)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     (Result, "displayRefreshRates" ::: Vector Float)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "displayRefreshRates" ::: Vector Float)
 -> ContT
      (Result, "displayRefreshRates" ::: Vector Float)
      IO
      (Result, "displayRefreshRates" ::: Vector Float))
-> (Result, "displayRefreshRates" ::: Vector Float)
-> ContT
     (Result, "displayRefreshRates" ::: Vector Float)
     IO
     (Result, "displayRefreshRates" ::: Vector Float)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "displayRefreshRates" ::: Vector Float
displayRefreshRates')


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkXrGetDisplayRefreshRateFB
  :: FunPtr (Ptr Session_T -> Ptr CFloat -> IO Result) -> Ptr Session_T -> Ptr CFloat -> IO Result

-- | xrGetDisplayRefreshRateFB - Get the current display refresh rate
--
-- == Parameter Descriptions
--
-- = Description
--
-- 'getDisplayRefreshRateFB' retrieves the current display refresh rate.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrGetDisplayRefreshRateFB-extension-notenabled# The @@
--     extension /must/ be enabled prior to calling
--     'getDisplayRefreshRateFB'
--
-- -   #VUID-xrGetDisplayRefreshRateFB-session-parameter# @session@ /must/
--     be a valid 'OpenXR.Core10.Handles.Session' handle
--
-- -   #VUID-xrGetDisplayRefreshRateFB-displayRefreshRate-parameter#
--     @displayRefreshRate@ /must/ be a pointer to a @float@ value
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
--     -   'OpenXR.Core10.Enums.Result.SESSION_LOSS_PENDING'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_SESSION_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Session', 'enumerateDisplayRefreshRatesFB',
-- 'requestDisplayRefreshRateFB'
getDisplayRefreshRateFB :: forall io
                         . (MonadIO io)
                        => -- | @session@ is the 'OpenXR.Core10.Handles.Session' to query.
                           Session
                        -> io (Result, ("displayRefreshRate" ::: Float))
getDisplayRefreshRateFB :: Session -> io (Result, Float)
getDisplayRefreshRateFB session :: Session
session = IO (Result, Float) -> io (Result, Float)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, Float) -> io (Result, Float))
-> (ContT (Result, Float) IO (Result, Float) -> IO (Result, Float))
-> ContT (Result, Float) IO (Result, Float)
-> io (Result, Float)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, Float) IO (Result, Float) -> IO (Result, Float)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, Float) IO (Result, Float) -> io (Result, Float))
-> ContT (Result, Float) IO (Result, Float) -> io (Result, Float)
forall a b. (a -> b) -> a -> b
$ do
  let xrGetDisplayRefreshRateFBPtr :: FunPtr
  (Ptr Session_T
   -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
xrGetDisplayRefreshRateFBPtr = InstanceCmds
-> FunPtr
     (Ptr Session_T
      -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
pXrGetDisplayRefreshRateFB (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
  IO () -> ContT (Result, Float) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Float) IO ())
-> IO () -> ContT (Result, Float) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Session_T
   -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
xrGetDisplayRefreshRateFBPtr FunPtr
  (Ptr Session_T
   -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
-> FunPtr
     (Ptr Session_T
      -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Session_T
   -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrGetDisplayRefreshRateFB is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrGetDisplayRefreshRateFB' :: Ptr Session_T
-> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result
xrGetDisplayRefreshRateFB' = FunPtr
  (Ptr Session_T
   -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
-> Ptr Session_T
-> ("displayRefreshRates" ::: Ptr CFloat)
-> IO Result
mkXrGetDisplayRefreshRateFB FunPtr
  (Ptr Session_T
   -> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result)
xrGetDisplayRefreshRateFBPtr
  "displayRefreshRates" ::: Ptr CFloat
pDisplayRefreshRate <- ((("displayRefreshRates" ::: Ptr CFloat) -> IO (Result, Float))
 -> IO (Result, Float))
-> ContT (Result, Float) IO ("displayRefreshRates" ::: Ptr CFloat)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("displayRefreshRates" ::: Ptr CFloat) -> IO (Result, Float))
  -> IO (Result, Float))
 -> ContT (Result, Float) IO ("displayRefreshRates" ::: Ptr CFloat))
-> ((("displayRefreshRates" ::: Ptr CFloat) -> IO (Result, Float))
    -> IO (Result, Float))
-> ContT (Result, Float) IO ("displayRefreshRates" ::: Ptr CFloat)
forall a b. (a -> b) -> a -> b
$ IO ("displayRefreshRates" ::: Ptr CFloat)
-> (("displayRefreshRates" ::: Ptr CFloat) -> IO ())
-> (("displayRefreshRates" ::: Ptr CFloat) -> IO (Result, Float))
-> IO (Result, Float)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("displayRefreshRates" ::: Ptr CFloat)
forall a. Int -> IO (Ptr a)
callocBytes @CFloat 4) ("displayRefreshRates" ::: Ptr CFloat) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT (Result, Float) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, Float) IO Result)
-> IO Result -> ContT (Result, Float) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrGetDisplayRefreshRateFB" (Ptr Session_T
-> ("displayRefreshRates" ::: Ptr CFloat) -> IO Result
xrGetDisplayRefreshRateFB' (Session -> Ptr Session_T
sessionHandle (Session
session)) ("displayRefreshRates" ::: Ptr CFloat
pDisplayRefreshRate))
  IO () -> ContT (Result, Float) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Float) IO ())
-> IO () -> ContT (Result, Float) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
  CFloat
displayRefreshRate <- IO CFloat -> ContT (Result, Float) IO CFloat
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO CFloat -> ContT (Result, Float) IO CFloat)
-> IO CFloat -> ContT (Result, Float) IO CFloat
forall a b. (a -> b) -> a -> b
$ ("displayRefreshRates" ::: Ptr CFloat) -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat "displayRefreshRates" ::: Ptr CFloat
pDisplayRefreshRate
  (Result, Float) -> ContT (Result, Float) IO (Result, Float)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, Float) -> ContT (Result, Float) IO (Result, Float))
-> (Result, Float) -> ContT (Result, Float) IO (Result, Float)
forall a b. (a -> b) -> a -> b
$ (Result
r, (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
displayRefreshRate))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkXrRequestDisplayRefreshRateFB
  :: FunPtr (Ptr Session_T -> CFloat -> IO Result) -> Ptr Session_T -> CFloat -> IO Result

-- | xrRequestDisplayRefreshRateFB - Request a display refresh rate
--
-- == Parameter Descriptions
--
-- = Description
--
-- 'requestDisplayRefreshRateFB' provides a mechanism for an application to
-- request the system to dynamically change the display refresh rate to the
-- application preferred value. The runtime /must/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_DISPLAY_REFRESH_RATE_UNSUPPORTED_FB'
-- if @displayRefreshRate@ is not either @0.0f@ or one of the values
-- enumerated by 'enumerateDisplayRefreshRatesFB'. A display refresh rate
-- of @0.0f@ indicates the application has no preference.
--
-- Note that this is only a request and does not guarantee the system will
-- switch to the requested display refresh rate.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrRequestDisplayRefreshRateFB-extension-notenabled# The @@
--     extension /must/ be enabled prior to calling
--     'requestDisplayRefreshRateFB'
--
-- -   #VUID-xrRequestDisplayRefreshRateFB-session-parameter# @session@
--     /must/ be a valid 'OpenXR.Core10.Handles.Session' handle
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
--     -   'OpenXR.Core10.Enums.Result.SESSION_LOSS_PENDING'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_INSTANCE_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_SESSION_LOST'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_RUNTIME_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_DISPLAY_REFRESH_RATE_UNSUPPORTED_FB'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_FEATURE_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Session', 'enumerateDisplayRefreshRatesFB',
-- 'getDisplayRefreshRateFB'
requestDisplayRefreshRateFB :: forall io
                             . (MonadIO io)
                            => -- | @session@ is a valid 'OpenXR.Core10.Handles.Session' handle.
                               Session
                            -> -- | @displayRefreshRate@ is @0.0f@ or a supported display refresh rate.
                               -- Supported display refresh rates are indicated by
                               -- 'enumerateDisplayRefreshRatesFB'.
                               ("displayRefreshRate" ::: Float)
                            -> io (Result)
requestDisplayRefreshRateFB :: Session -> Float -> io Result
requestDisplayRefreshRateFB session :: Session
session displayRefreshRate :: Float
displayRefreshRate = IO Result -> io Result
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> io Result) -> IO Result -> io Result
forall a b. (a -> b) -> a -> b
$ do
  let xrRequestDisplayRefreshRateFBPtr :: FunPtr (Ptr Session_T -> CFloat -> IO Result)
xrRequestDisplayRefreshRateFBPtr = InstanceCmds -> FunPtr (Ptr Session_T -> CFloat -> IO Result)
pXrRequestDisplayRefreshRateFB (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Session_T -> CFloat -> IO Result)
xrRequestDisplayRefreshRateFBPtr FunPtr (Ptr Session_T -> CFloat -> IO Result)
-> FunPtr (Ptr Session_T -> CFloat -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Session_T -> CFloat -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for xrRequestDisplayRefreshRateFB is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrRequestDisplayRefreshRateFB' :: Ptr Session_T -> CFloat -> IO Result
xrRequestDisplayRefreshRateFB' = FunPtr (Ptr Session_T -> CFloat -> IO Result)
-> Ptr Session_T -> CFloat -> IO Result
mkXrRequestDisplayRefreshRateFB FunPtr (Ptr Session_T -> CFloat -> IO Result)
xrRequestDisplayRefreshRateFBPtr
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrRequestDisplayRefreshRateFB" (Ptr Session_T -> CFloat -> IO Result
xrRequestDisplayRefreshRateFB' (Session -> Ptr Session_T
sessionHandle (Session
session)) (Float -> CFloat
CFloat (Float
displayRefreshRate)))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (OpenXrException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> OpenXrException
OpenXrException Result
r))
  Result -> IO Result
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Result -> IO Result) -> Result -> IO Result
forall a b. (a -> b) -> a -> b
$ (Result
r)


-- | XrEventDataDisplayRefreshRateChangedFB - Event representing display
-- refresh rate change
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-XrEventDataDisplayRefreshRateChangedFB-extension-notenabled#
--     The @@ extension /must/ be enabled prior to using
--     'EventDataDisplayRefreshRateChangedFB'
--
-- -   #VUID-XrEventDataDisplayRefreshRateChangedFB-type-type# @type@
--     /must/ be
--     'OpenXR.Core10.Enums.StructureType.TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB'
--
-- -   #VUID-XrEventDataDisplayRefreshRateChangedFB-next-next# @next@
--     /must/ be @NULL@ or a valid pointer to the
--     <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#valid-usage-for-structure-pointer-chains next structure in a structure chain>
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- 'getDisplayRefreshRateFB'
data EventDataDisplayRefreshRateChangedFB = EventDataDisplayRefreshRateChangedFB
  { -- | @fromDisplayRefreshRate@ is the previous display refresh rate.
    EventDataDisplayRefreshRateChangedFB -> Float
fromDisplayRefreshRate :: Float
  , -- | @toDisplayRefreshRate@ is the new display refresh rate.
    EventDataDisplayRefreshRateChangedFB -> Float
toDisplayRefreshRate :: Float
  }
  deriving (Typeable, EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> Bool
(EventDataDisplayRefreshRateChangedFB
 -> EventDataDisplayRefreshRateChangedFB -> Bool)
-> (EventDataDisplayRefreshRateChangedFB
    -> EventDataDisplayRefreshRateChangedFB -> Bool)
-> Eq EventDataDisplayRefreshRateChangedFB
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> Bool
$c/= :: EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> Bool
== :: EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> Bool
$c== :: EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (EventDataDisplayRefreshRateChangedFB)
#endif
deriving instance Show EventDataDisplayRefreshRateChangedFB

instance IsEventData EventDataDisplayRefreshRateChangedFB where
  toEventDataBaseHeader :: EventDataDisplayRefreshRateChangedFB -> EventDataBaseHeader
toEventDataBaseHeader EventDataDisplayRefreshRateChangedFB{} = $WEventDataBaseHeader :: StructureType -> EventDataBaseHeader
EventDataBaseHeader{$sel:type':EventDataBaseHeader :: StructureType
type' = StructureType
TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB}

instance ToCStruct EventDataDisplayRefreshRateChangedFB where
  withCStruct :: EventDataDisplayRefreshRateChangedFB
-> (Ptr EventDataDisplayRefreshRateChangedFB -> IO b) -> IO b
withCStruct x :: EventDataDisplayRefreshRateChangedFB
x f :: Ptr EventDataDisplayRefreshRateChangedFB -> IO b
f = Int
-> Int
-> (Ptr EventDataDisplayRefreshRateChangedFB -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr EventDataDisplayRefreshRateChangedFB -> IO b) -> IO b)
-> (Ptr EventDataDisplayRefreshRateChangedFB -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr EventDataDisplayRefreshRateChangedFB
p -> Ptr EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr EventDataDisplayRefreshRateChangedFB
p EventDataDisplayRefreshRateChangedFB
x (Ptr EventDataDisplayRefreshRateChangedFB -> IO b
f Ptr EventDataDisplayRefreshRateChangedFB
p)
  pokeCStruct :: Ptr EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> IO b -> IO b
pokeCStruct p :: Ptr EventDataDisplayRefreshRateChangedFB
p EventDataDisplayRefreshRateChangedFB{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("displayRefreshRates" ::: Ptr CFloat) -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
fromDisplayRefreshRate))
    ("displayRefreshRates" ::: Ptr CFloat) -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
toDisplayRefreshRate))
    IO b
f
  cStructSize :: Int
cStructSize = 24
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr EventDataDisplayRefreshRateChangedFB -> IO b -> IO b
pokeZeroCStruct p :: Ptr EventDataDisplayRefreshRateChangedFB
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("displayRefreshRates" ::: Ptr CFloat) -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    ("displayRefreshRates" ::: Ptr CFloat) -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct EventDataDisplayRefreshRateChangedFB where
  peekCStruct :: Ptr EventDataDisplayRefreshRateChangedFB
-> IO EventDataDisplayRefreshRateChangedFB
peekCStruct p :: Ptr EventDataDisplayRefreshRateChangedFB
p = do
    CFloat
fromDisplayRefreshRate <- ("displayRefreshRates" ::: Ptr CFloat) -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr CFloat))
    CFloat
toDisplayRefreshRate <- ("displayRefreshRates" ::: Ptr CFloat) -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr EventDataDisplayRefreshRateChangedFB
p Ptr EventDataDisplayRefreshRateChangedFB
-> Int -> "displayRefreshRates" ::: Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr CFloat))
    EventDataDisplayRefreshRateChangedFB
-> IO EventDataDisplayRefreshRateChangedFB
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EventDataDisplayRefreshRateChangedFB
 -> IO EventDataDisplayRefreshRateChangedFB)
-> EventDataDisplayRefreshRateChangedFB
-> IO EventDataDisplayRefreshRateChangedFB
forall a b. (a -> b) -> a -> b
$ Float -> Float -> EventDataDisplayRefreshRateChangedFB
EventDataDisplayRefreshRateChangedFB
             (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
fromDisplayRefreshRate) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
toDisplayRefreshRate)

instance Storable EventDataDisplayRefreshRateChangedFB where
  sizeOf :: EventDataDisplayRefreshRateChangedFB -> Int
sizeOf ~EventDataDisplayRefreshRateChangedFB
_ = 24
  alignment :: EventDataDisplayRefreshRateChangedFB -> Int
alignment ~EventDataDisplayRefreshRateChangedFB
_ = 8
  peek :: Ptr EventDataDisplayRefreshRateChangedFB
-> IO EventDataDisplayRefreshRateChangedFB
peek = Ptr EventDataDisplayRefreshRateChangedFB
-> IO EventDataDisplayRefreshRateChangedFB
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> IO ()
poke ptr :: Ptr EventDataDisplayRefreshRateChangedFB
ptr poked :: EventDataDisplayRefreshRateChangedFB
poked = Ptr EventDataDisplayRefreshRateChangedFB
-> EventDataDisplayRefreshRateChangedFB -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr EventDataDisplayRefreshRateChangedFB
ptr EventDataDisplayRefreshRateChangedFB
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero EventDataDisplayRefreshRateChangedFB where
  zero :: EventDataDisplayRefreshRateChangedFB
zero = Float -> Float -> EventDataDisplayRefreshRateChangedFB
EventDataDisplayRefreshRateChangedFB
           Float
forall a. Zero a => a
zero
           Float
forall a. Zero a => a
zero


type FB_display_refresh_rate_SPEC_VERSION = 1

-- No documentation found for TopLevel "XR_FB_display_refresh_rate_SPEC_VERSION"
pattern FB_display_refresh_rate_SPEC_VERSION :: forall a . Integral a => a
pattern $bFB_display_refresh_rate_SPEC_VERSION :: a
$mFB_display_refresh_rate_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
FB_display_refresh_rate_SPEC_VERSION = 1


type FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME = "XR_FB_display_refresh_rate"

-- No documentation found for TopLevel "XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME"
pattern FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bFB_DISPLAY_REFRESH_RATE_EXTENSION_NAME :: a
$mFB_DISPLAY_REFRESH_RATE_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME = "XR_FB_display_refresh_rate"