How to handle GLFW_REPEAT? getting more events than expectedfork() branches more than expected?Function Pointer as Function ParameterHow to tell if shift is pressed on numpad input with NumLock on? Or at least get NumLock status?SDL 2.0 Key repeat and delayGLFW Input StatesPassing in C++ Method as a Function Pointer?Why there is no GLFW_REPEAT for the mouse?Is there a way to process only one input event after a key is pressed using GLFW?GLFW switching boolean toggleglfwSetKeyCallback() from GLFW is not called constantly during a key press
How to deal with relatively technically incompetent coworker?
Do these creatures from the Tomb of Annihilation campaign speak Common?
Names of the Six Tastes
Illegal assignment from Id to List
Magical Modulo Squares
Why is it wrong to *implement* myself a known, published, widely believed to be secure crypto algorithm?
Is it safe to keep the GPU on 100% utilization for a very long time?
How can I test a shell script in a "safe environment" to avoid harm to my computer?
Examples where existence is harder than evaluation
Can the Telekinesis spell be used on yourself for the following?
Crime rates in a post-scarcity economy
What is the oldest instrument ever?
Why did Ham the Chimp push levers?
What's an appropriate age to involve kids in life changing decisions?
Light Switch Neutrals: Bundle all together?
Identity of a supposed anonymous referee revealed through "Description" of the report
get unsigned long long addition carry
How to explain intravenous drug abuse to a 6-year-old?
Why is there a cap on 401k contributions?
Opposite party turned away from voting when ballot is all opposing party
Colorless commander using lands that chose based upon identity?
How to animate petals opening
99 coins into the sacks
Should one save up to purchase a house/condo or maximize their 401k first?
How to handle GLFW_REPEAT? getting more events than expected
fork() branches more than expected?Function Pointer as Function ParameterHow to tell if shift is pressed on numpad input with NumLock on? Or at least get NumLock status?SDL 2.0 Key repeat and delayGLFW Input StatesPassing in C++ Method as a Function Pointer?Why there is no GLFW_REPEAT for the mouse?Is there a way to process only one input event after a key is pressed using GLFW?GLFW switching boolean toggleglfwSetKeyCallback() from GLFW is not called constantly during a key press
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm writing a simple game to discover Vulkan. I'm using GLFW 3 to create the window and handle input. I wanted some basic control over my camera with keyboard input, and I'm observing some strange lag when releasing a key passed the repeat delay.
I use glfwPollEvents() once in my update loop, and set up a key callback :
void Keyboard::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
static size_t count;
count++;
if(action == GLFW_PRESS)
std::cout << "(" << count << ") PRESS >> scancode : " << scancode << "
if(action == GLFW_REPEAT)
std::cout << "(" << count << ") REPEAT >> scancode : " << scancode << "
if (action == GLFW_RELEASE)
keycode : " << key << std::endl;
When running the application, I'm pressing the space bar once, keeping it pressed for some time and releasing it once. (the space bar isn't important here, the results are the same with other keys).
I would expect something like that :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
But in fact I get this :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
(21) PRESS >> scancode : 65 | keycode : 32
(22) REPEAT >> scancode : 65 | keycode : 32
(23) REPEAT >> scancode : 65 | keycode : 32
(24) REPEAT >> scancode : 65 | keycode : 32
(25) RELEASE >> scancode : 65 | keycode : 32
I get REPEAT events after the initial RELEASE event (which happens when I effectively release the space bar), and I get an extra PRESS and an extra RELEASE event. The longer I press the space bar, the more extra REPEAT I get, but I get only one extra PRESS and one extra RELEASE. If I don't get passed the repetition delay set up in my OS, I get only one PRESS and one RELEASE.
I'm looking for an explanation and/or a workaround, but I don't really know where to go from here. Reading GLFW documentation regarding input handling didn't help, I didn't find anyone with the same problem either.
c++ glfw
add a comment |
I'm writing a simple game to discover Vulkan. I'm using GLFW 3 to create the window and handle input. I wanted some basic control over my camera with keyboard input, and I'm observing some strange lag when releasing a key passed the repeat delay.
I use glfwPollEvents() once in my update loop, and set up a key callback :
void Keyboard::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
static size_t count;
count++;
if(action == GLFW_PRESS)
std::cout << "(" << count << ") PRESS >> scancode : " << scancode << "
if(action == GLFW_REPEAT)
std::cout << "(" << count << ") REPEAT >> scancode : " << scancode << "
if (action == GLFW_RELEASE)
keycode : " << key << std::endl;
When running the application, I'm pressing the space bar once, keeping it pressed for some time and releasing it once. (the space bar isn't important here, the results are the same with other keys).
I would expect something like that :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
But in fact I get this :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
(21) PRESS >> scancode : 65 | keycode : 32
(22) REPEAT >> scancode : 65 | keycode : 32
(23) REPEAT >> scancode : 65 | keycode : 32
(24) REPEAT >> scancode : 65 | keycode : 32
(25) RELEASE >> scancode : 65 | keycode : 32
I get REPEAT events after the initial RELEASE event (which happens when I effectively release the space bar), and I get an extra PRESS and an extra RELEASE event. The longer I press the space bar, the more extra REPEAT I get, but I get only one extra PRESS and one extra RELEASE. If I don't get passed the repetition delay set up in my OS, I get only one PRESS and one RELEASE.
I'm looking for an explanation and/or a workaround, but I don't really know where to go from here. Reading GLFW documentation regarding input handling didn't help, I didn't find anyone with the same problem either.
c++ glfw
add a comment |
I'm writing a simple game to discover Vulkan. I'm using GLFW 3 to create the window and handle input. I wanted some basic control over my camera with keyboard input, and I'm observing some strange lag when releasing a key passed the repeat delay.
I use glfwPollEvents() once in my update loop, and set up a key callback :
void Keyboard::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
static size_t count;
count++;
if(action == GLFW_PRESS)
std::cout << "(" << count << ") PRESS >> scancode : " << scancode << "
if(action == GLFW_REPEAT)
std::cout << "(" << count << ") REPEAT >> scancode : " << scancode << "
if (action == GLFW_RELEASE)
keycode : " << key << std::endl;
When running the application, I'm pressing the space bar once, keeping it pressed for some time and releasing it once. (the space bar isn't important here, the results are the same with other keys).
I would expect something like that :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
But in fact I get this :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
(21) PRESS >> scancode : 65 | keycode : 32
(22) REPEAT >> scancode : 65 | keycode : 32
(23) REPEAT >> scancode : 65 | keycode : 32
(24) REPEAT >> scancode : 65 | keycode : 32
(25) RELEASE >> scancode : 65 | keycode : 32
I get REPEAT events after the initial RELEASE event (which happens when I effectively release the space bar), and I get an extra PRESS and an extra RELEASE event. The longer I press the space bar, the more extra REPEAT I get, but I get only one extra PRESS and one extra RELEASE. If I don't get passed the repetition delay set up in my OS, I get only one PRESS and one RELEASE.
I'm looking for an explanation and/or a workaround, but I don't really know where to go from here. Reading GLFW documentation regarding input handling didn't help, I didn't find anyone with the same problem either.
c++ glfw
I'm writing a simple game to discover Vulkan. I'm using GLFW 3 to create the window and handle input. I wanted some basic control over my camera with keyboard input, and I'm observing some strange lag when releasing a key passed the repeat delay.
I use glfwPollEvents() once in my update loop, and set up a key callback :
void Keyboard::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
static size_t count;
count++;
if(action == GLFW_PRESS)
std::cout << "(" << count << ") PRESS >> scancode : " << scancode << "
if(action == GLFW_REPEAT)
std::cout << "(" << count << ") REPEAT >> scancode : " << scancode << "
if (action == GLFW_RELEASE)
keycode : " << key << std::endl;
When running the application, I'm pressing the space bar once, keeping it pressed for some time and releasing it once. (the space bar isn't important here, the results are the same with other keys).
I would expect something like that :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
But in fact I get this :
(1) PRESS >> scancode : 65 | keycode : 32
(2) REPEAT >> scancode : 65 | keycode : 32
(3) REPEAT >> scancode : 65 | keycode : 32
// more REPEAT lines
(18) REPEAT >> scancode : 65 | keycode : 32
(19) REPEAT >> scancode : 65 | keycode : 32
(20) RELEASE >> scancode : 65 | keycode : 32
(21) PRESS >> scancode : 65 | keycode : 32
(22) REPEAT >> scancode : 65 | keycode : 32
(23) REPEAT >> scancode : 65 | keycode : 32
(24) REPEAT >> scancode : 65 | keycode : 32
(25) RELEASE >> scancode : 65 | keycode : 32
I get REPEAT events after the initial RELEASE event (which happens when I effectively release the space bar), and I get an extra PRESS and an extra RELEASE event. The longer I press the space bar, the more extra REPEAT I get, but I get only one extra PRESS and one extra RELEASE. If I don't get passed the repetition delay set up in my OS, I get only one PRESS and one RELEASE.
I'm looking for an explanation and/or a workaround, but I don't really know where to go from here. Reading GLFW documentation regarding input handling didn't help, I didn't find anyone with the same problem either.
c++ glfw
c++ glfw
asked Mar 23 at 7:24
aTomaTom
499
499
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311574%2fhow-to-handle-glfw-repeat-getting-more-events-than-expected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311574%2fhow-to-handle-glfw-repeat-getting-more-events-than-expected%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown