Best way I can imagine handling this is to study Roger's whistling. Fortunately for those who'd prefer earlier engines, he also fidgets in SQ5. I think Larry, in some games, does so too.
For SQ5, the key is in SQEgo.sc, in the class FiddleStopWalk (of Smopper), whose name implies it's like your general StopWalk, but with some extras. Now, this one is a bit more complicated than it needs to be because Roger can wear two different uniforms throughout the game, but the important bit seems to be the check on top of FiddleStopWalk::doit, (if (client isStopped:). Among other things it counts down the ticks as long as Roger is standing (loop
, then sets a random fidget animation.