This is my attempt to stick a Pi Zero inside of a Wii Nunchuk. I use this to control an organization-type program I made, but I can see this being useful for videogames as well.
It is powered by a 750mAH LiPo battery used for drones. I used an Adafruit Powerboost to regulate the power. It uses the Wii Nunchuk's joystick PCB, buttons, and top cover.
I tried to get this as compact as possible, but there wasn't nearly enough room to actually fit a Pi Zero completely in a Wii Nunchuk, not even considering the other parts. I modelled the lower body of the Nunchuk to fit all the components in the hand-grip part. I planned to make a cover for the grip portion, but it feels ok to hold already, and I didn't want to add extra bulk.
I use this with my Vufine wearable display, which is why I needed it to have a standard HDMI port.
Thankfully, the Nunchuk's PCB has a built-in analogue-digital converter, so I didn't have to use a separate one.
To get the Pi to recognize the joystick's signal, I used this module.To use the Nunchuk's hardware to control the cursor, I used the Python module Pynput.
This is the script I made to control the mouse and click buttons:
from nunchuck import nunchuck
from pynput.mouse import Button, Controller
wii = nunchuck()
mouse = Controller()
x = wii.joystick_x()
y = wii.joystick_y()
x_scaled = ((x - 130)*2)/260
y_scaled = ((y-135)*2)/270
x_curve = int((x_scaled * abs(x_scaled))*100)
y_curve = int((y_scaled * abs(y_scaled))*100)
if wii.Button_z() = True:
if wii.Button_c() = True:
You might have to tweak the values for x_curve and y_curve because each Wii joystick potentiometer I've tried had different limits.
It's just rise over run, where 2(x-130) is Δx and 260 is Δy, so if your cursor moves in the opposite direction after moving the joystick all the way,
you need to lower the value of that direction.