TicRate and the Keyboard sensor

I’m stumped – the Keyboard sensor and the Always sensor in 2.49 do not seem to honor the setLogicTicRate setting identically. I have two scripts, one connected to an Always sensor where I set GameLogic.setLogicTicRate(20.), and the other connected to a Keyboard sensor. I’d like both scripts to operate at 20Hz, but the Keyboard sensor seems to race past the Always sensor at roughly 2x to 3x speed.

Here’s a little more detail. Both scripts have socket connections to an external C++ program. The Always sockets are blocking and the Keyboard socket is non-blocking. If I setLogicTicRate to 60Hz, the Keyboard script sends data precisely when key is pressed and all is good. But, if I setLogicTicRate to 20Hz, the Keyboard sensor samples and cues up all of my keyboard inputs at about 40Hz to 60Hz. I’d much prefer a TicRate of 20Hz if I can resolve this issue, because 20Hz is real world speed for this C++ program.

Thanks,
Doug

The Keyboard sensors work on the physics tick rate. So if you set the physics tick rate to 20 it should work fine.
Or you could set the game fps to 20 and set the max physics sub steps to 1 (default is 5).
As a third possibility you could set the Keyboard sensor to activate every 3rd tick.
One of these options should work for you I hope:)

Thanks. Turns out that at the lower rate, the C++ nonblocking socket was lagging. Changed to a blocking socket routine in my Always script that sends null when no keyboard key is pressed, and all is good.