Well, everyone.

I have prodded Linus and he has made a new release of pylirc which
includes returning of the repeat value of rc events.  It works great
here.

To take advantage, you will first have to enable the repeat flag in
your lircrc file as such:

begin
    remote = MY_REMOTE
    prog = freevo
    button = foo
    repeat = 1
    config = FOO
end

You will then need this patch to rc.py:

Index: src/rc.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/rc.py,v
retrieving revision 1.8
diff -u -r1.8 rc.py
--- src/rc.py   24 Feb 2003 04:21:40 -0000      1.8
+++ src/rc.py   30 Mar 2003 17:41:02 -0000
@@ -165,6 +166,8 @@
     REBUILD_SCREEN = 'REBUILD_SCREEN'
     DVD_PROTECTED = 'DVD_PROTECTED' # Cannot play prot. DVDs
 
+    REPEAT_SKIP = 'REPEAT_SKIP'
+
     def __init__(self, port=config.REMOTE_CONTROL_PORT):
         self.pylirc = PYLIRC
         
@@ -192,11 +196,16 @@
             del self.queue[0]
             return ret
         if self.pylirc:
-            list = pylirc.nextcode()
+            list = pylirc.nextcode(1)
             if list == None:
                 return None
             for code in list:
-                data = code
-                return data
+               if (code["repeat"] < 1 or code["repeat"] > 5):
+                   data = code["config"]
+                   #print "repeat %s: returning" % repeat
+                   return data
+               else:
+                   #print "repeat %s: dropping" % repeat
+                   return self.REPEAT_SKIP
         else:
             return None

Before you ask why return an event named "REPEAT_SKIP" when there is a
REPEAT value between 2 and 5 I will tell you.  This is needed simply
because of the way the event handling loop works.  Right now, the loop
spins and sleeps for 1/10th of a second if there are no events to
process so to prevent the sleep when there are actually key events
happening (which should be ignored) we return an event saying so.

Now _every_ rc event loop needs patching like such (I have done some
fo them but certainly not all of them):

Index: src/main.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/main.py,v
retrieving revision 1.31
diff -u -r1.31 main.py
--- src/main.py 29 Mar 2003 21:49:54 -0000      1.31
+++ src/main.py 30 Mar 2003 17:40:54 -0000
@@ -575,11 +575,16 @@
                 break
             if not rc.func:
                 m and m.poll()
             time.sleep(0.1)
 
         if not rc.func:
             m and m.refresh()
+        if event == rc.REPEAT_SKIP:
+           # empty rc event, to avoid sleeping for 100ms
+           pass
+
         # Handle volume control   XXX move to the skin
-        if event == rc.VOLUP:
+        elif event == rc.VOLUP:
             print "Got VOLUP in main!"
             if( config.MAJOR_AUDIO_CTRL == 'VOL' ):
                 mixer.incMainVolume()

It sucks, I know, but there is not much else we can do with the
current event processing architecture the way it is.

But having a functional repeating scheme is a lot better than having
lirc only return single events and having to pound on keys for every
event we want.

b.

-- 
Brian J. Murrell

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to