Jump to content
  • Advertisement
Sign in to follow this  
Codman

keyPressed() delay on some phones

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello there! On a Samsung C225 phone (midp 2.0) if I press quick enough the keys I introduce a delay between the moment I actually press the button and the application receives a keyPressed(keyCode) event. The game fps remains the same (around 7-9 fps) but the delay continue to increases after play time (my tester obtained around 30 seconds last time!!!). If I press more keys they will become avaible to aplication after that delay in a burst (normal delay between them). If I quit the application and restart the delay becomes 0 (or almost) again. The problem as I see it is: "I press a key - the delay increases". Any ideas or ways to reset some kind of internal key buffer are welcome.

Share this post


Link to post
Share on other sites
Advertisement
Are you doing anything overly complicated in keyPressed()?, because that method should exit as fast as possible. If you are not doing this already, try just setting/resetting flags in the keyPressed()/keyReleased() methods and handling the logic in the main game loop.

Another factor that could affect this is if your game loop is too "tight", ie, not enough sleep time between runs. This will not free up enough processor time for the UI thread to handle the key input (especially if you're using serviceRepaints() or flushGraphics() since they would move paint requests to the top of the queue and they would be handled before key input).

shmoove

Share this post


Link to post
Share on other sites
Thx to your advice I fixed the problem.

The game mechanics were updated on paint() and the run() method only had a short loop with a serviceRepaint() call somewhere. I removed that and I also put thread to sleep for 10 milliseconds.

Share this post


Link to post
Share on other sites
If you haven't done so, I'd suggest moving the logic out of paint() and putting it in run(). paint() can get called when you don't expect it sometimes (like after a low battery or incoming message alert), and that can mess things up a bit. Also it's a method called by the UI thread so it should be as fast as possible.

shmoove

[Edited by - shmoove on July 27, 2005 7:35:51 AM]

Share this post


Link to post
Share on other sites
with the Kyocera K10, it is not uncommon for it to recieve keypressed()/keyreleased() up to 500 milliseconds after they key is pressed, espeicially during continuous gameplay. Personally I just think the phone is junk.

~guyaton

Share this post


Link to post
Share on other sites
Unfortunatly the code have been written by someone else. I always use the run/paint Java game structure (as every game for every platform should have).

At this moment the game has gone gold already and there is nothing to do - it runs just fine :)

@Kyocera K10 - I don't know this phone. From what you describe I suppose it is not a game platform with all efforts.

Share this post


Link to post
Share on other sites
Oh well. Just don't forget to slap the person who wrote the code [wink]

All's well that ends well I guess.

shmoove

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!