| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Graphics.GPipe.Context.GLFW.Input
Contents
Description
This module exposes much of the functionality that GLFW the Input guide documents:
http://www.glfw.org/docs/latest/input_guide.html.
Actions are in the GPipe ContextT monad when a window handle is required,
otherwise they are bare IO actions.
It is recommended to read about GLFW input handling as it pertains to your domain,
especially the Event processing section:
http://www.glfw.org/docs/latest/input_guide.html#events.
- pollEvents :: IO ()
- waitEvents :: IO ()
- postEmptyEvent :: IO ()
- setKeyCallback :: MonadIO m => Maybe (Key -> Int -> KeyState -> ModifierKeys -> IO ()) -> ContextT GLFWWindow os f m ()
- getKey :: MonadIO m => Key -> ContextT GLFWWindow os f m KeyState
- setStickyKeysInputMode :: MonadIO m => StickyKeysInputMode -> ContextT GLFWWindow os f m ()
- getStickyKeysInputMode :: MonadIO m => ContextT GLFWWindow os f m StickyKeysInputMode
- setCharCallback :: MonadIO m => Maybe (Char -> IO ()) -> ContextT GLFWWindow os f m ()
- setCursorPosCallback :: MonadIO m => Maybe (Double -> Double -> IO ()) -> ContextT GLFWWindow os f m ()
- getCursorPos :: MonadIO m => ContextT GLFWWindow os f m (Double, Double)
- setCursorInputMode :: MonadIO m => CursorInputMode -> ContextT GLFWWindow os f m ()
- getCursorInputMode :: MonadIO m => ContextT GLFWWindow os f m CursorInputMode
- createCursor :: Image -> Int -> Int -> IO Cursor
- createStandardCursor :: StandardCursorShape -> IO Cursor
- destroyCursor :: Cursor -> IO ()
- setCursor :: MonadIO m => Cursor -> ContextT GLFWWindow os f m ()
- setCursorEnterCallback :: MonadIO m => Maybe (CursorState -> IO ()) -> ContextT GLFWWindow os f m ()
- setMouseButtonCallback :: MonadIO m => Maybe (MouseButton -> MouseButtonState -> ModifierKeys -> IO ()) -> ContextT GLFWWindow os f m ()
- getMouseButton :: MonadIO m => MouseButton -> ContextT GLFWWindow os f m MouseButtonState
- setStickyMouseButtonsInputMode :: MonadIO m => StickyMouseButtonsInputMode -> ContextT GLFWWindow os f m ()
- getStickyMouseButtonsInputMode :: MonadIO m => ContextT GLFWWindow os f m StickyMouseButtonsInputMode
- setScrollCallback :: MonadIO m => Maybe (Double -> Double -> IO ()) -> ContextT GLFWWindow os f m ()
- joystickPresent :: Joystick -> IO Bool
- getJoystickAxes :: Joystick -> IO (Maybe [Double])
- getJoystickButtons :: Joystick -> IO (Maybe [JoystickButtonState])
- getJoystickName :: Joystick -> IO (Maybe String)
- getTime :: IO (Maybe Double)
- setTime :: Double -> IO ()
- getClipboardString :: MonadIO m => ContextT GLFWWindow os f m (Maybe String)
- setClipboardString :: MonadIO m => String -> ContextT GLFWWindow os f m ()
- setDropCallback :: MonadIO m => Maybe ([String] -> IO ()) -> ContextT GLFWWindow os f m ()
- data Key :: *
- = Key'Unknown
- | Key'Space
- | Key'Apostrophe
- | Key'Comma
- | Key'Minus
- | Key'Period
- | Key'Slash
- | Key'0
- | Key'1
- | Key'2
- | Key'3
- | Key'4
- | Key'5
- | Key'6
- | Key'7
- | Key'8
- | Key'9
- | Key'Semicolon
- | Key'Equal
- | Key'A
- | Key'B
- | Key'C
- | Key'D
- | Key'E
- | Key'F
- | Key'G
- | Key'H
- | Key'I
- | Key'J
- | Key'K
- | Key'L
- | Key'M
- | Key'N
- | Key'O
- | Key'P
- | Key'Q
- | Key'R
- | Key'S
- | Key'T
- | Key'U
- | Key'V
- | Key'W
- | Key'X
- | Key'Y
- | Key'Z
- | Key'LeftBracket
- | Key'Backslash
- | Key'RightBracket
- | Key'GraveAccent
- | Key'World1
- | Key'World2
- | Key'Escape
- | Key'Enter
- | Key'Tab
- | Key'Backspace
- | Key'Insert
- | Key'Delete
- | Key'Right
- | Key'Left
- | Key'Down
- | Key'Up
- | Key'PageUp
- | Key'PageDown
- | Key'Home
- | Key'End
- | Key'CapsLock
- | Key'ScrollLock
- | Key'NumLock
- | Key'PrintScreen
- | Key'Pause
- | Key'F1
- | Key'F2
- | Key'F3
- | Key'F4
- | Key'F5
- | Key'F6
- | Key'F7
- | Key'F8
- | Key'F9
- | Key'F10
- | Key'F11
- | Key'F12
- | Key'F13
- | Key'F14
- | Key'F15
- | Key'F16
- | Key'F17
- | Key'F18
- | Key'F19
- | Key'F20
- | Key'F21
- | Key'F22
- | Key'F23
- | Key'F24
- | Key'F25
- | Key'Pad0
- | Key'Pad1
- | Key'Pad2
- | Key'Pad3
- | Key'Pad4
- | Key'Pad5
- | Key'Pad6
- | Key'Pad7
- | Key'Pad8
- | Key'Pad9
- | Key'PadDecimal
- | Key'PadDivide
- | Key'PadMultiply
- | Key'PadSubtract
- | Key'PadAdd
- | Key'PadEnter
- | Key'PadEqual
- | Key'LeftShift
- | Key'LeftControl
- | Key'LeftAlt
- | Key'LeftSuper
- | Key'RightShift
- | Key'RightControl
- | Key'RightAlt
- | Key'RightSuper
- | Key'Menu
- data KeyState :: *
- data ModifierKeys :: * = ModifierKeys {}
- data StickyKeysInputMode :: *
- data CursorInputMode :: *
- data StandardCursorShape :: *
- data CursorState :: *
- data StickyMouseButtonsInputMode :: *
- data MouseButton :: *
- data MouseButtonState :: *
- data Joystick :: *
- data JoystickButtonState :: *
- type ScrollCallback = Window -> Double -> Double -> IO ()
- registerScrollCallback :: MonadIO m => Maybe ScrollCallback -> ContextT GLFWWindow os f m ()
- windowShouldClose :: MonadIO m => ContextT GLFWWindow os f m Bool
Event processing
pollEvents :: IO () #
Process received events and return; for applications which continually render.
waitEvents :: IO () #
Sleep until an event is received; for applications which update in response to user input.
postEmptyEvent :: IO () #
Force wake from waitEvents with a dummy event.
Keyboard input
Key input
setKeyCallback :: MonadIO m => Maybe (Key -> Int -> KeyState -> ModifierKeys -> IO ()) -> ContextT GLFWWindow os f m () Source #
setStickyKeysInputMode :: MonadIO m => StickyKeysInputMode -> ContextT GLFWWindow os f m () Source #
Polling a Key for KeyState may sometimes miss state transitions.
If you use cannot use a callback to receive KeyState changes,
use getKey in combination with GLFW's sticky-keys feature:
http://www.glfw.org/docs/latest/input_guide.html#input_key.
getStickyKeysInputMode :: MonadIO m => ContextT GLFWWindow os f m StickyKeysInputMode Source #
Text input
setCharCallback :: MonadIO m => Maybe (Char -> IO ()) -> ContextT GLFWWindow os f m () Source #
Register or unregister a callback to receive character input obeying keyboard layouts and modifier effects.
Mouse input
Cursor position
setCursorPosCallback :: MonadIO m => Maybe (Double -> Double -> IO ()) -> ContextT GLFWWindow os f m () Source #
Register or unregister a callback to receive mouse location changes.
Callback receives x and y position measured in screen-coordinates relative to the top left of the GLFW window.
getCursorPos :: MonadIO m => ContextT GLFWWindow os f m (Double, Double) Source #
Poll for the location of the mouse.
Cursor modes
setCursorInputMode :: MonadIO m => CursorInputMode -> ContextT GLFWWindow os f m () Source #
GLFW supports setting cursor mode to support mouselook and other advanced uses of the mouse: http://www.glfw.org/docs/latest/input_guide.html#cursor_mode.
getCursorInputMode :: MonadIO m => ContextT GLFWWindow os f m CursorInputMode Source #
Cursor objects
Custom cursor creation
Arguments
| :: Image | The desired cursor image. |
| -> Int | The desired x-coordinate, in pixels, of the cursor hotspot. |
| -> Int | The desired y-coordinate, in pixels, of the cursor hotspot. |
| -> IO Cursor |
Creates a new cursor.
Standard cursor creation
createStandardCursor :: StandardCursorShape -> IO Cursor #
Creates a cursor with a standard shape that can be set for a window with setCursor.
Cursor destruction
destroyCursor :: Cursor -> IO () #
Destroys a cursor previously created with createCursor. Any remaining
cursors will be destroyed by terminate.
Cursor setting
setCursor :: MonadIO m => Cursor -> ContextT GLFWWindow os f m () Source #
Set the cursor to be displayed over the window while CursorInputMode is Normal.
Cursor enter/leave events
setCursorEnterCallback :: MonadIO m => Maybe (CursorState -> IO ()) -> ContextT GLFWWindow os f m () Source #
Register or unregister a callback to receive CursorState changes when the cursor enters or exits the window.
Mouse button input
setMouseButtonCallback :: MonadIO m => Maybe (MouseButton -> MouseButtonState -> ModifierKeys -> IO ()) -> ContextT GLFWWindow os f m () Source #
Register or unregister a callback to receive MouseButtonState changes to a MouseButton.
getMouseButton :: MonadIO m => MouseButton -> ContextT GLFWWindow os f m MouseButtonState Source #
Poll for the MouseButtonState of a MouseButton.
setStickyMouseButtonsInputMode :: MonadIO m => StickyMouseButtonsInputMode -> ContextT GLFWWindow os f m () Source #
Polling a MouseButton for MouseButtonState may sometimes miss state transitions.
If you use cannot use a callback to receive MouseButtonState changes,
use getMouseButton in combination with GLFW's sticky-mouse-buttons feature:
http://www.glfw.org/docs/latest/input_guide.html#input_mouse_button.
getStickyMouseButtonsInputMode :: MonadIO m => ContextT GLFWWindow os f m StickyMouseButtonsInputMode Source #
Scroll input
setScrollCallback :: MonadIO m => Maybe (Double -> Double -> IO ()) -> ContextT GLFWWindow os f m () Source #
Register or unregister a callback to receive scroll offset changes.
Joystick input
joystickPresent :: Joystick -> IO Bool #
Is the specified Joystick currently connected?
Joystick axis states
Poll for the positions of each axis on the Joystick. Positions are on the range `-1.0..1.0`.
Joystick button states
getJoystickButtons :: Joystick -> IO (Maybe [JoystickButtonState]) #
Poll for the JoystickButtonState of each button on the Joystick.
Joystick name
Retrieve a non-unique string identifier for the Joystick.
This might be the make & model name of the device.
Time input
Poll for the number of seconds since GLFW was initialized by GPipe.
Manually set the timer to a specified value.
Clipboard input and output
getClipboardString :: MonadIO m => ContextT GLFWWindow os f m (Maybe String) Source #
Poll the system clipboard for a UTF-8 encoded string, if one can be extracted.
setClipboardString :: MonadIO m => String -> ContextT GLFWWindow os f m () Source #
Store a UTF-8 encoded string in the system clipboard.
Path drop input
setDropCallback :: MonadIO m => Maybe ([String] -> IO ()) -> ContextT GLFWWindow os f m () Source #
Register or unregister a callback to receive file paths when files are dropped onto the window.
Reexported datatypes
Keyboard
Constructors
Constructors
| KeyState'Pressed | |
| KeyState'Released | |
| KeyState'Repeating |
data StickyKeysInputMode :: * #
Mouse
data CursorInputMode :: * #
data StandardCursorShape :: * #
data StickyMouseButtonsInputMode :: * #
data MouseButton :: * #
Constructors
| MouseButton'1 | |
| MouseButton'2 | |
| MouseButton'3 | |
| MouseButton'4 | |
| MouseButton'5 | |
| MouseButton'6 | |
| MouseButton'7 | |
| MouseButton'8 |
Instances
data MouseButtonState :: * #
Constructors
| MouseButtonState'Pressed | |
| MouseButtonState'Released |
Joystick
data JoystickButtonState :: * #
Not supported
Some GLFW functionality isn't currently exposed by GLFW-b.
glfwWaitEventsTimeoutglfwSetCharModsCallbackglfwGetKeyNameglfwSetJoystickCallbackglfwGetTimerValueglfwGetTimerFrequency
Deprecated
registerScrollCallback :: MonadIO m => Maybe ScrollCallback -> ContextT GLFWWindow os f m () Source #
Register or unregister a ScrollCallback to receive scroll events.
Deprecated and will be removed. Prefer to use setScrollCallback.
windowShouldClose :: MonadIO m => ContextT GLFWWindow os f m Bool Source #
Returns True if the window should close (e.g. because the user pressed the 'x' button).
Deprecated and will be moved to a different module.