{-# language CPP #-}
-- No documentation found for Chapter "Space"
module OpenXR.Core10.Space  ( destroySpace
                            , enumerateReferenceSpaces
                            , createReferenceSpace
                            , withReferenceSpace
                            , createActionSpace
                            , withActionSpace
                            , locateSpace
                            , getReferenceSpaceBoundsRect
                            , Vector3f(..)
                            , Quaternionf(..)
                            , Posef(..)
                            , ReferenceSpaceCreateInfo(..)
                            , ActionSpaceCreateInfo(..)
                            , SpaceLocation(..)
                            , SpaceVelocity(..)
                            ) where

import OpenXR.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
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 (castPtr)
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 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.Type.Equality ((:~:)(Refl))
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.CStruct.Extends (forgetExtensions)
import OpenXR.NamedType ((:::))
import OpenXR.Core10.Handles (Action_T)
import OpenXR.CStruct.Extends (Chain)
import OpenXR.CStruct.Extends (Extends)
import OpenXR.CStruct.Extends (Extendss)
import OpenXR.CStruct.Extends (Extensible(..))
import OpenXR.Core10.FundamentalTypes (Extent2Df)
import {-# SOURCE #-} OpenXR.Extensions.XR_EXT_eye_gaze_interaction (EyeGazeSampleTimeEXT)
import OpenXR.Dynamic (InstanceCmds(pXrCreateActionSpace))
import OpenXR.Dynamic (InstanceCmds(pXrCreateReferenceSpace))
import OpenXR.Dynamic (InstanceCmds(pXrDestroySpace))
import OpenXR.Dynamic (InstanceCmds(pXrEnumerateReferenceSpaces))
import OpenXR.Dynamic (InstanceCmds(pXrGetReferenceSpaceBoundsRect))
import OpenXR.Dynamic (InstanceCmds(pXrLocateSpace))
import OpenXR.Exception (OpenXrException(..))
import OpenXR.Core10.SemanticPaths (Path)
import OpenXR.CStruct.Extends (PeekChain)
import OpenXR.CStruct.Extends (PeekChain(..))
import OpenXR.CStruct.Extends (PokeChain)
import OpenXR.CStruct.Extends (PokeChain(..))
import OpenXR.Core10.Enums.ReferenceSpaceType (ReferenceSpaceType)
import OpenXR.Core10.Enums.ReferenceSpaceType (ReferenceSpaceType(..))
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.CStruct.Extends (SomeStruct)
import OpenXR.Core10.Handles (Space)
import OpenXR.Core10.Handles (Space(..))
import OpenXR.Core10.Handles (Space(Space))
import OpenXR.Core10.Enums.SpaceLocationFlags (SpaceLocationFlags)
import OpenXR.Core10.Enums.SpaceVelocityFlags (SpaceVelocityFlags)
import OpenXR.Core10.Handles (Space_T)
import OpenXR.Core10.Enums.StructureType (StructureType)
import OpenXR.Core10.FundamentalTypes (Time)
import OpenXR.Core10.Enums.Result (Result(SUCCESS))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_ACTION_SPACE_CREATE_INFO))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_REFERENCE_SPACE_CREATE_INFO))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_SPACE_LOCATION))
import OpenXR.Core10.Enums.StructureType (StructureType(TYPE_SPACE_VELOCITY))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkXrDestroySpace
  :: FunPtr (Ptr Space_T -> IO Result) -> Ptr Space_T -> IO Result

-- | xrDestroySpace - Creates a space based on a pose action
--
-- == Parameter Descriptions
--
-- = Description
--
-- 'OpenXR.Core10.Handles.Space' handles are destroyed using
-- 'destroySpace'. The runtime /may/ still use this space if there are
-- active dependencies (e.g, compositions in progress).
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrDestroySpace-space-parameter# @space@ /must/ be a valid
--     'OpenXR.Core10.Handles.Space' handle
--
-- == Thread Safety
--
-- -   Access to @space@, and any child handles, /must/ be externally
--     synchronized
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-successcodes Success>]
--
--     -   'OpenXR.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#fundamentals-errorcodes Failure>]
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Space', 'createActionSpace',
-- 'createReferenceSpace'
destroySpace :: forall io
              . (MonadIO io)
             => -- | @space@ is a handle to an 'OpenXR.Core10.Handles.Space' previously
                -- created by a function such as 'createReferenceSpace'.
                Space
             -> io ()
destroySpace :: Space -> io ()
destroySpace space :: Space
space = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  let xrDestroySpacePtr :: FunPtr (Ptr Space_T -> IO Result)
xrDestroySpacePtr = InstanceCmds -> FunPtr (Ptr Space_T -> IO Result)
pXrDestroySpace (Space -> InstanceCmds
instanceCmds (Space
space :: Space))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Space_T -> IO Result)
xrDestroySpacePtr FunPtr (Ptr Space_T -> IO Result)
-> FunPtr (Ptr Space_T -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Space_T -> 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 xrDestroySpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrDestroySpace' :: Ptr Space_T -> IO Result
xrDestroySpace' = FunPtr (Ptr Space_T -> IO Result) -> Ptr Space_T -> IO Result
mkXrDestroySpace FunPtr (Ptr Space_T -> IO Result)
xrDestroySpacePtr
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrDestroySpace" (Ptr Space_T -> IO Result
xrDestroySpace' (Space -> Ptr Space_T
spaceHandle (Space
space)))
  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))


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

-- | xrEnumerateReferenceSpaces - Enumerate available reference spaces
--
-- == Parameter Descriptions
--
-- -   @session@ is a handle to an 'OpenXR.Core10.Handles.Session'
--     previously created with 'OpenXR.Core10.Device.createSession'.
--
-- -   @spaceCapacityInput@ is the capacity of the spaces array, or 0 to
--     indicate a request to retrieve the required capacity.
--
-- -   @spaceCountOutput@ is a pointer to the count of spaces written, or a
--     pointer to the required capacity in the case that
--     @spaceCapacityInput@ is 0.
--
-- -   @spaces@ is a pointer to an application-allocated array that will be
--     filled with the enumerant of each supported reference space. It
--     /can/ be @NULL@ if @spaceCapacityInput@ 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
--     @spaces@ size.
--
-- = Description
--
-- Enumerates the set of reference space types that this runtime supports
-- for a given session. Runtimes /must/ always return identical buffer
-- contents from this enumeration for the lifetime of the session.
--
-- If a session enumerates support for a given reference space type, calls
-- to 'createReferenceSpace' /must/ succeed for that session, with any
-- transient unavailability of poses expressed later during calls to
-- 'locateSpace'.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrEnumerateReferenceSpaces-session-parameter# @session@ /must/
--     be a valid 'OpenXR.Core10.Handles.Session' handle
--
-- -   #VUID-xrEnumerateReferenceSpaces-spaceCountOutput-parameter#
--     @spaceCountOutput@ /must/ be a pointer to a @uint32_t@ value
--
-- -   #VUID-xrEnumerateReferenceSpaces-spaces-parameter# If
--     @spaceCapacityInput@ is not @0@, @spaces@ /must/ be a pointer to an
--     array of @spaceCapacityInput@
--     'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType' 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_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType',
-- 'OpenXR.Core10.Handles.Session', 'OpenXR.Core10.Handles.Space'
enumerateReferenceSpaces :: forall io
                          . (MonadIO io)
                         => -- No documentation found for Nested "xrEnumerateReferenceSpaces" "session"
                            Session
                         -> io (Result, ("spaces" ::: Vector ReferenceSpaceType))
enumerateReferenceSpaces :: Session -> io (Result, "spaces" ::: Vector ReferenceSpaceType)
enumerateReferenceSpaces session :: Session
session = IO (Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "spaces" ::: Vector ReferenceSpaceType)
 -> io (Result, "spaces" ::: Vector ReferenceSpaceType))
-> (ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      (Result, "spaces" ::: Vector ReferenceSpaceType)
    -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     (Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Result, "spaces" ::: Vector ReferenceSpaceType)
  IO
  (Result, "spaces" ::: Vector ReferenceSpaceType)
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Result, "spaces" ::: Vector ReferenceSpaceType)
   IO
   (Result, "spaces" ::: Vector ReferenceSpaceType)
 -> io (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     (Result, "spaces" ::: Vector ReferenceSpaceType)
-> io (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ do
  let xrEnumerateReferenceSpacesPtr :: FunPtr
  (Ptr Session_T
   -> ("spaceCapacityInput" ::: Word32)
   -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> ("spaces" ::: Ptr ReferenceSpaceType)
   -> IO Result)
xrEnumerateReferenceSpacesPtr = InstanceCmds
-> FunPtr
     (Ptr Session_T
      -> ("spaceCapacityInput" ::: Word32)
      -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
      -> ("spaces" ::: Ptr ReferenceSpaceType)
      -> IO Result)
pXrEnumerateReferenceSpaces (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
  IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ())
-> IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Session_T
   -> ("spaceCapacityInput" ::: Word32)
   -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> ("spaces" ::: Ptr ReferenceSpaceType)
   -> IO Result)
xrEnumerateReferenceSpacesPtr FunPtr
  (Ptr Session_T
   -> ("spaceCapacityInput" ::: Word32)
   -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> ("spaces" ::: Ptr ReferenceSpaceType)
   -> IO Result)
-> FunPtr
     (Ptr Session_T
      -> ("spaceCapacityInput" ::: Word32)
      -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
      -> ("spaces" ::: Ptr ReferenceSpaceType)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Session_T
   -> ("spaceCapacityInput" ::: Word32)
   -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> ("spaces" ::: Ptr ReferenceSpaceType)
   -> 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 xrEnumerateReferenceSpaces is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrEnumerateReferenceSpaces' :: Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
xrEnumerateReferenceSpaces' = FunPtr
  (Ptr Session_T
   -> ("spaceCapacityInput" ::: Word32)
   -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> ("spaces" ::: Ptr ReferenceSpaceType)
   -> IO Result)
-> Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
mkXrEnumerateReferenceSpaces FunPtr
  (Ptr Session_T
   -> ("spaceCapacityInput" ::: Word32)
   -> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> ("spaces" ::: Ptr ReferenceSpaceType)
   -> IO Result)
xrEnumerateReferenceSpacesPtr
  let session' :: Ptr Session_T
session' = Session -> Ptr Session_T
sessionHandle (Session
session)
  "spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput <- ((("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
  -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
 -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
   -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
  -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)))
-> ((("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
     -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
    -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> (("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
    -> IO ())
-> (("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
    -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int
-> IO
     ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result)
-> IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateReferenceSpaces" (Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
xrEnumerateReferenceSpaces' Ptr Session_T
session' (0) ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput) ("spaces" ::: Ptr ReferenceSpaceType
forall a. Ptr a
nullPtr))
  IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ())
-> IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) 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))
  "spaceCapacityInput" ::: Word32
spaceCountOutput <- IO ("spaceCapacityInput" ::: Word32)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaceCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("spaceCapacityInput" ::: Word32)
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      ("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaceCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput
  "spaces" ::: Ptr ReferenceSpaceType
pSpaces <- ((("spaces" ::: Ptr ReferenceSpaceType)
  -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
 -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaces" ::: Ptr ReferenceSpaceType)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("spaces" ::: Ptr ReferenceSpaceType)
   -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
  -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      ("spaces" ::: Ptr ReferenceSpaceType))
-> ((("spaces" ::: Ptr ReferenceSpaceType)
     -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
    -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaces" ::: Ptr ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ IO ("spaces" ::: Ptr ReferenceSpaceType)
-> (("spaces" ::: Ptr ReferenceSpaceType) -> IO ())
-> (("spaces" ::: Ptr ReferenceSpaceType)
    -> IO (Result, "spaces" ::: Vector ReferenceSpaceType))
-> IO (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("spaces" ::: Ptr ReferenceSpaceType)
forall a. Int -> IO (Ptr a)
callocBytes @ReferenceSpaceType ((("spaceCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("spaceCapacityInput" ::: Word32
spaceCountOutput)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 4)) ("spaces" ::: Ptr ReferenceSpaceType) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r' <- IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result)
-> IO Result
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrEnumerateReferenceSpaces" (Ptr Session_T
-> ("spaceCapacityInput" ::: Word32)
-> ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> ("spaces" ::: Ptr ReferenceSpaceType)
-> IO Result
xrEnumerateReferenceSpaces' Ptr Session_T
session' (("spaceCapacityInput" ::: Word32
spaceCountOutput)) ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput) ("spaces" ::: Ptr ReferenceSpaceType
pSpaces))
  IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) IO ())
-> IO ()
-> ContT (Result, "spaces" ::: Vector ReferenceSpaceType) 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'))
  "spaceCapacityInput" ::: Word32
spaceCountOutput' <- IO ("spaceCapacityInput" ::: Word32)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaceCapacityInput" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("spaceCapacityInput" ::: Word32)
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      ("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaceCapacityInput" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32))
-> IO ("spaceCapacityInput" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 "spaceCountOutput" ::: Ptr ("spaceCapacityInput" ::: Word32)
pSpaceCountOutput
  "spaces" ::: Vector ReferenceSpaceType
spaces' <- IO ("spaces" ::: Vector ReferenceSpaceType)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaces" ::: Vector ReferenceSpaceType)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("spaces" ::: Vector ReferenceSpaceType)
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      ("spaces" ::: Vector ReferenceSpaceType))
-> IO ("spaces" ::: Vector ReferenceSpaceType)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     ("spaces" ::: Vector ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO ReferenceSpaceType)
-> IO ("spaces" ::: Vector ReferenceSpaceType)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("spaceCapacityInput" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ("spaceCapacityInput" ::: Word32
spaceCountOutput')) (\i :: Int
i -> ("spaces" ::: Ptr ReferenceSpaceType) -> IO ReferenceSpaceType
forall a. Storable a => Ptr a -> IO a
peek @ReferenceSpaceType (("spaces" ::: Ptr ReferenceSpaceType
pSpaces ("spaces" ::: Ptr ReferenceSpaceType)
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr ReferenceSpaceType)))
  (Result, "spaces" ::: Vector ReferenceSpaceType)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     (Result, "spaces" ::: Vector ReferenceSpaceType)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "spaces" ::: Vector ReferenceSpaceType)
 -> ContT
      (Result, "spaces" ::: Vector ReferenceSpaceType)
      IO
      (Result, "spaces" ::: Vector ReferenceSpaceType))
-> (Result, "spaces" ::: Vector ReferenceSpaceType)
-> ContT
     (Result, "spaces" ::: Vector ReferenceSpaceType)
     IO
     (Result, "spaces" ::: Vector ReferenceSpaceType)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "spaces" ::: Vector ReferenceSpaceType
spaces')


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

-- | xrCreateReferenceSpace - Creates a reference space
--
-- == Parameter Descriptions
--
-- = Description
--
-- Creates an 'OpenXR.Core10.Handles.Space' handle based on a chosen
-- reference space. Application /can/ provide an 'Posef' to define the
-- position and orientation of the new space’s origin within the natural
-- reference frame of the reference space.
--
-- Multiple 'OpenXR.Core10.Handles.Space' handles may exist simultaneously,
-- up to some limit imposed by the runtime. The
-- 'OpenXR.Core10.Handles.Space' handle /must/ be eventually freed via the
-- 'destroySpace' function.
--
-- The runtime /must/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_REFERENCE_SPACE_UNSUPPORTED' if the
-- given reference space type is not supported by this @session@.
--
-- == 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_LIMIT_REACHED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_OUT_OF_MEMORY'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_REFERENCE_SPACE_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_POSE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
-- = See Also
--
-- 'ReferenceSpaceCreateInfo', 'OpenXR.Core10.Handles.Session',
-- 'OpenXR.Core10.Handles.Space', 'destroySpace'
createReferenceSpace :: forall io
                      . (MonadIO io)
                     => -- | @session@ is a handle to an 'OpenXR.Core10.Handles.Session' previously
                        -- created with 'OpenXR.Core10.Device.createSession'.
                        --
                        -- #VUID-xrCreateReferenceSpace-session-parameter# @session@ /must/ be a
                        -- valid 'OpenXR.Core10.Handles.Session' handle
                        Session
                     -> -- | @createInfo@ is the 'ReferenceSpaceCreateInfo' used to specify the
                        -- space.
                        --
                        -- #VUID-xrCreateReferenceSpace-createInfo-parameter# @createInfo@ /must/
                        -- be a pointer to a valid 'ReferenceSpaceCreateInfo' structure
                        ReferenceSpaceCreateInfo
                     -> io (Result, Space)
createReferenceSpace :: Session -> ReferenceSpaceCreateInfo -> io (Result, Space)
createReferenceSpace session :: Session
session createInfo :: ReferenceSpaceCreateInfo
createInfo = IO (Result, Space) -> io (Result, Space)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, Space) -> io (Result, Space))
-> (ContT (Result, Space) IO (Result, Space) -> IO (Result, Space))
-> ContT (Result, Space) IO (Result, Space)
-> io (Result, Space)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, Space) IO (Result, Space) -> IO (Result, Space)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, Space) IO (Result, Space) -> io (Result, Space))
-> ContT (Result, Space) IO (Result, Space) -> io (Result, Space)
forall a b. (a -> b) -> a -> b
$ do
  let cmds :: InstanceCmds
cmds = Session -> InstanceCmds
instanceCmds (Session
session :: Session)
  let xrCreateReferenceSpacePtr :: FunPtr
  (Ptr Session_T
   -> Ptr ReferenceSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
xrCreateReferenceSpacePtr = InstanceCmds
-> FunPtr
     (Ptr Session_T
      -> Ptr ReferenceSpaceCreateInfo
      -> ("space" ::: Ptr (Ptr Space_T))
      -> IO Result)
pXrCreateReferenceSpace InstanceCmds
cmds
  IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Session_T
   -> Ptr ReferenceSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
xrCreateReferenceSpacePtr FunPtr
  (Ptr Session_T
   -> Ptr ReferenceSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
-> FunPtr
     (Ptr Session_T
      -> Ptr ReferenceSpaceCreateInfo
      -> ("space" ::: Ptr (Ptr Space_T))
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Session_T
   -> Ptr ReferenceSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> 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 xrCreateReferenceSpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrCreateReferenceSpace' :: Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateReferenceSpace' = FunPtr
  (Ptr Session_T
   -> Ptr ReferenceSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
-> Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
mkXrCreateReferenceSpace FunPtr
  (Ptr Session_T
   -> Ptr ReferenceSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
xrCreateReferenceSpacePtr
  Ptr ReferenceSpaceCreateInfo
createInfo' <- ((Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
 -> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ReferenceSpaceCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
  -> IO (Result, Space))
 -> ContT (Result, Space) IO (Ptr ReferenceSpaceCreateInfo))
-> ((Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
    -> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ReferenceSpaceCreateInfo)
forall a b. (a -> b) -> a -> b
$ ReferenceSpaceCreateInfo
-> (Ptr ReferenceSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ReferenceSpaceCreateInfo
createInfo)
  "space" ::: Ptr (Ptr Space_T)
pSpace <- ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
 -> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
  -> IO (Result, Space))
 -> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T)))
-> ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
    -> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall a b. (a -> b) -> a -> b
$ IO ("space" ::: Ptr (Ptr Space_T))
-> (("space" ::: Ptr (Ptr Space_T)) -> IO ())
-> (("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("space" ::: Ptr (Ptr Space_T))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr Space_T) 8) ("space" ::: Ptr (Ptr Space_T)) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT (Result, Space) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, Space) IO Result)
-> IO Result -> ContT (Result, Space) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrCreateReferenceSpace" (Ptr Session_T
-> Ptr ReferenceSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateReferenceSpace' (Session -> Ptr Session_T
sessionHandle (Session
session)) Ptr ReferenceSpaceCreateInfo
createInfo' ("space" ::: Ptr (Ptr Space_T)
pSpace))
  IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) 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))
  Ptr Space_T
space <- IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T))
-> IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall a b. (a -> b) -> a -> b
$ ("space" ::: Ptr (Ptr Space_T)) -> IO (Ptr Space_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Space_T) "space" ::: Ptr (Ptr Space_T)
pSpace
  (Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, Space) -> ContT (Result, Space) IO (Result, Space))
-> (Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall a b. (a -> b) -> a -> b
$ (Result
r, ((\h :: Ptr Space_T
h -> Ptr Space_T -> InstanceCmds -> Space
Space Ptr Space_T
h InstanceCmds
cmds ) Ptr Space_T
space))

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createReferenceSpace' and 'destroySpace'
--
-- To ensure that 'destroySpace' is always called: pass
-- 'Control.Exception.bracket' (or the allocate function from your
-- favourite resource management library) as the last argument.
-- To just extract the pair pass '(,)' as the last argument.
--
withReferenceSpace :: forall io r . MonadIO io => Session -> ReferenceSpaceCreateInfo -> (io (Result, Space) -> ((Result, Space) -> io ()) -> r) -> r
withReferenceSpace :: Session
-> ReferenceSpaceCreateInfo
-> (io (Result, Space) -> ((Result, Space) -> io ()) -> r)
-> r
withReferenceSpace session :: Session
session createInfo :: ReferenceSpaceCreateInfo
createInfo b :: io (Result, Space) -> ((Result, Space) -> io ()) -> r
b =
  io (Result, Space) -> ((Result, Space) -> io ()) -> r
b (Session -> ReferenceSpaceCreateInfo -> io (Result, Space)
forall (io :: * -> *).
MonadIO io =>
Session -> ReferenceSpaceCreateInfo -> io (Result, Space)
createReferenceSpace Session
session ReferenceSpaceCreateInfo
createInfo)
    (\(_, o1 :: Space
o1) -> Space -> io ()
forall (io :: * -> *). MonadIO io => Space -> io ()
destroySpace Space
o1)


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

-- | xrCreateActionSpace - Creates a space based on a pose action
--
-- == Parameter Descriptions
--
-- = Description
--
-- Creates an 'OpenXR.Core10.Handles.Space' handle based on a chosen pose
-- action. Application /can/ provide an 'Posef' to define the position and
-- orientation of the new space’s origin within the natural reference frame
-- of the action space.
--
-- Multiple 'OpenXR.Core10.Handles.Space' handles may exist simultaneously,
-- up to some limit imposed by the runtime. The
-- 'OpenXR.Core10.Handles.Space' handle must be eventually freed via the
-- 'destroySpace' function or by destroying the parent
-- 'OpenXR.Core10.Handles.Action' handle.
--
-- The runtime /must/ return
-- 'OpenXR.Core10.Enums.Result.ERROR_ACTION_TYPE_MISMATCH' if the action
-- provided in @action@ is not of type
-- 'OpenXR.Core10.Enums.ActionType.ACTION_TYPE_POSE_INPUT'.
--
-- == 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_OUT_OF_MEMORY'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_HANDLE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_ACTION_TYPE_MISMATCH'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_LIMIT_REACHED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_POSE_INVALID'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_VALIDATION_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_PATH_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_PATH_INVALID'
--
-- = See Also
--
-- 'ActionSpaceCreateInfo', 'OpenXR.Core10.Handles.Session',
-- 'OpenXR.Core10.Handles.Space', 'destroySpace'
createActionSpace :: forall io
                   . (MonadIO io)
                  => -- | @session@ is the 'OpenXR.Core10.Handles.Session' to create the action
                     -- space in.
                     --
                     -- #VUID-xrCreateActionSpace-session-parameter# @session@ /must/ be a valid
                     -- 'OpenXR.Core10.Handles.Session' handle
                     Session
                  -> -- | @createInfo@ is the 'ActionSpaceCreateInfo' used to specify the space.
                     --
                     -- #VUID-xrCreateActionSpace-createInfo-parameter# @createInfo@ /must/ be a
                     -- pointer to a valid 'ActionSpaceCreateInfo' structure
                     ActionSpaceCreateInfo
                  -> io (Result, Space)
createActionSpace :: Session -> ActionSpaceCreateInfo -> io (Result, Space)
createActionSpace session :: Session
session createInfo :: ActionSpaceCreateInfo
createInfo = IO (Result, Space) -> io (Result, Space)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, Space) -> io (Result, Space))
-> (ContT (Result, Space) IO (Result, Space) -> IO (Result, Space))
-> ContT (Result, Space) IO (Result, Space)
-> io (Result, Space)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, Space) IO (Result, Space) -> IO (Result, Space)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, Space) IO (Result, Space) -> io (Result, Space))
-> ContT (Result, Space) IO (Result, Space) -> io (Result, Space)
forall a b. (a -> b) -> a -> b
$ do
  let cmds :: InstanceCmds
cmds = Session -> InstanceCmds
instanceCmds (Session
session :: Session)
  let xrCreateActionSpacePtr :: FunPtr
  (Ptr Session_T
   -> Ptr ActionSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
xrCreateActionSpacePtr = InstanceCmds
-> FunPtr
     (Ptr Session_T
      -> Ptr ActionSpaceCreateInfo
      -> ("space" ::: Ptr (Ptr Space_T))
      -> IO Result)
pXrCreateActionSpace InstanceCmds
cmds
  IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Session_T
   -> Ptr ActionSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
xrCreateActionSpacePtr FunPtr
  (Ptr Session_T
   -> Ptr ActionSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
-> FunPtr
     (Ptr Session_T
      -> Ptr ActionSpaceCreateInfo
      -> ("space" ::: Ptr (Ptr Space_T))
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Session_T
   -> Ptr ActionSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> 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 xrCreateActionSpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrCreateActionSpace' :: Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateActionSpace' = FunPtr
  (Ptr Session_T
   -> Ptr ActionSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
-> Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
mkXrCreateActionSpace FunPtr
  (Ptr Session_T
   -> Ptr ActionSpaceCreateInfo
   -> ("space" ::: Ptr (Ptr Space_T))
   -> IO Result)
xrCreateActionSpacePtr
  Ptr ActionSpaceCreateInfo
createInfo' <- ((Ptr ActionSpaceCreateInfo -> IO (Result, Space))
 -> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ActionSpaceCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ActionSpaceCreateInfo -> IO (Result, Space))
  -> IO (Result, Space))
 -> ContT (Result, Space) IO (Ptr ActionSpaceCreateInfo))
-> ((Ptr ActionSpaceCreateInfo -> IO (Result, Space))
    -> IO (Result, Space))
-> ContT (Result, Space) IO (Ptr ActionSpaceCreateInfo)
forall a b. (a -> b) -> a -> b
$ ActionSpaceCreateInfo
-> (Ptr ActionSpaceCreateInfo -> IO (Result, Space))
-> IO (Result, Space)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ActionSpaceCreateInfo
createInfo)
  "space" ::: Ptr (Ptr Space_T)
pSpace <- ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
 -> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
  -> IO (Result, Space))
 -> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T)))
-> ((("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
    -> IO (Result, Space))
-> ContT (Result, Space) IO ("space" ::: Ptr (Ptr Space_T))
forall a b. (a -> b) -> a -> b
$ IO ("space" ::: Ptr (Ptr Space_T))
-> (("space" ::: Ptr (Ptr Space_T)) -> IO ())
-> (("space" ::: Ptr (Ptr Space_T)) -> IO (Result, Space))
-> IO (Result, Space)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("space" ::: Ptr (Ptr Space_T))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr Space_T) 8) ("space" ::: Ptr (Ptr Space_T)) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT (Result, Space) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, Space) IO Result)
-> IO Result -> ContT (Result, Space) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrCreateActionSpace" (Ptr Session_T
-> Ptr ActionSpaceCreateInfo
-> ("space" ::: Ptr (Ptr Space_T))
-> IO Result
xrCreateActionSpace' (Session -> Ptr Session_T
sessionHandle (Session
session)) Ptr ActionSpaceCreateInfo
createInfo' ("space" ::: Ptr (Ptr Space_T)
pSpace))
  IO () -> ContT (Result, Space) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, Space) IO ())
-> IO () -> ContT (Result, Space) 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))
  Ptr Space_T
space <- IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T))
-> IO (Ptr Space_T) -> ContT (Result, Space) IO (Ptr Space_T)
forall a b. (a -> b) -> a -> b
$ ("space" ::: Ptr (Ptr Space_T)) -> IO (Ptr Space_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Space_T) "space" ::: Ptr (Ptr Space_T)
pSpace
  (Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, Space) -> ContT (Result, Space) IO (Result, Space))
-> (Result, Space) -> ContT (Result, Space) IO (Result, Space)
forall a b. (a -> b) -> a -> b
$ (Result
r, ((\h :: Ptr Space_T
h -> Ptr Space_T -> InstanceCmds -> Space
Space Ptr Space_T
h InstanceCmds
cmds ) Ptr Space_T
space))

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createActionSpace' and 'destroySpace'
--
-- To ensure that 'destroySpace' is always called: pass
-- 'Control.Exception.bracket' (or the allocate function from your
-- favourite resource management library) as the last argument.
-- To just extract the pair pass '(,)' as the last argument.
--
withActionSpace :: forall io r . MonadIO io => Session -> ActionSpaceCreateInfo -> (io (Result, Space) -> ((Result, Space) -> io ()) -> r) -> r
withActionSpace :: Session
-> ActionSpaceCreateInfo
-> (io (Result, Space) -> ((Result, Space) -> io ()) -> r)
-> r
withActionSpace session :: Session
session createInfo :: ActionSpaceCreateInfo
createInfo b :: io (Result, Space) -> ((Result, Space) -> io ()) -> r
b =
  io (Result, Space) -> ((Result, Space) -> io ()) -> r
