HIDMKtlDevice:
Filter:
Modality-toolkit/Classes (extension) | Libraries > Modality | External Control

HIDMKtlDevice
ExtensionExtension

The Modality class for creating and accessing external hid controllers

Description

HIDMKtlDevice provides an internal interface for HID devices you can connect to your computer.

NOTE: Usually, you never access the HIDMKtlDevice itself, as the MKtl that contains it (its parent MKtl) is the main code interface.

When looking for available devices with MKtl.find(\hid), HIDMKtlDevice searches for connected controllers, and returns a list of available devices.

When creating an MKtl by desc name, e.g. MKtl(\x, "*drive");, HIDMKtlDevice try to find the matching HID in the list of available devices and return it. If it does not find it, e.g. because the physical controller is not there, it will return nil. In that case, the MKtl will be virtual, meaning it has no device, and you can still work with it, because it can open a GUI that can replace the controller.

For most devices, this requires that someone has already made a description file for the device; if there is none, it is easy to make one following the instructions here: How_to_create_a_description_file

More general info can be found in MKtl and MKtlDevice .

Class Methods

.deviceProductNamesToHide

.devicesToShow

On OSX, some devices show up as HID that will cause system crashes when opened. these devices can be excluded from MKtl for safety.

.showAllDevices

a flag whether to show risky devices or not.

.find

Find all currently connected HID devices.

Arguments:

post

Whether or not to post about the found HID devices.

.postPossible

Post all access code for device that could be used by name.

.protocol

protocol name, \hid.

.initDevices

Look for available HID devices.

Arguments:

force

Whether or not to do this again if it was already done before.

.makeDeviceName

Convenience method to create a device name from the information from HIDInfo for idInfo lookup.

.getIDInfoFrom

get the idInfo string from a HIDInfo object.

.new

Creates a new instance of HIDMKtlDevice.

Arguments:

name

The short name of the controller as it shows up in the list of found devices.

path

The path of the device to open (optional).

parentMKtl

The instance of MKtl that this MKtlDevice will belong to.

multiIndex

When using multiple identical devices, the index which one to use.

Instance Methods

.enable

.disable

enable or disable this device.

.enabled

a boolean whether device is currently enabled.

.enableElement

.disableElement

enable or disable an element in the device by name.

.source

The HID device that is the source of this HIDMKtlDevice.

.srcID

The uid of the source.

.closeDevice

Close the device and clean up anything that it used.

.explore

When opening a device that is not known yet by MKtl, you may want to explore the device. See the tutorial How_to_create_a_description_file.

Arguments:

bool

a flag to turn exploring on or off.

.exploring

the flag whether the device is currently being explored or not.

.createDescriptionFile

Create and open a description file for this MKtlDevice, after exploring it.

.initElements

Initialize all elements and hook them up to the hardware elements.

.send

Send the value of an element to this HID device; called if you set the value of an MKtlElement that is an output.

Arguments:

key

The key of the element.

val

The value to which the element is to be set.