-- Produced by boxnd-gen; edit the generator, not this file.

module Box2D.RevoluteJoint
  ( create
  , enableSpring
  , isSpringEnabled
  , setSpringHertz
  , getSpringHertz
  , setSpringDampingRatio
  , getSpringDampingRatio
  , setTargetAngle
  , getTargetAngle
  , getAngle
  , enableLimit
  , isLimitEnabled
  , getLowerLimit
  , getUpperLimit
  , setLimits
  , enableMotor
  , isMotorEnabled
  , setMotorSpeed
  , getMotorSpeed
  , getMotorTorque
  , setMaxMotorTorque
  , getMaxMotorTorque
  )

  where

import Foreign
import Foreign.C.Types (CBool(..))
import Box2D.Id (JointId(..), WorldId(..))
import Box2D.Types (RevoluteJointDef)

foreign import ccall unsafe "b2CreateRevoluteJoint"
  c_b2CreateRevoluteJoint :: WorldId -> Ptr RevoluteJointDef -> IO JointId

foreign import ccall unsafe "b2RevoluteJoint_EnableSpring"
  c_b2RevoluteJoint_EnableSpring :: JointId -> CBool -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_IsSpringEnabled"
  c_b2RevoluteJoint_IsSpringEnabled :: JointId -> IO CBool

foreign import ccall unsafe "b2RevoluteJoint_SetSpringHertz"
  c_b2RevoluteJoint_SetSpringHertz :: JointId -> Float -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_GetSpringHertz"
  c_b2RevoluteJoint_GetSpringHertz :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_SetSpringDampingRatio"
  c_b2RevoluteJoint_SetSpringDampingRatio :: JointId -> Float -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_GetSpringDampingRatio"
  c_b2RevoluteJoint_GetSpringDampingRatio :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_SetTargetAngle"
  c_b2RevoluteJoint_SetTargetAngle :: JointId -> Float -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_GetTargetAngle"
  c_b2RevoluteJoint_GetTargetAngle :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_GetAngle"
  c_b2RevoluteJoint_GetAngle :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_EnableLimit"
  c_b2RevoluteJoint_EnableLimit :: JointId -> CBool -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_IsLimitEnabled"
  c_b2RevoluteJoint_IsLimitEnabled :: JointId -> IO CBool

foreign import ccall unsafe "b2RevoluteJoint_GetLowerLimit"
  c_b2RevoluteJoint_GetLowerLimit :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_GetUpperLimit"
  c_b2RevoluteJoint_GetUpperLimit :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_SetLimits"
  c_b2RevoluteJoint_SetLimits :: JointId -> Float -> Float -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_EnableMotor"
  c_b2RevoluteJoint_EnableMotor :: JointId -> CBool -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_IsMotorEnabled"
  c_b2RevoluteJoint_IsMotorEnabled :: JointId -> IO CBool

foreign import ccall unsafe "b2RevoluteJoint_SetMotorSpeed"
  c_b2RevoluteJoint_SetMotorSpeed :: JointId -> Float -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_GetMotorSpeed"
  c_b2RevoluteJoint_GetMotorSpeed :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_GetMotorTorque"
  c_b2RevoluteJoint_GetMotorTorque :: JointId -> IO Float

foreign import ccall unsafe "b2RevoluteJoint_SetMaxMotorTorque"
  c_b2RevoluteJoint_SetMaxMotorTorque :: JointId -> Float -> IO ()

foreign import ccall unsafe "b2RevoluteJoint_GetMaxMotorTorque"
  c_b2RevoluteJoint_GetMaxMotorTorque :: JointId -> IO Float

{- | Create a revolute joint
See also b2RevoluteJointDef for details.

Binds @b2CreateRevoluteJoint@.
-}
create
  :: WorldId
  -> RevoluteJointDef
  -> IO JointId
create :: WorldId -> RevoluteJointDef -> IO JointId
create WorldId
a0 RevoluteJointDef
a1 =
  RevoluteJointDef
