scripts/modules.d/550-LIRC-Hauppauge-Amarok.py

00001     #***
00002   #*********************************************************************
00003 #*************************************************************************
00004 #*** 
00005 #*** GizmoDaemon Config Script
00006 #***    LIRC Hauppauge Amarok config
00007 #***
00008 #*****************************************
00009   #*****************************************
00010     #***
00011 
00012 """
00013 
00014   Copyright (c) 2007, Gizmo Daemon Team
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 """
00028 
00029 ############################
00030 # Imports
00031 ##########################
00032 
00033 from GizmoDaemon import *
00034 from GizmoScriptRunningApplication import *
00035 import subprocess
00036 
00037 ENABLED = True
00038 VERSION_NEEDED = 3.2
00039 INTERESTED_CLASSES = [GizmoEventClass.LIRC]
00040 INTERESTED_APPLICATION = "amarokapp"
00041 USES_LIRC_REMOTES = ["Hauppauge_350"]
00042 
00043 ############################
00044 # LIRCHauppaugeAmarok Class definition
00045 ##########################
00046 
00047 class LIRCHauppaugeAmarok(GizmoScriptRunningApplication):
00048         """
00049         Amarok LIRC Hauppauge Event Mapping
00050         """
00051         
00052         ############################
00053         # Public Functions
00054         ##########################
00055                         
00056         def onDeviceEvent(self, Event, Gizmo = None):
00057                 """
00058                 Called from Base Class' onEvent method.
00059                 See GizmodDispatcher.onEvent documention for an explanation of this function
00060                 """
00061                                 
00062                 # if the event isn't from the remote we're interested in don't handle it
00063                 if Event.Remote not in USES_LIRC_REMOTES:
00064                         return False
00065 
00066                 # process the key
00067                 if   Event.Button == "Go":
00068                         return False
00069                 elif Event.Button == "Power":
00070                         return False
00071                 elif Event.Button == "TV":
00072                         return False
00073                 elif Event.Button == "Videos":
00074                         return False
00075                 elif Event.Button == "Music":                   
00076                         return False
00077                 elif Event.Button == "Pictures":
00078                         return False
00079                 elif Event.Button == "Guide":
00080                         return False
00081                 elif Event.Button == "Up":
00082                         return False
00083                 elif Event.Button == "Radio":
00084                         return False
00085                 elif Event.Button == "Left":
00086                         subprocess.Popen(["amarok", "--previous"])
00087                         return True
00088                 elif Event.Button == "OK":
00089                         return False
00090                 elif Event.Button == "Right":
00091                         subprocess.Popen(["amarok", "--next"])
00092                         return True
00093                 elif Event.Button == "Back/Exit":
00094                         return False
00095                 elif Event.Button == "Down":
00096                         return False
00097                 elif Event.Button == "Menu/i":
00098                         return False
00099                 elif Event.Button == "Vol+":
00100                         return False
00101                 elif Event.Button == "Vol-":
00102                         return False
00103                 elif Event.Button == "Prev.Ch":
00104                         return False
00105                 elif Event.Button == "Mute":
00106                         return False
00107                 elif Event.Button == "Ch+":
00108                         return False
00109                 elif Event.Button == "Ch-":
00110                         return False
00111                 elif Event.Button == "Record":
00112                         return False
00113                 elif Event.Button == "Stop":
00114                         subprocess.Popen(["amarok", "--stop"])
00115                         return True
00116                 elif Event.Button == "Rewind":
00117                         return False
00118                 elif Event.Button == "Play":
00119                         subprocess.Popen(["amarok", "--play-pause"])
00120                         return True
00121                 elif Event.Button == "Forward":
00122                         return False
00123                 elif Event.Button == "Replay/SkipBackward":
00124                         subprocess.Popen(["amarok", "--previous"])
00125                         return True
00126                 elif Event.Button == "Pause":
00127                         subprocess.Popen(["amarok", "--play-pause"])
00128                         return True
00129                 elif Event.Button == "SkipForward":
00130                         subprocess.Popen(["amarok", "--next"])
00131                         return True
00132                 elif Event.Button == "1":
00133                         return False
00134                 elif Event.Button == "2":
00135                         return False
00136                 elif Event.Button == "3":
00137                         return False
00138                 elif Event.Button == "4":
00139                         return False
00140                 elif Event.Button == "5":
00141                         return False
00142                 elif Event.Button == "6":
00143                         return False
00144                 elif Event.Button == "7":
00145                         return False
00146                 elif Event.Button == "8":
00147                         return False
00148                 elif Event.Button == "9":
00149                         return False
00150                 elif Event.Button == "Asterix":
00151                         return False
00152                 elif Event.Button == "0":
00153                         return False
00154                 elif Event.Button == "#":
00155                         return False
00156                 elif Event.Button == "Red":
00157                         return False
00158                 elif Event.Button == "Green":
00159                         return False
00160                 elif Event.Button == "Yellow":
00161                         return False
00162                 elif Event.Button == "Blue":
00163                         return False
00164                 else:
00165                         # unmatched event, keep processing
00166                         return False                            
00167                                 
00168         ############################
00169         # Private Functions
00170         ##########################
00171 
00172         def __init__(self):
00173                 """ 
00174                 Default Constructor
00175                 """
00176                 
00177                 GizmoScriptRunningApplication.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES, INTERESTED_APPLICATION)
00178 
00179 ############################
00180 # LIRCHauppaugeAmarok class end
00181 ##########################
00182 
00183 # register the user script
00184 LIRCHauppaugeAmarok()

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3