Removed Unicode character actions, updated events test.

This commit is contained in:
Camilla Berglund 2010-09-09 19:33:37 +02:00
parent 8fa7dddf16
commit 93ea341211
5 changed files with 11 additions and 40 deletions

View File

@ -371,7 +371,7 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
typedef void (* GLFWmousewheelfun)(GLFWwindow,int);
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
typedef void (* GLFWcharfun)(GLFWwindow,int,int);
typedef void (* GLFWcharfun)(GLFWwindow,int);
/*************************************************************************

View File

@ -276,7 +276,7 @@ void _glfwClearWindowHints(void);
void _glfwClearInput(_GLFWwindow* window);
void _glfwInputDeactivation(_GLFWwindow* window);
void _glfwInputKey(_GLFWwindow* window, int key, int action);
void _glfwInputChar(_GLFWwindow* window, int character, int action);
void _glfwInputChar(_GLFWwindow* window, int character);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
// OpenGL extensions (glext.c)

View File

@ -149,7 +149,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
// Register (keyboard) character activity
//========================================================================
void _glfwInputChar(_GLFWwindow* window, int character, int action)
void _glfwInputChar(_GLFWwindow* window, int character)
{
int keyrepeat = 0;
@ -157,36 +157,8 @@ void _glfwInputChar(_GLFWwindow* window, int character, int action)
if (!((character >= 32 && character <= 126) || character >= 160))
return;
// Is this a key repeat?
if (action == GLFW_PRESS && window->lastChar == character)
keyrepeat = 1;
// Store this character as last character (or clear it, if released)
if (action == GLFW_PRESS)
window->lastChar = character;
else
window->lastChar = 0;
if (action != GLFW_PRESS)
{
// This intentionally breaks release notifications for Unicode
// characters, partly to see if anyone cares but mostly because it's
// a nonsensical concept to begin with
//
// It will remain broken either until its removal in the 3.0 API or
// until someone explains, in a way that makes sense to people outside
// the US and Scandinavia, what "Unicode character up" actually means
//
// If what you want is "physical key up" then you should be using the
// key functions and/or the key callback, NOT the Unicode input
//
// However, if your particular application uses this misfeature for...
// something, you can re-enable it by removing this if-statement
return;
}
if (window->charCallback && (window->keyRepeat || !keyrepeat))
window->charCallback(window, character, action);
window->charCallback(window, character);
}

View File

@ -1027,7 +1027,7 @@ static GLboolean processSingleEvent(void)
_glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_PRESS);
// Translate and report character input
_glfwInputChar(window, translateChar(&event.xkey), GLFW_PRESS);
_glfwInputChar(window, translateChar(&event.xkey));
break;
}
@ -1065,9 +1065,6 @@ static GLboolean processSingleEvent(void)
// Translate and report key release
_glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_RELEASE);
// Translate and report character input
_glfwInputChar(window, translateChar(&event.xkey), GLFW_RELEASE);
break;
}

View File

@ -250,11 +250,13 @@ static void key_callback(GLFWwindow window, int key, int action)
}
}
static void char_callback(GLFWwindow window, int character, int action)
static void char_callback(GLFWwindow window, int character)
{
printf("%08x at %0.3f: Character 0x%04x", counter++, glfwGetTime(), character);
printf(" (%s) %s\n", get_character_string(character), get_action_name(action));
printf("%08x at %0.3f: Character 0x%04x (%s)\n",
counter++,
glfwGetTime(),
character,
get_character_string(character));
}
int main(void)