[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/util disp.py
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx/util disp.py |
Date: |
Tue, 04 Mar 2003 06:10:26 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 03/03/04 06:10:26
Modified files:
gfx/util : disp.py
Log message:
more
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/disp.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: gzz/gfx/util/disp.py
diff -u gzz/gfx/util/disp.py:1.4 gzz/gfx/util/disp.py:1.5
--- gzz/gfx/util/disp.py:1.4 Tue Mar 4 04:28:19 2003
+++ gzz/gfx/util/disp.py Tue Mar 4 06:10:25 2003
@@ -55,7 +55,6 @@
a = float(xs) / ys
s,t = xt,yt
- print texid
code = """
PushAttrib ENABLE_BIT
BindTexture TEXTURE_2D %(texid)s
@@ -78,39 +77,105 @@
End
PopAttrib
""" % locals()
- print code
+ #print code
l = getDList(code)
vs.put(background((.36, .84, 1.0)))
cs = vs.affineCS(0, "foo", 0, 0, 0, ys, 0, 0, ys)
vs.map.put(l, cs)
+
+keys = []
+starttime = 0
+mintime = 0
+toid = 0
+
class Bindings(AbstractBinder):
- def keystroke(self, s):
- print "KEY: '%s'"%s
+ def keystroke(self, key):
+ time = System.currentTimeMillis()
+ if time - starttime >= mintime:
+ if key in keys:
+ endTrial(time - starttime, key)
+
+ print "KEY: '%s'"%key
+
def mouse(self, e):
print "MOUSE: '%s'"%e
+
def timeout(self, o):
- print str(System.currentTimeMillis()) + " TIMEOUT ",o
+ time = System.currentTimeMillis()
+ if o == toid:
+ endTrial(time - starttime, "TIMEOUT")
+ print str(time) + " TIMEOUT ",o
+
+
+trials = []
+
+def nextTrial():
+ global trials
+ if len(trials) == 0:
+ return 0
+
+ trial = trials.pop(0)
+ print "Starting trial:", trial
+
+ global keys, mintime
+ keys = trial["keys"]
+ mintime = trial["min"]
+
+ vs = w.createVobScene()
+ filescene(vs, trial["file"])
+ w.renderStill(vs, 0)
+ global starttime
+ starttime = System.currentTimeMillis()
+
+ print "Start time", starttime
+ global toid
+ if trial["max"] > 0:
+ toid += 1
+ print "Scheduling timeout", toid, "at", trial["max"], "ms"
+ w.addTimeout(trial["max"], toid)
+
+ return 1
+
+def endTrial(time, key):
+ global toid
+ toid += 1
+
+ print "Trial ended:", time, key
+
+ if not nextTrial():
+ print "End of exper"
class Main(Runnable):
def run(self):
+ global w
w = gfxapi.createWindow()
w.setLocation(0,0,xs,ys)
w.registerBinder(Bindings())
+ print "Reading trials"
+ global trials
+ trials = []
f = open(sys.argv[1], "r")
- lines = f.readlines()
- f.close()
-
- for line in lines:
+ while 1:
+ line = f.readline()
+ if line == "": break
fields = line.split()
+ desc = f.readline()
+
+ trials.append( { "desc" : desc,
+ "file" : fields[0],
+ "min" : int(fields[1]),
+ "max" : int(fields[2]),
+ "keys" : fields[3:],
+ } )
+ f.close()
+ print "Read", len(trials), "trials"
- file = fields[0]
- vs = w.createVobScene()
- filescene(vs, file)
- w.renderStill(vs, 0)
+ # Start
+ nextTrial()
gfxapi = GraphicsAPI.getInstance()
- [Gzz-commits] gzz/gfx/util disp.py, Janne V. Kujala, 2003/03/04
- [Gzz-commits] gzz/gfx/util disp.py, Janne V. Kujala, 2003/03/04
- [Gzz-commits] gzz/gfx/util disp.py, Janne V. Kujala, 2003/03/04
- [Gzz-commits] gzz/gfx/util disp.py,
Janne V. Kujala <=
- [Gzz-commits] gzz/gfx/util disp.py, Janne V. Kujala, 2003/03/04
- [Gzz-commits] gzz/gfx/util disp.py, Janne V. Kujala, 2003/03/05
- [Gzz-commits] gzz/gfx/util disp.py, Janne V. Kujala, 2003/03/05