aboutsummaryrefslogtreecommitdiff
path: root/inputs/InitialLocationInput.py
blob: 8d39a40ffbc32b494257e3c181199a09f7a1c38d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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