diff options
Diffstat (limited to 'inputs/ContinuousLocationInput.py')
-rw-r--r-- | inputs/ContinuousLocationInput.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/inputs/ContinuousLocationInput.py b/inputs/ContinuousLocationInput.py new file mode 100644 index 0000000..72ca8f0 --- /dev/null +++ b/inputs/ContinuousLocationInput.py @@ -0,0 +1,20 @@ +import util.TimeOps as clock +import util.ComponentRegistry as compReg +import util.Strings as Strings +from operationscore.Input import * +class ContinuousLocationInput(Input): + '''Continuously returns one of nine positions on the screen as specified by the xloc + and yloc arguments, which can take values 'min', 'max', and 'center'. ''' + def inputInit(self): + xvals = {} + yvals = {} + compReg.getLock().acquire() + xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize() + compReg.getLock().release() + (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2) + + self.location = (xvals[self['xloc']], yvals[self['yloc']]) + + def sensingLoop(self): + self.respond({Strings.LOCATION: self.location}) + |