Go to: Synopsis. Return value. Related. Flags. Python examples.

Synopsis

assignInputDevice([clutch=string], [continuous=boolean], [device=string], [immediate=boolean], [multiple=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

assignInputDevice is undoable, queryable, and NOT editable.

This command associates a command string (i.e. a mel script) with the input device. When the device moves or a button on the device is pressed, the command string is executed as if you typed it into the window. If the command string contains the names of buttons or axes of the device, the current value of these buttons/axes are substituted in. Buttons are reported as booleans and axes as doubles.

This command is most useful for associating buttons on a device with commands. For using a device to capture continous movements it is much more efficient to attach the device directly into the dependency graph.

Return value

stringCommand result

In query mode, return type is based on queried flag.

Related

attachDeviceAttr, detachDeviceAttr, devicePanel, getInputDeviceRange, getModifiers, listDeviceAttachments, listInputDeviceAxes, listInputDeviceButtons, listInputDevices, recordAttr, setAttrMapping, setInputDeviceMapping, unassignInputDevice

Flags

clutch, continuous, device, immediate, multiple
Long name (short name) Argument types Properties
clutch(c) string create
specify a clutch button. This button must be down for the command string to be executed. If no clutch is specified the command string is executed everytime the device state changes
continuous(ct) boolean create
if this flag is set the command string is continously (once for everytime the device changes state). By default if a clutch button is specified the command string is only executed once when the button is pressed.
device(d) string create
specify which device to assign the command string.
immediate(im) boolean create
Immediately executes the command, without using the queue.
multiple(m) boolean create
if this flag is set the other command strings associated with this device are not deleted. By default, when a new command string is attached to the device, all other command strings are deleted.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

cmds.assignInputDevice( 'setKeyframe', d='spaceball', c='Button1' )

# This command will assign button1 on the spaceball with
# the setKeyframe command.  This is very much like using
# the spaceball buttons as hotkeys.

cmds.assignInputDevice( '"currentTime -e Axis0"', d='midi', ct=True, m=True )

# This command will execute the command to set the time
# to the value of the first midi slider.  As the slider
# moves this command will be executed.  So the slider
# will control time.