[patch] Low magnitudes with XInput haptics

"Trent Gamblin" <[email protected]> Fri, 26 May 2017 22:44:38 -0600
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
------=_20170526224438_65535
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

I recently tried the haptics support on a couple joysticks. One worked seemingly fine (an Xbox 360 pad) while the
other (Logitech F710) I can barely detect a rumble using the basic rumble support (SDL_RumbleInit etc.) I dug through
the code a little and found that although SDL_HapticEffect has a max magnitude of 32767, XInput expects max to be
65535[1]. I attached a patch. I'm not certain it's completely correct as I didn't quite understand what "180 degree
phase shift" for negative magnitudes means, but with positive values this makes my gamepad move.

[1]https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinput_vibration(v=vs.85).aspx

Best regards,

Trent Gamblin

------=_20170526224438_65535
Content-Type: application/octet-stream; name="xihaptic.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="xihaptic.diff"

ZGlmZiAtciAxMDU1MmFlNjM0Y2Egc3JjL2hhcHRpYy93aW5kb3dzL1NETF94aW5wdXRoYXB0aWMu
YwotLS0gYS9zcmMvaGFwdGljL3dpbmRvd3MvU0RMX3hpbnB1dGhhcHRpYy5jCUZyaSBNYXkgMjYg
MjI6NDU6NTIgMjAxNyArMDIwMAorKysgYi9zcmMvaGFwdGljL3dpbmRvd3MvU0RMX3hpbnB1dGhh
cHRpYy5jCUZyaSBNYXkgMjYgMjI6MzI6NTcgMjAxNyAtMDYwMApAQCAtMjc4LDggKzI3OCw5IEBA
CiB7CiAgICAgWElOUFVUX1ZJQlJBVElPTiAqdmliID0gJmVmZmVjdC0+aHdlZmZlY3QtPnZpYnJh
dGlvbjsKICAgICBTRExfYXNzZXJ0KGRhdGEtPnR5cGUgPT0gU0RMX0hBUFRJQ19MRUZUUklHSFQp
OwotICAgIHZpYi0+d0xlZnRNb3RvclNwZWVkID0gZGF0YS0+bGVmdHJpZ2h0LmxhcmdlX21hZ25p
dHVkZTsKLSAgICB2aWItPndSaWdodE1vdG9yU3BlZWQgPSBkYXRhLT5sZWZ0cmlnaHQuc21hbGxf
bWFnbml0dWRlOworICAgIC8qIFNETF9IYXB0aWNFZmZlY3QgaGFzIG1heCBtYWduaXR1ZGUgb2Yg
MzI3NjcsIFhJbnB1dCBleHBlY3RzIDY1NTM1IG1heCwgc28gbXVsdGlwbHkgKi8KKyAgICB2aWIt
PndMZWZ0TW90b3JTcGVlZCA9IGRhdGEtPmxlZnRyaWdodC5sYXJnZV9tYWduaXR1ZGUgKiAyOwor
ICAgIHZpYi0+d1JpZ2h0TW90b3JTcGVlZCA9IGRhdGEtPmxlZnRyaWdodC5zbWFsbF9tYWduaXR1
ZGUgKiAyOwogICAgIFNETF9Mb2NrTXV0ZXgoaGFwdGljLT5od2RhdGEtPm11dGV4KTsKICAgICBp
ZiAoaGFwdGljLT5od2RhdGEtPnN0b3BUaWNrcykgeyAgLyogcnVubmluZyByaWdodCBub3c/IFVw
ZGF0ZSBpdC4gKi8KICAgICAgICAgWElOUFVUU0VUU1RBVEUoaGFwdGljLT5od2RhdGEtPnVzZXJp
ZCwgdmliKTsK
------=_20170526224438_65535
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

------=_20170526224438_65535--