In my venture into VR I sometimes bump into experiences which only take keyboard and mouse input. To feel less tied down I usually opt for using a wireless Xbox360 gamepad, and this weekend I figured that there has to be a way to emulate keyboard and mouse controls with said controller.

Sure, a bit of searching later and I found FreePIE which can receive controller input and send keyboard and mouse output! At this point I had never done Python or used this software before, but I found a script floating around that showed me how to do the basic in/out operation. From there it was just about reading Python documentation and experimenting with FreePIE!

I’ve introduced two main improvements to the quite basic script I started with. The stick input was fairly square and not very accurate so I rewrote that to handle things better.

Both sticks now have a circular dead-zones instead of square.

The left stick is divided into pie pieces that better handles diagonal movement.

The right stick has a scaling input field in relation to the dead-zone and a vector based output.

The image to the right describes what I just said a bit easier, the red side is how the script originally worked, green side is my rewrite, top is movement (keyboard) and bottom is aiming (mouse).

The script can easily be customized by editing the settings at the top of the file. To use this you need an Xbox 360 controller, wired or wireless with dongle, FreePIE installed and the below script file. Just open FreePIE, locate the file, make adjustments and press F5 to run it. Enjoy! :)

Xbox360 Controller to Keyboard & Mouse for FreePIE

It is a .zip because WordPress will not allow me to upload .py files, understandably. Version number is just an integer as I iterated from 1 and onward.

Version History

12. Dead-zones for triggers, option to use dpad for other keys than movement. Bugfix for start button crash.

11. Initial release, vector based aiming with full range outside dead-zone. Equally segmented movement. Circular dead-zones for both sticks. Start button glitch work-around. Easy customization.