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 GizmoRegistrar import *
00035 from GizmoScriptEnableChecker import *
00036 import sys
00037
00038 ENABLED = True
00039 VERSION_NEEDED = 3.2
00040
00041
00042
00043
00044
00045 class RemoteControl(GizmoScriptEnableChecker):
00046 """
00047 Remote Control Event Mapping
00048 """
00049
00050
00051
00052
00053
00054 def onEvent(self, Event, Gizmo = None):
00055 """
00056 See GizmodDispatcher.onEvent documention for an explanation of this function
00057 """
00058
00059
00060 try:
00061 if not Event.Remote or not Gizmo:
00062 return False
00063 except AttributeError, msg:
00064
00065 return False
00066
00067 Registrar = GizmoRegistrar(Gizmo)
00068 if Registrar.DeviceType == DeviceType.Keyboard and len(Gizmod.Keyboards):
00069 Gizmod.Keyboards[0].createEventRaw(Event.Type, Event.Code, Event.Value)
00070 elif Registrar.DeviceType == DeviceType.Mouse and len(Gizmod.Mice):
00071 if Event.Type == GizmoEventType.EV_ABS:
00072 EventType = GizmoEventType.EV_REL
00073 if Event.Code == 0x0:
00074 if self.LastX != -1:
00075 Gizmod.Mice[0].createEventRaw(GizmoEventType.EV_REL, Event.Code, Event.Value - self.LastX)
00076 self.LastX = Event.Value
00077 if Event.Code == 0x1:
00078 if self.LastY != -1:
00079 Gizmod.Mice[0].createEventRaw(GizmoEventType.EV_REL, Event.Code, Event.Value - self.LastY)
00080 self.LastY = Event.Value
00081 else:
00082 Gizmod.Mice[0].createEventRaw(Event.Type, Event.Code, Event.Value)
00083
00084
00085 return False
00086
00087
00088
00089
00090
00091 def __init__(self):
00092 """
00093 Default Constructor
00094 """
00095
00096 GizmoScriptEnableChecker.__init__(self, ENABLED, VERSION_NEEDED)
00097 self.LastX = -1
00098 self.LastY = -1
00099
00100
00101
00102
00103
00104
00105 RemoteControl()