The pyxid package, written by Cedrus, is included in the Standalone PsychoPy distributions. See https://github.com/cedrus-opensource/pyxid for further info.
Example usage:
import pyxid
# get a list of all attached XID devices
devices = pyxid.get_xid_devices()
dev = devices[0] # get the first device to use
if dev.is_response_device():
dev.reset_base_timer()
dev.reset_rt_timer()
while True:
dev.poll_for_response()
if dev.response_queue_size() > 0:
response = dev.get_next_response()
# do something with the response
returns device at a given index.
Raises ValueError if the device at the passed in index doesn’t exist.
Returns a list of all Xid devices connected to your computer.
Clears the response queue
Pops the response at the beginning of the response queue and returns it.
This function returns a dict object with the following keys:
- pressed: A boolean value of whether the event was a keypress
- or key release.
- key: The key on the device that was pressed. This is a
- 0 based index.
- port: Device port the response came from. Typically this
- is 0 on RB-series devices, and 2 on SV-1 voice key devices.
- time: For the time being, this just returns 0. There is
- currently an issue with clock drift in the Cedrus XID devices. Once we have this issue resolved, time will report the value of the RT timer in miliseconds.
Polls the device for user input
If there is a keymapping for the device, the key map is applied to the key reported from the device.
If a response is waiting to be processed, the response is appended to the internal response_queue
Number of responses in the response queue
Class for interfacing with a Cedrus XID device.
At the beginning of an experiment, the developer should call:
XidDevice.reset_base_timer()
Whenever a stimulus is presented, the developer should call:
XidDevice.reset_rt_timer()
Developers Note: Currently there is a known issue of clock drift in the XID devices. Due to this, the dict returned by XidDevice.get_next_response() returns 0 for the reaction time value.
This issue will be resolved in a future release of this library.
Initializes the device with the proper keymaps and name