[gameprogrammer] Re: Key Repeat problem

Or maybe store the state, only pass the message on to the network server if the state changes. The state would store whether the key is pressed or not....

Paul Smith wrote:
Maybe in your KeyPressed function store a timestamp in a static variable and the next time the function is called only pass the message on to the network server if the time elapsed is greater than a certain number of milliseconds?

On 1/19/06, *Stephen Smith* <gp@xxxxxxxxxxxxxxxxxxxxxxxx <mailto:gp@xxxxxxxxxxxxxxxxxxxxxxxx>> wrote:

    I think this problem is purely with Java on Linux, but if anyone can
    think of a workaround it would be much appreciated.

    Basically, I have two functions, KeyPressed() and KeyReleased(), which
    normally get called (only) when a key is pressed and then released
    respectively.  However, if you hold a key down when running it on
    Linux,
    it fires each one pretty much constantly in turn for as long as
    the key
    is held down.  My program is a network client for my game, and I send
    keypress and keyrelease signals to the server.  With the above
    symptoms
    though, the server gets clogged up with constant signals from each
    client when a single key is held down.

    It is a known "symptom" of Java under Linux, but can anyone think
    of a
    work around?

    Thanks in advance,

    Stephen






--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html <http://gameprogrammer.com/mailinglist.html>





--
Paul Smith
Computer programmer

paul@xxxxxxxxxxxxxxxxxx <mailto:paul@xxxxxxxxxxxxxxxxxx>

-- Jacob Briggs Systems Engineer

Core Technology Limited
Level 1, NZX Centre
11 Cable Street
Wellington
Phone +64 4 499-1108

--

Named after its country of origin 'England', English is a little known dialect 
used by up to 1.5 billion non-Americans worldwide. Some interesting but 
obviously incorrect features of the language include:

- queues of people
- wonderful coloUrs
- the useful metal aluminIum
- the exotic herbs (h-urbs), basil (ba-zil) and oregano (o-re-gaa-no)
- specialiSed books called 'dictionaries' that tell you how to spell words 
correctly

Many people using this bizarre gutter speak also subscribe to the pagan belief 
that water freezes at 0 degrees and that distances should be measured in the 
forbidden mathematical system of base-10...



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: