Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data InputState
- data ControllerAxis
- data ControllerButton
- = ControllerButtonInvalid
- | ControllerButtonA
- | ControllerButtonB
- | ControllerButtonX
- | ControllerButtonY
- | ControllerButtonBack
- | ControllerButtonGuide
- | ControllerButtonStart
- | ControllerButtonLeftStick
- | ControllerButtonRightStick
- | ControllerButtonLeftShoulder
- | ControllerButtonRightShoulder
- | ControllerButtonDpadUp
- | ControllerButtonDpadDown
- | ControllerButtonDpadLeft
- | ControllerButtonDpadRight
- data MouseButton
- updateInputs :: MonadIO m => InputState -> m (InputState, Bool)
- closeControllers :: InputState -> TwirlMonad ()
- emptyInputState :: InputState
- numControllers :: InputState -> Int
- isControllerButtonDown :: InputState -> Int -> ControllerButton -> Bool
- controllerAxis :: InputState -> Int -> ControllerAxis -> Double
- isKeyDown :: InputState -> Keycode -> Bool
- isMouseDown :: InputState -> MouseButton -> Bool
- mousePosition :: InputState -> (Int, Int)
Documentation
data InputState Source #
Instances
Show InputState Source # | |
Defined in Twirl.Inputs showsPrec :: Int -> InputState -> ShowS # show :: InputState -> String # showList :: [InputState] -> ShowS # |
data ControllerAxis Source #
data ControllerButton #
Identifies a gamepad button.
Instances
data MouseButton #
ButtonLeft | |
ButtonMiddle | |
ButtonRight | |
ButtonX1 | |
ButtonX2 | |
ButtonExtra !Int | An unknown mouse button. |
Instances
updateInputs :: MonadIO m => InputState -> m (InputState, Bool) Source #
closeControllers :: InputState -> TwirlMonad () Source #
numControllers :: InputState -> Int Source #
Get number of controllers
Returns the maximum number of controllers that have been connected simultaneously. This means that if you connect four controllers and unplug one, this function will return 4.
isControllerButtonDown Source #
:: InputState | |
-> Int | Controller number to be queried |
-> ControllerButton | The Controller button to be queried |
-> Bool |
Query the state of controller buttons
Returns True if the queried button is down on the queried controller. Returns False if the controller is disconnected or doesn't exist (e.g. you query controller number 4 but there are only 2 controllers).
:: InputState | |
-> Int | Controller number |
-> ControllerAxis | The queried axis |
-> Double |
Query axes of controllers
For the stick axes, the returned value is between -1.0 and 1.0, where 0.0 is the neutral position. For triggers the value is between 0.0 and 1.0 where 0.0 is the neutral position. Bear in mind that usually the level of quality of controller sticks is so low that the sticks don't return exactly to the 0.0 position, so you have to ignore some values which are too close to zero.
isMouseDown :: InputState -> MouseButton -> Bool Source #
Query mouse button state
mousePosition :: InputState -> (Int, Int) Source #
Get mouse position on screen