Go to Post It never stops. Championships will be in your head forever!!! MWHAHAHAHA!!! - vadyr [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 15-04-2014, 15:19
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
How To: Xbox Controller Vibration

I have noticed a lot of question regarding how to access the vibration controls of an Xbox controller connected to the driver station.

So I started investigating and found LabVIEW can use DLLs, and remembered that Xbox controllers use the xinput DLL to control this feature of the controllers.

This is the function definition of XInputSetState in the Xinput DLL found on most, if not all Windows computers. I am using the Xinput9_1_0.dll found in C:\Windows\System32. If you do not have this DLL, install the latest directx available.
http://msdn.microsoft.com/en-us/libr...=v s.85).aspx

dwUserIndex is the controller index of the controller you want to use, you can identify the number by seeing which "player" light is lit on the controller.

pVibration is a struct in C++ but a cluster in the LabVIEW code attached. The vibration value is from 0 to 65536, higher means more vibration.

The attached code is a LabVIEW library that you place in the user.lib directory of your LabVIEW install. For example mine is
Code:
C:\Program Files (x86)\National Instruments\LabVIEW 2013\user.lib
Unzip the folder Xinput9_1_0 to that directory and open up LabVIEW with either a new VI or your current Dashboard Project. The example pictures below is a new, default Dashboard Project.


  1. Start by dragging the XinputSetState VI to you block diagram.
  2. Right click on the pVibration terminal, go to create, then click constant
  3. delete the wire branch connecting the constant to XInputSetState
  4. create a bundle by name and place it on the diagram
  5. connect the cluster constant to the bundle by name
  6. create controls, constants, or what ever to the input terminals of wLeftMotorSpeed or wRightMotorSpeed
    Left Motor is the 'rough' vibration while the Right Motor is the 'smooth' vbration
  7. Run the project and give it a value between 0 and 65536
  8. Your controller is Vibrating!

Here is a small video demonstrating the library (Note the controller in the video is wireless, this library will work just the same with wired controllers): https://www.dropbox.com/s/swrerlsmom...415_141309.mp4

Remember to set the vibration value to 0 before exiting, or your controller will vibrate until you do set it!

The controller will be pulling power from your driver station's USB hub. Be sure it does not go over the limit for your hub or your may lose connectivity to other devices connected to the same hub.

This method of interfacing with the XInput DLL should transfer to the SmartDashboard as well. If anyone accomplishes this, send me a private message with instructions and I will update the thread.
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer

Last edited by MDAWG25 : 15-04-2014 at 16:23.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi