def eventCallback(self, *args, **kwargs): if args[3] == 'config' and args[4] == 'load': if args[5] == 'defaults': self.app.config.add_setting( self.name, 'enabled', False, type=2, alias="Enable", about='Enable eye tracking using PyViewX') self.app.config.add_setting(self.name, 'server_address', '127.0.0.1', type=3, alias="Address", about='iViewX Server Address') self.app.config.add_setting( self.name, 'server_inport', '5555', type=3, alias="Incoming Port", about='iViewX Server Incoming Port') self.app.config.add_setting( self.name, 'server_outport', '4444', type=3, alias="Outgoing Port", about='iViewX Server Outgoing Port') self.app.config.add_setting( self.name, 'calmode', 'Once', type=1, alias='When To Calibrate', options=['Every Game', 'Once'], about='Set when eye tracker is calibrated') elif args[3] == 'display': if args[4] == 'setmode': if self.client: self.calibrator = Calibrator(self.client, self.app.screen, reactor=self.app.reactor) if self.app.config[self.name]['calmode'] == 'Once': self.app.reactor.callLater(1, self.calibrate, False) elif args[3] == 'game': if args[4] == 'ready': if self.client and self.app.config[ self.name]['calmode'] == 'Every Game': self.calibrate(True)
draw_text("%d" % fp.nFixations, f, (255, 255, 255), (screen_rect.left + 50, screen_rect.top + 15), screen) pygame.display.flip() angle1 += .05 if angle1 >= 360: angle1 = 0 angle2 -= .025 if angle2 <= 0: angle2 = 360 def cleanup(*args, **kwargs): reactor.stop() def start(lc, results): global state, update, client, cleanup state = 0 client.addDispatcher(d) lc = LoopingCall(update) dd = lc.start(1.0 / 30) dd.addCallbacks(cleanup) client = iViewXClient(os.environ['EYE_TRACKER'], 4444) reactor.listenUDP(5555, client) calibrator = Calibrator(client, screen, reactor=reactor, eye=0) fp = VelocityFP(1680, 1050, 473.76, 296.1, 500, 23, 45) #calibrator.start(start) reactor.callLater(0, lambda: start(None, None)) reactor.run()