Menu

Anti-Repeat

Help
UI_Guy
2006-12-15
2013-03-22
  • UI_Guy

    UI_Guy - 2006-12-15

    A quick inquiry.  I have several remotes which - with a single push of the button seem to spit out multiple versions of the same IR code.

    This is unfortunate because in a list of buttons, a single button press moves me down 3-4 buttons.  Is there an anti-repeat setting where only the first code within - say N msec - is honored?

    Many thanks,

    UI_Guy

     
    • Russell Black

      Russell Black - 2006-12-18

      There's not, althought that's not a bad idea.

       
    • Adam Kropelin

      Adam Kropelin - 2007-02-17

      I just implemented this feature for my own use and thought I'd check the forums to see if anyone else had wanted it. Guess so!

      I added a "lockout" attribute to the binding element which specifies the time period (in msec) during which repeats of that same binding will be ignored. I wanted to allow repeats of certain codes which is why I didn't make this a global setting for all bindings. Also, it seemed appropriate to apply the lockout at the binding level (where the action takes places) instead of the remote level (which is just mapping IR codes).

      Here is a diff showing my changes against v0.4:

      --- src.orig\remote2key.cpp    2006-01-31 23:37:00.000000000 -0500
      +++ src\remote2key.cpp    2007-02-17 15:22:46.281250000 -0500
      @@ -337,6 +337,9 @@
      }

      void R2K_ProcessIRCode(const char* codeType, const char* irCode) {
      +    static TiXmlElement* lastBinding = NULL;
      +    static ULONGLONG lastTime = 0;
      +
           if (!irCode) {
               R2K_Log("\nReceived NULL IR Code\n", irCode);
               return;
      @@ -352,6 +355,32 @@
           SetClipboardContents(irCode);
           TiXmlElement* binding = config->getBindingForIREvent(currApp, codeType, irCode);
           if (binding) {
      +        // check for repeats during lockout interval
      +        const char* lockout = binding->Attribute("lockout");
      +        if (lockout && binding == lastBinding) {
      +            // lockout interval in msec
      +            ULONGLONG lockoutMsec = strtoul(lockout, NULL, 10);
      +
      +            // current time
      +            ULONGLONG now;
      +            GetSystemTimeAsFileTime((FILETIME*)&now);
      +
      +            // time at which this binding is allowed to be used
      +            ULONGLONG targetTime;
      +            targetTime = lastTime + lockoutMsec * 10000;  // msec to 100s-of-nsec
      +
      +            // are we there yet, are we there yet?
      +            if (now < targetTime) {
      +                R2K_Log("Ignoring IR Code during %d msec lockout\n", lockoutMsec);
      +                return;
      +            }
      +
      +            lastTime = now;
      +        }
      +
      +        // remember this binding
      +        lastBinding = binding;
      +
               // switch-to-app?
               const char* newApp = binding->Attribute("switch-to-app");
               if (newApp) {

       
    • Adam Kropelin

      Adam Kropelin - 2007-02-17

      Argh. Since sourceforge mangled the patch, feel free to email me for a good copy.

       
    • Russell Black

      Russell Black - 2007-03-30

      Adam,

      Thanks for the patch.  I've incorporated it into release 0.5

       

Log in to post a comment.