This commit is contained in:
Dmitri Shuralyov 2014-06-22 21:05:19 +00:00
commit 601021eff5
8 changed files with 20 additions and 10 deletions

View File

@ -47,6 +47,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
## Changelog
- Added `mods` parameter to character callback
- Added `GLFWcursor` custom system cursor handle
- Added `glfwCreateCursor`, `glfwDestroyCursor` and `glfwSetCursor` for
managing custom system cursors

View File

@ -781,12 +781,14 @@ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
*
* @param[in] window The window that received the event.
* @param[in] codepoint The Unicode code point of the character.
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
* held down.
*
* @sa glfwSetCharCallback
*
* @ingroup input
*/
typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int,int);
/*! @brief The function signature for file drop callbacks.
*

View File

@ -611,7 +611,7 @@ static int translateKey(unsigned int key)
NSUInteger i, length = [characters length];
for (i = 0; i < length; i++)
_glfwInputChar(window, [characters characterAtIndex:i]);
_glfwInputChar(window, [characters characterAtIndex:i], mods);
}
- (void)flagsChanged:(NSEvent *)event

View File

@ -153,13 +153,13 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
}
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint)
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods)
{
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
return;
if (window->callbacks.character)
window->callbacks.character((GLFWwindow*) window, codepoint);
window->callbacks.character((GLFWwindow*) window, codepoint, mods);
}
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)

View File

@ -700,9 +700,10 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
/*! @brief Notifies shared code of a Unicode character input event.
* @param[in] window The window that received the event.
* @param[in] codepoint The Unicode code point of the input character.
* @param[in] mods The modifiers pressed when the event was generated.
* @ingroup event
*/
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint);
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods);
/*! @brief Notifies shared code of a scroll event.
* @param[in] window The window that received the event.

View File

@ -528,7 +528,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_CHAR:
case WM_SYSCHAR:
{
_glfwInputChar(window, (unsigned int) wParam);
_glfwInputChar(window, (unsigned int) wParam, getKeyMods());
return 0;
}
@ -543,7 +543,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
return TRUE;
}
_glfwInputChar(window, (unsigned int) wParam);
_glfwInputChar(window, (unsigned int) wParam, getKeyMods());
return FALSE;
}

View File

@ -609,7 +609,7 @@ static void processEvent(XEvent *event)
_glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods);
if (character != -1)
_glfwInputChar(window, character);
_glfwInputChar(window, character, mods);
break;
}

View File

@ -388,12 +388,18 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
}
}
static void char_callback(GLFWwindow* window, unsigned int codepoint)
static void char_callback(GLFWwindow* window, unsigned int codepoint, int mods)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
printf("%08x to %i at %0.3f: Character 0x%08x (%s)",
counter++, slot->number, glfwGetTime(), codepoint,
get_character_string(codepoint));
if (mods)
printf(" (with%s)", get_mods_name(mods));
printf(" input\n");
}
static void drop_callback(GLFWwindow* window, int count, const char** names)