Safe Haskell | None |
---|---|
Language | Haskell2010 |
User input functions covering much of the GLFW Input guide: 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 reexported IO actions which can be lifted into the ContextT
monad.
The Window
taken by many of these functions is the window resource from GPipe.
- postEmptyEvent :: IO ()
- setKeyCallback :: MonadIO m => Window os c ds -> Maybe (Key -> Int -> KeyState -> ModifierKeys -> IO ()) -> ContextT Handle os m (Maybe ())
- getKey :: MonadIO m => Window os c ds -> Key -> ContextT Handle os m (Maybe KeyState)
- setStickyKeysInputMode :: MonadIO m => Window os c ds -> StickyKeysInputMode -> ContextT Handle os m (Maybe ())
- getStickyKeysInputMode :: MonadIO m => Window os c ds -> ContextT Handle os m (Maybe StickyKeysInputMode)
- setCharCallback :: MonadIO m => Window os c ds -> Maybe (Char -> IO ()) -> ContextT Handle os m (Maybe ())
- setCursorPosCallback :: MonadIO m => Window os c ds -> Maybe (Double -> Double -> IO ()) -> ContextT Handle os m (Maybe ())
- getCursorPos :: MonadIO m => Window os c ds -> ContextT Handle os m (Maybe (Double, Double))
- setCursorInputMode :: MonadIO m => Window os c ds -> CursorInputMode -> ContextT Handle os m (Maybe ())
- getCursorInputMode :: MonadIO m => Window os c ds -> ContextT Handle os m (Maybe CursorInputMode)
- createCursor :: Image -> Int -> Int -> IO Cursor
- createStandardCursor :: StandardCursorShape -> IO Cursor
- destroyCursor :: Cursor -> IO ()
- setCursor :: MonadIO m => Window os c ds -> Cursor -> ContextT Handle os m (Maybe ())
- setCursorEnterCallback :: MonadIO m => Window os c ds -> Maybe (CursorState -> IO ()) -> ContextT Handle os m (Maybe ())
- setMouseButtonCallback :: MonadIO m => Window os c ds -> Maybe (MouseButton -> MouseButtonState -> ModifierKeys -> IO ()) -> ContextT Handle os m (Maybe ())
- getMouseButton :: MonadIO m => Window os c ds -> MouseButton -> ContextT Handle os m (Maybe MouseButtonState)
- setStickyMouseButtonsInputMode :: MonadIO m => Window os c ds -> StickyMouseButtonsInputMode -> ContextT Handle os m (Maybe ())
- getStickyMouseButtonsInputMode :: MonadIO m => Window os c ds -> ContextT Handle os m (Maybe StickyMouseButtonsInputMode)
- setScrollCallback :: MonadIO m => Window os c ds -> Maybe (Double -> Double -> IO ()) -> ContextT Handle os m (Maybe ())
- 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 => Window os c ds -> ContextT Handle os m (Maybe (Maybe String))
- setClipboardString :: MonadIO m => Window os c ds -> String -> ContextT Handle os m (Maybe ())
- setDropCallback :: MonadIO m => Window os c ds -> Maybe ([String] -> IO ()) -> ContextT Handle os m (Maybe ())
- 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 :: *
Event processing
Learn more: http://www.glfw.org/docs/latest/input_guide.html#events
glfwPollEvents
glfwWaitEvents
GLFW Events are processed after each buffer swap by default. To change
event processing construct a HandleConfig
for runContextT
. For greater
control use the mainloop
and mainstep
functions provided by
Graphics.GPipe.Context.GLFW.
postEmptyEvent :: IO () #
Force wake from waitEvents
with a dummy event.
Keyboard input
Key input
setKeyCallback :: MonadIO m => Window os c ds -> Maybe (Key -> Int -> KeyState -> ModifierKeys -> IO ()) -> ContextT Handle os m (Maybe ()) Source #
setStickyKeysInputMode :: MonadIO m => Window os c ds -> StickyKeysInputMode -> ContextT Handle os m (Maybe ()) 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 => Window os c ds -> ContextT Handle os m (Maybe StickyKeysInputMode) Source #
Text input
setCharCallback :: MonadIO m => Window os c ds -> Maybe (Char -> IO ()) -> ContextT Handle os m (Maybe ()) Source #
Register or unregister a callback to receive character input obeying keyboard layouts and modifier effects.
Mouse input
Cursor position
setCursorPosCallback :: MonadIO m => Window os c ds -> Maybe (Double -> Double -> IO ()) -> ContextT Handle os m (Maybe ()) 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 => Window os c ds -> ContextT Handle os m (Maybe (Double, Double)) Source #
Poll for the location of the mouse.
Cursor modes
setCursorInputMode :: MonadIO m => Window os c ds -> CursorInputMode -> ContextT Handle os m (Maybe ()) 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 => Window os c ds -> ContextT Handle os m (Maybe CursorInputMode) Source #
Cursor objects
Custom cursor creation
:: 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 => Window os c ds -> Cursor -> ContextT Handle os m (Maybe ()) Source #
Set the cursor to be displayed over the window while CursorInputMode
is Normal
.
Cursor enter/leave events
setCursorEnterCallback :: MonadIO m => Window os c ds -> Maybe (CursorState -> IO ()) -> ContextT Handle os m (Maybe ()) Source #
Register or unregister a callback to receive CursorState
changes when the cursor enters or exits the window.
Mouse button input
setMouseButtonCallback :: MonadIO m => Window os c ds -> Maybe (MouseButton -> MouseButtonState -> ModifierKeys -> IO ()) -> ContextT Handle os m (Maybe ()) Source #
Register or unregister a callback to receive MouseButtonState
changes to a MouseButton
.
getMouseButton :: MonadIO m => Window os c ds -> MouseButton -> ContextT Handle os m (Maybe MouseButtonState) Source #
Poll for the MouseButtonState
of a MouseButton
.
setStickyMouseButtonsInputMode :: MonadIO m => Window os c ds -> StickyMouseButtonsInputMode -> ContextT Handle os m (Maybe ()) 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 => Window os c ds -> ContextT Handle os m (Maybe StickyMouseButtonsInputMode) Source #
Scroll input
setScrollCallback :: MonadIO m => Window os c ds -> Maybe (Double -> Double -> IO ()) -> ContextT Handle os m (Maybe ()) 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 => Window os c ds -> ContextT Handle os m (Maybe (Maybe String)) Source #
Poll the system clipboard for a UTF-8 encoded string, if one can be extracted.
setClipboardString :: MonadIO m => Window os c ds -> String -> ContextT Handle os m (Maybe ()) Source #
Store a UTF-8 encoded string in the system clipboard.
Path drop input
setDropCallback :: MonadIO m => Window os c ds -> Maybe ([String] -> IO ()) -> ContextT Handle os m (Maybe ()) Source #
Register or unregister a callback to receive file paths when files are dropped onto the window.
Reexported datatypes
Keyboard
data ModifierKeys :: * #
data StickyKeysInputMode :: * #
Mouse
data CursorInputMode :: * #
data StandardCursorShape :: * #
data CursorState :: * #
data StickyMouseButtonsInputMode :: * #
data MouseButton :: * #
data MouseButtonState :: * #
Joystick
data JoystickButtonState :: * #
Not supported
Some GLFW functionality isn't currently exposed by Graphics.UI.GLFW.
glfwWaitEventsTimeout
glfwSetCharModsCallback
glfwGetKeyName
glfwSetJoystickCallback
glfwGetTimerValue
glfwGetTimerFrequency