X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Joyboard.py;fp=Joyboard.py;h=ef06b87e5f2439e54151a1809d3f1c075d37ae27;hb=e6382990f0d93407969f85b1d9cb9b23884979d3;hp=be8af893345c8b64d3c5de91c914fa3fd57edd71;hpb=804a2a2f884bdda0a90af110635a76391a88f0c0;p=audiocontrol.git diff --git a/Joyboard.py b/Joyboard.py index be8af89..ef06b87 100644 --- a/Joyboard.py +++ b/Joyboard.py @@ -118,11 +118,13 @@ class Controller(Views.View): 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 @@ -148,12 +150,16 @@ class Controller(Views.View): 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): @@ -166,16 +172,18 @@ class Controller(Views.View): 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): @@ -198,7 +206,11 @@ class Controller(Views.View): 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() @@ -241,11 +253,11 @@ class Controller(Views.View): 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) @@ -279,8 +291,10 @@ def register( viewmanager, 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,