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 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 = ["mceusb", "mceusb2"]
00042
00043
00044
00045
00046
00047 class LIRCMceUSB2Amarok(GizmoScriptRunningApplication):
00048 """
00049 Amarok 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 return False
00069 elif Event.Button == "TV":
00070 return False
00071 elif Event.Button == "Music":
00072 return False
00073 elif Event.Button == "Pictures":
00074 return False
00075 elif Event.Button == "Videos":
00076 return False
00077 elif Event.Button == "Stop":
00078 subprocess.Popen(["amarok", "--stop"])
00079 return True
00080 elif Event.Button == "Record":
00081 return False
00082 elif Event.Button == "Pause":
00083 subprocess.Popen(["amarok", "--play-pause"])
00084 return True
00085 elif Event.Button == "Rewind":
00086 subprocess.Popen(["amarok", "--previous"])
00087 return True
00088 elif Event.Button == "Play":
00089 subprocess.Popen(["amarok", "--play-pause"])
00090 return True
00091 elif Event.Button == "Forward":
00092 subprocess.Popen(["amarok", "--next"])
00093 return True
00094 elif Event.Button == "Replay":
00095 subprocess.Popen(["amarok", "--stop"])
00096 subprocess.Popen(["amarok", "--play"])
00097 return True
00098 elif Event.Button == "Back":
00099 return False
00100 elif Event.Button == "Up":
00101 return False
00102 elif Event.Button == "Skip":
00103 subprocess.Popen(["amarok", "--next"])
00104 return True
00105 elif Event.Button == "More":
00106 return False
00107 elif Event.Button == "Left":
00108 subprocess.Popen(["amarok", "--previous"])
00109 return True
00110 elif Event.Button == "OK":
00111 return False
00112 elif Event.Button == "Right":
00113 subprocess.Popen(["amarok", "--next"])
00114 return True
00115 elif Event.Button == "Down":
00116 return False
00117 elif Event.Button == "VolUp":
00118 return False
00119 elif Event.Button == "VolDown":
00120 return False
00121 elif Event.Button == "Home":
00122 return False
00123 elif Event.Button == "ChanUp":
00124 return False
00125 elif Event.Button == "ChanDown":
00126 return False
00127 elif Event.Button == "RecTV":
00128 return False
00129 elif Event.Button == "Mute":
00130 return False
00131 elif Event.Button == "DVD":
00132 return False
00133 elif Event.Button == "Guide":
00134 return False
00135 elif Event.Button == "LiveTV":
00136 return False
00137 elif Event.Button == "One":
00138 return False
00139 elif Event.Button == "Two":
00140 return False
00141 elif Event.Button == "Three":
00142 return False
00143 elif Event.Button == "Four":
00144 return False
00145 elif Event.Button == "Five":
00146 return False
00147 elif Event.Button == "Six":
00148 return False
00149 elif Event.Button == "Seven":
00150 return False
00151 elif Event.Button == "Eight":
00152 return False
00153 elif Event.Button == "Nine":
00154 return False
00155 elif Event.Button == "Star":
00156 return False
00157 elif Event.Button == "Zero":
00158 return False
00159 elif Event.Button == "Hash":
00160 return False
00161 elif Event.Button == "Clear":
00162 return False
00163 elif Event.Button == "Enter":
00164 return False
00165 else:
00166
00167 return False
00168
00169
00170
00171
00172
00173 def __init__(self):
00174 """
00175 Default Constructor
00176 """
00177
00178 GizmoScriptRunningApplication.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES, INTERESTED_APPLICATION)
00179
00180
00181
00182
00183
00184
00185 LIRCMceUSB2Amarok()