Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Character Release Event #21

Closed
wants to merge 3 commits into from

2 participants

@christiaanb

Let me start with the comment found in the bundled GLFW C-Library (glfw/lib/window.c _glfwInputChar):

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;
}

As long as the GLFW-b bindings are bundled with this version (2.7.3) of the GLFW C-library I would like to have the above if-statement removed or comment out. As my argument I want to present the current bizarre sequence of events:

  • I register both char and key callbacks
  • I hold down the 'shift' key on my US Intl. Keyboard
  • While still holding down the 'shift' key, I press the '.'-button
  • The char callback mechanism passes "Char '<' True" to my registered char-callback function
  • I release the '.' button
  • The key callback mechanism passes "Char '.' False" to my registered key-callback function

When the above mentioned if-statement would be removed, I would at least get a corresponding "Char '<' False" event. Now it feels like the '.'-button is released without ever being pressed, and the '>'-char is never being released.

p.s. Somehow I can't convince github to only include the changes to glfw/lib/window.c, so please ignore all the other files in the pull request.

@bsl
Owner

I'm working on GLFW 3.0 bindings in branch "glfw3". Please open another issue if there is still a problem.

@bsl bsl closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 4 deletions.
  1. +4 −4 glfw/lib/window.c
  2. +10 −0 src/Graphics/UI/GLFW.hsc
View
8 glfw/lib/window.c
@@ -199,8 +199,8 @@ void _glfwInputChar( int character, int action )
_glfwInput.LastChar = 0;
}
- if( action != GLFW_PRESS )
- {
+ // 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
@@ -214,8 +214,8 @@ void _glfwInputChar( int character, int action )
//
// However, if your particular application uses this misfeature for...
// something, you can re-enable it by removing this if-statement
- return;
- }
+ // return;
+ // }
if( _glfwWin.charCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
{
View
10 src/Graphics/UI/GLFW.hsc
@@ -62,6 +62,8 @@ module Graphics.UI.GLFW
, keyIsPressed
, setCharCallback
, setKeyCallback
+ , enableKeyRepeat
+ , disableKeyRepeat
--
, Key(..)
, CharCallback
@@ -584,6 +586,14 @@ setKeyCallback cb = do
glfwSetKeyCallback ccb
storeCallback keyCallback ccb
+-- Key and Character callbacks are called repeatedly when a key is held down long enough
+enableKeyRepeat :: IO ()
+enableKeyRepeat = glfwEnable (#const GLFW_KEY_REPEAT)
+
+-- Key and Character callbacks are called only once when a key is pressed (Default)
+disableKeyRepeat :: IO ()
+disableKeyRepeat = glfwDisable (#const GLFW_KEY_REPEAT)
+
-- -- -- -- -- -- -- -- -- --
data Key
Something went wrong with that request. Please try again.