ruchit
How to set the value of node attribute via MIDI device or USB joystick using python in realtime ?
Reply 0 0
pshipkov

Are you looking for a general idea how to approach this, or specific code example ?

If you don't intend this to be a headless client, probably the fastest path to there is through Qt's API:

https://doc.qt.io/qt-5/qtgamepad-examples.html

Reply 0 0
ruchit
There is no PySide2.QtGamepad namespace in Python 3.7.9/PySide2 5.15.2,
I didn't find anything about gamepad support in PySide2.
Reply 0 0
pshipkov

That's not good.
Well, then you can simply use the even callback systems in Maya, like this:

import maya.OpenMaya as om


previous_midi_data = None

def callback_function(*arg):
    print("processing important midi data")
    """
    midi_data = read_midi_data()
    if midi_data != previous_midi_data:
        apply_midi_data()
        previous_midi_data = midi_data
    """

# register a callback
delta_time = 1
id = om.MTimerMessage.addTimerCallback(delta_time, callback_function)

# unregister callback
om.MEventMessage.removeCallback(id)

Reply 0 0
Reply