def get_input_key(self): ky = [] while not qTo.empty(): message = qTo.get() # print 'eyelink: ' # print message if message == 'button': ky.append( pylink.KeyInput(32, 0) ) #button translated to space keypress (for drift correct) # if message=='quit': # # print 'received message to exit' # exitSafely() # el elif message[0] == 'keycode': keysym = message[1] keycode = keysym.sym if keycode == sdl2.SDLK_F1: keycode = pylink.F1_KEY elif keycode == sdl2.SDLK_F2: keycode = pylink.F2_KEY elif keycode == sdl2.SDLK_F3: keycode = pylink.F3_KEY elif keycode == sdl2.SDLK_F4: keycode = pylink.F4_KEY elif keycode == sdl2.SDLK_F5: keycode = pylink.F5_KEY elif keycode == sdl2.SDLK_F6: keycode = pylink.F6_KEY elif keycode == sdl2.SDLK_F7: keycode = pylink.F7_KEY elif keycode == sdl2.SDLK_F8: keycode = pylink.F8_KEY elif keycode == sdl2.SDLK_F9: keycode = pylink.F9_KEY elif keycode == sdl2.SDLK_F10: keycode = pylink.F10_KEY elif keycode == sdl2.SDLK_PAGEUP: keycode = pylink.PAGE_UP elif keycode == sdl2.SDLK_PAGEDOWN: keycode = pylink.PAGE_DOWN elif keycode == sdl2.SDLK_UP: keycode = pylink.CURS_UP elif keycode == sdl2.SDLK_DOWN: keycode = pylink.CURS_DOWN elif keycode == sdl2.SDLK_LEFT: keycode = pylink.CURS_LEFT elif keycode == sdl2.SDLK_RIGHT: keycode = pylink.CURS_RIGHT elif keycode == sdl2.SDLK_BACKSPACE: keycode = ord('\b') elif keycode == sdl2.SDLK_RETURN: keycode = pylink.ENTER_KEY elif keycode == sdl2.SDLK_ESCAPE: keycode = pylink.ESC_KEY elif keycode == sdl2.SDLK_TAB: keycode = ord('\t') elif keycode == pylink.JUNK_KEY: keycode = 0 ky.append(pylink.KeyInput(keycode, keysym.mod)) return ky
def get_input_key(self): ''' handle key input and send it over to the tracker''' ky = [] for ev in pygame.event.get(): if ev.type != KEYDOWN: pass else: keycode = ev.key if keycode == K_F1: keycode = pylink.F1_KEY elif keycode == K_F2: keycode = pylink.F2_KEY elif keycode == K_F3: keycode = pylink.F3_KEY elif keycode == K_F4: keycode = pylink.F4_KEY elif keycode == K_F5: keycode = pylink.F5_KEY elif keycode == K_F6: keycode = pylink.F6_KEY elif keycode == K_F7: keycode = pylink.F7_KEY elif keycode == K_F8: keycode = pylink.F8_KEY elif keycode == K_F9: keycode = pylink.F9_KEY elif keycode == K_F10: keycode = pylink.F10_KEY elif keycode == K_PAGEUP: keycode = pylink.PAGE_UP elif keycode == K_PAGEDOWN: keycode = pylink.PAGE_DOWN elif keycode == K_UP: keycode = pylink.CURS_UP elif keycode == K_DOWN: keycode = pylink.CURS_DOWN elif keycode == K_LEFT: keycode = pylink.CURS_LEFT elif keycode == K_RIGHT: keycode = pylink.CURS_RIGHT elif keycode == K_BACKSPACE: keycode = ord('\b') elif keycode == K_RETURN: keycode = pylink.ENTER_KEY elif keycode == K_ESCAPE: keycode = pylink.ESC_KEY elif keycode == K_TAB: keycode = ord('\t') elif(keycode == pylink.JUNK_KEY): keycode = 0 ky.append(pylink.KeyInput(keycode, ev.mod)) return ky
def translate_key_message(self,event): key = 0 mod = 0 if len(event) >0 : key = event[0] self.keys.append(pylink.KeyInput(key,mod)) return key
def get_input_key(self): ky=[] v = pygame.event.get() for key in v: if key.type != KEYDOWN: continue keycode = key.key if keycode == K_F1: keycode = pylink.F1_KEY elif keycode == K_F2: keycode = pylink.F2_KEY elif keycode == K_F3: keycode = pylink.F3_KEY elif keycode == K_F4: keycode = pylink.F4_KEY elif keycode == K_F5: keycode = pylink.F5_KEY elif keycode == K_F6: keycode = pylink.F6_KEY elif keycode == K_F7: keycode = pylink.F7_KEY elif keycode == K_F8: keycode = pylink.F8_KEY elif keycode == K_F9: keycode = pylink.F9_KEY elif keycode == K_F10: keycode = pylink.F10_KEY elif keycode == K_PAGEUP: keycode = pylink.PAGE_UP elif keycode == K_PAGEDOWN: keycode = pylink.PAGE_DOWN elif keycode == K_UP: keycode = pylink.CURS_UP elif keycode == K_DOWN: keycode = pylink.CURS_DOWN elif keycode == K_LEFT: keycode = pylink.CURS_LEFT elif keycode == K_RIGHT: keycode = pylink.CURS_RIGHT elif keycode == K_BACKSPACE: keycode = ord('\b') elif keycode == K_RETURN: keycode = pylink.ENTER_KEY elif keycode == K_ESCAPE: keycode = pylink.ESC_KEY elif keycode == K_TAB: keycode = ord('\t') elif(keycode==pylink.JUNK_KEY): keycode= 0 ky.append(pylink.KeyInput(keycode,key.mod)) return ky
def _handleEvent(self, event): event_type_index = DeviceEvent.EVENT_TYPE_ID_INDEX if event[event_type_index] == EventConstants.KEYBOARD_RELEASE: from psychopy.iohub.devices.keyboard import KeyboardInputEvent key_index = KeyboardInputEvent.CLASS_ATTRIBUTE_NAMES.index('key') modifiers_index = KeyboardInputEvent.CLASS_ATTRIBUTE_NAMES.index( 'modifiers') char = event[key_index] #mods = event[modifiers_index] if char: char = char.lower() else: return pylink_key = None if char == "escape": pylink_key = pylink.ESC_KEY self.state = None elif char == "return": pylink_key = pylink.ENTER_KEY self.state = None elif char == " ": pylink_key = ord(char) elif char == "c": pylink_key = ord(char) self.state = "calibration" elif char == "v": pylink_key = ord(char) self.state = "validation" elif char == "a": pylink_key = ord(char) elif char == "pageup": pylink_key = pylink.PAGE_UP elif char == "pagedown": pylink_key = pylink.PAGE_DOWN elif char == "-": pylink_key = ord(char) elif char == "=": pylink_key = ord(char) elif char == "up": pylink_key = pylink.CURS_UP elif char == "down": pylink_key = pylink.CURS_DOWN elif char == "left": pylink_key = pylink.CURS_LEFT elif char == "right": pylink_key = pylink.CURS_RIGHT else: return self.keys.append(pylink.KeyInput(pylink_key, 0)) elif event[event_type_index] == EventConstants.MOUSE_BUTTON_PRESS: self.mouse_button_state = 1 elif event[event_type_index] == EventConstants.MOUSE_BUTTON_RELEASE: self.mouse_button_state = 0 elif event[event_type_index] == EventConstants.MOUSE_MOVE: self.mouse_pos = self._ioMouse.getPosition()
def get_input_key(self): ky = [] v = event.getKeys() for key in v: pylink_key = None if len(key) == 1: pylink_key = ord(key) elif key == "escape": pylink_key = pylink.ESC_KEY elif key == "return": pylink_key = pylink.ENTER_KEY elif key == "pageup": pylink_key = pylink.PAGE_UP elif key == "pagedown": pylink_key = pylink.PAGE_DOWN elif key == "up": pylink_key = pylink.CURS_UP elif key == "down": pylink_key = pylink.CURS_DOWN elif key == "left": pylink_key = pylink.CURS_LEFT elif key == "right": pylink_key = pylink.CURS_RIGHT else: print('Error! :{} is not a used key.'.format(key)) return ky.append(pylink.KeyInput(pylink_key, 0)) return ky
def _handleEvent(self, event): event_type_index = DeviceEvent.EVENT_TYPE_ID_INDEX if event[event_type_index] == EventConstants.KEYBOARD_RELEASE: from .....keyboard import KeyboardInputEvent key_index = KeyboardInputEvent.CLASS_ATTRIBUTE_NAMES.index('key') char = event[key_index] if isinstance(char, bytes): char = str(event[key_index], 'utf-8') if char: char = char.lower() else: return pylink_key = None if char == 'escape': pylink_key = pylink.ESC_KEY self.state = None elif char == 'return': pylink_key = pylink.ENTER_KEY self.state = None elif char == ' ': pylink_key = ord(char) elif char == 'c': pylink_key = ord(char) self.state = 'calibration' elif char == 'v': pylink_key = ord(char) self.state = 'validation' elif char == 'a': pylink_key = ord(char) elif char == 'pageup': pylink_key = pylink.PAGE_UP elif char == 'pagedown': pylink_key = pylink.PAGE_DOWN elif char == '-': pylink_key = ord(char) elif char == '=': pylink_key = ord(char) elif char == 'up': pylink_key = pylink.CURS_UP elif char == 'down': pylink_key = pylink.CURS_DOWN elif char == 'left': pylink_key = pylink.CURS_LEFT elif char == 'right': pylink_key = pylink.CURS_RIGHT else: return self.keys.append(pylink.KeyInput(pylink_key, 0)) elif event[event_type_index] == EventConstants.MOUSE_BUTTON_PRESS: self.mouse_button_state = 1 elif event[event_type_index] == EventConstants.MOUSE_BUTTON_RELEASE: self.mouse_button_state = 0 elif event[event_type_index] == EventConstants.MOUSE_MOVE: self.mouse_pos = self._ioMouse.getPosition()
def get_input_key(self): """ this function will be constantly pools, update the stimuli here is you need dynamic calibration target """ if not self.display_open: return None ky = [] for keycode in event.getKeys(modifiers=False): k = pylink.JUNK_KEY if keycode == 'f1': k = pylink.F1_KEY elif keycode == 'f2': k = pylink.F2_KEY elif keycode == 'f3': k = pylink.F3_KEY elif keycode == 'f4': k = pylink.F4_KEY elif keycode == 'f5': k = pylink.F5_KEY elif keycode == 'f6': k = pylink.F6_KEY elif keycode == 'f7': k = pylink.F7_KEY elif keycode == 'f8': k = pylink.F8_KEY elif keycode == 'f9': k = pylink.F9_KEY elif keycode == 'f10': k = pylink.F10_KEY elif keycode == 'pageup': k = pylink.PAGE_UP elif keycode == 'pagedown': k = pylink.PAGE_DOWN elif keycode == 'up': k = pylink.CURS_UP elif keycode == 'down': k = pylink.CURS_DOWN elif keycode == 'left': k = pylink.CURS_LEFT elif keycode == 'right': k = pylink.CURS_RIGHT elif keycode == 'backspace': k = ord('\b') elif keycode == 'return': k = pylink.ENTER_KEY elif keycode == 'space': k = ord(' ') elif keycode == 'escape': k = 'q' self.esc_pressed = True elif keycode == 'q': k = pylink.ESC_KEY self.state = None elif keycode == "c": k = ord("c") self.state = "calibration" elif keycode == "v": k = ord("v") self.state = "validation" elif keycode == "a": k = ord("a") elif keycode == "i": self.extra_info = not self.extra_info k = 0 elif keycode == 'tab': k = ord('\t') elif keycode in string.ascii_letters: k = ord(keycode) elif k == pylink.JUNK_KEY: key = 0 # if modifier['alt']==True: mod = 256 # else: mod = 0 ky.append(pylink.KeyInput(k, 0)) #event.clearEvents() return ky
def get_input_key(self): ky = [] for key in pygame.event.get([KEYDOWN]): try: tkey = self.translate_key_message(key) ky.append(pylink.KeyInput(tkey, key.mod)) except Exception, err: print err
def get_input_key(self): """ Gets an input key. Returns: A list containing a single pylink key identifier. """ # Don't try to collect key presses when the display is no longer # available. This is necessary, because pylink polls key presses during # file transfer, which generally occurs after the display has been # closed. if not self.display_open: return None try: key, time = self.kb.get_key(keylist=None, timeout='default') except: self.esc_pressed = True key = 'q' if key == None: return None # Escape functions as a 'q' with the additional esc_pressed flag if key == 'escape': key = 'q' self.esc_pressed = True # Process regular keys if key == "return": keycode = pylink.ENTER_KEY self.state = None elif key == "space": keycode = ord(" ") elif key == "q": keycode = pylink.ESC_KEY self.state = None elif key == "c": keycode = ord("c") self.state = "calibration" elif key == "v": keycode = ord("v") self.state = "validation" elif key == "a": keycode = ord("a") elif key == "i": self.extra_info = not self.extra_info keycode = 0 elif key == "up": keycode = pylink.CURS_UP elif key == "down": keycode = pylink.CURS_DOWN elif key == "left": keycode = pylink.CURS_LEFT elif key == "right": keycode = pylink.CURS_RIGHT else: keycode = 0 # Convert key to PyLink keycode and return return [pylink.KeyInput(keycode, 0)] # 0 = pygame.KMOD_NONE
def translate_key_message(self, event): key = 0 mod = 0 #ioHub.print2err('translate_key_message:' ,event) if len(event) > 0: key = event[0] self.keys.append(pylink.KeyInput(key, mod)) return key
def translate_key_message(self, event): key = 0 mod = 0 if len(event) > 0: if event[0] == pyglet.window.key.F1: key = pylink.F1_KEY elif event[0] == pyglet.window.key.F2: key = pylink.F2_KEY elif event[0] == pyglet.window.key.F3: key = pylink.F3_KEY elif event[0] == pyglet.window.key.F4: key = pylink.F4_KEY elif event[0] == pyglet.window.key.F5: key = pylink.F5_KEY elif event[0] == pyglet.window.key.F6: key = pylink.F6_KEY elif event[0] == pyglet.window.key.F7: key = pylink.F7_KEY elif event[0] == pyglet.window.key.F8: key = pylink.F8_KEY elif event[0] == pyglet.window.key.F9: key = pylink.F9_KEY elif event[0] == pyglet.window.key.F10: key = pylink.F10_KEY elif event[0] == pyglet.window.key.PAGEUP: key = pylink.PAGE_UP elif event[0] == pyglet.window.key.PAGEDOWN: key = pylink.PAGE_DOWN elif event[0] == pyglet.window.key.UP: key = pylink.CURS_UP elif event[0] == pyglet.window.key.DOWN: key = pylink.CURS_DOWN elif event[0] == pyglet.window.key.LEFT: key = pylink.CURS_LEFT elif event[0] == pyglet.window.key.RIGHT: key = pylink.CURS_RIGHT elif event[0] == pyglet.window.key.BACKSPACE: key = '\b' elif event[0] == pyglet.window.key.RETURN: key = pylink.ENTER_KEY elif event[ 0] == pyglet.window.key.TAB: #use TAB instead of ESCAPE, since piglet automatically exits as soon as esc is pressed. key = pylink.ESC_KEY #elif event[0] == pyglet.window.key.TAB: # key = '\t' else: key = event[0] if len(event) > 0: self.keys.append(pylink.KeyInput(key, mod)) return key
def get_input_key(self): ''' this function will be constantly pools, update the stimuli here is you need dynamic calibration target ''' # this function is constantly checked by the API, so we could update the gabor here if self.animatedTarget: if self.calTarget is 'rotatingCheckerboard': self.calibTar.angularPhase += 0.03 self.calibTar.radialPhase -= 0.03 self.calibTar.draw() self.display.flip() ky = [] for keycode, modifier in event.getKeys(modifiers=True): k = pylink.JUNK_KEY if keycode == 'f1': k = pylink.F1_KEY elif keycode == 'f2': k = pylink.F2_KEY elif keycode == 'f3': k = pylink.F3_KEY elif keycode == 'f4': k = pylink.F4_KEY elif keycode == 'f5': k = pylink.F5_KEY elif keycode == 'f6': k = pylink.F6_KEY elif keycode == 'f7': k = pylink.F7_KEY elif keycode == 'f8': k = pylink.F8_KEY elif keycode == 'f9': k = pylink.F9_KEY elif keycode == 'f10': k = pylink.F10_KEY elif keycode == 'pageup': k = pylink.PAGE_UP elif keycode == 'pagedown': k = pylink.PAGE_DOWN elif keycode == 'up': k = pylink.CURS_UP elif keycode == 'down': k = pylink.CURS_DOWN elif keycode == 'left': k = pylink.CURS_LEFT elif keycode == 'right': k = pylink.CURS_RIGHT elif keycode == 'backspace': k = ord('\b') elif keycode == 'return': k = pylink.ENTER_KEY elif keycode == 'space': k = ord(' ') elif keycode == 'escape': k = pylink.ESC_KEY elif keycode == 'tab': k = ord('\t') elif keycode in string.ascii_letters: k = ord(keycode) elif k == pylink.JUNK_KEY: k = 0 # plus/equal & minux signs for CR adjustment if keycode in ['num_add', 'equal']: k = ord('+') if keycode in ['num_subtract', 'minus']: k = ord('-') if modifier['alt'] == True: mod = 256 else: mod = 0 ky.append(pylink.KeyInput(k, mod)) #event.clearEvents() return ky
def get_input_key(self): '''This function is repeatedly pooled to check keyboard events''' ky = [] for keycode, modifier in event.getKeys(modifiers=True): k = pylink.JUNK_KEY if keycode == 'f1': k = pylink.F1_KEY elif keycode == 'f2': k = pylink.F2_KEY elif keycode == 'f3': k = pylink.F3_KEY elif keycode == 'f4': k = pylink.F4_KEY elif keycode == 'f5': k = pylink.F5_KEY elif keycode == 'f6': k = pylink.F6_KEY elif keycode == 'f7': k = pylink.F7_KEY elif keycode == 'f8': k = pylink.F8_KEY elif keycode == 'f9': k = pylink.F9_KEY elif keycode == 'f10': k = pylink.F10_KEY elif keycode == 'pageup': k = pylink.PAGE_UP elif keycode == 'pagedown': k = pylink.PAGE_DOWN elif keycode == 'up': k = pylink.CURS_UP elif keycode == 'down': k = pylink.CURS_DOWN elif keycode == 'left': k = pylink.CURS_LEFT elif keycode == 'right': k = pylink.CURS_RIGHT elif keycode == 'backspace': k = ord('\b') elif keycode == 'return': k = pylink.ENTER_KEY elif keycode == 'space': k = ord(' ') elif keycode == 'escape': k = 27 elif keycode == 'tab': k = ord('\t') elif keycode in string.ascii_letters: k = ord(keycode) elif k == pylink.JUNK_KEY: k = 0 # plus & minus signs for CR adjustment if keycode in ['num_add', 'equal']: k = ord('+') if keycode in ['num_subtract', 'minus']: k = ord('-') # handles key modifier if modifier['alt'] is True: mod = 256 elif modifier['ctrl'] is True: mod = 64 elif modifier['shift'] is True: mod = 1 else: mod = 0 ky.append(pylink.KeyInput(k, mod)) return ky
def get_input_key(self): keys = [] for keycode, modifiers in psychopy.event.getKeys(modifiers=True): if keycode in self.keys: key = self.keys[keycode] elif keycode in string.ascii_letters: key = ord(keycode) else: key = pylink.JUNK_KEY mod = 256 if modifiers['alt'] else 0 keys.append(pylink.KeyInput(key, mod)) return keys
def get_input_key(self): keys = [] for event in pump(True): if event.type == sdl2.SDL_KEYDOWN: keysym = event.key.keysym if not self.el._quitting: # don't process quit requests while already quitting ui_request(keysym) try: key = self.pylink_keycodes[keysym.sym] except KeyError: key = keysym.sym # don't allow escape to control tracker unless calibrating if key == pylink.ESC_KEY and not self.el.in_setup: key = pylink.JUNK_KEY keys.append(pylink.KeyInput(key, keysym.mod)) return keys
def get_input_key(self): ky = [] v = event.getKeys() # returns list of keypresses for keycode in v: # function keys if keycode == 'f1': keycode = pylink.F1_KEY elif keycode == 'f2': keycode = pylink.F2_KEY elif keycode == 'f3': keycode = pylink.F3_KEY elif keycode == 'f4': keycode = pylink.F4_KEY elif keycode == 'f5': keycode = pylink.F5_KEY elif keycode == 'f6': keycode = pylink.F6_KEY elif keycode == 'f7': keycode = pylink.F7_KEY elif keycode == 'f8': keycode = pylink.F8_KEY elif keycode == 'f9': keycode = pylink.F9_KEY elif keycode == 'f10': keycode = pylink.F10_KEY # arrow keys elif keycode == 'pageup': keycode = pylink.PAGE_UP elif keycode == 'pagedown': keycode = pylink.PAGE_DOWN elif keycode == 'up': keycode = pylink.CURS_UP elif keycode == 'down': keycode = pylink.CURS_DOWN elif keycode == 'left': keycode = pylink.CURS_LEFT elif keycode == 'right': keycode = pylink.CURS_RIGHT # escape keys elif keycode == 'backspace': keycode = ord('\b') elif keycode == 'return': keycode = pylink.ENTER_KEY elif keycode == 'escape': keycode = pylink.ESC_KEY elif keycode == 'tab': keycode = ord('\t') elif (keycode == pylink.JUNK_KEY): keycode = 0 # add to buffer to send to eyelink ky.append(pylink.KeyInput(keycode, 0)) # 0 used to be key.mod return ky
def get_input_key(self): ''' this function will be constantly pools, update the stimuli here is you need dynamic calibration target ''' ky=[] for keycode, modifier in event.getKeys(modifiers=True): k= pylink.JUNK_KEY if keycode == 'f1': k = pylink.F1_KEY elif keycode == 'f2': k = pylink.F2_KEY elif keycode == 'f3': k = pylink.F3_KEY elif keycode == 'f4': k = pylink.F4_KEY elif keycode == 'f5': k = pylink.F5_KEY elif keycode == 'f6': k = pylink.F6_KEY elif keycode == 'f7': k = pylink.F7_KEY elif keycode == 'f8': k = pylink.F8_KEY elif keycode == 'f9': k = pylink.F9_KEY elif keycode == 'f10': k = pylink.F10_KEY elif keycode == 'pageup': k = pylink.PAGE_UP elif keycode == 'pagedown': k = pylink.PAGE_DOWN elif keycode == 'up': k = pylink.CURS_UP elif keycode == 'down': k = pylink.CURS_DOWN elif keycode == 'left': k = pylink.CURS_LEFT elif keycode == 'right': k = pylink.CURS_RIGHT elif keycode == 'backspace': k = ord('\b') elif keycode == 'return': k = pylink.ENTER_KEY elif keycode == 'space': k = ord(' ') elif keycode == 'escape': k = pylink.ESC_KEY elif keycode == 'tab': k = ord('\t') elif keycode in string.ascii_letters: k = ord(keycode) elif k== pylink.JUNK_KEY: k = 0 # plus/equal & minux signs for CR adjustment if keycode in ['num_add', 'equal']: k = ord('+') if keycode in ['num_subtract', 'minus']: k = ord('-') if modifier['alt']==True: mod = 256 else: mod = 0 ky.append(pylink.KeyInput(k, mod)) #event.clearEvents() return ky
def get_input_key(self): ky = [] v = event.getKeys() for key in v: pylink_key = None if len(key) == 1: pylink_key = ord(key) elif key == "escape": pylink_key = pylink.ESC_KEY elif key == "return": #self.reward.deliver() self.correct_fixation = True pylink_key = pylink.ENTER_KEY elif key == "pageup": pylink_key = pylink.PAGE_UP elif key == "pagedown": pylink_key = pylink.PAGE_DOWN elif key == "up": pylink_key = pylink.CURS_UP elif key == "down": pylink_key = pylink.CURS_DOWN elif key == "left": pylink_key = pylink.CURS_LEFT elif key == "right": pylink_key = pylink.CURS_RIGHT else: print('Error! :{} is not a used key.'.format(key)) return ky.append(pylink.KeyInput(pylink_key, 0)) #update the phase here as this function is polled regularly if self.animate: if self.use_gabor: self.targetout.phase += 0.05 #update the grating phase self.targetout.draw() self.window.flip() return ky
def get_input_key(self): """ Check the event buffer for special key presses """ # the next line is a highly questionable trick to use two event loops in spite of the GIL. QtCore.QCoreApplication.instance().processEvents() # use eyelink event loop for Qt events retval = [] while True: try: key = self.keyList.popleft() if 0x20 <= key < 0x80: k = key # ascii non-special keys elif QtCore.Qt.Key_F1 <= key <= QtCore.Qt.Key_F10: k = pylink.F1_KEY + 0x100 * (key - QtCore.Qt.Key_F1 - 1) # function keys elif key == QtCore.Qt.Key_Enter or key == QtCore.Qt.Key_Return: k = pylink.ENTER_KEY # main enter or numpad enter elif key == QtCore.Qt.Key_Left: k = pylink.CURS_LEFT elif key == QtCore.Qt.Key_Up: k = pylink.CURS_UP elif key == QtCore.Qt.Key_Right: k = pylink.CURS_RIGHT elif key == QtCore.Qt.Key_Down: k = pylink.CURS_DOWN elif key == QtCore.Qt.Key_PageUp: k = pylink.PAGE_UP elif key == QtCore.Qt.Key_PageDown: k = pylink.PAGE_DOWN elif key == QtCore.Qt.Key_Escape: k = pylink.ESC_KEY else: k = pylink.JUNK_KEY retval.append(pylink.KeyInput(k)) print("get input: {} -> {}".format(key, k)) except IndexError: return retval
def on_key_press(symbol, modifiers): key_trans_dict = _get_key_trans_dict() key = key_trans_dict.get(str(symbol), symbol) self.keys += [pylink.KeyInput(key, modifiers)]
# Copyright (C) 2011 Jason Locklin
def get_input_key(self): ''' this function will be constantly pools, update the stimuli here is you need dynamic calibration target ''' # this function is constantly checked by the API, so we could update the gabor here if self.animatedTarget: if self.calTarget is 'spiral': self.calibTar.phases -= 0.02 self.calibTar.draw() self.display.flip() ky = [] for keycode, modifier in event.getKeys(modifiers=True): k = pylink.JUNK_KEY if keycode == 'f1': k = pylink.F1_KEY elif keycode == 'f2': k = pylink.F2_KEY elif keycode == 'f3': k = pylink.F3_KEY elif keycode == 'f4': k = pylink.F4_KEY elif keycode == 'f5': k = pylink.F5_KEY elif keycode == 'f6': k = pylink.F6_KEY elif keycode == 'f7': k = pylink.F7_KEY elif keycode == 'f8': k = pylink.F8_KEY elif keycode == 'f9': k = pylink.F9_KEY elif keycode == 'f10': k = pylink.F10_KEY elif keycode == 'pageup': k = pylink.PAGE_UP elif keycode == 'pagedown': k = pylink.PAGE_DOWN elif keycode == 'up': k = pylink.CURS_UP elif keycode == 'down': k = pylink.CURS_DOWN elif keycode == 'left': k = pylink.CURS_LEFT elif keycode == 'right': k = pylink.CURS_RIGHT elif keycode == 'backspace': k = ord('\b') elif keycode == 'return': k = pylink.ENTER_KEY # probe the tracker to see if it's "simulating gaze with mouse" # if so, show a warning instead of a blank screen to experimenter # do so, only when the tracker is in Camera Setup screen if self.tracker.getCurrentMode() is pylink.IN_SETUP_MODE: self.tracker.readRequest('aux_mouse_simulation') pylink.pumpDelay(50) if self.tracker.readReply() is '1': self.msgMouseSim.autoDraw = True self.camImgRect.autoDraw = True self.calibInst.autoDraw = True self.display.flip() elif keycode == 'space': k = ord(' ') elif keycode == 'escape': k = pylink.ESC_KEY elif keycode == 'tab': k = ord('\t') elif keycode in string.ascii_letters: k = ord(keycode) elif k == pylink.JUNK_KEY: k = 0 # plus/equal & minux signs for CR adjustment if keycode in ['num_add', 'equal']: k = ord('+') if keycode in ['num_subtract', 'minus']: k = ord('-') if modifier['alt'] == True: mod = 256 else: mod = 0 ky.append(pylink.KeyInput(k, mod)) #event.clearEvents() return ky