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.ATIX10]
00040 INTERESTED_WINDOWS = ["mythfrontend"]
00041 POWER_APPLICATION = "mythfrontend"
00042
00043
00044
00045
00046
00047 class ATIX10MythTV(GizmoScriptActiveApplication):
00048 """
00049 MythTV ATIX10 Event Mapping
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.Value == 0:
00064 return False
00065
00066
00067 if Event.Code == GizmoKey.KEY_POWER:
00068
00069 subprocess.Popen(["killall", "mythfrontend"])
00070 return True
00071 elif Event.Code == GizmoKey.KEY_A:
00072 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_A)
00073 return True
00074 elif Event.Code == GizmoKey.KEY_B:
00075 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_B)
00076 return True
00077 elif Event.Code == GizmoKey.KEY_PROG1:
00078 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SLASH, [GizmoKey.KEY_RIGHTSHIFT])
00079 return True
00080 elif Event.Code == GizmoKey.KEY_PROG2:
00081 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_SLASH)
00082 return True
00083 elif Event.Code == GizmoKey.KEY_WWW:
00084 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_V)
00085 return True
00086 elif Event.Code == GizmoKey.KEY_BOOKMARKS:
00087 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_N)
00088 return True
00089 elif Event.Code == GizmoKey.KEY_EDIT:
00090 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_I)
00091 return True
00092 elif Event.Code == GizmoKey.KEY_VOLUMEUP:
00093 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHTBRACE)
00094 return True
00095 elif Event.Code == GizmoKey.KEY_VOLUMEDOWN:
00096 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTBRACE)
00097 return True
00098 elif Event.Code == GizmoKey.KEY_CHANNELUP:
00099 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_UP)
00100 return True
00101 elif Event.Code == GizmoKey.KEY_CHANNELDOWN:
00102 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOWN)
00103 return True
00104 elif Event.Code == GizmoKey.KEY_MENU:
00105 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_M)
00106 return True
00107 elif Event.Code == GizmoKey.KEY_KPENTER:
00108 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_END)
00109 return True
00110 elif Event.Code == GizmoKey.KEY_C:
00111 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_C)
00112 return True
00113 elif Event.Code == GizmoKey.KEY_D:
00114 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_D)
00115 return True
00116 elif Event.Code == GizmoKey.KEY_COFFEE:
00117 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ESC)
00118 return True
00119 elif Event.Code == GizmoKey.KEY_FRONT:
00120 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_HOME)
00121 return True
00122 elif Event.Code == GizmoKey.KEY_E:
00123 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_H)
00124 return True
00125 elif Event.Code == GizmoKey.KEY_F:
00126 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_M)
00127 return True
00128 elif Event.Code == GizmoKey.KEY_REWIND:
00129 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_COMMA, [GizmoKey.KEY_RIGHTSHIFT])
00130 return True
00131 elif Event.Code == GizmoKey.KEY_PLAYCD:
00132 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_P)
00133 return True
00134 elif Event.Code == GizmoKey.KEY_FORWARD:
00135 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOT, [GizmoKey.KEY_RIGHTSHIFT])
00136 return True
00137 elif Event.Code == GizmoKey.KEY_RECORD:
00138 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_R)
00139 return True
00140 elif Event.Code == GizmoKey.KEY_STOP:
00141 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_S)
00142 return True
00143 elif Event.Code == GizmoKey.KEY_PAUSE:
00144 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_P)
00145 return True
00146 else:
00147
00148 return False
00149
00150 def onEvent(self, Event, Gizmo = None):
00151 """
00152 Overloading Base Class' onEvent method!
00153 Make sure to call it!
00154 """
00155
00156
00157
00158
00159
00160 if Event.Class in INTERESTED_CLASSES \
00161 and Event.Value != 0 \
00162 and Event.Code == GizmoKey.KEY_POWER \
00163 and Gizmod.isProcessRunning(POWER_APPLICATION) < 0:
00164 subprocess.Popen([POWER_APPLICATION])
00165 Gizmod.updateProcessTree()
00166 return False
00167
00168
00169 return GizmoScriptActiveApplication.onEvent(self, Event, Gizmo)
00170
00171
00172
00173
00174
00175 def __init__(self):
00176 """
00177 Default Constructor
00178 """
00179
00180 GizmoScriptActiveApplication.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES, INTERESTED_WINDOWS)
00181
00182
00183
00184
00185
00186
00187 ATIX10MythTV()