Is there a digital joystick with 16 directions?

Status
Not open for further replies.

wilykat

Member
Intellivision has 16 directions over 4 lines: https://arcarc.xmission.com/Web Archives/Deathskull (May-2006)/games/tech/intvcont.html

However the controller is prone to failing due to cheap aluminum circuit that aren't sealed (can't seal it anyway) and the side button are often awful so people have built custom controllers with keypad and buttons but all of them have used a more common 8 direction joystick interface like Atari 2600.

I have built an adapter that lets me use Atari Jaguar controller on an Intellivision with success, since the controller has everything except for 16 direction control. Many games work fine with only 8 but there are a few that sucks with only 8 direction, and a few that are unplayable like Vectron.

If there a current source of 16 direction controller that can be used in a custom replacement controller? If not, does anyone know if an X-Y axis analog joystick can be converted to 16 digital direction? I'm lousy with math and can't quite figure out how to define X and Y range to determine North, NWN, NW, WNW, West, WSW, SW, SWS, South, etc. and have neutral (centered)

I've used Arduino for Jaguar interface, and other people have used either off the shelf logic chips or CPLD for custom built controller with common 3x4 keypad and 3 or 4 buttons (2 side action buttons away from user are the same on Intellivision controller while other 2 buttons closer to user are separate, see more at above link for pinout and truth table)
 
Yes, you can convert the analogue joystick output to 16 discrete steps. Obviously you want to use the angle of the joystick to decide the direction, and the distance of the joystick from the centre to determine the whether the joystick is actively being used/pushed.

If you can get the values of the X & Y resistors scaled into 8 bit two variables (let's call them X & Y), we first need to centre them on 0 by subtracting 128.
The angle is then found using the function atan2(Y', X') and then rounded and scaled to the 16 directions.

So, something like the following might work (it's untested).
Code:
// returns the direction from 1..16, or 0 if the joystick is not being used
uint8_t getDirectionFromAnalog(uint8_t x, uint8_t y)
{
	int8_t _x = x - 128;
	int8_t _y = y - 128;
	int8_t direction = (int8_t)(atan2(_y, _x) / M_PI * 8);
	
	if(direction <= 0)
		direction += 16;
		
	if(_x*_x + _y*_y > 64*64)
		return (uint8_t)direction;
	else
		return 0;		// joystick too close to centre
}

You can replace the atan2() function with a lookup table and some logic if you wanted.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…