Multiple keyboards

It would be useful if MWorks had the ability to take input from either one of multiple keyboards, or else from multiple keyboards simultaneously.

I ran into this issue using MWorks in the Building 46 MEG, which provides a keyboard-emulating device as behavioral input. I was unable to use a Macbook Air to run the experiment because MWorks would only recognize input from the main keyboard. I was able to use a Mac Pro, but I had to unplug the keyboard when I loaded the experiment so that MWorks would pay attention to the behavioral input device.

I think the simplest solution from a user perspective would be for MWorks to take input from all the keyboards it sees (I tested this out in my browser url bar and the Macbook was fine with it), although I don’t know if that’s the best solution for other devices.

Hi Evan,

I’ve made some changes to the USBHID interface to address this situation.

First, if multiple devices match the specified usage_page and usage, you’ll get an error message, and the experiment will fail to load. For example, here’s the error message when two keyboards are attached to my system:

ERROR: Found multiple matching HID devices for "keyboard":

Device #1
    Product:        Apple Keyboard
    Manufacturer:   Apple, Inc
    Location ID:    4245815296  (0xfd120000)

Device #2
    Product:        Standard USB Keyboard
    Manufacturer:   Silitek
    Location ID:    975175680   (0x3a200000)

Please set the "preferred_location_id" attribute to the Location ID of the desired device.

As the message indicates, you can tell MWorks which device to use with the new preferred_location_id attribute. To indicate that I want to use the Silitek keyboard, I can add

preferred_location_id="975175680"

to the device definition, and the experiment will load successfully. If I then unplug the Silitek keyboard and reload the experiment, I’ll get the following warning:

WARNING: Location ID for HID device "keyboard" (4245815296) does not match preferred location ID (975175680)

However, because there’s only one matching device, MWorks will use it, and the experiment will load.

These changes should be in tonight’s nightly build.

Cheers,
Chris

Works great. Thanks Chris!