From fba8184491e0b7ae6fab7ac01b4600d230dc4569 Mon Sep 17 00:00:00 2001 From: marsunet Date: Tue, 21 Dec 2021 17:04:22 -0800 Subject: Initial commit with window demo. --- .../docs/html/group__input.html | 2227 ++++++++++++++++++++ 1 file changed, 2227 insertions(+) create mode 100644 contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/group__input.html (limited to 'contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/group__input.html') diff --git a/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/group__input.html b/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/group__input.html new file mode 100644 index 0000000..0df94a6 --- /dev/null +++ b/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/group__input.html @@ -0,0 +1,2227 @@ + + + + + + + +GLFW: Input reference + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+ + +
+ +
+ +
+ +
Input reference
+
+
+

Description

+

This is the reference documentation for input related functions and types. For more task-oriented information, see the Input guide.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +

+Modules

 Gamepad axes
 Gamepad axes.
 
 Gamepad buttons
 Gamepad buttons.
 
 Joystick hat states
 Joystick hat states.
 
 Joysticks
 Joystick IDs.
 
 Keyboard keys
 Keyboard key IDs.
 
 Modifier key flags
 Modifier key flags.
 
 Mouse buttons
 Mouse button IDs.
 
 Standard cursor shapes
 Standard system cursor shapes.
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Typedefs

typedef struct GLFWcursor GLFWcursor
 Opaque cursor object. More...
 
typedef void(* GLFWmousebuttonfun) (GLFWwindow *window, int button, int action, int mods)
 The function pointer type for mouse button callbacks. More...
 
typedef void(* GLFWcursorposfun) (GLFWwindow *window, double xpos, double ypos)
 The function pointer type for cursor position callbacks. More...
 
typedef void(* GLFWcursorenterfun) (GLFWwindow *window, int entered)
 The function pointer type for cursor enter/leave callbacks. More...
 
typedef void(* GLFWscrollfun) (GLFWwindow *window, double xoffset, double yoffset)
 The function pointer type for scroll callbacks. More...
 
typedef void(* GLFWkeyfun) (GLFWwindow *window, int key, int scancode, int action, int mods)
 The function pointer type for keyboard key callbacks. More...
 
typedef void(* GLFWcharfun) (GLFWwindow *window, unsigned int codepoint)
 The function pointer type for Unicode character callbacks. More...
 
typedef void(* GLFWcharmodsfun) (GLFWwindow *window, unsigned int codepoint, int mods)
 The function pointer type for Unicode character with modifiers callbacks. More...
 
typedef void(* GLFWdropfun) (GLFWwindow *window, int path_count, const char *paths[])
 The function pointer type for path drop callbacks. More...
 
typedef void(* GLFWjoystickfun) (int jid, int event)
 The function pointer type for joystick configuration callbacks. More...
 
typedef struct GLFWgamepadstate GLFWgamepadstate
 Gamepad input state. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

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 glfwRawMouseMotionSupported (void)
 Returns whether raw mouse motion is supported. More...
 
const char * glfwGetKeyName (int key, int scancode)
 Returns the layout-specific name of the specified printable key. More...
 
int glfwGetKeyScancode (int key)
 Returns the platform-specific scancode of the specified key. 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 content area of the window. More...
 
void glfwSetCursorPos (GLFWwindow *window, double xpos, double ypos)
 Sets the position of the cursor, relative to the content area of the window. More...
 
GLFWcursorglfwCreateCursor (const GLFWimage *image, int xhot, int yhot)
 Creates a custom cursor. More...
 
GLFWcursorglfwCreateStandardCursor (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 callback)
 Sets the key callback. More...
 
GLFWcharfun glfwSetCharCallback (GLFWwindow *window, GLFWcharfun callback)
 Sets the Unicode character callback. More...
 
GLFWcharmodsfun glfwSetCharModsCallback (GLFWwindow *window, GLFWcharmodsfun callback)
 Sets the Unicode character with modifiers callback. More...
 
GLFWmousebuttonfun glfwSetMouseButtonCallback (GLFWwindow *window, GLFWmousebuttonfun callback)
 Sets the mouse button callback. More...
 
GLFWcursorposfun glfwSetCursorPosCallback (GLFWwindow *window, GLFWcursorposfun callback)
 Sets the cursor position callback. More...
 
GLFWcursorenterfun glfwSetCursorEnterCallback (GLFWwindow *window, GLFWcursorenterfun callback)
 Sets the cursor enter/leave callback. More...
 
GLFWscrollfun glfwSetScrollCallback (GLFWwindow *window, GLFWscrollfun callback)
 Sets the scroll callback. More...
 
GLFWdropfun glfwSetDropCallback (GLFWwindow *window, GLFWdropfun callback)
 Sets the path drop callback. More...
 
int glfwJoystickPresent (int jid)
 Returns whether the specified joystick is present. More...
 
const float * glfwGetJoystickAxes (int jid, int *count)
 Returns the values of all axes of the specified joystick. More...
 
const unsigned char * glfwGetJoystickButtons (int jid, int *count)
 Returns the state of all buttons of the specified joystick. More...
 
const unsigned char * glfwGetJoystickHats (int jid, int *count)
 Returns the state of all hats of the specified joystick. More...
 
const char * glfwGetJoystickName (int jid)
 Returns the name of the specified joystick. More...
 
const char * glfwGetJoystickGUID (int jid)
 Returns the SDL compatible GUID of the specified joystick. More...
 
void glfwSetJoystickUserPointer (int jid, void *pointer)
 Sets the user pointer of the specified joystick. More...
 
void * glfwGetJoystickUserPointer (int jid)
 Returns the user pointer of the specified joystick. More...
 