b (Session -> ActionSpaceCreateInfo -> io (Result, Space)
forall (io :: * -> *).
MonadIO io =>
Session -> ActionSpaceCreateInfo -> io (Result, Space)
createActionSpace Session
session ActionSpaceCreateInfo
createInfo)
    (\(_, o1 :: Space
o1) -> Space -> io ()
forall (io :: * -> *). MonadIO io => Space -> io ()
destroySpace Space
o1)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkXrLocateSpace
  :: FunPtr (Ptr Space_T -> Ptr Space_T -> Time -> Ptr (SomeStruct SpaceLocation) -> IO Result) -> Ptr Space_T -> Ptr Space_T -> Time -> Ptr (SomeStruct SpaceLocation) -> IO Result

-- | xrLocateSpace - Locates a space with reference to another space
--
-- == Parameter Descriptions
--
-- = Description
--
-- For a @time@ in the past, the runtime /should/ locate the spaces based
-- on the runtime’s most accurate current understanding of how the world
-- was at that historical time.
--
-- For a @time@ in the future, the runtime /should/ locate the spaces based
-- on the runtime’s most up-to-date prediction of how the world will be at
-- that future time.
--
-- The minimum valid range of values for @time@ are described in
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#prediction-time-limits>.
-- For values of @time@ outside this range, 'locateSpace' /may/ return a
-- location with no position and @XR_SPACE_LOCATION_POSITION_VALID_BIT@
-- unset.
--
-- Some devices improve their understanding of the world as the device is
-- used. The location returned by 'locateSpace' for a given @space@,
-- @baseSpace@ and @time@ /may/ change over time, even for spaces that
-- track static objects, as one or both spaces adjust their origins.
--
-- During tracking loss of @space@ relative to @baseSpace@, runtimes
-- /should/ continue to provide inferred or last-known @position@ and
-- @orientation@ values. These inferred poses can, for example, be based on
-- neck model updates, inertial dead reckoning, or a last-known position,
-- so long as it is still reasonable for the application to use that pose.
-- While a runtime is providing position data, it /must/ continue to set
-- @XR_SPACE_LOCATION_POSITION_VALID_BIT@ but it /can/ clear
-- @XR_SPACE_LOCATION_POSITION_TRACKED_BIT@ to indicate that the position
-- is inferred or last-known in this way.
--
-- If the runtime has not yet observed even a last-known pose for how to
-- locate @space@ in @baseSpace@ (e.g. one space is an action space bound
-- to a motion controller that has not yet been detected, or the two spaces
-- are in disconnected fragments of the runtime’s tracked volume), the
-- runtime /should/ return a location with no position and
-- @XR_SPACE_LOCATION_POSITION_VALID_BIT@ unset.
--
-- The runtime /must/ return a location with both
-- @XR_SPACE_LOCATION_POSITION_VALID_BIT@ and
-- @XR_SPACE_LOCATION_POSITION_TRACKED_BIT@ set when locating @space@ and
-- @baseSpace@ if both spaces were created relative to the same entity
-- (e.g. two action spaces for the same action), even if the entity is
-- currently untracked. The location in this case is the difference in the
-- two spaces\' application-specified transforms relative to that common
-- entity.
--
-- The runtime /should/ return a location with
-- @XR_SPACE_LOCATION_POSITION_VALID_BIT@ set and
-- @XR_SPACE_LOCATION_POSITION_TRACKED_BIT@ unset for spaces tracking two
-- static entities in the world when their relative pose is known to the
-- runtime. This enables applications to make use of the runtime’s latest
-- knowledge of the world, even during tracking loss.
--
-- If an 'SpaceVelocity' structure is chained to the @next@ pointer of
-- 'SpaceLocation' and the velocity is observed or can be calculated by the
-- runtime, the runtime /must/ fill in the linear velocity of the origin of
-- space within the reference frame of @baseSpace@ and set the
-- @XR_SPACE_VELOCITY_LINEAR_VALID_BIT@. Similarly, if an 'SpaceVelocity'
-- structure is chained to the @next@ pointer of 'SpaceLocation' and the
-- angular velocity is observed or can be calculated by the runtime, the
-- runtime /must/ fill in the angular velocity of the origin of space
-- within the reference frame of @baseSpace@ and set the
-- @XR_SPACE_VELOCITY_ANGULAR_VALID_BIT@.
--
-- The following example code shows how an application can get both the
-- location and velocity of a space within a base space using the
-- 'locateSpace' function by chaining an 'SpaceVelocity' to the next
-- pointer of 'SpaceLocation' and calling 'locateSpace'.
--
-- > XrSpace space;      // previously initialized
-- > XrSpace baseSpace;  // previously initialized
-- > XrTime time;        // previously initialized
-- >
-- > XrSpaceVelocity velocity {XR_TYPE_SPACE_VELOCITY};
-- > XrSpaceLocation location {XR_TYPE_SPACE_LOCATION, &velocity};
-- > xrLocateSpace(space, baseSpace, time, &location);
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-xrLocateSpace-space-parameter# @space@ /must/ be a valid
--     'OpenXR.Core10.Handles.Space' handle
--
-- -   #VUID-xrLocateSpace-baseSpace-parameter# @baseSpace@ /must/ be a
--     valid 'OpenXR.Core10.Handles.Space' handle
--
-- -   #VUID-xrLocateSpace-location-parameter# @location@ /must/ be a
--     pointer to an 'SpaceLocation' structure
--
-- -   #VUID-xrLocateSpace-commonparent# Both of @baseSpace@ and @space@
--     /must/ have been created, allocated, or retrieved from the same
--     'OpenXR.Core10.Handles.Session'
--
-- == 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_VALIDATION_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_TIME_INVALID'
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Space', 'SpaceLocation',
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrSpaceLocationFlagBits XrSpaceLocationFlagBits>,
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrTime >
locateSpace :: forall a io
             . (Extendss SpaceLocation a, PokeChain a, PeekChain a, MonadIO io)
            => -- | @space@ identifies the target space to locate.
               Space
            -> -- | @baseSpace@ identifies the underlying space in which to locate @space@.
               ("baseSpace" ::: Space)
            -> -- | @time@ is the time for which the location should be provided.
               Time
            -> io (Result, SpaceLocation a)
locateSpace :: Space -> Space -> Time -> io (Result, SpaceLocation a)
locateSpace space :: Space
space baseSpace :: Space
baseSpace time :: Time
time = IO (Result, SpaceLocation a) -> io (Result, SpaceLocation a)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, SpaceLocation a) -> io (Result, SpaceLocation a))
-> (ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
    -> IO (Result, SpaceLocation a))
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> io (Result, SpaceLocation a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> IO (Result, SpaceLocation a)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
 -> io (Result, SpaceLocation a))
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
-> io (Result, SpaceLocation a)
forall a b. (a -> b) -> a -> b
$ do
  let xrLocateSpacePtr :: FunPtr
  (Ptr Space_T
   -> Ptr Space_T
   -> Time
   -> ("location" ::: Ptr (SomeStruct SpaceLocation))
   -> IO Result)
xrLocateSpacePtr = InstanceCmds
-> FunPtr
     (Ptr Space_T
      -> Ptr Space_T
      -> Time
      -> ("location" ::: Ptr (SomeStruct SpaceLocation))
      -> IO Result)
pXrLocateSpace (Space -> InstanceCmds
instanceCmds (Space
space :: Space))
  IO () -> ContT (Result, SpaceLocation a) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, SpaceLocation a) IO ())
-> IO () -> ContT (Result, SpaceLocation a) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Space_T
   -> Ptr Space_T
   -> Time
   -> ("location" ::: Ptr (SomeStruct SpaceLocation))
   -> IO Result)
xrLocateSpacePtr FunPtr
  (Ptr Space_T
   -> Ptr Space_T
   -> Time
   -> ("location" ::: Ptr (SomeStruct SpaceLocation))
   -> IO Result)
-> FunPtr
     (Ptr Space_T
      -> Ptr Space_T
      -> Time
      -> ("location" ::: Ptr (SomeStruct SpaceLocation))
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Space_T
   -> Ptr Space_T
   -> Time
   -> ("location" ::: Ptr (SomeStruct SpaceLocation))
   -> 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 xrLocateSpace is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrLocateSpace' :: Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result
xrLocateSpace' = FunPtr
  (Ptr Space_T
   -> Ptr Space_T
   -> Time
   -> ("location" ::: Ptr (SomeStruct SpaceLocation))
   -> IO Result)
-> Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result
mkXrLocateSpace FunPtr
  (Ptr Space_T
   -> Ptr Space_T
   -> Time
   -> ("location" ::: Ptr (SomeStruct SpaceLocation))
   -> IO Result)
xrLocateSpacePtr
  Ptr (SpaceLocation a)
pLocation <- ((Ptr (SpaceLocation a) -> IO (Result, SpaceLocation a))
 -> IO (Result, SpaceLocation a))
-> ContT (Result, SpaceLocation a) IO (Ptr (SpaceLocation a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct (SpaceLocation a) =>
(Ptr (SpaceLocation a) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @(SpaceLocation _))
  Result
r <- IO Result -> ContT (Result, SpaceLocation a) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, SpaceLocation a) IO Result)
-> IO Result -> ContT (Result, SpaceLocation a) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrLocateSpace" (Ptr Space_T
-> Ptr Space_T
-> Time
-> ("location" ::: Ptr (SomeStruct SpaceLocation))
-> IO Result
xrLocateSpace' (Space -> Ptr Space_T
spaceHandle (Space
space)) (Space -> Ptr Space_T
spaceHandle (Space
baseSpace)) (Time
time) (Ptr (SpaceLocation a)
-> "location" ::: Ptr (SomeStruct SpaceLocation)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (SpaceLocation a)
pLocation)))
  IO () -> ContT (Result, SpaceLocation a) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, SpaceLocation a) IO ())
