Questions about input

just got done putting a thirdpersonhandler together, I "fashioned" it from the strategyhandler it does the basic stuff I need so far, I never got jme's builtin tph to work the way I needed "one thing was at the cost of another…sadly" and I had no idea how to get arround that.

Anyway back on topic…as part of my input action scheme, I want to have my player model perform an action if a key/mouse button is pressed and released twice in rapid succession"like double clicking"  e.g  trigger an aggressive sprint or stepping motion. I am not quite sure how to setup such actions, can any body offer some advice or point me in the direction of info.



thanks in advance


Perhaps keep a timestamp and compare to see if they are close enough together?

are there any tests or code block in jme it can reference for doing that, searched the forums but nothing useful popped up.

Here is a util class i built some years ago for double click prevention - you could adapt it quite easily



public class DoubleClickPassifier {
   
   final long delay;
   long lastClickTime = 0l;
   
   public DoubleClickPassifier(long delay) {
      this.delay = delay;
   }
   
   private boolean action(long clickTime) {
      boolean allow = false;
      if(lastClickTime + delay < clickTime) allow = true;
      this.lastClickTime = clickTime;   
      ExceptionLog.addDebug("DoubleClickPassifier", "action", "Result = " + allow);
      return allow;
   }
   
   public boolean action() {
      return action(System.currentTimeMillis());
   }
   
   public void passThroughnext() {
      lastClickTime -= delay;
   }

}

Also, you could use Java's native MouseListener; it can tell you the 'click' count.  Basically just doing a timer thing also, but its already done for you :slight_smile:

thank for this guys really helpful :slight_smile: :wink: