scripts/modules.d/201-Powermate-Compiz.py

00001     #***
00002   #*********************************************************************
00003 #*************************************************************************
00004 #*** 
00005 #*** GizmoDaemon Config Script
00006 #***    Powermate Compiz config
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 # Imports
00031 ##########################
00032 
00033 from GizmoDaemon import *
00034 from GizmoScriptDefault import *
00035 import time
00036 
00037 ENABLED = True
00038 VERSION_NEEDED = 3.3
00039 INTERESTED_CLASSES = [GizmoEventClass.Powermate]
00040 
00041 ############################
00042 # PowermateCompiz Class definition
00043 ##########################
00044 
00045 class PowermateCompiz(GizmoScriptDefault):
00046         """
00047         Compiz Powermate Event Mapping
00048         """
00049         
00050         ############################
00051         # Public Functions
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                 if self.Unfolded and Event.Type == GizmoEventType.EV_REL:
00061                         if Event.Value < 0:
00062                                 for repeat in range(abs(Event.Value)):
00063                                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFT)
00064                         else:
00065                                 for repeat in range(abs(Event.Value)):
00066                                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_RIGHT)
00067                         return True
00068                         
00069                 return False
00070                 
00071         def onDeviceEventButtonTimeout(self, Gizmo):
00072                 """
00073                 Called when a Powermate's button times out
00074                 
00075                 This is generated from 200-Powermate-ButtonTimeout.py
00076                 """
00077                 
00078                 #print "Button Timeout in [" + self.__class__.__name__ + "] from [" + str(Gizmo.Type) + " " + str(Gizmo.DeviceClassID) + "]"
00079                 Gizmod.Keyboards[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTCTRL, 1)
00080                 Gizmod.Keyboards[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTALT, 1)
00081                 Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEDOWN)
00082                 self.Unfolded = True
00083                 
00084                 return True
00085                 
00086         def onDeviceEventEaten(self, Event, Gizmo):
00087                 """
00088                 Called when a Powermate's button is released after timing out
00089                 
00090                 This is generated from 200-Powermate-ButtonTimeout.py
00091                 """
00092                 
00093                 #print "Device Event Eaten in [" + self.__class__.__name__ + "] from [" + str(Gizmo.Type) + " " + str(Gizmo.DeviceClassID) + "]"
00094                 if self.Unfolded and Event.Type == GizmoEventType.EV_KEY and Event.Value == 0:
00095                         Gizmod.Keyboards[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTCTRL, 0)
00096                         Gizmod.Keyboards[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTALT, 0)
00097                         self.Unfolded = False
00098                         return True
00099                         
00100                 return False
00101                 
00102         ############################
00103         # Private Functions
00104         ##########################
00105 
00106         def __init__(self):
00107                 """ 
00108                 Default Constructor
00109                 """
00110                 
00111                 GizmoScriptDefault.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES)
00112                 self.Unfolded = False
00113 
00114 ############################
00115 # PowermateCompiz class end
00116 ##########################
00117 
00118 # register the user script
00119 PowermateCompiz()

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3