-> IO () -> ContT (Result, SpaceLocation a) 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))
  SpaceLocation a
location <- IO (SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (SpaceLocation a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (SpaceLocation a)
 -> ContT (Result, SpaceLocation a) IO (SpaceLocation a))
-> IO (SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (SpaceLocation a)
forall a b. (a -> b) -> a -> b
$ Ptr (SpaceLocation a) -> IO (SpaceLocation a)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @(SpaceLocation _) Ptr (SpaceLocation a)
pLocation
  (Result, SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, SpaceLocation a)
 -> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a))
-> (Result, SpaceLocation a)
-> ContT (Result, SpaceLocation a) IO (Result, SpaceLocation a)
forall a b. (a -> b) -> a -> b
$ (Result
r, SpaceLocation a
location)


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

-- | xrGetReferenceSpaceBoundsRect - Gets the bounds rectangle of a reference
-- space
--
-- == 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.SPACE_BOUNDS_UNAVAILABLE'
--
--     -   '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_VALIDATION_FAILURE'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_FUNCTION_UNSUPPORTED'
--
--     -   'OpenXR.Core10.Enums.Result.ERROR_REFERENCE_SPACE_UNSUPPORTED'
--
-- = See Also
--
-- 'OpenXR.Core10.FundamentalTypes.Extent2Df',
-- 'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType',
-- 'OpenXR.Core10.Handles.Session', 'createReferenceSpace'
getReferenceSpaceBoundsRect :: forall io
                             . (MonadIO io)
                            => -- | @session@ is a handle to an 'OpenXR.Core10.Handles.Session' previously
                               -- created with 'OpenXR.Core10.Device.createSession'.
                               --
                               -- #VUID-xrGetReferenceSpaceBoundsRect-session-parameter# @session@ /must/
                               -- be a valid 'OpenXR.Core10.Handles.Session' handle
                               Session
                            -> -- | @referenceSpaceType@ is the reference space type whose bounds should be
                               -- retrieved.
                               --
                               -- #VUID-xrGetReferenceSpaceBoundsRect-referenceSpaceType-parameter#
                               -- @referenceSpaceType@ /must/ be a valid
                               -- 'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType' value
                               ReferenceSpaceType
                            -> io (Result, ("bounds" ::: Extent2Df))
getReferenceSpaceBoundsRect :: Session
-> ReferenceSpaceType -> io (Result, "bounds" ::: Extent2Df)
getReferenceSpaceBoundsRect session :: Session
session referenceSpaceType :: ReferenceSpaceType
referenceSpaceType = IO (Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "bounds" ::: Extent2Df)
 -> io (Result, "bounds" ::: Extent2Df))
-> (ContT
      (Result, "bounds" ::: Extent2Df)
      IO
      (Result, "bounds" ::: Extent2Df)
    -> IO (Result, "bounds" ::: Extent2Df))
-> ContT
     (Result, "bounds" ::: Extent2Df)
     IO
     (Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Result, "bounds" ::: Extent2Df)
  IO
  (Result, "bounds" ::: Extent2Df)
-> IO (Result, "bounds" ::: Extent2Df)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Result, "bounds" ::: Extent2Df)
   IO
   (Result, "bounds" ::: Extent2Df)
 -> io (Result, "bounds" ::: Extent2Df))
-> ContT
     (Result, "bounds" ::: Extent2Df)
     IO
     (Result, "bounds" ::: Extent2Df)
-> io (Result, "bounds" ::: Extent2Df)
forall a b. (a -> b) -> a -> b
$ do
  let xrGetReferenceSpaceBoundsRectPtr :: FunPtr
  (Ptr Session_T
   -> ReferenceSpaceType
   -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
   -> IO Result)
xrGetReferenceSpaceBoundsRectPtr = InstanceCmds
-> FunPtr
     (Ptr Session_T
      -> ReferenceSpaceType
      -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
      -> IO Result)
pXrGetReferenceSpaceBoundsRect (Session -> InstanceCmds
instanceCmds (Session
session :: Session))
  IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ())
-> IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Session_T
   -> ReferenceSpaceType
   -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
   -> IO Result)
xrGetReferenceSpaceBoundsRectPtr FunPtr
  (Ptr Session_T
   -> ReferenceSpaceType
   -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
   -> IO Result)
-> FunPtr
     (Ptr Session_T
      -> ReferenceSpaceType
      -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Session_T
   -> ReferenceSpaceType
   -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
   -> 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 xrGetReferenceSpaceBoundsRect is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let xrGetReferenceSpaceBoundsRect' :: Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result
xrGetReferenceSpaceBoundsRect' = FunPtr
  (Ptr Session_T
   -> ReferenceSpaceType
   -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
   -> IO Result)
-> Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result
mkXrGetReferenceSpaceBoundsRect FunPtr
  (Ptr Session_T
   -> ReferenceSpaceType
   -> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
   -> IO Result)
xrGetReferenceSpaceBoundsRectPtr
  "bounds" ::: Ptr ("bounds" ::: Extent2Df)
pBounds <- ((("bounds" ::: Ptr ("bounds" ::: Extent2Df))
  -> IO (Result, "bounds" ::: Extent2Df))
 -> IO (Result, "bounds" ::: Extent2Df))
-> ContT
     (Result, "bounds" ::: Extent2Df)
     IO
     ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("bounds" ::: Extent2Df) =>
(("bounds" ::: Ptr ("bounds" ::: Extent2Df)) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @Extent2Df)
  Result
r <- IO Result -> ContT (Result, "bounds" ::: Extent2Df) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Result, "bounds" ::: Extent2Df) IO Result)
-> IO Result -> ContT (Result, "bounds" ::: Extent2Df) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "xrGetReferenceSpaceBoundsRect" (Ptr Session_T
-> ReferenceSpaceType
-> ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO Result
xrGetReferenceSpaceBoundsRect' (Session -> Ptr Session_T
sessionHandle (Session
session)) (ReferenceSpaceType
referenceSpaceType) ("bounds" ::: Ptr ("bounds" ::: Extent2Df)
pBounds))
  IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Result, "bounds" ::: Extent2Df) IO ())
-> IO () -> ContT (Result, "bounds" ::: Extent2Df) 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))
  "bounds" ::: Extent2Df
bounds <- IO ("bounds" ::: Extent2Df)
-> ContT
     (Result, "bounds" ::: Extent2Df) IO ("bounds" ::: Extent2Df)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("bounds" ::: Extent2Df)
 -> ContT
      (Result, "bounds" ::: Extent2Df) IO ("bounds" ::: Extent2Df))
-> IO ("bounds" ::: Extent2Df)
-> ContT
     (Result, "bounds" ::: Extent2Df) IO ("bounds" ::: Extent2Df)
forall a b. (a -> b) -> a -> b
$ ("bounds" ::: Ptr ("bounds" ::: Extent2Df))
-> IO ("bounds" ::: Extent2Df)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Extent2Df "bounds" ::: Ptr ("bounds" ::: Extent2Df)
pBounds
  (Result, "bounds" ::: Extent2Df)
-> ContT
     (Result, "bounds" ::: Extent2Df)
     IO
     (Result, "bounds" ::: Extent2Df)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "bounds" ::: Extent2Df)
 -> ContT
      (Result, "bounds" ::: Extent2Df)
      IO
      (Result, "bounds" ::: Extent2Df))
-> (Result, "bounds" ::: Extent2Df)
-> ContT
     (Result, "bounds" ::: Extent2Df)
     IO
     (Result, "bounds" ::: Extent2Df)
forall a b. (a -> b) -> a -> b
$ (Result
r, "bounds" ::: Extent2Df
bounds)


-- | XrVector3f - Three-dimensional vector
--
-- == Member Descriptions
--
-- = Description
--
-- If used to represent physical distances (rather than e.g. velocity or
-- angular velocity) and not otherwise specified, values /must/ be in
-- meters.
--
-- = See Also
--
-- 'OpenXR.Extensions.XR_EXT_hand_tracking.HandJointVelocityEXT',
-- 'OpenXR.Extensions.XR_MSFT_hand_tracking_mesh.HandMeshVertexMSFT',
-- 'Posef', 'Quaternionf', 'SpaceVelocity', 'OpenXR.Core10.Input.Vector2f',
-- 'OpenXR.Core10.OtherTypes.Vector4f'
data Vector3f = Vector3f
  { -- | @x@ is the x coordinate of the vector.
    Vector3f -> Float
x :: Float
  , -- | @y@ is the y coordinate of the vector.
    Vector3f -> Float
y :: Float
  , -- | @z@ is the z coordinate of the vector.
    Vector3f -> Float
z :: Float
  }
  deriving (Typeable, Vector3f -> Vector3f -> Bool
(Vector3f -> Vector3f -> Bool)
-> (Vector3f -> Vector3f -> Bool) -> Eq Vector3f
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Vector3f -> Vector3f -> Bool
$c/= :: Vector3f -> Vector3f -> Bool
== :: Vector3f -> Vector3f -> Bool
$c== :: Vector3f -> Vector3f -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Vector3f)
#endif
deriving instance Show Vector3f

instance ToCStruct Vector3f where
  withCStruct :: Vector3f -> (Ptr Vector3f -> IO b) -> IO b
