(self, inptype, inp, stage, stagevars)
return stage, stagevars
Checks the input, compares this with what is possible in the
		current stage, then returns adjusted stage and adjusted stage
		variables
		
		arguments
		inptype		--	string indicating input type, should be
						either 'mouseclick' or 'keypress'
		inp			--	input, should be either
Checks the input, compares this with what is possible in the
		current stage, then returns adjusted stage and adjusted stage
		variables
		
		arguments
		inptype		--	string indicating input type, should be
						either 'mouseclick' or 'keypress'
		inp			--	input, should be either
Checks the input compares this with what is possible in the current stage then returns adjusted stage and adjusted stage variables arguments inptype -- string indicating input type should be either mouseclick or keypress inp -- input should be either
def handle_input(self, inptype, inp, stage, stagevars):
		
		"""Checks the input, compares this with what is possible in the
		current stage, then returns adjusted stage and adjusted stage
		variables
		
		arguments
		inptype		--	string indicating input type, should be
						either 'mouseclick' or 'keypress'
		inp			--	input, should be either
		"""
		
		# # # # #
		# mouseclicks to keypress value
		
		if inptype == 'mouseclick':
			
			# click position
			pos = inp[:]
			
			# loop through buttons
			for bn in self.buttons.keys():
				# check if click position is on a button
				r = self.buttons[bn]['inactive']['rect']
				if pos[0] > r[0] and pos[0] < r[0]+r[2] and pos[1] > r[1] and pos[1] < r[1]+r[3]:
					# change input to button name
					inp = bn
					# break from loop (we don't want to loop through all the other buttons once we've found the clicked one)
					break
		
		# # # # #
		# keypress (or simulated keypress) handling
		
		# stage 1
		if stage == 1:
			# up should increase threshold, down should decrease threshold
			if inp in ['up','down']:
				stagevars[1]['thresholdchange'] = inp
		
		# stage 2
		elif stage == 2:
			# up should increase pupil rect size, down should decrease pupil rect size
			if inp in ['up','down']:
				stagevars[2]['vprectchange'] = inp
			elif inp in ['left','right']:
				stagevars[2]['hprectchange'] = inp
		
		# stage 3
		elif stage == 3:
			# up should increase threshold, down should decrease threshold
			if inp in ['up','down']:
				stagevars[1]['thresholdchange'] = inp
			# space should confirm settings
			if inp == 'space':
				stagevars[3]['confirmed'] = True

		# space should move to next stage (but not in stage 3)
		if inp == 'space' and stage < 3:
			stage += 1
		
		# number keys should make the stage jump to that number
		if inp in ['1','2','3']:
			stage = int(inp)
		
		# T should toggle between displays
		if inp == 't':
			if stagevars[0]['show_threshimg']:
				stagevars[0]['show_threshimg'] = False
			else:
				stagevars[0]['show_threshimg'] = True
		
		# R should toggle between using pupil rect or not
		if inp == 'r':
			if stagevars[0]['use_prect']:
				stagevars[0]['use_prect'] = False
			else:
				stagevars[0]['use_prect'] = True
		
		# escape should close down
		if inp == 'escape':
			pygame.display.quit()
			raise Exception("camtracker.Setup: Escape was pressed")
		
		# return the changed variables
		return stage, stagevars
def handle_input ( self , inptype , inp , stage , stagevars ) : # # # # # # mouseclicks to keypress value if inptype == 'mouseclick' : # click position pos = inp [ : ] # loop through buttons for bn in self . buttons . keys ( ) : # check if click position is on a button r = self . buttons [ bn ] [ 'inactive' ] [ 'rect' ] if pos [ 0 ] > r [ 0 ] and pos [ 0 ] < r [ 0 ] + r [ 2 ] and pos [ 1 ] > r [ 1 ] and pos [ 1 ] < r [ 1 ] + r [ 3 ] : # change input to button name inp = bn # break from loop (we don't want to loop through all the other buttons once we've found the clicked one) break # # # # # # keypress (or simulated keypress) handling # stage 1 if stage == 1 : # up should increase threshold, down should decrease threshold if inp in [ 'up' , 'down' ] : stagevars [ 1 ] [ 'thresholdchange' ] = inp # stage 2 elif stage == 2 : # up should increase pupil rect size, down should decrease pupil rect size if inp in [ 'up' , 'down' ] : stagevars [ 2 ] [ 'vprectchange' ] = inp elif inp in [ 'left' , 'right' ] : stagevars [ 2 ] [ 'hprectchange' ] = inp # stage 3 elif stage == 3 : # up should increase threshold, down should decrease threshold if inp in [ 'up' , 'down' ] : stagevars [ 1 ] [ 'thresholdchange' ] = inp # space should confirm settings if inp == 'space' : stagevars [ 3 ] [ 'confirmed' ] = True # space should move to next stage (but not in stage 3) if inp == 'space' and stage < 3 : stage += 1 # number keys should make the stage jump to that number if inp in [ '1' , '2' , '3' ] : stage = int ( inp ) # T should toggle between displays if inp == 't' : if stagevars [ 0 ] [ 'show_threshimg' ] : stagevars [ 0 ] [ 'show_threshimg' ] = False else : stagevars [ 0 ] [ 'show_threshimg' ] = True # R should toggle between using pupil rect or not if inp == 'r' : if stagevars [ 0 ] [ 'use_prect' ] : stagevars [ 0 ] [ 'use_prect' ] = False else : stagevars [ 0 ] [ 'use_prect' ] = True # escape should close down if inp == 'escape' : pygame . display . quit ( ) raise Exception ( "camtracker.Setup: Escape was pressed" ) # return the changed variables return stage , stagevars