Package SmootLight :: Package inputs :: Module ContinuousLocationInput
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.inputs.ContinuousLocationInput

 1  import util.TimeOps as clock 
 2  import util.ComponentRegistry as compReg 
 3  import util.Strings as Strings 
 4  from operationscore.Input import * 
5 -class ContinuousLocationInput(Input):
6 '''Continuously returns one of nine positions on the screen as specified by the xloc 7 and yloc arguments, which can take values 'min', 'max', and 'center'. '''
8 - def inputInit(self):
9 xvals = {} 10 yvals = {} 11 compReg.getLock().acquire() 12 xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize() 13 compReg.getLock().release() 14 (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2) 15 16 self.location = (xvals[self['xloc']], yvals[self['yloc']])
17
18 - def sensingLoop(self):
19 self.respond({Strings.LOCATION: self.location})
20