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
1=== modified file 'src/event.py'
2--- src/event.py 2010-01-10 11:30:16 +0000
3+++ src/event.py 2010-07-04 02:10:41 +0000
4@@ -28,6 +28,30 @@
5 WantStatus = True
6 DrawCurrentPage()
7
8+# A psuedo event for LIRC.
9+class RemoteEvent:
10+ configs = {
11+ 'Escape': K_ESCAPE,
12+ 'Right': K_RIGHT,
13+ 'Left': K_LEFT,
14+ }
15+
16+ def __init__(self, config):
17+ self.type = KEYDOWN
18+ self.unicode = ''
19+ self.key = self.configs[config]
20+
21+# Poll for remote IR events and feed them to HandleEvent
22+def PollLircEvent():
23+ if not EnableLirc:
24+ return
25+ remote = pylirc.nextcode(1)
26+ if remote:
27+ for press in remote:
28+ remote_event = RemoteEvent(press['config'])
29+ if remote_event.key:
30+ HandleEvent(remote_event)
31+
32 # main event handling function
33 def HandleEvent(event):
34 global HaveMark, ZoomMode, Marking, Tracing, Panning, SpotRadius, FileStats
35
36=== modified file 'src/init.py'
37--- src/init.py 2010-02-03 15:00:39 +0000
38+++ src/init.py 2010-07-04 02:10:41 +0000
39@@ -103,3 +103,9 @@
40 def release(self): self.state = False
41 def locked(self): return self.state
42 def create_lock(): return pseudolock()
43+
44+try:
45+ import pylirc
46+ EnableLirc = True
47+except ImportError:
48+ EnableLirc = False
49
50=== modified file 'src/main.py'
51--- src/main.py 2010-02-25 18:55:44 +0000
52+++ src/main.py 2010-07-04 02:10:41 +0000
53@@ -23,6 +23,10 @@
54 if not(FileName) and (len(FileList) == 1):
55 FileName = FileList[0]
56
57+ # Register impressive as a Linux IR client.
58+ if EnableLirc:
59+ pylirc.init("impressive")
60+
61 # initialize PyGame
62 pygame.init()
63
64@@ -338,6 +342,7 @@
65 DrawCurrentPage()
66 UpdateCaption(Pcurrent)
67 while True:
68+ PollLircEvent()
69 HandleEvent(pygame.event.wait())
70
71
72@@ -376,6 +381,8 @@
73 os.remove(tmp)
74 except OSError:
75 pass
76+ if EnableLirc:
77+ pylirc.exit()
78 pygame.quit()
79
80 # release all locks

Subscribers

People subscribed via source and target branches

to all changes: