aboutsummaryrefslogtreecommitdiff
path: root/inputs
diff options
context:
space:
mode:
authorGravatar dxiao <dxiao@mit.edu>2011-02-20 17:52:18 -0500
committerGravatar dxiao <dxiao@mit.edu>2011-02-20 17:52:18 -0500
commit00576b225ad8b60ef1e0291e231aa499042436ba (patch)
treeb032b812e5734aaa842b09a1fc3716192f74858a /inputs
parent792dd4d7139f9080bf6d3d760efe763b8b3f60cc (diff)
Added an InitialLocationInput
Diffstat (limited to 'inputs')
-rw-r--r--inputs/InitialLocationInput.py24
1 files changed, 24 insertions, 0 deletions
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
+