Tuesday, 21 November 2017

Building the Next Spectrum - Part 3

Wiring up the buttons and joystick port.


To keep things simple the GPIO uses the internal pull-ups for the joystick and function buttons.  Wiring is as follows;

Raspi BOARD pin numbers

 fire = 16
up = 15
down = 36
left = 13
right = 37
f1 = 22
f2 = 18
gnd = 20

Pin numbering for D (9 pin) socket, connect to corresponding pin above on the pi

up = 1
down = 2
left = 3
right = 4
fire = 6
gnd = 8

The buttons (f1 and f2) have a common ground this is  wired to pin (20) , pins 18 and 22 on the pi.

How it all works


The pi runs a python script that reads the GPIO and when a pin goes low a keyboard press is sent to the OS.  I have used uinput to do this as documented here.  I have then modified Fuse source so that the keys F8 - F12 emulate a joystick.  This allows for the mapping of the real joystick to any Fuse emulated joystick.  This key mapping has also been used in the menu system to allow control of settings/options using the joystick.  The two function keys on are used to enter the Fuse menu. (possible snapshot creation coming soon).

Menu Joystick controls are;

Fire - confirm
Right - select item
Left - escape
Up - up
Down - down


Joystick port


Function buttons