Commercial 3D navigation mice are incredible tools for CAD, but they are often expensive and locked behind proprietary software. I wanted to change that.
This project is a fully open-source, 3D-printable Space Mouse and programmable Macro Pad combined into a single desktop tool. It provides smooth, 6-axis 3D navigation for software like Fusion 360 and FreeCAD, alongside customizable mechanical keys for your most-used shortcuts. By using a magnetometer to read magnetic shifts inside the 3D-printed joystick, it delivers premium hardware control for a fraction of the cost.
I am a passionate maker and designer. I build things because I love the process, but I share them for one reason: if something I create makes your life even a little bit easier, Iโm happy. That is why all the STEP files, Fusion 360 files, STL, and Python code are completely free and available for you to download, modify, and make your own.
Letโs build it!
All the physical components for this build are 3D printable. You can find the STEP files attached to this step, so you can easily modify the design to fit your exact desk setup or hardware dimensions.
Printing Recommendations:
- The Keycaps and Internal Mechanics: PLA works great for these. It handles the fine details of the keycap stems and internal joystick tolerances beautifully. I've used Marble PLA
- The Main Shell: While PLA works, I highly recommend printing the outer housing in PETG. It gives the enclosure a much more robust, durable, and shinier finish that feels like a premium commercial product.
Prep Work: Once the parts are printed, before hand wiring , Snap your mechanical switches into the top plate. They should click firmly into place.
Github link for all the STL files https://github.com/jeevan8232/macrokeyboard
Step and Fusion360 files are attached
Since we are keeping this accessible, there is no custom PCB requiredโeverything is hand-wired directly to the microcontroller!
Hand-wiring a project like this is incredibly rewarding. Take your time, trim your wires to length so they fit nicely inside the shell, and double-check your connections as you go.
Below is the complete wiring guide based on the Raspberry Pi Pico (RP2040) pinout used for this project.
1. Power Distribution (ALL components VCC (+) and GND (-))
First, let's establish our power and ground lines. It helps to daisy-chain your ground wires or create a small ground hub.
- VBUS (Pin 40, 5V from USB): Connect your LED Strip VCC here.
- 3V3 (Pin 36, 3.3V Out): Connect the Joystick VCC, Magnetometer VCC, and Rotary Encoder VCCs here.
- GND (Any Ground Pin): Connect the GND from all components (LEDs, Joystick, Magnetometer, Encoders, Extra Switches, etc.) to the microcontroller's ground.
2. The Key Matrix (Macro Keyboard)
To save pins, the mechanical switches are wired in a 5x5 matrix. You will need to solder diodes to your switches to prevent "ghosting" when pressing multiple keys.
๐จ CRITICAL DIODE NOTE: When soldering the 1N4148 diodes to the mechanical switches, the black line on the diode must face AWAY from the switch pin, Check the image.
* Rows (Solder to the diode tails):
- Row 1 โ GP0
- Row 2 โ GP1
- Row 3 โ GP2
- Row 4 โ GP3
- Row 5 โ GP4
- Columns (Solder to the other switch pin): (Note: These are wired in reverse order in the code! Don't worry we can always change the pin numbers in the code)
- Col 1 โ GP9
- Col 2 โ GP8
- Col 3 โ GP7
- Col 4 โ GP6
- Col 5 โ GP5
3. The Space Mouse (Magnetometer & Joystick)
This is the core of our 3D navigation!
- Magnetometer (MLX90393): This communicates via I2C. Ensure your breakout board is in I2C mode.
- SDA โ GP16
- SCL โ GP17
- Analog Joystick Module:
- VRx (X-Axis) โ GP27
- VRy (Y-Axis) โ GP26
- SW (Button) โ GP22
4. Rotary Encoders & Extra Buttons
These give you scroll and quick-action control.
- Encoder 1 (Left - Horizontal Scroll / Right Click):
- CLK โ GP10
- DT โ GP11
- SW โ GP12
- Encoder 2 (Right - Vertical Scroll / Home):
- CLK โ GP13
- DT โ GP14
- SW โ GP15
- Extra Button 1 (F6 - Fit View): Wire one leg to GP18, the other to GND.
- Extra Button 2 (Mode/Color Cycle): Wire one leg to GP19, the other to GND.
5. RGB Lighting
To give the macro pad that premium glow:
- WS2812B Data In (DIN): โ GP28
With the electronics wired up, it is time to carefully pack everything into the 3D-printed enclosure. Take your time here to ensure no wires get pinched!
1. Assembling the Space Mouse Core This is where the magic happens. The Space Mouse relies on reading magnetic fields to give you that smooth, 6-axis control, and the dual-spring mechanism is what gives it that perfect tactile return-to-center feel.
- First, press-fit your neodymium magnets into the designated slots inside the 3D-printed joystick knob. Make sure they are seated flush.
- Now, we can assemble the spring mechanism. Begin by inserting the 3 compression springs into the appropriate holes on both the Spacemouse Base cover spring loader M3x8mm screws.stl and Spacemouse Top Magnet Holder.stl parts.
- With both pieces compressed together, securely hold them in place while fastening the extension springs to the three sides using M3 x 8mm hex head screws.
- Once this mechanism is complete, insert the entire contraption inside the knob. Secure it from the inside using M3 x 8mm screws. The Spacemouse Base cover spring loader M3x8mm screws.stl part features three larger holes, allowing you to pass your screwdriver through the springs to screw the entire assembly directly into the inside of the knob.
- Finally, mount the magnetometer breakout board. Crucial tip: Glue the magnetometer directly to the Spacemouse base.stl first to avoid any micro-movements, then screw it down securely with M3 x 8mm screws. The sensor needs to be perfectly rigid and centered under the magnets to read the push, pull, and twist movements accurately!
2. Mounting the Rotary Encoders and Extra Buttons
- Secure the rotary encoders and any extra push-buttons to their designated mounting holes using hot glue gun
3. Closing the Enclosure
- Carefully fold your wiring "spaghetti" into the main PETG/PLA shell. Take a moment to make sure no wires are sitting where they might get pinched by the edges of the case.
- Secure the microcontroller into its mount near the USB cutout.
- Bring the top plate down, ensuring the USB port lines up perfectly with the opening in the case.
- To seal the enclosure, we are going to use a hot glue gun. Apply a few dabs or a steady bead of hot glue along the inner lip or the resting points of the base, then firmly press the top plate down. Hold it steady for a minute while the glue sets.
- Maker Tip: Hot glue is perfect for this because it holds the case together securely, but if you ever need to open it back up to change a switch or fix a connection, you can soften the glue with a few drops of isopropyl alcohol to safely pop it open!
The hardware is built, but right now it is just a paperweight. We need to upload the code that tells it how to be a Space Mouse and a Macro Pad!
Because we are using an RP2040 microcontroller, flashing the firmware is as easy as dragging and dropping a file onto a USB drive.
1. Prep the Microcontroller
- While holding down the BOOTSEL button on your microcontroller, plug the USB cable into your computer.
- A new drive will appear on your computer called RPI-RP2.
2. Install CircuitPython (Two Ways)
You can install it using one of two methods:
- Method A: Drag & Drop (The Quick Way)
- First, we need to put the CircuitPython operating system onto the board. You can grab the latest version for your specific board directly from circuitpython.org.
- Drag and drop the CircuitPython .uf2 file you downloaded directly onto that drive. The board will reboot, and a new drive called CIRCUITPY will appear.
- Method B: The Thonny IDE Way (Recommended for Beginners)
- Download and open Thonny IDE, a fantastic free code editor for Python.
- Hold the BOOTSEL button and plug in your board.
- In Thonny, go to Tools > Options > Interpreter.
- Select CircuitPython (generic) from the dropdown, then click Install or update CircuitPython.Follow the prompts, and Thonny will download and flash the latest firmware for you automatically!
3. Upload the Project Code
- Download the project repository https://github.com/jeevan8232/macrokeyboard
- Copy the lib folder (which contains the libraries for the magnetometer and HID keyboard/mouse controls) and the main code.py file directly onto the CIRCUITPY drive.
- The lib Folder Dependency if your CircuitPython version is not 10.x(Crucial Step!)
- To make our sensors and keyboard work, we need to add libraries to the board.
- Download the Adafruit CircuitPython Library Bundle.
- Important: The version of the library bundle you download must match the major version of CircuitPython you just installed! (For example, if you installed CircuitPython 9.x, you must download the 9.x library bundle).
- From that bundle, copy the required library folders (like adafruit_hid and the magnetometer library) into the lib folder on your CIRCUITPY drive.
4. The Tinkercad / Web-CAD Magic
If you are wondering how this works with browser-based software like Tinkercad (which doesn't have native 6-axis support), the code handles it for you! The firmware is pre-programmed to emulate a Right-Click + Mouse Drag when you move the joystick. It bypasses the need for keyboard shortcuts so you can rotate the camera smoothly right out of the box.
5. Customize Your Keymap (Optional)
Want to change the hotkeys for Fusion 360 or FreeCAD? Open the code.py file in any text editor preferably Thonny IDE. Look for the KEYMAP array:
Python
KEYMAP = [
[(COMMAND, Keycode.C), (COMMAND, Keycode.V), (COMMAND, Keycode.A), None, None],
[(COMMAND, Keycode.ALT, Keycode.V), (COMMAND, Keycode.F), Keycode.ESCAPE, None, None],
# ...
]
Simply swap out those Keycode commands for whatever shortcuts match your workflow, save the file, and the board will update instantly!
Congratulations! If everything went according to plan, you now have a fully functional, open-source Space Mouse and Macro Pad sitting on your desk.
Whether you are orbiting around complex models in Fusion 360, FreeCAD, or Tinkercad, this tool is designed to make your workflow significantly faster and much more enjoyableโall without the premium price tag of proprietary hardware.
Share Your Build! Instructables has an "I Made It!" button at the bottom of the page. If you build one of these, please share a picture of it down below! I absolutely love seeing the different color combinations, keycap sets, and filament choices the community comes up with.
Keep in Touch & Get Updates: Because this is an open-source project, the code and files will continue to improve over time.
- Watch the full build process: https://www.youtube.com/watch?v=AjmmTDKetks
- Get the latest firmware updates & files: https://github.com/jeevan8232/macrokeyboard
I build things for the love of the process, but I share in the hope that it makes your workflow just a little bit better. I hope this project does exactly that for your 3D modeling journey.
Happy making!





_t9PF3orMPd.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)



Comments