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

Proposed by Curtis Hovey
Status: Needs review
Proposed branch: lp:~sinzui/impressive/lirc-0
Merge into: lp:impressive
Diff against target: 80 lines (+37/-0)
3 files modified
src/event.py (+24/-0)
src/init.py (+6/-0)
src/main.py (+7/-0)
To merge this branch: bzr merge lp:~sinzui/impressive/lirc-0

Description of the change

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.

To post a comment you must log in.

Unmerged revisions

33. By Curtis Hovey

Added lirc support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
28 WantStatus = True28 WantStatus = True
29 DrawCurrentPage()29 DrawCurrentPage()
3030
31# A psuedo event for LIRC.
32class RemoteEvent:
33 configs = {
34 'Escape': K_ESCAPE,
35 'Right': K_RIGHT,
36 'Left': K_LEFT,
37 }
38
39 def __init__(self, config):
40 self.type = KEYDOWN
41 self.unicode = ''
42 self.key = self.configs[config]
43
44# Poll for remote IR events and feed them to HandleEvent
45def PollLircEvent():
46 if not EnableLirc:
47 return
48 remote = pylirc.nextcode(1)
49 if remote:
50 for press in remote:
51 remote_event = RemoteEvent(press['config'])
52 if remote_event.key:
53 HandleEvent(remote_event)
54
31# main event handling function55# main event handling function
32def HandleEvent(event):56def HandleEvent(event):
33 global HaveMark, ZoomMode, Marking, Tracing, Panning, SpotRadius, FileStats57 global HaveMark, ZoomMode, Marking, Tracing, Panning, SpotRadius, FileStats
3458
=== 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 @@
103 def release(self): self.state = False103 def release(self): self.state = False
104 def locked(self): return self.state104 def locked(self): return self.state
105 def create_lock(): return pseudolock()105 def create_lock(): return pseudolock()
106
107try:
108 import pylirc
109 EnableLirc = True
110except ImportError:
111 EnableLirc = False
106112
=== 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 @@
23 if not(FileName) and (len(FileList) == 1):23 if not(FileName) and (len(FileList) == 1):
24 FileName = FileList[0]24 FileName = FileList[0]
2525
26 # Register impressive as a Linux IR client.
27 if EnableLirc:
28 pylirc.init("impressive")
29
26 # initialize PyGame30 # initialize PyGame
27 pygame.init()31 pygame.init()
2832
@@ -338,6 +342,7 @@
338 DrawCurrentPage()342 DrawCurrentPage()
339 UpdateCaption(Pcurrent)343 UpdateCaption(Pcurrent)
340 while True:344 while True:
345 PollLircEvent()
341 HandleEvent(pygame.event.wait())346 HandleEvent(pygame.event.wait())
342347
343348
@@ -376,6 +381,8 @@
376 os.remove(tmp)381 os.remove(tmp)
377 except OSError:382 except OSError:
378 pass383 pass
384 if EnableLirc:
385 pylirc.exit()
379 pygame.quit()386 pygame.quit()
380387
381 # release all locks388 # release all locks

Subscribers

People subscribed via source and target branches

to all changes: