I’m trying to figure out how to use a joystick controller as an input device to control an armature. The idea is to assign the joystick (perhaps as a driver?) to a joint or bone and create a kind of puppeteering system where the keyframes get recorded in real time.
So imagine the left joystick x direction maps to the x rotation of the bone, and the y direction controls the x rotation.
I found a python library called Inputs https://pypi.org/project/inputs/
but when I run it in Blender 2.9 it will show the results in the console, but it basically freezes Blender… and i don’t know how to grab the values and map them to my joint rotation position.
here is the code:
"""Simple example showing how to get gamepad events.""" #https://pypi.org/project/inputs/ from __future__ import print_function from inputs import get_gamepad myVal = 0 def main(): """Just print out some event infomation when the gamepad is used.""" while 1: events = get_gamepad() for event in events: if event.code == 'ABS_X': print('X position RAW: ') print(event.state) #need to add sume kind of conversion factor to map absolute values to degrees of rotation #need a way to store the values in a variable that Blender can access if event.code == 'ABS_Y': print('Y position RAW: ') print(event.state) #for event in events: # print(event.ev_type, event.code, event.state) if __name__ == "__main__": main()