sdl2-2.4.1.0: Both high- and low-level bindings to the SDL library (version 2.0.4+).

Safe Haskell | None
Language | Haskell2010

SDL.Input.Joystick

Synopsis

- numJoysticks :: MonadIO m => m CInt
- availableJoysticks :: MonadIO m => m (Vector JoystickDevice)
- data JoystickDevice = JoystickDevice {
  - joystickDeviceName :: Text
  - joystickDeviceId :: CInt
  }
- openJoystick :: (Functor m, MonadIO m) => JoystickDevice -> m Joystick
- closeJoystick :: MonadIO m => Joystick -> m ()
- getJoystickID :: MonadIO m => Joystick -> m Int32
- data Joystick
- data JoyButtonState
  - = JoyButtonPressed
  - | JoyButtonReleased
- buttonPressed :: (Functor m, MonadIO m) => Joystick -> CInt -> m Bool
- ballDelta :: MonadIO m => Joystick -> CInt -> m (V2 CInt)
- axisPosition :: MonadIO m => Joystick -> CInt -> m Int16
- numAxes :: MonadIO m => Joystick -> m CInt
- numButtons :: MonadIO m => Joystick -> m CInt
- numBalls :: MonadIO m => Joystick -> m CInt
- data JoyHatPosition
  - = HatCentered
  - | HatUp
  - | HatRight
  - | HatDown
  - | HatLeft
  - | HatRightUp
  - | HatRightDown
  - | HatLeftUp
  - | HatLeftDown
- getHat :: (Functor m, MonadIO m) => Joystick -> CInt -> m JoyHatPosition
- numHats :: MonadIO m => Joystick -> m CInt
- data JoyDeviceConnection
  - = JoyDeviceAdded
  - | JoyDeviceRemoved

# Documentation

numJoysticks :: MonadIO m => m CInt Source #

Count the number of joysticks attached to the system.

See `SDL_NumJoysticks` for C documentation.

availableJoysticks :: MonadIO m => m (Vector JoystickDevice) Source #

Enumerate all connected joysticks, retrieving a description of each.

data JoystickDevice Source #

A description of joystick that can be opened using `openJoystick`. To retrieve a list of connected joysticks, use `availableJoysticks`.

Constructors

JoystickDevice |

Fields

- joystickDeviceName :: Text
- joystickDeviceId :: CInt

Instances

Eq JoystickDevice Source # |
Instance details Defined in SDL.Input.Joystick Methods (==) :: JoystickDevice -> JoystickDevice -> Bool Source # (/=) :: JoystickDevice -> JoystickDevice -> Bool Source #
Ord JoystickDevice Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

compare :: JoystickDevice -> JoystickDevice -> Ordering Source #

(<) :: JoystickDevice -> JoystickDevice -> Bool Source #

(<=) :: JoystickDevice -> JoystickDevice -> Bool Source #

(>) :: JoystickDevice -> JoystickDevice -> Bool Source #

(>=) :: JoystickDevice -> JoystickDevice -> Bool Source #

max :: JoystickDevice -> JoystickDevice -> JoystickDevice Source #

min :: JoystickDevice -> JoystickDevice -> JoystickDevice Source #

Read JoystickDevice Source # |
Instance details Defined in SDL.Input.Joystick Methods readsPrec :: Int -> ReadS JoystickDevice Source # readList :: ReadS [JoystickDevice] Source # readPrec :: ReadPrec JoystickDevice Source # readListPrec :: ReadPrec [JoystickDevice] Source #
Show JoystickDevice Source # |
Instance details Defined in SDL.Input.Joystick Methods showsPrec :: Int -> JoystickDevice -> ShowS Source # show :: JoystickDevice -> String Source # showList :: [JoystickDevice] -> ShowS Source #
Generic JoystickDevice Source # |
Instance details Defined in SDL.Input.Joystick Associated Types type Rep JoystickDevice :: Type -> Type Source # Methods from :: JoystickDevice -> Rep JoystickDevice x Source # to :: Rep JoystickDevice x -> JoystickDevice Source #
type Rep JoystickDevice Source # |

Instance details

Defined in SDL.Input.Joystick