withCStruct x :: Vector3f
x f :: Ptr Vector3f -> IO b
f = Int -> Int -> (Ptr Vector3f -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 12 4 ((Ptr Vector3f -> IO b) -> IO b) -> (Ptr Vector3f -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Vector3f
p -> Ptr Vector3f -> Vector3f -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Vector3f
p Vector3f
x (Ptr Vector3f -> IO b
f Ptr Vector3f
p)
  pokeCStruct :: Ptr Vector3f -> Vector3f -> IO b -> IO b
pokeCStruct p :: Ptr Vector3f
p Vector3f{..} f :: IO b
f = do
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
x))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
y))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
z))
    IO b
f
  cStructSize :: Int
cStructSize = 12
  cStructAlignment :: Int
cStructAlignment = 4
  pokeZeroCStruct :: Ptr Vector3f -> IO b -> IO b
pokeZeroCStruct p :: Ptr Vector3f
p f :: IO b
f = do
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct Vector3f where
  peekCStruct :: Ptr Vector3f -> IO Vector3f
peekCStruct p :: Ptr Vector3f
p = do
    CFloat
x <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat))
    CFloat
y <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat))
    CFloat
z <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Vector3f
p Ptr Vector3f -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat))
    Vector3f -> IO Vector3f
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector3f -> IO Vector3f) -> Vector3f -> IO Vector3f
forall a b. (a -> b) -> a -> b
$ Float -> Float -> Float -> Vector3f
Vector3f
             (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
x) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
y) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
z)

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

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


-- | XrQuaternionf - Unit Quaternion
--
-- == Member Descriptions
--
-- = See Also
--
-- 'OpenXR.Extensions.XR_KHR_composition_layer_cube.CompositionLayerCubeKHR',
-- 'Posef', 'OpenXR.Core10.Input.Vector2f', 'Vector3f',
-- 'OpenXR.Core10.OtherTypes.Vector4f'
data Quaternionf = Quaternionf
  { -- | @x@ is the x coordinate of the quaternion.
    Quaternionf -> Float
x :: Float
  , -- | @y@ is the y coordinate of the quaternion.
    Quaternionf -> Float
y :: Float
  , -- | @z@ is the z coordinate of the quaternion.
    Quaternionf -> Float
z :: Float
  , -- | @w@ is the w coordinate of the quaternion.
    Quaternionf -> Float
w :: Float
  }
  deriving (Typeable, Quaternionf -> Quaternionf -> Bool
(Quaternionf -> Quaternionf -> Bool)
-> (Quaternionf -> Quaternionf -> Bool) -> Eq Quaternionf
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Quaternionf -> Quaternionf -> Bool
$c/= :: Quaternionf -> Quaternionf -> Bool
== :: Quaternionf -> Quaternionf -> Bool
$c== :: Quaternionf -> Quaternionf -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Quaternionf)
#endif
deriving instance Show Quaternionf

instance ToCStruct Quaternionf where
  withCStruct :: Quaternionf -> (Ptr Quaternionf -> IO b) -> IO b
withCStruct x :: Quaternionf
x f :: Ptr Quaternionf -> IO b
f = Int -> Int -> (Ptr Quaternionf -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 16 4 ((Ptr Quaternionf -> IO b) -> IO b)
-> (Ptr Quaternionf -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Quaternionf
p -> Ptr Quaternionf -> Quaternionf -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Quaternionf
p Quaternionf
x (Ptr Quaternionf -> IO b
f Ptr Quaternionf
p)
  pokeCStruct :: Ptr Quaternionf -> Quaternionf -> IO b -> IO b
pokeCStruct p :: Ptr Quaternionf
p Quaternionf{..} f :: IO b
f = do
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
x))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
y))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
z))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
w))
    IO b
f
  cStructSize :: Int
cStructSize = 16
  cStructAlignment :: Int
cStructAlignment = 4
  pokeZeroCStruct :: Ptr Quaternionf -> IO b -> IO b
pokeZeroCStruct p :: Ptr Quaternionf
p f :: IO b
f = do
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct Quaternionf where
  peekCStruct :: Ptr Quaternionf -> IO Quaternionf
peekCStruct p :: Ptr Quaternionf
p = do
    CFloat
x <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr CFloat))
    CFloat
y <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr CFloat))
    CFloat
z <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr CFloat))
    CFloat
w <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr Quaternionf
p Ptr Quaternionf -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr CFloat))
    Quaternionf -> IO Quaternionf
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Quaternionf -> IO Quaternionf) -> Quaternionf -> IO Quaternionf
forall a b. (a -> b) -> a -> b
$ Float -> Float -> Float -> Float -> Quaternionf
Quaternionf
             (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
x) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
y) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
z) (CFloat -> Float
forall a b. Coercible a b => a -> b
coerce @CFloat @Float CFloat
w)

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

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


-- | XrPosef - Location and orientation in a space.
--
-- == Member Descriptions
--
-- A construct representing a position and orientation within a space, with
-- position expressed in meters, and orientation represented as a unit
-- quaternion. When using 'Posef' the rotation described by @orientation@
-- is always applied before the translation described by @position@.
--
-- = Description
--
-- A runtime /must/ return 'OpenXR.Core10.Enums.Result.ERROR_POSE_INVALID'
-- if the @orientation@ norm deviates by more than 1% from unit length.
--
-- = See Also
--
-- 'ActionSpaceCreateInfo',
-- 'OpenXR.Extensions.XR_KHR_composition_layer_cylinder.CompositionLayerCylinderKHR',
-- 'OpenXR.Extensions.XR_KHR_composition_layer_equirect2.CompositionLayerEquirect2KHR',
-- 'OpenXR.Extensions.XR_KHR_composition_layer_equirect.CompositionLayerEquirectKHR',
-- 'OpenXR.Core10.OtherTypes.CompositionLayerProjectionView',
-- 'OpenXR.Core10.OtherTypes.CompositionLayerQuad',
-- 'OpenXR.Extensions.XR_MSFT_controller_model.ControllerModelNodeStateMSFT',
-- 'OpenXR.Core10.OtherTypes.EventDataReferenceSpaceChangePending',
-- 'OpenXR.Extensions.XR_EXT_hand_tracking.HandJointLocationEXT',
-- 'OpenXR.Extensions.XR_MSFT_hand_tracking_mesh.HandMeshSpaceCreateInfoMSFT',
-- 'Quaternionf', 'ReferenceSpaceCreateInfo', 'SpaceLocation',
-- 'OpenXR.Extensions.XR_MSFT_spatial_anchor.SpatialAnchorCreateInfoMSFT',
-- 'OpenXR.Extensions.XR_MSFT_spatial_anchor.SpatialAnchorSpaceCreateInfoMSFT',
-- 'OpenXR.Extensions.XR_MSFT_spatial_graph_bridge.SpatialGraphNodeSpaceCreateInfoMSFT',
-- 'OpenXR.Core10.Input.Vector2f', 'Vector3f',
-- 'OpenXR.Core10.OtherTypes.Vector4f', 'OpenXR.Core10.DisplayTiming.View',
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#xrSetInputDeviceLocationEXT xrSetInputDeviceLocationEXT>
data Posef = Posef
  { -- | @orientation@ is an 'Quaternionf' representing the orientation within a
    -- space.
    Posef -> Quaternionf
orientation :: Quaternionf
  , -- | @position@ is an 'Vector3f' representing position within a space.
    Posef -> Vector3f
position :: Vector3f
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Posef)
#endif
deriving instance Show Posef

instance ToCStruct Posef where
  withCStruct :: Posef -> (Ptr Posef -> IO b) -> IO b
withCStruct x :: Posef
x f :: Ptr Posef -> IO b
f = Int -> Int -> (Ptr Posef -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 28 4 ((Ptr Posef -> IO b) -> IO b) -> (Ptr Posef -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Posef
p -> Ptr Posef -> Posef -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr Posef
p Posef
x (Ptr Posef -> IO b
f Ptr Posef
p)
  pokeCStruct :: Ptr Posef -> Posef -> IO b -> IO b
pokeCStruct p :: Ptr Posef
p Posef{..} f :: IO b
f = do
    Ptr Quaternionf -> Quaternionf -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Quaternionf
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Quaternionf)) (Quaternionf
orientation)
    Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Vector3f)) (Vector3f
position)
    IO b
f
  cStructSize :: Int
cStructSize = 28
  cStructAlignment :: Int
cStructAlignment = 4
  pokeZeroCStruct :: Ptr Posef -> IO b -> IO b
pokeZeroCStruct p :: Ptr Posef
p f :: IO b
f = do
    Ptr Quaternionf -> Quaternionf -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Quaternionf
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Quaternionf)) (Quaternionf
forall a. Zero a => a
zero)
    Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr Posef
p Ptr Posef -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Vector3f)) (Vector3f
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct Posef where
  peekCStruct :: Ptr Posef -> IO Posef
peekCStruct p :: Ptr Posef
p = do
    Quaternionf
orientation <- Ptr Quaternionf -> IO Quaternionf
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Quaternionf ((Ptr Posef
p Ptr Posef -> Int -> Ptr Quaternionf
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Quaternionf))
    Vector3f
position <- Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Vector3f ((Ptr Posef
p Ptr Posef -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Vector3f))
    Posef -> IO Posef
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Posef -> IO Posef) -> Posef -> IO Posef
forall a b. (a -> b) -> a -> b
$ Quaternionf -> Vector3f -> Posef
Posef
             Quaternionf
orientation Vector3f
position

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

instance Zero Posef where
  zero :: Posef
zero = Quaternionf -> Vector3f -> Posef
Posef
           Quaternionf
forall a. Zero a => a
zero
           Vector3f
forall a. Zero a => a
zero


