########################################################################## ########################################################################## ## ## Gizmo Daemon Python Config Script ## ## gizmoDaemonConfig.py - v2:2 ## ####################################### ####################################### import GizmoDaemon import commands import sys import string import time from array import array import subprocess ####################################### # Constants ################### VERSION = "2:2" DEVICE_KEYBOARD = "Keyboard" DEVICE_MOUSE = "Mouse" ALWAYS_CONTROL_VOLUME = False # enable this to turn on debugging messages # including print outs of received events DEBUG = True # number of installed monitors MAX_MONITORS = 3 # Setup all of our devices DeviceID = -1 # load a generic plugin for the keyboard if DEBUG: print " Listing Devices..." GizmoDaemon.loadPlugin("GizmoPluginGeneric", "!ListDevices") # load XOSD plugin print " Loading XOSD Plugin..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginXOSD", "arial;Cyan;30") if DeviceID == -1: print " * Failed to Load XOSD Plugin!" # load powermate plugin print " Loading Griffin PowerMate Plugin..." while True: DeviceID = GizmoDaemon.loadPlugin("GizmoPluginPowerMate", "auto"); if DeviceID == -1: break GizmoDaemon.genericSetGrabExclusiveAccess( DeviceID, True ) # load alsa mixer plugin print " Loading AlsaMixer Plugin [Master]..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginAlsaMixer", "hw:0;Master") if DeviceID == -1: print " * Failed to Load Alsa Mixer Plugin for Mixer [Masetr]!" else: if GizmoDaemon.isPluginLoaded("GizmoPluginPowerMate", 0): GizmoDaemon.powerMateSetLEDPercent(0, GizmoDaemon.alsaMixerGetVolume(0)) # load another alsa mixer plugin print " Loading AlsaMixer Plugin [PCM]..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginAlsaMixer", "hw:0;PCM") if DeviceID == -1: print " * Failed to Load Alsa Mixer Plugin for Mixer [PCM]!" else: if GizmoDaemon.isPluginLoaded("GizmoPluginPowerMate", 1): GizmoDaemon.powerMateSetLEDPercent(1, GizmoDaemon.alsaMixerGetVolume(1)) # load a generic plugin for the keyboard print " Loading Generic Plugin [Keyboard]..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginGeneric", DEVICE_KEYBOARD) if DeviceID == -1: print " * Failed to Load Generic Plugin for [Keyboard]!" # load a generic plugin for the mouse print " Loading Generic Plugin [Mouse]..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginGeneric", DEVICE_MOUSE) if DeviceID == -1: print " * Failed to Load Generic Plugin for [Mouse]!" # load the X11 plugin print " Loading X11 Plugin..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginX11", ":0.0") if DeviceID == -1: print " * Failed to Load X11 Plugin!" # load the XMMS Control plugin print " Loading XMMS Control Plugin..." DeviceID = GizmoDaemon.loadPlugin("GizmoPluginXMMSControl", "auto") if DeviceID == -1: print " * Failed to Load XMMS Control Plugin!" ####################################### # Window functions ################### # Cinelerra specific mappings for the ShuttlePro2. # Jog: Step by frames (KP4 and KP1) # Shuttle: Step by seconds? # 0: # 1: # 2: # 3: # 4: # 5: # 6: # 7: # 8: # 9: #10: #11: #12: #13: #14: Mark In '[' #15: Mark Out ']' ####################################### # Event Handlers ################### def onPowerMateJog( DeviceID, Value, ButtonPressed ): print "Jog: ", Value, " buttons=", ButtonPressed def onPowerMateShuttle( DeviceID, Value, ButtonPressed ): print "Shuttle: ", Value, " buttons=", ButtonPressed def onPowerMateRotate(DeviceID, Value, ButtonPressed, DevicePath, WheelID): # Differentiate between the jog wheel and shuttle if( WheelID == 0 ): onPowerMateJog( DeviceID, Value, ButtonPressed ) else: onPowerMateShuttle( DeviceID, Value, ButtonPressed ) def onPowerMatePress(DeviceID, DevicePath, ButtonID): 1 def onPowerMateRelease(DeviceID, DevicePath, ButtonID): 1 def onPowerMateClick(DeviceID, DevicePath, ButtonID): 1 def onPowerMateLEDChange(DeviceID, Value, ButtonPressed, DevicePath): 1 def onAlsaMixerEvent(DeviceID, VolumePercent, Mute, CardName, MixerName): 1 def onGenericPress(DeviceID, ButtonCode, ButtonString, DeviceName, DevicePath): 1 def onGenericRelease(DeviceID, ButtonCode, ButtonString, DeviceName, DevicePath): 1 def onGenericClick(DeviceID, ButtonCode, ButtonString, DeviceName, DevicePath): 1 def onGenericRelative(DeviceID, Axis, Value, DeviceName, DevicePath): 1 def onGenericAbsolute(DeviceID, Axis, Value, DeviceName, DevicePath): 1 def onGenericMisc(DeviceID, Axis, Value, DeviceName, DevicePath): 1 def onSoundVisualization(FrameID, LeftChannel, RightChannel, Combined, Special): 1 def onCPUUsage(Usage, UsagePercent): 1 def onX11ForegroundWindowChange(DeviceID, X11Display, WindowName): print "Focus: ", WindowName def onLIRCClick(DeviceID, ButtonCode, ButtonValue, ButtonString, DeviceName, DevicePath): 1 def onPulse(Pulse): 1 ####################################### # Debug ################### def debugPrint(text): if DEBUG: print text ####################################### # Main ################### def gizmoMain(): if not GizmoDaemon.getVersion() == VERSION: print " * Gizmo Daemon Has Incorrect Version: v" + GizmoDaemon.getVersion() + " Script is: v" + VERSION + "\n" return print "*** Going into event loop" while not GizmoDaemon.waitForNextEvent(3): 1 print "*** Shutting down"