scripts/modules.d/599-LIRC-Hauppauge-Default.py

00001     #***
00002   #*********************************************************************
00003 #*************************************************************************
00004 #*** 
00005 #*** GizmoDaemon Config Script
00006 #***    LIRCHauppauge Default 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 GizmoScriptDefault import *
00035 from GizmoScriptAltTabber import *
00036 import subprocess
00037 
00038 ENABLED = True
00039 VERSION_NEEDED = 3.2
00040 INTERESTED_CLASSES = [GizmoEventClass.LIRC]
00041 USES_LIRC_REMOTES = ["Hauppauge_350"]
00042 
00043 ############################
00044 # LIRCHauppaugeDefault Class definition
00045 ##########################
00046 
00047 class LIRCHauppaugeDefault(GizmoScriptDefault):
00048         """
00049         Default LIRC Event Mapping for the Hauppauge remote
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                         self.AltTabber.doAltTab()
00069                         return True
00070                 elif Event.Button == "Power":
00071                         return False
00072                 elif Event.Button == "TV":
00073                         return False
00074                 elif Event.Button == "Videos":
00075                         return False
00076                 elif Event.Button == "Music":
00077                         return False
00078                 elif Event.Button == "Pictures":
00079                         subprocess.Popen(["xset", "dpms", "force", "off"])
00080                         return True
00081                 elif Event.Button == "Guide":
00082                         return False
00083                 elif Event.Button == "Up":
00084                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_UP)
00085                         return True
00086                 elif Event.Button == "Radio":
00087                         return False
00088                 elif Event.Button == "Left":
00089                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT)
00090                         return True
00091                 elif Event.Button == "OK":
00092                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ENTER)
00093                         return True
00094                 elif Event.Button == "Right":
00095                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT)
00096                         return True
00097                 elif Event.Button == "Back/Exit":
00098                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ESC)
00099                         return True
00100                 elif Event.Button == "Down":
00101                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOWN)
00102                         return True
00103                 elif Event.Button == "Menu/i":
00104                         return False
00105                 elif Event.Button == "Vol+":
00106                         if Gizmod.DefaultMixerVolume:
00107                                 Gizmod.DefaultMixerVolume.VolumePlaybackPercent = Gizmod.DefaultMixerVolume.VolumePlaybackPercent + 2.5
00108                         return True
00109                 elif Event.Button == "Vol-":
00110                         if Gizmod.DefaultMixerVolume:
00111                                 Gizmod.DefaultMixerVolume.VolumePlaybackPercent = Gizmod.DefaultMixerVolume.VolumePlaybackPercent - 2.5
00112                         return True
00113                 elif Event.Button == "Prev.Ch":
00114                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_BACKSPACE)
00115                         return True
00116                 elif Event.Button == "Mute":
00117                         Gizmod.toggleMuteAllCards()
00118                         return True
00119                 elif Event.Button == "Ch+":
00120                         return False
00121                 elif Event.Button == "Ch-":
00122                         return False
00123                 elif Event.Button == "Record":
00124                         return False
00125                 elif Event.Button == "Stop":
00126                         return False
00127                 elif Event.Button == "Rewind":
00128                         return False
00129                 elif Event.Button == "Play":
00130                         return False
00131                 elif Event.Button == "Forward":
00132                         return False
00133                 elif Event.Button == "Replay/SkipBackward":
00134                         return False
00135                 elif Event.Button == "Pause":
00136                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_P)
00137                         return True
00138                 elif Event.Button == "SkipForward":
00139                         return False
00140                 elif Event.Button == "1":
00141                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_1)
00142                         return True
00143                 elif Event.Button == "2":
00144                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_2)
00145                         return True
00146                 elif Event.Button == "3":
00147                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_3)
00148                         return True
00149                 elif Event.Button == "4":
00150                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_4)
00151                         return True
00152                 elif Event.Button == "5":
00153                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_5)
00154                         return True
00155                 elif Event.Button == "6":
00156                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_6)
00157                         return True
00158                 elif Event.Button == "7":
00159                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_7)
00160                         return True
00161                 elif Event.Button == "8":
00162                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_8)
00163                         return True
00164                 elif Event.Button == "9":
00165                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_9)
00166                         return True
00167                 elif Event.Button == "Asterix":
00168                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_F12, [GizmoKey.KEY_LEFTMETA])
00169                         return True
00170                 elif Event.Button == "0":
00171                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_0)
00172                         return True
00173                 elif Event.Button == "#":
00174                         return False
00175                 elif Event.Button == "Red":
00176                         return False
00177                 elif Event.Button == "Green":
00178                         return False
00179                 elif Event.Button == "Yellow":
00180                         return False
00181                 elif Event.Button == "Blue":
00182                         return False
00183                 else:
00184                         # unmatched event, keep processing
00185                         return False                            
00186         
00187         ############################
00188         # Private Functions
00189         ##########################
00190 
00191         def __init__(self):
00192                 """ 
00193                 Default Constructor
00194                 """
00195                 
00196                 GizmoScriptDefault.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES)
00197                 self.AltTabber = GizmoScriptAltTabber()
00198 
00199 ############################
00200 # LIRCHauppaugeDefault class end
00201 ##########################
00202 
00203 # register the user script
00204 LIRCHauppaugeDefault()

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