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 import subprocess
00036
00037 ENABLED = True
00038 VERSION_NEEDED = 3.2
00039 INTERESTED_CLASSES = [GizmoEventClass.Standard]
00040
00041
00042
00043
00044
00045 class KeyboardDefault(GizmoScriptDefault):
00046 """
00047 Default Fancy Keyboard Event Mapping
00048 """
00049
00050
00051
00052
00053
00054 def onDeviceEvent(self, Event, Gizmo = None):
00055 """
00056 Called from Base Class' onEvent method.
00057 See GizmodDispatcher.onEvent documention for an explanation of this function
00058 """
00059
00060
00061 if Event.Code == GizmoKey.KEY_EJECTCD or \
00062 Event.Code == GizmoKey.KEY_EJECTCLOSECD:
00063 subprocess.Popen(["eject", "/dev/dvd"])
00064 subprocess.Popen(["eject", "/dev/cdrom"])
00065 return True
00066 elif Event.Code == GizmoKey.KEY_CLOSECD:
00067 subprocess.Popen(["mount", "/media/dvd"])
00068 subprocess.Popen(["mount", "/media/cdrom"])
00069 subprocess.Popen(["mount", "/mnt/dvd"])
00070 subprocess.Popen(["mount", "/mnt/cdrom"])
00071 return True
00072 elif Event.Code == GizmoKey.KEY_WWW:
00073 subprocess.Popen(["firefox", "http://gizmod.sf.net"])
00074 return True
00075 elif Event.Code == GizmoKey.KEY_VOLUMEUP:
00076 Gizmod.DefaultMixerVolume.VolumePlayback = Gizmod.DefaultMixerVolume.VolumePlayback + 1
00077 return True
00078 elif Event.Code == GizmoKey.KEY_VOLUMEDOWN:
00079 Gizmod.DefaultMixerVolume.VolumePlayback = Gizmod.DefaultMixerVolume.VolumePlayback - 1
00080 return True
00081 elif Event.Code == GizmoKey.KEY_MUTE:
00082 Gizmod.toggleMuteAllCards()
00083 return True
00084 elif Event.Code == GizmoKey.KEY_NEXTSONG:
00085
00086 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT, [GizmoKey.KEY_LEFTCTRL, GizmoKey.KEY_LEFTALT])
00087 return True
00088 elif Event.Code == GizmoKey.KEY_PREVIOUSSONG:
00089
00090 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT, [GizmoKey.KEY_LEFTCTRL, GizmoKey.KEY_LEFTALT])
00091 return True
00092 else:
00093
00094 return False
00095
00096
00097
00098
00099
00100 def __init__(self):
00101 """
00102 Default Constructor
00103 """
00104
00105 GizmoScriptDefault.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES)
00106
00107
00108
00109
00110
00111
00112 KeyboardDefault()