]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/joystick.cpp
Disable wxUSE_ENH_METAFILE for wxGTK builds.
[wxWidgets.git] / src / unix / joystick.cpp
index f5ad7183461923001ea753618394d541b1e3f042..27b3b6cb74a8d67e254cc800c00ac3bc9c3134be 100644 (file)
 #ifndef WX_PRECOMP
     #include "wx/event.h"
     #include "wx/window.h"
+    #include "wx/log.h"
 #endif //WX_PRECOMP
 
+#include "wx/thread.h"
+
 #include <linux/joystick.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -100,7 +103,7 @@ void wxJoystickThread::SendEvent(wxEventType type, long ts, int change)
     jwx_event.SetEventObject(m_catchwin);
 
     if (m_catchwin)
-        m_catchwin->AddPendingEvent(jwx_event);
+        m_catchwin->GetEventHandler()->AddPendingEvent(jwx_event);
 }
 
 void* wxJoystickThread::Entry()
@@ -134,6 +137,14 @@ void* wxJoystickThread::Entry()
 
             if ((j_evt.type & JS_EVENT_AXIS) && (j_evt.number < wxJS_MAX_AXES))
             {
+                // Ignore invalid axis.
+                if ( j_evt.number >= wxJS_MAX_AXES )
+                {
+                    wxLogDebug(wxS("Invalid axis index %d in joystick message."),
+                               j_evt.number);
+                    continue;
+                }
+
                 if (   (m_axe[j_evt.number] + m_threshold < j_evt.value)
                     || (m_axe[j_evt.number] - m_threshold > j_evt.value) )
             {
@@ -394,7 +405,7 @@ int wxJoystick::GetNumberButtons() const
     if (m_device != -1)
         ioctl(m_device, JSIOCGBUTTONS, &nb);
 
-    if (nb > wxJS_MAX_BUTTONS)
+    if ((int)nb > wxJS_MAX_BUTTONS)
         nb = wxJS_MAX_BUTTONS;
 
     return nb;
@@ -407,7 +418,7 @@ int wxJoystick::GetNumberAxes() const
     if (m_device != -1)
         ioctl(m_device, JSIOCGAXES, &nb);
 
-    if (nb > wxJS_MAX_AXES)
+    if ((int)nb > wxJS_MAX_AXES)
         nb = wxJS_MAX_AXES;
 
     return nb;