Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I need to use vibration for my java game, which is only available through xinput since I use xbox controllers. How can I achieve this with jna? I've never worked with dlls before so any help is appreciated. I looked at some tutorials but I haven't found anything about using structures (specifically XINPUT_VIBRATION vibration;) and such.

This is what I want to do in the DLL:

XINPUT_VIBRATION vibration;
ZeroMemory( &vibration, sizeof(XINPUT_VIBRATION) );
vibration.wLeftMotorSpeed = 32000; // use any value between 0-65535 here
vibration.wRightMotorSpeed = 16000; // use any value between 0-65535 here
XInputSetState( i, &vibration );

The above is taken from http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001(v=vs.85).aspx#setting_vibration_effects

Thanks!

share|improve this question
    
An alternative to using Java Native Access is to use the JINPUT library with which you can control an Xbox controller github.com/jinput/jinput –  Roy T. Aug 31 '14 at 21:57
    
I already use jinput, however it does not support vibration on the xbox controller since it uses directinput instead of xinput. –  David Sep 1 '14 at 9:19

1 Answer 1

up vote 0 down vote accepted

Thank you world, this library works: https://github.com/StrikerX3/JXInput

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.