-- | XrReferenceSpaceCreateInfo - Creation info for a reference space
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'Posef', 'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType',
-- 'OpenXR.Core10.Handles.Space',
-- 'OpenXR.Core10.Enums.StructureType.StructureType',
-- 'createReferenceSpace'
data ReferenceSpaceCreateInfo = ReferenceSpaceCreateInfo
  { -- | @referenceSpaceType@ is the chosen
    -- 'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType'.
    --
    -- #VUID-XrReferenceSpaceCreateInfo-referenceSpaceType-parameter#
    -- @referenceSpaceType@ /must/ be a valid
    -- 'OpenXR.Core10.Enums.ReferenceSpaceType.ReferenceSpaceType' value
    ReferenceSpaceCreateInfo -> ReferenceSpaceType
referenceSpaceType :: ReferenceSpaceType
  , -- | @poseInReferenceSpace@ is an 'Posef' defining the position and
    -- orientation of the new space’s origin within the natural reference frame
    -- of the reference space.
    ReferenceSpaceCreateInfo -> Posef
poseInReferenceSpace :: Posef
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ReferenceSpaceCreateInfo)
#endif
deriving instance Show ReferenceSpaceCreateInfo

instance ToCStruct ReferenceSpaceCreateInfo where
  withCStruct :: ReferenceSpaceCreateInfo
-> (Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b
withCStruct x :: ReferenceSpaceCreateInfo
x f :: Ptr ReferenceSpaceCreateInfo -> IO b
f = Int -> Int -> (Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b)
-> (Ptr ReferenceSpaceCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ReferenceSpaceCreateInfo
p -> Ptr ReferenceSpaceCreateInfo
-> ReferenceSpaceCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ReferenceSpaceCreateInfo
p ReferenceSpaceCreateInfo
x (Ptr ReferenceSpaceCreateInfo -> IO b
f Ptr ReferenceSpaceCreateInfo
p)
  pokeCStruct :: Ptr ReferenceSpaceCreateInfo
-> ReferenceSpaceCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr ReferenceSpaceCreateInfo
p ReferenceSpaceCreateInfo{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_REFERENCE_SPACE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("spaces" ::: Ptr ReferenceSpaceType)
-> ReferenceSpaceType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ReferenceSpaceType)) (ReferenceSpaceType
referenceSpaceType)
    Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
poseInReferenceSpace)
    IO b
f
  cStructSize :: Int
cStructSize = 48
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr ReferenceSpaceCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr ReferenceSpaceCreateInfo
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_REFERENCE_SPACE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("spaces" ::: Ptr ReferenceSpaceType)
-> ReferenceSpaceType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ReferenceSpaceType)) (ReferenceSpaceType
forall a. Zero a => a
zero)
    Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct ReferenceSpaceCreateInfo where
  peekCStruct :: Ptr ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
peekCStruct p :: Ptr ReferenceSpaceCreateInfo
p = do
    ReferenceSpaceType
referenceSpaceType <- ("spaces" ::: Ptr ReferenceSpaceType) -> IO ReferenceSpaceType
forall a. Storable a => Ptr a -> IO a
peek @ReferenceSpaceType ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo
-> Int -> "spaces" ::: Ptr ReferenceSpaceType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ReferenceSpaceType))
    Posef
poseInReferenceSpace <- Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Posef ((Ptr ReferenceSpaceCreateInfo
p Ptr ReferenceSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef))
    ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo)
-> ReferenceSpaceCreateInfo -> IO ReferenceSpaceCreateInfo
forall a b. (a -> b) -> a -> b
$ ReferenceSpaceType -> Posef -> ReferenceSpaceCreateInfo
ReferenceSpaceCreateInfo
             ReferenceSpaceType
referenceSpaceType Posef
poseInReferenceSpace

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

instance Zero ReferenceSpaceCreateInfo where
  zero :: ReferenceSpaceCreateInfo
zero = ReferenceSpaceType -> Posef -> ReferenceSpaceCreateInfo
ReferenceSpaceCreateInfo
           ReferenceSpaceType
forall a. Zero a => a
zero
           Posef
forall a. Zero a => a
zero


-- | XrActionSpaceCreateInfo - Creation info for an action space
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Action',
-- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrPath >,
-- 'Posef', 'OpenXR.Core10.Handles.Space',
-- 'OpenXR.Core10.Enums.StructureType.StructureType', 'createActionSpace'
data ActionSpaceCreateInfo = ActionSpaceCreateInfo
  { -- | @action@ is a handle to a pose 'OpenXR.Core10.Handles.Action' previously
    -- created with 'OpenXR.Core10.Input.createAction'.
    --
    -- #VUID-XrActionSpaceCreateInfo-action-parameter# @action@ /must/ be a
    -- valid 'OpenXR.Core10.Handles.Action' handle
    ActionSpaceCreateInfo -> Ptr Action_T
action :: Ptr Action_T
  , -- | @subactionPath@ is 'OpenXR.Core10.APIConstants.NULL_PATH' or an
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrPath >
    -- that was specified when the action was created. If @subactionPath@ is a
    -- valid path not specified when the action was created the runtime /must/
    -- return 'OpenXR.Core10.Enums.Result.ERROR_PATH_UNSUPPORTED'. If this
    -- parameter is set, the runtime /must/ create a space that is relative to
    -- only that subaction’s pose binding.
    ActionSpaceCreateInfo -> Path
subactionPath :: Path
  , -- | @poseInActionSpace@ is an 'Posef' defining the position and orientation
    -- of the new space’s origin within the natural reference frame of the pose
    -- action.
    ActionSpaceCreateInfo -> Posef
poseInActionSpace :: Posef
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ActionSpaceCreateInfo)
#endif
deriving instance Show ActionSpaceCreateInfo

instance ToCStruct ActionSpaceCreateInfo where
  withCStruct :: ActionSpaceCreateInfo
-> (Ptr ActionSpaceCreateInfo -> IO b) -> IO b
withCStruct x :: ActionSpaceCreateInfo
x f :: Ptr ActionSpaceCreateInfo -> IO b
f = Int -> Int -> (Ptr ActionSpaceCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 64 8 ((Ptr ActionSpaceCreateInfo -> IO b) -> IO b)
-> (Ptr ActionSpaceCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ActionSpaceCreateInfo
p -> Ptr ActionSpaceCreateInfo -> ActionSpaceCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ActionSpaceCreateInfo
p ActionSpaceCreateInfo
x (Ptr ActionSpaceCreateInfo -> IO b
f Ptr ActionSpaceCreateInfo
p)
  pokeCStruct :: Ptr ActionSpaceCreateInfo -> ActionSpaceCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr ActionSpaceCreateInfo
p ActionSpaceCreateInfo{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_ACTION_SPACE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr (Ptr Action_T) -> Ptr Action_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr Action_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Action_T))) (Ptr Action_T
action)
    Ptr Path -> Path -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Path
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Path)) (Path
subactionPath)
    Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Posef)) (Posef
poseInActionSpace)
    IO b
f
  cStructSize :: Int
cStructSize = 64
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr ActionSpaceCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr ActionSpaceCreateInfo
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_ACTION_SPACE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr (Ptr Action_T) -> Ptr Action_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr Action_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Action_T))) (Ptr Action_T
forall a. Zero a => a
zero)
    Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Posef)) (Posef
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct ActionSpaceCreateInfo where
  peekCStruct :: Ptr ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
peekCStruct p :: Ptr ActionSpaceCreateInfo
p = do
    Ptr Action_T
action <- Ptr (Ptr Action_T) -> IO (Ptr Action_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Action_T) ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr (Ptr Action_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Action_T)))
    Path
subactionPath <- Ptr Path -> IO Path
forall a. Storable a => Ptr a -> IO a
peek @Path ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Path
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Path))
    Posef
poseInActionSpace <- Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Posef ((Ptr ActionSpaceCreateInfo
p Ptr ActionSpaceCreateInfo -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Posef))
    ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo)
-> ActionSpaceCreateInfo -> IO ActionSpaceCreateInfo
forall a b. (a -> b) -> a -> b
$ Ptr Action_T -> Path -> Posef -> ActionSpaceCreateInfo
ActionSpaceCreateInfo
             Ptr Action_T
action Path
subactionPath Posef
poseInActionSpace

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

instance Zero ActionSpaceCreateInfo where
  zero :: ActionSpaceCreateInfo
zero = Ptr Action_T -> Path -> Posef -> ActionSpaceCreateInfo
ActionSpaceCreateInfo
           Ptr Action_T
forall a. Zero a => a
zero
           Path
forall a. Zero a => a
zero
           Posef
forall a. Zero a => a
zero