int glfwJoystickIsGamepad (int jid)
 Returns whether the specified joystick has a gamepad mapping. More...
 
GLFWjoystickfun glfwSetJoystickCallback (GLFWjoystickfun callback)
 Sets the joystick configuration callback. More...
 
int glfwUpdateGamepadMappings (const char *string)
 Adds the specified SDL_GameControllerDB gamepad mappings. More...
 
const char * glfwGetGamepadName (int jid)
 Returns the human-readable gamepad name for the specified joystick. More...
 
int glfwGetGamepadState (int jid, GLFWgamepadstate *state)
 Retrieves the state of the specified joystick remapped as a gamepad. 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 GLFW time. More...
 
void glfwSetTime (double time)
 Sets the GLFW time. More...
 
uint64_t glfwGetTimerValue (void)
 Returns the current value of the raw timer. More...
 
uint64_t glfwGetTimerFrequency (void)
 Returns the frequency, in Hz, of the raw timer. More...
 
+

Macro Definition Documentation

+ +

◆ GLFW_RELEASE

+ +
+
+ + + + +
#define GLFW_RELEASE   0
+
+

The key or mouse button was released.

+ +
+
+ +

◆ GLFW_PRESS

+ +
+
+ + + + +
#define GLFW_PRESS   1
+
+

The key or mouse button was pressed.

+ +
+
+ +

◆ GLFW_REPEAT

+ +
+
+ + + + +
#define GLFW_REPEAT   2
+
+

The key was held down until it repeated.

+ +
+
+

Typedef Documentation

+ +

◆ GLFWcursor

+ +
+
+ + + + +
typedef struct GLFWcursor GLFWcursor
+
+

Opaque cursor object.

+
See also
Cursor objects
+
Since
Added in version 3.1.
+ +
+
+ +

◆ GLFWmousebuttonfun

+ +
+
+ + + + +
typedef void(* GLFWmousebuttonfun) (GLFWwindow *window, int button, int action, int mods)
+
+

This is the function pointer type for mouse button callback functions. A mouse button callback function has the following signature:

void function_name(GLFWwindow* window, int button, int action, int mods)
+
struct GLFWwindow GLFWwindow
Opaque window object.
Definition: glfw3.h:1186
+
Parameters
+ + + + + +
[in]windowThe window that received the event.
[in]buttonThe mouse button that was pressed or released.
[in]actionOne of GLFW_PRESS or GLFW_RELEASE. Future releases may add more actions.
[in]modsBit field describing which modifier keys were held down.
+
+
+
See also
Mouse button input
+
+glfwSetMouseButtonCallback
+
Since
Added in version 1.0. GLFW 3: Added window handle and modifier mask parameters.
+ +
+
+ +

◆ GLFWcursorposfun

+ +
+
+ + + + +
typedef void(* GLFWcursorposfun) (GLFWwindow *window, double xpos, double ypos)
+
+

This is the function pointer type for cursor position callbacks. A cursor position callback function has the following signature:

void function_name(GLFWwindow* window, double xpos, double ypos);
+
Parameters
+ + + + +
[in]windowThe window that received the event.
[in]xposThe new cursor x-coordinate, relative to the left edge of the content area.
[in]yposThe new cursor y-coordinate, relative to the top edge of the content area.
+
+
+
See also
Cursor position
+
+glfwSetCursorPosCallback
+
Since
Added in version 3.0. Replaces GLFWmouseposfun.
+ +
+
+ +

◆ GLFWcursorenterfun

+ +
+
+ + + + +
typedef void(* GLFWcursorenterfun) (GLFWwindow *window, int entered)
+
+

This is the function pointer type for cursor enter/leave callbacks. A cursor enter/leave callback function has the following signature:

void function_name(GLFWwindow* window, int entered)
+
Parameters
+ + + +
[in]windowThe window that received the event.
[in]enteredGLFW_TRUE if the cursor entered the window's content area, or GLFW_FALSE if it left it.
+
+
+
See also
Cursor enter/leave events
+
+glfwSetCursorEnterCallback
+
Since
Added in version 3.0.
+ +
+
+ +

◆ GLFWscrollfun

+ +
+
+ + + + +
typedef void(* GLFWscrollfun) (GLFWwindow *window, double xoffset, double yoffset)
+
+

This is the function pointer type for scroll callbacks. A scroll callback function has the following signature:

void function_name(GLFWwindow* window, double xoffset, double yoffset)
+
Parameters
+ + + + +
[in]windowThe window that received the event.
[in]xoffsetThe scroll offset along the x-axis.
[in]yoffsetThe scroll offset along the y-axis.
+
+
+
See also
Scroll input
+
+glfwSetScrollCallback
+
Since
Added in version 3.0. Replaces GLFWmousewheelfun.
+ +
+
+ +

◆ GLFWkeyfun

+ +
+
+ + + + +
typedef void(* GLFWkeyfun) (GLFWwindow *window, int key, int scancode, int action, int mods)
+
+

This is the function pointer type for keyboard key callbacks. A keyboard key callback function has the following signature:

void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
+
Parameters
+ + + + + + +
[in]windowThe window that received the event.
[in]keyThe keyboard key that was pressed or released.
[in]scancodeThe system-specific scancode of the key.
[in]actionGLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT. Future releases may add more actions.
[in]modsBit field describing which modifier keys were held down.
+
+
+
See also
Key input
+
+glfwSetKeyCallback
+
Since
Added in version 1.0. GLFW 3: Added window handle, scancode and modifier mask parameters.
+ +
+
+ +

◆ GLFWcharfun

+ +
+
+ + + + +
typedef void(* GLFWcharfun) (GLFWwindow *window, unsigned int codepoint)
+
+

This is the function pointer type for Unicode character callbacks. A Unicode character callback function has the following signature:

void function_name(GLFWwindow* window, unsigned int codepoint)
+
Parameters
+ + + +
[in]windowThe window that received the event.
[in]codepointThe Unicode code point of the character.
+
+
+
See also
Text input
+
+glfwSetCharCallback
+
Since
Added in version 2.4. GLFW 3: Added window handle parameter.
+ +
+
+ +

◆ GLFWcharmodsfun

+ +
+
+ + + + +
typedef void(* GLFWcharmodsfun) (GLFWwindow *window, unsigned int codepoint, int mods)
+
+

This is the function pointer type for Unicode character with modifiers callbacks. It is called for each input character, regardless of what modifier keys are held down. A Unicode character with modifiers callback function has the following signature:

void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
+
Parameters
+ + + + +
[in]windowThe window that received the event.
[in]codepointThe Unicode code point of the character.
[in]modsBit field describing which modifier keys were held down.
+
+
+
See also
Text input
+
+glfwSetCharModsCallback
+
Deprecated:
Scheduled for removal in version 4.0.
+
Since
Added in version 3.1.
+ +
+
+ +

◆ GLFWdropfun

+ +
+
+ + + + +
typedef void(* GLFWdropfun) (GLFWwindow *window, int path_count, const char *paths[])
+
+

This is the function pointer type for path drop callbacks. A path drop callback function has the following signature:

void function_name(GLFWwindow* window, int path_count, const char* paths[])
+
Parameters
+ + + + +
[in]windowThe window that received the event.
[in]path_countThe number of dropped paths.
[in]pathsThe UTF-8 encoded file and/or directory path names.
+
+
+
Pointer lifetime
The path array and its strings are valid until the callback function returns.
+
See also
Path drop input
+
+glfwSetDropCallback
+
Since
Added in version 3.1.
+ +
+
+ +

◆ GLFWjoystickfun

+ +
+
+ + + + +
typedef void(* GLFWjoystickfun) (int jid, int event)
+
+

This is the function pointer type for joystick configuration callbacks. A joystick configuration callback function has the following signature:

void function_name(int jid, int event)
+
Parameters
+ + + +
[in]jidThe joystick that was connected or disconnected.
[in]eventOne of GLFW_CONNECTED or GLFW_DISCONNECTED. Future releases may add more events.
+
+
+
See also
Joystick configuration changes
+
+glfwSetJoystickCallback
+
Since
Added in version 3.2.
+ +
+
+ +

◆ GLFWgamepadstate

+ +
+
+ + + + +
typedef struct GLFWgamepadstate GLFWgamepadstate
+
+

This describes the input state of a gamepad.

+
See also
Gamepad input
+
+glfwGetGamepadState
+
Since
Added in version 3.3.
+ +
+
+

Function Documentation

+ +

◆ glfwGetInputMode()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int glfwGetInputMode (GLFWwindowwindow,
int mode 
)
+
+

This function returns the value of an input option for the specified window. The mode must be one of GLFW_CURSOR, GLFW_STICKY_KEYS, GLFW_STICKY_MOUSE_BUTTONS, GLFW_LOCK_KEY_MODS or GLFW_RAW_MOUSE_MOTION.

+
Parameters
+ + + +
[in]windowThe window to query.
[in]modeOne of GLFW_CURSOR, GLFW_STICKY_KEYS, GLFW_STICKY_MOUSE_BUTTONS, GLFW_LOCK_KEY_MODS or GLFW_RAW_MOUSE_MOTION.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_ENUM.
+
Thread safety
This function must only be called from the main thread.
+
See also
glfwSetInputMode
+
Since
Added in version 3.0.
+ +
+
+ +

