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 GizmoScriptDefault import *
00035 from GizmoScriptAltTabber import *
00036 import subprocess
00037
00038 ENABLED = True
00039 VERSION_NEEDED = 3.2
00040 INTERESTED_CLASSES = [GizmoEventClass.ATIX10]
00041
00042
00043
00044
00045
00046 class ATIX10Default(GizmoScriptDefault):
00047 """
00048 Default ATIX10 Event Mapping
00049 """
00050
00051
00052
00053
00054
00055 def onDeviceEvent(self, Event, Gizmo = None):
00056 """
00057 Called from Base Class' onEvent method.
00058 See GizmodDispatcher.onEvent documention for an explanation of this function
00059 """
00060
00061
00062 if Event.Code == GizmoKey.BTN_LEFT:
00063
00064 Gizmod.Mice[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_BTN_LFT, Event.Value)
00065 return True
00066 elif Event.Code == GizmoKey.BTN_RIGHT:
00067
00068 Gizmod.Mice[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_BTN_RIGHT, Event.Value)
00069 return True
00070 elif Event.Type == GizmoEventType.EV_REL:
00071
00072 Gizmod.Mice[0].createEventRaw(GizmoEventType.EV_REL, Event.Code, Event.Value)
00073 return True
00074 elif Event.Value != 0:
00075
00076 if Event.Code == GizmoKey.KEY_WWW:
00077 subprocess.Popen(["firefox", "http://gizmod.sf.net"])
00078 return True
00079 elif Event.Code == GizmoKey.KEY_A:
00080 subprocess.Popen(["amarok"])
00081 return True
00082 elif Event.Code == GizmoKey.KEY_DVD:
00083 subprocess.Popen(["xine", "-f", "--no-splash", "dvd:/"])
00084 return True
00085 elif Event.Code == GizmoKey.KEY_POWER:
00086 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_F4, [GizmoKey.KEY_RIGHTALT])
00087 return True
00088 elif Event.Code == GizmoKey.KEY_BOOKMARKS:
00089 self.AltTabber.doAltTab()
00090 return True
00091 elif Event.Code == GizmoKey.KEY_VOLUMEUP:
00092 Gizmod.DefaultMixerVolume.VolumePlayback = Gizmod.DefaultMixerVolume.VolumePlayback + 1
00093 return True
00094 elif Event.Code == GizmoKey.KEY_VOLUMEDOWN:
00095 Gizmod.DefaultMixerVolume.VolumePlayback = Gizmod.DefaultMixerVolume.VolumePlayback - 1
00096 return True
00097 elif Event.Code == GizmoKey.KEY_MUTE:
00098 Gizmod.toggleMuteAllCards()
00099 return True
00100 elif Event.Code == GizmoKey.KEY_LEFT:
00101 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT)
00102 return True
00103 elif Event.Code == GizmoKey.KEY_RIGHT:
00104 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT)
00105 return True
00106 elif Event.Code == GizmoKey.KEY_UP:
00107 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_UP)
00108 return True
00109 elif Event.Code == GizmoKey.KEY_DOWN:
00110 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_DOWN)
00111 return True
00112 elif Event.Code == GizmoKey.KEY_ENTER:
00113 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ENTER)
00114 return True
00115 elif Event.Code == GizmoKey.KEY_OK:
00116 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_ENTER)
00117 return True
00118 elif Event.Code == GizmoKey.KEY_1:
00119 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_1)
00120 return True
00121 elif Event.Code == GizmoKey.KEY_2:
00122 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_2)
00123 return True
00124 elif Event.Code == GizmoKey.KEY_3:
00125 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_3)
00126 return True
00127 elif Event.Code == GizmoKey.KEY_4:
00128 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_4)
00129 return True
00130 elif Event.Code == GizmoKey.KEY_5:
00131 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_5)
00132 return True
00133 elif Event.Code == GizmoKey.KEY_6:
00134 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_6)
00135 return True
00136 elif Event.Code == GizmoKey.KEY_7:
00137 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_7)
00138 return True
00139 elif Event.Code == GizmoKey.KEY_8:
00140 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_8)
00141 return True
00142 elif Event.Code == GizmoKey.KEY_9:
00143 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_9)
00144 return True
00145 elif Event.Code == GizmoKey.KEY_0:
00146 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_0)
00147 return True
00148 else:
00149
00150 return False
00151
00152 return False
00153
00154
00155
00156
00157
00158 def __init__(self):
00159 """
00160 Default Constructor
00161 """
00162
00163 GizmoScriptDefault.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES)
00164 self.AltTabber = GizmoScriptAltTabber()
00165
00166
00167
00168
00169
00170
00171 ATIX10Default()