scripts/modules.d/511-LIRC-Hauppauge-MPlayer.py

00001     #***
00002   #*********************************************************************
00003 #*************************************************************************
00004 #*** 
00005 #*** GizmoDaemon Config Script
00006 #***    LIRCHauppauge MPlayer 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 GizmoScriptActiveApplication import *
00035 import subprocess
00036 import sys
00037 
00038 ENABLED = True
00039 VERSION_NEEDED = 3.2
00040 INTERESTED_CLASSES = [GizmoEventClass.LIRC]
00041 INTERESTED_WINDOWS = ["mplayer"]
00042 USES_LIRC_REMOTES = ["Hauppauge_350"]
00043 
00044 ############################
00045 # LIRCHauppaugeMPlayer Class definition
00046 ##########################
00047 
00048 class LIRCHauppaugeMPlayer(GizmoScriptActiveApplication):
00049         """
00050         MPlayer LIRC Event Mapping for the Hauppauge remote
00051         """
00052         
00053         ############################
00054         # Public Functions
00055         ##########################
00056                         
00057         def onDeviceEvent(self, Event, Gizmo = None):
00058                 """
00059                 Called from Base Class' onEvent method.
00060                 See GizmodDispatcher.onEvent documention for an explanation of this function
00061                 """
00062                 
00063                 # if the event isn't from the remote we're interested in don't handle it
00064                 if Event.Remote not in USES_LIRC_REMOTES:
00065                         return False
00066 
00067                 # process the key
00068                 if   Event.Button == "Go":
00069                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_A)
00070                         return True
00071                 elif Event.Button == "Power":
00072                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ESC)
00073                         return True
00074                 elif Event.Button == "TV":
00075                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_B)
00076                         return True
00077                 elif Event.Button == "Videos":
00078                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_V)
00079                         return True
00080                 elif Event.Button == "Music":                   
00081                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SLASH, [GizmoKey.KEY_RIGHTSHIFT])
00082                         return True
00083                 elif Event.Button == "Pictures":
00084                         return False
00085                 elif Event.Button == "Guide":
00086                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_S)
00087                         return True
00088                 elif Event.Button == "Up":
00089                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_UP)
00090                         return True
00091                 elif Event.Button == "Radio":
00092                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_N)
00093                         return True
00094                 elif Event.Button == "Left":
00095                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT)
00096                         return True
00097                 elif Event.Button == "OK":
00098                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ENTER)
00099                         return True
00100                 elif Event.Button == "Right":
00101                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT)
00102                         return True
00103                 elif Event.Button == "Back/Exit":
00104                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ESC)
00105                         return True
00106                 elif Event.Button == "Down":
00107                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOWN)
00108                         return True
00109                 elif Event.Button == "Menu/i":
00110                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_O)
00111                         return True
00112                 elif Event.Button == "Vol+":
00113                         return False
00114                 elif Event.Button == "Vol-":
00115                         return False
00116                 elif Event.Button == "Prev.Ch":
00117                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_H)
00118                         return True
00119                 elif Event.Button == "Mute":
00120                         return False
00121                 elif Event.Button == "Ch+":
00122                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_UP)
00123                         return True
00124                 elif Event.Button == "Ch-":
00125                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOWN)
00126                         return True
00127                 elif Event.Button == "Record":
00128                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_R)
00129                         return True
00130                 elif Event.Button == "Stop":
00131                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_S)
00132                         return True
00133                 elif Event.Button == "Rewind":
00134                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_COMMA, [GizmoKey.KEY_RIGHTSHIFT])
00135                         return True
00136                 elif Event.Button == "Play":
00137                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SPACE)
00138                         return True
00139                 elif Event.Button == "Forward":
00140                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOT, [GizmoKey.KEY_RIGHTSHIFT])
00141                         return True
00142                 elif Event.Button == "Replay/SkipBackward":
00143                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEDOWN)
00144                         return True
00145                 elif Event.Button == "Pause":
00146                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SPACE)
00147                         return True
00148                 elif Event.Button == "SkipForward":
00149                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEUP)
00150                         return True
00151                 elif Event.Button == "1":
00152                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_1)
00153                         return True
00154                 elif Event.Button == "2":
00155                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_2)
00156                         return True
00157                 elif Event.Button == "3":
00158                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_3)
00159                         return True
00160                 elif Event.Button == "4":
00161                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_4)
00162                         return True
00163                 elif Event.Button == "5":
00164                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_5)
00165                         return True
00166                 elif Event.Button == "6":
00167                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_6)
00168                         return True
00169                 elif Event.Button == "7":
00170                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_7)
00171                         return True
00172                 elif Event.Button == "8":
00173                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_8)
00174                         return True
00175                 elif Event.Button == "9":
00176                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_9)
00177                         return True
00178                 elif Event.Button == "Asterix":
00179                         return False
00180                 elif Event.Button == "0":
00181                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_0)
00182                         return True
00183                 elif Event.Button == "#":
00184                         return False
00185                 elif Event.Button == "Red":
00186                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_END)
00187                         return True
00188                 elif Event.Button == "Green":
00189                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_HOME)
00190                         return True
00191                 elif Event.Button == "Yellow":
00192                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_C)
00193                         return True
00194                 elif Event.Button == "Blue":
00195                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_I)
00196                         return True
00197                 else:
00198                         # unmatched event, keep processing
00199                         return False                            
00200         
00201         ############################
00202         # Private Functions
00203         ##########################
00204 
00205         def __init__(self):
00206                 """ 
00207                 Default Constructor
00208                 """
00209                 
00210                 GizmoScriptActiveApplication.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES, INTERESTED_WINDOWS)
00211 
00212 ############################
00213 # LIRCHauppaugeMPlayer class end
00214 ##########################
00215 
00216 # register the user script
00217 LIRCHauppaugeMPlayer()

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