A gamepad camera layout tool

Hi everyone !

I’m working on an add-on that allows you to make camera animations using an xbox controller. The idea is to get very cool looking shot easily.

I had the idea after looking at Polyfjord’s “Quick Smooth Camera Movements in Blender” tutorial.

I thinks this kind of tool can be awesome for motion design or layout.

It’s not so simple because of the technical limitations that comes with the Python API:

But hey, I’m verry happy that we have an API ! :slight_smile:

I managed to get the xbox inputs working inside of blender. It was easy when the game engine was there. But since it was removed, I have to use inputs with some modifications.

Coding ergonomic camera controls is as easy as I thought, and I’m not sure which controls I should add on which buttons.

If there is some people interested around here, I would be happy to get some feedback/feature request/whatever !

xobx_blender

Very good idea. I was thinking about it a couple of weeks now and I am really surprised that it was so simple. I was trying to think of reading raw USB data (libusb) or using subprocesses etc… But your approach was top notch in terms of simplicity.

Simply getting an 3D Connection device is ridiculous amount of money spent (150 euros), with this approach mortals with humble gamepads can get the same effect. :wink:

1 Like

Thanks !

Getting the controller input is fairly easy. But using it in the blender loop isn’t so. As we don’t have control of when the code is called, so you can’t process the events correctly :frowning: You could process the inputs from another thread or a timer, but blender doesn’t allow to run operators from there.

See Python: Support for calling operators in timers.

Would you try something like threading?

I’m already using a thread to make sure I receive all gamepad events. Something like

# Input detection will be done in another thread to keep 
# the main thread running smoothly.
# The pill to kill is used to stop that new thread.        
# We use a deamon thread to make sure it is killed when blender stops.
self._pill_to_kill = threading.Event()
self._monitor_thread = threading.Thread(target=self._monitor_controller, args=(self._pill_to_kill,))
self._monitor_thread.daemon = True
self._monitor_thread.start()

But the thing is, when you move your mouse or press a key, blender updates and call the update method of your running operator. But if you use the gamepad, blender doesn’t care :frowning:

I tried some hacks, like pressing play to make sure we process gamepad inputs each frame. But it’s not as reactive as I want.

At the moment, I’m not working on it anymore. But if you are interested in something (like the gamepad wrapper or the camera controller itself), tell me and I can make it public :slight_smile:

OK, I am interested to have a look. I can try various techniques to see how it can be improved. :slight_smile:

P.S. Modal operators / threading / stored state in properties. I will try to test one by one just in case something better.

Cool! Give me some time to push my changes and make the repo public. It will be done by this week end :wink:

2 Likes

Hey @const, there you go :slight_smile: https://github.com/oktomus/blender_gamepad_controls
At the moment, the code is not well written and I’m sorry about this. Please don’t hesitate to ask me if help is needed.

Thanks for being interest into this :slight_smile: Hope you will have fun with it.

Here is the most important script: https://github.com/oktomus/blender_gamepad_controls/blob/master/gamepad/xbox_gamepad.py#L206

Very cool, I appreciate the effort put in this trying to investigate how things stick together and how it can be setup. Technically everything worked great from the start (diagnostics and movement), is only a matter of testing and testing until techniques settle and it becomes polished.

1 Like

Thanks for testing ! I need to schedule some time and make a first version for this addon.