From 00576b225ad8b60ef1e0291e231aa499042436ba Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 20 Feb 2011 17:52:18 -0500 Subject: Added an InitialLocationInput --- inputs/InitialLocationInput.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 inputs/InitialLocationInput.py (limited to 'inputs') diff --git a/inputs/InitialLocationInput.py b/inputs/InitialLocationInput.py new file mode 100644 index 0000000..8d39a40 --- /dev/null +++ b/inputs/InitialLocationInput.py @@ -0,0 +1,24 @@ +import util.TimeOps as clock +import util.ComponentRegistry as compReg +import util.Strings as Strings +from operationscore.Input import * +class InitialLocationInput(Input): + """Takes two arguments: xPos, yPos, where xPos and yPos is a value from + 0 to 1, where 0 represents top/left and 1 represents bottom/right of the + lightscreen. Will return that position on the screen only once.""" + + def inputInit(self): + compReg.getLock().acquire() + xmin, ymin, xmax, ymax = compReg.getComponent('Screen').getSize() + compReg.getLock().release() + + xlen = xmax-xmin + ylen = ymax-ymin + + self.xloc = xmin + xlen * self['xPos'] + self.yloc = ymin + ylen * self['yPos'] + + def sensingLoop(self): + self.respond({Strings.LOCATION: (self.xloc, self.yloc)}) + self.done = True + -- cgit v1.2.3