← Back to team overview

registry team mailing list archive

[Merge] lp:~sinzui/impressive/lirc-0 into lp:impressive

 

Curtis Hovey has proposed merging lp:~sinzui/impressive/lirc-0 into lp:impressive.

This branch add infrared remote support using LIRC. LIRC is optional, if the pylirc is installed, used can page though the presenatation and end it using their remote.
-- 
https://code.launchpad.net/~sinzui/impressive/lirc-0/+merge/29161
Your team Registry Administrators is subscribed to branch lp:impressive.
=== modified file 'src/event.py'
--- src/event.py	2010-01-10 11:30:16 +0000
+++ src/event.py	2010-07-04 02:10:41 +0000
@@ -28,6 +28,30 @@
     WantStatus = True
     DrawCurrentPage()
 
+# A psuedo event for LIRC.
+class RemoteEvent:
+    configs = {
+        'Escape': K_ESCAPE,
+        'Right': K_RIGHT,
+        'Left': K_LEFT,
+        }
+
+    def __init__(self, config):
+        self.type = KEYDOWN
+        self.unicode = ''
+        self.key = self.configs[config]
+
+# Poll for remote IR events and feed them to HandleEvent
+def PollLircEvent():
+    if not EnableLirc:
+        return
+    remote = pylirc.nextcode(1)
+    if remote:
+        for press in remote:
+            remote_event = RemoteEvent(press['config'])
+            if remote_event.key:
+                HandleEvent(remote_event)
+
 # main event handling function
 def HandleEvent(event):
     global HaveMark, ZoomMode, Marking, Tracing, Panning, SpotRadius, FileStats

=== modified file 'src/init.py'
--- src/init.py	2010-02-03 15:00:39 +0000
+++ src/init.py	2010-07-04 02:10:41 +0000
@@ -103,3 +103,9 @@
         def release(self): self.state = False
         def locked(self): return self.state
     def create_lock(): return pseudolock()
+
+try:
+    import pylirc
+    EnableLirc = True
+except ImportError:
+    EnableLirc = False

=== modified file 'src/main.py'
--- src/main.py	2010-02-25 18:55:44 +0000
+++ src/main.py	2010-07-04 02:10:41 +0000
@@ -23,6 +23,10 @@
     if not(FileName) and (len(FileList) == 1):
         FileName = FileList[0]
 
+    # Register impressive as a Linux IR client.
+    if EnableLirc:
+        pylirc.init("impressive")
+
     # initialize PyGame
     pygame.init()
 
@@ -338,6 +342,7 @@
         DrawCurrentPage()
     UpdateCaption(Pcurrent)
     while True:
+        PollLircEvent()
         HandleEvent(pygame.event.wait())
 
 
@@ -376,6 +381,8 @@
                 os.remove(tmp)
             except OSError:
                 pass
+        if EnableLirc:
+            pylirc.exit()
         pygame.quit()
 
     # release all locks