X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6733873f5bc5de9ef538533da786250de9dd9c7..8c6471af3cf87c97f5f1564c601237caf9fdeb60:/src/unix/joystick.cpp diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index f5ad718346..cf9cc33b3e 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -4,7 +4,6 @@ // Author: Ported to Linux by Guilhem Lavaux // Modified by: // Created: 05/23/98 -// RCS-ID: $Id$ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,8 +18,11 @@ #ifndef WX_PRECOMP #include "wx/event.h" #include "wx/window.h" + #include "wx/log.h" #endif //WX_PRECOMP +#include "wx/thread.h" + #include #include #include @@ -100,7 +102,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 +136,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 +404,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 +417,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;