◆ glfwSetInputMode()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void glfwSetInputMode (GLFWwindowwindow,
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, GLFW_STICKY_MOUSE_BUTTONS, GLFW_LOCK_KEY_MODS or GLFW_RAW_MOUSE_MOTION.

+

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 content 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 GLFW_TRUE to enable sticky keys, or GLFW_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 GLFW_TRUE to enable sticky mouse buttons, or GLFW_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.

+

If the mode is GLFW_LOCK_KEY_MODS, the value must be either GLFW_TRUE to enable lock key modifier bits, or GLFW_FALSE to disable them. If enabled, callbacks that receive modifier bits will also have the GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on, and the GLFW_MOD_NUM_LOCK bit when Num Lock was on.

+

If the mode is GLFW_RAW_MOUSE_MOTION, the value must be either GLFW_TRUE to enable raw (unscaled and unaccelerated) mouse motion when the cursor is disabled, or GLFW_FALSE to disable it. If raw motion is not supported, attempting to set this will emit GLFW_PLATFORM_ERROR. Call glfwRawMouseMotionSupported to check for support.

+
Parameters
+ + + + +
[in]windowThe window whose input mode to set.
[in]modeOne of GLFW_CURSOR, GLFW_STICKY_KEYS, GLFW_STICKY_MOUSE_BUTTONS, GLFW_LOCK_KEY_MODS or GLFW_RAW_MOUSE_MOTION.
[in]valueThe new value of the specified input mode.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Thread safety
This function must only be called from the main thread.
+
See also
glfwGetInputMode
+
Since
Added in version 3.0. Replaces glfwEnable and glfwDisable.
+ +
+
+ +

◆ glfwRawMouseMotionSupported()

+ +
+
+ + + + + + + + +
int glfwRawMouseMotionSupported (void )
+
+

This function returns whether raw mouse motion is supported on the current system. This status does not change after GLFW has been initialized so you only need to check this once. If you attempt to enable raw motion on a system that does not support it, GLFW_PLATFORM_ERROR will be emitted.

+

Raw mouse motion is closer to the actual motion of the mouse across a surface. It is not affected by the scaling and acceleration applied to the motion of the desktop cursor. That processing is suitable for a cursor while raw motion is better for controlling for example a 3D camera. Because of this, raw mouse motion is only provided when the cursor is disabled.

+
Returns
GLFW_TRUE if raw mouse motion is supported on the current machine, or GLFW_FALSE otherwise.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Raw mouse motion
+
+glfwSetInputMode
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwGetKeyName()

+ +
+
+ + + + + + + + + + + + + + + + + + +
const char * glfwGetKeyName (int key,
int scancode 
)
+
+

This function returns the name of the specified printable key, encoded as UTF-8. This is typically the character that key would produce without any modifier keys, intended for displaying key bindings to the user. For dead keys, it is typically the diacritic it would add to a character.

+

Do not use this function for text input. You will break text input for many languages even if it happens to work for yours.

+

If the key is GLFW_KEY_UNKNOWN, the scancode is used to identify the key, otherwise the scancode is ignored. If you specify a non-printable key, or GLFW_KEY_UNKNOWN and a scancode that maps to a non-printable key, this function returns NULL but does not emit an error.

+

This behavior allows you to always pass in the arguments in the key callback without modification.

+

The printable keys are:

    +
  • GLFW_KEY_APOSTROPHE
  • +
  • GLFW_KEY_COMMA
  • +
  • GLFW_KEY_MINUS
  • +
  • GLFW_KEY_PERIOD
  • +
  • GLFW_KEY_SLASH
  • +
  • GLFW_KEY_SEMICOLON
  • +
  • GLFW_KEY_EQUAL
  • +
  • GLFW_KEY_LEFT_BRACKET
  • +
  • GLFW_KEY_RIGHT_BRACKET
  • +
  • GLFW_KEY_BACKSLASH
  • +
  • GLFW_KEY_WORLD_1
  • +
  • GLFW_KEY_WORLD_2
  • +
  • GLFW_KEY_0 to GLFW_KEY_9
  • +
  • GLFW_KEY_A to GLFW_KEY_Z
  • +
  • GLFW_KEY_KP_0 to GLFW_KEY_KP_9
  • +
  • GLFW_KEY_KP_DECIMAL
  • +
  • GLFW_KEY_KP_DIVIDE
  • +
  • GLFW_KEY_KP_MULTIPLY
  • +
  • GLFW_KEY_KP_SUBTRACT
  • +
  • GLFW_KEY_KP_ADD
  • +
  • GLFW_KEY_KP_EQUAL
  • +
+

Names for printable keys depend on keyboard layout, while names for non-printable keys are the same across layouts but depend on the application language and should be localized along with other user interface text.

+
Parameters
+ + + +
[in]keyThe key to query, or GLFW_KEY_UNKNOWN.
[in]scancodeThe scancode of the key to query.
+
+
+
Returns
The UTF-8 encoded, layout-specific name of the key, or NULL.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Remarks
The contents of the returned string may change when a keyboard layout change event is received.
+
Pointer lifetime
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Key names
+
Since
Added in version 3.2.
+ +
+
+ +

◆ glfwGetKeyScancode()

+ +
+
+ + + + + + + + +
int glfwGetKeyScancode (int key)
+
+

This function returns the platform-specific scancode of the specified key.

+

If the key is GLFW_KEY_UNKNOWN or does not exist on the keyboard this method will return -1.

+
Parameters
+ + +
[in]keyAny named key.
+
+
+
Returns
The platform-specific scancode for the key, or -1 if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Thread safety
This function may be called from any thread.
+
See also
Key input
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwGetKey()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int glfwGetKey (GLFWwindowwindow,
int key 
)
+
+

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.

+

Do not use this function to implement text input.

+
Parameters
+ + + +
[in]windowThe desired window.
[in]keyThe desired keyboard key. GLFW_KEY_UNKNOWN is not a valid key for this function.
+
+
+
Returns
One of GLFW_PRESS or GLFW_RELEASE.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_ENUM.
+
Thread safety
This function must only be called from the main thread.
+
See also
Key input
+
Since
Added in version 1.0. GLFW 3: Added window handle parameter.
+ +
+
+ +

◆ glfwGetMouseButton()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int glfwGetMouseButton (GLFWwindowwindow,
int button 
)
+
+

This function returns the last state reported for the specified mouse button to the specified window. The returned state is one of GLFW_PRESS or GLFW_RELEASE.

+

If the GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function returns GLFW_PRESS the first time you call it for a mouse button that was pressed, even if that mouse button has already been released.

+
Parameters
+ + + +
[in]windowThe desired window.
[in]buttonThe desired mouse button.
+
+
+
Returns
One of GLFW_PRESS or GLFW_RELEASE.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_ENUM.
+
Thread safety
This function must only be called from the main thread.
+
See also
Mouse button input
+
Since
Added in version 1.0. GLFW 3: Added window handle parameter.
+ +
+
+ +

◆ glfwGetCursorPos()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void glfwGetCursorPos (GLFWwindowwindow,
double * xpos,
double * ypos 
)
+
+

This function returns the position of the cursor, in screen coordinates, relative to the upper-left corner of the content 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]windowThe desired window.
[out]xposWhere to store the cursor x-coordinate, relative to the left edge of the content area, or NULL.
[out]yposWhere to store the cursor y-coordinate, relative to the to top edge of the content area, or NULL.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor position
+
+glfwSetCursorPos
+
Since
Added in version 3.0. Replaces glfwGetMousePos.
+ +
+
+ +

◆ glfwSetCursorPos()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void glfwSetCursorPos (GLFWwindowwindow,
double xpos,
double ypos 
)
+
+