type Rep JoystickDevice = D1 (MetaData "JoystickDevice" "SDL.Input.Joystick" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (C1 (MetaCons "JoystickDevice" PrefixI True) (S1 (MetaSel (Just "joystickDeviceName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text) :*: S1 (MetaSel (Just "joystickDeviceId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CInt)))

openJoystick Source #

Arguments

:: (Functor m, MonadIO m) |
=> JoystickDevice | The device to open. Use `availableJoysticks` to find `JoystickDevices`s
-> m Joystick |

Open a joystick so that you can start receiving events from interaction with this joystick.

See `SDL_JoystickOpen` for C documentation.

closeJoystick :: MonadIO m => Joystick -> m () Source #

Close a joystick previously opened with `openJoystick`.

See `SDL_JoystickClose` for C documentation.

getJoystickID :: MonadIO m => Joystick -> m Int32 Source #

Get the instance ID of an opened joystick. The instance ID is used to identify the joystick in future SDL events.

See `SDL_JoystickInstanceID` for C documentation.

data Joystick Source #

Instances

Eq Joystick Source # |
Instance details Defined in SDL.Internal.Types Methods (==) :: Joystick -> Joystick -> Bool Source # (/=) :: Joystick -> Joystick -> Bool Source #
Data Joystick Source # |

Instance details

Defined in SDL.Internal.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Joystick -> c Joystick Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Joystick Source #

toConstr :: Joystick -> Constr Source #

dataTypeOf :: Joystick -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Joystick) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Joystick) Source #

gmapT :: (forall b. Data b => b -> b) -> Joystick -> Joystick Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Joystick -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Joystick -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Joystick -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Joystick -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Joystick -> m Joystick Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Joystick -> m Joystick Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Joystick -> m Joystick Source #

Ord Joystick Source # |
Instance details Defined in SDL.Internal.Types Methods compare :: Joystick -> Joystick -> Ordering Source # (<) :: Joystick -> Joystick -> Bool Source # (<=) :: Joystick -> Joystick -> Bool Source # (>) :: Joystick -> Joystick -> Bool Source # (>=) :: Joystick -> Joystick -> Bool Source # max :: Joystick -> Joystick -> Joystick Source # min :: Joystick -> Joystick -> Joystick Source #
Show Joystick Source # |
Instance details Defined in SDL.Internal.Types Methods showsPrec :: Int -> Joystick -> ShowS Source # show :: Joystick -> String Source # showList :: [Joystick] -> ShowS Source #
Generic Joystick Source # |
Instance details Defined in SDL.Internal.Types Associated Types type Rep Joystick :: Type -> Type Source # Methods from :: Joystick -> Rep Joystick x Source # to :: Rep Joystick x -> Joystick Source #
type Rep Joystick Source # |
Instance details Defined in SDL.Internal.Types type Rep Joystick = D1 (MetaData "Joystick" "SDL.Internal.Types" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" True) (C1 (MetaCons "Joystick" PrefixI True) (S1 (MetaSel (Just "joystickPtr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Joystick)))

data JoyButtonState Source #

Identifies the state of a joystick button.

Constructors

JoyButtonPressed |
JoyButtonReleased |

Instances

Eq JoyButtonState Source # |
Instance details Defined in SDL.Input.Joystick Methods (==) :: JoyButtonState -> JoyButtonState -> Bool Source # (/=) :: JoyButtonState -> JoyButtonState -> Bool Source #
Data JoyButtonState Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JoyButtonState -> c JoyButtonState Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JoyButtonState Source #

toConstr :: JoyButtonState -> Constr Source #

dataTypeOf :: JoyButtonState -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JoyButtonState) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JoyButtonState) Source #

gmapT :: (forall b. Data b => b -> b) -> JoyButtonState -> JoyButtonState Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JoyButtonState -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JoyButtonState -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> JoyButtonState -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JoyButtonState -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JoyButtonState -> m JoyButtonState Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JoyButtonState -> m JoyButtonState Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JoyButtonState -> m JoyButtonState Source #

Ord JoyButtonState Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

compare :: JoyButtonState -> JoyButtonState -> Ordering Source #

(<) :: JoyButtonState -> JoyButtonState -> Bool Source #

(<=) :: JoyButtonState -> JoyButtonState -> Bool Source #

(>) :: JoyButtonState -> JoyButtonState -> Bool Source #

(>=) :: JoyButtonState -> JoyButtonState -> Bool Source #

max :: JoyButtonState -> JoyButtonState -> JoyButtonState Source #

min :: JoyButtonState -> JoyButtonState -> JoyButtonState Source #