-> (Ptr RevoluteJointDef -> IO JointId) -> IO JointId
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with RevoluteJointDef
a1 ((Ptr RevoluteJointDef -> IO JointId) -> IO JointId)
-> (Ptr RevoluteJointDef -> IO JointId) -> IO JointId
forall a b. (a -> b) -> a -> b
$ \Ptr RevoluteJointDef
p1 ->
  WorldId -> Ptr RevoluteJointDef -> IO JointId
c_b2CreateRevoluteJoint WorldId
a0 Ptr RevoluteJointDef
p1

{- | Enable\/disable the revolute joint spring

Binds @b2RevoluteJoint_EnableSpring@.
-}
enableSpring
  :: JointId
  -> Bool
  -- ^ @enableSpring@
  -> IO ()
enableSpring :: JointId -> Bool -> IO ()
enableSpring JointId
a0 Bool
a1 =
  JointId -> CBool -> IO ()
c_b2RevoluteJoint_EnableSpring JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | It the revolute angular spring enabled?

Binds @b2RevoluteJoint_IsSpringEnabled@.
-}
isSpringEnabled
  :: JointId
  -> IO Bool
isSpringEnabled :: JointId -> IO Bool
isSpringEnabled JointId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b2RevoluteJoint_IsSpringEnabled JointId
a0)

{- | Set the revolute joint spring stiffness in Hertz

Binds @b2RevoluteJoint_SetSpringHertz@.
-}
setSpringHertz
  :: JointId
  -> Float
  -- ^ @hertz@
  -> IO ()
setSpringHertz :: JointId -> Float -> IO ()
setSpringHertz JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b2RevoluteJoint_SetSpringHertz JointId
a0 Float
a1

{- | Get the revolute joint spring stiffness in Hertz

Binds @b2RevoluteJoint_GetSpringHertz@.
-}
getSpringHertz
  :: JointId
  -> IO Float
getSpringHertz :: JointId -> IO Float
getSpringHertz JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetSpringHertz JointId
a0

{- | Set the revolute joint spring damping ratio, non-dimensional

Binds @b2RevoluteJoint_SetSpringDampingRatio@.
-}
setSpringDampingRatio
  :: JointId
  -> Float
  -- ^ @dampingRatio@
  -> IO ()
setSpringDampingRatio :: JointId -> Float -> IO ()
setSpringDampingRatio JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b2RevoluteJoint_SetSpringDampingRatio JointId
a0 Float
a1

{- | Get the revolute joint spring damping ratio, non-dimensional

Binds @b2RevoluteJoint_GetSpringDampingRatio@.
-}
getSpringDampingRatio
  :: JointId
  -> IO Float
getSpringDampingRatio :: JointId -> IO Float
getSpringDampingRatio JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetSpringDampingRatio JointId
a0

{- | Set the revolute joint spring target angle, radians

Binds @b2RevoluteJoint_SetTargetAngle@.
-}
setTargetAngle
  :: JointId
  -> Float
  -- ^ @angle@
  -> IO ()
setTargetAngle :: JointId -> Float -> IO ()
setTargetAngle JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b2RevoluteJoint_SetTargetAngle JointId
a0 Float
a1

{- | Get the revolute joint spring target angle, radians

Binds @b2RevoluteJoint_GetTargetAngle@.
-}
getTargetAngle
  :: JointId
  -> IO Float
getTargetAngle :: JointId -> IO Float
getTargetAngle JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetTargetAngle JointId
a0

{- | Get the revolute joint current angle in radians relative to the reference angle
See also b2RevoluteJointDef::referenceAngle.

Binds @b2RevoluteJoint_GetAngle@.
-}
getAngle
  :: JointId
  -> IO Float
getAngle :: JointId -> IO Float
getAngle JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetAngle JointId
a0

{- | Enable\/disable the revolute joint limit

Binds @b2RevoluteJoint_EnableLimit@.
-}
enableLimit
  :: JointId
  -> Bool
  -- ^ @enableLimit@
  -> IO ()
enableLimit :: JointId -> Bool -> IO ()
enableLimit JointId
a0 Bool
a1 =
  JointId -> CBool -> IO ()
c_b2RevoluteJoint_EnableLimit JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is the revolute joint limit enabled?

Binds @b2RevoluteJoint_IsLimitEnabled@.
-}
isLimitEnabled
  :: JointId
  -> IO Bool
