The first step is to discover which devices are available for use:
This will find all currently available devices, all the known info on them, and post instructions with example lines of code for several possible cases:
Copy the code line for the device you want to use from the post window to a text document and change its nickname to one you like:
You can see the output from all elements by doing
The same for a Thrustmaster RunNDrive gamepad:
Each control (i.e. knob, slider, button, etc) on the device is represented by an MKtlElement. All elements are contained in the elementGroup in a hierarchical order:
The elementGroup is an (MKtlElementGroup) and usually contains some nested groups, where the final node is always an MKtlElement. The structure of the groups follows a meaningful order, e.g. the spatial arrangement on the device (rows, columns, areas) or a logical order (pages, function groups, etc). (One can create custom orders of elements as well, see Creating_Custom_Elements_and_Groups.
This organization is defined in an MKtlDesc file for the device, which are provided for many devices already.
The pages can also be in the top layer, and element names below them:
Actions for an element (or group) are defined using the "action_" or the "addAction" methods of MKtlElement. These methods take a function as argument which receives a single argument, the MKtlElement it belongs to. One can get the current value of the element by ".value". The value returned by an MKtlElement is always between 0 and 1.
... Now you can control four parameters of synth z.
For more flexibility and clarity, one can give the elements names for their functions, and use those:
And now run the same function setting code as above for the gamepad controller! For a full example of this approach, see Substituting_MKtls.
For very flexible use of multiple actions, see also MFunc in the "adclib" Quark.
Some devices can be set to specific values, e.g. setting motorfaders or LED rings around encoder knobs to the corresponding values.