How to use the psychtoolbox.hid.get_keyboard_indices function in psychtoolbox

To help you get started, we’ve selected a few psychtoolbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kleinerm / Psychtoolbox-3 / PsychPython / demos / hidtest_pythonic.py View on Github external
# The test will be subject to change without notice, it is throwaway wip code.
#
# (c) 2019 Jon Peirce - Licensed under MIT license.
# (c) 2018 Mario Kleiner - Licensed under MIT license.

from psychtoolbox import hid
import psychtoolbox as ptb

print("Devices:")
for dev in hid.devices():
    print("  %(index)s: %(product)s "
          "usagePageValue=%(usagePageValue)s, usageValue=%(usageValue)s"
          % dev)

print("Keyboards:")
kbIDs, kbNames, kbDevices = hid.get_keyboard_indices()
for dev in kbDevices:
    print("  %(index)s: %(product)s" % dev)

def run():

    dev = kbDevices[0]
    # KbQueueTest
    ptb.WaitSecs('YieldSecs', 1)
    keyboard = hid.Keyboard(dev['index'])

    # keyboard.queue_create(num_slots=10000)  # done implicitly but can redo

    # keyboard.start_trapping() # stops keys going to stdout but sketchy!

    keyboard.queue_start()
    t0 = ptb.GetSecs()
github psychopy / psychopy / psychopy / hardware / keyboard.py View on Github external
def getKeyboards():
    """Get info about the available keyboards.

    Only really useful on Mac/Linux because on these the info can be used to
    select a particular physical device when calling :class:`Keyboard`. On Win
    this function does return information correctly but the :class:Keyboard
    can't make use of it.

    Returns
    ----------
    A list of dicts
        USB Info including with name, manufacturer, id, etc for each device

    """
    indices, names, keyboards = hid.get_keyboard_indices()
    return keyboards
github psychopy / psychopy / psychopy / hardware / keyboard.py View on Github external
def __init__(self, bufferSize, kb_id):
        self.bufferSize = bufferSize
        self._evts = deque()

        # create the PTB keyboard object and corresponding queue
        allInds, names, keyboards = hid.get_keyboard_indices()

        self._keys = []
        self._keysStillDown = []

        if kb_id == -1:
            self.dev = hid.Keyboard()  # a PTB keyboard object
        else:
            self.dev = hid.Keyboard(kb_id)  # a PTB keyboard object
        self.dev._create_queue(bufferSize)