isLimitEnabled :: JointId -> IO Bool
isLimitEnabled JointId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b2RevoluteJoint_IsLimitEnabled JointId
a0)

{- | Get the revolute joint lower limit in radians

Binds @b2RevoluteJoint_GetLowerLimit@.
-}
getLowerLimit
  :: JointId
  -> IO Float
getLowerLimit :: JointId -> IO Float
getLowerLimit JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetLowerLimit JointId
a0

{- | Get the revolute joint upper limit in radians

Binds @b2RevoluteJoint_GetUpperLimit@.
-}
getUpperLimit
  :: JointId
  -> IO Float
getUpperLimit :: JointId -> IO Float
getUpperLimit JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetUpperLimit JointId
a0

{- | Set the revolute joint limits in radians. It is expected that lower \<= upper
and that -0.99 * B2_PI \<= lower && upper \<= -0.99 * B2_PI.

Binds @b2RevoluteJoint_SetLimits@.
-}
setLimits
  :: JointId
  -> Float
  -- ^ @lower@
  -> Float
  -- ^ @upper@
  -> IO ()
setLimits :: JointId -> Float -> Float -> IO ()
setLimits JointId
a0 Float
a1 Float
a2 =
  JointId -> Float -> Float -> IO ()
c_b2RevoluteJoint_SetLimits JointId
a0 Float
a1 Float
a2

{- | Enable\/disable a revolute joint motor

Binds @b2RevoluteJoint_EnableMotor@.
-}
enableMotor
  :: JointId
  -> Bool
  -- ^ @enableMotor@
  -> IO ()
enableMotor :: JointId -> Bool -> IO ()
enableMotor JointId
a0 Bool
a1 =
  JointId -> CBool -> IO ()
c_b2RevoluteJoint_EnableMotor JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)

{- | Is the revolute joint motor enabled?

Binds @b2RevoluteJoint_IsMotorEnabled@.
-}
isMotorEnabled
  :: JointId
  -> IO Bool
isMotorEnabled :: JointId -> IO Bool
isMotorEnabled JointId
a0 =
  CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b2RevoluteJoint_IsMotorEnabled JointId
a0)

{- | Set the revolute joint motor speed in radians per second

Binds @b2RevoluteJoint_SetMotorSpeed@.
-}
setMotorSpeed
  :: JointId
  -> Float
  -- ^ @motorSpeed@
  -> IO ()
setMotorSpeed :: JointId -> Float -> IO ()
setMotorSpeed JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b2RevoluteJoint_SetMotorSpeed JointId
a0 Float
a1

{- | Get the revolute joint motor speed in radians per second

Binds @b2RevoluteJoint_GetMotorSpeed@.
-}
getMotorSpeed
  :: JointId
  -> IO Float
getMotorSpeed :: JointId -> IO Float
getMotorSpeed JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetMotorSpeed JointId
a0

{- | Get the revolute joint current motor torque, usually in newton-meters

Binds @b2RevoluteJoint_GetMotorTorque@.
-}
getMotorTorque
  :: JointId
  -> IO Float
getMotorTorque :: JointId -> IO Float
getMotorTorque JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetMotorTorque JointId
a0

{- | Set the revolute joint maximum motor torque, usually in newton-meters

Binds @b2RevoluteJoint_SetMaxMotorTorque@.
-}
setMaxMotorTorque
  :: JointId
  -> Float
  -- ^ @torque@
  -> IO ()
setMaxMotorTorque :: JointId -> Float -> IO ()
setMaxMotorTorque JointId
a0 Float
a1 =
  JointId -> Float -> IO ()
c_b2RevoluteJoint_SetMaxMotorTorque JointId
a0 Float
a1

{- | Get the revolute joint maximum motor torque, usually in newton-meters

Binds @b2RevoluteJoint_GetMaxMotorTorque@.
-}
getMaxMotorTorque
  :: JointId
  -> IO Float
getMaxMotorTorque :: JointId -> IO Float
getMaxMotorTorque JointId
a0 =
  JointId -> IO Float
c_b2RevoluteJoint_GetMaxMotorTorque JointId
a0