mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
Removed key repeat.
This commit is contained in:
parent
ef1da2dde9
commit
c479124e69
|
@ -359,8 +359,6 @@ int main(int argc, char *argv[])
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
reshape(window, width, height);
|
reshape(window, width, height);
|
||||||
|
|
||||||
glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE );
|
|
||||||
|
|
||||||
// Parse command-line options
|
// Parse command-line options
|
||||||
init(argc, argv);
|
init(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -419,8 +419,6 @@ int main(int argc, char* argv[])
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
window_size_callback(window, width, height);
|
window_size_callback(window, width, height);
|
||||||
|
|
||||||
glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE);
|
|
||||||
|
|
||||||
// Initialize OpenGL
|
// Initialize OpenGL
|
||||||
init_opengl();
|
init_opengl();
|
||||||
|
|
||||||
|
|
|
@ -605,11 +605,6 @@ extern "C" {
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
|
#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
|
||||||
/*! @brief Whether to allow key repeat for the @link GLFWkeyfun key callback
|
|
||||||
* @endlink.
|
|
||||||
* @ingroup input
|
|
||||||
*/
|
|
||||||
#define GLFW_KEY_REPEAT 0x00030004
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
/*! @name Cursor modes
|
/*! @name Cursor modes
|
||||||
|
@ -1272,7 +1267,6 @@ GLFWAPI void glfwWaitEvents(void);
|
||||||
* @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
|
* @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
|
||||||
* @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
|
* @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
|
||||||
* @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
|
* @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
|
||||||
* @arg @ref GLFW_KEY_REPEAT Sets whether key repeat is enabled.
|
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*
|
*
|
||||||
* @sa glfwSetInputMode
|
* @sa glfwSetInputMode
|
||||||
|
@ -1284,7 +1278,6 @@ GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode);
|
||||||
* @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
|
* @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
|
||||||
* @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
|
* @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
|
||||||
* @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
|
* @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
|
||||||
* @arg @ref GLFW_KEY_REPEAT Sets whether key repeat is enabled.
|
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*
|
*
|
||||||
* @sa glfwGetInputMode
|
* @sa glfwGetInputMode
|
||||||
|
|
|
@ -313,7 +313,7 @@ version of GLFW.</p>
|
||||||
<li>Replaced <code>glfwEnable</code> and <code>glfwDisable</code> with <code>glfwGetInputMode</code> and <code>glfwSetInputMode</code></li>
|
<li>Replaced <code>glfwEnable</code> and <code>glfwDisable</code> with <code>glfwGetInputMode</code> and <code>glfwSetInputMode</code></li>
|
||||||
<li>Replaced <code>joystick</code> test with graphical version</li>
|
<li>Replaced <code>joystick</code> test with graphical version</li>
|
||||||
<li>Replaced automatic closing of windows with <code>GLFW_CLOSE_REQUESTED</code> window parameter</li>
|
<li>Replaced automatic closing of windows with <code>GLFW_CLOSE_REQUESTED</code> window parameter</li>
|
||||||
<li>Made Unicode character input unaffected by <code>GLFW_KEY_REPEAT</code></li>
|
<li>Removed the <code>GLFW_KEY_REPEAT</code> input option</li>
|
||||||
<li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li>
|
<li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li>
|
||||||
<li>Removed the Win32 port .def files</li>
|
<li>Removed the Win32 port .def files</li>
|
||||||
<li>Removed the entire threading API</li>
|
<li>Removed the entire threading API</li>
|
||||||
|
|
17
src/input.c
17
src/input.c
|
@ -115,16 +115,6 @@ static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set key repeat for the specified window
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void setKeyRepeat(_GLFWwindow* window, int enabled)
|
|
||||||
{
|
|
||||||
window->keyRepeat = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -154,7 +144,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call user callback function
|
// Call user callback function
|
||||||
if (window->keyCallback && (window->keyRepeat || !repeated))
|
if (window->keyCallback && !repeated)
|
||||||
window->keyCallback(window, key, action);
|
window->keyCallback(window, key, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +267,6 @@ GLFWAPI int glfwGetInputMode(GLFWwindow handle, int mode)
|
||||||
return window->stickyKeys;
|
return window->stickyKeys;
|
||||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
return window->stickyMouseButtons;
|
return window->stickyMouseButtons;
|
||||||
case GLFW_KEY_REPEAT:
|
|
||||||
return window->keyRepeat;
|
|
||||||
default:
|
default:
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -311,9 +299,6 @@ GLFWAPI void glfwSetInputMode(GLFWwindow handle, int mode, int value)
|
||||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE);
|
setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE);
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_REPEAT:
|
|
||||||
setKeyRepeat(window, value ? GL_TRUE : GL_FALSE);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -185,7 +185,6 @@ struct _GLFWwindow
|
||||||
// Window input state
|
// Window input state
|
||||||
GLboolean stickyKeys;
|
GLboolean stickyKeys;
|
||||||
GLboolean stickyMouseButtons;
|
GLboolean stickyMouseButtons;
|
||||||
GLboolean keyRepeat;
|
|
||||||
int cursorPosX, cursorPosY;
|
int cursorPosX, cursorPosY;
|
||||||
int cursorMode;
|
int cursorMode;
|
||||||
double scrollX, scrollY;
|
double scrollX, scrollY;
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
// These must match the input mode defaults
|
// These must match the input mode defaults
|
||||||
static GLboolean keyrepeat = GL_FALSE;
|
|
||||||
static GLboolean closeable = GL_TRUE;
|
static GLboolean closeable = GL_TRUE;
|
||||||
|
|
||||||
// Event index
|
// Event index
|
||||||
|
@ -310,15 +309,6 @@ static void key_callback(GLFWwindow window, int key, int action)
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_R:
|
|
||||||
{
|
|
||||||
keyrepeat = !keyrepeat;
|
|
||||||
glfwSetInputMode(window, GLFW_KEY_REPEAT, keyrepeat);
|
|
||||||
|
|
||||||
printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLFW_KEY_C:
|
case GLFW_KEY_C:
|
||||||
{
|
{
|
||||||
closeable = !closeable;
|
closeable = !closeable;
|
||||||
|
@ -382,8 +372,6 @@ int main(void)
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
printf("Window size should be %ix%i\n", width, height);
|
printf("Window size should be %ix%i\n", width, height);
|
||||||
|
|
||||||
printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled");
|
|
||||||
|
|
||||||
printf("Main loop starting\n");
|
printf("Main loop starting\n");
|
||||||
|
|
||||||
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user