Read JoyButtonState Source # |
Instance details Defined in SDL.Input.Joystick Methods readsPrec :: Int -> ReadS JoyButtonState Source # readList :: ReadS [JoyButtonState] Source # readPrec :: ReadPrec JoyButtonState Source # readListPrec :: ReadPrec [JoyButtonState] Source #
Show JoyButtonState Source # |
Instance details Defined in SDL.Input.Joystick Methods showsPrec :: Int -> JoyButtonState -> ShowS Source # show :: JoyButtonState -> String Source # showList :: [JoyButtonState] -> ShowS Source #
Generic JoyButtonState Source # |
Instance details Defined in SDL.Input.Joystick Associated Types type Rep JoyButtonState :: Type -> Type Source # Methods from :: JoyButtonState -> Rep JoyButtonState x Source # to :: Rep JoyButtonState x -> JoyButtonState Source #
FromNumber JoyButtonState Word8 Source # |
Instance details Defined in SDL.Input.Joystick Methods fromNumber :: Word8 -> JoyButtonState Source #
type Rep JoyButtonState Source # |
Instance details Defined in SDL.Input.Joystick type Rep JoyButtonState = D1 (MetaData "JoyButtonState" "SDL.Input.Joystick" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (C1 (MetaCons "JoyButtonPressed" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "JoyButtonReleased" PrefixI False) (U1 :: Type -> Type))

buttonPressed Source #

Arguments

:: (Functor m, MonadIO m) |
=> Joystick |
-> CInt | The index of the button. You can use `numButtons` to determine how many buttons a given joystick has.
-> m Bool |

Determine if a given button is currently held.

See `SDL_JoystickGetButton` for C documentation.

ballDelta Source #

Arguments

:: MonadIO m |
=> Joystick |
-> CInt | The index of the joystick ball. You can use `numBalls` to determine how many balls a given joystick has.
-> m (V2 CInt) |

Get the ball axis change since the last poll.

See `SDL_JoystickGetBall` for C documentation.

axisPosition :: MonadIO m => Joystick -> CInt -> m Int16 Source #

Get the current state of an axis control on a joystick.

Returns a 16-bit signed integer representing the current position of the axis. The state is a value ranging from -32768 to 32767.

On most modern joysticks the x-axis is usually represented by axis 0 and the y-axis by axis 1. The value returned by `axisPosition` is a signed integer (-32768 to 32767) representing the current position of the axis. It may be necessary to impose certain tolerances on these values to account for jitter.

Some joysticks use axes 2 and 3 for extra buttons.

See `SDL_JoystickGetAxis` for C documentation.

numAxes :: MonadIO m => Joystick -> m CInt Source #

Get the number of general axis controls on a joystick.

See `SDL_JoystickNumAxes` for C documentation.

numButtons :: MonadIO m => Joystick -> m CInt Source #

Get the number of buttons on a joystick.

See `SDL_JoystickNumButtons` for C documentation.

numBalls :: MonadIO m => Joystick -> m CInt Source #

Get the number of trackballs on a joystick.

See `SDL_JoystickNumBalls` for C documentation.

data JoyHatPosition Source #

Identifies the state of the POV hat on a joystick.

Constructors

HatCentered | Centered position
HatUp | Up position
HatRight | Right position
HatDown | Down position
HatLeft | Left position
HatRightUp | Right-up position
HatRightDown | Right-down position
HatLeftUp | Left-up position
HatLeftDown | Left-down position

Instances

Eq JoyHatPosition Source # |
Instance details Defined in SDL.Input.Joystick Methods (==) :: JoyHatPosition -> JoyHatPosition -> Bool Source # (/=) :: JoyHatPosition -> JoyHatPosition -> Bool Source #
Data JoyHatPosition Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JoyHatPosition -> c JoyHatPosition Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JoyHatPosition Source #

toConstr :: JoyHatPosition -> Constr Source #

dataTypeOf :: JoyHatPosition -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JoyHatPosition) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JoyHatPosition) Source #

gmapT :: (forall b. Data b => b -> b) -> JoyHatPosition -> JoyHatPosition Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JoyHatPosition -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JoyHatPosition -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> JoyHatPosition -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JoyHatPosition -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JoyHatPosition -> m JoyHatPosition Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JoyHatPosition -> m JoyHatPosition Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JoyHatPosition -> m JoyHatPosition Source #

Ord JoyHatPosition Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

compare :: JoyHatPosition -> JoyHatPosition -> Ordering Source #

(<) :: JoyHatPosition -> JoyHatPosition -> Bool Source #

(<=) :: JoyHatPosition -> JoyHatPosition -> Bool Source #

(>) :: JoyHatPosition -> JoyHatPosition -> Bool Source #

(>=) :: JoyHatPosition -> JoyHatPosition -> Bool Source #

max :: JoyHatPosition -> JoyHatPosition -> JoyHatPosition Source #

min :: JoyHatPosition -> JoyHatPosition -> JoyHatPosition Source #

Read JoyHatPosition Source # |
Instance details Defined in SDL.Input.Joystick Methods readsPrec :: Int -> ReadS JoyHatPosition Source # readList :: ReadS [JoyHatPosition] Source # readPrec :: ReadPrec JoyHatPosition Source # readListPrec :: ReadPrec [JoyHatPosition] Source #
Show JoyHatPosition Source # |
Instance details Defined in SDL.Input.Joystick Methods showsPrec :: Int -> JoyHatPosition -> ShowS Source # show :: JoyHatPosition -> String Source # showList :: [JoyHatPosition] -> ShowS Source #
Generic JoyHatPosition Source # |
Instance details Defined in SDL.Input.Joystick Associated Types type Rep JoyHatPosition :: Type -> Type Source # Methods from :: JoyHatPosition -> Rep JoyHatPosition x Source # to :: Rep JoyHatPosition x -> JoyHatPosition Source #
FromNumber JoyHatPosition Word8 Source # |
Instance details Defined in SDL.Input.Joystick Methods fromNumber :: Word8 -> JoyHatPosition Source #
type Rep JoyHatPosition Source # |

