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
pyxid.
get_xid_device
(device_number)¶returns device at a given index.
Raises ValueError if the device at the passed in index doesn’t exist.
pyxid.
get_xid_devices
()¶Returns a list of all Xid devices connected to your computer.
pyxid.
ResponseDevice
(connection, name='Unknown XID Device', keymap=None, trigger_prefix='Button')¶clear_response_queue
()¶Clears the response queue
get_next_response
()¶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.
poll_for_response
()¶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
response_queue_size
()¶Number of responses in the response queue
pyxid.
XidDevice
(xid_connection)¶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.
init_device
()¶Initializes the device with the proper keymaps and name