|
typedef void(* | GLFWmousebuttonfun) (GLFWwindow *, int, int, int) |
| The function signature for mouse button callbacks. More...
|
|
typedef void(* | GLFWcursorposfun) (GLFWwindow *, double, double) |
| The function signature for cursor position callbacks. More...
|
|
typedef void(* | GLFWcursorenterfun) (GLFWwindow *, int) |
| The function signature for cursor enter/leave callbacks. More...
|
|
typedef void(* | GLFWscrollfun) (GLFWwindow *, double, double) |
| The function signature for scroll callbacks. More...
|
|
typedef void(* | GLFWkeyfun) (GLFWwindow *, int, int, int, int) |
| The function signature for keyboard key callbacks. More...
|
|
typedef void(* | GLFWcharfun) (GLFWwindow *, unsigned int) |
| The function signature for Unicode character callbacks. More...
|
|
typedef void(* | GLFWcharmodsfun) (GLFWwindow *, unsigned int, int) |
| The function signature for Unicode character with modifiers callbacks. More...
|
|
typedef void(* | GLFWdropfun) (GLFWwindow *, int, const char **) |
| The function signature for file drop callbacks. More...
|
|
|
int | glfwGetInputMode (GLFWwindow *window, int mode) |
| Returns the value of an input option for the specified window. More...
|
|
void | glfwSetInputMode (GLFWwindow *window, int mode, int value) |
| Sets an input option for the specified window. More...
|
|
int | glfwGetKey (GLFWwindow *window, int key) |
| Returns the last reported state of a keyboard key for the specified window. More...
|
|
int | glfwGetMouseButton (GLFWwindow *window, int button) |
| Returns the last reported state of a mouse button for the specified window. More...
|
|
void | glfwGetCursorPos (GLFWwindow *window, double *xpos, double *ypos) |
| Retrieves the position of the cursor relative to the client area of the window. More...
|
|
void | glfwSetCursorPos (GLFWwindow *window, double xpos, double ypos) |
| Sets the position of the cursor, relative to the client area of the window. More...
|
|
GLFWcursor * | glfwCreateCursor (const GLFWimage *image, int xhot, int yhot) |
| Creates a custom cursor. More...
|
|
GLFWcursor * | glfwCreateStandardCursor (int shape) |
| Creates a cursor with a standard shape. More...
|
|
void | glfwDestroyCursor (GLFWcursor *cursor) |
| Destroys a cursor. More...
|
|
void | glfwSetCursor (GLFWwindow *window, GLFWcursor *cursor) |
| Sets the cursor for the window. More...
|
|
GLFWkeyfun | glfwSetKeyCallback (GLFWwindow *window, GLFWkeyfun cbfun) |
| Sets the key callback. More...
|
|
GLFWcharfun | glfwSetCharCallback (GLFWwindow *window, GLFWcharfun cbfun) |
| Sets the Unicode character callback. More...
|
|
GLFWcharmodsfun | glfwSetCharModsCallback (GLFWwindow *window, GLFWcharmodsfun cbfun) |
| Sets the Unicode character with modifiers callback. More...
|
|
GLFWmousebuttonfun | glfwSetMouseButtonCallback (GLFWwindow *window, GLFWmousebuttonfun cbfun) |
| Sets the mouse button callback. More...
|
|
GLFWcursorposfun | glfwSetCursorPosCallback (GLFWwindow *window, GLFWcursorposfun cbfun) |
| Sets the cursor position callback. More...
|
|
GLFWcursorenterfun | glfwSetCursorEnterCallback (GLFWwindow *window, GLFWcursorenterfun cbfun) |
| Sets the cursor enter/exit callback. More...
|
|
GLFWscrollfun | glfwSetScrollCallback (GLFWwindow *window, GLFWscrollfun cbfun) |
| Sets the scroll callback. More...
|
|
GLFWdropfun | glfwSetDropCallback (GLFWwindow *window, GLFWdropfun cbfun) |
| Sets the file drop callback. More...
|
|
int | glfwJoystickPresent (int joy) |
| Returns whether the specified joystick is present. More...
|
|
const float * | glfwGetJoystickAxes (int joy, int *count) |
| Returns the values of all axes of the specified joystick. More...
|
|
const unsigned char * | glfwGetJoystickButtons (int joy, int *count) |
| Returns the state of all buttons of the specified joystick. More...
|
|
const char * | glfwGetJoystickName (int joy) |
| Returns the name of the specified joystick. More...
|
|
void | glfwSetClipboardString (GLFWwindow *window, const char *string) |
| Sets the clipboard to the specified string. More...
|
|
const char * | glfwGetClipboardString (GLFWwindow *window) |
| Returns the contents of the clipboard as a string. More...
|
|
double | glfwGetTime (void) |
| Returns the value of the GLFW timer. More...
|
|
void | glfwSetTime (double time) |
| Sets the GLFW timer. More...
|
|
This is the reference documentation for input related functions and types. For more information, see the Input guide.
Creates a new custom cursor image that can be set for a window with glfwSetCursor. The cursor can be destroyed with glfwDestroyCursor. Any remaining cursors are destroyed by glfwTerminate.
The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits per channel. They are arranged canonically as packed sequential rows, starting from the top-left corner.
The cursor hotspot is specified in pixels, relative to the upper-left corner of the cursor image. Like all other coordinate systems in GLFW, the X-axis points to the right and the Y-axis points down.
- Parameters
-
[in] | image | The desired cursor image. |
[in] | xhot | The desired x-coordinate, in pixels, of the cursor hotspot. |
[in] | yhot | The desired y-coordinate, in pixels, of the cursor hotspot. |
- Returns
- The handle of the created cursor, or
NULL
if an error occurred.
- Pointer Lifetime
- The specified image data is copied before this function returns.
- Reentrancy
- This function may not be called from a callback.
- Thread Safety
- This function may only be called from the main thread.
- See also
- Cursor objects
-
glfwDestroyCursor
-
glfwCreateStandardCursor
- Since
- Added in GLFW 3.1.
void glfwGetCursorPos |
( |
GLFWwindow * |
window, |
|
|
double * |
xpos, |
|
|
double * |
ypos |
|
) |
| |
This function returns the position of the cursor, in screen coordinates, relative to the upper-left corner of the client area of the specified window.
If the cursor is disabled (with GLFW_CURSOR_DISABLED
) then the cursor position is unbounded and limited only by the minimum and maximum values of a double
.
The coordinate can be converted to their integer equivalents with the floor
function. Casting directly to an integer type works for positive coordinates, but fails for negative ones.
Any or all of the position arguments may be NULL
. If an error occurs, all non-NULL
position arguments will be set to zero.
- Parameters
-
[in] | window | The desired window. |
[out] | xpos | Where to store the cursor x-coordinate, relative to the left edge of the client area, or NULL . |
[out] | ypos | Where to store the cursor y-coordinate, relative to the to top edge of the client area, or NULL . |
- Thread Safety
- This function may only be called from the main thread.
- See also
- Cursor position
-
glfwSetCursorPos
- Since
- Added in GLFW 3.0. Replaces
glfwGetMousePos
.
This function returns the last state reported for the specified key to the specified window. The returned state is one of GLFW_PRESS
or GLFW_RELEASE
. The higher-level action GLFW_REPEAT
is only reported to the key callback.
If the GLFW_STICKY_KEYS
input mode is enabled, this function returns GLFW_PRESS
the first time you call it for a key that was pressed, even if that key has already been released.
The key functions deal with physical keys, with key tokens named after their use on the standard US keyboard layout. If you want to input text, use the Unicode character callback instead.
The modifier key bit masks are not key tokens and cannot be used with this function.
- Parameters
-
[in] | window | The desired window. |
[in] | key | The desired keyboard key. GLFW_KEY_UNKNOWN is not a valid key for this function. |
- Returns
- One of
GLFW_PRESS
or GLFW_RELEASE
.
- Thread Safety
- This function may only be called from the main thread.
- See also
- Key input
- Since
- Added in GLFW 1.0.
- GLFW 3: Added window handle parameter.
This function sets the character callback of the specified window, which is called when a Unicode character is input.
The character callback is intended for Unicode text input. As it deals with characters, it is keyboard layout dependent, whereas the key callback is not. Characters do not map 1:1 to physical keys, as a key may produce zero, one or more characters. If you want to know whether a specific physical key was pressed or released, see the key callback instead.
The character callback behaves as system text input normally does and will not be called if modifier keys are held down that would prevent normal text input on that platform, for example a Super (Command) key on OS X or Alt key on Windows. There is a character with modifiers callback that receives these events.
- Parameters
-
[in] | window | The window whose callback to set. |
[in] | cbfun | The new callback, or NULL to remove the currently set callback. |
- Returns
- The previously set callback, or
NULL
if no callback was set or the library had not been initialized.
- Thread Safety
- This function may only be called from the main thread.
- See also
- Text input
- Since
- Added in GLFW 2.4.
- GLFW 3: Added window handle parameter. Updated callback signature.
This function sets the character with modifiers callback of the specified window, which is called when a Unicode character is input regardless of what modifier keys are used.
The character with modifiers callback is intended for implementing custom Unicode character input. For regular Unicode text input, see the character callback. Like the character callback, the character with modifiers callback deals with characters and is keyboard layout dependent. Characters do not map 1:1 to physical keys, as a key may produce zero, one or more characters. If you want to know whether a specific physical key was pressed or released, see the key callback instead.
- Parameters
-
[in] | window | The window whose callback to set. |
[in] | cbfun | The new callback, or NULL to remove the currently set callback. |
- Returns
- The previously set callback, or
NULL
if no callback was set or an error occurred.
- Thread Safety
- This function may only be called from the main thread.
- See also
- Text input
- Since
- Added in GLFW 3.1.
void glfwSetCursorPos |
( |
GLFWwindow * |
window, |
|
|
double |
xpos, |
|
|
double |
ypos |
|
) |
| |
This function sets the position, in screen coordinates, of the cursor relative to the upper-left corner of the client area of the specified window. The window must have input focus. If the window does not have input focus when this function is called, it fails silently.
Do not use this function to implement things like camera controls. GLFW already provides the GLFW_CURSOR_DISABLED
cursor mode that hides the cursor, transparently re-centers it and provides unconstrained cursor motion. See glfwSetInputMode for more information.
If the cursor mode is GLFW_CURSOR_DISABLED
then the cursor position is unconstrained and limited only by the minimum and maximum values of a double
.
- Parameters
-
[in] | window | The desired window. |
[in] | xpos | The desired x-coordinate, relative to the left edge of the client area. |
[in] | ypos | The desired y-coordinate, relative to the top edge of the client area. |
- Thread Safety
- This function may only be called from the main thread.
- See also
- Cursor position
-
glfwGetCursorPos
- Since
- Added in GLFW 3.0. Replaces
glfwSetMousePos
.
void glfwSetInputMode |
( |
GLFWwindow * |
window, |
|
|
int |
mode, |
|
|
int |
value |
|
) |
| |
This function sets an input mode option for the specified window. The mode must be one of GLFW_CURSOR
, GLFW_STICKY_KEYS
or GLFW_STICKY_MOUSE_BUTTONS
.
If the mode is GLFW_CURSOR
, the value must be one of the following cursor modes:
GLFW_CURSOR_NORMAL
makes the cursor visible and behaving normally.
GLFW_CURSOR_HIDDEN
makes the cursor invisible when it is over the client area of the window but does not restrict the cursor from leaving.
GLFW_CURSOR_DISABLED
hides and grabs the cursor, providing virtual and unlimited cursor movement. This is useful for implementing for example 3D camera controls.
If the mode is GLFW_STICKY_KEYS
, the value must be either GL_TRUE
to enable sticky keys, or GL_FALSE
to disable it. If sticky keys are enabled, a key press will ensure that glfwGetKey returns GLFW_PRESS
the next time it is called even if the key had been released before the call. This is useful when you are only interested in whether keys have been pressed but not when or in which order.
If the mode is GLFW_STICKY_MOUSE_BUTTONS
, the value must be either GL_TRUE
to enable sticky mouse buttons, or GL_FALSE
to disable it. If sticky mouse buttons are enabled, a mouse button press will ensure that glfwGetMouseButton returns GLFW_PRESS
the next time it is called even if the mouse button had been released before the call. This is useful when you are only interested in whether mouse buttons have been pressed but not when or in which order.
- Parameters
-
[in] | window | The window whose input mode to set. |
[in] | mode | One of GLFW_CURSOR , GLFW_STICKY_KEYS or GLFW_STICKY_MOUSE_BUTTONS . |
[in] | value | The new value of the specified input mode. |
- Thread Safety
- This function may only be called from the main thread.
- See also
- glfwGetInputMode
- Since
- Added in GLFW 3.0. Replaces
glfwEnable
and glfwDisable
.
This function sets the key callback of the specified window, which is called when a key is pressed, repeated or released.
The key functions deal with physical keys, with layout independent key tokens named after their values in the standard US keyboard layout. If you want to input text, use the character callback instead.
When a window loses input focus, it will generate synthetic key release events for all pressed keys. You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the window focus callback has been called.
The scancode of a key is specific to that platform or sometimes even to that machine. Scancodes are intended to allow users to bind keys that don't have a GLFW key token. Such keys have key
set to GLFW_KEY_UNKNOWN
, their state is not saved and so it cannot be queried with glfwGetKey.
Sometimes GLFW needs to generate synthetic key events, in which case the scancode may be zero.
- Parameters
-
[in] | window | The window whose callback to set. |
[in] | cbfun | The new key callback, or NULL to remove the currently set callback. |
- Returns
- The previously set callback, or
NULL
if no callback was set or the library had not been initialized.
- Thread Safety
- This function may only be called from the main thread.
- See also
- Key input
- Since
- Added in GLFW 1.0.
- GLFW 3: Added window handle parameter. Updated callback signature.