I wanted to use joystick buttons for camera switch and level restart. I like the external camera most of the time, but I switch to the in-car camera for loop-the-loops, since the external cam is nearly useless. (I might not need that with cspotcode's new camera mode, though; haven't tried it enough yet.)
Also, 'c' is right next to the dangerous space bar, and I normally have both hands on the joystick anyway.
Anyway, it turned out to be pretty easy to figure out the code, esp. with the help of kscope to keep track of what C function I was in. (I really don't like having function bodies not indented.) Here's a patch against the Radium 1.2 mania_drive.c:
Code:
--- mania_drive.c.orig 2006-08-21 17:56:03.000000000 -0300
+++ mania_drive.c~ 2007-10-20 02:24:13.000000000 -0300
@@ -2272,7 +2272,8 @@
if(raydium_key_last==1116) draw_debug*=-1;
-if(raydium_key_last==1032)
+// PJC- joystick buttons added.
+if(raydium_key_last==1032 || raydium_joy_click == 6)
create_car();
if(raydium_key_last==1008)
@@ -2282,7 +2283,8 @@
if(raydium_key_last==1122) { raydium_ode_time_change(10); }
if(raydium_key_last==1101) { raydium_ode_time_change(100); }
-if(raydium_key_last==1000+'c')
+// joystick buttons switch camera
+if(raydium_key_last==1000+'c' || raydium_joy_click == 3)
{
if(vue==3)
raydium_key_last=6;
@@ -2290,7 +2292,7 @@
raydium_key_last=3;
}
-if(raydium_key_last==5)
+if(raydium_key_last==5 || raydium_joy_click == 1)
{
vue=5;
raydium_projection_near=10;
@@ -2298,7 +2300,7 @@
raydium_window_view_update();
}
-if(raydium_key_last==6)
+if(raydium_key_last==6 || raydium_joy_click == 2)
{
vue=6;
raydium_projection_near=0.05 ;
This is extremely arbitrary. I wrote it for my own use. It's not often you look at your joystick and hard code the numbers written on the buttons into some source code.
The only problem now is that the X screensaver activates because there's no kbd or mouse input. Raydium should probably take care of that. Or ManiaDrive can maybe simulate a keypress every minute or so. That's more reliable than just disabling the X screensaver (e.g. xset s off), since gnome/kde/xscreensaver are all different. xine (the video player) sends fake events. mplayer disables the x screensaver and dpms, and re-enables on exit (which of course doesn't happen if it crashes).
If you decide to put something like this in the official version, you could make the highest-numbered joystick button be the restart-level button, and all others do the same thing as 'c'.
Anyway, great game. This is the kind of driving game I was looking for. vdrift is fun, but I find it too easy to spin out. OTOH, I don't want something with totally arcade physics. (Being a physicist, I appreciate good physics...) Also, I loved stunt-car racer on the atari ST, and Mania Drive has some similar aspects.