mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Removed Unicode character actions, updated events test.
This commit is contained in:
parent
8fa7dddf16
commit
93ea341211
@ -371,7 +371,7 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
|
|||||||
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWmousewheelfun)(GLFWwindow,int);
|
typedef void (* GLFWmousewheelfun)(GLFWwindow,int);
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWcharfun)(GLFWwindow,int,int);
|
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -276,7 +276,7 @@ void _glfwClearWindowHints(void);
|
|||||||
void _glfwClearInput(_GLFWwindow* window);
|
void _glfwClearInput(_GLFWwindow* window);
|
||||||
void _glfwInputDeactivation(_GLFWwindow* window);
|
void _glfwInputDeactivation(_GLFWwindow* window);
|
||||||
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
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);
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
|
||||||
|
|
||||||
// OpenGL extensions (glext.c)
|
// OpenGL extensions (glext.c)
|
||||||
|
32
lib/window.c
32
lib/window.c
@ -149,7 +149,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
|||||||
// Register (keyboard) character activity
|
// Register (keyboard) character activity
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwInputChar(_GLFWwindow* window, int character, int action)
|
void _glfwInputChar(_GLFWwindow* window, int character)
|
||||||
{
|
{
|
||||||
int keyrepeat = 0;
|
int keyrepeat = 0;
|
||||||
|
|
||||||
@ -157,36 +157,8 @@ void _glfwInputChar(_GLFWwindow* window, int character, int action)
|
|||||||
if (!((character >= 32 && character <= 126) || character >= 160))
|
if (!((character >= 32 && character <= 126) || character >= 160))
|
||||||
return;
|
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))
|
if (window->charCallback && (window->keyRepeat || !keyrepeat))
|
||||||
window->charCallback(window, character, action);
|
window->charCallback(window, character);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1027,7 +1027,7 @@ static GLboolean processSingleEvent(void)
|
|||||||
_glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_PRESS);
|
_glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_PRESS);
|
||||||
|
|
||||||
// Translate and report character input
|
// Translate and report character input
|
||||||
_glfwInputChar(window, translateChar(&event.xkey), GLFW_PRESS);
|
_glfwInputChar(window, translateChar(&event.xkey));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1065,9 +1065,6 @@ static GLboolean processSingleEvent(void)
|
|||||||
// Translate and report key release
|
// Translate and report key release
|
||||||
_glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_RELEASE);
|
_glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_RELEASE);
|
||||||
|
|
||||||
// Translate and report character input
|
|
||||||
_glfwInputChar(window, translateChar(&event.xkey), GLFW_RELEASE);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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("%08x at %0.3f: Character 0x%04x (%s)\n",
|
||||||
|
counter++,
|
||||||
printf(" (%s) %s\n", get_character_string(character), get_action_name(action));
|
glfwGetTime(),
|
||||||
|
character,
|
||||||
|
get_character_string(character));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user