This function sets the position, in screen coordinates, of the cursor relative to the upper-left corner of the content 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]windowThe desired window.
[in]xposThe desired x-coordinate, relative to the left edge of the content area.
[in]yposThe desired y-coordinate, relative to the top edge of the content area.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Remarks
Wayland: This function will only work when the cursor mode is GLFW_CURSOR_DISABLED, otherwise it will do nothing.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor position
+
+glfwGetCursorPos
+
Since
Added in version 3.0. Replaces glfwSetMousePos.
+ +
+
+ +

◆ glfwCreateCursor()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
GLFWcursor * glfwCreateCursor (const GLFWimageimage,
int xhot,
int yhot 
)
+
+

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 with the red channel first. 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]imageThe desired cursor image.
[in]xhotThe desired x-coordinate, in pixels, of the cursor hotspot.
[in]yhotThe desired y-coordinate, in pixels, of the cursor hotspot.
+
+
+
Returns
The handle of the created cursor, or NULL if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The specified image data is copied before this function returns.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor objects
+
+glfwDestroyCursor
+
+glfwCreateStandardCursor
+
Since
Added in version 3.1.
+ +
+
+ +

◆ glfwCreateStandardCursor()

+ +
+
+ + + + + + + + +
GLFWcursor * glfwCreateStandardCursor (int shape)
+
+

Returns a cursor with a standard shape, that can be set for a window with glfwSetCursor.

+
Parameters
+ + +
[in]shapeOne of the standard shapes.
+
+
+
Returns
A new cursor ready to use or NULL if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor objects
+
+glfwCreateCursor
+
Since
Added in version 3.1.
+ +
+
+ +

◆ glfwDestroyCursor()

+ +
+
+ + + + + + + + +
void glfwDestroyCursor (GLFWcursorcursor)
+
+

This function destroys a cursor previously created with glfwCreateCursor. Any remaining cursors will be destroyed by glfwTerminate.

+

If the specified cursor is current for any window, that window will be reverted to the default cursor. This does not affect the cursor mode.

+
Parameters
+ + +
[in]cursorThe cursor object to destroy.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Reentrancy
This function must not be called from a callback.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor objects
+
+glfwCreateCursor
+
Since
Added in version 3.1.
+ +
+
+ +

◆ glfwSetCursor()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void glfwSetCursor (GLFWwindowwindow,
GLFWcursorcursor 
)
+
+

This function sets the cursor image to be used when the cursor is over the content area of the specified window. The set cursor will only be visible when the cursor mode of the window is GLFW_CURSOR_NORMAL.

+

On some platforms, the set cursor may not be visible unless the window also has input focus.

+
Parameters
+ + + +
[in]windowThe window to set the cursor for.
[in]cursorThe cursor to set, or NULL to switch back to the default arrow cursor.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor objects
+
Since
Added in version 3.1.
+ +
+
+ +

◆ glfwSetKeyCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWkeyfun glfwSetKeyCallback (GLFWwindowwindow,
GLFWkeyfun callback 
)
+
+

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]windowThe window whose callback to set.
[in]callbackThe 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.
+
Callback signature
void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Key input
+
Since
Added in version 1.0. GLFW 3: Added window handle parameter and return value.
+ +
+
+ +

◆ glfwSetCharCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWcharfun glfwSetCharCallback (GLFWwindowwindow,
GLFWcharfun callback 
)
+
+

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 macOS or Alt key on Windows.

+
Parameters
+ + + +
[in]windowThe window whose callback to set.
[in]callbackThe 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.
+
Callback signature
void function_name(GLFWwindow* window, unsigned int codepoint)
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Text input
+
Since
Added in version 2.4. GLFW 3: Added window handle parameter and return value.
+ +
+
+ +

◆ glfwSetCharModsCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWcharmodsfun glfwSetCharModsCallback (GLFWwindowwindow,
GLFWcharmodsfun callback 
)
+
+

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]windowThe window whose callback to set.
[in]callbackThe 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.
+
Callback signature
void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
+
For more information about the callback parameters, see the function pointer type.
+
Deprecated:
Scheduled for removal in version 4.0.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Text input
+
Since
Added in version 3.1.
+ +
+
+ +

◆ glfwSetMouseButtonCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWmousebuttonfun glfwSetMouseButtonCallback (GLFWwindowwindow,
GLFWmousebuttonfun callback 
)
+
+

This function sets the mouse button callback of the specified window, which is called when a mouse button is pressed or released.

+

When a window loses input focus, it will generate synthetic mouse button release events for all pressed mouse buttons. 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.

+
Parameters
+ + + +
[in]windowThe window whose callback to set.
[in]callbackThe 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.
+
Callback signature
void function_name(GLFWwindow* window, int button, int action, int mods)
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Mouse button input
+
Since
Added in version 1.0. GLFW 3: Added window handle parameter and return value.
+ +
+
+ +

◆ glfwSetCursorPosCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWcursorposfun glfwSetCursorPosCallback (GLFWwindowwindow,
GLFWcursorposfun callback 
)
+
+

This function sets the cursor position callback of the specified window, which is called when the cursor is moved. The callback is provided with the position, in screen coordinates, relative to the upper-left corner of the content area of the window.

+
Parameters
+ + + +
[in]windowThe window whose callback to set.
[in]callbackThe 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.
+
Callback signature
void function_name(GLFWwindow* window, double xpos, double ypos);
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor position
+
Since
Added in version 3.0. Replaces glfwSetMousePosCallback.
+ +
+
+ +

◆ glfwSetCursorEnterCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWcursorenterfun glfwSetCursorEnterCallback (GLFWwindowwindow,
GLFWcursorenterfun callback 
)
+
+

This function sets the cursor boundary crossing callback of the specified window, which is called when the cursor enters or leaves the content area of the window.