Instance details

Defined in SDL.Input.Joystick

type Rep JoyHatPosition = D1 (MetaData "JoyHatPosition" "SDL.Input.Joystick" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (((C1 (MetaCons "HatCentered" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "HatUp" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "HatRight" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "HatDown" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "HatLeft" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "HatRightUp" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "HatRightDown" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "HatLeftUp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "HatLeftDown" PrefixI False) (U1 :: Type -> Type)))))

getHat Source #

Arguments

:: (Functor m, MonadIO m) |
=> Joystick |
-> CInt | The index of the POV hat. You can use `numHats` to determine how many POV hats a given joystick has.
-> m JoyHatPosition |

Get current position of a POV hat on a joystick.

See `SDL_JoystickGetHat` for C documentation.

numHats :: MonadIO m => Joystick -> m CInt Source #

Get the number of POV hats on a joystick.

See `SDL_JoystickNumHats` for C documentation.

data JoyDeviceConnection Source #

Identifies whether a joystick has been connected or disconnected.

Constructors

JoyDeviceAdded |
JoyDeviceRemoved |

Instances

Eq JoyDeviceConnection Source # |
Instance details Defined in SDL.Input.Joystick Methods (==) :: JoyDeviceConnection -> JoyDeviceConnection -> Bool Source # (/=) :: JoyDeviceConnection -> JoyDeviceConnection -> Bool Source #
Data JoyDeviceConnection Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JoyDeviceConnection -> c JoyDeviceConnection Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JoyDeviceConnection Source #

toConstr :: JoyDeviceConnection -> Constr Source #

dataTypeOf :: JoyDeviceConnection -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JoyDeviceConnection) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JoyDeviceConnection) Source #

gmapT :: (forall b. Data b => b -> b) -> JoyDeviceConnection -> JoyDeviceConnection Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JoyDeviceConnection -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JoyDeviceConnection -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> JoyDeviceConnection -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JoyDeviceConnection -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JoyDeviceConnection -> m JoyDeviceConnection Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JoyDeviceConnection -> m JoyDeviceConnection Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JoyDeviceConnection -> m JoyDeviceConnection Source #

Ord JoyDeviceConnection Source # |

Instance details

Defined in SDL.Input.Joystick

Methods

compare :: JoyDeviceConnection -> JoyDeviceConnection -> Ordering Source #

(<) :: JoyDeviceConnection -> JoyDeviceConnection -> Bool Source #

(<=) :: JoyDeviceConnection -> JoyDeviceConnection -> Bool Source #

(>) :: JoyDeviceConnection -> JoyDeviceConnection -> Bool Source #

(>=) :: JoyDeviceConnection -> JoyDeviceConnection -> Bool Source #

max :: JoyDeviceConnection -> JoyDeviceConnection -> JoyDeviceConnection Source #

min :: JoyDeviceConnection -> JoyDeviceConnection -> JoyDeviceConnection Source #

Read JoyDeviceConnection Source # |
Instance details Defined in SDL.Input.Joystick Methods readsPrec :: Int -> ReadS JoyDeviceConnection Source # readList :: ReadS [JoyDeviceConnection] Source # readPrec :: ReadPrec JoyDeviceConnection Source # readListPrec :: ReadPrec [JoyDeviceConnection] Source #
Show JoyDeviceConnection Source # |
Instance details Defined in SDL.Input.Joystick Methods showsPrec :: Int -> JoyDeviceConnection -> ShowS Source # show :: JoyDeviceConnection -> String Source # showList :: [JoyDeviceConnection] -> ShowS Source #
Generic JoyDeviceConnection Source # |
Instance details Defined in SDL.Input.Joystick Associated Types type Rep JoyDeviceConnection :: Type -> Type Source # Methods from :: JoyDeviceConnection -> Rep JoyDeviceConnection x Source # to :: Rep JoyDeviceConnection x -> JoyDeviceConnection Source #
FromNumber JoyDeviceConnection Word32 Source # |
Instance details Defined in SDL.Input.Joystick Methods fromNumber :: Word32 -> JoyDeviceConnection Source #
type Rep JoyDeviceConnection Source # |
Instance details Defined in SDL.Input.Joystick type Rep JoyDeviceConnection = D1 (MetaData "JoyDeviceConnection" "SDL.Input.Joystick" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (C1 (MetaCons "JoyDeviceAdded" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "JoyDeviceRemoved" PrefixI False) (U1 :: Type -> Type))