Odd Keyboard/Mouse bug?

BlitzMax Forums/BlitzMax Programming/Odd Keyboard/Mouse bug?

Tachyon(Posted 2008) [#1]
I didn't want to post this in the Bug Reports section because it is impossible to duplicate, but I was hoping that someone else might be able to confirm this.

With my game, several people have reported that the mouse stops responding to clicks (MouseDown) and the keyboard stops responding to key presses (KeyDown) when their system has been up for a while- i.e. several days or weeks without rebooting.

I have dealt with this now on all 3 platforms (Windows, MacOS, Linux) where people have complained that their mouse/keyboard has stopped responding in the game, and so far all of them have reported not having rebooted their computer for a long period of time, and upon rebooting their problem is fixed. In fact, this was my very first support issue upon release back in November, and it's the only issue that repeatedly comes up every few weeks with new users.

Anyone else seen this?


tonyg(Posted 2008) [#2]
'Fraid not but I would suggest it has something to do with the millisecs counter wrapping.
Is it possible you use millisecs() to slow-down or time user input?


Tachyon(Posted 2008) [#3]
tonyg: no, I don't use anything like that.

Also, I should clarify that it's not that they have my game up for days or weeks constantly, but rather they just haven't rebooted their computer for that amount of time, then when they start the game, the mouse and/or keyboard experiences this odd behavior.


tonyg(Posted 2008) [#4]
Millisecs() is taken from when the system is booted so is not dependant on your game. Because it is held in an int the value wraps after about 25 days (I think).
That's the only thing I can think of that is dependant on how long a machine has not been rebooted for (other than memory leaks)


Tachyon(Posted 2008) [#5]
Hmmm...good point. I'll thoroughly review my code again.


TaskMaster(Posted 2008) [#6]
Yes, it means their computer has been on for more than 24 days (or something like that). They will either need to reboot, or you will need to redo the way you are using millisecs() within your program.


Tachyon(Posted 2008) [#7]
I see a couple places where my use of millisecs() may be causing an issue. Will using a LONG overcome this quirk?

i.e. Global Time:Long = Millisecs()


GfK(Posted 2008) [#8]
No.

If Millisecs() returns a negative value, then that's what Time will contain.

Your best resolution is to use a timer for these calculations, instead of Millisecs(). You can reset the timer periodically to prevent it from going to stupidly high values, or set its frequency lower - there's no point having it ticking a thousand times a second if 5 ticks a second will do the same job.


deps(Posted 2008) [#9]
I have a similar problem, but rebooting did not help at all.

The game starts and runs just fine for a couple of seconds, then it behaves like my last keypress got stuck.
For example, I could press the right arrow to make the character go right, when I later release the key it still moves right. If I during this time press left, it continues to move right for several seconds. Then it starts to move left.
It's like it notices the keypresses, but keyhit/keydown isn't told about this for quite some time. It can literarly take about half a minute to close the game, since ESC is also affected by this.

I also noticed that while the game does this, every application ignores the mouse buttons or keys. I can't even click on the Start button.

Anyone got any ideas? Like I said, a reboot didn't cure this. :(
Thankful for any help!


deps(Posted 2008) [#10]
removed everything related to timing and the keyboard still stops to responds properly.

No one have any idea? :P


GfK(Posted 2008) [#11]
Dunno. Try adding FlushKeys() at the end of each loop?


deps(Posted 2008) [#12]
Added flushkeys to the end of the main loop and that made things worse.
I also tried to add a short delay (10 milliseconds) at that made it play as normal again, except that it's now quite jerky.

I also tried to add a pollsystem but that had no effect whatsoever.


GfK(Posted 2008) [#13]
Try Delay 1?

Are you using any form of timing at all in your code? Code *can* run too fast for its own good.


deps(Posted 2008) [#14]
Delay 1 worked a lot better, tried it as soon as I had posted my previous message.
But it feels so ugly. And why is it even needed? And why doesn't pollsystem work instead? Doesn't delay call it anyway?

I do have some timing code in there. Didn't write it myself but it looks to be based on the code found in many of the discussions found here. The issue I was having occurred both with and without the timing code.

But other projects not using any timing at all works just fine. And why was I'm not able to press ctrl+alt+del while the game was behaving like this?

Odd stuff.


GfK(Posted 2008) [#15]
Its impossible to say without seeing any code.

Have you tried it on a different PC to rule out any hardware issues?


deps(Posted 2008) [#16]
I havent tried it on another computer, but have ruled out hardware issues/buggy drivers because other games and apps runs just fine. Even when they aren't using any timing code.

Could show parts of the code, but it's basically just a loop that calls an update function and a render function. The player input is done using keydown() in a TPlayer type, called by the update function.
That's why the problem was really irritating, nothing was notably different from other projects. :P


Anyway. Thanks for helping. It works and don't seem too jerky so I think it will have to do for the time being. Got a deadline and lots of graphics and levels to add.