jsWindows: fail gracefully when joyGetDevCaps() returns undocumented values
According to Pfeffer's report[1] and many other messages on the Internet, joyGetDevCaps() can return the (so far) undocumented value 165, which some say is JOYERR_PARMS. Since this is a valid return code for joyGetPosEx() (not joyGetDevCaps()!), handle a few return codes from that function too, and don't throw an exception when joyGetDevCaps()'s return value is not one of the documented ones (we simply can't trust its documentation). [1] https://sourceforge.net/p/flightgear/mailman/message/36657149/
This commit is contained in:
parent
7db06300c0
commit
df352346ad
1 changed files with 11 additions and 3 deletions
14
3rdparty/joystick/jsWindows.cxx
vendored
14
3rdparty/joystick/jsWindows.cxx
vendored
|
@ -51,12 +51,20 @@ static std::string joyGetDevCaps_errorString(MMRESULT errorCode)
|
||||||
"invalid";
|
"invalid";
|
||||||
case MMSYSERR_INVALPARAM:
|
case MMSYSERR_INVALPARAM:
|
||||||
return "invalid parameter passed to joyGetDevCaps()";
|
return "invalid parameter passed to joyGetDevCaps()";
|
||||||
|
// joyGetDevCaps() appears to return undocumented values, see
|
||||||
|
// https://sourceforge.net/p/flightgear/mailman/message/36657149/
|
||||||
|
case MMSYSERR_BADDEVICEID: // fallthrough
|
||||||
|
case JOYERR_PARMS:
|
||||||
|
return "invalid joystick identifier";
|
||||||
|
case JOYERR_UNPLUGGED:
|
||||||
|
return "joystick not connected to the system";
|
||||||
case JOYERR_NOERROR:
|
case JOYERR_NOERROR:
|
||||||
return "no error";
|
return "no error";
|
||||||
default:
|
default:
|
||||||
throw sg_exception(
|
// Don't throw an exception, since joyGetDevCaps()'s documentation isn't
|
||||||
"Unexpected value passed to joyGetDevCaps_errorString(): "
|
// correct (we can't be sure to have covered all possible return values).
|
||||||
+ std::to_string(errorCode));
|
return "unexpected value passed to joyGetDevCaps_errorString(): "
|
||||||
|
+ std::to_string(errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw sg_exception("This code path should be unreachable; value "
|
throw sg_exception("This code path should be unreachable; value "
|
||||||
|
|
Loading…
Add table
Reference in a new issue