123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|556|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> N64 Controller Project...

Sun, 02 Oct 2022, 04:47
spinal

N64 Controller Project...


Here is the Arduino code for my N64 joystick replacement. It should work fine on any Arduino compatible device, just wire up the potentiometer outputs the the defined pins in the code and you're good to go.

Question 1 - Why?

Because both replacemtn and original N64 joysticks are terrible. Original ones, even if fully working, have a horrible feel to them. Old original joysticks are often worn and do not cover the full range. Replacement modern sticks are always way outside of the normal range for an N64 stick, which results in a lot of games not controlling correctly.

Question 2 - How?

Got a replacement stick from the internet, removed the controller chip from it and made my own.

Question 3 - Did it work?

Yes, better than I hoped. I now have a fully working, correctly ranged N64 joystick that has a modern feel.













OK, joysticks are weird.
My current project is in 2 parts.

Part 1
Using Arduino to convert inputs from an N64 controller to XInput to be used on an emulator (or anything that supports XInput other than games consoles, because that would mean spoofing hardware IDs to have it detected and thats too much work for now). Oh and support RUMBLE!

Part 2
Replace the joystick in an N64 controller with a modern analog stick and convert the inputs so that the controller recognises it.



So far...
Figuring the 'correct' range for an analog stick seems to be difficult. The N64 stick is reported (from the controller) as having a range of -83 to 84. But I need to report slightly higher than that so that I max out every single direction. This means scaling it down(?) to -62 to 64. It LOOKS correct, testing in the windows joystick thingy maxes every direction to the edge of the littls square, with the raw values being reported as between 0 and 65535, floating around 32767 when centered.

To test that the range is within the specific range that an N64 would send, I've put together a small test program in blitz3d, however blitz maps the controller to -1 to 1, making my data, well, different. So I then multiply that by 83 to get a nice display of whats going on.



The next step is to limit the joystick in the N64 to the exact range that a stock joystick was supposed to do when brand new. That'll be fun. I do however have somewhere the PS2 to N64 adapter code somewhere, I should be able to copy-paste that.

|update|
OK, after some googling, it seems that the stick should range from about -84 to 84 by use of the octagonal plastic thingy around the joystick. The stick itself should technically would further than that. With the diagonals being limited to 68.
So my plan is to scale the reading so that the diagonals are outside of the 68,86 distance then limit all the values accordingly.

People have also done a bunch of tests with N64 stick replacements and found them all to be wrong.




Steps I think I need to do....

Determine the angle of the stick, positive 0-90 degrees. Check the distance of the stick.
Check for intersection between the stick line (0,0 to x,y) against either of the 2 lines to the max distance (e,g, 0,84 to 68,68 or 84,0 to 68,68), then the distance of that intersection from the center. If the stick distance is longer than the intersection point then use the intersection point as the x,y of the stick...

Does that sound right?

-=-=-
Check out my excellent homepage!
Sun, 02 Oct 2022, 06:48
Jayenkai
Good grief!!!

At some point...
> Reveal 🔎

-=-=-
''Load, Next List!''
Mon, 03 Oct 2022, 00:58
spinal
Oh, wait, thought of a much easier way. Just a look up tables with distances for each angle.

-=-=-
Check out my excellent homepage!
Mon, 03 Oct 2022, 01:09
rockford
Haven't you already done this before?
Mon, 03 Oct 2022, 03:30
spinal
I'm 50% sure I have, but I can't find anything on myhard drive other than the usb adapter part, and that didn't support rumble.
I did also do a PS2 to N64 adapter, and I remember doing a Wii to N64 adapter also.

And here be a list of distances to the edge for angles 0-90.


-=-=-
Check out my excellent homepage!
Tue, 04 Oct 2022, 01:54
spinal
KO, just need to figure out which quarter the stick is in...



Its supposed to be a full circle clockwise.

-=-=-
Check out my excellent homepage!
Tue, 04 Oct 2022, 02:04
Jayenkai
How bizarre!! There doesn't seem to be any logic in the way that's moving!

-=-=-
''Load, Next List!''
Tue, 04 Oct 2022, 14:35
spinal
Done!



Now I have an N64 controller with a stick that is limited to ONLY what a brand new N64 stick is SUPPOSED to do. Which makes it 1000% better than any of the replacement joysticks and probably replacement controllers.

Question is, should it be open source

-=-=-
Check out my excellent homepage!
Tue, 04 Oct 2022, 14:39
Jayenkai
Anyone wanting to do anything similar would require all the hardware skills, too. Might as well put it out there, see if anyone dare try it

-=-=-
''Load, Next List!''
Tue, 04 Oct 2022, 15:04
spinal
Just tested it on my N64. Might need a little work.

Still to do...

1. Add a deadzone in the centre, Mario likes to move if the joystick isn't completely 0,0.

2. Seems a bit floaty, need to see if the lag is my joystick code, or the capture card. Tomorrow will test on a real TV.

|edit|

When testing on my TV, there is no noticable lag when playing, so it was probably the capture device, not the joystick code.
I'm going to have to put together a proper post with details on how it works and stuff now

-=-=-
Check out my excellent homepage!
Fri, 28 Oct 2022, 02:57
spinal
Here is the output of my joystick fix.

Here is an original joystick in extremely good condition, best I've owned.


Here is a replacement stick 'gamecube style', it was cheap, but outside of the range of a real joystick. This causes problems in some games like MarioKart.


Here is my modification, using an arduino pro micro, replacing the brains of the gamecube joystick.


Weirdly not perfect, which I don't understand because the code activly makes it perfect.

-=-=-
Check out my excellent homepage!
Fri, 28 Oct 2022, 02:59
Jayenkai
Looks like it might be a precision thing.
Can you bitshift it up, then do the maths, then bitshift it down? The higher values might help.. .. maybe..?

-=-=-
''Load, Next List!''
Fri, 08 Sep 2023, 03:23
spinal
OK, I dug out the arduino code, but I didn't comment it very well so I have gone and forgot that the hell the offset value does...

I'm tempted to think its the difference between the full stick value and the 'correct' full stick value...



-=-=-
Check out my excellent homepage!
Fri, 08 Sep 2023, 04:25
Jayenkai
Looks like it might be some sort of smoothing. Did you ever code smoothing into it?

-=-=-
''Load, Next List!''
Fri, 08 Sep 2023, 15:13
spinal
I didn't, from what I remember, it takes the value from the analog stick, does a little math to round the value down to a similar vaue to the real n64 stick, then clip it so that id doesn't go outlide that.

I think I remember, it's the negative of the outside of the octagon. Because its symetrical, if you read offset[x] it gives you the y value, if you read offset[y] it gives you the x value. Now it's coming back.

-=-=-
Check out my excellent homepage!
Fri, 08 Sep 2023, 16:17
spinal
Modded the code a little for potential speed ups, only by removing function calls to abs().



-=-=-
Check out my excellent homepage!