SpiderPig Posted April 28, 2019 Share Posted April 28, 2019 I haven't managed to pin point this issue yet but sometimes I have to press keys multiple times before it registers. My fps average between 40 to 60 and it happens when I use Window::KeyHit(). KeyDown() has no problems. Has anyone else had similar issues to this? I was wondering if it was something to do with low fps and it didn't detect the key in some frames? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted April 28, 2019 Author Share Posted April 28, 2019 for (int id = 0; id < 256; id++) { MainFrame::window->keyhitstate[id] = false; } I think this was the cause. I can't remember why I was doing this though... I need to write more notes on my code... My only guess as to why this was the problem is that some key-presses are being picked up after a KeyHit() check is being made? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted April 28, 2019 Share Posted April 28, 2019 You could also see if FlushKeys could help. https://www.leadwerks.com/community/topic/16999-keyhit-problem/?do=findComment&comment=110861 Might not apply to your case though, depending on the rest of your code. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted April 28, 2019 Author Share Posted April 28, 2019 This is what I was trying to solve with resetting the hit-state.- Vec3 mpos = window->GetMousePosition(); if (mpos.x > 500) { if (window->KeyHit(Key::R) == true) { int test = 0; } } else { //If mouse.x is less than 500 and the key is pressed nothing happens. however if you then move your mouse to greater than 500, they key is detected as hit. } I think FlushKeys() was resetting keydown events too... I'll have to retry that and check... Quote Link to comment Share on other sites More sharing options...
gamecreator Posted April 28, 2019 Share Posted April 28, 2019 That part looks like it should work correctly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.