/usr/lib/python2.7/dist-packages/VisionEgg/DaqKeyboard.py is in python-visionegg 1.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # The Vision Egg: DaqKeyboard
#
# Author(s): Hubertus Becker <hubertus.becker@uni-tuebingen.de>
# Copyright: (C) 2005 by Hertie Institute for Clinical Brain Research,
# Department of Cognitive Neurology, University of Tuebingen
# URL: http://www.hubertus-becker.de/resources/visionegg/
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
"""
Data acquisition and triggering over the keyboard.
This module was programmed using information from the web site
http://www.pygame.org/docs/ref/pygame_key.html
"""
####################################################################
#
# Import all the necessary packages
#
####################################################################
import VisionEgg
import VisionEgg.Core
import VisionEgg.FlowControl
import VisionEgg.ParameterTypes as ve_types
import sys
import pygame
__version__ = VisionEgg.release_name
####################################################################
#
# KeyboardInput
#
####################################################################
class KeyboardInput:
def get_pygame_data(self):
"""Get keyboard input (return values are in pygame.locals.* notation)."""
keys = pygame.key.get_pressed()
return [k for k, v in enumerate(keys) if v]
def get_string_data(self):
"""Get keyboard input (return values are converted to keyboard symbols (strings))."""
pressed = self.get_pygame_data()
keys_pressed = []
for k in pressed: # Convert integers to keyboard symbols (strings)
keys_pressed.append(pygame.key.name(k))
return keys_pressed
get_data = get_string_data # Create alias
####################################################################
#
# KeyboardTriggerInController
#
####################################################################
class KeyboardTriggerInController(VisionEgg.FlowControl.Controller):
"""Use the keyboard to trigger the presentation."""
def __init__(self,key=pygame.locals.K_1):
VisionEgg.FlowControl.Controller.__init__(
self,
return_type=ve_types.Integer,
eval_frequency=VisionEgg.FlowControl.Controller.EVERY_FRAME)
self.key = key
def during_go_eval(self):
return 1
def between_go_eval(self):
for event in pygame.event.get():
# if (event.type == pygame.locals.KEYUP) or (event.type == pygame.locals.KEYDOWN):
if event.type == pygame.locals.KEYDOWN:
if event.key == self.key:
return 1
else:
return 0
|