Applied patch [ 1374618 ] Fix wxJoystick::GetXMin/Max (bug 1374480)
Ryan Norton git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -62,10 +62,6 @@ enum
|
|||||||
wxJS_AXIS_RUDDER,
|
wxJS_AXIS_RUDDER,
|
||||||
wxJS_AXIS_U,
|
wxJS_AXIS_U,
|
||||||
wxJS_AXIS_V,
|
wxJS_AXIS_V,
|
||||||
|
|
||||||
//For the Get[XXX](Min/Max) functions
|
|
||||||
wxJS_AXIS_MAX = 255, //32767,
|
|
||||||
wxJS_AXIS_MIN = 0, //-32767
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -74,12 +70,18 @@ enum
|
|||||||
class wxHIDJoystick : public wxHIDDevice
|
class wxHIDJoystick : public wxHIDDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
wxHIDJoystick();
|
||||||
|
~wxHIDJoystick();
|
||||||
|
|
||||||
bool Create(int nWhich);
|
bool Create(int nWhich);
|
||||||
virtual void BuildCookies(wxCFArray& Array);
|
virtual void BuildCookies(wxCFArray& Array);
|
||||||
void MakeCookies(wxCFArray& Array);
|
void MakeCookies(wxCFArray& Array);
|
||||||
IOHIDElementCookie* GetCookies();
|
IOHIDElementCookie* GetCookies();
|
||||||
IOHIDQueueInterface** GetQueue();
|
IOHIDQueueInterface** GetQueue();
|
||||||
|
|
||||||
|
int m_nXMax, m_nYMax, m_nZMax, m_nRudderMax, m_nUMax, m_nVMax,
|
||||||
|
m_nXMin, m_nYMin, m_nZMin, m_nRudderMin, m_nUMin, m_nVMin;
|
||||||
|
|
||||||
friend class wxJoystick;
|
friend class wxJoystick;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,6 +111,19 @@ private:
|
|||||||
// IMPLEMENTATION
|
// IMPLEMENTATION
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
// wxGetIntFromCFDictionary
|
||||||
|
//
|
||||||
|
// Helper function that gets a integer from a dictionary key
|
||||||
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
void wxGetIntFromCFDictionary(CFTypeRef cfDict, CFStringRef key, int* pOut)
|
||||||
|
{
|
||||||
|
CFNumberGetValue(
|
||||||
|
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) cfDict,
|
||||||
|
key),
|
||||||
|
kCFNumberIntType, pOut);
|
||||||
|
}
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
//
|
//
|
||||||
// wxJoystick
|
// wxJoystick
|
||||||
@@ -320,35 +335,34 @@ bool wxJoystick::ReleaseCapture()
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// wxJoystick::Get[XXX]
|
// wxJoystick::Get[XXX]
|
||||||
//
|
//
|
||||||
// All values in hid range from 0 to 255, making these all kind of
|
// Gets the minimum and maximum values for each axis, returning 0 if the
|
||||||
// superflous. These are mainly here due to the msw-centric api
|
// axis doesn't exist.
|
||||||
// that wxJoystick has... it should REALLY do its own scaling... oh well :)
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int wxJoystick::GetXMin() const
|
int wxJoystick::GetXMin() const
|
||||||
{ return wxJS_AXIS_MIN; }
|
{ return m_hid->m_nXMin; }
|
||||||
int wxJoystick::GetYMin() const
|
int wxJoystick::GetYMin() const
|
||||||
{ return wxJS_AXIS_MIN; }
|
{ return m_hid->m_nYMin; }
|
||||||
int wxJoystick::GetZMin() const
|
int wxJoystick::GetZMin() const
|
||||||
{ return wxJS_AXIS_MIN; }
|
{ return m_hid->m_nZMin; }
|
||||||
int wxJoystick::GetUMin() const
|
|
||||||
{ return wxJS_AXIS_MIN; }
|
|
||||||
int wxJoystick::GetVMin() const
|
|
||||||
{ return wxJS_AXIS_MIN; }
|
|
||||||
int wxJoystick::GetRudderMin() const
|
int wxJoystick::GetRudderMin() const
|
||||||
{ return wxJS_AXIS_MIN; }
|
{ return m_hid->m_nRudderMin; }
|
||||||
|
int wxJoystick::GetUMin() const
|
||||||
|
{ return m_hid->m_nUMin; }
|
||||||
|
int wxJoystick::GetVMin() const
|
||||||
|
{ return m_hid->m_nVMin; }
|
||||||
|
|
||||||
int wxJoystick::GetXMax() const
|
int wxJoystick::GetXMax() const
|
||||||
{ return wxJS_AXIS_MAX; }
|
{ return m_hid->m_nXMax; }
|
||||||
int wxJoystick::GetYMax() const
|
int wxJoystick::GetYMax() const
|
||||||
{ return wxJS_AXIS_MAX; }
|
{ return m_hid->m_nYMax; }
|
||||||
int wxJoystick::GetZMax() const
|
int wxJoystick::GetZMax() const
|
||||||
{ return wxJS_AXIS_MAX; }
|
{ return m_hid->m_nZMax; }
|
||||||
int wxJoystick::GetUMax() const
|
|
||||||
{ return wxJS_AXIS_MAX; }
|
|
||||||
int wxJoystick::GetVMax() const
|
|
||||||
{ return wxJS_AXIS_MAX; }
|
|
||||||
int wxJoystick::GetRudderMax() const
|
int wxJoystick::GetRudderMax() const
|
||||||
{ return wxJS_AXIS_MAX; }
|
{ return m_hid->m_nRudderMax; }
|
||||||
|
int wxJoystick::GetUMax() const
|
||||||
|
{ return m_hid->m_nUMax; }
|
||||||
|
int wxJoystick::GetVMax() const
|
||||||
|
{ return m_hid->m_nVMax; }
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// wxJoystick::Get[XXX]
|
// wxJoystick::Get[XXX]
|
||||||
@@ -371,10 +385,10 @@ int wxJoystick::GetPollingMax() const
|
|||||||
// Just queries the native hid implementation if the cookie was found
|
// Just queries the native hid implementation if the cookie was found
|
||||||
// when enumerating the cookies of the joystick device
|
// when enumerating the cookies of the joystick device
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool wxJoystick::HasRudder() const
|
|
||||||
{ return m_hid->HasElement(wxJS_AXIS_RUDDER); }
|
|
||||||
bool wxJoystick::HasZ() const
|
bool wxJoystick::HasZ() const
|
||||||
{ return m_hid->HasElement(wxJS_AXIS_Z); }
|
{ return m_hid->HasElement(wxJS_AXIS_Z); }
|
||||||
|
bool wxJoystick::HasRudder() const
|
||||||
|
{ return m_hid->HasElement(wxJS_AXIS_RUDDER); }
|
||||||
bool wxJoystick::HasU() const
|
bool wxJoystick::HasU() const
|
||||||
{ return m_hid->HasElement(wxJS_AXIS_U); }
|
{ return m_hid->HasElement(wxJS_AXIS_U); }
|
||||||
bool wxJoystick::HasV() const
|
bool wxJoystick::HasV() const
|
||||||
@@ -404,6 +418,26 @@ bool wxJoystick::HasPOVCTS() const
|
|||||||
//
|
//
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// wxHIDJoystick ctor
|
||||||
|
//
|
||||||
|
// Initializes the min/max members
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
wxHIDJoystick::wxHIDJoystick() :
|
||||||
|
m_nXMax(0), m_nYMax(0), m_nZMax(0), m_nRudderMax(0), m_nUMax(0), m_nVMax(0),
|
||||||
|
m_nXMin(0), m_nYMin(0), m_nZMin(0), m_nRudderMin(0), m_nUMin(0), m_nVMin(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// wxHIDJoystick dtor
|
||||||
|
//
|
||||||
|
// Nothing...
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
wxHIDJoystick::~wxHIDJoystick()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// wxHIDJoystick::Create
|
// wxHIDJoystick::Create
|
||||||
//
|
//
|
||||||
@@ -474,11 +508,11 @@ void wxHIDJoystick::MakeCookies(wxCFArray& Array)
|
|||||||
{
|
{
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsageKey)),
|
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsageKey)),
|
||||||
kCFNumberLongType, &nUsage);
|
kCFNumberIntType, &nUsage);
|
||||||
|
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsagePageKey)),
|
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsagePageKey)),
|
||||||
kCFNumberLongType, &nPage);
|
kCFNumberIntType, &nPage);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
|
wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
|
||||||
@@ -487,23 +521,43 @@ void wxHIDJoystick::MakeCookies(wxCFArray& Array)
|
|||||||
AddCookieInQueue(Array[i], nUsage-1 );
|
AddCookieInQueue(Array[i], nUsage-1 );
|
||||||
else if (nPage == kHIDPage_GenericDesktop)
|
else if (nPage == kHIDPage_GenericDesktop)
|
||||||
{
|
{
|
||||||
|
//axis...
|
||||||
switch(nUsage)
|
switch(nUsage)
|
||||||
{
|
{
|
||||||
case kHIDUsage_GD_X:
|
case kHIDUsage_GD_X:
|
||||||
AddCookieInQueue(Array[i], wxJS_AXIS_X);
|
AddCookieInQueue(Array[i], wxJS_AXIS_X);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMaxKey),
|
||||||
|
&m_nXMax);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMinKey),
|
||||||
|
&m_nXMin);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_GD_Y:
|
case kHIDUsage_GD_Y:
|
||||||
AddCookieInQueue(Array[i], wxJS_AXIS_Y);
|
AddCookieInQueue(Array[i], wxJS_AXIS_Y);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMaxKey),
|
||||||
|
&m_nYMax);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMinKey),
|
||||||
|
&m_nYMin);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_GD_Z:
|
case kHIDUsage_GD_Z:
|
||||||
AddCookieInQueue(Array[i], wxJS_AXIS_Z);
|
AddCookieInQueue(Array[i], wxJS_AXIS_Z);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMaxKey),
|
||||||
|
&m_nZMax);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMinKey),
|
||||||
|
&m_nZMin);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nPage == kHIDPage_Simulation && nUsage == kHIDUsage_Sim_Rudder)
|
else if (nPage == kHIDPage_Simulation && nUsage == kHIDUsage_Sim_Rudder)
|
||||||
|
{
|
||||||
|
//rudder...
|
||||||
AddCookieInQueue(Array[i], wxJS_AXIS_RUDDER );
|
AddCookieInQueue(Array[i], wxJS_AXIS_RUDDER );
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMaxKey),
|
||||||
|
&m_nRudderMax);
|
||||||
|
wxGetIntFromCFDictionary(Array[i], CFSTR(kIOHIDElementMinKey),
|
||||||
|
&m_nRudderMin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user