self._parameter = None
self._keylist = keylist
self._keymap = Bindings.KeyMap()
- self._keymap.add( Bindings.Binding(Events.Event(source.context(), 'p%d' % controller), '',
- Actions.Command('controllerChanged',
- self._controllerChanged)) )
+ if source:
+ self._keymap.add( Bindings.Binding(Events.Event(source.context(), 'p%d' % controller), '',
+ Actions.Command('controllerChanged',
+ self._controllerChanged)) )
self._keylist.prepend(self._keymap)
- source.registerController(controller, low, high)
+ if source:
+ source.registerController(controller, low, high)
self._dispatcher = dispatcher
self._min = None
self._max = None
self._min = min
self._max = max
self._stops = stops
- self._keymap.add( Bindings.Binding( self._valueEvent, '',
- Actions.Command('updateValue',
- self._updateValue)) )
+ if self._valueEvent:
+ self._keymap.add( Bindings.Binding( self._valueEvent, '',
+ Actions.Command('updateValue',
+ self._updateValue)) )
self._keylist.prepend(self._keymap)
self._value = None
- self._valueCommand()
+ if self._valueEvent:
+ self._valueCommand()
+ else:
+ self._value = self._valueCommand()
self._redraw()
def _updateValue(self, binding):
Logger.log('ctl',"value = %d" % event.value)
self._controlValue = event.value
if self._controlValue >= 999 or self._controlValue <= 1:
- self._dispatcher.setIdleCallback(self._changeValue,50)
+ self._dispatcher.setIdleCallback(self._changeValue,75)
+ elif self._controlValue >= 700 or self._controlValue <= 200:
+ self._dispatcher.setIdleCallback(self._changeValue,200)
else:
self._dispatcher.unsetIdleCallback()
self._redrawController()
def _changeValue(self):
if self._value is None: return
- if self._controlValue >= 999:
+ if self._controlValue > 500:
self.stepValue(+1)
- elif self._controlValue <= 1:
+ else:
self.stepValue(-1)
def stepValue(self, direction):
self._redrawValue()
else:
self._setCommand(newValue)
- self._valueCommand()
+ if self._valueEvent:
+ self._valueCommand()
+ else:
+ self._value = self._valueCommand()
+ self._redrawValue()
def _redraw(self):
height, width = self.win().getmaxyx()
def _redrawController(self, refresh=True):
height, width = self.win().getmaxyx()
- if self._controlValue is not None and self._controlValue >= 999:
+ if self._controlValue is not None and self._controlValue >= 700:
self.win().addch(3,3,curses.ACS_UARROW)
else:
self.win().addch(3,3,curses.ACS_TTEE)
- if self._controlValue is not None and self._controlValue <= 1:
+ if self._controlValue is not None and self._controlValue <= 200:
self.win().addch(height-3,3,curses.ACS_DARROW)
else:
self.win().addch(height-3,3,curses.ACS_BTEE)
bits = None,
controllers = []):
viewmanager.registerView( View(context, label, numeric_switches, alpha_switches, x, y, dx, size) )
- source = Source(device, context, bits)
- dispatcher.registerSource( source )
+ source = None
+ if device is not None:
+ source = Source(device, context, bits)
+ dispatcher.registerSource( source )
return source
def registerController( viewmanager, dispatcher, keylist, source, context, name, x, y, dx, dy,