PsychHID KbQueueCreate Error when attached to Button Box

Hi all,
I’m getting this error when I am attached to the button box, but not otherwise. It only happens sometimes, and we’ve unplugged/replugged the button box, and then it sometimes works, but not always. When it gives this error, the button box is still attached and will still work when pressing buttons. But Psychopy will not run.

It is the same type of error as if I didn’t have “Input Monitoring” allowed for Psychopy, but I do.

PSYCHOPY VERSION:
Psychopy 2 Beta, v2025.1.0
Psychopy, v2024.2.4

MAC OS:
Apple M3 Max 15.5 (24F74) & Apple M2 Air 15.3.1

BUTTON BOX:
932 Interface & Power Supply from Current Designs (Fiber Optic Response Devices Versatile fMRI Computer Response Interface - 932 Interface)

WHAT I’VE TRIED:

  • I’ve tried on two different computers (listed above)
  • I’ve tried on Psychopy 2 Beta & regular Psychopy
  • When attached to an external monitor, an external keyboard, or both, this error doesn’t happen
  • The error will appear, and after we restart the button box, it sometimes works.
  • When the error happens, the button box is listed as one of the devices when running this code, so it’s attached:
from psychopy.tools.systemtools import getKeyboards
keyboards=getKeyboards()
print('All keyboards:', keyboards)

Output for the relevant keyboard (button box):
All keyboards: [ {‘usagePageValue’: 1, ‘usageValue’: 6, ‘usageName’: ‘Keyboard’, ‘index’: 18, ‘transport’: ‘USB’, ‘vendorID’: 6171, ‘productID’: 8, ‘version’: 1.0, ‘manufacturer’: ‘Current Designs, Inc.’, ‘product’: ‘932’, ‘serialNumber’: ‘R809’, ‘locationID’: 1179648, ‘interfaceID’: -1, ‘totalElements’: 244, ‘features’: 0, ‘inputs’: 239, ‘outputs’: 5, ‘collections’: 1, ‘axes’: 0, ‘buttons’: 0, ‘hats’: 0, ‘sliders’: 0, ‘dials’: 0, ‘wheels’: 0, ‘touchDeviceType’: -1, ‘maxTouchpoints’: -1, ‘device_name’: ‘932’},

ERROR:


[1920, 1080]
INTERNAL PSYCHTOOLBOX ERROR
Traceback (most recent call last):
    error:                PsychError_system
    general description:  Error reported by a system call
    specific description: Failed to create event queue for detecting key press.
    module name:          PsychHID
    subfunction call:     KbQueueCreate
    file name:            ./PsychSourceGL/Source/OSX/PsychHID/PsychHIDStandardInterfaces.c
    function name:        PsychHIDOSKbQueueCreate
    line number:          1035
PsychHID:KbQueueCreate: See error message printed above.
5.5772     WARNING     Couldn't measure a consistent frame rate!
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/keyboard.py", line 761, in getBuffer
    self[kb_id] = _KeyBuffer(bufferSize=bufferSize,
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/keyboard.py", line 803, in __init__
    self.dev = hid.Keyboard(kb_id)  # a PTB keyboard object
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychtoolbox/hid.py", line 137, in __init__
    self._create_queue(buffer_size)
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychtoolbox/hid.py", line 144, in _create_queue
    PsychHID('KbQueueCreate', self.device_number,
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/manager.py", line 250, in addDevice
    device = cls(*args, **kwargs)
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/keyboard.py", line 372, in __init__
    buffer = _keyBuffers.getBuffer(devId, bufferSize)
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/keyboard.py", line 766, in getBuffer
    raise OSError("Failed to connect to Keyboard globally. "
OSError: Failed to connect to Keyboard globally. You need to add PsychoPy App bundle (or the terminal if you run from terminal) to the System Preferences/Privacy/Accessibility (macOS <= 10.14) or System Preferences/Privacy/InputMonitoring (macOS >= 10.15).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/holmeslab/Library/CloudStorage/Box-Box/Holmes_Lab_Wiki/PCX_Round2/Procedures/fMRI_tasks/Movie_tasks/PlayMomentous.py", line 191, in <module>
    defaultKeyboard = keyboard.Keyboard(backend='ptb')
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/keyboard.py", line 192, in __init__
    self.device = DeviceManager.addDevice(
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/hardware/manager.py", line 253, in addDevice
    raise ManagedDeviceError(
psychopy.hardware.manager.ManagedDeviceError: Failed to connect to Keyboard globally. You need to add PsychoPy App bundle (or the terminal if you run from terminal) to the System Preferences/Privacy/Accessibility (macOS <= 10.14) or System Preferences/Privacy/InputMonitoring (macOS >= 10.15).

If anyone has any suggestions I’d be grateful to hear them! Thank you.

Update: I tried attaching an external keyboard before attaching the button box, and this seemed to work. The “keyboard assistant” popup required me to tap buttons to configure the keyboard, which we’re thinking may have been the problem with the button box-- the keyboard assistant perhaps needed configuration. However, an hour later it started giving the same error again, even though it had been working on the prior tasks. We’re not sure why. We tried rebooting and trying different orders of plugging-in.