00001
00002
00003
00004
00005
00006
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
00031
00032
00033 from GizmoDaemon import *
00034 from GizmoScriptActiveApplication import *
00035 import subprocess
00036
00037 ENABLED = True
00038 VERSION_NEEDED = 3.2
00039 INTERESTED_CLASSES = [GizmoEventClass.LIRC]
00040 INTERESTED_WINDOWS = ["mplayer"]
00041 USES_LIRC_REMOTES = ["mceusb", "mceusb2"]
00042
00043
00044
00045
00046
00047 class LIRCMceUSB2MPlayer(GizmoScriptActiveApplication):
00048 """
00049 MPlayer LIRC Event Mapping for the MceUSB2 remote
00050 """
00051
00052
00053
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
00063 if Event.Remote not in USES_LIRC_REMOTES:
00064 return False
00065
00066
00067 if Event.Button == "Power":
00068 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ESC)
00069 return True
00070 elif Event.Button == "TV":
00071 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_A)
00072 return True
00073 elif Event.Button == "Music":
00074 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_B)
00075 return True
00076 elif Event.Button == "Pictures":
00077 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_V)
00078 return True
00079 elif Event.Button == "Videos":
00080 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SLASH, [GizmoKey.KEY_RIGHTSHIFT])
00081 return True
00082 elif Event.Button == "Stop":
00083 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_S)
00084 return True
00085 elif Event.Button == "Record":
00086 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_R)
00087 return True
00088 elif Event.Button == "Pause":
00089 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SPACE)
00090 return True
00091 elif Event.Button == "Rewind":
00092 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT)
00093 return True
00094 elif Event.Button == "Play":
00095 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SPACE)
00096 return True
00097 elif Event.Button == "Forward":
00098 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT)
00099 return True
00100 elif Event.Button == "Replay":
00101 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEDOWN)
00102 return True
00103 elif Event.Button == "Back":
00104 return False
00105 elif Event.Button == "Up":
00106 return False
00107 elif Event.Button == "Skip":
00108 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEUP)
00109 return True
00110 elif Event.Button == "More":
00111 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_O)
00112 return True
00113 elif Event.Button == "Left":
00114 return False
00115 elif Event.Button == "OK":
00116 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SPACE)
00117 return True
00118 elif Event.Button == "Right":
00119 return False
00120 elif Event.Button == "Down":
00121 return False
00122 elif Event.Button == "VolUp":
00123 return False
00124 elif Event.Button == "VolDown":
00125 return False
00126 elif Event.Button == "Home":
00127 return False
00128 elif Event.Button == "ChanUp":
00129 return False
00130 elif Event.Button == "ChanDown":
00131 return False
00132 elif Event.Button == "RecTV":
00133 return False
00134 elif Event.Button == "Mute":
00135 return False
00136 elif Event.Button == "DVD":
00137 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_N)
00138 return True
00139 elif Event.Button == "Guide":
00140 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_S)
00141 return True
00142 elif Event.Button == "LiveTV":
00143 return False
00144 elif Event.Button == "One":
00145 return False
00146 elif Event.Button == "Two":
00147 return False
00148 elif Event.Button == "Three":
00149 return False
00150 elif Event.Button == "Four":
00151 return False
00152 elif Event.Button == "Five":
00153 return False
00154 elif Event.Button == "Six":
00155 return False
00156 elif Event.Button == "Seven":
00157 return False
00158 elif Event.Button == "Eight":
00159 return False
00160 elif Event.Button == "Nine":
00161 return False
00162 elif Event.Button == "Star":
00163 return False
00164 elif Event.Button == "Zero":
00165 return False
00166 elif Event.Button == "Hash":
00167 return False
00168 elif Event.Button == "Clear":
00169 return False
00170 elif Event.Button == "Enter":
00171 return False
00172 else:
00173
00174 return False
00175
00176
00177
00178
00179
00180 def __init__(self):
00181 """
00182 Default Constructor
00183 """
00184
00185 GizmoScriptActiveApplication.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES, INTERESTED_WINDOWS)
00186
00187
00188
00189
00190
00191
00192 LIRCMceUSB2MPlayer()