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

00001     #***
00002   #*********************************************************************
00003 #*************************************************************************
00004 #*** 
00005 #*** GizmoDaemon Config Script
00006 #***    LIRCMceUSB2 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 = ["mceusb", "mceusb2"]
00042 
00043 ############################
00044 # LIRCMceUSB2Default Class definition
00045 ##########################
00046 
00047 class LIRCMceUSB2Default(GizmoScriptDefault):
00048         """
00049         Default LIRC Event Mapping for the MceUSB2 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 == "Power":
00068                         return False
00069                 elif Event.Button == "TV":
00070                         return False
00071                 elif Event.Button == "Music":
00072                         return False
00073                 elif Event.Button == "Pictures":
00074                         subprocess.Popen(["xset", "dpms", "force", "off"])
00075                         return True
00076                 elif Event.Button == "Videos":
00077                         return False
00078                 elif Event.Button == "Stop":
00079                         return False
00080                 elif Event.Button == "Record":
00081                         return False
00082                 elif Event.Button == "Pause":
00083                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_P)
00084                         return True
00085                 elif Event.Button == "Rewind":
00086                         return False
00087                 elif Event.Button == "Play":
00088                         return False
00089                 elif Event.Button == "Forward":
00090                         return False
00091                 elif Event.Button == "Replay":
00092                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_BACKSPACE)
00093                         return True
00094                 elif Event.Button == "Back":
00095                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ESC)
00096                         return True
00097                 elif Event.Button == "Up":
00098                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_UP)
00099                         return True
00100                 elif Event.Button == "Skip":
00101                         return False
00102                 elif Event.Button == "More":
00103                         return False
00104                 elif Event.Button == "Left":
00105                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT)
00106                         return True
00107                 elif Event.Button == "OK":
00108                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ENTER)
00109                         return True
00110                 elif Event.Button == "Right":
00111                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT)
00112                         return True
00113                 elif Event.Button == "Down":
00114                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOWN)
00115                         return True
00116                 elif Event.Button == "VolUp":
00117                         if Gizmod.DefaultMixerVolume:
00118                                 Gizmod.DefaultMixerVolume.VolumePlaybackPercent = Gizmod.DefaultMixerVolume.VolumePlaybackPercent + 2.5
00119                         return True
00120                 elif Event.Button == "VolDown":
00121                         if Gizmod.DefaultMixerVolume:
00122                                 Gizmod.DefaultMixerVolume.VolumePlaybackPercent = Gizmod.DefaultMixerVolume.VolumePlaybackPercent - 2.5
00123                         return True
00124                 elif Event.Button == "Home":
00125                         self.AltTabber.doAltTab()
00126                         return True
00127                 elif Event.Button == "ChanUp":
00128                         return False
00129                 elif Event.Button == "ChanDown":
00130                         return False
00131                 elif Event.Button == "RecTV":
00132                         return False
00133                 elif Event.Button == "Mute":
00134                         Gizmod.toggleMuteAllCards()
00135                         return True
00136                 elif Event.Button == "DVD":
00137                         return False
00138                 elif Event.Button == "Guide":
00139                         return False
00140                 elif Event.Button == "LiveTV":
00141                         return False
00142                 elif Event.Button == "One":
00143                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_1)
00144                         return True
00145                 elif Event.Button == "Two":
00146                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_2)
00147                         return True
00148                 elif Event.Button == "Three":
00149                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_3)
00150                         return True
00151                 elif Event.Button == "Four":
00152                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_4)
00153                         return True
00154                 elif Event.Button == "Five":
00155                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_5)
00156                         return True
00157                 elif Event.Button == "Six":
00158                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_6)
00159                         return True
00160                 elif Event.Button == "Seven":
00161                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_7)
00162                         return True
00163                 elif Event.Button == "Eight":
00164                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_8)
00165                         return True
00166                 elif Event.Button == "Nine":
00167                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_9)
00168                         return True
00169                 elif Event.Button == "Star":
00170                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_F12, [GizmoKey.KEY_LEFTMETA])
00171                         return True
00172                 elif Event.Button == "Zero":
00173                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_0)
00174                         return True
00175                 elif Event.Button == "Hash":
00176                         return False
00177                 elif Event.Button == "Clear":
00178                         return False
00179                 elif Event.Button == "Enter":
00180                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ENTER)
00181                         return True
00182                 else:
00183                         # unmatched event, keep processing
00184                         return False                            
00185         
00186         ############################
00187         # Private Functions
00188         ##########################
00189 
00190         def __init__(self):
00191                 """ 
00192                 Default Constructor
00193                 """
00194                 
00195                 GizmoScriptDefault.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES)
00196                 self.AltTabber = GizmoScriptAltTabber()
00197 
00198 ############################
00199 # LIRCMceUSB2Default class end
00200 ##########################
00201 
00202 # register the user script
00203 LIRCMceUSB2Default()

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