#!/bin/sh /usr/share/dpatch/dpatch-run

## control-1.3.18 patch - by Thomas Günther <tom@toms-cafe.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Changes for VDR >= 1.3.18.

@DPATCH@
--- control-0.0.2a/gateway.c
+++ control-0.0.2a/gateway.c
@@ -102,7 +102,12 @@
 
       uint64 Command = 0;
       uint i = 0;
+#if VDRVERSNUM >= 10318
+      cTimeMs timeout;
+      timeout.Set(100);
+#else
       int t0 = time_ms();
+#endif
       while (_active && i < sizeof(Command)) {
 
         uchar ch;
@@ -131,7 +136,11 @@
           // of their codes, so we'll need to wait some 100ms to see if
           // there is more coming up - or whether this really is the 'ESC'
           // key (if somebody knows how to clean this up, please let me know):
+#if VDRVERSNUM >= 10318
+          if (Command == 0x1B && !timeout.TimedOut())
+#else
           if (Command == 0x1B && time_ms() - t0 < 100)
+#endif
             continue;
 
           if (Command) {
