mirror of
https://github.com/glfw/glfw.git
synced 2026-08-29 03:04:14 +02:00
Add GLFW_RAW_INPUT and glfwRawInputSupported
This adds runtime per-window control of whether accelerated or raw mouse motion is provided when the cursor is disabled. Fixes #1400. Closes #1401.
This commit is contained in:
committed by
Camilla Löwy
parent
5f9cbd0ebc
commit
9e29f556fd
@@ -1002,6 +1002,7 @@ extern "C" {
|
||||
#define GLFW_STICKY_KEYS 0x00033002
|
||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
|
||||
#define GLFW_LOCK_KEY_MODS 0x00033004
|
||||
#define GLFW_RAW_INPUT 0x00033005
|
||||
|
||||
#define GLFW_CURSOR_NORMAL 0x00034001
|
||||
#define GLFW_CURSOR_HIDDEN 0x00034002
|
||||
@@ -3812,11 +3813,12 @@ GLFWAPI void glfwPostEmptyEvent(void);
|
||||
*
|
||||
* This function returns the value of an input option for the specified window.
|
||||
* The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
|
||||
* @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
|
||||
* @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
|
||||
* @ref GLFW_RAW_INPUT.
|
||||
*
|
||||
* @param[in] window The window to query.
|
||||
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
|
||||
* `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
|
||||
* `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or `GLFW_RAW_INPUT`.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_INVALID_ENUM.
|
||||
@@ -3835,7 +3837,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
||||
*
|
||||
* This function sets an input mode option for the specified window. The mode
|
||||
* must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
|
||||
* @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
|
||||
* @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
|
||||
* @ref GLFW_RAW_INPUT.
|
||||
*
|
||||
* If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
|
||||
* modes:
|
||||
@@ -3867,9 +3870,14 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
||||
* GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
|
||||
* and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
|
||||
*
|
||||
* If the mode is `GLFW_RAW_INPUT`, the value must be either `GLFW_TRUE` to
|
||||
* enable the use of raw input, or `GLFW_FALSE` to disable it. If enabled and
|
||||
* supported by the machine, the program will retrieve high-definition mouse
|
||||
* movement when cursor is grabbed.
|
||||
*
|
||||
* @param[in] window The window whose input mode to set.
|
||||
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
|
||||
* `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
|
||||
* `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or `GLFW_RAW_INPUT`.
|
||||
* @param[in] value The new value of the specified input mode.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
@@ -3885,6 +3893,38 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
||||
*/
|
||||
GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
|
||||
|
||||
/*! @brief Returns whether the raw input is supported.
|
||||
*
|
||||
* This function returns whether the raw input is supported by the current
|
||||
* machine.
|
||||
*
|
||||
* Raw input allow to retrieve high-definition movement from mouse.
|
||||
* Input from a high-definition mouse is much more precise than that from a
|
||||
* standard mouse. But often, they cannot be obtained through standard
|
||||
* platforms API which transform mouse movement using their own improvements
|
||||
* (like pointer acceleration). Platform's improvements are ideal for pointer
|
||||
* control but it is not so good for moving a first-person camera. For this
|
||||
* reason when the cursor of a window is grabbed by setting @ref GLFW_CURSOR
|
||||
* to @ref GLFW_CURSOR_DISABLED, raw input is used.
|
||||
*
|
||||
* The use of raw input can be disabled using @ref glfwSetInputMode with
|
||||
* @ref GLFW_RAW_INPUT mode.
|
||||
*
|
||||
* @return `GLFW_TRUE` if high-definition mouse movement is supported, or
|
||||
* `GLFW_FALSE` otherwise.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread.
|
||||
*
|
||||
* @sa @ref glfwSetInputMode
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
GLFWAPI int glfwRawInputSupported(void);
|
||||
|
||||
/*! @brief Returns the layout-specific name of the specified printable key.
|
||||
*
|
||||
* This function returns the name of the specified printable key, encoded as
|
||||
|
||||
Reference in New Issue
Block a user