Has anyone else noticed that in current Nokia MIDP emulators and runtimes, when the user keeps a key pressed for a longer time the runtime generates the following sequence of events:
keyPressed, keyReleased, (keyrepeat start wait time), keyPressed, keyReleased, keyPressed, keyReleased, keyPressed, keyReleased, keyPressed, keyReleased...keyReleased
When in fact it should generate the following sequence of events:
keyPressed, (keyrepeat start wait time), keyRepeat, keyRepeat, keyRepeat, keyRepeat, keyRepeat, keyRepeat, keyRepeat, keyRepeat...keyReleased
In current implementation it's really impossible to read the keyboard reliably in an interactive game that runs in it's own thread as sometimes the thread will see the key pressed and sometime it will see it as released. I've tried various solutions like setting the a flag in keyPressed callback method and resetting it after reading it in the main loop of the game, but you still get very choppy and random looking behaviour as the keyPressed callback method switches the flag on every n:th game loop cycle. If the keyboard callback would work as it should in MIDP implementations I could set the flag in keyPressed method, clear it in keyReleased method and just read it's current state in game loop.

Reply With Quote

