Overpro,
First, thank you for taking your time to create this sketch and get it working for those of us without programming skills.
I've had a Mega2560 for three years now, and have not been able to find a long term use for it until now.
With that said, I uncommented the analog inputs line and programmed the Arduino with the sketch, and then flashed it to appear as a joystick.
Buttons are working great, but my analog inputs are not.
I hooked up a Parallax 27800 two axis joystick to Analog pins 0 and 1 with 0 being the Up/Down axis and 1 being the Left/Right axis.
The movement of the stick is detected, but it is not working correctly.
When the stick is at rest, the system shows the joystick response as being maximum.
When I move the stick to the right, the response meter starts at 0 and moves up to the 50% mark.
When I put it at rest, it goes back down to 0 and then maximizes at 100%.
When I move the stick to the left, it drops down from 100% to 50%. At rest, it goes back to 100%.
Every potentiometer I have hooked up, no matter what brand or resistance level exhibits this same characteristic.
Help?