|
|
|
@ -31,6 +31,111 @@ |
|
|
|
|
#include "internal.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
////// GLFW internal API //////
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Register keyboard activity
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwInputKey(_GLFWwindow* window, int key, int action) |
|
|
|
|
{ |
|
|
|
|
GLboolean keyrepeat = GL_FALSE; |
|
|
|
|
|
|
|
|
|
if (key < 0 || key > GLFW_KEY_LAST) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
// Are we trying to release an already released key?
|
|
|
|
|
if (action == GLFW_RELEASE && window->key[key] != GLFW_PRESS) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
// Register key action
|
|
|
|
|
if(action == GLFW_RELEASE && window->stickyKeys) |
|
|
|
|
window->key[key] = GLFW_STICK; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS); |
|
|
|
|
window->key[key] = (char) action; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Call user callback function
|
|
|
|
|
if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat)) |
|
|
|
|
_glfwLibrary.keyCallback(window, key, action); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Register (keyboard) character activity
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwInputChar(_GLFWwindow* window, int character) |
|
|
|
|
{ |
|
|
|
|
// Valid Unicode (ISO 10646) character?
|
|
|
|
|
if (!((character >= 32 && character <= 126) || character >= 160)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (_glfwLibrary.charCallback) |
|
|
|
|
_glfwLibrary.charCallback(window, character); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Register scroll events
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset) |
|
|
|
|
{ |
|
|
|
|
window->scrollX += xoffset; |
|
|
|
|
window->scrollY += yoffset; |
|
|
|
|
|
|
|
|
|
if (_glfwLibrary.scrollCallback) |
|
|
|
|
_glfwLibrary.scrollCallback(window, xoffset, yoffset); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Register mouse button clicks
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action) |
|
|
|
|
{ |
|
|
|
|
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
// Register mouse button action
|
|
|
|
|
if (action == GLFW_RELEASE && window->stickyMouseButtons) |
|
|
|
|
window->mouseButton[button] = GLFW_STICK; |
|
|
|
|
else |
|
|
|
|
window->mouseButton[button] = (char) action; |
|
|
|
|
|
|
|
|
|
if (_glfwLibrary.mouseButtonCallback) |
|
|
|
|
_glfwLibrary.mouseButtonCallback(window, button, action); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Register cursor moves
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y) |
|
|
|
|
{ |
|
|
|
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED) |
|
|
|
|
{ |
|
|
|
|
window->mousePosX += x; |
|
|
|
|
window->mousePosY += y; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
window->mousePosX = x; |
|
|
|
|
window->mousePosY = y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (_glfwLibrary.mousePosCallback) |
|
|
|
|
_glfwLibrary.mousePosCallback(window, x, y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
////// GLFW public API //////
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|