+
Parameters
+ + + +
[in]windowThe window whose callback to set.
[in]callbackThe 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.
+
Callback signature
void function_name(GLFWwindow* window, int entered)
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Cursor enter/leave events
+
Since
Added in version 3.0.
+ +
+
+ +

◆ glfwSetScrollCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWscrollfun glfwSetScrollCallback (GLFWwindowwindow,
GLFWscrollfun callback 
)
+
+

This function sets the scroll callback of the specified window, which is called when a scrolling device is used, such as a mouse wheel or scrolling area of a touchpad.

+

The scroll callback receives all scrolling input, like that from a mouse wheel or a touchpad scrolling area.

+
Parameters
+ + + +
[in]windowThe window whose callback to set.
[in]callbackThe new scroll 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.
+
Callback signature
void function_name(GLFWwindow* window, double xoffset, double yoffset)
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Scroll input
+
Since
Added in version 3.0. Replaces glfwSetMouseWheelCallback.
+ +
+
+ +

◆ glfwSetDropCallback()

+ +
+
+ + + + + + + + + + + + + + + + + + +
GLFWdropfun glfwSetDropCallback (GLFWwindowwindow,
GLFWdropfun callback 
)
+
+

This function sets the path drop callback of the specified window, which is called when one or more dragged paths are dropped on the window.

+

Because the path array and its strings may have been generated specifically for that event, they are not guaranteed to be valid after the callback has returned. If you wish to use them after the callback returns, you need to make a deep copy.

+
Parameters
+ + + +
[in]windowThe window whose callback to set.
[in]callbackThe new file drop 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.
+
Callback signature
void function_name(GLFWwindow* window, int path_count, const char* paths[])
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Remarks
Wayland: File drop is currently unimplemented.
+
Thread safety
This function must only be called from the main thread.
+
See also
Path drop input
+
Since
Added in version 3.1.
+ +
+
+ +

◆ glfwJoystickPresent()

+ +
+
+ + + + + + + + +
int glfwJoystickPresent (int jid)
+
+

This function returns whether the specified joystick is present.

+

There is no need to call this function before other functions that accept a joystick ID, as they all check for presence before performing any other work.

+
Parameters
+ + +
[in]jidThe joystick to query.
+
+
+
Returns
GLFW_TRUE if the joystick is present, or GLFW_FALSE otherwise.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Thread safety
This function must only be called from the main thread.
+
See also
Joystick input
+
Since
Added in version 3.0. Replaces glfwGetJoystickParam.
+ +
+
+ +

◆ glfwGetJoystickAxes()

+ +
+
+ + + + + + + + + + + + + + + + + + +
const float * glfwGetJoystickAxes (int jid,
int * count 
)
+
+

This function returns the values of all axes of the specified joystick. Each element in the array is a value between -1.0 and 1.0.

+

If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling glfwJoystickPresent.

+
Parameters
+ + + +
[in]jidThe joystick to query.
[out]countWhere to store the number of axis values in the returned array. This is set to zero if the joystick is not present or an error occurred.
+
+
+
Returns
An array of axis values, or NULL if the joystick is not present or an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Joystick axis states
+
Since
Added in version 3.0. Replaces glfwGetJoystickPos.
+ +
+
+ +

◆ glfwGetJoystickButtons()

+ +
+
+ + + + + + + + + + + + + + + + + + +
const unsigned char * glfwGetJoystickButtons (int jid,
int * count 
)
+
+

This function returns the state of all buttons of the specified joystick. Each element in the array is either GLFW_PRESS or GLFW_RELEASE.

+

For backward compatibility with earlier versions that did not have glfwGetJoystickHats, the button array also includes all hats, each represented as four buttons. The hats are in the same order as returned by glfwGetJoystickHats and are in the order up, right, down and left. To disable these extra buttons, set the GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.

+

If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling glfwJoystickPresent.

+
Parameters
+ + + +
[in]jidThe joystick to query.
[out]countWhere to store the number of button states in the returned array. This is set to zero if the joystick is not present or an error occurred.
+
+
+
Returns
An array of button states, or NULL if the joystick is not present or an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Joystick button states
+
Since
Added in version 2.2. GLFW 3: Changed to return a dynamic array.
+ +
+
+ +

◆ glfwGetJoystickHats()

+ +
+
+ + + + + + + + + + + + + + + + + + +
const unsigned char * glfwGetJoystickHats (int jid,
int * count 
)
+
+

This function returns the state of all hats of the specified joystick. Each element in the array is one of the following values:

+ + + + + + + + + + + + + + + + + + + + + +
Name Value
GLFW_HAT_CENTERED 0
GLFW_HAT_UP 1
GLFW_HAT_RIGHT 2
GLFW_HAT_DOWN 4
GLFW_HAT_LEFT 8
GLFW_HAT_RIGHT_UP GLFW_HAT_RIGHT | GLFW_HAT_UP
GLFW_HAT_RIGHT_DOWN GLFW_HAT_RIGHT | GLFW_HAT_DOWN
GLFW_HAT_LEFT_UP GLFW_HAT_LEFT | GLFW_HAT_UP
GLFW_HAT_LEFT_DOWN GLFW_HAT_LEFT | GLFW_HAT_DOWN
+

The diagonal directions are bitwise combinations of the primary (up, right, down and left) directions and you can test for these individually by ANDing it with the corresponding direction.

+
if (hats[2] & GLFW_HAT_RIGHT)
+
{
+
// State of hat 2 could be right-up, right or right-down
+
}
+
#define GLFW_HAT_RIGHT
Definition: glfw3.h:358
+

If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling glfwJoystickPresent.

+
Parameters
+ + + +
[in]jidThe joystick to query.
[out]countWhere to store the number of hat states in the returned array. This is set to zero if the joystick is not present or an error occurred.
+
+
+
Returns
An array of hat states, or NULL if the joystick is not present or an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected, this function is called again for that joystick or the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Joystick hat states
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwGetJoystickName()

+ +
+
+ + + + + + + + +
const char * glfwGetJoystickName (int jid)
+
+

This function returns the name, encoded as UTF-8, of the specified joystick. The returned string is allocated and freed by GLFW. You should not free it yourself.

+

If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling glfwJoystickPresent.

+
Parameters
+ + +
[in]jidThe joystick to query.
+
+
+
Returns
The UTF-8 encoded name of the joystick, or NULL if the joystick is not present or an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Joystick name
+
Since
Added in version 3.0.
+ +
+
+ +

◆ glfwGetJoystickGUID()

+ +
+
+ + + + + + + + +
const char * glfwGetJoystickGUID (int jid)
+
+

This function returns the SDL compatible GUID, as a UTF-8 encoded hexadecimal string, of the specified joystick. The returned string is allocated and freed by GLFW. You should not free it yourself.

+

The GUID is what connects a joystick to a gamepad mapping. A connected joystick will always have a GUID even if there is no gamepad mapping assigned to it.

+

If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling glfwJoystickPresent.

+

The GUID uses the format introduced in SDL 2.0.5. This GUID tries to uniquely identify the make and model of a joystick but does not identify a specific unit, e.g. all wired Xbox 360 controllers will have the same GUID on that platform. The GUID for a unit may vary between platforms depending on what hardware information the platform specific APIs provide.

+
Parameters
+ + +
[in]jidThe joystick to query.
+
+
+
Returns
The UTF-8 encoded GUID of the joystick, or NULL if the joystick is not present or an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED, GLFW_INVALID_ENUM and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Gamepad input
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwSetJoystickUserPointer()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void glfwSetJoystickUserPointer (int jid,
void * pointer 
)
+
+

This function sets the user-defined pointer of the specified joystick. The current value is retained until the joystick is disconnected. The initial value is NULL.

+

This function may be called from the joystick callback, even for a joystick that is being disconnected.

+
Parameters
+ + + +
[in]jidThe joystick whose pointer to set.
[in]pointerThe new value.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function may be called from any thread. Access is not synchronized.
+
See also
Joystick user pointer
+
+glfwGetJoystickUserPointer
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwGetJoystickUserPointer()

+ +
+
+ + + + + + + + +
void * glfwGetJoystickUserPointer (int jid)
+
+

This function returns the current value of the user-defined pointer of the specified joystick. The initial value is NULL.

+

This function may be called from the joystick callback, even for a joystick that is being disconnected.

+
Parameters
+ + +
[in]jidThe joystick whose pointer to return.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function may be called from any thread. Access is not synchronized.
+
See also
Joystick user pointer
+
+glfwSetJoystickUserPointer
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwJoystickIsGamepad()

+ +
+
+ + + + + + + + +
int glfwJoystickIsGamepad (int jid)
+
+

This function returns whether the specified joystick is both present and has a gamepad mapping.

+

If the specified joystick is present but does not have a gamepad mapping this function will return GLFW_FALSE but will not generate an error. Call glfwJoystickPresent to check if a joystick is present regardless of whether it has a mapping.

+
Parameters
+ + +
[in]jidThe joystick to query.
+
+
+
Returns
GLFW_TRUE if a joystick is both present and has a gamepad mapping, or GLFW_FALSE otherwise.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_ENUM.
+
Thread safety
This function must only be called from the main thread.
+
See also
Gamepad input
+
+glfwGetGamepadState
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwSetJoystickCallback()

+ +
+
+ + + + + + + + +
GLFWjoystickfun glfwSetJoystickCallback (GLFWjoystickfun callback)
+
+

This function sets the joystick configuration callback, or removes the currently set callback. This is called when a joystick is connected to or disconnected from the system.

+

For joystick connection and disconnection events to be delivered on all platforms, you need to call one of the event processing functions. Joystick disconnection may also be detected and the callback called by joystick functions. The function will then return whatever it returns if the joystick is not present.

+
Parameters
+ + +
[in]callbackThe 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.
+
Callback signature
void function_name(int jid, int event)
+
For more information about the callback parameters, see the function pointer type.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function must only be called from the main thread.
+
See also
Joystick configuration changes
+
Since
Added in version 3.2.
+ +
+
+ +

◆ glfwUpdateGamepadMappings()

+ +
+
+ + + + + + + + +
int glfwUpdateGamepadMappings (const char * string)
+
+

This function parses the specified ASCII encoded string and updates the internal list with any gamepad mappings it finds. This string may contain either a single gamepad mapping or many mappings separated by newlines. The parser supports the full format of the gamecontrollerdb.txt source file including empty lines and comments.

+

See Gamepad mappings for a description of the format.

+

If there is already a gamepad mapping for a given GUID in the internal list, it will be replaced by the one passed to this function. If the library is terminated and re-initialized the internal list will revert to the built-in default.

+
Parameters
+ + +
[in]stringThe string containing the gamepad mappings.
+
+
+
Returns
GLFW_TRUE if successful, or GLFW_FALSE if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_VALUE.
+
Thread safety
This function must only be called from the main thread.
+
See also
Gamepad input
+
+glfwJoystickIsGamepad
+
+glfwGetGamepadName
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwGetGamepadName()

+ +
+
+ + + + + + + + +
const char * glfwGetGamepadName (int jid)
+
+

This function returns the human-readable name of the gamepad from the gamepad mapping assigned to the specified joystick.

+

If the specified joystick is not present or does not have a gamepad mapping this function will return NULL but will not generate an error. Call glfwJoystickPresent to check whether it is present regardless of whether it has a mapping.

+
Parameters
+ + +
[in]jidThe joystick to query.
+
+
+
Returns
The UTF-8 encoded name of the gamepad, or NULL if the joystick is not present, does not have a mapping or an error occurred.
+
Pointer lifetime
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected, the gamepad mappings are updated or the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Gamepad input
+
+glfwJoystickIsGamepad
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwGetGamepadState()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int glfwGetGamepadState (int jid,
GLFWgamepadstatestate 
)
+
+

This function retrieves the state of the specified joystick remapped to an Xbox-like gamepad.

+

If the specified joystick is not present or does not have a gamepad mapping this function will return GLFW_FALSE but will not generate an error. Call glfwJoystickPresent to check whether it is present regardless of whether it has a mapping.

+

The Guide button may not be available for input as it is often hooked by the system or the Steam client.

+

Not all devices have all the buttons or axes provided by GLFWgamepadstate. Unavailable buttons and axes will always report GLFW_RELEASE and 0.0 respectively.

+
Parameters
+ + + +
[in]jidThe joystick to query.
[out]stateThe gamepad input state of the joystick.
+
+
+
Returns
GLFW_TRUE if successful, or GLFW_FALSE if no joystick is connected, it has no gamepad mapping or an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_ENUM.
+
Thread safety
This function must only be called from the main thread.
+
See also
Gamepad input
+
+glfwUpdateGamepadMappings
+
+glfwJoystickIsGamepad
+
Since
Added in version 3.3.
+ +
+
+ +

◆ glfwSetClipboardString()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void glfwSetClipboardString (GLFWwindowwindow,
const char * string 
)
+
+

This function sets the system clipboard to the specified, UTF-8 encoded string.

+
Parameters
+ + + +
[in]windowDeprecated. Any valid window or NULL.
[in]stringA UTF-8 encoded string.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The specified string is copied before this function returns.
+
Thread safety
This function must only be called from the main thread.
+
See also
Clipboard input and output
+
+glfwGetClipboardString
+
Since
Added in version 3.0.
+ +
+
+ +

◆ glfwGetClipboardString()

+ +
+
+ + + + + + + + +
const char * glfwGetClipboardString (GLFWwindowwindow)
+
+

This function returns the contents of the system clipboard, if it contains or is convertible to a UTF-8 encoded string. If the clipboard is empty or if its contents cannot be converted, NULL is returned and a GLFW_FORMAT_UNAVAILABLE error is generated.

+
Parameters
+ + +
[in]windowDeprecated. Any valid window or NULL.
+
+
+
Returns
The contents of the clipboard as a UTF-8 encoded string, or NULL if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
+
Pointer lifetime
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the next call to glfwGetClipboardString or glfwSetClipboardString, or until the library is terminated.
+
Thread safety
This function must only be called from the main thread.
+
See also
Clipboard input and output
+
+glfwSetClipboardString
+
Since
Added in version 3.0.
+ +
+
+ +

◆ glfwGetTime()

+ +
+
+ + + + + + + + +
double glfwGetTime (void )
+
+

This function returns the current GLFW time, in seconds. Unless the time has been set using glfwSetTime it measures time elapsed since GLFW was initialized.

+

This function and glfwSetTime are helper functions on top of glfwGetTimerFrequency and glfwGetTimerValue.

+

The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds. It uses the highest-resolution monotonic time source on each supported platform.

+
Returns
The current time, in seconds, or zero if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function may be called from any thread. Reading and writing of the internal base time is not atomic, so it needs to be externally synchronized with calls to glfwSetTime.
+
See also
Time input
+
Since
Added in version 1.0.
+ +
+
+ +

◆ glfwSetTime()

+ +
+
+ + + + + + + + +
void glfwSetTime (double time)
+
+

This function sets the current GLFW time, in seconds. The value must be a positive finite number less than or equal to 18446744073.0, which is approximately 584.5 years.

+

This function and glfwGetTime are helper functions on top of glfwGetTimerFrequency and glfwGetTimerValue.

+
Parameters
+ + +
[in]timeThe new value, in seconds.
+
+
+
Errors
Possible errors include GLFW_NOT_INITIALIZED and GLFW_INVALID_VALUE.
+
Remarks
The upper limit of GLFW time is calculated as floor((264 - 1) / 109) and is due to implementations storing nanoseconds in 64 bits. The limit may be increased in the future.
+
Thread safety
This function may be called from any thread. Reading and writing of the internal base time is not atomic, so it needs to be externally synchronized with calls to glfwGetTime.
+
See also
Time input
+
Since
Added in version 2.2.
+ +
+
+ +

◆ glfwGetTimerValue()

+ +
+
+ + + + + + + + +
uint64_t glfwGetTimerValue (void )
+
+

This function returns the current value of the raw timer, measured in 1 / frequency seconds. To get the frequency, call glfwGetTimerFrequency.

+
Returns
The value of the timer, or zero if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function may be called from any thread.
+
See also
Time input
+
+glfwGetTimerFrequency
+
Since
Added in version 3.2.
+ +
+
+ +

◆ glfwGetTimerFrequency()

+ +
+
+ + + + + + + + +
uint64_t glfwGetTimerFrequency (void )
+
+

This function returns the frequency, in Hz, of the raw timer.

+
Returns
The frequency of the timer, in Hz, or zero if an error occurred.
+
Errors
Possible errors include GLFW_NOT_INITIALIZED.
+
Thread safety
This function may be called from any thread.
+
See also
Time input
+
+glfwGetTimerValue
+
Since
Added in version 3.2.
+ +
+
+
+ + + -- cgit v1.2.3