Index: joy.c
===================================================================
--- joy.c	(revision 752)
+++ joy.c	(revision 753)
@@ -836,8 +836,13 @@
 
             // Tell the app that everything is centered.
             raydium_joy_x = 0.0;
+            raydium_joy_axis[0] = 0.0;
+
             raydium_joy_y = 0.0;
+            raydium_joy_axis[1] = 0.0;
+
             raydium_joy_z = 0.0;
+            raydium_joy_axis[2] = 0.0;
 
             return;
         }
@@ -883,9 +888,13 @@
             value = HIDGetElementValue(device, element);
             if (value > 1) value = 1;
             raydium_joy_button[i] = value;
-            #ifdef joy_debug
-            if (value == 1) raydium_log("joy: button %i %s", i + 1, "pressed");
-            #endif
+            if (value == 1)
+            {
+                raydium_joy_click = i + 1;
+                #ifdef joy_debug
+                raydium_log("joy: button %i %s", i + 1, "pressed");
+                #endif
+            }
             element = element->pNext;
             ++i;
         }
@@ -1155,6 +1164,8 @@
     {
         // There are no joysticks.
         raydium_log("joy: FAILED (no device found)");
+        device = NULL;
+        joystick = NULL;
         raydium_joy = 0;
         return;
     }
@@ -1214,6 +1225,16 @@
         device = device->pNext;
     }
 
+    if (detectedDevices < 1)
+    {
+        // There are no joysticks.
+        raydium_log("joy: FAILED (no device found)");
+        device = NULL;
+        joystick = NULL;
+        raydium_joy = 0;
+        return;
+    }
+
     raydium_log("joy: OK (found %i)", detectedDevices);
 
     // Print information about the devices.