X-Carve mod pack 2

The gamepad setup needs to address the following areas.

connectivity
Since I already had the particular gamepad I used a playstation 2 to USB converter. Alternatevely I would get a generic USB gamepad. You get plenty of results if you look for either on google/amazon/ebay. The gamepad connects to an RPi’s USB port which in turn connects to X-Controller’s USB port.

g-code sender
I run bCNC on the RPi. This g-code sender apart from being the best performer as tested by Sonny, it’s packed with features some of which are unique (e.g. the only GRBL gcode sender with multiple policies for handling M6). In the gamepad scenario I take advantage of its ability to handle shortcuts, custom shortcuts and custom macros.

key mapping
I use the following libraries

sudo apt-get install joystick
sudo apt-get install python-xlib python-pygame

Key identification is done via (your actual device name may vary)

jstest /dev/input/js0

Then once you know your button IDs, the actual key mapping is handled by jkeys , a free python script.

You create your custom mapping “joy” file and then run

jkeys bCNC.joy /path/to/bCNC

My bCNC.joy so far looks like

<config>
    <joystick id="0">
        <button number="0" key="Up" />
        <button number="1" key="Right" />
        <button number="2" key="Down" />
        <button number="3" key="Left" />
        <button number="4" key="KP_Multiply" />
        <button number="5" key="Prior" />
        <button number="6" key="slash" />
        <button number="7" key="Next" />
        <button number="8" key="F7" />
        <button number="9" key="F1" />
    </joystick>
</config>

The human friendly version of the above would be:

when I press the:

  • triangle button send <Up> , which is bCNC standard shortcut for +Y
  • circle button send <Right>, which is bCNC standard shortcut for +X
  • X button send <Down>, which is bCNC standard shortcut for -Y
  • square button send Left>, which is bCNC standard shortcut for -X
  • left side front top send <*>, which is bCNC standard shortcut for x10 step
  • right side front top send <PgUp>, which is bCNC standard shortcut for +Z
  • left side front bottom send </>, which is bCNC standard shortcut for /10 step
  • right side front bottom send <PgDn>, which is bCNC standard shortcut for -Z
  • select button send <F7>, which is a bCNC custom shortcut I made for probe
  • start button send <F1>, which is a bCNC custom shortcut I made for home
[Shortcut]
f1 = HOME
f7 = M5
     G91
     G38.2 Z-30 F30
     G10L20P1Z19.37
     G0 Z5
     M0
     G90

It may sound overwhelming, but if you get a grasp of the idea (identify your buttons, then map them to known or custom shortcuts), the specifics can be worked out.

When I find some time I will try to take a small video to demo.