Fixed goofy logic in haptic device comparison code.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 20 Oct 2013 15:49:52 -0400
changeset 7846 70f1d63482d0
parent 7845 b92b8c52946c
child 7847 038da46576e6
Fixed goofy logic in haptic device comparison code. Mitchell Keith Bloch did the research on this bug, and came up with a slightly different patch than this. Partially fixes Bugzilla #2126.
src/haptic/windows/SDL_syshaptic.c
--- a/src/haptic/windows/SDL_syshaptic.c	Sun Oct 20 15:45:48 2013 -0400
+++ b/src/haptic/windows/SDL_syshaptic.c	Sun Oct 20 15:49:52 2013 -0400
@@ -636,9 +636,11 @@
 int
 SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
 {
-    if ((joystick->hwdata->bXInputHaptic == haptic->hwdata->bXInputHaptic) && (haptic->hwdata->userid == joystick->hwdata->userid)) {
-        return 1;
-    } else {
+    if ((joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) {
+        return 0;  /* one is XInput, one is not; not the same device. */
+    } else if (joystick->hwdata->bXInputHaptic) {  /* XInput */
+        return (haptic->hwdata->userid == joystick->hwdata->userid);
+    } else {  /* DirectInput */
         HRESULT ret;
         DIDEVICEINSTANCE hap_instance, joy_instance;