def prepare_response_func(self): """See base_response_item.""" self._keyboard = keyboard(self.experiment, keylist=self._allowed_responses, timeout=self._timeout) if self.var._dummy == u'yes': return self._keyboard.get_key # Dynamically load a joystick instance if not hasattr(self.experiment, u'joystick'): _joystick = plugins.load_mod(__file__, u'libjoystick') self.experiment.joystick = _joystick.libjoystick( self.experiment, device=self._device) self.python_workspace[u'joystick'] = self.experiment.joystick if self._allowed_responses is not None: self._allowed_responses = [int(r) for r in self._allowed_responses] return self._get_button_press
def prepare(self): """Prepares the item.""" # Pass the word on to the parent item.item.prepare(self) # Prepare the allowed responses if self.has(u"allowed_responses"): self._allowed_responses = [] for r in self.unistr(self.get(u"allowed_responses")).split(u";"): if r.strip() != "": try: r = int(r) except: raise osexception( \ u"'%s' is not a valid response on your joystick/gamepad. Expecting a number in the range of 1 to the amount of buttons." \ % (r,self.name)) if r < 0 or r > 255: raise osexception( \ u"'%s' is not a valid response on your joystick/gamepad. Expecting a number in the range of 1 to the amount of buttons." \ % (r, self.name)) self._allowed_responses.append(r) if len(self._allowed_responses) == 0: self._allowed_responses = None else: self._allowed_responses = None debug.msg(u"allowed responses has been set to %s" % self._allowed_responses) # In case of dummy-mode: self._keyboard = openexp.keyboard.keyboard(self.experiment) if self.has(u"_dummy") and self.get(u"_dummy") == u"yes": self._resp_func = self._keyboard.get_key # Not in dummy-mode: else: timeout = self.get(u"timeout") # Dynamically load a joystick instance if not hasattr(self.experiment, u"joystick"): _joystick = plugins.load_mod(__file__, u'libjoystick') self.experiment.joystick = _joystick.libjoystick( \ self.experiment, device=self._device) # Prepare auto response if self.experiment.auto_response: self._resp_func = self.auto_responder else: self._resp_func = self.experiment.joystick.get_joybutton self.prepare_timeout()
Quest = None try: import Quest debug.msg(u'Loading Quest module directly') except: debug.msg(u'Failed to load Quest module directly') if Quest == None: try: from psychopy.contrib import quest as Quest debug.msg(u'Loading Quest module from PsychoPy') except: debug.msg(u'Failed to load Quest module from PsychoPy') if Quest == None: try: Quest = plugins.load_mod(__file__, u'Quest') debug.msg(u'Loading Quest module from plug-in folder') except: debug.msg(u'Failed to load Quest module from plug-in folder') if Quest == None: raise osexception(u'Failed to load Quest module.') class quest_staircase_init(item): """ desc: A plug-in that iniializes a Quest staircase. """ description = u'Initializes a new Quest staircase procedure'