-- | XrSpaceLocation - Contains info about a space
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'Posef', 'OpenXR.Core10.Handles.Space',
-- 'OpenXR.Core10.Enums.SpaceLocationFlags.SpaceLocationFlags',
-- 'SpaceVelocity', 'OpenXR.Core10.Enums.StructureType.StructureType',
-- 'locateSpace'
data SpaceLocation (es :: [Type]) = SpaceLocation
  { -- | @next@ is @NULL@ or a pointer to the next structure in a structure
    -- chain, such as 'SpaceVelocity'.
    --
    -- #VUID-XrSpaceLocation-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.Extensions.XR_EXT_eye_gaze_interaction.EyeGazeSampleTimeEXT',
    -- 'SpaceVelocity'
    SpaceLocation es -> Chain es
next :: Chain es
  , -- | @locationFlags@ is a bitfield, with bit masks defined in
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrSpaceLocationFlagBits XrSpaceLocationFlagBits>,
    -- to indicate which members contain valid data. If none of the bits are
    -- set, no other fields in this structure /should/ be considered to be
    -- valid or meaningful.
    --
    -- #VUID-XrSpaceLocation-locationFlags-parameter# @locationFlags@ /must/ be
    -- @0@ or a valid combination of
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrSpaceLocationFlagBits XrSpaceLocationFlagBits>
    -- values
    SpaceLocation es -> SpaceLocationFlags
locationFlags :: SpaceLocationFlags
  , -- | @pose@ is an 'Posef' defining the position and orientation of the origin
    -- of 'locateSpace'::@space@ within the reference frame of
    -- 'locateSpace'::@baseSpace@.
    SpaceLocation es -> Posef
pose :: Posef
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SpaceLocation (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (SpaceLocation es)

instance Extensible SpaceLocation where
  extensibleTypeName :: String
extensibleTypeName = "SpaceLocation"
  setNext :: SpaceLocation ds -> Chain es -> SpaceLocation es
setNext x :: SpaceLocation ds
x next :: Chain es
next = SpaceLocation ds
x{$sel:next:SpaceLocation :: Chain es
next = Chain es
next}
  getNext :: SpaceLocation es -> Chain es
getNext SpaceLocation{..} = Chain es
next
  extends :: forall e b proxy. Typeable e => proxy e -> (Extends SpaceLocation e => b) -> Maybe b
  extends :: proxy e -> (Extends SpaceLocation e => b) -> Maybe b
extends _ f :: Extends SpaceLocation e => b
f
    | Just Refl <- (Typeable e, Typeable EyeGazeSampleTimeEXT) =>
Maybe (e :~: EyeGazeSampleTimeEXT)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @EyeGazeSampleTimeEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SpaceLocation e => b
f
    | Just Refl <- (Typeable e, Typeable SpaceVelocity) => Maybe (e :~: SpaceVelocity)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @SpaceVelocity = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SpaceLocation e => b
f
    | Bool
otherwise = Maybe b
forall a. Maybe a
Nothing

instance (Extendss SpaceLocation es, PokeChain es) => ToCStruct (SpaceLocation es) where
  withCStruct :: SpaceLocation es -> (Ptr (SpaceLocation es) -> IO b) -> IO b
withCStruct x :: SpaceLocation es
x f :: Ptr (SpaceLocation es) -> IO b
f = Int -> Int -> (Ptr (SpaceLocation es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr (SpaceLocation es) -> IO b) -> IO b)
-> (Ptr (SpaceLocation es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (SpaceLocation es)
p -> Ptr (SpaceLocation es) -> SpaceLocation es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (SpaceLocation es)
p SpaceLocation es
x (Ptr (SpaceLocation es) -> IO b
f Ptr (SpaceLocation es)
p)
  pokeCStruct :: Ptr (SpaceLocation es) -> SpaceLocation es -> IO b -> IO b
pokeCStruct p :: Ptr (SpaceLocation es)
p SpaceLocation{..} f :: IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_LOCATION)
    Ptr ()
next'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
    -> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ Chain es -> (Ptr (Chain es) -> IO b) -> IO b
forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
next''
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SpaceLocationFlags -> SpaceLocationFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr SpaceLocationFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceLocationFlags)) (SpaceLocationFlags
locationFlags)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
pose)
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = 48
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr (SpaceLocation es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (SpaceLocation es)
p f :: IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_LOCATION)
    Ptr ()
pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
    -> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ forall a. PokeChain es => (Ptr (Chain es) -> IO a) -> IO a
forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext'
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Posef -> Posef -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef)) (Posef
forall a. Zero a => a
zero)
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f

instance (Extendss SpaceLocation es, PeekChain es) => FromCStruct (SpaceLocation es) where
  peekCStruct :: Ptr (SpaceLocation es) -> IO (SpaceLocation es)
peekCStruct p :: Ptr (SpaceLocation es)
p = do
    Ptr ()
next <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ())))
    Chain es
next' <- Ptr (Chain es) -> IO (Chain es)
forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (Ptr () -> Ptr (Chain es)
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
next)
    SpaceLocationFlags
locationFlags <- Ptr SpaceLocationFlags -> IO SpaceLocationFlags
forall a. Storable a => Ptr a -> IO a
peek @SpaceLocationFlags ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr SpaceLocationFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceLocationFlags))
    Posef
pose <- Ptr Posef -> IO Posef
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Posef ((Ptr (SpaceLocation es)
p Ptr (SpaceLocation es) -> Int -> Ptr Posef
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Posef))
    SpaceLocation es -> IO (SpaceLocation es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SpaceLocation es -> IO (SpaceLocation es))
-> SpaceLocation es -> IO (SpaceLocation es)
forall a b. (a -> b) -> a -> b
$ Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
forall (es :: [*]).
Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
SpaceLocation
             Chain es
next' SpaceLocationFlags
locationFlags Posef
pose

instance es ~ '[] => Zero (SpaceLocation es) where
  zero :: SpaceLocation es
zero = Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
forall (es :: [*]).
Chain es -> SpaceLocationFlags -> Posef -> SpaceLocation es
SpaceLocation
           ()
           SpaceLocationFlags
forall a. Zero a => a
zero
           Posef
forall a. Zero a => a
zero


-- | XrSpaceVelocity - Contains info about a space
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'OpenXR.Core10.Handles.Space', 'SpaceLocation',
-- 'OpenXR.Core10.Enums.SpaceVelocityFlags.SpaceVelocityFlags',
-- 'OpenXR.Core10.Enums.StructureType.StructureType', 'Vector3f',
-- 'locateSpace'
data SpaceVelocity = SpaceVelocity
  { -- | @velocityFlags@ is a bitfield, with bit masks defined in
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrSpaceVelocityFlagBits XrSpaceVelocityFlagBits>,
    -- to indicate which members contain valid data. If none of the bits are
    -- set, no other fields in this structure /should/ be considered to be
    -- valid or meaningful.
    --
    -- #VUID-XrSpaceVelocity-velocityFlags-parameter# @velocityFlags@ /must/ be
    -- @0@ or a valid combination of
    -- <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrSpaceVelocityFlagBits XrSpaceVelocityFlagBits>
    -- values
    SpaceVelocity -> SpaceVelocityFlags
velocityFlags :: SpaceVelocityFlags
  , -- | @linearVelocity@ is the relative linear velocity of the origin of
    -- 'locateSpace'::@space@ with respect to and expressed in the reference
    -- frame of 'locateSpace'::@baseSpace@, in units of meters per second.
    SpaceVelocity -> Vector3f
linearVelocity :: Vector3f
  , -- | @angularVelocity@ is the relative angular velocity of
    -- 'locateSpace'::@space@ with respect to 'locateSpace'::@baseSpace@. The
    -- vector’s direction is expressed in the reference frame of
    -- 'locateSpace'::@baseSpace@ and is parallel to the rotational axis of
    -- 'locateSpace'::@space@. The vector’s magnitude is the relative angular
    -- speed of 'locateSpace'::@space@ in radians per second. The vector
    -- follows the right-hand rule for torque\/rotation.
    SpaceVelocity -> Vector3f
angularVelocity :: Vector3f
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SpaceVelocity)
#endif
deriving instance Show SpaceVelocity

instance ToCStruct SpaceVelocity where
  withCStruct :: SpaceVelocity -> (Ptr SpaceVelocity -> IO b) -> IO b
withCStruct x :: SpaceVelocity
x f :: Ptr SpaceVelocity -> IO b
f = Int -> Int -> (Ptr SpaceVelocity -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr SpaceVelocity -> IO b) -> IO b)
-> (Ptr SpaceVelocity -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr SpaceVelocity
p -> Ptr SpaceVelocity -> SpaceVelocity -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SpaceVelocity
p SpaceVelocity
x (Ptr SpaceVelocity -> IO b
f Ptr SpaceVelocity
p)
  pokeCStruct :: Ptr SpaceVelocity -> SpaceVelocity -> IO b -> IO b
pokeCStruct p :: Ptr SpaceVelocity
p SpaceVelocity{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_VELOCITY)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr SpaceVelocityFlags -> SpaceVelocityFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr SpaceVelocityFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceVelocityFlags)) (SpaceVelocityFlags
velocityFlags)
    Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Vector3f)) (Vector3f
linearVelocity)
    Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Vector3f)) (Vector3f
angularVelocity)
    IO b
f
  cStructSize :: Int
cStructSize = 48
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr SpaceVelocity -> IO b -> IO b
pokeZeroCStruct p :: Ptr SpaceVelocity
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
TYPE_SPACE_VELOCITY)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Vector3f)) (Vector3f
forall a. Zero a => a
zero)
    Ptr Vector3f -> Vector3f -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Vector3f)) (Vector3f
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct SpaceVelocity where
  peekCStruct :: Ptr SpaceVelocity -> IO SpaceVelocity
peekCStruct p :: Ptr SpaceVelocity
p = do
    SpaceVelocityFlags
velocityFlags <- Ptr SpaceVelocityFlags -> IO SpaceVelocityFlags
forall a. Storable a => Ptr a -> IO a
peek @SpaceVelocityFlags ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr SpaceVelocityFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr SpaceVelocityFlags))
    Vector3f
linearVelocity <- Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Vector3f ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Vector3f))
    Vector3f
angularVelocity <- Ptr Vector3f -> IO Vector3f
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Vector3f ((Ptr SpaceVelocity
p Ptr SpaceVelocity -> Int -> Ptr Vector3f
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Vector3f))
    SpaceVelocity -> IO SpaceVelocity
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SpaceVelocity -> IO SpaceVelocity)
-> SpaceVelocity -> IO SpaceVelocity
forall a b. (a -> b) -> a -> b
$ SpaceVelocityFlags -> Vector3f -> Vector3f -> SpaceVelocity
SpaceVelocity
             SpaceVelocityFlags
velocityFlags Vector3f
linearVelocity Vector3f
angularVelocity

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

instance Zero SpaceVelocity where
  zero :: SpaceVelocity
zero = SpaceVelocityFlags -> Vector3f -> Vector3f -> SpaceVelocity
SpaceVelocity
           SpaceVelocityFlags
forall a. Zero a => a
zero
           Vector3f
forall a. Zero a => a
zero
           Vector3f
forall a. Zero a => a
zero