Initial check-in.
authorAlexander Koenig <alex@lisas.de>
Wed, 9 Oct 2013 19:48:03 +0000 (19:48 +0000)
committerAlexander Koenig <alex@lisas.de>
Wed, 9 Oct 2013 19:48:03 +0000 (19:48 +0000)
Lircmap.xml [new file with mode: 0644]
hardware.conf [new file with mode: 0644]
lircd.conf [new file with mode: 0644]
lircrc [new file with mode: 0644]
vompilirc.py [new file with mode: 0755]

diff --git a/Lircmap.xml b/Lircmap.xml
new file mode 100644 (file)
index 0000000..fd56d48
--- /dev/null
@@ -0,0 +1,56 @@
+<!-- This file contains the mapping of LIRC keys to XBMC keys used in Keymap.xml  -->
+<!--                                                                              -->
+<!-- How to add remotes                                                           -->
+<!-- <remote device="name_Lirc_calls_the_remote">                                 -->
+<!--                                                                              -->
+<!-- For the commands the layout following layout is used                         -->
+<!-- <XBMC_COMMAND>LircButtonName</XBMC_COMMAND>                                  -->
+<!--                                                                              -->
+<!-- For a list of XBMC_COMMAND's check out the <remote> sections of keymap.xml   -->
+
+<lircmap>
+       <remote device="Hauppauge_MVP_H4">
+               <left>KEY_LEFT</left>
+               <right>KEY_RIGHT</right>
+               <up>KEY_UP</up>
+               <down>KEY_DOWN</down>
+               <select>KEY_OK</select>
+               <start>KEY_HOME</start>
+               <back>KEY_EXIT</back>
+               <record>KEY_RECORD</record>
+               <play>KEY_PLAY</play>
+               <pause>KEY_PAUSE</pause>
+               <stop>KEY_STOP</stop>
+               <forward>KEY_FORWARD</forward>
+               <reverse>KEY_REWIND</reverse>
+               <volumeplus>KEY_VOLUMEUP</volumeplus>
+               <volumeminus>KEY_VOLUMEDOWN</volumeminus>
+               <pageplus>KEY_CHANNELUP</pageplus>
+               <pageminus>KEY_CHANNELDOWN</pageminus>
+               <skipplus>KEY_FRAMEFORWARD</skipplus>
+               <skipminus>KEY_FRAMEBACK</skipminus>
+               <mute>KEY_MUTE</mute>
+               <power>KEY_POWER</power>
+               <myvideo>KEY_VIDEO</myvideo>
+               <mymusic>KEY_AUDIO</mymusic>
+               <mytv>LiveTV</mytv>
+               <one>KEY_1</one>
+               <two>KEY_2</two>
+               <three>KEY_3</three>
+               <four>KEY_4</four>
+               <five>KEY_5</five>
+               <six>KEY_6</six>
+               <seven>KEY_7</seven>
+               <eight>KEY_8</eight>
+               <nine>KEY_9</nine>
+               <zero>KEY_0</zero>
+               <red>KEY_RED</red>
+               <green>KEY_GREEN</green>
+               <yellow>KEY_YELLOW</yellow>
+               <blue>KEY_BLUE</blue>
+               <menu>KEY_DVD</menu>
+               <clear>KEY_CLEAR</clear>
+               <enter>KEY_ENTER</enter>
+       </remote>
+       
+</lircmap>
diff --git a/hardware.conf b/hardware.conf
new file mode 100644 (file)
index 0000000..1665ddc
--- /dev/null
@@ -0,0 +1,23 @@
+# /etc/lirc/hardware.conf
+#
+# Arguments which will be used when launching lircd
+LIRCD_ARGS=""
+
+#Don't start lircmd even if there seems to be a good config file
+#START_LIRCMD=false
+
+#Don't start irexec, even if a good config file seems to exist.
+START_IREXEC=false
+
+#Try to load appropriate kernel modules
+LOAD_MODULES=true
+
+# Run "lircd --driver=help" for a list of supported drivers.
+DRIVER="default"
+# usually /dev/lirc0 is the correct setting for systems using udev 
+DEVICE="/dev/lirc0"
+MODULES="lirc_rpi"
+
+# Default configuration files for your hardware if any
+LIRCD_CONF=""
+LIRCMD_CONF=""
diff --git a/lircd.conf b/lircd.conf
new file mode 100644 (file)
index 0000000..a51ca62
--- /dev/null
@@ -0,0 +1,81 @@
+
+# Please make this file available to others
+# by sending it to <lirc@bartelmus.de>
+#
+# this config file was automatically generated
+# using lirc-0.9.0-pre1(default) on Mon Oct  7 20:10:09 2013
+#
+# contributed by 
+#
+# brand:                                   Hauppauge 
+# model no. of remote control:             Rev H4 
+# devices being controlled by this remote: MVP Rev H4
+#
+
+begin remote
+
+  name Hauppauge_MVP_H4 
+  bits           13
+  flags RC5|CONST_LENGTH
+  eps            30
+  aeps          100
+
+  one           889   889
+  zero          889   889
+  plead         889
+  gap          113792
+  toggle_bit_mask 0x800
+  frequency    36000
+  duty_cycle   50
+
+      begin codes
+          KEY_POWER                0x17BD
+          KEY_HOME                 0x17BB
+          KEY_TV                   0x179C
+          KEY_VIDEO                0x1798
+          KEY_AUDIO                0x1799
+          KEY_CAMERA               0x179A
+          KEY_EPG                  0x179B
+          KEY_RADIO                0x178C
+          KEY_UP                   0x1794
+          KEY_DOWN                 0x1795
+          KEY_LEFT                 0x1796
+          KEY_RIGHT                0x1797
+          KEY_OK                   0x17A5
+          KEY_EXIT                 0x179F
+          KEY_MENU                 0x178D
+          KEY_PREVIOUS             0x1792
+          KEY_MUTE                 0x178F
+          KEY_VOLUMEUP             0x1790
+          KEY_VOLUMEDOWN           0x1791
+          KEY_CHANNELUP            0x17A0
+          KEY_CHANNELDOWN          0x17A1
+          KEY_RECORD               0x17B7
+          KEY_STOP                 0x17B6
+          KEY_PLAY                 0x17B5
+          KEY_REWIND               0x17B2
+          KEY_FORWARD              0x17B4
+          KEY_FRAMEBACK            0x17A4
+          KEY_PAUSE                0x17B0
+          KEY_FRAMEFORWARD         0x179E
+          KEY_1                    0x1781
+          KEY_2                    0x1782
+          KEY_3                    0x1783
+          KEY_4                    0x1784
+          KEY_5                    0x1785
+          KEY_6                    0x1786
+          KEY_7                    0x1787
+          KEY_8                    0x1788
+          KEY_9                    0x1789
+          KEY_KPASTERISK           0x178A
+          KEY_0                    0x1780
+          KEY_KPPLUS               0x178E
+          KEY_RED                  0x178B
+          KEY_GREEN                0x17AE
+          KEY_YELLOW               0x17B8
+          KEY_BLUE                 0x17A9
+      end codes
+
+end remote
+
+
diff --git a/lircrc b/lircrc
new file mode 100644 (file)
index 0000000..1dcf1a2
--- /dev/null
+++ b/lircrc
@@ -0,0 +1,315 @@
+begin
+prog = vompilirc
+button = KEY_POWER
+config = KEY_POWER
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_HOME
+config = KEY_HOME
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_TV
+config = KEY_TV
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_VIDEO
+config = KEY_VIDEO
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_AUDIO
+config = KEY_AUDIO
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_CAMERA
+config = KEY_CAMERA
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_EPG
+config = KEY_EPG
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_RADIO
+config = KEY_RADIO
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_UP
+config = KEY_UP
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_DOWN
+config = KEY_DOWN
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_LEFT
+config = KEY_LEFT
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_RIGHT
+config = KEY_RIGHT
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_OK
+config = KEY_OK
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_EXIT
+config = KEY_EXIT
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_MENU
+config = KEY_MENU
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_PREVIOUS
+config = KEY_PREVIOUS
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_MUTE
+config = KEY_MUTE
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_VOLUMEUP
+config = KEY_VOLUMEUP
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_VOLUMEDOWN
+config = KEY_VOLUMEDOWN
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_CHANNELUP
+config = KEY_CHANNELUP
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_CHANNELDOWN
+config = KEY_CHANNELDOWN
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_RECORD
+config = KEY_RECORD
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_STOP
+config = KEY_STOP
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_PLAY
+config = KEY_PLAY
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_REWIND
+config = KEY_REWIND
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_FORWARD
+config = KEY_FORWARD
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_FRAMEBACK
+config = KEY_FRAMEBACK
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_PAUSE
+config = KEY_PAUSE
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_FRAMEFORWARD
+config = KEY_FRAMEFORWARD
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_1
+config = KEY_1
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_2
+config = KEY_2
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_3
+config = KEY_3
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_4
+config = KEY_4
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_5
+config = KEY_5
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_6
+config = KEY_6
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_7
+config = KEY_7
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_8
+config = KEY_8
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_9
+config = KEY_9
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_KPASTERISK
+config = KEY_KPASTERISK
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_0
+config = KEY_0
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_KPPLUS
+config = KEY_KPPLUS
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_RED
+config = KEY_RED
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_GREEN
+config = KEY_GREEN
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_YELLOW
+config = KEY_YELLOW
+repeat = 1
+end
+
+begin
+prog = vompilirc
+button = KEY_BLUE
+config = KEY_BLUE
+repeat = 1
+end
+
diff --git a/vompilirc.py b/vompilirc.py
new file mode 100755 (executable)
index 0000000..1f6fea1
--- /dev/null
@@ -0,0 +1,172 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""vompilirc.py: Routes remote commands received through LIRC to vompclient via UDP."""
+
+#  Copyright (C) 2013  Alexander Koenig <alex@lisas.de>
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    
+__author__ = "Alexander K├Ânig"
+__email__ = "alex@lisas.de"
+__license__ = "GPLv2"
+
+import pylirc, time, socket, os, signal
+
+vomp_host = '127.0.0.1'
+vomp_port = 2000
+vomp_client = None
+
+# VOMP remote commands as defined in remote.h
+
+VOMP_NA_LEARN    = 101
+VOMP_NA_NONE     = 98
+VOMP_NA_UNKNOWN  = 99
+VOMP_NA_SIGNAL   = 100
+VOMP_DF_UP       = 94
+VOMP_DF_DOWN     = 95
+VOMP_DF_LEFT     = 96
+VOMP_DF_RIGHT    = 97
+
+VOMP_VOLUMEUP    = 16
+VOMP_VOLUMEDOWN  = 17
+VOMP_CHANNELUP   = 32
+VOMP_CHANNELDOWN = 33
+
+VOMP_ZERO        = 0
+VOMP_ONE         = 1
+VOMP_TWO         = 2
+VOMP_THREE       = 3
+VOMP_FOUR        = 4
+VOMP_FIVE        = 5
+VOMP_SIX         = 6
+VOMP_SEVEN       = 7
+VOMP_EIGHT       = 8
+VOMP_NINE        = 9
+VOMP_POWER       = 61
+VOMP_GO          = 59
+VOMP_BACK        = 31
+VOMP_MENU        = 13
+VOMP_RED         = 11
+VOMP_GREEN       = 46
+VOMP_YELLOW      = 56
+VOMP_BLUE        = 41
+VOMP_MUTE        = 15
+VOMP_RADIO       = 12
+VOMP_REVERSE     = 50
+VOMP_PLAY        = 53
+VOMP_FORWARD     = 52
+VOMP_RECORD      = 55
+VOMP_STOP        = 54
+VOMP_PAUSE       = 48
+VOMP_SKIPBACK    = 36
+VOMP_SKIPFORWARD = 30
+VOMP_OK          = 37
+
+VOMP_FULL        = 60
+
+VOMP_TV          = 28
+VOMP_VIDEOS      = 24
+VOMP_MUSIC       = 25
+VOMP_PICTURES    = 26
+VOMP_GUIDE       = 27
+VOMP_UP          = 20
+VOMP_DOWN        = 21
+VOMP_LEFT        = 22
+VOMP_RIGHT       = 23
+VOMP_PREVCHANNEL = 18
+VOMP_STAR        = 10
+VOMP_HASH        = 14
+
+VOMP_PLAYPAUSE   = 201
+
+unhandled_map =  { 
+       'KEY_POWER': VOMP_POWER,'KEY_HOME': 0, 'KEY_TV': VOMP_TV, 'KEY_VIDEO': VOMP_VIDEOS, 'KEY_AUDIO': VOMP_MUSIC, 'KEY_CAMERA': VOMP_PICTURES
+       }
+
+remote_map = { 
+       'KEY_EPG': VOMP_GUIDE,'KEY_RADIO': VOMP_RADIO,'KEY_UP': VOMP_UP,'KEY_DOWN': VOMP_DOWN,
+       'KEY_LEFT': VOMP_LEFT,'KEY_RIGHT': VOMP_RIGHT,'KEY_OK': VOMP_OK,'KEY_EXIT': VOMP_BACK,
+       'KEY_MENU': VOMP_MENU,'KEY_PREVIOUS': VOMP_PREVCHANNEL,'KEY_MUTE': VOMP_MUTE,
+       'KEY_VOLUMEUP': VOMP_VOLUMEUP,'KEY_VOLUMEDOWN': VOMP_VOLUMEDOWN,'KEY_CHANNELUP': VOMP_CHANNELUP,'KEY_CHANNELDOWN': VOMP_CHANNELDOWN,
+       'KEY_RECORD': VOMP_RECORD,'KEY_STOP': VOMP_STOP,'KEY_PLAY': VOMP_PLAY,'KEY_REWIND': VOMP_REVERSE,'KEY_FORWARD': VOMP_FORWARD,
+       'KEY_FRAMEBACK': VOMP_SKIPBACK,'KEY_PAUSE': VOMP_PAUSE,'KEY_FRAMEFORWARD': VOMP_SKIPFORWARD,
+       'KEY_1': VOMP_ONE,'KEY_2': VOMP_TWO,'KEY_3': VOMP_THREE,'KEY_4': VOMP_FOUR,'KEY_5': VOMP_FIVE,
+       'KEY_6': VOMP_SIX,'KEY_7': VOMP_SEVEN,'KEY_8': VOMP_EIGHT,'KEY_9': VOMP_NINE,
+       'KEY_KPASTERISK': VOMP_STAR,'KEY_0': VOMP_ZERO,'KEY_KPPLUS': VOMP_HASH,
+       'KEY_RED': VOMP_RED,'KEY_GREEN': VOMP_GREEN,'KEY_YELLOW': VOMP_YELLOW,'KEY_BLUE': VOMP_BLUE
+}
+
+repeaters = [ VOMP_CHANNELUP, VOMP_CHANNELDOWN ]
+vomp_started = False
+debug = False
+
+def signal_handler(signum, frame):
+       if debug: print 'Exiting...'
+       pylirc.exit()
+       os._exit(0)
+
+def process_lirc_event():
+       global vomp_started
+       
+       s = pylirc.nextcode(1)
+                       
+       for code in s:
+               vompmessage = ''
+               if debug: print "Command: %s, Repeat: %d" % (code["config"], code["repeat"])
+               mapped_code = None
+               try:
+                       mapped_code = '%i' % remote_map[code["config"]]
+               except:
+                       pass
+
+               if mapped_code != None:
+                       vompmessage = mapped_code
+               elif code["config"] == 'KEY_POWER':
+                       if code["repeat"] == 0:
+                               if vomp_started:
+                                       os.system('killall vompclient')
+                                       time.sleep(1)
+                                       os.system('killall -9 vompclient')
+                                       #os.system('/opt/vc/bin/tvservice -o')
+                                       vomp_started = False
+                               else:
+                                       #os.system('/opt/vc/bin/tvservice -p')
+                                       os.system('vompclient')
+                                       vomp_started = True
+               else:
+                       sys.stderr.write('Unknown key: %s\n' % code["config"])
+
+               if (len(vompmessage) > 0) and ((code["repeat"] == 0) or (vompmessage in repeaters)):
+                       vomp_client.sendto(vompmessage, (vomp_host, vomp_port))
+                                       
+if __name__ == "__main__":
+       try:
+               vomp_client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+       except socket.error, (value,message):
+               sys.stderr.write('Failed to open UDP socket: "%s"\n' % message)
+               sys.exit(1) 
+       
+       if pylirc.init('vompilirc', os.path.join('/etc/lirc/lircrc')):
+               pylirc.blocking(1)
+
+               signal.signal(signal.SIGINT, signal_handler)
+               signal.signal(signal.SIGTERM, signal_handler)
+               
+               while True:
+                       process_lirc_event()
+       else:
+               sys.stderr.write('Failed to init pylirc.\n')
+               sys.exit(2)